chiark / gitweb /
user-spam.m4: Fix indentation in the output.
[exim-config] / Makefile
index 60a827937e490f0570a5c464db74dfd8ebbe6ebe..49a117939a9a8448a2c357b8d631ca32da44c5ce 100644 (file)
--- a/Makefile
+++ b/Makefile
 ### along with this program; if not, write to the Free Software Foundation,
 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
+###--------------------------------------------------------------------------
+### Utility macros.
+
+## Silent-rules machinery.
 V = 0
 v_tag = $(call v_tag_$V,$1)
 v_tag_0 = @printf "  %-6s %s\n" $1 $@;
@@ -29,37 +33,56 @@ V_GEN = $(call v_tag,GEN)
 V_AT = $(V_AT_$V)
 V_AT_0 = @
 
+## Splitting things at slashes -- don't leave the slash.
 dir-nosl = $(patsubst %/,%,$(dir $1))
 
+###--------------------------------------------------------------------------
+### Introductory machinery.
+
 all:
 .SECONDEXPANSION: # sorry
 
 CLEANFILES             += $(TARGETS)
 
+###--------------------------------------------------------------------------
+### Main source files.
+
+## There's a base set of files, and a number of optional modules.  A
+## collection of modules is called a `mode', and we generate an output file
+## for each required mode.
+
 EARLY                   = defs.m4 divmap.m4 config.m4
 MAIN                    = lists.m4 base.m4
 
 MODES                   =
 
 MODES                  += satellite
-OPTIONS_satellite       = satellite.m4
+OPTIONS_satellite       = satellite.m4 sat-rewrite.m4
+
+MODES                  += srv
+CONF_srv                = sysdomains=
+OPTIONS_srv             = exchange.m4 spam.m4 vhost.m4 sat-rewrite.m4
 
 MODES                  += hub
-OPTIONS_hub             = auth.m4 exchange.m4 local.m4 spam.m4 vhost.m4
+OPTIONS_hub             = auth.m4 exchange.m4 local.m4 spam.m4
+OPTIONS_hub            += user-spam.m4 vhost.m4
 
 MODES                  += usersat
 OPTIONS_usersat                 = auth.m4 local.m4 satellite.m4
 
 -include local.mk
 
+###--------------------------------------------------------------------------
+### Resolving what needs to be built.
+
 HOST_MODES             += $(foreach m, $(MODES), \
                                $(foreach h, $(HOSTS_$m), $h/$m))
 
 CONFIGS                         = $(foreach m, $(MODES), exim4-$m.conf)
 TARGETS                        += $(CONFIGS)
 $(CONFIGS): exim4-%.conf: $(EARLY) $$(HOOKS_$$*) $(MAIN) $$(OPTIONS_$$*)
-       $(V_GEN)m4 -P -DMODE=$* $^ >$@.new
-       $(V_AT)$(CHECK_$*)exim4 -C$@.new -bV >/dev/null
+       $(V_GEN)m4 -P -DMODE=$* $(CONF_$*:%=-DCONF_%) $^ >$@.new
+       $(V_AT)$(CHECK_$*)exim4 -C$$(pwd)/$@.new -bV >/dev/null
        $(V_AT)mv $@.new $@
 
 all: $(TARGETS)
@@ -67,24 +90,32 @@ all: $(TARGETS)
 host-mode               = $(notdir $(filter $1/%, $(HOST_MODES)))
 
 HOSTS                   = $(sort $(call dir-nosl, $(HOST_MODES)))
+
+###--------------------------------------------------------------------------
+### Propagating configuration to remote hosts.
+
 THISHOST                = $(shell hostname)
 OTHERHOSTS              = $(filter-out $(THISHOST), $(HOSTS))
 
 ROOT                    = sudo
 
-install/$(THISHOST): exim4-$(call host-mode,$(THISHOST)).conf
-       $(ROOT) install -m644 $< /etc/exim4/exim4.conf
-       $(ROOT) service exim4 reload
+install_rune            = \
+       exim4 -C/etc/exim4/exim4.conf.new -bV >/dev/null && \
+       mv /etc/exim4/exim4.conf.new /etc/exim4/exim4.conf && \
+       service exim4 reload
 
-show:
-       : $(addprefix install/, $(OTHERHOSTS))
+install/$(THISHOST): exim4-$(call host-mode,$(THISHOST)).conf
+       $(ROOT) cp $< /etc/exim4/exim4.conf.new
+       $(ROOT) sh -c '$(install_rune)'
 
 $(addprefix install/, $(OTHERHOSTS)): \
 install/%: exim4-$$(call host-mode,$$*).conf
-       $(ROOT) scp $< root@$*:/etc/exim4/exim4.conf
-       $(ROOT) ssh root@$* service exim4 reload
+       $(ROOT) scp $< root@$*:/etc/exim4/exim4.conf.new
+       $(ROOT) ssh root@$* '$(install_rune)'
 
 install: $(addprefix install/, $(HOSTS))
 
 clean:; rm -f $(CLEANFILES)
 .PHONY: clean
+
+###----- That's all, folks --------------------------------------------------