forked from suyash/ulid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
106 lines (69 loc) · 2.8 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
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
# Based on the Makefile in googletest/make
# Points to the root of Google Test
GTEST_DIR = vendor/googletest/googletest
BENCHMARK_BUILD_DIR = vendor/benchmark_build
# Flags passed to the preprocessor.
CPPFLAGS += -isystem $(GTEST_DIR)/include
# Flags passed to the C++ compiler.
CXXFLAGS += -g -Wall -Wextra -pthread -std=c++11
# All tests produced by this Makefile.
TESTS = ulid_uint128_test ulid_struct_test
# All benchmarks produced by this Makefile.
BENCHS = ulid_uint128_bench ulid_struct_bench
# All Google Test headers.
GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
$(GTEST_DIR)/include/gtest/internal/*.h
# DO NOT TWEAK
GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
# General Tasks
all : test bench
clean :
rm -f *_test.o *_test.out *_bench.o *_bench.out
clean-all : clean
rm -f gtest.a gtest_main.a
rm -rf $(BENCHMARK_BUILD_DIR)
test : $(TESTS)
bench : $(BENCHS)
# Tasks for gtest
gtest-all.o : $(GTEST_SRCS_)
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c $(GTEST_DIR)/src/gtest-all.cc
gtest_main.o : $(GTEST_SRCS_)
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c $(GTEST_DIR)/src/gtest_main.cc
gtest.a : gtest-all.o
$(AR) $(ARFLAGS) $@ $^
gtest_main.a : gtest-all.o gtest_main.o
$(AR) $(ARFLAGS) $@ $^
# Tasks to build benchmark
$(BENCHMARK_BUILD_DIR) : vendor/benchmark
cd $< \
&& cmake -DBENCHMARK_ENABLE_GTEST_TESTS=OFF -DCMAKE_INSTALL_PREFIX=../../$@ -DCMAKE_BUILD_TYPE=Release . \
&& make \
&& make install
# Tasks for ulid_uint128_test
ulid_uint128_test.o : ulid_test.cc $(GTEST_HEADERS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -DULIDUINT128 -c ulid_test.cc -o $@
ulid_uint128_test.out : gtest_main.a ulid_uint128_test.o
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@
ulid_uint128_test : ulid_uint128_test.out
./$<
# Tasks for ulid_struct_test
ulid_struct_test.o : ulid_test.cc $(GTEST_HEADERS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c ulid_test.cc -o $@
ulid_struct_test.out : gtest_main.a ulid_struct_test.o
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@
ulid_struct_test : ulid_struct_test.out
./$<
# Tasks for ulid_uint128_bench
ulid_uint128_bench.o : ulid_bench.cc $(BENCHMARK_BUILD_DIR)
$(CXX) $(CXXFLAGS) -I$(BENCHMARK_BUILD_DIR)/include -DULIDUINT128 -c ulid_bench.cc -o $@
ulid_uint128_bench.out : ulid_uint128_bench.o
$(CXX) $(CXXFLAGS) $^ -lpthread -L$(BENCHMARK_BUILD_DIR)/lib -lbenchmark -o $@
ulid_uint128_bench : ulid_uint128_bench.out
./$< --benchmark_out_format=console
# Tasks for ulid_uint128_bench
ulid_struct_bench.o : ulid_bench.cc $(BENCHMARK_BUILD_DIR)
$(CXX) $(CXXFLAGS) -I$(BENCHMARK_BUILD_DIR)/include -c ulid_bench.cc -o $@
ulid_struct_bench.out : ulid_struct_bench.o
$(CXX) $(CXXFLAGS) $^ -lpthread -L$(BENCHMARK_BUILD_DIR)/lib -lbenchmark -o $@
ulid_struct_bench : ulid_struct_bench.out
./$< --benchmark_out_format=console