Makefile, base.m4: Inject the target hostname into the generated script.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 5 Mar 2012 09:46:35 +0000 (09:46 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 5 Mar 2012 23:54:58 +0000 (23:54 +0000)
This means we can identify the target in the comment header.  It will be
even more useful later.

Makefile
base.m4

index 8f918e5..b69ddd0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -102,7 +102,8 @@ TARGETS                      = $(addsuffix .sh,$(HOSTS))
 
 TARGETS                        += dummy.sh
 dummy.sh: base.m4 prologue.m4 dummy-payload.m4
-       $(V_M4) $^ >$@.new && chmod +x $@.new && mv $@.new $@
+       $(V_M4)-DFWHOST=testing $^ >$@.new
+       $(V_AT)chmod +x $@.new && mv $@.new $@
 
 TARGETS                        += dummy-inst.sh
 dummy-inst.sh: dummy.sh
@@ -116,7 +117,7 @@ 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
diff --git a/base.m4 b/base.m4
index 5170531..3a0172d 100644 (file)
--- a/base.m4
+++ b/base.m4
@@ -56,6 +56,10 @@ m4_changecom(<:##:>)
 
 m4_divert(0)m4_dnl
 #! /bin/sh
+<:###:> Firewall script for FWHOST
+###
+### *** GENERATED FILE: DO NOT EDIT ***
+
 ### BEGIN INIT INFO
 # Provides:            firewall
 # Required-Start:      mountkernfs
@@ -66,10 +70,10 @@ m4_divert(0)m4_dnl
 # Default-Stop:                0 6
 # Description:         Provides customized packet filter rules.
 ### END INIT INFO
-### *** GENERATED FILE: DO NOT EDIT ***
 
 set -e
 PATH=/bin:/sbin:/usr/bin:/usr/sbin; export PATH
+fwhost=FWHOST
 
 m4_divert(99)m4_dnl
 ### *** GENERATED FILE: DO NOT EDIT ***