-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
70 lines (44 loc) · 1.6 KB
/
makefile
File metadata and controls
70 lines (44 loc) · 1.6 KB
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
#
# Created by mandriy on 5/8/15.
#
binary_dir ?= build
executable_name ?= server
run_args ?= -p 4242
tests_dir = tests
test_runner = tests
headers ?= thread/myThread.h socket/TCPSocket.h connection/connection.h tcp_server/asioTcpServer.h
main_file ?= server.cpp
source_files ?= thread/myThread.cpp socket/TCPSocket.cpp
flags += -lpthread -std=c++11 -lboost_serialization -lboost_program_options -lboost_system
ifndef suppress_warnings
warnings ?= -Wall -Wextra
endif
all : run
.PHONY : run
run : executable
./$(executable_name) $(run_args)
valgrind_run: executable
valgrind --track-origins=yes ./$(executable_name) $(run_args)
.PHONY :executable
executable : $(executable_name)
$(executable_name) : build_files
g++ $(binary_dir)/* -o $(executable_name) $(flags)
.PHONY : build_files
build_files : $(binary_dir)
$(binary_dir) : $(headers) $(source_files) $(main_file)
if ! [ -d $(binary_dir) ]; then mkdir $(binary_dir); fi
rm -rf $(binary_dir)/*
( cd $(binary_dir) ; g++ $(addprefix ../, $(main_file) $(source_files)) -c $(flags) $(additional_flags) $(warnings))
.PHONY : clean
clean :
rm -rf $(binary_dir)
rm -rf $(executable_name)
.PHONY : run-tests
run-tests : execute-tests
clean-test-suite :
( cd $(tests_dir); rm -rf $(test_runner) )
execute-tests : build-tests
( cd $(tests_dir); ./$(test_runner) )
build-tests : $(tests_dir)/$(test_runner)
$(tests_dir)/$(test_runner) : $(shell find $(tests_dir) -name "*.cpp")
( cd $(tests_dir) ; g++ $(addprefix ../, $(source_files) $(shell find $(tests_dir) -name "*.cpp")) $(flags) $(additional_flags) -lboost_unit_test_framework -o $(test_runner))