-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
54 lines (45 loc) · 1.07 KB
/
makefile
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
51
52
53
54
PROGNAME=SHA1check
CC=gcc
CF=-c -Wall --optimize -I headers
CFD=-c -Wall -g -fsanitize=address -I headers
NUM=1 2
NAMES=args compare dir files getdent hashing paths main
SRC=$(foreach name,$(NAMES),$(name).c)
OBJECTS=$(foreach name,$(NAMES),$(name).o)
DBGOBJ=$(foreach name,$(NAMES),$(name)-debug.o)
prod: prog clean
prog: $(OBJECTS)
$(CC) $(OBJECTS) -lcrypto -o $(PROGNAME)
debug: prog-debug clean
prog-debug: $(DBGOBJ)
$(CC) $(DBGOBJ) -g -fsanitize=address -lcrypto -o $(PROGNAME)-debug
$(DBGOBJ): $(SRC)
@echo Building $(PROGNAME)-debug
@for i in $(NUM) ; do \
echo;\
done
@for file in $(SRC); do \
$(CC) $(CFD) $$file -o $${file%.c}-debug.o; \
if [ $$? = 0 ]; then \
echo $${file} compiled ;\
else \
echo $${file} did not compile ;\
exit 1 ;\
fi \
done
$(OBJECTS): $(SRC)
@echo Building $(PROGNAME)
@for i in $(NUM) ; do \
echo;\
done
@for file in $(SRC); do \
$(CC) $(CF) $$file -o $${file%.c}.o; \
if [ $$? = 0 ]; then \
echo $${file} compiled ;\
else \
echo $${file} did not compile ;\
exit 1 ;\
fi \
done
clean:
rm -rf *.o