-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
129 lines (100 loc) · 3.72 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# lug - Embedded DSL for PE grammar parsers in C++
# See LICENSE file for copyright and license details
# distribution version
VERSION = 0.4.0
# paths
PREFIX = /usr/local
# toolchain
CXXSTD = -std=c++17
CXXFLAGS = $(CXXSTD) -pedantic -Wall -Wconversion -Wextra -Wextra-semi -Wshadow -Wsign-conversion -Wsuggest-override -Wno-parentheses -Wno-logical-not-parentheses \
-Os -ffunction-sections -fdata-sections -I.
LDFLAGS = $(CXXSTD) -s
CLANGTIDY = clang-tidy
# unicode character database version
UCD_VERSION = 15.1.0
# samples
SAMPLES = basic/basic calc/calc json/json xml/xml
SAMPLES_BIN = $(SAMPLES:%=samples/%)
SAMPLES_OBJ = $(SAMPLES:%=samples/%.o)
# tests
TESTS = attributes captures conditions leftrecursion nonterminals parser predicates symbols terminals
TESTS_BIN = $(TESTS:%=tests/%)
TESTS_OBJ = $(TESTS:%=tests/%.o)
# tools
TOOLS = makeunicode
TOOLS_BIN = $(TOOLS:%=tools/%)
TOOLS_OBJ = $(TOOLS:%=tools/%.o)
# header dependencies
HEADERS = lug/detail.hpp lug/error.hpp lug/unicode.hpp lug/utf8.hpp lug/lug.hpp
# distribution files
DISTFILES = CHANGELOG.md LICENSE.md README.md CMakeLists.txt Makefile runtests.sh .clang-tidy .editorconfig .gitattributes .gitignore .github/ doc/ lug/ samples/ tests/ tools/
all: options samples tests
.cpp.o:
@echo CXX $<
@$(CXX) -c $(CXXFLAGS) $$(if [ "$(CI_BUILD)" = "1" ]; then echo "-Werror"; fi) -o $@ $<
$(SAMPLES_OBJ): $(HEADERS)
$(SAMPLES_BIN): $(SAMPLES_OBJ)
@echo LD $@
@$(CXX) -o $@ $@.o $(LDFLAGS)
samples: $(SAMPLES_BIN)
$(TESTS_OBJ): $(HEADERS)
$(TESTS_BIN): $(TESTS_OBJ)
@echo LD $@
@$(CXX) -o $@ $@.o $(LDFLAGS)
tests: $(TESTS_BIN)
check: tests
@sh runtests.sh "tests" $(TESTS_BIN)
lint:
@$(CLANGTIDY) --quiet $(CXXFLAGS:%=--extra-arg=%) $(HEADERS)
$(TOOLS_OBJ): $(HEADERS)
$(TOOLS_BIN): $(TOOLS_OBJ)
@echo LD $@
@$(CXX) -o $@ $@.o $(LDFLAGS)
tools: $(TOOLS_BIN)
unicode: tools
@echo fetching Unicode Character Database $(UCD_VERSION)
@cd tools/ && sh fetchucd.sh $(UCD_VERSION)
@echo generating lug/unicode.hpp
@cd tools/ && ./makeunicode > ../lug/unicode.hpp
options:
@echo lug build options:
@echo "CXX = $(CXX)"
@echo "CXXSTD = $(CXXSTD)"
@echo "CXXFLAGS = $(CXXFLAGS)"
@echo "LDFLAGS = $(LDFLAGS)"
@echo "CLANGTIDY = $(CLANGTIDY)"
@echo "PREFIX = $(PREFIX)"
@echo "UCD_VERSION = $(UCD_VERSION)"
clean:
@echo cleaning
@rm -f $(SAMPLES_BIN) $(SAMPLES_OBJ) $(TESTS_BIN) $(TESTS_OBJ) $(TOOLS_BIN) $(TOOLS_OBJ) lug-$(VERSION).tar.gz
@rm -rf tools/ucd
dist: clean
@echo creating dist tarball
@mkdir -p lug-$(VERSION)
@cp -R $(DISTFILES) lug-$(VERSION)
@tar -cf lug-$(VERSION).tar lug-$(VERSION)
@gzip lug-$(VERSION).tar
@rm -rf lug-$(VERSION)
install: all
@echo installing header file to $(DESTDIR)$(PREFIX)/include/lug
@mkdir -p $(DESTDIR)$(PREFIX)/include/lug
@cp -f lug/lug.hpp $(DESTDIR)$(PREFIX)/include/lug
@chmod 644 $(DESTDIR)$(PREFIX)/include/lug/lug.hpp
@cp -f lug/detail.hpp $(DESTDIR)$(PREFIX)/include/lug
@chmod 644 $(DESTDIR)$(PREFIX)/include/lug/detail.hpp
@cp -f lug/error.hpp $(DESTDIR)$(PREFIX)/include/lug
@chmod 644 $(DESTDIR)$(PREFIX)/include/lug/error.hpp
@cp -f lug/unicode.hpp $(DESTDIR)$(PREFIX)/include/lug
@chmod 644 $(DESTDIR)$(PREFIX)/include/lug/unicode.hpp
@cp -f lug/utf8.hpp $(DESTDIR)$(PREFIX)/include/lug
@chmod 644 $(DESTDIR)$(PREFIX)/include/lug/utf8.hpp
uninstall:
@echo removing header files from $(DESTDIR)$(PREFIX)/include/lug
@rm -f $(DESTDIR)$(PREFIX)/include/lug/lug.hpp
@rm -f $(DESTDIR)$(PREFIX)/include/lug/detail.hpp
@rm -f $(DESTDIR)$(PREFIX)/include/lug/error.hpp
@rm -f $(DESTDIR)$(PREFIX)/include/lug/unicode.hpp
@rm -f $(DESTDIR)$(PREFIX)/include/lug/utf8.hpp
@rmdir $(DESTDIR)$(PREFIX)/include/lug
.PHONY: all samples tests check lint tools unicode options clean dist install uninstall