# Copyright (C) 2009-2012  Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.

# $Id$

top_srcdir =	@top_srcdir@
srcdir =	@top_srcdir@/lib/dns
export_srcdir =	@top_srcdir@/lib/export

# Attempt to disable parallel processing.
.NOTPARALLEL:
.NO_PARALLEL:

@BIND9_VERSION@

@LIBDNS_API@

@BIND9_MAKE_INCLUDES@

CINCLUDES =	-I. -Iinclude ${DNS_INCLUDES} -I${export_srcdir}/isc/include \
		${ISC_INCLUDES} @DST_OPENSSL_INC@ @DST_GSSAPI_INC@

CDEFINES =	-DUSE_MD5 @USE_OPENSSL@ @USE_GSSAPI@

CWARNINGS =

ISCLIBS =	../isc/libisc.@A@

ISCDEPLIBS =	../isc/libisc.@A@

LIBS =		@LIBS@

# Alphabetically

OPENSSLLINKOBJS = openssl_link.@O@ openssldh_link.@O@ openssldsa_link.@O@ \
		opensslgost_link.@O@ opensslrsa_link.@O@

DSTOBJS =	@OPENSSLLINKOBJS@ \
		dst_api.@O@ dst_lib.@O@ dst_parse.@O@ dst_result.@O@ \
		gssapi_link.@O@ gssapictx.@O@ hmac_link.@O@ key.@O@

DNSOBJS =	acl.@O@ adb.@O@ byaddr.@O@ \
		cache.@O@ callbacks.@O@ client.@O@ compress.@O@ \
		db.@O@ dbiterator.@O@ diff.@O@ dispatch.@O@ dlz.@O@ dnssec.@O@ \
		ds.@O@ \
		forward.@O@ iptable.@O@ \
		keytable.@O@ \
		lib.@O@ log.@O@ \
		master.@O@ masterdump.@O@ message.@O@ \
		name.@O@ ncache.@O@ nsec.@O@ nsec3.@O@ \
		peer.@O@ portlist.@O@ \
		rbt.@O@ rbtdb.@O@ rcode.@O@ rdata.@O@ \
		rdatalist.@O@ rdataset.@O@ rdatasetiter.@O@ rdataslab.@O@ \
		request.@O@ resolver.@O@ result.@O@ soa.@O@ stats.@O@ \
		tcpmsg.@O@ time.@O@ tsec.@O@ tsig.@O@ ttl.@O@ \
		validator.@O@ version.@O@ view.@O@
PORTDNSOBJS =	ecdb.@O@

OBJS=		${DNSOBJS} ${OTHEROBJS} ${DSTOBJS} ${PORTDNSOBJS}

# Alphabetically

OPENSSLLINKSRCS = openssl_link.c openssldh_link.c openssldsa_link.c \
		opensslgost_link.c opensslrsa_link.c

DSTSRCS =	@OPENSSLLINKSRCS@ \
		dst_api.c dst_lib.c dst_parse.c \
		dst_result.c gssapi_link.c gssapictx.c \
		hmac_link.c key.c 

DNSSRCS =	acl.c adb.c byaddr.c \
		cache.c callbacks.c client.c compress.c \
		db.c dbiterator.c diff.c dispatch.c dlz.c dnssec.c ds.c \
		forward.c iptable.c \
		keytable.c \
		lib.c log.c \
		master.c masterdump.c message.c \
		name.c ncache.c nsec.c nsec3.c \
		peer.c portlist.c \
		rbt.c rbtdb.c rcode.c rdata.c \
		rdatalist.c rdataset.c rdatasetiter.c rdataslab.c \
		request.c res.c resolver.c result.c soa.c stats.c \
		tcpmsg.c time.c tsec.c tsig.c ttl.c \
		validator.c version.c view.c
PORTDNSSRCS =	ecdb.c

SRCS = ${DSTSRCS} ${DNSSRCS} ${PORTDNSSRCS}

SUBDIRS =	include
TARGETS =	include/dns/enumtype.h include/dns/enumclass.h \
		include/dns/rdatastruct.h timestamp

DEPENDEXTRA =	./gen -F include/dns/rdatastruct.h \
		-s ${srcdir} -d >> Makefile ;

@BIND9_MAKE_RULES@

version.@O@: ${srcdir}/version.c
	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \
		-DVERSION=\"${VERSION}\" \
		-DLIBINTERFACE=${LIBINTERFACE} \
		-DLIBREVISION=${LIBREVISION} \
		-DLIBAGE=${LIBAGE} \
		-c ${srcdir}/version.c

libdns.@SA@: ${OBJS}
	${AR} ${ARFLAGS} $@ ${OBJS}
	${RANLIB} $@

libdns.la: ${OBJS}
	${LIBTOOL_MODE_LINK} \
		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libdns.la \
		-rpath ${export_libdir} \
		-version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \
		${OBJS} ${ISCLIBS} @DNS_CRYPTO_LIBS@ ${LIBS}

timestamp: libdns.@A@
	touch timestamp

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

install:: timestamp installdirs
	${LIBTOOL_MODE_INSTALL} ${INSTALL_DATA} libdns.@A@ \
	${DESTDIR}${export_libdir}/

clean distclean::
	rm -f libdns.@A@ timestamp
	rm -f gen code.h include/dns/enumtype.h include/dns/enumclass.h
	rm -f include/dns/rdatastruct.h

newrr::
	rm -f code.h include/dns/enumtype.h include/dns/enumclass.h
	rm -f include/dns/rdatastruct.h

include: include/dns/enumtype.h include/dns/enumclass.h \
	include/dns/rdatastruct.h

rdata.@O@: code.h

include/dns/enumtype.h: gen
	./gen -s ${srcdir} -t > $@

include/dns/enumclass.h: gen
	./gen -s ${srcdir} -c > $@

include/dns/rdatastruct.h: gen \
		${srcdir}/rdata/rdatastructpre.h \
		${srcdir}/rdata/rdatastructsuf.h
	./gen -s ${srcdir} -i \
		-P ${srcdir}/rdata/rdatastructpre.h \
		-S ${srcdir}/rdata/rdatastructsuf.h > $@

code.h:	gen
	./gen -s ${srcdir} > code.h

gen: ${srcdir}/gen.c
	${CC} ${ALL_CFLAGS} ${LDFLAGS} -o $@ ${srcdir}/gen.c ${LIBS}

#We don't need rbtdb64 for this library
#rbtdb64.@O@: rbtdb.c

depend: include/dns/enumtype.h include/dns/enumclass.h \
	include/dns/rdatastruct.h code.h
subdirs: include/dns/enumtype.h include/dns/enumclass.h \
	include/dns/rdatastruct.h code.h
${OBJS}: include/dns/enumtype.h include/dns/enumclass.h \
	include/dns/rdatastruct.h
