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

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

DNSLIBS =	../../lib/dns/libdns.@A@ @DNS_CRYPTO_LIBS@
ISCLIBS =	../../lib/isc/libisc.@A@ @OPENSSL_LIBS@
ISCNOSYMLIBS =	../../lib/isc/libisc-nosymtbl.@A@ @OPENSSL_LIBS@

DNSDEPLIBS =	../../lib/dns/libdns.@A@
ISCDEPLIBS =	../../lib/isc/libisc.@A@

DEPLIBS =	${DNSDEPLIBS} ${ISCDEPLIBS}

LIBS =		${DNSLIBS} ${ISCLIBS} @LIBS@

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

# Alphabetically
TARGETS =	dnssec-cds@EXEEXT@ dnssec-dsfromkey@EXEEXT@ \
		dnssec-importkey@EXEEXT@ dnssec-keyfromlabel@EXEEXT@ \
		dnssec-keygen@EXEEXT@ dnssec-revoke@EXEEXT@ \
		dnssec-settime@EXEEXT@ dnssec-signzone@EXEEXT@ \
		dnssec-verify@EXEEXT@

OBJS =		dnssectool.@O@

SRCS =		dnssec-cds.c dnssec-dsfromkey.c dnssec-importkey.c \
		dnssec-keyfromlabel.c dnssec-keygen.c dnssec-revoke.c \
		dnssec-settime.c dnssec-signzone.c dnssec-verify.c \
		dnssectool.c

MANPAGES =	dnssec-cds.8 dnssec-dsfromkey.8  dnssec-importkey.8 \
		dnssec-keyfromlabel.8 dnssec-keygen.8 dnssec-revoke.8 \
		dnssec-settime.8 dnssec-signzone.8 dnssec-verify.8

HTMLPAGES =	dnssec-cds.html dnssec-dsfromkey.html \
		dnssec-importkey.html dnssec-keyfromlabel.html \
		dnssec-keygen.html dnssec-revoke.html \
		dnssec-settime.html dnssec-signzone.html \
		dnssec-verify.html

MANOBJS =	${MANPAGES} ${HTMLPAGES}

@BIND9_MAKE_RULES@

dnssec-cds@EXEEXT@: dnssec-cds.@O@ ${OBJS} ${DEPLIBS}
	export BASEOBJS="dnssec-cds.@O@ ${OBJS}"; \
	${FINALBUILDCMD}

dnssec-dsfromkey@EXEEXT@: dnssec-dsfromkey.@O@ ${OBJS} ${DEPLIBS}
	export BASEOBJS="dnssec-dsfromkey.@O@ ${OBJS}"; \
	${FINALBUILDCMD}

dnssec-keyfromlabel@EXEEXT@: dnssec-keyfromlabel.@O@ ${OBJS} ${DEPLIBS}
	export BASEOBJS="dnssec-keyfromlabel.@O@ ${OBJS}"; \
	${FINALBUILDCMD}

dnssec-keygen@EXEEXT@: dnssec-keygen.@O@ ${OBJS} ${DEPLIBS}
	export BASEOBJS="dnssec-keygen.@O@ ${OBJS}"; \
	${FINALBUILDCMD}

dnssec-signzone.@O@: dnssec-signzone.c
	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -DVERSION=\"${VERSION}\" \
		-c ${srcdir}/dnssec-signzone.c

dnssec-signzone@EXEEXT@: dnssec-signzone.@O@ ${OBJS} ${DEPLIBS}
	export BASEOBJS="dnssec-signzone.@O@ ${OBJS}"; \
	${FINALBUILDCMD}

dnssec-verify.@O@: dnssec-verify.c
	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -DVERSION=\"${VERSION}\" \
		-c ${srcdir}/dnssec-verify.c

dnssec-verify@EXEEXT@: dnssec-verify.@O@ ${OBJS} ${DEPLIBS}
	export BASEOBJS="dnssec-verify.@O@ ${OBJS}"; \
	${FINALBUILDCMD}

dnssec-revoke@EXEEXT@: dnssec-revoke.@O@ ${OBJS} ${DEPLIBS}
	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
	dnssec-revoke.@O@ ${OBJS} ${LIBS}

dnssec-settime@EXEEXT@: dnssec-settime.@O@ ${OBJS} ${DEPLIBS}
	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
	dnssec-settime.@O@ ${OBJS} ${LIBS}

dnssec-importkey@EXEEXT@: dnssec-importkey.@O@ ${OBJS} ${DEPLIBS}
	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
	dnssec-importkey.@O@ ${OBJS} ${LIBS}

doc man:: ${MANOBJS}

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

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

install:: ${TARGETS} installdirs
	for t in ${TARGETS}; do ${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} $$t ${DESTDIR}${sbindir} || exit 1; done
	for m in ${MANPAGES}; do ${INSTALL_DATA} ${srcdir}/$$m ${DESTDIR}${mandir}/man8 || exit 1; done

uninstall::
	for m in ${MANPAGES}; do rm -f ${DESTDIR}${mandir}/man8/$$m || exit 1; done
	for t in ${TARGETS}; do ${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/$$t || exit 1; done

clean distclean::
	rm -f ${TARGETS}
