-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
75 lines (62 loc) · 1.97 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
# The MIT License (MIT)
#
# Copyright (c) 2018-2022 Yury Gribov
#
# Use of this source code is governed by The MIT License (MIT)
# that can be found in the LICENSE.txt file.
$(shell mkdir -p bin)
CXX ?= g++
LLVM_CONFIG ?= llvm-config
DESTDIR ?= /usr/local
CXXFLAGS = $(shell $(LLVM_CONFIG) --cflags) -std=c++11 -g -Wall -Wextra -Werror
LDFLAGS = $(shell $(LLVM_CONFIG) --ldflags) -Wl,--warn-common
ifneq (,$(COVERAGE))
DEBUG = 1
CXXFLAGS += --coverage -DNDEBUG
LDFLAGS += --coverage
endif
ifeq (,$(DEBUG))
CXXFLAGS += -O2
LDFLAGS += -Wl,-O2
else
CXXFLAGS += -O0
endif
ifneq (,$(ASAN))
CXXFLAGS += -fsanitize=address -fsanitize-address-use-after-scope -U_FORTIFY_SOURCE -fno-common -D_GLIBCXX_DEBUG -D_GLIBCXX_SANITIZE_VECTOR
LDFLAGS += -fsanitize=address
endif
ifneq (,$(UBSAN))
ifneq (,$(shell $(CXX) --version | grep clang))
# Isan is clang-only...
CXXFLAGS += -fsanitize=undefined,integer -fno-sanitize-recover=undefined,integer
LDFLAGS += -fsanitize=undefined,integer -fno-sanitize-recover=undefined,integer
else
CXXFLAGS += -fsanitize=undefined -fno-sanitize-recover=undefined
LDFLAGS += -fsanitize=undefined -fno-sanitize-recover=undefined
endif
endif
all: bin/read_header_api
# TODO: install Python as well
install:
mkdir -p $(DESTDIR)
install bin/read_header_api $(DESTDIR)/bin
install read_binary_api $(DESTDIR)/bin
check:
tests/basic/run.sh
tests/debian/run.sh
tests/only/run.sh
pylint:
pylint shlibvischeck
bin/read_header_api: bin/read_header_api.o Makefile bin/FLAGS
$(CXX) $(LDFLAGS) -o $@ $(filter %.o, $^) -lclang
bin/%.o: src/%.cc Makefile bin/FLAGS
$(CXX) $(CXXFLAGS) -o $@ -c $<
bin/FLAGS: FORCE
if test x"$(CFLAGS) $(CXXFLAGS) $(LDFLAGS)" != x"$$(cat $@)"; then \
echo "$(CFLAGS) $(CXXFLAGS) $(LDFLAGS)" > $@; \
fi
clean:
rm -rf bin/* build dist *.egg-info
find -name \*.gcov -o -name \*.gcno -o -name \*.gcda | xargs rm -rf
find -name .coverage -o -name \*.xml | xargs rm -rf
.PHONY: check all install clean pylint FORCE