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