@@ -4,13 +4,42 @@ BOOST_VERSION = 1.62.0
4
4
CXX := $(CXX )
5
5
CXX_STD ?= c++11
6
6
7
- BOOST_FLAGS = ` $( MASON) cflags boost $( BOOST_VERSION) `
7
+ BOOST_ROOT = $(shell $(MASON ) prefix boost $(BOOST_VERSION ) )
8
+ BOOST_FLAGS = -isystem $(BOOST_ROOT ) /include/
8
9
RELEASE_FLAGS = -O3 -DNDEBUG -march=native -DSINGLE_THREADED -fvisibility-inlines-hidden -fvisibility=hidden
9
- DEBUG_FLAGS = -O0 -g -DDEBUG -fno-inline-functions -fno-omit-frame-pointer
10
- COMMON_FLAGS = -Wall -pedantic -Wextra -Wsign-compare -Wsign-conversion -Wshadow -Wunused-parameter -std=$(CXX_STD )
10
+ DEBUG_FLAGS = -O0 -g -DDEBUG -fno-inline-functions -fno-omit-frame-pointer -fPIE -D_FORTIFY_SOURCE=2 -fwrapv -Wformat -Wformat-security
11
+ COMMON_FLAGS = -std=$(CXX_STD )
12
+
13
+ WARNING_FLAGS = -Wall -Werror -pedantic -Wextra -Wsign-compare -Wsign-conversion -Wshadow -Wunused-parameter
14
+ CLANG_WARNING_FLAGS = -Wno-unsequenced -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-exit-time-destructors
15
+ ifneq (,$(findstring clang,$(CXX ) ) )
16
+ WARNING_FLAGS += $(CLANG_WARNING_FLAGS )
17
+ endif
18
+
19
+ COMMON_FLAGS += $(WARNING_FLAGS )
20
+
11
21
CXXFLAGS := $(CXXFLAGS )
12
22
LDFLAGS := $(LDFLAGS )
13
23
24
+ export BUILDTYPE ?= Release
25
+
26
+ OS := $(shell uname -s)
27
+ ifeq ($(OS ) , Linux)
28
+ EXTRA_FLAGS = -pthread
29
+ endif
30
+ ifeq ($(OS ) , Darwin)
31
+ EXTRA_FLAGS = -mmacosx-version-min=10.8
32
+ endif
33
+
34
+
35
+ ifeq ($(BUILDTYPE ) ,Release)
36
+ FINAL_CXXFLAGS := $(COMMON_FLAGS) $(RELEASE_FLAGS) $(CXXFLAGS) $(EXTRA_FLAGS)
37
+ else
38
+ FINAL_CXXFLAGS := $(COMMON_FLAGS) $(DEBUG_FLAGS) $(CXXFLAGS) $(EXTRA_FLAGS)
39
+ endif
40
+
41
+
42
+
14
43
ALL_HEADERS = $(shell find include/mapbox/ '(' -name '* .hpp' ') ')
15
44
16
45
all : out/bench-variant out/unique_ptr_test out/unique_ptr_test out/recursive_wrapper_test out/binary_visitor_test out/lambda_overload_test out/hashable_test
@@ -31,31 +60,31 @@ gyp: ./deps/gyp
31
60
32
61
out/bench-variant-debug : Makefile mason_packages/headers/boost test/bench_variant.cpp
33
62
mkdir -p ./out
34
- $(CXX ) -o out/bench-variant-debug test/bench_variant.cpp -I./include -Itest /include -pthreads $( DEBUG_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
63
+ $(CXX ) -o out/bench-variant-debug test/bench_variant.cpp -I./include -isystem test /include $( FINAL_CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
35
64
36
65
out/bench-variant : Makefile mason_packages/headers/boost test/bench_variant.cpp
37
66
mkdir -p ./out
38
- $(CXX ) -o out/bench-variant test/bench_variant.cpp -I./include -Itest /include $(RELEASE_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
67
+ $(CXX ) -o out/bench-variant test/bench_variant.cpp -I./include -isystem test /include $(FINAL_CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
39
68
40
69
out/unique_ptr_test : Makefile mason_packages/headers/boost test/unique_ptr_test.cpp
41
70
mkdir -p ./out
42
- $(CXX ) -o out/unique_ptr_test test/unique_ptr_test.cpp -I./include -Itest /include $(RELEASE_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
71
+ $(CXX ) -o out/unique_ptr_test test/unique_ptr_test.cpp -I./include -isystem test /include $(FINAL_CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
43
72
44
73
out/recursive_wrapper_test : Makefile mason_packages/headers/boost test/recursive_wrapper_test.cpp
45
74
mkdir -p ./out
46
- $(CXX ) -o out/recursive_wrapper_test test/recursive_wrapper_test.cpp -I./include -Itest /include $(RELEASE_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
75
+ $(CXX ) -o out/recursive_wrapper_test test/recursive_wrapper_test.cpp -I./include -isystem test /include $(FINAL_CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
47
76
48
77
out/binary_visitor_test : Makefile mason_packages/headers/boost test/binary_visitor_test.cpp
49
78
mkdir -p ./out
50
- $(CXX ) -o out/binary_visitor_test test/binary_visitor_test.cpp -I./include -Itest /include $(RELEASE_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
79
+ $(CXX ) -o out/binary_visitor_test test/binary_visitor_test.cpp -I./include -isystem test /include $(FINAL_CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
51
80
52
81
out/lambda_overload_test : Makefile mason_packages/headers/boost test/lambda_overload_test.cpp
53
82
mkdir -p ./out
54
- $(CXX ) -o out/lambda_overload_test test/lambda_overload_test.cpp -I./include -Itest /include $(RELEASE_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
83
+ $(CXX ) -o out/lambda_overload_test test/lambda_overload_test.cpp -I./include -isystem test /include $(FINAL_CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
55
84
56
85
out/hashable_test : Makefile mason_packages/headers/boost test/hashable_test.cpp
57
86
mkdir -p ./out
58
- $(CXX ) -o out/hashable_test test/hashable_test.cpp -I./include -Itest /include $(RELEASE_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
87
+ $(CXX ) -o out/hashable_test test/hashable_test.cpp -I./include -isystem test /include $(FINAL_CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS )
59
88
60
89
bench : out/bench-variant out/unique_ptr_test out/unique_ptr_test out/recursive_wrapper_test out/binary_visitor_test
61
90
./out/bench-variant 100000
@@ -65,11 +94,11 @@ bench: out/bench-variant out/unique_ptr_test out/unique_ptr_test out/recursive_w
65
94
66
95
out/unit.o : Makefile test/unit.cpp
67
96
mkdir -p ./out
68
- $(CXX ) -c -o $@ test/unit.cpp -Itest /include $(DEBUG_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS )
97
+ $(CXX ) -c -o $@ test/unit.cpp -isystem test /include $(FINAL_CXXFLAGS )
69
98
70
99
out/% .o : test/t/% .cpp Makefile $(ALL_HEADERS )
71
100
mkdir -p ./out
72
- $(CXX ) -c -o $@ $< -Iinclude -Itest /include $(DEBUG_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS )
101
+ $(CXX ) -c -o $@ $< -Iinclude -isystem test /include $(FINAL_CXXFLAGS )
73
102
74
103
out/unit : out/unit.o out/binary_visitor_1.o out/binary_visitor_2.o out/binary_visitor_3.o out/binary_visitor_4.o out/binary_visitor_5.o out/binary_visitor_6.o out/issue21.o out/issue122.o out/mutating_visitor.o out/optional.o out/recursive_wrapper.o out/sizeof.o out/unary_visitor.o out/variant.o
75
104
mkdir -p ./out
@@ -80,14 +109,14 @@ test: out/unit
80
109
81
110
coverage :
82
111
mkdir -p ./out
83
- $(CXX ) -o out/cov-test --coverage test/unit.cpp test/t/* .cpp -I./include -Itest /include $(DEBUG_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) $(LDFLAGS )
112
+ $(CXX ) -o out/cov-test --coverage test/unit.cpp test/t/* .cpp -I./include -isystem test /include $(FINAL_CXXFLAGS ) $(LDFLAGS )
84
113
85
114
sizes : Makefile
86
115
mkdir -p ./out
87
- @$(CXX ) -o ./out/our_variant_hello_world.out include/mapbox/variant.hpp -I./include $(RELEASE_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) && du -h ./out/our_variant_hello_world.out
88
- @$(CXX ) -o ./out/boost_variant_hello_world.out ` $( MASON ) prefix boost $( BOOST_VERSION ) ` /include/boost/variant.hpp -I./include $(RELEASE_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) $(BOOST_FLAGS ) && du -h ./out/boost_variant_hello_world.out
89
- @$(CXX ) -o ./out/our_variant_hello_world ./test/our_variant_hello_world.cpp -I./include $(RELEASE_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) && du -h ./out/our_variant_hello_world
90
- @$(CXX ) -o ./out/boost_variant_hello_world ./test/boost_variant_hello_world.cpp -I./include $(RELEASE_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) $(BOOST_FLAGS ) && du -h ./out/boost_variant_hello_world
116
+ @$(CXX ) -o ./out/our_variant_hello_world.out include/mapbox/variant.hpp -I./include $(FINAL_CXXFLAGS ) && du -h ./out/our_variant_hello_world.out
117
+ @$(CXX ) -o ./out/boost_variant_hello_world.out $( BOOST_ROOT ) /include/boost/variant.hpp -I./include $(FINAL_CXXFLAGS ) $(BOOST_FLAGS ) && du -h ./out/boost_variant_hello_world.out
118
+ @$(CXX ) -o ./out/our_variant_hello_world ./test/our_variant_hello_world.cpp -I./include $(FINAL_CXXFLAGS ) && du -h ./out/our_variant_hello_world
119
+ @$(CXX ) -o ./out/boost_variant_hello_world ./test/boost_variant_hello_world.cpp -I./include $(FINAL_CXXFLAGS ) $(BOOST_FLAGS ) && du -h ./out/boost_variant_hello_world
91
120
92
121
profile : out/bench-variant-debug
93
122
mkdir -p profiling/
@@ -104,8 +133,8 @@ clean:
104
133
rm -f * .gcda * .gcno
105
134
106
135
pgo : out Makefile
107
- $(CXX ) -o out/bench-variant test/bench_variant.cpp -I./include $(RELEASE_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS ) -pg -fprofile-generate
136
+ $(CXX ) -o out/bench-variant test/bench_variant.cpp -I./include $(FINAL_CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS ) -pg -fprofile-generate
108
137
./test-variant 500000 > /dev/null 2> /dev/null
109
- $(CXX ) -o out/bench-variant test/bench_variant.cpp -I./include $(RELEASE_FLAGS ) $( COMMON_FLAGS ) $( CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS ) -fprofile-use
138
+ $(CXX ) -o out/bench-variant test/bench_variant.cpp -I./include $(FINAL_CXXFLAGS ) $(LDFLAGS ) $(BOOST_FLAGS ) -fprofile-use
110
139
111
140
.PHONY : sizes test
0 commit comments