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