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

AUTOMAKE_OPTIONS = 1.5 subdir-objects
ACLOCAL_AMFLAGS = -I m4

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_CXXFLAGS += $(WERROR)

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: coverage-reconfigure coverage-reconfigure-maintainer-mode coverage-check

# This relies on GNU make (for the pattern rule) but it's just a convenience
# as you can run these check-* targets with any make using:
#
#   cd tests ; make check-FOO
#
# So the pain of maintaining a huge list of target forwarding rules here isn't
# worth it.
#
# Note: We use @PERCENT@ here instead of a literal % to suppress an automake
# portability warning.
check-@PERCENT@:
	cd tests && $(MAKE) $(AM_MAKEFLAGS) $@

## --disable-shared as shared builds fail for me on x86-64 Debian etch.
## If you're using ccache, you need ccache >= 3.0, released 2010-06-20 (older
## versions don't handle --coverage properly).  You need ccache >= 3.2.2 to
## actually cache compilations with --coverage - older 3.x just disables
## caching for them.
COVERAGE_CONFIGURE = \
    $(srcdir)/configure CXXFLAGS='-O0 --coverage' --disable-shared VALGRIND=

coverage-reconfigure: distclean
	$(COVERAGE_CONFIGURE)

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

coverage-check:
	## GNU find specific.
	find . -name '*.gcda' -delete
	## 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 '$(abs_builddir)' -t "Test Coverage for xapian-core `git log -n1 --abbrev-commit --format=%h`" -o lcov xapian-core.lcov

# We want to clean out build tree paths from the copy of xapian-config we
# install, mostly in the interests of facilitating reproducible builds.
bin_SCRIPTS = installable/xapian-config

# Create the installable version in a subdirectory.  It's not made executable
# until install time, which hopefully should avoid people trying to use it when
# building against an uninstalled xapian-core.
installable/xapian-config: xapian-config
	$(MKDIR_P) installable
	$(SED) '/##UNINSTONLYBEGIN/,/##UNINSTONLYEND/d' xapian-config > installable/xapian-config.tmp
	mv installable/xapian-config.tmp installable/xapian-config

CLEANFILES += installable/xapian-config

noinst_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

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

# Install the pkg-config file containing the correct compiler options.
pkgconfigdir = $(libdir)/pkgconfig
nodist_pkgconfig_DATA = pkgconfig/xapian-core.pc
DISTCLEANFILES += pkgconfig/xapian-core.pc

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 geospatial/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 these files change, we need to rerun configure to reprocess them -
# making them dependencies of config.status achieves that.
CONFIG_STATUS_DEPENDENCIES = include/xapian/version_h.cc

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)

.PHONY: check-syntax

check-syntax:
	$(CXXCOMPILE) -fsyntax-only -gstabs+ $(check_sources)
