3 ### Makefile for the DNS zones I maintain.
5 ### (c) 2011 Mark Wooding
7 ###--------------------------------------------------------------------------
8 ### Silent-rules machinery.
11 v_tag
= $(call v_tag_
$V,$1)
12 v_tag_0
= @printf
" %-6s %s\n" "$1" "$@";
17 ###--------------------------------------------------------------------------
18 ### Programs and options.
20 CHECKZONE
= named-checkzone
-i full \
21 -k fail
-M fail
-n fail
-S fail
-W fail
23 ###--------------------------------------------------------------------------
24 ### Utility functions.
26 dir-nosl
= $(patsubst %/,%,$(dir $1))
28 ###--------------------------------------------------------------------------
29 ### Keeping all of the files straight.
31 ## Establish a default target. We'll sort out what it does later.
38 REALCLEANFILES
= $(CLEANFILES
)
39 REALCLEANDIRS
= $(CLEANDIRS
)
41 ## We work in terms of `zonesets'. Each one corresponds to a Lisp source
42 ## file to be passed to `zone'. A zoneset has a number of different nets
43 ## associated with it, in the variable zoneset_NETS, and we must run it
44 ## through `zone' once for each net. The zoneset will make a number of
45 ## zones, listed in zoneset_ZONES.
48 ###--------------------------------------------------------------------------
49 ### The distorted.org.uk zones.
53 distorted_VIEWS
= inet fretwank
54 distorted_inet_NETS
= inet
55 distorted_fretwank_NETS
= fretwank
57 distorted_all_ZONES
= distorted.org.uk io.distorted.org.uk
58 distorted_fretwank_ZONES
= 199.29.172.in-addr.arpa
60 ###--------------------------------------------------------------------------
61 ### The harlequin.org.uk zones.
65 harlequin_VIEWS
= inet fretwank
66 harlequin_inet_NETS
= inet
67 harlequin_fretwank_NETS
= fretwank
69 harlequin_all_ZONES
= harlequin.org.uk
71 ###--------------------------------------------------------------------------
72 ### Zone construction machinery.
75 V_ZONE
= $(call v_tag
,ZONE
)$(ZONE
)
77 .SECONDEXPANSION
: #sorry
79 ## For each net/zoneset pair, we make a stamp file net/zoneset.stamp to
80 ## remember that we've made the corresponding zones.
81 ALL_ZONESTAMPS
= $(foreach s
,$(ZONESETS
), \
82 $(patsubst %,%/$s.zonestamp
,$($s_VIEWS)))
83 $(ALL_ZONESTAMPS
) : %.zonestamp
: $$(notdir $$*).lisp hosts.lisp
84 $(V_AT
)mkdir
-p
$(dir $*)
85 $(V_ZONE
) -d
$(dir $*) -fview
/$(call dir-nosl
,$*)$(hack \
86 hack
) $(addprefix -s
, $($(notdir $*)_
$(call dir-nosl
,$*)_NETS
)) $<
88 all: $(ALL_ZONESTAMPS
)
89 CLEANFILES
+= $(sort $(foreach s
,$(ZONESETS
), \
90 $(foreach v
,$($s_VIEWS), \
91 $v/*.zonestamp
$v/*.zone
)))
92 REALCLEANFILES
+= $(sort $(foreach s
,$(ZONESETS
), \
93 $(foreach v
,$($s_VIEWS), \
95 REALCLEANDIRS
+= $(sort $(foreach s
,$(ZONESETS
),$($s_VIEWS)))
97 ## Now explain that each generated zone file depends on the corresponding
98 ## zonestamp. This is where things start getting a little hairy.
99 $(foreach s
,$(ZONESETS
), \
100 $(foreach v
,$($s_VIEWS), \
101 $(foreach z
,$($s_all_ZONES) $($s_$v_ZONES), \
102 $(eval
$v/$z.zone
: $v/$s.zonestamp
))))
104 ## Now we have to check the individual zone files.
105 ALL_ZONECHECKS
= $(foreach s
,$(ZONESETS
), \
106 $(foreach v
,$($s_VIEWS), \
107 $(foreach z
,$($s_all_ZONES) $($s_$v_ZONES), \
109 $(ALL_ZONECHECKS
) : %.
check : %.zone
111 { $(CHECKZONE
) $(notdir $*) $^ || kill
$$$$; } | \
112 { grep
-Ev
'loaded serial|OK' ||
:; }
113 check: $(ALL_ZONECHECKS
)
114 .PHONY
: check $(ALL_ZONECHECKS
)
119 [ "$(CLEANDIRS)x" = x
] || rmdir
$(CLEANDIRS
) ||
:
121 rm -f
$(REALCLEANFILES
)
122 [ "$(REALCLEANDIRS)x" = x
] || rmdir
$(REALCLEANDIRS
) ||
:
123 .PHONY
: clean realclean
125 ###----- That's all, folks --------------------------------------------------