forked from newsboat/newsboat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
374 lines (285 loc) · 11.4 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# important directories
prefix?=/usr/local
mandir?=$(prefix)/share/man
datadir?=$(prefix)/share
localedir?=$(datadir)/locale
docdir?=$(datadir)/doc/$(PACKAGE)
CPPCHECK_JOBS?=5
# compiler
CXX?=c++
# compiler and linker flags
DEFINES=-DLOCALEDIR=\"$(localedir)\"
ifneq ($(wildcard .git/.),)
GIT_HASH:=$(shell git describe --abbrev=4 --dirty --always --tags)
DEFINES+=-DGIT_HASH=\"$(GIT_HASH)\"
endif
WARNFLAGS=-Werror -Wall -Wextra -Wunreachable-code
INCLUDES=-Iinclude -Istfl -Ifilter -I. -Irss
BARE_CXXFLAGS=-std=c++11 -O2 -ggdb $(INCLUDES)
LDFLAGS+=-L.
PACKAGE=newsboat
ifeq (, $(filter $(MAKECMDGOALS),distclean run-i18nspector))
include config.mk
endif
ifeq ($(PROFILE),1)
BARE_CXXFLAGS+=-O0 -fprofile-arcs -ftest-coverage
LDFLAGS+=-fprofile-arcs -ftest-coverage
endif
CXXFLAGS:=$(BARE_CXXFLAGS) $(WARNFLAGS) $(DEFINES) $(CXXFLAGS)
LIB_SOURCES:=$(shell cat mk/libboat.deps)
LIB_OBJS:=$(patsubst %.cpp,%.o,$(LIB_SOURCES))
LIB_OUTPUT=libboat.a
FILTERLIB_SOURCES=filter/Scanner.cpp filter/Parser.cpp filter/FilterParser.cpp
FILTERLIB_OBJS:=$(patsubst %.cpp,%.o,$(FILTERLIB_SOURCES))
FILTERLIB_OUTPUT=libfilter.a
NEWSBOAT=newsboat
NEWSBOAT_SOURCES:=$(shell cat mk/newsboat.deps)
NEWSBOAT_OBJS:=$(patsubst %.cpp,%.o,$(NEWSBOAT_SOURCES))
NEWSBOAT_LIBS=-lboat -lfilter -lpthread -lrsspp
RSSPPLIB_SOURCES=$(sort $(wildcard rss/*.cpp))
RSSPPLIB_OBJS=$(patsubst rss/%.cpp,rss/%.o,$(RSSPPLIB_SOURCES))
RSSPPLIB_OUTPUT=librsspp.a
CARGO_FLAGS+=--verbose
ifeq ($(PROFILE),1)
NEWSBOATLIB_OUTPUT=rust/libnewsboat-ffi/target/debug/libnewsboat.a
LDFLAGS+=-L./rust/libnewsboat-ffi/target/debug
else
NEWSBOATLIB_OUTPUT=rust/libnewsboat-ffi/target/release/libnewsboat.a
LDFLAGS+=-L./rust/libnewsboat-ffi//target/release
CARGO_FLAGS+=--release
endif
LDFLAGS+=-lnewsboat -lpthread -ldl
PODBOAT=podboat
PODBOAT_SOURCES:=$(shell cat mk/podboat.deps)
PODBOAT_OBJS:=$(patsubst %.cpp,%.o,$(PODBOAT_SOURCES))
PODBOAT_LIBS=-lboat -lpthread
ifeq (, $(filter Linux GNU GNU/%, $(shell uname -s)))
NEWSBOAT_LIBS+=-liconv -lintl
PODBOAT_LIBS+=-liconv -lintl
endif
# additional commands
MKDIR=mkdir -p
INSTALL=install
A2X=a2x
MSGFMT=msgfmt
RANLIB?=ranlib
AR?=ar
CHMOD=chmod
STFLHDRS:=$(patsubst %.stfl,%.h,$(wildcard stfl/*.stfl))
POFILES:=$(wildcard po/*.po)
MOFILES:=$(patsubst %.po,%.mo,$(POFILES))
POTFILE=po/newsboat.pot
TEXTCONV=./txt2h
RM=rm -f
all: doc $(NEWSBOAT) $(PODBOAT) mo-files
NB_DEPS=xlicense.h $(LIB_OUTPUT) $(FILTERLIB_OUTPUT) $(NEWSBOAT_OBJS) $(RSSPPLIB_OUTPUT) $(NEWSBOATLIB_OUTPUT)
$(NEWSBOATLIB_OUTPUT): .FORCE
( cd rust/libnewsboat-ffi && cargo build $(CARGO_FLAGS) )
$(NEWSBOAT): $(NB_DEPS)
$(CXX) $(CXXFLAGS) -o $(NEWSBOAT) $(NEWSBOAT_OBJS) $(NEWSBOAT_LIBS) $(LDFLAGS)
$(PODBOAT): $(LIB_OUTPUT) $(NEWSBOATLIB_OUTPUT) $(PODBOAT_OBJS)
$(CXX) $(CXXFLAGS) -o $(PODBOAT) $(PODBOAT_OBJS) $(PODBOAT_LIBS) $(LDFLAGS)
$(LIB_OUTPUT): $(LIB_OBJS)
$(RM) $@
$(AR) qc $@ $^
$(RANLIB) $@
$(RSSPPLIB_OUTPUT): $(RSSPPLIB_OBJS)
$(RM) $@
$(AR) qc $@ $^
$(RANLIB) $@
$(FILTERLIB_OUTPUT): $(FILTERLIB_OBJS)
$(RM) $@
$(AR) qc $@ $^
$(RANLIB) $@
regenerate-parser:
$(RM) filter/Scanner.cpp filter/Parser.cpp filter/Scanner.h filter/Parser.h
cococpp -frames filter filter/filter.atg
%.o: %.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $<
%.h: %.stfl
$(TEXTCONV) $< .stfl > $@
clean-newsboat:
$(RM) $(NEWSBOAT) $(NEWSBOAT_OBJS)
clean-podboat:
$(RM) $(PODBOAT) $(PODBOAT_OBJS)
clean-libboat:
$(RM) $(LIB_OUTPUT) $(LIB_OBJS)
clean-librsspp:
$(RM) $(RSSPPLIB_OUTPUT) $(RSSPPLIB_OBJS)
clean-libfilter:
$(RM) $(FILTERLIB_OUTPUT) $(FILTERLIB_OBJS)
clean-libnewsboat:
( cd rust/libnewsboat && cargo clean )
( cd rust/libnewsboat-ffi && cargo clean )
clean-doc:
$(RM) -r doc/xhtml
$(RM) doc/*.xml doc/*.1 doc/newsboat-cfgcmds.txt doc/podboat-cfgcmds.txt \
doc/newsboat-keycmds.txt doc/configcommands-linked.dsv \
doc/podboat-cmds-linked.dsv doc/keycmds-linked.dsv \
doc/gen-example-config doc/example-config doc/generate doc/generate2
clean: clean-newsboat clean-podboat clean-libboat clean-libfilter clean-doc clean-librsspp clean-libnewsboat
$(RM) $(STFLHDRS) xlicense.h
distclean: clean clean-mo test-clean profclean
$(RM) core *.core core.* config.mk
doc: doc/newsboat.1 doc/podboat.1 doc/xhtml/newsboat.html doc/xhtml/faq.html
doc/xhtml/newsboat.html: doc/newsboat.txt doc/chapter-firststeps.txt doc/configcommands-linked.dsv \
doc/keycmds-linked.dsv doc/chapter-tagging.txt doc/chapter-snownews.txt \
doc/chapter-cmdline.txt doc/chapter-podcasts.txt doc/podboat-cmds-linked.dsv \
doc/chapter-password.txt doc/chapter-environment-variables.txt
$(MKDIR) doc/xhtml
$(A2X) -f xhtml -D doc/xhtml doc/newsboat.txt
$(CHMOD) u+w doc/xhtml/docbook-xsl.css
echo "/* AsciiDoc's new tables have <p> inside <td> which wastes vertical space, so fix it */" >> doc/xhtml/docbook-xsl.css
echo "td > p { margin: 0; }" >> doc/xhtml/docbook-xsl.css
echo "td > p + p { margin-top: 0.5em; }" >> doc/xhtml/docbook-xsl.css
echo "td > pre { margin: 0; white-space: pre-wrap; }" >> doc/xhtml/docbook-xsl.css
doc/xhtml/faq.html: doc/faq.txt
$(MKDIR) doc/xhtml
$(A2X) -f xhtml -D doc/xhtml doc/faq.txt
$(CHMOD) u+w doc/xhtml/docbook-xsl.css
echo "/* AsciiDoc's new tables have <p> inside <td> which wastes vertical space, so fix it */" >> doc/xhtml/docbook-xsl.css
echo "td > p { margin: 0; }" >> doc/xhtml/docbook-xsl.css
echo "td > p + p { margin-top: 0.5em; }" >> doc/xhtml/docbook-xsl.css
echo "td > pre { margin: 0; white-space: pre-wrap; }" >> doc/xhtml/docbook-xsl.css
doc/generate: doc/generate.cpp doc/split.h
$(CXX) $(CXXFLAGS) -o doc/generate doc/generate.cpp
doc/newsboat-cfgcmds.txt: doc/generate doc/configcommands.dsv
doc/generate doc/configcommands.dsv > doc/newsboat-cfgcmds.txt
doc/generate2: doc/generate2.cpp
$(CXX) $(CXXFLAGS) -o doc/generate2 doc/generate2.cpp
doc/newsboat-keycmds.txt: doc/generate2 doc/keycmds.dsv
doc/generate2 doc/keycmds.dsv > doc/newsboat-keycmds.txt
doc/newsboat.1: doc/manpage-newsboat.txt doc/chapter-firststeps.txt doc/newsboat-cfgcmds.txt \
doc/newsboat-keycmds.txt doc/chapter-tagging.txt doc/chapter-snownews.txt \
doc/chapter-cmdline.txt doc/chapter-environment-variables.txt
$(A2X) -f manpage doc/manpage-newsboat.txt
doc/podboat-cfgcmds.txt: doc/generate doc/podboat-cmds.dsv
doc/generate doc/podboat-cmds.dsv 'pb-' > doc/podboat-cfgcmds.txt
doc/podboat.1: doc/manpage-podboat.txt doc/chapter-podcasts.txt doc/podboat-cfgcmds.txt \
doc/chapter-environment-variables.txt
$(A2X) -f manpage doc/manpage-podboat.txt
doc/gen-example-config: doc/gen-example-config.cpp doc/split.h
$(CXX) $(CXXFLAGS) -o doc/gen-example-config doc/gen-example-config.cpp
doc/example-config: doc/gen-example-config doc/configcommands.dsv
sed 's/+{backslash}"+/`\\"`/g' doc/configcommands.dsv | doc/gen-example-config > doc/example-config
# add hyperlinks for every configuration command
doc/configcommands-linked.dsv: doc/configcommands.dsv
sed -E 's/^([^|]+)/[[\1]]<<\1,`\1`>>/' doc/configcommands.dsv > doc/configcommands-linked.dsv
# add hyperlinks for every configuration command
doc/podboat-cmds-linked.dsv: doc/podboat-cmds.dsv
sed -E 's/^([^|]+)/[[\1]]<<\1,`\1`>>/' doc/podboat-cmds.dsv > doc/podboat-cmds-linked.dsv
doc/keycmds-linked.dsv: doc/keycmds.dsv
sed -E 's/^([^|]+)/[[\1]]<<\1,`\1`>>/' doc/keycmds.dsv > doc/keycmds-linked.dsv
fmt:
clang-format --style=file -i *.cpp doc/*.cpp include/*.h rss/*.h rss/*.cpp src/*.cpp test/*.h test/*.cpp
cppcheck:
cppcheck -j$(CPPCHECK_JOBS) --force --enable=all --suppress=unusedFunction \
-DDEBUG=1 \
$(INCLUDES) $(DEFINES) \
include filter newsboat.cpp podboat.cpp rss src stfl \
test/*.cpp test/*.h \
2>cppcheck.log
@echo "Done! See cppcheck.log for details."
install-newsboat: $(NEWSBOAT) doc/$(NEWSBOAT).1
$(MKDIR) $(DESTDIR)$(prefix)/bin
$(INSTALL) $(NEWSBOAT) $(DESTDIR)$(prefix)/bin
$(MKDIR) $(DESTDIR)$(mandir)/man1
$(INSTALL) -m 644 doc/$(NEWSBOAT).1 $(DESTDIR)$(mandir)/man1 || true
install-podboat: $(PODBOAT) doc/$(PODBOAT).1
$(MKDIR) $(DESTDIR)$(prefix)/bin
$(INSTALL) $(PODBOAT) $(DESTDIR)$(prefix)/bin
$(MKDIR) $(DESTDIR)$(mandir)/man1
$(INSTALL) -m 644 doc/$(PODBOAT).1 $(DESTDIR)$(mandir)/man1 || true
install-docs: doc
$(MKDIR) $(DESTDIR)$(docdir)
$(INSTALL) -m 644 doc/xhtml/* $(DESTDIR)$(docdir) || true
install-examples: doc/example-config
$(MKDIR) $(DESTDIR)$(docdir)/examples
$(INSTALL) -m 644 doc/example-config $(DESTDIR)$(docdir)/examples/config || true
install: install-newsboat install-podboat install-docs install-examples install-mo
uninstall: uninstall-mo
$(RM) $(DESTDIR)$(prefix)/bin/$(NEWSBOAT)
$(RM) $(DESTDIR)$(prefix)/bin/$(PODBOAT)
$(RM) $(DESTDIR)$(mandir)/man1/$(NEWSBOAT).1
$(RM) $(DESTDIR)$(mandir)/man1/$(PODBOAT).1
$(RM) -rf $(DESTDIR)$(docdir)
$(RM) -r $(DESTDIR)$(docdir)
.PHONY: doc clean distclean all test test-rss extract install uninstall regenerate-parser clean-newsboat \
clean-podboat clean-libboat clean-librsspp clean-libfilter clean-doc install-mo msgmerge clean-mo \
test-clean config cppcheck
# the following targets are i18n/l10n-related:
run-i18nspector: $(POFILES)
i18nspector $^
mo-files: $(MOFILES)
extract:
$(RM) $(POTFILE)
xgettext -c/ -k_ -k_s -o $(POTFILE) *.cpp src/*.cpp rss/*.cpp
sed -i 's#Report-Msgid-Bugs-To: \\n#Report-Msgid-Bugs-To: https://github.com/newsboat/newsboat/issues\\n#' $(POTFILE)
msgmerge:
for f in $(POFILES) ; do msgmerge -U $$f $(POTFILE) ; done
%.mo: %.po
$(MSGFMT) --check --statistics -o $@ $<
clean-mo:
$(RM) $(MOFILES) po/*~
install-mo: mo-files
$(MKDIR) $(DESTDIR)$(datadir)
@for mof in $(MOFILES) ; do \
mofile=`basename $$mof` ; \
lang=`echo $$mofile | sed 's/\.mo$$//'`; \
dir=$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES; \
$(MKDIR) $$dir ; \
$(INSTALL) -m 644 $$mof $$dir/$(PACKAGE).mo ; \
echo "Installing $$mofile as $$dir/$(PACKAGE).mo" ; \
done
uninstall-mo:
@for mof in $(MOFILES) ; do \
mofile=`basename $$mof` ; \
lang=`echo $$mofile | sed 's/\.mo$$//'`; \
dir=$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES; \
$(RM) -f $$dir/$(PACKAGE).mo ; \
echo "Uninstalling $$dir/$(PACKAGE).mo" ; \
done
# tests and coverage reports
test: test/test
TEST_SRCS:=$(wildcard test/*.cpp)
TEST_OBJS:=$(patsubst %.cpp,%.o,$(TEST_SRCS))
test/test: xlicense.h $(LIB_OUTPUT) $(NEWSBOATLIB_OUTPUT) $(NEWSBOAT_OBJS) $(PODBOAT_OBJS) $(FILTERLIB_OUTPUT) $(RSSPPLIB_OUTPUT) $(TEST_OBJS) test/test-helpers.h
$(CXX) $(CXXFLAGS) -o test/test $(TEST_OBJS) src/*.o $(NEWSBOAT_LIBS) $(LDFLAGS)
test-clean:
$(RM) test/test test/*.o
profclean:
find . -name '*.gc*' -type f -print0 | xargs -0 $(RM) --
$(RM) app*.info
# Substitutes for Cargo commands
#
# Since we split our Rust code into multiple crates, it takes a bit of effort
# to run all the checks and tests. These commands hide all that complexity from
# the programmer.
cargo-check:
(cd rust/libnewsboat && cargo check)
(cd rust/libnewsboat-ffi && cargo check)
cargo-doc:
(cd rust/libnewsboat && cargo doc)
(cd rust/libnewsboat-ffi && cargo doc)
cargo-test:
(cd rust/libnewsboat && cargo test)
(cd rust/libnewsboat-ffi && cargo test)
# miscellaneous stuff
config: config.mk
config.mk:
@./config.sh
xlicense.h: LICENSE
$(TEXTCONV) $< > $@
ALL_SRCS:=$(wildcard filter/*.cpp rss/*.cpp src/*.cpp test/*.cpp)
ALL_HDRS:=$(wildcard filter/*.h rss/*.h test/*.h 3rd-party/*.hpp) $(STFLHDRS) xlicense.h
depslist: $(ALL_SRCS) $(ALL_HDRS)
> mk/mk.deps
for dir in filter rss src test ; do \
for file in $$dir/*.cpp ; do \
target=`echo $$file | sed 's/cpp$$/o/'`; \
$(CXX) $(BARE_CXXFLAGS) -MM -MG -MQ $$target $$file >> mk/mk.deps ; \
echo $$file ; \
done; \
done
.FORCE:
include mk/mk.deps