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