-
Notifications
You must be signed in to change notification settings - Fork 36
/
Makefile
53 lines (42 loc) · 1.43 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
CXX=g++-8
FLAGS=-std=c++11 -Wall -Wextra -fsanitize=address,leak
files = $(basename $(notdir $(filter-out $(wildcard source/**/*.test.cpp), $(wildcard source/$(1)/*.cpp))))
SORTS=$(call files,Sorts)
LISTS=$(call files,LinkedList)
TREES=$(call files,Trees)
ALGORITHMS=$(basename $(notdir $(wildcard source/Algorithms/*.cpp)))
TARGETS=$(call files,*) $(ALGORITHMS)
# Object Files
%.o: source/*/%.cpp
$(CXX) $(FLAGS) $(if $(RECURSIVE),-DRECURSIVE=$(RECURSIVE)) -c $^
# Dependencies
Graph: Graph.test.o
Hashtable: Hashtable.test.o String.o functions.o
Stack: Stack.test.o SLL.o
Queue: Queue.test.o SLL.o
Deque: Deque.test.o DLL.o
functions: functions.test.o
String: String.test.o functions.o
# Algorithm Dependencies
twostack.test: twostack.test.o Stack.o SLL.o String.o functions.o
lexicographic.test: lexicographic.test.o Trie.o String.o functions.o
hamiltoniancycle.test: Graph.o
karprabin.test: String.o functions.o
djikstra.test: Graph.o functions.o
a-star.test: String.o functions.o
# Complex Depedencies
.SECONDEXPANSION:
$(LISTS): LinkedList.test.o [email protected]
$(TREES): [email protected] [email protected] String.o functions.o
$(SORTS): sort.test.o [email protected] functions.o BST.o RBTree.o MinHeap.o
# Generic execution rule.
$(CXX) $(FLAGS) $^ && ./a.out
# Algorithms execution rule.
$(ALGORITHMS): [email protected]
$(CXX) $(FLAGS) $^ && ./a.out $(if $(TEST_CASE),--test-case=$(TEST_CASE))
all: $(TARGETS)
.PHONY: clean
clean:
find . -name "*out" -delete
find . -name "*.o" -delete