Allow all parts of Apache 2.0 to build when --srcdir is used. This
required exposing a build directory and a source directory to all parts
of Apache's build system. It also required a small hack in APR-util, if
we are using the bundled Expat, and we are using VPATH support, then we
have hard-coded the xml/expat location. I couldn't figure out how to
allow the configure script to determine the correct location. I added a
comment, but if somebody else figures it out, we should fix that at some
point.
PR: 7630
git-svn-id: https://svn.apache.org/repos/asf/apr/apr-util/trunk@58320 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/build/apu-conf.m4 b/build/apu-conf.m4
index f003576..7e8dc91 100644
--- a/build/apu-conf.m4
+++ b/build/apu-conf.m4
@@ -15,28 +15,46 @@
AC_MSG_ERROR(You need to specify a directory with --with-apr)
fi
absdir="`cd $withval ; pwd`"
- if test -f "$absdir/apr_pools.h"; then
+ if test -f "$absdir/apr.h"; then
APR_INCLUDES="$absdir"
- elif test -f "$absdir/include/apr_pools.h"; then
- APR_SOURCE_DIR="$absdir"
+ elif test -f "$absdir/include/apr.h"; then
+ APR_BUILD_DIR="$absdir"
fi
],[
dnl see if we can find APR
- if test -f "$srcdir/apr/include/apr_pools.h"; then
- APR_SOURCE_DIR="$srcdir/apr"
- elif test -f "$srcdir/../apr/include/apr_pools.h"; then
- APR_SOURCE_DIR="`cd $srcdir/../apr ; pwd`"
+ if test -f "$srcdir/apr/include/apr.h"; then
+ APR_BUILD_DIR="$srcdir/apr"
+ elif test -f "$srcdir/../apr/include/apr.h"; then
+ APR_BUILD_DIR="`cd $srcdir/../apr ; pwd`"
fi
])
-if test -n "$APR_SOURCE_DIR"; then
- APR_INCLUDES="$APR_SOURCE_DIR/include"
+
+dnl
+dnl grab flags from APR.
+dnl ### APR doesn't have "nice" names for its exports (yet), but it isn't
+dnl ### a problem to deal with them right here
+dnl
+
+. "$APR_BUILD_DIR/APRVARS"
+APR_EXPORT_CPPFLAGS="$EXTRA_CPPFLAGS"
+APR_EXPORT_CFLAGS="$EXTRA_CFLAGS"
+APR_EXPORT_LIBS="$EXTRA_LIBS"
+
+if test -n "$APR_BUILD_DIR"; then
+ APR_INCLUDES="-I$APR_BUILD_DIR/include"
+ if test "$APR_BUILD_DIR" != "$APR_SOURCE_DIR"; then
+ APR_INCLUDES="$APR_INCLUDES -I$APR_SOURCE_DIR/include"
+ fi
fi
+
if test -z "$APR_INCLUDES"; then
AC_MSG_RESULT(not found)
AC_MSG_ERROR(APR could not be located. Please use the --with-apr option.)
fi
+
AC_MSG_RESULT($APR_INCLUDES)
+AC_SUBST(APR_BUILD_DIR)
AC_SUBST(APR_SOURCE_DIR)
])
@@ -353,7 +371,7 @@
])
if test -z "$expat_include_dir"; then
- for d in /usr /usr/local xml/expat-cvs xml/expat ; do
+ for d in /usr /usr/local xml/expat-cvs xml/expat $srcdir/xml/expat ; do
APU_TEST_EXPAT($d)
if test -n "$expat_include_dir"; then
break
@@ -376,6 +394,15 @@
expat_libs=$top_builddir/$bundled_subdir/lib/libexpat.la
APR_XML_SUBDIRS="`echo $bundled_subdir | sed -e 's%xml/%%'`"
fi
+if test "$expat_include_dir" = "$srcdir/xml/expat/include" -o "$expat_include_dir" = "$srcdir/xml/expat/lib"; then
+ dnl This is a bit of a hack. This only works because we know that
+ dnl we are working with the bundled version of the software.
+ bundled_subdir="xml/expat"
+ APU_SUBDIR_CONFIG($bundled_subdir)
+ expat_include_dir=$top_builddir/$bundled_subdir/lib
+ expat_libs=$top_builddir/$bundled_subdir/lib/libexpat.la
+ APR_XML_SUBDIRS="`echo $bundled_subdir | sed -e 's%xml/%%'`"
+fi
AC_SUBST(APR_XML_SUBDIRS)
INCLUDES="$INCLUDES -I$expat_include_dir"
diff --git a/build/rules.mk.in b/build/rules.mk.in
index 50bdaba..a8cb025 100644
--- a/build/rules.mk.in
+++ b/build/rules.mk.in
@@ -60,6 +60,8 @@
# Configuration variables
#
top_builddir=@top_builddir@
+top_srcdir=@top_srcdir@
+APR_BUILD_DIR=@APR_BUILD_DIR@
APR_SOURCE_DIR=@APR_SOURCE_DIR@
CC=@CC@
diff --git a/configure.in b/configure.in
index fc7751c..f1ec5a7 100644
--- a/configure.in
+++ b/configure.in
@@ -12,18 +12,31 @@
AC_PROG_AWK
AC_CHECK_PROG(RM, rm, rm)
+dnl Absolute source/build directory
+abs_srcdir=`(cd $srcdir && pwd)`
+abs_builddir=`pwd`
+
+if test "$abs_builddir" != "$abs_srcdir"; then
+ USE_VPATH=1
+fi
+
dnl
dnl compute the top directory of the build
dnl note: this is needed for LIBTOOL and exporting the bundled Expat
dnl
-top_builddir="`cd $srcdir ; pwd`"
+top_builddir="$abs_builddir"
AC_SUBST(top_builddir)
+AC_SUBST(abs_srcdir)
dnl
dnl set up the compilation flags and stuff
dnl
INCLUDES="$INCLUDES -I\$(top_builddir)/include/private -I\$(top_builddir)/include"
+if test -n "$USE_VPATH"; then
+ INCLUDES="$INCLUDES -I\$(top_srcdir)/include"
+fi
+
dnl
dnl 1. Find the APR includes directory and (possibly) the source (base) dir.
dnl 2. Determine what DBM backend type to use.
@@ -33,7 +46,7 @@
APU_CHECK_DBM
APU_FIND_EXPAT
-INCLUDES="$INCLUDES -I$APR_INCLUDES"
+INCLUDES="$INCLUDES $APR_INCLUDES"
dnl
dnl prep libtool
@@ -96,16 +109,6 @@
AC_SUBST(EXPAT_LINK)
dnl
-dnl grab flags from APR.
-dnl ### APR doesn't have "nice" names for its exports (yet), but it isn't
-dnl ### a problem to deal with them right here
-dnl
-. "$APR_SOURCE_DIR/APRVARS"
-APR_EXPORT_CPPFLAGS="$EXTRA_CPPFLAGS"
-APR_EXPORT_CFLAGS="$EXTRA_CFLAGS"
-APR_EXPORT_LIBS="$EXTRA_LIBS"
-
-dnl
dnl Prep all the flags and stuff for compilation and export to other builds
dnl
CFLAGS="$CFLAGS $INCLUDES $APR_EXPORT_CFLAGS $APR_EXPORT_CPPFLAGS"
@@ -133,21 +136,31 @@
dnl
dnl everthing is done.
+MAKEFILES=" Makefile build/Makefile buckets/Makefile crypto/Makefile dbm/Makefile dbm/sdbm/Makefile encoding/Makefile hooks/Makefile uri/Makefile xml/Makefile misc/Makefile $test_Makefile"
AC_OUTPUT([
- Makefile
export_vars.sh
- build/Makefile
build/rules.mk
include/private/apu_select_dbm.h
include/apu.h
- buckets/Makefile
- crypto/Makefile
- dbm/Makefile
- dbm/sdbm/Makefile
- encoding/Makefile
- hooks/Makefile
- uri/Makefile
- xml/Makefile
- misc/Makefile
- $test_Makefile
+ $MAKEFILES
])
+
+dnl #----------------------------- Fixup Makefiles for VPATH support
+
+changequote({,})
+
+if test -n "$USE_VPATH"; then
+ for makefile in $MAKEFILES; do
+ dir=`echo $makefile|sed 's%[^/][^/]*$%%'`
+ (cat <<EOF
+srcdir = $abs_srcdir/$dir
+VPATH = $abs_srcdir/$dir
+
+EOF
+) | cat - $makefile > tmp
+ cp tmp $makefile
+ done
+ rm -f tmp
+fi
+
+changequote([,])
diff --git a/uri/Makefile.in b/uri/Makefile.in
index e875009..4c7e398 100644
--- a/uri/Makefile.in
+++ b/uri/Makefile.in
@@ -11,4 +11,4 @@
apr_uri.lo: uri_delims.h
uri_delims.h: gen_uri_delims
- ./gen_uri_delims > uri_delims.h
+ ./gen_uri_delims > $(top_builddir)/include/private/uri_delims.h
diff --git a/xml/expat/configure.in b/xml/expat/configure.in
index 9c04bf0..b8df47b 100644
--- a/xml/expat/configure.in
+++ b/xml/expat/configure.in
@@ -58,6 +58,9 @@
;;
esac
+blddir=`pwd`
+AC_SUBST(blddir)
+
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
AC_SUBST(EXPAT_MAJOR_VERSION)
diff --git a/xml/expat/lib/Makefile.in b/xml/expat/lib/Makefile.in
index a2ea2cd..d9d9f06 100644
--- a/xml/expat/lib/Makefile.in
+++ b/xml/expat/lib/Makefile.in
@@ -27,6 +27,7 @@
prefix = @prefix@
exec_prefix = @exec_prefix@
+blddir = @blddir@/lib
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
@@ -77,7 +78,7 @@
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
-INCLUDES = -I$(srcdir) -I..
+INCLUDES = -I$(srcdir) -I.. -I$(blddir)
DEFS = @DEFS@ -DPACKAGE='"$(PACKAGE)"' -DVERSION='"$(PACKAGE)_$(VERSION)"'
CPPFLAGS = @CPPFLAGS@