# SPDX-License-Identifier: GPL-2.0 .SUFFIXES: MAKEFLAGS += -Rr .ONESHELL: .SHELLFLAGS := -ec RM := rm -f MKDIR_P := mkdir -p ifeq ("$(origin CC)", "default") CC := cc endif ifeq ("$(origin V)", "command line") SAY = else SAY = @echo '$(strip $(1))' endif COPYRIGHT_YEAR := 2018 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 ifeq ($(findstring clean, $(MAKECMDGOALS)),) -include $(deps) include config.mak endif .PRECIOUS: %.flex.c %.bison.c %.bison.h %.lsg.h %.lsg.c %.lsg.h # created by version-gen.sh version.c: %.lsg.c: %.suite $(call SAY, LSGC $<) $(LOPSUBGEN) --gen-c < $< %.lsg.h: %.suite $(call SAY, LSGH $<) $(LOPSUBGEN) --gen-header < $< %.1: %.suite $(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 += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"' TF_CPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)' TF_CPPFLAGS += -DBUILD_DATE='"$(build_date)"' TF_CPPFLAGS += -DCC_VERSION='"$(cc_version)"' TF_CPPFLAGS += -DUNAME_RS='"$(uname_rs)"' 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 %.flex.o: TF_CFLAGS += -Wno-all %.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 tfortune: $(deps:.d=.o) $(call SAY, LD $@) $(CC) $^ -o $@ $(TF_LDFLAGS) $(LDFLAGS) .PHONY: all mostlyclean clean install install-strip mostlyclean: $(RM) tfortune *.o *.d clean: mostlyclean $(RM) *.lsg.* *.flex.* *.bison.* *.1 version.c distclean: clean $(RM) config.mak config.status config.log config.h configure config.h.in $(RM) -r autom4te.cache maintainer-clean: distclean 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)