-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
108 lines (81 loc) · 2.76 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
107
# Copyright 2015-2022 The libcount Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License. See the AUTHORS file for names of
# contributors.
# Uncomment exactly one of the lines labelled (A), (B), and (C) below
# to switch between compilation modes.
# A: Production use (full optimizations)
#OPT ?= -O3 -DNDEBUG
# B: Debug mode, with full line-level debugging symbols
OPT ?= -g2
# C: Profiling mode: optimizations, but w/debugging symbols
#OPT ?= -O3 -g2 -DNDEBUG
PREFIX ?= /usr/local
# Warning Flags
WARNINGFLAGS = -Wall -Werror
# Detect what platform we're building on
$(shell CXX="$(CXX)" TARGET_OS="$(TARGET_OS)" \
./build_config build_config.mk .)
# Include the file generated by the previous line to set build flags, sources
include build_config.mk
AR = ar
RANLIB = ranlib
CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) $(WARNINGFLAGS)
COUNT_OBJECTS = $(COUNT_FILES:.cc=.o)
TESTS = empirical_data_test
# Targets
all: libcount.a
.PHONY:
check: $(TESTS)
for t in $(TESTS); do echo "** Running $$t"; ./$$t || exit 1; done
.PHONY:
clean:
-rm -f */*.o build_config.mk *.a c_example cc_example merge_example $(TESTS)
c_example: examples/c_example.o libcount.a
$(CXX) $(CXXFLAGS) examples/c_example.o libcount.a -o $@ -lcrypto
cc_example: examples/cc_example.o libcount.a
$(CXX) $(CXXFLAGS) examples/cc_example.o libcount.a -o $@ -lcrypto
certify: examples/certify.o libcount.a
$(CXX) $(CXXFLAGS) examples/certify.o libcount.a -o $@ -lcrypto
./certify
empirical_data_test: count/empirical_data_test.o libcount.a
$(CXX) $(CXXFLAGS) count/empirical_data_test.o libcount.a -o $@
merge_example: examples/merge_example.o libcount.a
$(CXX) $(CXXFLAGS) examples/merge_example.o libcount.a -o $@ -lcrypto
.PHONY:
examples: c_example cc_example merge_example
.PHONY: install
install: libcount.a
cp libcount.a "$(PREFIX)/lib"
mkdir -p "$(PREFIX)/include/count"
cp include/count/*.h "$(PREFIX)/include/count"
libcount.a: $(COUNT_OBJECTS)
$(AR) rcs libcount.a $(COUNT_OBJECTS)
$(RANLIB) libcount.a
.PHONY:
linecount:
wc -l $(CPPLINT_SOURCES)
.PHONY:
lint:
$(LINT_TOOL) $(CPPLINT_SOURCES)
.PHONY:
neat: clean
-rm -f *~ .*~ */*~ ./include/*/*~
.PHONY:
reformat:
clang-format -i $(CPPLINT_SOURCES)
# Suffix Rules
.c.o:
$(CC) $(CXXFLAGS) -c $< -o $@
.cc.o:
$(CXX) $(CXXFLAGS) -c $< -o $@