-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
125 lines (100 loc) · 2.72 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
.DEFAULT_GOAL := all
# Options for valgrind: "on"/"off"
check_memory = "off"
# Options for profiling: "on"/"off"
check_profiling = "off"
# Options for optimisation
optimisation = "on"
# Library files
SRC_DIR = src/
# Main runnable files
CPP_DIR = src/cpp/
# Object files generated by compilation
OBJ_DIR = obj/
# Test source files
TEST_SRC_DIR = src/test/
# Test object files generated by compilation
TEST_OBJ_DIR = test_obj/
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
$(TEST_OBJ_DIR):
mkdir -p $(TEST_OBJ_DIR)
CC = g++
CCFLAGS = -I./$(SRC_DIR) -I./$(CPP_DIR) -Wall -Wextra
CCTESTFLAGS = -I./$(TEST_SRC_DIR)
ifeq ($(check_memory), "on")
CCFLAGS += -g -O0
endif
ifeq ($(check_profiling), "on")
CCFLAGS += -pg
endif
ifeq ($(optimisation), "on")
CCFLAGS += -O2
endif
_HEADERS = exception.h \
constants.h \
utilities.h \
rand_maths.h \
activity_tracker.h \
sequence.h \
point_mutation_models.h \
mutator.h \
burster.h \
pool.h \
representative.h \
families.h \
output.h \
simulation.h
HEADERS := $(addprefix $(SRC_DIR), $(_HEADERS))
_SRCS = utilities.o \
rand_maths.o \
activity_tracker.o \
sequence.o \
point_mutation_models.o \
mutator.o \
burster.o \
pool.o \
representative.o \
families.o \
output.o \
simulation.o
SRCS := $(addprefix $(OBJ_DIR), $(_SRCS))
_OBJS = main.o
OBJS := $(addprefix $(OBJ_DIR), $(_OBJS))
_TEST_HEADERS = test_header.h \
test_rand_maths.h \
test_activity_tracker.h \
test_sequence.h \
test_point_mutation_models.h \
test_mutator.h \
test_pool.h \
test_simulation.h \
test_utilities.h
TEST_HEADERS := $(addprefix $(TEST_SRC_DIR), $(_TEST_HEADERS))
_TEST_OBJS = test.o
TEST_OBJS := $(addprefix $(TEST_OBJ_DIR), $(_TEST_OBJS))
# Currently only test is up and running
TARGET = retrocombinator
TEST_TARGET = test_retrocombinator
$(OBJ_DIR)%.o: $(SRC_DIR)%.cpp $(HEADERS) | $(OBJ_DIR)
$(CC) -c $(SRC_DIR)$*.cpp -o $(OBJ_DIR)$*.o $(CCFLAGS)
$(OBJ_DIR)%.o: $(CPP_DIR)%.cpp $(HEADERS) | $(OBJ_DIR)
$(CC) -c $(CPP_DIR)$*.cpp -o $(OBJ_DIR)$*.o $(CCFLAGS)
$(TARGET): $(OBJS) $(SRCS)
$(CC) -o $@ $^ $(CCFLAGS)
$(TEST_OBJ_DIR)%.o: $(TEST_SRC_DIR)%.cpp $(HEADERS) $(TEST_HEADERS) | $(TEST_OBJ_DIR)
$(CC) -c $(TEST_SRC_DIR)$*.cpp -o $(TEST_OBJ_DIR)$*.o $(CCFLAGS) $(CCTESTFLAGS)
$(TEST_TARGET): $(TEST_OBJS) $(SRCS)
$(CC) -o $@ $^ $(CCFLAGS) $(CCTESTFLAGS)
.PHONY: target
target: $(TARGET)
.PHONY: test
test: $(TEST_TARGET)
.PHONY: all
all: target test
.PHONY: clean
clean:
rm -f $(OBJ_DIR)*.o $(TARGET)
rm -d -f $(OBJ_DIR)
rm -f $(TEST_OBJ_DIR)*.o $(TEST_OBJ_DIR)*.out $(TEST_TARGET)
rm -d -f $(TEST_OBJ_DIR)