## Process this file with automake to produce Makefile.in

AUTOMAKE_OPTIONS = 1.5 subdir-objects
ACLOCAL_AMFLAGS = -I m4

# `make QUIET=' overrides `./configure --enable-quiet'.
# `make QUIET=y' overrides `./configure' without `--enable-quiet'.
LIBTOOL = @LIBTOOL@ $(QUIET:y=--quiet)

if MAINTAINER_MODE
# Export these so that we run the locally installed autotools when building
# from a bootstrapped git tree.
export ACLOCAL AUTOCONF AUTOHEADER AUTOM4TE AUTOMAKE
endif

AM_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/include
if VPATH_BUILD
# Needed for the generated files include/xapian/version.h
# include/xapian/error.h and include/xapian/errordispatch.h
AM_CPPFLAGS += -I$(top_builddir)/include
endif

# Order is relevant: when building, tests must be after ".".
SUBDIRS = . docs tests

noinst_HEADERS =
BUILT_SOURCES =
noinst_LTLIBRARIES =
CLEANFILES =
DISTCLEANFILES =
MAINTAINERCLEANFILES =
bin_PROGRAMS =
EXTRA_PROGRAMS =

.PHONY: check-none check-inmemory check-multi \
        check-remote check-remoteprog check-remotetcp \
        check-chert check-flint check-perftest \
	coverage-reconfigure coverage-reconfigure-maintainer-mode coverage-check

check-none:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-none

check-inmemory:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-inmemory

check-multi:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-multi

if BUILD_BACKEND_REMOTE
check-remote:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-remote
check-remoteprog:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-remoteprog
check-remotetcp:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-remotetcp
if BUILD_BACKEND_CHERT
check-remoteprog-chert:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-remoteprog-chert
check-remotetcp-chert: apitest$(EXEEXT)
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-remotetcp-chert
endif
if BUILD_BACKEND_FLINT
check-remoteprog-flint:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-remoteprog-flint
check-remotetcp-flint: apitest$(EXEEXT)
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-remotetcp-flint
endif
endif

if BUILD_BACKEND_CHERT
check-multi-chert:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-multi-chert
check-chert:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-chert
endif

if BUILD_BACKEND_FLINT
check-multi-flint:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-multi-flint
check-flint:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-flint
endif

check-perf:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) check-perf

## --disable-shared as shared builds fail for me on x86-64 Debian etch.
## CCACHE_DISABLE as ccache 2.4 doesn't handle the .gcno files.
COVERAGE_CONFIGURE = \
    $(srcdir)/configure CXXFLAGS='-O0 --coverage' \
    --enable-quiet --disable-shared CCACHE_DISABLE=1 VALGRIND=

coverage-reconfigure: distclean
	$(COVERAGE_CONFIGURE)

coverage-reconfigure-maintainer-mode: distclean
	$(COVERAGE_CONFIGURE) --enable-maintainer-mode

coverage-check:
	## GNU find and xargs specific.
	find . -name '*.gcda' -print0|xargs -0 rm -f
	## Don't run under valgrind even if configure was run by hand.
	$(MAKE) $(AM_MAKEFLAGS) check VALGRIND=
	rm -f xapian-core.lcov
	lcov --capture -d . --quiet --rc 'lcov_branch_coverage=1' --no-external -o xapian-core.lcov
	rm -rf lcov
	genhtml --demangle-cpp --branch-coverage $(GENHTML_ARGS) -q -p "`pwd`" -t "Test Coverage for xapian-core `git log -n1 --abbrev-commit --format=%h`" -o lcov xapian-core.lcov

bin_SCRIPTS = xapian-config

DISTCLEANFILES += xapian-config

EXTRA_DIST = ChangeLog ChangeLog.0 ChangeLog.examples HACKING PLATFORMS \
 xapian-core.spec include/xapian/error.h include/xapian/errordispatch.h \
 generate-exceptions exception_data.pm preautoreconf dir_contents

cmakedir = $(libdir)/cmake/xapian
cmake_DATA = cmake/xapian-config.cmake cmake/xapian-config-version.cmake

# docsource.mk is generated by preautoreconf, run by bootstrap prior to
# it running autoreconf.
include docsource.mk

# Install the m4 file containing the XO_LIB_XAPIAN autoconf macro.
m4datadir = $(datadir)/aclocal
dist_m4data_DATA = m4-macros/xapian.m4

libxapian_la = libxapian.la
lib_LTLIBRARIES = libxapian.la
libxapian_la_SOURCES = $(lib_src)
libxapian_la_LIBADD = $(XAPIAN_LIBS)
libxapian_la_LDFLAGS = \
    $(XAPIAN_LDFLAGS) -no-undefined -version-info $(LIBRARY_VERSION_INFO)

lib_src =

if !MAINTAINER_NO_DOCS
dist_man_MANS = xapian-config.1
endif

include api/Makefile.mk
include bin/Makefile.mk
include backends/Makefile.mk
include common/Makefile.mk
include examples/Makefile.mk
include expand/Makefile.mk
include include/Makefile.mk
include languages/Makefile.mk
include matcher/Makefile.mk
include net/Makefile.mk
include queryparser/Makefile.mk
include unicode/Makefile.mk
include weight/Makefile.mk

xapianinclude_HEADERS += include/xapian/error.h

if MAINTAINER_MODE
BUILT_SOURCES += include/xapian/error.h include/xapian/errordispatch.h

include/xapian/error.h include/xapian/errordispatch.h: generate-exceptions exception_data.pm
	$(PERL) -w -I"$(srcdir)" "$(srcdir)/generate-exceptions"
endif

if !MAINTAINER_NO_DOCS
MAINTAINERCLEANFILES += $(dist_man_MANS)
endif

if DOCUMENTATION_RULES
xapian-config.1: xapian-config makemanpage
	./makemanpage ./xapian-config xapian-config xapian-config.1
endif

MAINTAINERCLEANFILES += $(BUILT_SOURCES)
