From e5d9a9165aaedbfb3b5f6e0bbbb4993d6343fe55 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sat, 11 Apr 2015 15:56:04 +0200 Subject: [PATCH] build system: Fix VPATH (out-of-tree) builds. --- Makefile.am | 2 +- doc/Makefile.am | 33 ++++++++++++++++++++++++--------- src/Makefile.am | 20 ++++++++++++-------- t/Makefile.am | 5 +++-- t/integration/test_lib.sh | 20 +++++++++++++++----- 5 files changed, 55 insertions(+), 25 deletions(-) diff --git a/Makefile.am b/Makefile.am index 97e8e9f..c925186 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,7 +12,7 @@ EXTRA_DIST = \ version: FORCE @# As a side-effect, this updates version. - @echo Building $(PACKAGE_NAME) version $$( ./version-gen.sh ) + @echo Building $(PACKAGE_NAME) version $$( $(top_srcdir)/version-gen.sh ) .PHONY: FORCE test: check diff --git a/doc/Makefile.am b/doc/Makefile.am index 3867744..915614f 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -4,6 +4,21 @@ SUFFIXES = \ .1.txt .5.txt .7.txt \ .1.xml .5.xml .7.xml +BUILT_SOURCES = \ + sysdb.1.xml \ + sysdbd.1.xml \ + sysdbd.conf.5.xml \ + sysdbd-cname-dns.5.xml \ + sysdbd-collectd-unixsock.5.xml \ + sysdbd-facter.5.xml \ + sysdbd-mk-livestatus.5.xml \ + sysdbd-puppet-store-configs.5.xml \ + sysdbd-store-network.5.xml \ + sysdbd-syslog.5.xml \ + sysdbd-timeseries-rrdtool.5.xml \ + sysdb.7.xml \ + sysdbql.7.xml + EXTRA_DIST = \ asciidoc.conf \ sysdb.1.txt \ @@ -146,23 +161,23 @@ html-local: $(html_DATA) install-html-local: install-htmlDATA .1.txt.1.xml: - @ASCIIDOC@ $(ADOC_FLAGS) -b docbook -d manpage $< + @ASCIIDOC@ $(ADOC_FLAGS) -b docbook -d manpage -o $@ $< .5.txt.5.xml: - @ASCIIDOC@ $(ADOC_FLAGS) -b docbook -d manpage $< + @ASCIIDOC@ $(ADOC_FLAGS) -b docbook -d manpage -o $@ $< .7.txt.7.xml: - @ASCIIDOC@ $(ADOC_FLAGS) -b docbook -d manpage $< + @ASCIIDOC@ $(ADOC_FLAGS) -b docbook -d manpage -o $@ $< .1.xml.1: - @XMLTO@ man $< + @XMLTO@ -o . man $< .5.xml.5: - @XMLTO@ man $< + @XMLTO@ -o . man $< .7.xml.7: - @XMLTO@ man $< + @XMLTO@ -o . man $< .1.txt.1.html: - @ASCIIDOC@ $(ADOC_FLAGS) -b html5 -d manpage $< + @ASCIIDOC@ $(ADOC_FLAGS) -b html5 -d manpage -o $@ $< .5.txt.5.html: - @ASCIIDOC@ $(ADOC_FLAGS) -b html5 -d manpage $< + @ASCIIDOC@ $(ADOC_FLAGS) -b html5 -d manpage -o $@ $< .7.txt.7.html: - @ASCIIDOC@ $(ADOC_FLAGS) -b html5 -d manpage $< + @ASCIIDOC@ $(ADOC_FLAGS) -b html5 -d manpage -o $@ $< diff --git a/src/Makefile.am b/src/Makefile.am index 4c920ec..ddd856c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,7 +4,7 @@ SUBDIRS = liboconfig AM_CFLAGS = @STRICT_CFLAGS@ @COVERAGE_CFLAGS@ @PROFILING_CFLAGS@ AM_CXXFLAGS = @STRICT_CXXFLAGS@ @COVERAGE_CFLAGS@ @PROFILING_CFLAGS@ AM_LDFLAGS = @COVERAGE_LDFLAGS@ @PROFILING_LDFLAGS@ -AM_CPPFLAGS = -I"${top_srcdir}/src/include" +AM_CPPFLAGS = -I${top_builddir}/src/include -I${top_srcdir}/src/include AM_CPPFLAGS += -DSYSCONFDIR='"${sysconfdir}"' AM_CPPFLAGS += -DLOCALSTATEDIR='"${localstatedir}"' AM_CPPFLAGS += -DPKGLIBDIR='"${pkglibdir}"' @@ -232,23 +232,27 @@ sysdbd_LDADD += -dlopen plugins/store/network.la sysdbd_DEPENDENCIES += plugins/store/network.la endif -include/client/sysdb.h: include/client/sysdb.h.in ../version - source ../version; sed \ +include/client/sysdb.h: include/client/sysdb.h.in $(abs_top_builddir)/version + mkdir -p include/client + source $(abs_top_builddir)/version; sed \ -e "s/@SDB_VERSION_MAJOR@/$$VERSION_MAJOR/g" \ -e "s/@SDB_VERSION_MINOR@/$$VERSION_MINOR/g" \ -e "s/@SDB_VERSION_PATCH@/$$VERSION_PATCH/g" \ -e "s/@SDB_VERSION_EXTRA@/$$VERSION_EXTRA/g" \ -e "s/@SDB_VERSION_STRING@/$$VERSION_STRING/g" \ - include/client/sysdb.h.in > include/client/sysdb.h + $(srcdir)/include/client/sysdb.h.in \ + > include/client/sysdb.h -include/sysdb.h: include/sysdb.h.in ../version - source ../version; sed \ +include/sysdb.h: include/sysdb.h.in $(abs_top_builddir)/version + mkdir -p include + source $(abs_top_builddir)/version; sed \ -e "s/@SDB_VERSION_MAJOR@/$$VERSION_MAJOR/g" \ -e "s/@SDB_VERSION_MINOR@/$$VERSION_MINOR/g" \ -e "s/@SDB_VERSION_PATCH@/$$VERSION_PATCH/g" \ -e "s/@SDB_VERSION_EXTRA@/$$VERSION_EXTRA/g" \ -e "s/@SDB_VERSION_STRING@/$$VERSION_STRING/g" \ - include/sysdb.h.in > include/sysdb.h + $(srcdir)/include/sysdb.h.in \ + > include/sysdb.h -../version: +$(abs_top_builddir)/version: cd .. && make version diff --git a/t/Makefile.am b/t/Makefile.am index d35bb77..039995c 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -12,7 +12,8 @@ EXTRA_DIST = \ # coverage related flags are only set when gcov is enabled AM_CFLAGS = @STRICT_CFLAGS@ @COVERAGE_CFLAGS@ AM_LDFLAGS = @COVERAGE_LDFLAGS@ -AM_CPPFLAGS = -I$(top_srcdir)/src/include +AM_CPPFLAGS = -I$(top_builddir)/src/include \ + -I$(top_srcdir)/src/include -I$(top_srcdir)/src TESTS = check_PROGRAMS = @@ -22,7 +23,7 @@ check_LTLIBRARIES = # unit tests # -LOG_COMPILER = $(abs_srcdir)/testwrapper.sh +LOG_COMPILER = env VPATH=$(VPATH) $(abs_srcdir)/testwrapper.sh if UNIT_TESTING UNIT_TESTS = \ diff --git a/t/integration/test_lib.sh b/t/integration/test_lib.sh index 1fb3324..fe4efe3 100644 --- a/t/integration/test_lib.sh +++ b/t/integration/test_lib.sh @@ -29,18 +29,28 @@ # TOP_SRCDIR="$( readlink -f "$( dirname "$0" )/../.." )" +TOP_BUILDDIR="$TOP_SRCDIR" +if test -n "$VPATH"; then + # We'll have to guess. + if test -d ../t; then + TOP_BUILDDIR="$( readlink -f .. )" + else if test -d t; then + TOP_BUILDDIR="$( readlink -f . )" + fi; fi +fi + TESTDIR="$( mktemp -d )" trap "rm -rf '$TESTDIR'; test -z \$SYSDBD_PID || kill \$SYSDBD_PID" EXIT mkdir "$TESTDIR/backend" -cp "$TOP_SRCDIR/t/integration/.libs/mock_timeseries.so" "$TESTDIR" -cp "$TOP_SRCDIR/t/integration/.libs/mock_plugin.so" "$TESTDIR/backend" +cp "$TOP_BUILDDIR/t/integration/.libs/mock_timeseries.so" "$TESTDIR" +cp "$TOP_BUILDDIR/t/integration/.libs/mock_plugin.so" "$TESTDIR/backend" mkdir "$TESTDIR/store" -cp "$TOP_SRCDIR/src/plugins/store/.libs/network.so" "$TESTDIR/store" +cp "$TOP_BUILDDIR/src/plugins/store/.libs/network.so" "$TESTDIR/store" -cp "$TOP_SRCDIR"/src/sysdb "$TESTDIR" -cp "$TOP_SRCDIR"/src/sysdbd "$TESTDIR" +cp "$TOP_BUILDDIR"/src/sysdb "$TESTDIR" +cp "$TOP_BUILDDIR"/src/sysdbd "$TESTDIR" MEMCHECK="valgrind --quiet --tool=memcheck --error-exitcode=1" MEMCHECK="$MEMCHECK --trace-children=yes" -- 2.30.2