-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
34 lines (26 loc) · 903 Bytes
/
makefile
File metadata and controls
34 lines (26 loc) · 903 Bytes
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
CC=gcc
INCLUDE_DIR =inc
CC_FLAG=-Wall -g
SRC=code/src code/util .
OBJ_FLAGS=-Wall -c
LDFLAGS +=-lz
EXECUTABLES=a.out
SOURCES=$(foreach DIR, $(SRC),$(wildcard $(DIR)/*.c))
INCLUDE += $(foreach includedir, $(INCLUDE_DIR),-I $(includedir))
INCLUDE_FILES += $(foreach includedir, $(INCLUDE_DIR),$(includedir)/*.h)
OBJS_FOLDER=.objs
OBJECTS := $(addprefix ${OBJS_FOLDER}/,$(SOURCES:.c=.o))
all: ${EXECUTABLES}
.PHONY: all clean distclean
${OBJS_FOLDER}:
mkdir -p ${foreach s, ${SRC}, ${OBJS_FOLDER}/${s}}
${EXECUTABLES}: ${OBJS_FOLDER} ${OBJECTS} ${INCLUDE_FILES}
${CC} ${INCLUDE} ${OPT} ${CC_FLAG} ${LDFLAGS} ${OBJECTS} -o $@ && ctags -R --c-kinds=+p --fields=+S
#if any header files gets modified compile the whole project again
.objs/%.o: %.c ${INCLUDE_FILES}
${CC} ${INCLUDE} ${OPT} ${OBJ_FLAGS} $< -o $@
clean:
rm -rf ${EXECUTABLES} ${OBJS_FOLDER}
cleanscm:
rm -rf .scm
distclean: clean