-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
96 lines (77 loc) · 2.04 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
# Makefile
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
SANITIZERS = none debug msan asan usan tsan
.PHONY: default gcc clang run update check ce todo distclean clean build test all $(SANITIZERS)
COMPILER=system
CXX_BASE=$(CXX:$(dir $(CXX))%=%)
ifeq ($(CXX_BASE),g++)
COMPILER=gcc
endif
ifeq ($(CXX_BASE),clang++)
COMPILER=clang
endif
CXX_FLAGS = -g
SANITIZER = none
SOURCEDIR = $(shell pwd)
BUILDROOT = build
BUILD = $(BUILDROOT)/$(COMPILER)/$(SANITIZER)
EXAMPLE = server
CMAKE_C_COMPILER=$(COMPILER)
CMAKE_CXX_COMPILER=$(COMPILER)
ifeq ($(SANITIZER),none)
CXX_FLAGS = -O3 -pedantic -Wall -Wextra -Werror
endif
ifeq ($(SANITIZER),debug)
CXX_FLAGS = -g
endif
ifeq ($(SANITIZER),usan)
SAN_FLAGS = -fsanitize=memory
endif
ifeq ($(SANITIZER),asan)
SAN_FLAGS = -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize-address-use-after-scope
endif
ifeq ($(SANITIZER),usan)
SAN_FLAGS = -fsanitize=undefined
endif
ifeq ($(SANITIZER),tsan)
SAN_FLAGS = -fsanitize=thread
endif
ifeq ($(SANITIZER),lsan)
SAN_FLAGS = -fsanitize=leak
endif
default: build
all: $(SANITIZERS)
gcc:
$(MAKE) CXX=/opt/gcc-14.1.0/bin/g++
clang:
$(MAKE) CXX=/opt/llvm-18.1.8/bin/clang++
run: build
./$(BUILD)/examples/$(EXAMPLE)
none: test
$(SANITIZERS):
$(MAKE) SANITIZER=$@
build:
@mkdir -p $(BUILD)
cd $(BUILD); CC=$(CXX) cmake $(SOURCEDIR) $(TOOLCHAIN) $(SYSROOT) -DCMAKE_CXX_COMPILER=$(CXX) -DCMAKE_CXX_FLAGS="$(CXX_FLAGS) $(SAN_FLAGS)"
cmake --build $(BUILD)
test: build
cd $(BUILD); $(MAKE) test
ce:
@mkdir -p $(BUILD)
bin/mk-compiler-explorer.py $(BUILD)
SOURCE_CMAKELISTS = src/beman/net29/CMakeLists.txt
update:
bin/update-cmake-headers.py $(SOURCE_CMAKELISTS)
check:
@for h in `find include -name \*.hpp`; \
do \
from=`echo -n $$h | sed -n 's@.*Beman/\(.*\).hpp.*@\1@p'`; \
< $$h sed -n "/^ *# *include <Beman\//s@.*[</]Beman/\(.*\).hpp>.*@$$from \1@p"; \
done | tsort > /dev/null
todo:
bin/mk-todo.py
clean:
$(RM) -r $(BUILD)
$(RM) mkerr olderr *~
distclean: clean
$(RM) -r $(BUILDROOT)