-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
50 lines (35 loc) · 1.1 KB
/
makefile
File metadata and controls
50 lines (35 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
CC=gcc
# general set of flags
FLAGS=-g -Wall -Werror -Wpedantic
HEADERSDIR=typedefs
SRCDIR=src
SRCS := $(wildcard ${SRCDIR}/*.c)
SRCS := $(filter-out src/main.c, $(SRCS))
OBJDIR=obj
OBJS=$(patsubst ${SRCDIR}/%.c, ${OBJDIR}/%.o, ${SRCS})
# literally take everything that is in the 3rd param, and replace every
# element that looks like the 1st with the 2nd param's pattern
# This way, every source file produces an object file
BINDIR=bin
EXECUTABLE=${BINDIR}/okengine
####################################
# including bin and obj directories as dependencies so they can be created
${EXECUTABLE}: ${BINDIR} ${OBJDIR} ${OBJS}
${CC} ${FLAGS} ${SRCDIR}/main.c ${OBJS} -o $@
####################################
# header files are just dependencies of obj files, if they change, we recompile
${OBJDIR}/%.o: ${SRCDIR}/%.c ${SRCDIR}/${HEADERSDIR}/%.h
${CC} ${FLAGS} -c $< -o $@
####################################
${OBJDIR}:
mkdir $@
${BINDIR}:
mkdir $@
###################################
clean:
${RM} -r ${BINDIR}/* ${OBJDIR}/*;
${RM} -r **/*.dSYM;
again:
make clean; make; make run
run:
./${EXECUTABLE}