# SPDX-License-Identifier: GPL-3.0-only .SUFFIXES: MAKEFLAGS += -Rr .ONESHELL: .SHELLFLAGS := -ec RM := rm -f MKDIR_P := mkdir -p CHMOD := chmod ifeq ("$(origin CC)", "default") CC := cc endif ifeq ("$(origin V)", "command line") SAY = else SAY = @echo '$(strip $(1))' endif AUTHOR := Andre Noll COPYRIGHT_YEAR := 2018 CLONE_URL := git://git.tuebingen.mpg.de/tfortune GITWEB_URL := http://git.tuebingen.mpg.de/tfortune.git LICENSE := GNU GPL version 3 LICENSE_URL := https://www.gnu.org/licenses/gpl-3.0-standalone.html define DESCRIPTION1 := Like fortune(1), 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) cc_version := $(shell $(CC) --version | head -n 1) build_date := $(shell date) uname_rs := $(shell uname -rs) all := tfortune tfortune.1 all: $(all) 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 "PACKAGE_BUGREPORT=$(PACKAGE_BUGREPORT)" \ -D "PACKAGE_URL=$(PACKAGE_URL)" \ -D "CLONE_URL=$(CLONE_URL)" \ -D "GITWEB_URL=$(GITWEB_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 < $< %.1: %.suite version.c $(call SAY, LSGM $<) $(LOPSUBGEN) --gen-man=$@ --version-string $(GIT_VERSION) < $< %.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 += -DAUTHOR='"$(AUTHOR)"' 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 += -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 mostlyclean: $(RM) tfortune *.o *.d clean: mostlyclean $(RM) *.lsg.* *.flex.* *.bison.* *.1 *.suite distclean: clean $(RM) config.mak config.status config.log config.h config.h.in version.c $(RM) -r autom4te.cache maintainer-clean: git clean -dfqx > /dev/null 2>&1 mandir := $(datarootdir)/man/man1 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) $(INSTALL_PROGRAM) $(strip_option) tfortune $(DESTDIR)$(bindir) $(INSTALL_DATA) tfortune.1 $(DESTDIR)$(mandir) define README := tfortune - fortune cookies with tags ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $(DESCRIPTION1) $(DESCRIPTION2) $(DESCRIPTION3) Resources ~~~~~~~~~ | git clone URL: $(CLONE_URL) | web page: $(PACKAGE_URL) | email: $(AUTHOR) <$(PACKAGE_BUGREPORT)> Documentation ~~~~~~~~~~~~~ See tfortune.suite. Or build the man page with \"make tfortune.1\" and run \"man -l tfortune.1\". 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)"