aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile.inc.zones
blob: fdcbfcd89fa23e38f2063c652de06c156cc3fdff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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