-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile
More file actions
140 lines (115 loc) · 4.15 KB
/
makefile
File metadata and controls
140 lines (115 loc) · 4.15 KB
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
130
131
132
133
134
135
136
137
138
139
140
# Default to using all available CPU cores for parallel builds
# unless the user specifies a different number of jobs with -jN
ifeq ($(filter -j%,$(MAKEFLAGS)),)
MAKEFLAGS += -j$(shell nproc)
endif
WIKIDIRECTORY=polonius.wiki
WIKIUPSTREAM=https://github.com/rail5/polonius.wiki.git
VERSION=$(shell dpkg-parsechangelog -l debian/changelog --show-field version)
CXX = g++
CXXFLAGS = -O2 -std=gnu++20 -Wall -Wextra -MMD -MP
LDFLAGS = -s -lboost_regex -lncurses -ltinfo
BPP = bpp
# Install directories
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
SHARED_OBJS = \
bin/obj/shared/explode.o \
bin/obj/shared/to_lower.o \
bin/obj/shared/is_number.o \
bin/obj/shared/parse_block_units.o \
bin/obj/shared/process_special_chars.o \
bin/obj/shared/parse_regex.o \
bin/obj/block.o \
bin/obj/file.o \
bin/obj/polonius-editor/expression.o \
bin/obj/polonius/window.o \
bin/obj/polonius/widget.o \
bin/obj/polonius/helppane.o \
bin/obj/polonius/textdisplay.o \
bin/obj/polonius/message.o \
bin/obj/polonius/searchpane.o
all: src/shared/version.h
$(MAKE) bin/polonius-editor bin/polonius-reader
bin/%: bin/obj/%/main.o $(SHARED_OBJS)
$(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
bin/obj/%.o: src/%.cpp
$(CXX) -c $< -o $@ $(CXXFLAGS) $(LDFLAGS)
bin/obj/polonius-editor/%.o: src/edit/%.cpp
$(CXX) -c $< -o $@ $(CXXFLAGS) $(LDFLAGS)
bin/obj/polonius-reader/%.o: src/read/%.cpp
$(CXX) -c $< -o $@ $(CXXFLAGS) $(LDFLAGS)
bin/obj/polonius/%.o: src/tui/%.cpp
$(CXX) -c $< -o $@ $(CXXFLAGS) $(LDFLAGS)
bin/obj/shared/%.o: src/shared/%.cpp
$(CXX) -c $< -o $@ $(CXXFLAGS) $(LDFLAGS)
src/shared/version.h: debian/changelog
@# Read the latest version number from debian/changelog
@# And update shared/version.h with that number
@# This ensures that the output of --version
@# For each of the binaries is always up-to-date
@ \
if [ "$(VERSION)" != "" ]; then \
echo "#define program_version \"$(VERSION)\"" > src/shared/version.h; \
echo "$(VERSION)"; \
else \
echo "#define program_version \"unknown\"" > src/shared/version.h; \
echo "Could not parse debian/changelog for version number"; \
fi
manual:
@# Git pull wiki & run pandoc to create manual pages
@# You must have Git and Pandoc installed for this
@ \
if [ -d "$(WIKIDIRECTORY)" ]; then \
cd "$(WIKIDIRECTORY)" && git pull "$(WIKIUPSTREAM)"; \
else \
git clone "$(WIKIUPSTREAM)" "$(WIKIDIRECTORY)"; \
fi;
pandoc --standalone --to man "$(WIKIDIRECTORY)/Polonius-Editor.md" -o debian/polonius-editor.1
pandoc --standalone --to man "$(WIKIDIRECTORY)/Polonius-Reader.md" -o debian/polonius-reader.1
test-suite/run.sh: test-suite/run.bpp test-suite/TestRunner.bpp test-suite/Test.bpp test-suite/TestStats.bpp
@$(BPP) -o test-suite/run.sh test-suite/run.bpp
test: test-suite/run.sh
@if [ ! -f bin/polonius-editor ] || [ ! -f bin/polonius-reader ]; then \
echo "Binaries not found. Please run 'make all' first."; \
exit 1; \
fi
@cd test-suite && ./run.sh
clean: clean-manual clean-binaries clean-tests clean-wiki
@rm -f bin/obj/*.o
@rm -f bin/obj/polonius-editor/*.o
@rm -f bin/obj/polonius-reader/*.o
@rm -f bin/obj/shared/*.o
@rm -f bin/obj/*.d
@rm -f bin/obj/polonius-editor/*.d
@rm -f bin/obj/polonius-reader/*.d
@rm -f bin/obj/shared/*.d
@rm -f src/shared/version.h
@echo "Cleaned up build artifacts."
clean-manual:
@rm -f debian/polonius-editor.1
@rm -f debian/polonius-reader.1
@echo "Cleaned up manual pages."
clean-binaries:
@rm -f bin/polonius-editor
@rm -f bin/polonius-reader
@echo "Cleaned up binaries."
clean-tests:
@rm -f tests/debug/*
@rm -f tests/results/*
@echo "Cleaned up test results."
clean-wiki:
@if [ -d "$(WIKIDIRECTORY)" ]; then \
rm -rf "$(WIKIDIRECTORY)"; \
echo "Removed wiki directory $(WIKIDIRECTORY)"; \
fi
install: all
@install -Dm755 bin/polonius-editor "$(BINDIR)/polonius-editor"
@install -Dm755 bin/polonius-reader "$(BINDIR)/polonius-reader"
@echo "Installed polonius binaries to $(BINDIR)"
uninstall:
@rm -f "$(BINDIR)/polonius-editor"
@rm -f "$(BINDIR)/polonius-reader"
@echo "Uninstalled polonius binaries from $(BINDIR)"
.PHONY: all clean clean-manual clean-binaries clean-tests clean-wiki manual test install uninstall
-include $(shell find bin/obj -name '*.d' 2>/dev/null)