simplify top-level makefile using more generic constructs.
authorPierre Habouzit <madcoder@debian.org>
Sun, 11 Jan 2009 18:33:36 +0000 (19:33 +0100)
committerPierre Habouzit <madcoder@debian.org>
Sun, 11 Jan 2009 18:39:28 +0000 (19:39 +0100)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Makefile

index 7fb3235..f6c11dd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -38,38 +38,19 @@ PROGRAMS = postlicyd pfix-srsd
 LIBS     = common
 SUBDIRS  = $(LIBS) $(PROGRAMS)
 
-CLEAN_TARGETS     = $(addprefix clean-,$(SUBDIRS))
-DISTCLEAN_TARGETS = $(addprefix distclean-,$(SUBDIRS))
-INSTALL_TARGETS   = $(addprefix install-,$(SUBDIRS))
-
 # RULES ###################################################################{{{
 
-all: $(SUBDIRS)
-
-clean: $(CLEAN_TARGETS)
-
-distclean: $(DISTCLEAN_TARGETS)
-
-install: all $(INSTALL_TARGETS)
-
-$(PROGRAMS): $(LIBS)
-
-$(SUBDIRS): %:
-       make -C $@ all
-
-$(CLEAN_TARGETS): clean-%:
-       make -C $* clean
-
-$(DISTCLEAN_TARGETS): distclean-%:
-       make -C $* distclean
+all clean distclean doc install: %: %-recurse
 
-$(INSTALL_TARGETS): install-%: % install-dir
-       make -C $* install
+%-recurse:
+       @set -e $(foreach dir,$(SUBDIRS),; $(MAKE) -C $(dir) $*)
 
-install-postlicyd: install-postlicyd-tools install-postlicyd-conf
+install-recurse: install-dir
+install: install-postlicyd-tools install-postlicyd-conf
 install-dir:
        install -d $(DESTDIR)$(prefix)/sbin
        install -d $(DESTDIR)$(prefix)/bin
+       install -d $(DESTDIR)$(prefix)/share/doc/pfixtools
        install -d $(DESTDIR)/etc/pfixtools
 
 install-postlicyd-tools:
@@ -81,8 +62,6 @@ install-postlicyd-conf:
        install -m 640 example/postlicyd.conf $(DESTDIR)/etc/pfixtools/postlicyd.example.conf
        install -m 640 example/postlicyd-rsyncrbl.conf $(DESTDIR)/etc/pfixtools/postlicyd-rsyncrbl.example.conf
 
-.PHONY: clean distclean install install-dir $(SUBDIRS) $(CLEAN_TARGETS) \
-                               $(DISTCLEAN_TARGETS) $(INSTALL_TARGETS) install-postlicyd-tools \
-                               install-postlicyd-conf
+.PHONY: clean distclean install install-% %-recurse
 
 ###########################################################################}}}