X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=Makefile;h=e9e391709a8f9bbe35892a5a7e3742f1eb29a8d5;hb=92dc834e982d4b71ce6a3fcc2c973e555afd3fcf;hp=2f96388a09fad913bcbb1458bf700dd67087b194;hpb=14330fbdf398c3786803a001f0130b0d9ab70b46;p=apps%2Fpfixtools.git diff --git a/Makefile b/Makefile index 2f96388..e9e3917 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,58 +29,45 @@ # THE POSSIBILITY OF SUCH DAMAGE. # ############################################################################## -include mk/cflags.mk -CFLAGS += --std=gnu99 -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 +prefix ?= /usr/local -PROGRAMS = postlicyd +PROGRAMS = postlicyd pfix-srsd +LIBS = common +SUBDIRS = $(LIBS) $(PROGRAMS) -GENERATED = tokens.h tokens.c - -postlicyd_SOURCES = \ - str.h buffer.h job.h postfix.h gai.h \ - str.c buffer.c job.c postfix.c gai.c \ - postlicyd.c $(GENERATED) - -postlicyd_LIBADD = -lanl +CLEAN_TARGETS = $(addprefix clean-,$(SUBDIRS)) +DISTCLEAN_TARGETS = $(addprefix distclean-,$(SUBDIRS)) +INSTALL_TARGETS = $(addprefix install-,$(SUBDIRS)) # RULES ###################################################################{{{ -all: $(PROGRAMS) - -clean: - $(RM) $(PROGRAMS) - $(RM) .*.o - -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) -%.c: %.sh - ./$< $@ || ($(RM) $@; exit 1) +install: all $(INSTALL_TARGETS) -%.h: %.sh - ./$< $@ || ($(RM) $@; exit 1) +$(PROGRAMS): $(LIBS) -.%.o: %.c Makefile - $(CC) $(CFLAGS) -MMD -MT ".$*.d $@" -MF .$*.d -g -c -o $@ $< +$(SUBDIRS): %: + make -C $@ all -%.d: %.c Makefile - $(CC) $(CFLAGS) -MM -MT ".$*.d $@" -MF .$*.d $< +$(CLEAN_TARGETS): clean-%: + make -C $* clean -.SECONDEXPANSION: +$(DISTCLEAN_TARGETS): distclean-%: + make -C $* distclean -$(PROGRAMS): $$(patsubst %.c,.%.o,$$($$@_SOURCES)) Makefile - $(CC) -o $@ $(CFLAGS) $(filter %.o,$^) $(LDFLAGS) $($@_LIBADD) $(filter %.a,$^) +$(INSTALL_TARGETS): install-%: % install-dir + make -C $* install --include $(foreach p,$(PROGRAMS),$(patsubst %.c,.%.d,$(filter %.c,$($p_SOURCES)))) +install-dir: + install -d $(DESTDIR)$(prefix)/sbin + install -d $(DESTDIR)/etc/pfixtools + install example/postlicyd.conf $(DESTDIR)/etc/pfixtools/postlicyd.example.conf +.PHONY: clean distclean install install-dir $(SUBDIRS) $(CLEAN_TARGETS) \ + $(DISTCLEAN_TARGETS) $(INSTALL_TARGETS) ###########################################################################}}}