distorted.lisp: Reorder the network infrastructure hosts.
[zones] / Makefile
1 ### -*-makefile-*-
2 ###
3 ### Makefile for the DNS zones I maintain.
4 ###
5 ### (c) 2011 Mark Wooding
6
7 ###--------------------------------------------------------------------------
8 ### Silent-rules machinery.
9
10 V = 0
11 v_tag = $(call v_tag_$V,$1)
12 v_tag_0 = @printf " %-6s %s\n" "$1" "$@";
13
14 V_AT = $(V_AT_$V)
15 V_AT_0 = @
16
17 ###--------------------------------------------------------------------------
18 ### Programs and options.
19
20 ## Zone checking.
21 CHECKZONE = named-checkzone -i full \
22 -k fail -M fail -n fail -S fail -W fail
23
24 ## Zone installation.
25 MASTER = localhost
26 inside_MASTER = precision
27
28 ifeq ($(MASTER),localhost)
29 ZONEINST = userv zoneconf install
30 else
31 ZONEINST = ssh zoneconf@$(MASTER)
32 endif
33
34 ###--------------------------------------------------------------------------
35 ### Utility functions.
36
37 dir-nosl = $(patsubst %/,%,$(dir $1))
38
39 ###--------------------------------------------------------------------------
40 ### Keeping all of the files straight.
41
42 ## Establish a default target. We'll sort out what it does later.
43 all:
44 .PHONY: all
45
46 ## Things to clean.
47 CLEANFILES =
48 CLEANDIRS =
49 REALCLEANFILES = $(CLEANFILES)
50 REALCLEANDIRS = $(CLEANDIRS)
51
52 ## We work in terms of `zonesets'. Each one corresponds to a Lisp source
53 ## file to be passed to `zone'. A zoneset has a number of different nets
54 ## associated with it, in the variable zoneset_NETS, and we must run it
55 ## through `zone' once for each net. The zoneset will make a number of
56 ## zones, listed in zoneset_ZONES.
57 ZONESETS =
58
59 ###--------------------------------------------------------------------------
60 ### The distorted.org.uk zones.
61
62 ZONESETS += distorted
63
64 distorted_VIEWS = inside outside
65 distorted_outside_NETS = dmz jump
66 distorted_inside_NETS = any unsafe colo vpn
67
68 distorted_all_ZONES += distorted.org.uk
69
70 distorted_all_ZONES += 144-159.204.49.62.in-addr.arpa
71 distorted_all_ZONES += 64-79.198.13.212.in-addr.arpa
72
73 distorted_all_ZONES += 199.29.172.in-addr.arpa
74
75 distorted_all_ZONES += 8.9.b.1.9.0.f.1.0.7.4.0.1.0.0.2.ip6.arpa
76 distorted_all_ZONES += 0.4.7.9.0.7.4.0.1.0.0.2.ip6.arpa
77
78 distorted_all_ZONES += 9.d.1.0.0.0.0.0.8.a.b.0.1.0.0.2.ip6.arpa
79 distorted_all_ZONES += 9.d.1.0.8.a.b.0.1.0.0.2.ip6.arpa
80
81 ###--------------------------------------------------------------------------
82 ### Other zones.
83
84 ## binswood.org.uk
85 ZONESETS += binswood
86 binswood_VIEWS = outside
87 binswood_all_ZONES += binswood.org.uk
88 binswood_all_ZONES += 27.165.10.in-addr.arpa
89
90 ## escorted.org.uk
91 ZONESETS += escorted
92 escorted_VIEWS = outside
93 escorted_all_ZONES += escorted.org.uk
94
95 ## odin.gg
96 ZONESETS += odin
97 odin_VIEWS = outside
98 odin_all_ZONES = odin.gg
99
100 ## goodhstg.com
101 ZONESETS += goodhstg
102 goodhstg_VIEWS = outside
103 goodhstg_all_ZONES = goodhstg.com
104
105 ###--------------------------------------------------------------------------
106 ### Zone construction machinery.
107
108 ZONE = zone
109 V_ZONE = $(call v_tag,ZONE)$(ZONE)
110
111 .SECONDEXPANSION: #sorry
112
113 ## For each net/zoneset pair, we make a stamp file net/zoneset.stamp to
114 ## remember that we've made the corresponding zones.
115 ALL_ZONESTAMPS = $(foreach s,$(ZONESETS), \
116 $(patsubst %,%/$s.zonestamp,$($s_VIEWS)))
117 $(ALL_ZONESTAMPS) : %.zonestamp : $$(notdir $$*).lisp hosts.lisp
118 $(V_AT)mkdir -p $(dir $*)
119 $(V_ZONE) -d$(dir $*) -fview/$(call dir-nosl,$*)$(hack \
120 hack) $(addprefix -s, \
121 $($(notdir $*)_$(call dir-nosl,$*)_NETS)) $<
122 $(V_AT)touch $@
123 all: $(ALL_ZONESTAMPS)
124 CLEANFILES += $(sort $(foreach s,$(ZONESETS), \
125 $(foreach v,$($s_VIEWS), \
126 $v/*.zonestamp $v/*.zone)))
127 REALCLEANFILES += $(sort $(foreach s,$(ZONESETS), \
128 $(foreach v,$($s_VIEWS), \
129 $v/*.serial)))
130 REALCLEANDIRS += $(sort $(foreach s,$(ZONESETS),$($s_VIEWS)))
131
132 ## Now explain that each generated zone file depends on the corresponding
133 ## zonestamp. This is where things start getting a little hairy.
134 $(foreach s,$(ZONESETS), \
135 $(foreach v,$($s_VIEWS), \
136 $(foreach z,$($s_all_ZONES) $($s_$v_ZONES), \
137 $(eval $v/$z.zone: $v/$s.zonestamp))))
138
139 ## Now we have to check the individual zone files.
140 ALL_ZONECHECKS = $(foreach s,$(ZONESETS), \
141 $(foreach v,$($s_VIEWS), \
142 $(foreach z,$($s_all_ZONES) $($s_$v_ZONES), \
143 $v/$z.check)))
144 $(ALL_ZONECHECKS) : %.check : %.zone
145 $(call v_tag,CHECK)\
146 { $(CHECKZONE) $(notdir $*) $^ || kill $$$$; } | \
147 { grep -Ev 'loaded serial|OK' || :; }
148 check: $(ALL_ZONECHECKS)
149 .PHONY: check $(ALL_ZONECHECKS)
150
151 ## Finally we have to install the zone files.
152 ALL_INSTALLS = $(foreach s,$(ZONESETS), \
153 $(foreach v,$($s_VIEWS), \
154 $(foreach z,$($s_all_ZONES) $($s_$v_ZONES), \
155 $v/$z.inst)))
156 $(ALL_INSTALLS) : %.inst : %.check
157 $(call v_tag,INST)$(ZONEINST) \
158 $(call dir-nosl,$*) $(notdir $*) <$*.zone
159 install: $(ALL_INSTALLS)
160 .PHONY: install $(ALL_INSTALLS)
161
162 ## Files to clean.
163 clean:
164 rm -f $(CLEANFILES)
165 [ "$(CLEANDIRS)x" = x ] || rmdir $(CLEANDIRS) || :
166 realclean:
167 rm -f $(REALCLEANFILES)
168 [ "$(REALCLEANDIRS)x" = x ] || rmdir $(REALCLEANDIRS) || :
169 .PHONY: clean realclean
170
171 ###----- That's all, folks --------------------------------------------------