# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.

srcdir =	@srcdir@
VPATH =		@srcdir@
top_srcdir =	@top_srcdir@

@BIND9_MAKE_RULES@

PERL = @PERL@

MANOBJS = options

doc man:: ${MANOBJS}

docclean manclean maintainer-clean::
	rm -f options

# Do not make options depend on ../../bin/tests/cfg_test, doing so
# will cause excessively clever versions of make to attempt to build
# that program right here, right now, if it is missing, which will
# cause make doc to bomb.

CFG_TEST = ../../bin/tests/cfg_test

options: FORCE
	if test -x ${CFG_TEST} ; \
	then \
		${CFG_TEST} --named --grammar > $@.raw ; \
		${PERL} ${srcdir}/sort-options.pl < $@.raw > $@.sorted ; \
		${PERL} ${srcdir}/format-options.pl < $@.sorted > $@.new ; \
		mv -f $@.new $@ ; \
		${CFG_TEST} --named --grammar --active > $@.raw ; \
		${PERL} ${srcdir}/sort-options.pl < $@.raw > $@.sorted ; \
		${PERL} ${srcdir}/format-options.pl < $@.sorted > $@.new ; \
		mv -f $@.new $@.active ; \
		rm -f $@.raw $@.sorted ; \
		${CFG_TEST} --zonegrammar master --active > master.zoneopt ; \
		${CFG_TEST} --zonegrammar slave --active > slave.zoneopt ; \
		${CFG_TEST} --zonegrammar mirror --active > mirror.zoneopt ; \
		${CFG_TEST} --zonegrammar forward --active > forward.zoneopt ; \
		${CFG_TEST} --zonegrammar hint --active > hint.zoneopt ; \
		${CFG_TEST} --zonegrammar stub --active > stub.zoneopt ; \
		${CFG_TEST} --zonegrammar static-stub --active > static-stub.zoneopt ; \
		${CFG_TEST} --zonegrammar redirect --active > redirect.zoneopt ; \
		${CFG_TEST} --zonegrammar delegation-only --active > delegation-only.zoneopt ; \
		${CFG_TEST} --zonegrammar in-view --active > in-view.zoneopt ; \
	else \
		rm -f $@.new $@.raw $@.sorted ; \
	fi

docbook: options
	${PERL} docbook-options.pl options.active > ${top_srcdir}/bin/named/named.conf.docbook
	${PERL} docbook-zoneopt.pl master.zoneopt > ${top_srcdir}/doc/arm/master.zoneopt.xml
	${PERL} docbook-zoneopt.pl slave.zoneopt > ${top_srcdir}/doc/arm/slave.zoneopt.xml
	${PERL} docbook-zoneopt.pl mirror.zoneopt > ${top_srcdir}/doc/arm/mirror.zoneopt.xml
	${PERL} docbook-zoneopt.pl forward.zoneopt > ${top_srcdir}/doc/arm/forward.zoneopt.xml
	${PERL} docbook-zoneopt.pl hint.zoneopt > ${top_srcdir}/doc/arm/hint.zoneopt.xml
	${PERL} docbook-zoneopt.pl stub.zoneopt > ${top_srcdir}/doc/arm/stub.zoneopt.xml
	${PERL} docbook-zoneopt.pl static-stub.zoneopt > ${top_srcdir}/doc/arm/static-stub.zoneopt.xml
	${PERL} docbook-zoneopt.pl redirect.zoneopt > ${top_srcdir}/doc/arm/redirect.zoneopt.xml
	${PERL} docbook-zoneopt.pl delegation-only.zoneopt > ${top_srcdir}/doc/arm/delegation-only.zoneopt.xml
	${PERL} docbook-zoneopt.pl in-view.zoneopt > ${top_srcdir}/doc/arm/in-view.zoneopt.xml
	${PERL} docbook-grammars.pl options.active acl > ${top_srcdir}/doc/arm/acl.grammar.xml
	${PERL} docbook-grammars.pl options.active controls > ${top_srcdir}/doc/arm/controls.grammar.xml
	${PERL} docbook-grammars.pl options.active key > ${top_srcdir}/doc/arm/key.grammar.xml
	${PERL} docbook-grammars.pl options.active logging > ${top_srcdir}/doc/arm/logging.grammar.xml
	${PERL} docbook-grammars.pl options.active masters > ${top_srcdir}/doc/arm/masters.grammar.xml
	${PERL} docbook-grammars.pl options.active options > ${top_srcdir}/doc/arm/options.grammar.xml
	${PERL} docbook-grammars.pl options.active server > ${top_srcdir}/doc/arm/server.grammar.xml
	${PERL} docbook-grammars.pl options.active statistics-channels > ${top_srcdir}/doc/arm/statistics-channels.grammar.xml
	${PERL} docbook-grammars.pl options.active dnssec-keys > ${top_srcdir}/doc/arm/dnssec-keys.grammar.xml
	${PERL} docbook-grammars.pl options.active managed-keys > ${top_srcdir}/doc/arm/managed-keys.grammar.xml
	${PERL} docbook-grammars.pl options.active trusted-keys > ${top_srcdir}/doc/arm/trusted-keys.grammar.xml
