-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (39 loc) · 824 Bytes
/
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
#
# Variable Assigments
#
PROJECT_NAME = output
# Tools
CPP = g++
GDB = gdb
RM = rm
PY = python3
AR = ar rcs
# Sources
SOURCE_CPP_LIB = $(wildcard lib/*.cpp)
SOURCE_CPP = $(wildcard *.cpp)
SOURCE_AR = $(wildcard lib/*.a)
TEST_PATH = $(wildcard test/test.py)
# Option flags
GPP_FLAGS = -Wall -Wextra -pedantic -O3
GDB_FLAGS = $(GPP_FLAGS) -g -ggdb
#
# Rules
#
.PHONY: all clean debug test lib
all: $(patsubst %.cpp, %.o, $(SOURCE_CPP))
$(CPP) -o $(PROJECT_NAME).out $^ -L. lib/*.a
clean:
$(RM) -f *.o lib/*.o lib/*.a *.out ==
debug: dbg.out
$(GDB) --args $< a.out
test:
$(PY) $(TEST_PATH)
lib: $(patsubst %.cpp, %.a, $(SOURCE_CPP_LIB))
debug.o:
$(CPP) $(GDB_FLAGS) -c -o $@ $(SOURCE_CPP)
dbg.out: debug.o
$(CPP) -o $@ $^ -L. lib/*.a
%.a: %.o
$(AR) $@ $^
%.o: $.cpp
$(CPP) $(GPP_FLAGS) -c -o $@ $^