]> git.tuebingen.mpg.de Git - dss.git/blob - Makefile
build: Add target install and install-strip.
[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 DEBUG_CFLAGS ?=
14 DEBUG_CFLAGS += -Wno-sign-compare -g -Wunused -Wundef
15 DEBUG_CFLAGS += -Wredundant-decls
16 CFLAGS ?=
17 CFLAGS += -Os
18 CFLAGS += -Wall
19 CFLAGS += -Wuninitialized
20 CFLAGS += -Wchar-subscripts
21 CFLAGS += -Wformat-security
22 CFLAGS += -Werror-implicit-function-declaration
23 CFLAGS += -Wmissing-format-attribute
24 CFLAGS += -Wunused-macros
25 CFLAGS += -Wunused-parameter
26 CFLAGS += -Wbad-function-cast
27 CFLAGS += -Wshadow
28
29 Makefile.deps: $(wildcard *.c *.h)
30         gcc -MM -MG *.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 -DVERSION_STRING='"$(VERSION_STRING)"' $(CFLAGS) $(DEBUG_CFLAGS) $<
39
40 %.png: %.dia
41         dia -e $@ -t png $<
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 >> $@