1 # SPDX-License-Identifier: GPL-2.0
6 INSTALL_PROGRAM ?= $(INSTALL)
7 INSTALL_DATA ?= $(INSTALL) -m 644
10 VERSION := $(shell $(MKDIR_P) $(B) && ./version-gen.sh $(PACKAGE) $(B)/version.c)
13 GROFF := groff -m man -t -Thtml -P -l -P -r -P -I -P image
16 M4 := m4 -D "PACKAGE=$(PACKAGE)" defs.m4
17 c_source := $(PACKAGE) str file exec sig daemon df tv snap ipc
18 c_generated := $(B)/$(PACKAGE).lsg $(B)/version
19 objs := $(addsuffix .o, $(c_generated) $(addprefix $(B)/, $(c_source)))
21 all := $(PACKAGE) $(PACKAGE).1.gz
22 www := $(B)/index.html $(B)/$(PACKAGE).1.html $(B)/$(PACKAGE)
27 $(objs): $(B)/$(PACKAGE).lsg.h Makefile
30 DSS_CPPFLAGS += -Wunused-macros
31 DSS_CPPFLAGS += -I$(B)
33 DSS_CFLAGS := -Wno-sign-compare -g -Wunused -Wundef
34 DSS_CFLAGS += -Wredundant-decls
37 DSS_CFLAGS += -Wuninitialized
38 DSS_CFLAGS += -Wchar-subscripts
39 DSS_CFLAGS += -Wformat-security
40 DSS_CFLAGS += -Werror-implicit-function-declaration
41 DSS_CFLAGS += -Wmissing-format-attribute
42 DSS_CFLAGS += -Wunused-parameter
43 DSS_CFLAGS += -Wbad-function-cast
44 DSS_CFLAGS += -Wshadow
46 CC_CMD = $(CC) -c -o $@ $(DSS_CPPFLAGS) $(CPPFLAGS) $(DSS_CFLAGS) $(CFLAGS) \
47 -MMD -MF $(B)/$(*F).d -MT $@ $<
48 LD_CMD = $(CC) -o $@ $(objs) $(LDFLAGS) -llopsub
52 ifeq ("$(origin V)", "command line")
55 SAY = @printf '%s\n' '$(strip $(1))'
59 ./version-gen.sh $(PACKAGE) version.c > /dev/null
63 $(B)/$(PACKAGE): $(objs)
74 .PHONY: all www clean distclean maintainer-clean install README
75 .PRECIOUS: $(B)/%.lsg.c $(B)/%.lsg.h $(B)/%.suite $(B)/%.1
76 $(B)/$(PACKAGE).suite: $(PACKAGE).suite.m4 defs.m4 Makefile
79 $(B)/%.lsg.h: $(B)/%.suite
81 $(LSG) --gen-h=$@ < $<
82 $(B)/%.lsg.c: $(B)/%.suite
84 $(LSG) --gen-c=$@ < $<
85 $(B)/%.1: $(B)/%.suite
87 $(LSG) --gen-man=$@ --version-string=$(VERSION) < $<
91 $(B)/%.1.html: $(B)/%.1
94 $(GROFF) ../$< > ../$@
95 $(B)/index.html: index.html.m4 Makefile defs.m4 dss.svg
100 $(RM) $(B)/*.o $(B)/*.d $(all) $(www)
102 $(call SAY, DISTCLEAN)
104 maintainer-clean: distclean
105 $(call SAY, MAINTANER-CLEAN)
106 $(GIT) clean -dfqxe Makefile.local
108 ifneq ($(findstring strip, $(MAKECMDGOALS)),)
111 bindir := $(DESTDIR)$(PREFIX)/bin
112 mandir := $(DESTDIR)$(PREFIX)/share/man/man1
113 install install-strip: all
114 $(MKDIR_P) $(bindir) $(mandir)
115 $(INSTALL_PROGRAM) $(strip_option) $(PACKAGE) $(bindir)
116 $(INSTALL_DATA) $(PACKAGE).1.gz $(mandir)
121 -include Makefile.local