]> git.tuebingen.mpg.de Git - dss.git/blob - Makefile
build: Create dependencies on the fly and implement dynamic versioning
[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
9 units := dss str file exec sig daemon df tv snap ipc dss.lsg version
10 objs := $(addsuffix .o, $(units))
11 deps := $(addsuffix .d, $(units))
12
13 all: dss dss.1
14 man: dss.1
15 $(objs): dss.lsg.h Makefile
16 -include $(deps)
17
18 DSS_CPPFLAGS += -Wunused-macros
19
20 DSS_CFLAGS := -Wno-sign-compare -g -Wunused -Wundef
21 DSS_CFLAGS += -Wredundant-decls
22 DSS_CFLAGS += -Os
23 DSS_CFLAGS += -Wall
24 DSS_CFLAGS += -Wuninitialized
25 DSS_CFLAGS += -Wchar-subscripts
26 DSS_CFLAGS += -Wformat-security
27 DSS_CFLAGS += -Werror-implicit-function-declaration
28 DSS_CFLAGS += -Wmissing-format-attribute
29 DSS_CFLAGS += -Wunused-parameter
30 DSS_CFLAGS += -Wbad-function-cast
31 DSS_CFLAGS += -Wshadow
32
33 version.c:
34         ./version-gen.sh dss version.c
35 dss: $(objs)
36         $(CC) -o $@ $(objs) $(LDFLAGS) -llopsub
37 %.o: %.c
38         $(CC) -c -o $@ $(DSS_CPPFLAGS) $(CPPFLAGS) $(DSS_CFLAGS) $(CFLAGS) \
39                 -MMD -MF $(*F).d -MT $@ $<
40 %.lsg.h: %.suite
41         lopsubgen --gen-h=$@ < $<
42 %.lsg.c: %.suite
43         lopsubgen --gen-c=$@ < $<
44 %.1: %.suite
45         lopsubgen --gen-man=$@ --version-string=$(VERSION) < $<
46
47 %.1.html: %.1
48         groff -m man -Thtml -P -l -P -r $< | sed -e '1,/^<body>/d; /^<\/body>/,$$d' > $@
49
50 clean:
51         rm -f *.[od] dss dss.1 *.html dss.lsg.[ch] version.c
52
53 ifneq ($(findstring strip, $(MAKECMDGOALS)),)
54        strip_option := -s
55 endif
56 bindir := $(DESTDIR)$(PREFIX)/bin
57 mandir := $(DESTDIR)$(PREFIX)/share/man/man1
58 install install-strip: all
59         $(MKDIR_P) $(bindir) $(mandir)
60         $(INSTALL_PROGRAM) $(strip_option) dss $(bindir)
61         $(INSTALL_DATA) dss.1 $(mandir)
62
63 index.html: dss.1.html index.html.in INSTALL README NEWS
64         sed -e '/@README@/,$$d' index.html.in > $@
65         markdown README >> $@
66         sed -e '1,/@README@/d' -e '/@NEWS@/,$$d' index.html.in >> $@
67         markdown NEWS >> $@
68         sed -e '1,/@NEWS@/d' -e '/@INSTALL@/,$$d' index.html.in >> $@
69         markdown INSTALL >> $@
70         sed -e '1,/@INSTALL@/d' -e '/@MAN_PAGE@/,$$d' index.html.in >> $@
71         cat dss.1.html >> $@
72         sed -e '1,/@MAN_PAGE@/d' index.html.in >> $@
73
74 -include Makefile.local