# $Progeny$

# Autoconf defines top_builddir to an empty string at the top-level
# when srcdir == builddir, so we need to redefine distdir.

distdir=		${builddir}/${distname}

SUBDIR=			buildtools doctools portability etc doc scripts \
			sysdeps include lib discover tests discover-xml

all:
	@${MAKE} __recur TARGET=$@

check test: all
	@cd tests && ${MAKE} check

###############################################################################
# Clean

distclean_FILES=	Makefile config.h config.log config.status libtool
maintainer_clean_FILES=	aclocal.m4 autom4te.cache config.h.in configure

clean:
	@${MAKE} __recur TARGET=$@

# Recursion should always happen first so that commands executed in
# this directory are distinguishable from commands executed in the
# last subdirectory, but this one must be an exception because this
# Makefile is removed.
distclean:
	@${MAKE} __recur TARGET=$@
	rm -rf ${distclean_FILES}

maintainer-clean:
	@${MAKE} __recur TARGET=$@
	rm -rf ${distclean_FILES} ${maintainer_clean_FILES}

###############################################################################
# Installation

install:
	@${MAKE} __recur TARGET=$@
	${INSTALL_DATA} ${srcdir}/discover.dtd \
			  ${DESTDIR}${datadir}/discover/dtd/discover.dtd

uninstall:
	@${MAKE} __recur TARGET=$@
	rm -f ${DESTDIR}${datadir}/discover/dtd/discover.dtd

###############################################################################
# Distribution

DISTFILES=		Makefile.in config.h.in configure configure.ac \
			AUTHORS INSTALL LICENSE README RELEASE discover.dtd \
			package.ent

dist: ${distname}.tar.bz2
distdir: ${distdir}

distcheck: ${distname}.tar.bz2
	${top_srcdir}/buildtools/distcheck ${distname}

${distname}.tar.bz2: ${distdir}
	${top_srcdir}/buildtools/dist ${distname}

${distdir}: ${DISTFILES}
	${top_srcdir}/buildtools/distdir ${distdir} ${DISTFILES}
	@${MAKE} __recur TARGET=distdir

###############################################################################
# Development aids

aclocal.m4: aclibs
	${top_srcdir}/buildtools/setup aclocal

config.h.in: aclocal.m4 configure.ac
	${top_srcdir}/buildtools/setup autoheader

configure: aclocal.m4 config.h.in configure.ac
	${top_srcdir}/buildtools/setup autoconf
