Makefile 1.23 KB
Newer Older
Patrick J Cherry's avatar
Patrick J Cherry committed
1
2
3
program      := $(notdir $(CURDIR))
conf         := $(program).conf
conf_tmp     := $(conf).tmp
4
snippets_dir := symbiosis.d
Patrick J Cherry's avatar
Patrick J Cherry committed
5
6
7
snippets     := $(shell find $(CURDIR)/$(snippets_dir) -mindepth 1 -regextype posix-basic -type f -regex '.*/[a-z0-9][a-z0-9-]\+' | sort) 

ifeq ($(program),dovecot)
8
test_args = -a -c $(conf_tmp)
Patrick J Cherry's avatar
Patrick J Cherry committed
9
else ifeq ($(program),exim4)
10
test_args = -bV -C $(CURDIR)/$(conf_tmp)
Patrick J Cherry's avatar
Patrick J Cherry committed
11
12
13
14
endif

all: $(conf)

15
$(conf): test
Patrick J Cherry's avatar
Patrick J Cherry committed
16
17
	@mv -fb $(conf_tmp) $(conf)

18
19
20
21
22
#
# Add an explicit dependency on the header, to make sure that the snippets
# directory has at least that bit.
#
$(conf_tmp): distclean Makefile $(snippets) $(CURDIR)/$(snippets_dir)/00-header
23
	@touch $(conf_tmp)
Patrick J Cherry's avatar
Patrick J Cherry committed
24
25
26
27
28
29
30
31
	@for s in $(snippets) ; do \
	    echo "# ------------------------------------------------------------------------------" >>  $(conf_tmp)  ;\
	    echo "# $$s" >> $(conf_tmp)  ;\
	    echo "# ------------------------------------------------------------------------------" >>  $(conf_tmp)  ;\
	    echo >> $(conf_tmp)  ;\
	    cat $$s >> $(conf_tmp) ;\
	done

32
33
test: $(conf_tmp)
	@/usr/sbin/$(program) $(test_args) > /dev/null
Patrick J Cherry's avatar
Patrick J Cherry committed
34
35
36
37
38
39
40
41

distclean:
	@rm -f $(conf_tmp)

clean:
	@rm -f $(conf)

# We always want the temporary config to be remade.
42
.PHONY: $(conf_tmp) clean distclean test
Patrick J Cherry's avatar
Patrick J Cherry committed
43

44
.PRECIOUS: $(conf)