File: Makefile

package info (click to toggle)
tfortune 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 248 kB
  • sloc: ansic: 2,477; makefile: 227; yacc: 85; sh: 25
file content (258 lines) | stat: -rw-r--r-- 7,369 bytes parent folder | download
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
# SPDX-License-Identifier: GPL-3.0-only

.SUFFIXES:
MAKEFLAGS += -Rr
.ONESHELL:
.SHELLFLAGS := -ec

RM := rm -f
MKDIR_P := mkdir -p
CHMOD := chmod
GZIP := gzip -nf9

ifeq ("$(origin CC)", "default")
        CC := cc
endif
ifeq ("$(origin V)", "command line")
	SAY =
else
	SAY = @echo '$(strip $(1))'
endif

PACKAGE := tfortune
SLOGAN := fortune cookies with tags
AUTHOR := Andre Noll
EMAIL := maan@tuebingen.mpg.de
COPYRIGHT_YEAR := 2019
PACKAGE_HOMEPAGE := https://people.tuebingen.mpg.de/maan/$(PACKAGE)/
CLONE_URL := https://git.tuebingen.mpg.de/$(PACKAGE)/
GITWEB_URL := https://git.tuebingen.mpg.de/$(PACKAGE).git
LICENSE := GNU GPL version 3
LICENSE_URL := https://www.gnu.org/licenses/gpl-3.0-standalone.html
HOME_URL := https://people.tuebingen.mpg.de/maan/

define DESCRIPTION1 :=
	Like fortune(6), tfortune is a Unix command line utility which prints
	a random epigram. Epigrams are stored as plain text files, but they
	must be annotated with tags to make full use of the features which
	tfortune offers over other implementations.
endef

define DESCRIPTION2 :=
	Tfortune has a built-in matching language for epigrams. User-supplied
	tag expressions define subsets of admissible epigrams. If a tag
	expression is given, epigrams are picked from the admissible subset
	only.
endef

define DESCRIPTION3 :=
	Besides printing random epigrams, tfortune supports a number of other
	subcommands which help to maintain epigrams and tag expressions. There
	are subcommands for listing and for editing the input files, and for
	printing statistics about epigrams, expressions and tags. A subcommand
	that enables bash command line completion is also included.
endef
LOGLEVELS := LL_DEBUG,LL_INFO,LL_NOTICE,LL_WARNING,LL_ERROR,LL_CRIT,LL_EMERG
GIT_VERSION := $(shell ./version-gen.sh $(PACKAGE) version.c)
cc_version := $(shell $(CC) --version | head -n 1)
build_date := $(shell date)
uname_rs := $(shell uname -rs)

exe := tfortune
man := tfortune.6.gz
epigrams := epigrams/en.tfortunes
all: $(man) $(exe)
man build-indep: $(man)
exe build-arch: $(exe)

deps := txp.bison.d txp.flex.d ast.d tfortune.d util.d txp.flex.d \
	tfortune.lsg.d version.d linhash.d

ifeq ($(findstring clean, $(MAKECMDGOALS)),)
-include $(deps)
-include config.mak
endif

config.h.in: configure.ac
	$(call SAY, AH $<)
	autoheader -f
config.mak config.h: config.status config.mak.in config.h.in
	$(call SAY, CS $@)
	./config.status -q
	test -f config.h && touch config.h
config.status: configure.sh
	$(call SAY, CFG)
	if test -x config.status; then \
		./config.status --recheck; \
	else \
		./configure.sh --no-create; \
	fi
configure.sh: configure.ac
	$(call SAY, AC $<)
	autoconf configure.ac > $@
	$(CHMOD) 755 $@

.PRECIOUS: %.flex.c %.bison.c %.bison.h %.lsg.h %.lsg.c %.lsg.h

# created by version-gen.sh
version.c:

index.html tfortune.suite: %: %.m4
	$(call SAY, M4 $<)
	$(M4) -D "AUTHOR=$(AUTHOR)" -D "COPYRIGHT_YEAR=$(COPYRIGHT_YEAR)" \
		-D "DATADIR=$(datadir)" \
		-D "PACKAGE=$(PACKAGE)" \
		-D "SLOGAN=$(SLOGAN)" \
		-D "EMAIL=$(EMAIL)" \
		-D "PACKAGE_URL=$(PACKAGE_URL)" \
		-D "PACKAGE_HOMEPAGE=$(PACKAGE_HOMEPAGE)" \
		-D "CLONE_URL=$(CLONE_URL)" \
		-D "GITWEB_URL=$(GITWEB_URL)" \
		-D "HOME_URL=$(HOME_URL)" \
		-D "LICENSE=$(LICENSE)" \
		-D "LICENSE_URL=$(LICENSE_URL)" \
		-D "DESCRIPTION1=$(DESCRIPTION1)" \
		-D "DESCRIPTION2=$(DESCRIPTION2)" \
		-D "DESCRIPTION3=$(DESCRIPTION3)" $< > $@
%.lsg.c: %.suite
	$(call SAY, LSGC $<)
	$(LOPSUBGEN) --gen-c < $<

%.lsg.h: %.suite
	$(call SAY, LSGH $<)
	$(LOPSUBGEN) --gen-header < $<

%.6.gz: %.suite version.c
	$(call SAY, LSGM $<)
	$(LOPSUBGEN) --gen-man=${@:.gz=} --version-string $(GIT_VERSION) < $<
	$(GZIP) ${@:.gz=}

