X-Git-Url: https://git.distorted.org.uk/~mdw/firewall/blobdiff_plain/5a4a2cdeaff3804484a3404179dd309c43040bf6..38e85ca3b58ddcf50c7db608f5baa2fd19771f8a:/Makefile diff --git a/Makefile b/Makefile index 242bbfd..a0cc605 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,18 @@ MAIN_M4_SOURCES = HOSTS = +## Where to install the scripts. +FIREWALL = /etc/init.d/firewall + +## How to achieve root privileges. +ROOT = sudo + +## Throw additional scripts in here to have them installed. SCRIPTS = +sbindir = /usr/local/sbin +## Establish the default target early, so that targets in `local.mk' don't +## override it. default: all .PHONY: default @@ -88,16 +98,74 @@ M4_SOURCES += $(MAIN_M4_SOURCES) TARGETS = $(addsuffix .sh,$(HOSTS)) ###-------------------------------------------------------------------------- +### Prologue testing. + +TARGETS += dummy.sh +dummy.sh: base.m4 prologue.m4 dummy-payload.m4 + $(V_M4)-DFWHOST=testing $^ >$@.new + $(V_AT)chmod +x $@.new && mv $@.new $@ + +TARGETS += dummy-inst.sh +dummy-inst.sh: dummy.sh + $(V_GEN)sed '/dummy_action=/s/lose/win/' $< >$@.new + $(V_AT)chmod +x $@.new && mv $@.new $@ + +###-------------------------------------------------------------------------- +### Other utilities. + +## A list of diversions in ascending numerical order. +CLEANFILES += divs +divs: $(M4_SOURCES) $(addsuffix .m4,$(HOSTS)) + $(V_GEN)grep -n m4_divert $^ | \ + grep -v 'm4_divert(-1)' | \ + sort -t\( -k2n >$@ + +###-------------------------------------------------------------------------- ### Building. all: $(TARGETS) .PHONY: all %.sh: %.m4 $(M4_SOURCES) - $(V_M4)base.m4 $*.m4 $(MAIN_M4_SOURCES) >$@.new + $(V_M4)-DFWHOST=$* base.m4 $*.m4 $(MAIN_M4_SOURCES) >$@.new $(V_AT)chmod +x $@.new && mv $@.new $@ -clean:; rm -f $(TARGETS) *.new +clean:; rm -f $(TARGETS) *.new $(CLEANFILES) .PHONY: clean +###-------------------------------------------------------------------------- +### Installation. + +## The local machine doesn't want the complicated SSH stuff. +THISHOST = $(shell hostname) +OTHERHOSTS = $(filter-out $(THISHOST), $(HOSTS)) + +## Testing. +check: $(THISHOST).sh + $(ROOT) ./$(THISHOST).sh test + +## Installation on a local host, +install/$(THISHOST): $(THISHOST).sh + [ "x$(SCRIPTS)" = x ] || $(ROOT) install -m755 $(SCRIPTS) $(sbindir) + $(ROOT) ./$(THISHOST).sh replace