### -*-makefile-*- ### ### Build script for Exim configuration ### ### (c) 2012 Mark Wooding ### ###----- Licensing notice --------------------------------------------------- ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of the GNU General Public License as published by ### the Free Software Foundation; either version 2 of the License, or ### (at your option) any later version. ### ### This program is distributed in the hope that it will be useful, ### but WITHOUT ANY WARRANTY; without even the implied warranty of ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ### GNU General Public License for more details. ### ### You should have received a copy of the GNU General Public License ### along with this program; if not, write to the Free Software Foundation, ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. V = 0 v_tag = $(call v_tag_$V,$1) v_tag_0 = @printf " %-6s %s\n" $1 $@; V_GEN = $(call v_tag,GEN) V_AT = $(V_AT_$V) V_AT_0 = @ dir-nosl = $(patsubst %/,%,$(dir $1)) all: .SECONDEXPANSION: # sorry CLEANFILES += $(TARGETS) EARLY = defs.m4 divmap.m4 config.m4 MAIN = lists.m4 base.m4 MODES = MODES += satellite OPTIONS_satellite = satellite.m4 MODES += hub OPTIONS_hub = auth.m4 exchange.m4 local.m4 spam.m4 vhost.m4 MODES += usersat OPTIONS_usersat = auth.m4 local.m4 satellite.m4 -include local.mk 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)exim4 -C$@.new -bV >/dev/null $(V_AT)mv $@.new $@ all: $(TARGETS) THISHOST = $(shell hostname) ROOT = sudo INSTALL_TARGETS = $(addprefix install-, $(HOST_MODES)) $(filter install-$(THISHOST)/%, $(INSTALL_TARGETS)): \ install-$(THISHOST)/%: exim4-%.conf $(ROOT) install -m644 $< /etc/exim4/exim4.conf $(ROOT) service exim4 reload $(filter-out install-$(THISHOST)/%, $(INSTALL_TARGETS)): \ install-%: exim4-$$(notdir $$*).conf $(ROOT) scp $< root@$(call dir-nosl,$*):/etc/exim4/exim4.conf $(ROOT) ssh root@$(call dir-nosl,$*) service exim4 reload install: $(INSTALL_TARGETS) clean:; rm -f $(CLEANFILES) .PHONY: clean