File: Makefile

package info (click to toggle)
mapbox-variant 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,236 kB
  • sloc: cpp: 31,068; ansic: 959; python: 424; makefile: 144; objc: 59; sh: 36
file content (157 lines) | stat: -rw-r--r-- 6,012 bytes parent folder | download | duplicates (2)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
MASON = .mason/mason
BOOST_VERSION = 1.62.0

CXX := $(CXX)
CXX_STD ?= c++11

BOOST_ROOT = $(shell $(MASON) prefix boost $(BOOST_VERSION))
BOOST_FLAGS = 
RELEASE_FLAGS = -O3 -DNDEBUG -march=native -DSINGLE_THREADED -fvisibility-inlines-hidden -fvisibility=hidden
DEBUG_FLAGS = -O0 -g -DDEBUG -fno-inline-functions -fno-omit-frame-pointer -fPIE
WARNING_FLAGS = -Werror -Wall -Wextra -pedantic \
		-Wformat=2 -Wsign-conversion -Wshadow -Wunused-parameter

COMMON_FLAGS = -std=$(CXX_STD)
COMMON_FLAGS += $(WARNING_FLAGS)

CXXFLAGS := $(CXXFLAGS)
LDFLAGS := $(LDFLAGS)

export BUILDTYPE ?= Release

OS := $(shell uname -s)
ifeq ($(OS), Linux)
  EXTRA_FLAGS = -pthread
endif
ifeq ($(OS), Darwin)
  OSX_OLDEST_SUPPORTED ?= 10.7
  # we need to explicitly ask for libc++ otherwise the
  # default will flip back to libstdc++ for mmacosx-version-min < 10.9
  EXTRA_FLAGS = -stdlib=libc++ -mmacosx-version-min=$(OSX_OLDEST_SUPPORTED)
endif


ifeq ($(BUILDTYPE),Release)
	FINAL_CXXFLAGS := $(COMMON_FLAGS) $(RELEASE_FLAGS) $(CXXFLAGS) $(EXTRA_FLAGS)
else
	FINAL_CXXFLAGS := $(COMMON_FLAGS) $(DEBUG_FLAGS) $(CXXFLAGS) $(EXTRA_FLAGS)
endif



ALL_HEADERS = $(shell find include/mapbox/ '(' -name '*.hpp' ')')

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

$(MASON):
#	git submodule update --init .mason

mason_packages/headers/boost: $(MASON)
#	$(MASON) install boost $(BOOST_VERSION)

./deps/gyp:
	git clone --depth 1 https://chromium.googlesource.com/external/gyp.git ./deps/gyp

gyp: ./deps/gyp
	deps/gyp/gyp --depth=. -Goutput_dir=./ --generator-output=./out -f make
	make V=1 -C ./out tests
	./out/$(BUILDTYPE)/tests

out/bench-variant-debug: Makefile mason_packages/headers/boost test/bench_variant.cpp
	mkdir -p ./out
	$(CXX) -o out/bench-variant-debug test/bench_variant.cpp -I./include -isystem test/include $(FINAL_CXXFLAGS) $(LDFLAGS) $(BOOST_FLAGS)

out/bench-variant: Makefile mason_packages/headers/boost test/bench_variant.cpp
	mkdir -p ./out
	$(CXX) -o out/bench-variant test/bench_variant.cpp -I./include -isystem test/include $(FINAL_CXXFLAGS) $(LDFLAGS) $(BOOST_FLAGS)

out/unique_ptr_test: Makefile mason_packages/headers/boost test/unique_ptr_test.cpp
	mkdir -p ./out
	$(CXX) -o out/unique_ptr_test test/unique_ptr_test.cpp -I./include -isystem test/include $(FINAL_CXXFLAGS) $(LDFLAGS) $(BOOST_FLAGS)

out/recursive_wrapper_test: Makefile mason_packages/headers/boost test/recursive_wrapper_test.cpp
	mkdir -p ./out
	$(CXX) -o out/recursive_wrapper_test test/recursive_wrapper_test.cpp -I./include -isystem test/include $(FINAL_CXXFLAGS) $(LDFLAGS) $(BOOST_FLAGS)

