# THE POSSIBILITY OF SUCH DAMAGE. #
##############################################################################
-all:
-
-LDFLAGS += -Wl,--warn-common
-
-include mk/cflags.mk
-
-CFLAGS += --std=gnu99 -D_GNU_SOURCE
prefix ?= /usr/local
PROGRAMS = postlicyd pfix-srsd
-TESTS = tst-rbl
-
-GENERATED = tokens.h tokens.c
-
-postlicyd_SOURCES = common.c threads.c str.c buffer.c rbl.c \
- $(GENERATED) postfix.c main-postlicyd.c
-postlicyd_LIBADD = -lpthread
-
-pfix-srsd_SOURCES = common.c epoll.c buffer.c str.c main-srsd.c
-pfix-srsd_LIBADD = -lsrs2
+LIBS = common
+SUBDIRS = $(LIBS) $(PROGRAMS)
-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) $(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
- $(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
+
+install-postlicyd: install-postlicyd-tools install-postlicyd-conf
+install-dir:
+ install -d $(DESTDIR)$(prefix)/sbin
+ install -d $(DESTDIR)/etc/pfixtools
-.SECONDEXPANSION:
+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 $@ $(CFLAGS) $($@_CFLAGS) $(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
###########################################################################}}}