]> git.tuebingen.mpg.de Git - dss.git/blobdiff - Makefile
build: Use variables for lobsubgen and rm commands.
[dss.git] / Makefile
index a60a65b3e34e99f643ff4493cfff0c1b8d76a44d..3f3afd32e24d2af85b5350ea97b9b6f0501a6a03 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,14 +4,19 @@ INSTALL ?= install
 INSTALL_PROGRAM ?= $(INSTALL)
 INSTALL_DATA ?= $(INSTALL) -m 644
 MKDIR_P := mkdir -p
+VERSION := $(shell ./version-gen.sh dss version.c)
+RM := rm -f
+LSG := lopsubgen
 
-VERSION_STRING = 1.0.1
+units := dss str file exec sig daemon df tv snap ipc dss.lsg version
+objs := $(addsuffix .o, $(units))
+deps := $(addsuffix .d, $(units))
 
-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
 all: dss dss.1
 man: dss.1
+$(objs): dss.lsg.h Makefile
+-include $(deps)
 
-DSS_CPPFLAGS := -DVERSION_STRING='"$(VERSION_STRING)"'
 DSS_CPPFLAGS += -Wunused-macros
 
 DSS_CFLAGS := -Wno-sign-compare -g -Wunused -Wundef
@@ -27,29 +32,39 @@ DSS_CFLAGS += -Wunused-parameter
 DSS_CFLAGS += -Wbad-function-cast
 DSS_CFLAGS += -Wshadow
 
-Makefile.deps: $(wildcard *.c *.h)
-       $(CC) -MM -MG $(DSS_CPPFLAGS) $(CPPFLAGS) $(DSS_CFLAGS) $(CFLAGS) *.c > $@
-
--include Makefile.deps
-
-dss: $(dss_objects)
-       $(CC) -o $@ $(dss_objects) $(LDFLAGS) -llopsub
-
-%.o: %.c Makefile
-       $(CC) -c $(DSS_CPPFLAGS) $(CPPFLAGS) $(DSS_CFLAGS) $(CFLAGS) $<
-
+.ONESHELL:
+.SHELLFLAGS := -ec
+ifeq ("$(origin V)", "command line")
+       SAY =
+else
+       SAY = @echo '$(strip $(1))'
+endif
+version.c:
+       $(call SAY, VG $@)
+       ./version-gen.sh dss version.c
+dss: $(objs)
+       $(call SAY, LD $@)
+       $(CC) -o $@ $(objs) $(LDFLAGS) -llopsub
+%.o: %.c
+       $(call SAY, CC $<)
+       $(CC) -c -o $@ $(DSS_CPPFLAGS) $(CPPFLAGS) $(DSS_CFLAGS) $(CFLAGS) \
+               -MMD -MF $(*F).d -MT $@ $<
 %.lsg.h: %.suite
-       lopsubgen --gen-h=$@ < $<
+       $(call SAY, LSGH $<)
+       $(LSG) --gen-h=$@ < $<
 %.lsg.c: %.suite
-       lopsubgen --gen-c=$@ < $<
+       $(call SAY, LSGC $<)
+       $(LSG) --gen-c=$@ < $<
 %.1: %.suite
-       lopsubgen --gen-man=$@ --version-string=$(VERSION_STRING) < $<
-
+       $(call SAY, LSGM $<)
+       $(LSG) --gen-man=$@ --version-string=$(VERSION) < $<
 %.1.html: %.1
+       $(call SAY, GROFF $<)
        groff -m man -Thtml -P -l -P -r $< | sed -e '1,/^<body>/d; /^<\/body>/,$$d' > $@
 
 clean:
-       rm -f *.o dss dss.1 dss.1.html Makefile.deps *~ index.html dss.lsg.h dss.lsg.c
+       $(call SAY, CLEAM)
+       $(RM) *.[od] dss dss.1 *.html dss.lsg.[ch] version.c
 
 ifneq ($(findstring strip, $(MAKECMDGOALS)),)
        strip_option := -s
@@ -71,3 +86,5 @@ index.html: dss.1.html index.html.in INSTALL README NEWS
        sed -e '1,/@INSTALL@/d' -e '/@MAN_PAGE@/,$$d' index.html.in >> $@
        cat dss.1.html >> $@
        sed -e '1,/@MAN_PAGE@/d' index.html.in >> $@
+
+-include Makefile.local