-
Notifications
You must be signed in to change notification settings - Fork 187
/
Makefile
92 lines (65 loc) · 2.77 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
.PHONY: default all clean grammar compare single-header single-header/ctre.hpp single-header/ctre-unicode.hpp single-header/unicode-db.hpp
default: all
TARGETS := $(wildcard tests/benchmark-exec/*.cpp)
IGNORE := $(wildcard tests/benchmark/*.cpp) $(wildcard tests/benchmark-exec/*.cpp)
DESATOMAT := /bin/false
CXX_STANDARD := 20
PYTHON := python3.9
PEDANTIC:=-pedantic
override CXXFLAGS := $(CXXFLAGS) -std=c++$(CXX_STANDARD) -Iinclude -O3 $(PEDANTIC) -Wall -Wextra -Werror -Wconversion
LDFLAGS :=
TESTS := $(wildcard tests/*.cpp) $(wildcard tests/benchmark/*.cpp)
TRUE_TARGETS := $(TARGETS:%.cpp=%)
override TRUE_TARGETS := $(filter-out $(IGNORE:%.cpp=%), $(TRUE_TARGETS))
OBJECTS := $(TARGETS:%.cpp=%.o) $(TESTS:%.cpp=%.o)
override OBJECTS := $(filter-out $(IGNORE:%.cpp=%.o),$(OBJECTS))
DEPEDENCY_FILES := $(OBJECTS:%.o=%.d)
all: $(TRUE_TARGETS) $(OBJECTS)
list:
echo $(SUPPORTED_CPP20)
$(TRUE_TARGETS): %: %.o
$(CXX) $< $(LDFLAGS) -o $@
$(OBJECTS): %.o: %.cpp
$(CXX) $(CXXFLAGS) -MMD -c $< -o $@
-include $(DEPEDENCY_FILES)
benchmark:
@$(MAKE) clean
@$(MAKE) IGNORE=""
benchmark-clean:
@$(MAKE) IGNORE="" clean
clean:
rm -f $(TRUE_TARGETS) $(OBJECTS) $(DEPEDENCY_FILES) mtent12.txt mtent12.zip
grammar: include/ctre/pcre.hpp
regrammar:
@rm -f include/ctre/pcre.hpp
@$(MAKE) grammar
include/ctre/pcre.hpp: include/ctre/pcre.gram
@echo "LL1q $<"
@$(DESATOMAT) --ll --q --input=include/ctre/pcre.gram --output=include/ctre/ --generator=cpp_ctll_v2 --cfg:fname=pcre.hpp --cfg:namespace=ctre --cfg:guard=CTRE__PCRE__HPP --cfg:grammar_name=pcre
mtent12.zip:
curl -s http://www.gutenberg.org/files/3200/old/mtent12.zip -o mtent12.zip
mtent12.txt: mtent12.zip
unzip -o mtent12.zip
touch mtent12.txt
single-header: single-header/ctre.hpp single-header/ctre-unicode.hpp single-header/unicode-db.hpp
single-header/unicode-db.hpp: include/unicode-db/unicode-db.hpp
cp $+ $@
single-header/ctre.hpp:
${PYTHON} -m quom include/ctre.hpp ctre.hpp.tmp
echo "/*" > single-header/ctre.hpp
cat LICENSE >> single-header/ctre.hpp
echo "*/" >> single-header/ctre.hpp
cat ctre.hpp.tmp >> single-header/ctre.hpp
rm ctre.hpp.tmp
single-header/ctre-unicode.hpp:
${PYTHON} -m quom include/ctre-unicode.hpp ctre-unicode.hpp.tmp
echo "/*" > single-header/ctre-unicode.hpp
cat LICENSE >> single-header/ctre-unicode.hpp
echo "*/" >> single-header/ctre-unicode.hpp
cat ctre-unicode.hpp.tmp >> single-header/ctre-unicode.hpp
rm ctre-unicode.hpp.tmp
REPEAT:=10
compare: mtent12.txt
$(CXX) $(CXXFLAGS) -MMD -march=native -DPATTERN="\"(${PATTERN})\"" -c tests/benchmark-range/measurement.cpp -o tests/benchmark-range/measurement.o
$(CXX) tests/benchmark-range/measurement.o -lboost_regex -lpcre2-8 -lre2 -o tests/benchmark-range/measurement
tests/benchmark-range/measurement all mtent12.txt ${REPEAT}