aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile.inc.zones
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-06-09 12:05:50 +0100
committerLexi Winter <lexi@le-fay.org>2025-06-09 12:05:50 +0100
commitda5a30813185926c381f33073c58d32ef0167539 (patch)
tree598aca25a03673547444518089780034e929634f /Makefile.inc.zones
parent4a6119c1a9ea22825c0952b730118268cf33f0ad (diff)
downloaddns-da5a30813185926c381f33073c58d32ef0167539.tar.gz
dns-da5a30813185926c381f33073c58d32ef0167539.tar.bz2
support managing knot.conf
Diffstat (limited to 'Makefile.inc.zones')
-rw-r--r--Makefile.inc.zones53
1 files changed, 53 insertions, 0 deletions
diff --git a/Makefile.inc.zones b/Makefile.inc.zones
new file mode 100644
index 0000000..fdcbfcd
--- /dev/null
+++ b/Makefile.inc.zones
@@ -0,0 +1,53 @@
+# This source code is released into the public domain.
+
+DIFF?=
+ZONEDIR= ${.CURDIR}/zones
+NSUPDATE?= nsupdate
+NSUPDATE_FLAGS?=-g
+NSDIFF?= nsdiff
+NSDIFFFLAGS?= -Sserial -s ${MASTER}
+
+.SUFFIXES: .zone.erb .czone
+
+update-zones:
+.PHONY: update-zones
+
+.for zone in ${ZONES}
+
+# Update this zone when running update-zones.
+update-zones: ${zone}
+
+# How to build a processed zone from an ERB zonefile.
+${zone:S,/,_,g}.czone: Makefile ${zone:S,/,_,g}.zone.erb
+ ${PROCESS} \
+ -Dzone=${zone} \
+ ${ZONE_PROCESS_FLAGS} \
+ ${ZONEDIR}/${zone:S,/,_,g}.zone.erb $@
+
+# Take the built .czone file and send it to nsdiff.
+# If DIFF is set, just print the diff instead of sending it to nsupdate.
+${zone}: ${zone:S,/,_,g}.czone
+.if ${DIFF} != ""
+ @if ! ${NSDIFF} ${NSDIFFFLAGS} ${zone} ${.ALLSRC} >/dev/null 2>&1; then \
+ tmpfile="$$(mktemp dns.XXXXXX)"; \
+ ${NSDIFF} ${NSDIFFFLAGS} ${zone} ${.ALLSRC} || true; \
+ rm "$$tmpfile"; \
+ fi
+.else
+ ${NSDIFF} ${NSDIFFFLAGS} ${zone} $> | ${NSUPDATE} ${NSUPDATE_FLAGS}
+.endif
+
+.PHONY: ${zone}
+
+# Delete the czone for this zone when cleaning.
+clean-zone-${zone}:
+ rm -f ${zone:S,/,_,g}.czone
+.PHONY: Clean-zone-${zone}
+clean: clean-zone-${zone}
+.endfor
+
+# For easy of use, 'make diff' runs update-zone with DIFF set.
+diff:
+ @${MAKE} -C ${.CURDIR} DIFF=yes update-zones
+.PHONY: diff
+