]> 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
11 units := dss str file exec sig daemon df tv snap ipc dss.lsg version
12 objs := $(addsuffix .o, $(units))
13 deps := $(addsuffix .d, $(units))
14
15 all: dss dss.1
16 man: dss.1
17 $(objs): dss.lsg.h Makefile
18 -include $(deps)
19
20 DSS_CPPFLAGS += -Wunused-macros
21
22 DSS_CFLAGS := -Wno-sign-compare -g -Wunused -Wundef
23 DSS_CFLAGS += -Wredundant-decls
24 DSS_CFLAGS += -Os
25 DSS_CFLAGS += -Wall
26 DSS_CFLAGS += -Wuninitialized
27 DSS_CFLAGS += -Wchar-subscripts
28 DSS_CFLAGS += -Wformat-security
29 DSS_CFLAGS += -Werror-implicit-function-declaration
30 DSS_CFLAGS += -Wmissing-format-attribute
31 DSS_CFLAGS += -Wunused-parameter
32 DSS_CFLAGS += -Wbad-function-cast
33 DSS_CFLAGS += -Wshadow
34
35 .ONESHELL:
36 .SHELLFLAGS := -ec
37 ifeq ("$(origin V)", "command line")
38         SAY =
39 else
40         SAY = @echo '$(strip $(1))'
41 endif
42 version.c:
43         $(call SAY, VG $@)
44         ./version-gen.sh dss version.c
45 dss: $(objs)
46         $(call SAY, LD $@)
47         $(CC) -o $@ $(objs) $(LDFLAGS) -llopsub
48 %.o: %.c
49         $(call SAY, CC $<)
50         $(CC) -c -o $@ $(DSS_CPPFLAGS) $(CPPFLAGS) $(DSS_CFLAGS) $(CFLAGS) \
51                 -MMD -MF $(*F).d -MT $@ $<
52 %.lsg.h: %.suite
53         $(call SAY, LSGH $<)
54         $(LSG) --gen-h=$@ < $<
55 %.lsg.c: %.suite
56         $(call SAY, LSGC $<)
57         $(LSG) --gen-c=$@ < $<
58 %.1: %.suite
59         $(call SAY, LSGM $<)
60         $(LSG) --gen-man=$@ --version-string=$(VERSION) < $<
61 %.1.html: %.1
62         $(call SAY, GROFF $<)
63         groff -m man -Thtml -P -l -P -r $< | sed -e '1,/^<body>/d; /^<\/body>/,$$d' > $@
64
65 clean:
66         $(call SAY, CLEAM)
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