Code

build system: Fix VPATH (out-of-tree) builds.
authorSebastian Harl <sh@tokkee.org>
Sat, 11 Apr 2015 13:56:04 +0000 (15:56 +0200)
committerSebastian Harl <sh@tokkee.org>
Sat, 11 Apr 2015 13:56:04 +0000 (15:56 +0200)
Makefile.am
doc/Makefile.am
src/Makefile.am
t/Makefile.am
t/integration/test_lib.sh

index 97e8e9fc24b6374ad6396c0c3deb82c2163d217d..c92518605a18f8a3a100b52e1269a8ea5a4fa9df 100644 (file)
@@ -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
index 38677442a3fe58ef784aa9f0a5248b271e887d0a..915614fb6c0653bf0c3b42c3d7af8ce1e693f30d 100644 (file)
@@ -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 $@ $<
 
index 4c920ec0bfed4d2f94d8905b9009a46822a2641b..ddd856cd6b8e858b936132d27a617a67025b58e6 100644 (file)
@@ -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
index d35bb77db9a824e84c5787d423d38302335cbb88..039995cdc3fde350004d564c143544a6410aec1e 100644 (file)
@@ -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 = \
index 1fb3324ca332081fddc9dac43392913cad21e966..fe4efe3c1945ac9626017ff931a3ec6629d28d8c 100644 (file)
 #
 
 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"