# 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@

VERSION=@BIND9_VERSION@

@BIND9_MAKE_INCLUDES@

CINCLUDES =	${DNS_INCLUDES} ${ISC_INCLUDES} ${ISCCFG_INCLUDES} \
		${BIND9_INCLUDES} ${MAXMINDDB_CFLAGS} \
		@OPENSSL_INCLUDES@

CDEFINES =	-DVERSION=\"${VERSION}\"
CWARNINGS =

DNSLIBS =	../../lib/dns/libdns.@A@ ${MAXMINDDB_LIBS} @DNS_CRYPTO_LIBS@
BIND9LIBS =	../../lib/bind9/libbind9.@A@
ISCLIBS =	../../lib/isc/libisc.@A@ @OPENSSL_LIBS@
ISCNOSYMLIBS =	../../lib/isc/libisc-nosymtbl.@A@ @OPENSSL_LIBS@
ISCCFGLIBS = 	../../lib/isccfg/libisccfg.@A@

DNSDEPLIBS =	../../lib/dns/libdns.@A@
BIND9DEPLIBS =	../../lib/bind9/libbind9.@A@
ISCDEPLIBS =	../../lib/isc/libisc.@A@
ISCCFGDEPLIBS = ../../lib/isccfg/libisccfg.@A@

LIBS =		${ISCLIBS} @LIBS@
NOSYMLIBS =	${ISCNOSYMLIBS} @LIBS@

SUBDIRS =

DNSTAPTARGETS =	dnstap-read@EXEEXT@
NZDTARGETS =	named-nzd2nzf@EXEEXT@
TARGETS =	arpaname@EXEEXT@ named-journalprint@EXEEXT@ \
		named-rrchecker@EXEEXT@ nsec3hash@EXEEXT@ \
		mdig@EXEEXT@ \
		@DNSTAPTARGETS@ @NZDTARGETS@

DNSTAPSRCS  =	dnstap-read.c
NZDSRCS  =	named-nzd2nzf.c
SRCS =		arpaname.c named-journalprint.c named-rrchecker.c \
		nsec3hash.c mdig.c \
		@DNSTAPSRCS@ @NZDSRCS@

MANPAGES =	arpaname.1 dnstap-read.1 \
		mdig.1 named-journalprint.8 \
		named-nzd2nzf.8 named-rrchecker.1 nsec3hash.8

HTMLPAGES =	arpaname.html dnstap-read.html \
		mdig.html named-journalprint.html \
		named-nzd2nzf.html named-rrchecker.html nsec3hash.html

MANOBJS =	${MANPAGES} ${HTMLPAGES}

@BIND9_MAKE_RULES@

arpaname@EXEEXT@: arpaname.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} \
		-o $@ arpaname.@O@ ${ISCLIBS} ${LIBS}

named-journalprint@EXEEXT@: named-journalprint.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
	export BASEOBJS="named-journalprint.@O@"; \
	export LIBS0="${DNSLIBS}"; \
	${FINALBUILDCMD}

named-rrchecker@EXEEXT@: named-rrchecker.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
	export BASEOBJS="named-rrchecker.@O@"; \
	export LIBS0="${DNSLIBS}"; \
	${FINALBUILDCMD}

nsec3hash@EXEEXT@: nsec3hash.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
	export BASEOBJS="nsec3hash.@O@"; \
	export LIBS0="${DNSLIBS} ${ISCLIBS}"; \
	${FINALBUILDCMD}

mdig@EXEEXT@: mdig.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} ${BIND9DEPLIBS}
	export BASEOBJS="mdig.@O@"; \
	export LIBS0="${DNSLIBS} ${BIND9LIBS}"; \
	${FINALBUILDCMD}

dnstap-read@EXEEXT@: dnstap-read.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
	export BASEOBJS="dnstap-read.@O@"; \
	export LIBS0="${DNSLIBS}"; \
	${FINALBUILDCMD}

named-nzd2nzf@EXEEXT@: named-nzd2nzf.@O@ ${NZDDEPLIBS}
	export BASEOBJS="named-nzd2nzf.@O@"; \
	export LIBS0="${ISCCFGLIBS} ${ISCCCLIBS} ${BIND9LIBS} ${DNSLIBS}"; \
	${FINALBUILDCMD}

doc man:: ${MANOBJS}

docclean manclean maintainer-clean::
	rm -f ${MANOBJS}

installdirs:
	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${bindir}
	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${sbindir}
	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man1
	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man8

nzd:
	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named-nzd2nzf@EXEEXT@ \
		${DESTDIR}${sbindir}
	${INSTALL_DATA} ${srcdir}/named-nzd2nzf.8 ${DESTDIR}${mandir}/man8

dnstap:
	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} dnstap-read@EXEEXT@ \
		${DESTDIR}${bindir}
	${INSTALL_DATA} ${srcdir}/dnstap-read.1 ${DESTDIR}${mandir}/man1

install:: ${TARGETS} installdirs @DNSTAP@ @NZD_TOOLS@
	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} arpaname@EXEEXT@ \
		${DESTDIR}${bindir}
	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named-journalprint@EXEEXT@ \
		${DESTDIR}${sbindir}
	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named-rrchecker@EXEEXT@ \
		${DESTDIR}${bindir}
	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} nsec3hash@EXEEXT@ \
		${DESTDIR}${sbindir}
	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} mdig@EXEEXT@ \
		${DESTDIR}${bindir}
	${INSTALL_DATA} ${srcdir}/arpaname.1 ${DESTDIR}${mandir}/man1
	${INSTALL_DATA} ${srcdir}/named-journalprint.8 ${DESTDIR}${mandir}/man8
	${INSTALL_DATA} ${srcdir}/named-rrchecker.1 ${DESTDIR}${mandir}/man1
	${INSTALL_DATA} ${srcdir}/nsec3hash.8 ${DESTDIR}${mandir}/man8
	${INSTALL_DATA} ${srcdir}/mdig.1 ${DESTDIR}${mandir}/man1

uninstall::
	rm -f ${DESTDIR}${mandir}/man1/mdig.1
	rm -f ${DESTDIR}${mandir}/man8/nsec3hash.8
	rm -f ${DESTDIR}${mandir}/man1/named-rrchecker.1
	rm -f ${DESTDIR}${mandir}/man8/named-journalprint.8
	rm -f ${DESTDIR}${mandir}/man1/arpaname.1
	${LIBTOOL_MODE_UNINSTALL} rm -f \
		${DESTDIR}${bindir}/mdig@EXEEXT@
	${LIBTOOL_MODE_UNINSTALL} rm -f \
		${DESTDIR}${sbindir}/nsec3hash@EXEEXT@
	${LIBTOOL_MODE_UNINSTALL} rm -f \
		${DESTDIR}${bindir}/named-rrchecker@EXEEXT@
	${LIBTOOL_MODE_UNINSTALL} rm -f \
		${DESTDIR}${sbindir}/named-journalprint@EXEEXT@
	${LIBTOOL_MODE_UNINSTALL} rm -f \
		${DESTDIR}${bindir}/arpaname@EXEEXT@
	rm -f ${DESTDIR}${mandir}/man1/dnstap-read.1
	${LIBTOOL_MODE_UNINSTALL} rm -f \
		${DESTDIR}${bindir}/dnstap-read@EXEEXT@
	rm -f ${DESTDIR}${mandir}/man8/named-nzd2nzf.8
	${LIBTOOL_MODE_UNINSTALL} rm -f \
		${DESTDIR}${sbindir}/named-nzd2nzf@EXEEXT@

clean distclean::
	rm -f ${TARGETS}
