-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
80 lines (65 loc) · 2.22 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# compiler to use gcc, clang, g++, etc.
CC = gcc
# compiler flags (add -g for debug)
CFLAGS = -Wall -O3
# includes (header file locations)
INCLUDES = -I/include/ -Iinclude/
# all the files to include in the generated .tar
TAR_FILES = include/*.h src/*.c test/*.c LICENSE.txt Makefile README.md conf.ini
# risky executable
MAIN_DEPS = include/ini.h src/ini.c \
include/log.h src/log.c \
include/dna.h src/dna.c \
include/risk.h src/risk.c \
src/main.c
MAIN_OBJS = $(MAIN_DEPS:.c=.o)
MAIN = risky
# log library test executable
LOG_DEPS = include/log.h src/log.c test/testLOG.c
LOG_OBJS = $(LOG_DEPS:.c=.o)
LOG_TEST = logtest
# ini library test executable
INI_DEPS = include/ini.h src/ini.c test/testINI.c
INI_OBJS = $(INI_DEPS:.c=.o)
INI_TEST = initest
# dna library test executable
DNA_DEPS = include/dna.h src/dna.c test/testDNA.c
DNA_OBJS = $(DNA_DEPS:.c=.o)
DNA_TEST = dnatest
# risk library test executable
RISK_DEPS = include/risk.h src/risk.c test/testRISK.c
RISK_OBJS = $(RISK_DEPS:.c=.o)
RISK_TEST = risktest
# targets not dependent on files so make doesnt get confused
.PHONY: default build rebuild all install clean tar tests
default: $(MAIN)
build: $(MAIN)
rebuild: clean build
all: $(MAIN)
$(MAIN): $(MAIN_OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(MAIN_OBJS)
.c.o:
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
install: rebuild
\cp $(MAIN) /usr/bin/
clean:
\rm -f *.o *~ src/*.o src/*~ test/*.o test/*~ $(MAIN) $(DNA_TEST) $(INI_TEST) $(RISK_TEST) $(LOG_TEST)
tar:
\tar -cvf $(MAIN).tar $(TAR_FILES)
tests: $(DNA_TEST) $(INI_TEST) $(RISK_TEST) $(LOG_TEST)
$(DNA_TEST): $(DNA_OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(DNA_TEST) $(DNA_OBJS)
./$(DNA_TEST)
\rm -f *.o *~ src/*.o src/*~ test/*.o test/*~ $(DNA_TEST)
$(INI_TEST): $(INI_OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(INI_TEST) $(INI_OBJS)
./$(INI_TEST)
\rm -f *.o *~ src/*.o src/*~ test/*.o test/*~ $(INI_TEST)
$(RISK_TEST): $(RISK_OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(RISK_TEST) $(RISK_OBJS)
./$(RISK_TEST)
\rm -f *.o *~ src/*.o src/*~ test/*.o test/*~ $(RISK_TEST)
$(LOG_TEST): $(LOG_OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(LOG_TEST) $(LOG_OBJS)
./$(LOG_TEST)
\rm -f *.o *~ src/*.o src/*~ test/*.o test/*~ $(LOG_TEST)