# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
#
# SPDX-License-Identifier: MPL-2.0
#
# 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 https://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} \
		${LMDB_CFLAGS} ${OPENSSL_CFLAGS} \
		${PROTOBUF_C_CFLAGS} \
		${MAXMINDDB_CFLAGS} \
		${LMDB_CFLAGS}

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

DNSLIBS =	../../lib/dns/libdns.@A@ @NO_LIBTOOL_DNSLIBS@
BIND9LIBS =	../../lib/bind9/libbind9.@A@
ISCLIBS =	../../lib/isc/libisc.@A@ @NO_LIBTOOL_ISCLIBS@
ISCNOSYMLIBS =	../../lib/isc/libisc-nosymtbl.@A@ @NO_LIBTOOL_ISCLIBS@
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@

@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}"; \
	${FINALBUILDCMD}

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

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

named-nzd2nzf@EXEEXT@: named-nzd2nzf.@O@ ${ISCDEPLIBS}
	export BASEOBJS="named-nzd2nzf.@O@"; \
	export LIBS0="${LMDB_LIBS}"; \
	${FINALBUILDCMD}

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

nzd:
	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named-nzd2nzf@EXEEXT@ \
		${DESTDIR}${sbindir}

dnstap:
	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} dnstap-read@EXEEXT@ \
		${DESTDIR}${bindir}

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}

uninstall::
	${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@
	${LIBTOOL_MODE_UNINSTALL} rm -f \
		${DESTDIR}${bindir}/dnstap-read@EXEEXT@
	${LIBTOOL_MODE_UNINSTALL} rm -f \
		${DESTDIR}${sbindir}/named-nzd2nzf@EXEEXT@

clean distclean::
	rm -f ${TARGETS}
