-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (44 loc) · 1.66 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
CXX = g++
# Extra flags to prevent segfaulting: https://stackoverflow.com/q/35116327
CXXFLAGS = -std=c++11 -Wall -Wextra -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -g -fno-stack-protector -z execstack -m32
include_flag = -I include/
names = client server
binaries := $(names:%=bin/%)
shared_src := $(wildcard src/*.cpp)
client_only_src := $(wildcard src/client/*.cpp)
server_only_src := $(wildcard src/server/*.cpp)
client_src := $(shared_src) $(client_only_src)
server_src := $(shared_src) $(server_only_src)
all_src := $(shared_src) $(client_only_src) $(server_only_src)
client_obj := $(client_src:src/%.cpp=obj/%.o)
server_obj := $(server_src:src/%.cpp=obj/%.o)
all_dep := $(all_src:src/%.cpp=obj/%.d)
latex_extensions = aux log pdf
remove := $(binaries) obj/*.[do] $(names:%=obj/%/*.[do])
remove_exploits := $(latex_extensions:%=exploits/exploits.%)
remove_docs := $(latex_extensions:%=docs/documentation.%)
.PHONY: all exploits clean clean-bin clean-exploits clean-docs
all: $(binaries)
bin/client: $(client_obj)
bin/server: $(server_obj)
bin/%:
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(include_flag) -o $@ $^
@echo "Built $@ successfully!"
obj/%.o: src/%.cpp
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(include_flag) -MMD -MP -c -o $@ $<
exploits: exploits/exploits.pdf
exploits/exploits.pdf: exploits/exploits.tex
pdflatex -output-directory=exploits exploits/exploits
docs: docs/documentation.pdf
docs/documentation.pdf: docs/documentation.tex
pdflatex -output-directory=docs docs/documentation
clean: clean-bin clean-exploits clean-docs
clean-bin:
rm -f $(remove)
clean-exploits:
rm -f $(remove_exploits)
clean-docs:
rm -f $(remove_docs)
-include $(all_dep)