X-Git-Url: http://git.madism.org/?p=apps%2Fpfixtools.git;a=blobdiff_plain;f=Makefile;h=b2290cb9312cbe75466b533a68e366d7e097d8a6;hp=d4c2aa0d154a89bd36d81c0bf12942a6fafc86b5;hb=7fa8c1bc673add68529fa2bda8134be5089e8745;hpb=10b49f7af56977b8c27a26438b3cfb07ca63ae90 diff --git a/Makefile b/Makefile index d4c2aa0..b2290cb 100644 --- a/Makefile +++ b/Makefile @@ -29,78 +29,56 @@ # THE POSSIBILITY OF SUCH DAMAGE. # ############################################################################## -all: - -LDFLAGS += -Wl,--warn-common - -include mk/cflags.mk -include mk/tc.mk - -CFLAGS += --std=gnu99 -D_GNU_SOURCE prefix ?= /usr/local PROGRAMS = postlicyd pfix-srsd -LIBS = lib -TESTS = tst-rbl - -GENERATED = tokens.h tokens.c - -lib_SOURCES = str.c buffer.c common.c epoll.c $(GENERATED) - -postlicyd_SOURCES = greylist.c rbl.c main-postlicyd.c server.c lib.a -postlicyd_LIBADD = $(TC_LIBS) +LIBS = common +SUBDIRS = $(LIBS) $(PROGRAMS) -pfix-srsd_SOURCES = main-srsd.c lib.a -pfix-srsd_LIBADD = -lsrs2 - -tst-rbl_SOURCES = tst-rbl.c - -install: all - install -d $(DESTDIR)$(prefix)/sbin - install $(PROGRAMS) $(DESTDIR)$(prefix)/sbin - install -d $(DESTDIR)/etc/pfixtools +CLEAN_TARGETS = $(addprefix clean-,$(SUBDIRS)) +DISTCLEAN_TARGETS = $(addprefix distclean-,$(SUBDIRS)) +INSTALL_TARGETS = $(addprefix install-,$(SUBDIRS)) # RULES ###################################################################{{{ -all: $(GENERATED) $(PROGRAMS) | $(GENERATED) +all: $(SUBDIRS) -clean: - $(RM) $(LIBS:=.a) $(PROGRAMS) $(TESTS) .*.o .*.dep +clean: $(CLEAN_TARGETS) -distclean: clean - $(RM) $(GENERATED) +distclean: $(DISTCLEAN_TARGETS) -tags: .tags -.tags: $(shell git ls-files | egrep '\.[hc]$$') - ctags -o $@ $^ +install: all $(INSTALL_TARGETS) -headers: HEADACHEOPTS=-c mk/headache.cfg -h mk/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) +$(PROGRAMS): $(LIBS) -%.h: %.sh - ./$< $@ || ($(RM) $@; exit 1) +$(SUBDIRS): %: + make -C $@ all -%.c: %.sh - ./$< $@ || ($(RM) $@; exit 1) +$(CLEAN_TARGETS): clean-%: + make -C $* clean -.%.o: %.c Makefile - $(shell test -d $(@D) || mkdir -p $(@D)) - $(CC) $(CFLAGS) -MMD -MT ".$*.dep $@" -MF .$*.dep -g -c -o $@ $< +$(DISTCLEAN_TARGETS): distclean-%: + make -C $* distclean -.%.dep: .%.o +$(INSTALL_TARGETS): install-%: % install-dir + make -C $* install -.SECONDEXPANSION: +install-postlicyd: install-postlicyd-tools install-postlicyd-conf +install-dir: + install -d $(DESTDIR)$(prefix)/sbin + install -d $(DESTDIR)/etc/pfixtools -$(LIBS:=.a): $$(patsubst %.c,.%.o,$$($$(patsubst %.a,%,$$@)_SOURCES)) Makefile - $(RM) $@ - $(AR) rcs $@ $(filter %.o,$^) +install-postlicyd-tools: + install tools/postlicyd-rsyncrbl $(DESTDIR)$(prefix)/bin/postlicyd-rsyncrbl + install tools/postgrey2postlicyd $(DESTDIR)$(prefix)/bin/postgrey2postlicyd + install tools/rbldns2postlicyd $(DESTDIR)$(prefix)/bin/rbldns2postlicyd -$(PROGRAMS) $(TESTS): $$(patsubst %.c,.%.o,$$($$@_SOURCES)) Makefile common.ld - $(CC) -o $@ $(filter %.ld,$^) $(filter %.o,$^) $(LDFLAGS) $($@_LIBADD) $(filter %.a,$^) +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 --include $(foreach p,$(PROGRAMS) $(TESTS),$(patsubst %.c,.%.dep,$(filter %.c,$($p_SOURCES)))) +.PHONY: clean distclean install install-dir $(SUBDIRS) $(CLEAN_TARGETS) \ + $(DISTCLEAN_TARGETS) $(INSTALL_TARGETS) install-postlicyd-tools \ + install-postlicyd-conf ###########################################################################}}}