forked from gparmer/memory_the_final_frontier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (35 loc) · 1.09 KB
/
Makefile
File metadata and controls
44 lines (35 loc) · 1.09 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
BINARY=bin
CODEDIRS=.
INCDIRS=.
CC=gcc
OPT=-O0
# generate files that encode make rules for the .h dependencies
DEPFLAGS=-MP -MD
LIBS=-lpthread
# automatically add the -I onto each include directory
CFLAGS=-Wall -Wextra -Wno-unused-but-set-variable -Wno-unused-label -Wno-discarded-qualifiers -g $(foreach D,$(INCDIRS),-I$(D)) $(OPT) $(DEPFLAGS)
# for-style iteration (foreach) and regular expression completions (wildcard)
CFILES=$(foreach D,$(CODEDIRS),$(wildcard $(D)/*.c))
# regular expression replacement
OBJECTS=$(patsubst %.c,%.o,$(CFILES))
DEPFILES=$(patsubst %.c,%.d,$(CFILES))
all: $(BINARY)
$(BINARY): $(OBJECTS)
$(CC) -o $@ $^ $(LIBS)
# only want the .c file dependency here, thus $< instead of $^.
#
%.o:%.c
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -rf $(BINARY) $(OBJECTS) $(DEPFILES)
# shell commands are a set of keystrokes away
distribute: clean
tar zcvf dist.tgz *
# @ silences the printing of the command
# $(info ...) prints output
diff:
$(info The status of the repository, and the volume of per-file changes:)
@git status
@git diff --stat
# include the dependencies
-include $(DEPFILES)