out/binary_visitor_test: Makefile mason_packages/headers/boost test/binary_visitor_test.cpp
	mkdir -p ./out
	$(CXX) -o out/binary_visitor_test test/binary_visitor_test.cpp -I./include -isystem test/include $(FINAL_CXXFLAGS) $(LDFLAGS) $(BOOST_FLAGS)

out/lambda_overload_test: Makefile mason_packages/headers/boost test/lambda_overload_test.cpp
	mkdir -p ./out
	$(CXX) -o out/lambda_overload_test test/lambda_overload_test.cpp -I./include -isystem test/include $(FINAL_CXXFLAGS) $(LDFLAGS) $(BOOST_FLAGS)

out/hashable_test: Makefile mason_packages/headers/boost test/hashable_test.cpp
	mkdir -p ./out
	$(CXX) -o out/hashable_test test/hashable_test.cpp -I./include -isystem test/include $(FINAL_CXXFLAGS) $(LDFLAGS) $(BOOST_FLAGS)

bench: out/bench-variant out/unique_ptr_test out/unique_ptr_test out/recursive_wrapper_test out/binary_visitor_test
	./out/bench-variant 100000
	./out/unique_ptr_test 100000
	./out/recursive_wrapper_test 100000
	./out/binary_visitor_test 100000

out/unit.o: Makefile test/unit.cpp
	mkdir -p ./out
	$(CXX) -c -o $@ test/unit.cpp -isystem test/include $(FINAL_CXXFLAGS)

out/%.o: test/t/%.cpp Makefile $(ALL_HEADERS)
	mkdir -p ./out
	$(CXX) -c -o $@ $< -Iinclude -isystem test/include $(FINAL_CXXFLAGS)

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 \
          out/variant_alternative.o \
          out/nothrow_move.o \
          out/visitor_result_type.o \

	mkdir -p ./out
	$(CXX) -o $@ $^ $(LDFLAGS)

test: out/unit
	./out/unit

coverage:
	mkdir -p ./out
	$(CXX) -o out/cov-test --coverage test/unit.cpp test/t/*.cpp -I./include -isystem test/include $(FINAL_CXXFLAGS) $(LDFLAGS)

sizes: Makefile
	mkdir -p ./out
	@$(CXX) -o ./out/our_variant_hello_world.out include/mapbox/variant.hpp -I./include $(FINAL_CXXFLAGS) &&  ls -lah ./out/our_variant_hello_world.out
	@$(CXX) -o ./out/boost_variant_hello_world.out $(BOOST_ROOT)/include/boost/variant.hpp -I./include $(FINAL_CXXFLAGS) $(BOOST_FLAGS) &&  ls -lah ./out/boost_variant_hello_world.out
	@$(CXX) -o ./out/our_variant_hello_world ./test/our_variant_hello_world.cpp -I./include $(FINAL_CXXFLAGS) &&  ls -lah ./out/our_variant_hello_world
	@$(CXX) -o ./out/boost_variant_hello_world ./test/boost_variant_hello_world.cpp -I./include $(FINAL_CXXFLAGS) $(BOOST_FLAGS) &&  ls -lah ./out/boost_variant_hello_world

profile: out/bench-variant-debug
	mkdir -p profiling/
	rm -rf profiling/*
	iprofiler -timeprofiler -d profiling/ ./out/bench-variant-debug 500000

clean:
	rm -rf ./out
	rm -rf *.dSYM
	rm -f unit.gc*
	rm -f *gcov
	rm -f test/unit.gc*
	rm -f test/*gcov
	rm -f *.gcda *.gcno

pgo: out Makefile
	$(CXX) -o out/bench-variant test/bench_variant.cpp -I./include $(FINAL_CXXFLAGS) $(LDFLAGS) $(BOOST_FLAGS) -pg -fprofile-generate
	./test-variant 500000 >/dev/null 2>/dev/null
	$(CXX) -o out/bench-variant test/bench_variant.cpp -I./include $(FINAL_CXXFLAGS) $(LDFLAGS) $(BOOST_FLAGS) -fprofile-use

.PHONY: sizes test