X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=Makefile;h=e7f631d0c220c629ea78a693f0436f7efa705abb;hb=7723ba1a23042c5bd6a920feabd93d3d373c9d55;hp=881191892fc5c291429aa2e48447046af087e0d2;hpb=2472ae9bd2a2a22a278ffe586fd381e70c881e8d;p=apps%2Fpfixtools.git diff --git a/Makefile b/Makefile index 8811918..e7f631d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ ############################################################################## -# postlicyd: a postfix policy daemon with a lot of features # +# pfixtools: a collection of postfix related tools # # ~~~~~~~~~ # # ________________________________________________________________________ # # # @@ -29,62 +29,44 @@ # THE POSSIBILITY OF SUCH DAMAGE. # ############################################################################## -LDFLAGS += -Wl,--warn-common +prefix ?= /usr/local -include mk/cflags.mk +PROGRAMS = postlicyd pfix-srsd +LIBS = common +SUBDIRS = $(LIBS) $(PROGRAMS) -CFLAGS += --std=gnu99 -D_GNU_SOURCE - -PROGRAMS = postlicyd srsd -TESTS = tst-rbl - -GENERATED = tokens.h tokens.c - -postlicyd_SOURCES = common.c str.c buffer.c daemon.c rbl.c postfix.c \ - $(GENERATED) postlicyd.c -postlicyd_LIBADD = -lpthread - -srsd_SOURCES = common.c buffer.c str.c daemon.c srsd.c -srsd_LIBADD = -lsrs2 - -tst-rbl_SOURCES = tst-rbl.c +CLEAN_TARGETS = $(addprefix clean-,$(SUBDIRS)) +DISTCLEAN_TARGETS = $(addprefix distclean-,$(SUBDIRS)) +INSTALL_TARGETS = $(addprefix install-,$(SUBDIRS)) # RULES ###################################################################{{{ -all: $(PROGRAMS) $(GENERATED) | $(GENERATED) - -clean: - $(RM) $(PROGRAMS) $(TESTS) .*.o .*.dep - -distclean: clean - $(RM) $(GENERATED) +all: $(SUBDIRS) -tags: .tags -.tags: $(shell git ls-files | egrep '\.[hc]$$') - ctags -o $@ $^ +clean: $(CLEAN_TARGETS) -headers: HEADACHEOPTS=-c mk/headache.cfg -h COPYING -headers: - @which headache > /dev/null || \ - ( echo "package headache not installed" ; exit 1 ) - @git ls-files | egrep '(\.h|\.c|Makefile|*\.mk)$$' | xargs -t headache $(HEADACHEOPTS) +distclean: $(DISTCLEAN_TARGETS) -%.h: %.sh - ./$< $@ || ($(RM) $@; exit 1) +install: all $(INSTALL_TARGETS) -%.c: %.sh - ./$< $@ || ($(RM) $@; exit 1) +$(PROGRAMS): $(LIBS) -.%.o: %.c Makefile - $(CC) $(CFLAGS) -MMD -MT ".$*.dep $@" -MF .$*.dep -g -c -o $@ $< +$(SUBDIRS): %: + make -C $@ all -.%.dep: .%.o +$(CLEAN_TARGETS): clean-%: + make -C $* clean -.SECONDEXPANSION: +$(DISTCLEAN_TARGETS): distclean-%: + make -C $* distclean -$(PROGRAMS) $(TESTS): $$(patsubst %.c,.%.o,$$($$@_SOURCES)) Makefile common.ld - $(CC) -o $@ $(CFLAGS) $($@_CFLAGS) $(filter %.ld,$^) $(filter %.o,$^) $(LDFLAGS) $($@_LIBADD) $(filter %.a,$^) +$(INSTALL_TARGETS): install-%: % install-dir + make -C $* install --include $(foreach p,$(PROGRAMS) $(TESTS),$(patsubst %.c,.%.dep,$(filter %.c,$($p_SOURCES)))) +install-dir: + install -d $(DESTDIR)$(prefix)/sbin + install -d $(DESTDIR)/etc/pfixtools +.PHONY: clean distclean install install-dir $(SUBDIRS) $(CLEAN_TARGETS) \ + $(DISTCLEAN_TARGETS) $(INSTALL_TARGETS) ###########################################################################}}}