]> git.tuebingen.mpg.de Git - dss.git/blob - Makefile
build: Use variables for lobsubgen and rm commands.
[dss.git] / Makefile
1 # SPDX-License-Identifier: GPL-2.0
2 PREFIX ?= /usr/local
3 INSTALL ?= install
4 INSTALL_PROGRAM ?= $(INSTALL)
5 INSTALL_DATA ?= $(INSTALL) -m 644
6 MKDIR_P := mkdir -p
7 VERSION := $(shell ./version-gen.sh dss version.c)
8 RM := rm -f
9 LSG := lopsubgen
10 GROFF := groff -m man -Thtml -P -l -P -r
11
12 units := dss str file exec sig daemon df tv snap ipc dss.lsg version
13 objs := $(addsuffix .o, $(units))
14 deps := $(addsuffix .d, $(units))
15
16 all: dss dss.1
17 man: dss.1
18 $(objs): dss.lsg.h Makefile
19 -include $(deps)
20
21 DSS_CPPFLAGS += -Wunused-macros
22
23 DSS_CFLAGS := -Wno-sign-compare -g -Wunused -Wundef
24 DSS_CFLAGS += -Wredundant-decls
25 DSS_CFLAGS += -Os
26 DSS_CFLAGS += -Wall
27 DSS_CFLAGS += -Wuninitialized
28 DSS_CFLAGS += -Wchar-subscripts
29 DSS_CFLAGS += -Wformat-security
30 DSS_CFLAGS += -Werror-implicit-function-declaration
31 DSS_CFLAGS += -Wmissing-format-attribute
32 DSS_CFLAGS += -Wunused-parameter
33 DSS_CFLAGS += -Wbad-function-cast
34 DSS_CFLAGS += -Wshadow
35
36 .ONESHELL:
37 .SHELLFLAGS := -ec
38 ifeq ("$(origin V)", "command line")
39         SAY =
40 else
41         SAY = @printf '%s\n' '$(strip $(1))'
42 endif
43 version.c:
44         $(call SAY, VG $@)
45         ./version-gen.sh dss version.c > /dev/null
46 dss: $(objs)
47         $(call SAY, LD $@)
48         $(CC) -o $@ $(objs) $(LDFLAGS) -llopsub
49 %.o: %.c
50         $(call SAY, CC $<)
51         $(CC) -c -o $@ $(DSS_CPPFLAGS) $(CPPFLAGS) $(DSS_CFLAGS) $(CFLAGS) \
52                 -MMD -MF $(*F).d -MT $@ $<
53 %.lsg.h: %.suite
54         $(call SAY, LSGH $<)
55         $(LSG) --gen-h=$@ < $<
56 %.lsg.c: %.suite
57         $(call SAY, LSGC $<)
58         $(LSG) --gen-c=$@ < $<
59 %.1: %.suite
60         $(call SAY, LSGM $<)
61         $(LSG) --gen-man=$@ --version-string=$(VERSION) < $<
62 %.1.html: %.1
63         $(call SAY, GROFF $<)
64         $(GROFF) $< | sed -e '1,/^<body>/d; /^<\/body>/,$$d' > $@
65 clean:
66         $(call SAY, CLEAN)
67         $(RM) *.[od] dss dss.1 *.html dss.lsg.[ch] version.c
68
69 ifneq ($(findstring strip, $(MAKECMDGOALS)),)
70        strip_option := -s
71 endif
72 bindir := $(DESTDIR)$(PREFIX)/bin
73 mandir := $(DESTDIR)$(PREFIX)/share/man/man1
74 install install-strip: all
75         $(MKDIR_P) $(bindir) $(mandir)
76         $(INSTALL_PROGRAM) $(strip_option) dss $(bindir)
77         $(INSTALL_DATA) dss.1 $(mandir)
78
79 index.html: dss.1.html index.html.in INSTALL README NEWS
80         sed -e '/@README@/,$$d' index.html.in > $@
81         markdown README >> $@
82         sed -e '1,/@README@/d' -e '/@NEWS@/,$$d' index.html.in >> $@
83         markdown NEWS >> $@
84         sed -e '1,/@NEWS@/d' -e '/@INSTALL@/,$$d' index.html.in >> $@
85         markdown INSTALL >> $@
86         sed -e '1,/@INSTALL@/d' -e '/@MAN_PAGE@/,$$d' index.html.in >> $@
87         cat dss.1.html >> $@
88         sed -e '1,/@MAN_PAGE@/d' index.html.in >> $@
89
90 -include Makefile.local