X-Git-Url: http://git.madism.org/?p=apps%2Fpfixtools.git;a=blobdiff_plain;f=Makefile;h=88e599de711eee90f184a9ff7a110c9b04691cb3;hp=a0f9786804638cd00e2bd365706e5cc854a1b8f2;hb=e327d3786ba0371eaaff8e6ba0fe3fc39f095ae2;hpb=ab8bc5aee397b411abd0358171e990e8bc4647d6 diff --git a/Makefile b/Makefile index a0f9786..88e599d 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 = threads.c str.c buffer.c common.c epoll.c $(GENERATED) - -postlicyd_SOURCES = greylist.c rbl.c main-postlicyd.c lib.a -postlicyd_LIBADD = -lpthread $(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 example/postlicyd.conf $(DESTDIR)/etc/pfixtools/postlicyd.example.conf + install 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 ###########################################################################}}}