%.flex.c: %.lex
	$(call SAY, FLEX $<)
	$(FLEX) -o $@ $<

%.bison.c %.bison.h: %.y
	$(call SAY, BISON $<)
	$(BISON) --defines=$(notdir $(<:.y=.bison.h)) \
		--output=$(notdir $(<:.y=.bison.c)) $<

TF_CPPFLAGS += -Wunused-macros
TF_CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"'
TF_CPPFLAGS += -DPACKAGE='"$(PACKAGE)"'
TF_CPPFLAGS += -DAUTHOR='"$(AUTHOR)"'
TF_CPPFLAGS += -DEMAIL='"$(EMAIL)"'
TF_CPPFLAGS += -DPACKAGE_HOMEPAGE='"$(PACKAGE_HOMEPAGE)"'
TF_CPPFLAGS += -DCLONE_URL='"$(CLONE_URL)"'
TF_CPPFLAGS += -DGITWEB_URL='"$(GITWEB_URL)"'
TF_CPPFLAGS += -DHOME_URL='"$(HOME_URL)"'
TF_CPPFLAGS += -DGET_VERSION='$(PACKAGE)_version'
TF_CPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)'
TF_CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
TF_CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
TF_CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
TF_CPPFLAGS += -DLICENSE='"$(LICENSE)"'
TF_CPPFLAGS += -DLICENSE_URL='"$(LICENSE_URL)"'
TF_CPPFLAGS += -DDATADIR='"$(datadir)"'
TF_CPPFLAGS += -I/usr/local/include

TF_CFLAGS += -g
TF_CFLAGS += -O2
TF_CFLAGS += -Wall
TF_CFLAGS += -Wundef -W -Wuninitialized
TF_CFLAGS += -Wchar-subscripts
TF_CFLAGS += -Werror-implicit-function-declaration
TF_CFLAGS += -Wmissing-noreturn
TF_CFLAGS += -Wbad-function-cast
TF_CFLAGS += -Wredundant-decls
TF_CFLAGS += -Wdeclaration-after-statement
TF_CFLAGS += -Wformat -Wformat-security -Wmissing-format-attribute
#TF_CFLAGS += -fsanitize=address

%.flex.o: TF_CFLAGS += -Wno-all -Wno-sign-compare -Wno-unused-parameter
%.flex.o %.bison.o: TF_CPPFLAGS += -Wno-unused-macros

%.o: %.c tfortune.lsg.h txp.bison.h
	$(call SAY, CC $<)
	$(CC) \
		-o $@ -c -MMD -MF $(*F).d \
		-MT $@ $(TF_CPPFLAGS) $(CPPFLAGS) $(TF_CFLAGS) $(CFLAGS) $<

TF_LDFLAGS = -llopsub
#TF_LDFLAGS += -fsanitize=address

tfortune: $(deps:.d=.o)
	$(call SAY, LD $@)
	$(CC) $^ -o $@ $(TF_LDFLAGS) $(LDFLAGS)

.PHONY: all mostlyclean clean distclan maintainer-clean install \
	install-strip README exe build-arch man build-indep

mostlyclean:
	$(RM) $(exe) *.o *.d
clean: mostlyclean
	$(RM) *.lsg.* *.flex.* *.bison.* $(man) *.suite
distclean: clean
	$(RM) config.mak config.status config.log config.h config.h.in \
		version.c configure.sh
	$(RM) -r autom4te.cache
maintainer-clean:
	git clean -dfqx > /dev/null 2>&1

mandir := $(datarootdir)/man/man6
epidir := $(datadir)/tfortunes/epigrams
INSTALL ?= install
INSTALL_PROGRAM ?= $(INSTALL) -m 755
INSTALL_DATA ?= $(INSTALL) -m 644
ifneq ($(findstring strip, $(MAKECMDGOALS)),)
	strip_option := -s
endif

install install-strip: all
	$(MKDIR_P) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir) $(DESTDIR)$(epidir)
	$(INSTALL_PROGRAM) $(strip_option) $(exe) $(DESTDIR)$(bindir)
	$(INSTALL_DATA) $(man) $(DESTDIR)$(mandir)
	$(INSTALL_DATA) $(epigrams) $(DESTDIR)$(epidir)

define README :=
tfortune - $(SLOGAN)

$(DESCRIPTION1)

$(DESCRIPTION2)

$(DESCRIPTION3)

Resources
~~~~~~~~~
|	web page: $(PACKAGE_HOMEPAGE)
|	git clone URL: $(CLONE_URL)
|	gitweb: $(GITWEB_URL)
|	author's home page: $(HOME_URL)
|	Send feedback to: $(AUTHOR) <$(EMAIL)>

Documentation
~~~~~~~~~~~~~
See tfortune.suite. Or build the man page with \"make man\"
and run \"man -l $(man)\".

Dependencies
~~~~~~~~~~~~
This package requires m4, autoconf, gnu make, flex, bison, gcc or
clang, and lopsub. The configure script checks if all required
dependencies are installed and prints a meaningful error message if
one of them is missing.

Building
~~~~~~~~
Run \"make\" to build tfortune with the default settings. Run
\"./configure -h\" to list configuration options.

Installation
~~~~~~~~~~~~
Run \"sudo make install\" to install to /usr/local. To install to
/somewhere/else, run \"./configure --prefix /somewhere/else && make\"
first.
endef

README:
	@printf '%s\n' "$(README)"