chiark / gitweb /
hosts.lisp, distorted.lisp: Rename `virtual' network to `vpn'.
[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
38c2de7c
MW
26inside_MASTER = precision
27
28
d7af5ae7
MW
29ifeq ($(MASTER),localhost)
30ZONEINST = userv zoneconf install
31else
32ZONEINST = ssh zoneconf@$(MASTER)
33endif
34
5c420db9
MW
35###--------------------------------------------------------------------------
36### Utility functions.
37
38dir-nosl = $(patsubst %/,%,$(dir $1))
39
40###--------------------------------------------------------------------------
41### Keeping all of the files straight.
42
43## Establish a default target. We'll sort out what it does later.
44all:
45.PHONY: all
46
47## Things to clean.
48CLEANFILES =
49CLEANDIRS =
50REALCLEANFILES = $(CLEANFILES)
51REALCLEANDIRS = $(CLEANDIRS)
52
53## We work in terms of `zonesets'. Each one corresponds to a Lisp source
54## file to be passed to `zone'. A zoneset has a number of different nets
55## associated with it, in the variable zoneset_NETS, and we must run it
56## through `zone' once for each net. The zoneset will make a number of
57## zones, listed in zoneset_ZONES.
58ZONESETS =
59
60###--------------------------------------------------------------------------
61### The distorted.org.uk zones.
62
63ZONESETS += distorted
64
4a487d58 65distorted_VIEWS = inside outside
38c2de7c
MW
66distorted_outside_NETS = dmz jump
67distorted_inside_NETS = unsafe colo
5c420db9
MW
68
69distorted_all_ZONES = distorted.org.uk io.distorted.org.uk
4a487d58 70distorted_inside_ZONES = 199.29.172.in-addr.arpa
5c420db9
MW
71
72###--------------------------------------------------------------------------
73### The harlequin.org.uk zones.
74
75ZONESETS += harlequin
76
4a487d58 77harlequin_VIEWS = inside outside
ff6c53ad
MW
78harlequin_outside_NETS = dmz
79harlequin_inside_NETS = unsafe
5c420db9
MW
80
81harlequin_all_ZONES = harlequin.org.uk
82
39c01832
MW
83###--------------------------------------------------------------------------
84### The felixpearce.com zones.
85
86ZONESETS += felixpearce
87
88felixpearce_VIEWS = inside outside
89felixpearce_outside_NETS = dmz
90felixpearce_inside_NETS = unsafe
91
92felixpearce_all_ZONES = felixpearce.com
93
5c420db9
MW
94###--------------------------------------------------------------------------
95### Zone construction machinery.
96
97ZONE = zone
98V_ZONE = $(call v_tag,ZONE)$(ZONE)
99
100.SECONDEXPANSION: #sorry
101
102## For each net/zoneset pair, we make a stamp file net/zoneset.stamp to
103## remember that we've made the corresponding zones.
104ALL_ZONESTAMPS = $(foreach s,$(ZONESETS), \
105 $(patsubst %,%/$s.zonestamp,$($s_VIEWS)))
106$(ALL_ZONESTAMPS) : %.zonestamp : $$(notdir $$*).lisp hosts.lisp
107 $(V_AT)mkdir -p $(dir $*)
108 $(V_ZONE) -d$(dir $*) -fview/$(call dir-nosl,$*)$(hack \
d7af5ae7
MW
109 hack) $(addprefix -s, \
110 $($(notdir $*)_$(call dir-nosl,$*)_NETS)) $<
5c420db9
MW
111 $(V_AT)touch $@
112all: $(ALL_ZONESTAMPS)
113CLEANFILES += $(sort $(foreach s,$(ZONESETS), \
114 $(foreach v,$($s_VIEWS), \
115 $v/*.zonestamp $v/*.zone)))
116REALCLEANFILES += $(sort $(foreach s,$(ZONESETS), \
117 $(foreach v,$($s_VIEWS), \
118 $v/*.serial)))
119REALCLEANDIRS += $(sort $(foreach s,$(ZONESETS),$($s_VIEWS)))
120
121## Now explain that each generated zone file depends on the corresponding
122## zonestamp. This is where things start getting a little hairy.
123$(foreach s,$(ZONESETS), \
124 $(foreach v,$($s_VIEWS), \
125 $(foreach z,$($s_all_ZONES) $($s_$v_ZONES), \
126 $(eval $v/$z.zone: $v/$s.zonestamp))))
127
128## Now we have to check the individual zone files.
129ALL_ZONECHECKS = $(foreach s,$(ZONESETS), \
130 $(foreach v,$($s_VIEWS), \
131 $(foreach z,$($s_all_ZONES) $($s_$v_ZONES), \
132 $v/$z.check)))
133$(ALL_ZONECHECKS) : %.check : %.zone
134 $(call v_tag,CHECK)\
135 { $(CHECKZONE) $(notdir $*) $^ || kill $$$$; } | \
136 { grep -Ev 'loaded serial|OK' || :; }
137check: $(ALL_ZONECHECKS)
138.PHONY: check $(ALL_ZONECHECKS)
139
d7af5ae7
MW
140## Finally we have to install the zone files.
141ALL_INSTALLS = $(foreach s,$(ZONESETS), \
142 $(foreach v,$($s_VIEWS), \
143 $(foreach z,$($s_all_ZONES) $($s_$v_ZONES), \
144 $v/$z.inst)))
145$(ALL_INSTALLS) : %.inst : %.check
146 $(call v_tag,INST)$(ZONEINST) \
147 $(call dir-nosl,$*) $(notdir $*) <$*.zone
148install: $(ALL_INSTALLS)
149.PHONY: install $(ALL_INSTALLS)
150
5c420db9
MW
151## Files to clean.
152clean:
153 rm -f $(CLEANFILES)
154 [ "$(CLEANDIRS)x" = x ] || rmdir $(CLEANDIRS) || :
155realclean:
156 rm -f $(REALCLEANFILES)
157 [ "$(REALCLEANDIRS)x" = x ] || rmdir $(REALCLEANDIRS) || :
158.PHONY: clean realclean
159
160###----- That's all, folks --------------------------------------------------