base.m4: Line-wrap the DKIM warning header.
[exim-config] / Makefile
CommitLineData
185b5456
MW
1### -*-makefile-*-
2###
3### Build script for Exim configuration
4###
5### (c) 2012 Mark Wooding
6###
7
8###----- Licensing notice ---------------------------------------------------
9###
10### This program is free software; you can redistribute it and/or modify
11### it under the terms of the GNU General Public License as published by
12### the Free Software Foundation; either version 2 of the License, or
13### (at your option) any later version.
14###
15### This program is distributed in the hope that it will be useful,
16### but WITHOUT ANY WARRANTY; without even the implied warranty of
17### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18### GNU General Public License for more details.
19###
20### You should have received a copy of the GNU General Public License
21### along with this program; if not, write to the Free Software Foundation,
22### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
c376fbe7
MW
24###--------------------------------------------------------------------------
25### Utility macros.
26
27## Silent-rules machinery.
185b5456
MW
28V = 0
29v_tag = $(call v_tag_$V,$1)
30v_tag_0 = @printf " %-6s %s\n" $1 $@;
31
32V_GEN = $(call v_tag,GEN)
33V_AT = $(V_AT_$V)
34V_AT_0 = @
35
c376fbe7 36## Splitting things at slashes -- don't leave the slash.
185b5456
MW
37dir-nosl = $(patsubst %/,%,$(dir $1))
38
c376fbe7
MW
39###--------------------------------------------------------------------------
40### Introductory machinery.
41
185b5456
MW
42all:
43.SECONDEXPANSION: # sorry
44
45CLEANFILES += $(TARGETS)
46
c376fbe7
MW
47###--------------------------------------------------------------------------
48### Main source files.
49
50## There's a base set of files, and a number of optional modules. A
51## collection of modules is called a `mode', and we generate an output file
52## for each required mode.
53
185b5456
MW
54EARLY = defs.m4 divmap.m4 config.m4
55MAIN = lists.m4 base.m4
56
57MODES =
58
59MODES += satellite
8fca6182 60OPTIONS_satellite = satellite.m4 sat-rewrite.m4
185b5456 61
a924b8b3 62MODES += srv
7c43ea06 63CONF_srv = sysdomains=
4fd7858a 64OPTIONS_srv = exchange.m4 spam.m4 vhost.m4 sat-rewrite.m4
a924b8b3 65
185b5456 66MODES += hub
3865ac97 67OPTIONS_hub = auth.m4 exchange.m4 local.m4 spam.m4
d90bdbcf 68OPTIONS_hub += user-spam.m4 vhost.m4 vhost-local.m4
185b5456
MW
69
70MODES += usersat
71OPTIONS_usersat = auth.m4 local.m4 satellite.m4
72
25539fc6 73-include site.mk
185b5456
MW
74-include local.mk
75
c376fbe7
MW
76###--------------------------------------------------------------------------
77### Resolving what needs to be built.
78
185b5456
MW
79HOST_MODES += $(foreach m, $(MODES), \
80 $(foreach h, $(HOSTS_$m), $h/$m))
81
82CONFIGS = $(foreach m, $(MODES), exim4-$m.conf)
83TARGETS += $(CONFIGS)
84$(CONFIGS): exim4-%.conf: $(EARLY) $$(HOOKS_$$*) $(MAIN) $$(OPTIONS_$$*)
7c43ea06 85 $(V_GEN)m4 -P -DMODE=$* $(CONF_$*:%=-DCONF_%) $^ >$@.new
5918499b 86 $(V_AT)$(CHECK_$*)exim4 -C$$(pwd)/$@.new -bV >/dev/null
185b5456
MW
87 $(V_AT)mv $@.new $@
88
89all: $(TARGETS)
90
485c5db5
MW
91host-mode = $(notdir $(filter $1/%, $(HOST_MODES)))
92
93HOSTS = $(sort $(call dir-nosl, $(HOST_MODES)))
c376fbe7
MW
94
95###--------------------------------------------------------------------------
96### Propagating configuration to remote hosts.
97
185b5456 98THISHOST = $(shell hostname)
485c5db5 99OTHERHOSTS = $(filter-out $(THISHOST), $(HOSTS))
185b5456
MW
100
101ROOT = sudo
102
1c921c9f
MW
103install_rune = \
104 exim4 -C/etc/exim4/exim4.conf.new -bV >/dev/null && \
105 mv /etc/exim4/exim4.conf.new /etc/exim4/exim4.conf && \
106 service exim4 reload
107
485c5db5 108install/$(THISHOST): exim4-$(call host-mode,$(THISHOST)).conf
1c921c9f
MW
109 $(ROOT) cp $< /etc/exim4/exim4.conf.new
110 $(ROOT) sh -c '$(install_rune)'
185b5456 111
485c5db5
MW
112$(addprefix install/, $(OTHERHOSTS)): \
113install/%: exim4-$$(call host-mode,$$*).conf
1c921c9f
MW
114 $(ROOT) scp $< root@$*:/etc/exim4/exim4.conf.new
115 $(ROOT) ssh root@$* '$(install_rune)'
185b5456 116
485c5db5 117install: $(addprefix install/, $(HOSTS))
185b5456
MW
118
119clean:; rm -f $(CLEANFILES)
120.PHONY: clean
c376fbe7
MW
121
122###----- That's all, folks --------------------------------------------------