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

@LIBISC_API@

@BIND9_MAKE_INCLUDES@

CINCLUDES =	-I${srcdir}/unix/include \
		-I${srcdir}/pthreads/include \
		-I./include \
		-I${srcdir}/include ${DNS_INCLUDES} \
		${OPENSSL_CFLAGS} \
		${JSON_C_CFLAGS} \
		${LIBXML2_CFLAGS}
CDEFINES =
CWARNINGS =

# Alphabetically
UNIXOBJS =	unix/pk11_api.@O@ \
		unix/dir.@O@ unix/errno.@O@ \
		unix/errno2result.@O@ unix/file.@O@ unix/fsaccess.@O@ \
		unix/interfaceiter.@O@ unix/meminfo.@O@ \
		unix/net.@O@ unix/os.@O@ unix/resource.@O@ unix/socket.@O@ \
		unix/stdio.@O@ unix/stdtime.@O@ \
		unix/syslog.@O@ unix/time.@O@

THREADOBJS =	pthreads/condition.@O@ pthreads/mutex.@O@ pthreads/thread.@O@

WIN32OBJS = 	win32/condition.@O@ win32/dir.@O@ win32/errno.@O@ \
		win32/file.@O@ win32/fsaccess.@O@ \
		win32/meminfo.@O@ win32/once.@O@ \
		win32/stdtime.@O@ win32/thread.@O@ win32/time.@O@

# Alphabetically
OBJS =		pk11.@O@ pk11_result.@O@ \
		aes.@O@ app.@O@ assertions.@O@ \
		backtrace.@O@ base32.@O@ base64.@O@ \
		bind9.@O@ buffer.@O@ bufferlist.@O@ \
		commandline.@O@ counter.@O@ crc64.@O@ error.@O@ entropy.@O@ \
		event.@O@ hash.@O@ ht.@O@ heap.@O@ hex.@O@ hmac.@O@ \
		httpd.@O@ iterated_hash.@O@ \
		lex.@O@ lfsr.@O@ lib.@O@ log.@O@ \
		md.@O@ mem.@O@ mutexblock.@O@ \
		netaddr.@O@ netscope.@O@ nonce.@O@ openssl_shim.@O@ pool.@O@ \
		parseint.@O@ portset.@O@ quota.@O@ radix.@O@ random.@O@ \
		ratelimiter.@O@ region.@O@ regex.@O@ result.@O@ \
		rwlock.@O@ \
		serial.@O@ siphash.@O@ sockaddr.@O@ stats.@O@ \
		string.@O@ symtab.@O@ task.@O@ taskpool.@O@ \
		tm.@O@ timer.@O@ version.@O@ \
		${UNIXOBJS} ${THREADOBJS}
SYMTBLOBJS =	backtrace-emptytbl.@O@

# Alphabetically
SRCS =		pk11.c pk11_result.c \
		aes.c app.c assertions.c \
		backtrace.c base32.c base64.c bind9.c \
		buffer.c bufferlist.c commandline.c counter.c crc64.c \
		entropy.c error.c event.c hash.c ht.c heap.c hex.c hmac.c \
		httpd.c iterated_hash.c \
		lex.c lfsr.c lib.c log.c \
		md.c mem.c mutexblock.c \
		netaddr.c netscope.c nonce.c openssl_shim.c pool.c \
		parseint.c portset.c quota.c radix.c random.c \
		ratelimiter.c region.c regex.c result.c rwlock.c \
		serial.c siphash.c sockaddr.c stats.c string.c \
		symtab.c task.c taskpool.c timer.c \
		tm.c version.c

LIBS =		${OPENSSL_LIBS} @LIBS@

# Note: the order of SUBDIRS is important.
# Attempt to disable parallel processing.
.NOTPARALLEL:
.NO_PARALLEL:
SUBDIRS =	include unix pthreads
TARGETS =	timestamp
TESTDIRS =	@UNITTESTS@

@BIND9_MAKE_RULES@

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

libisc.@SA@: ${OBJS} ${SYMTBLOBJS}
	${AR} ${ARFLAGS} $@ ${OBJS} ${SYMTBLOBJS}
	${RANLIB} $@

libisc-nosymtbl.@SA@: ${OBJS}
	${AR} ${ARFLAGS} $@ ${OBJS}
	${RANLIB} $@

libisc.la: ${OBJS} ${SYMTBLOBJS}
	${LIBTOOL_MODE_LINK} \
		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libisc.la -rpath ${libdir} \
		-version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \
		${OBJS} ${SYMTBLOBJS} ${LIBS}

libisc-nosymtbl.la: ${OBJS}
	${LIBTOOL_MODE_LINK} \
		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libisc-nosymtbl.la -rpath ${libdir} \
		-version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \
		${OBJS} ${LIBS}

timestamp: libisc.@A@ libisc-nosymtbl.@A@
	touch timestamp

testdirs: libisc.@A@ libisc-nosymtbl.@A@

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

install:: timestamp installdirs
	${LIBTOOL_MODE_INSTALL} ${INSTALL_LIBRARY} libisc.@A@ ${DESTDIR}${libdir}

uninstall::
	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libisc.@A@

clean distclean::
	rm -f libisc.@A@ libisc-nosymtbl.@A@ libisc.la \
	libisc-nosymtbl.la timestamp
