Backport from HEAD:
Remove "location detection" from apu-config:
* configure.in: Substitute APU_CONFIG_LOCATION as "build" or "source"
appropriately.
* apu-config.in: Set location to @APU_CONFIG_LOCATION@ rather than
using fragile pwd/realpath guesswork.
* Makefile.in (apu-config.out): New target.
(install): Install apu-config.out instead of apu-config.
PR: 8867 (episode two)
git-svn-id: https://svn.apache.org/repos/asf/apr/apr-util/branches/APU_0_9_BRANCH@59129 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/.cvsignore b/.cvsignore
index 65896df..4fbf6c7 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -15,6 +15,7 @@
export_vars.h
export_vars.sh
apu-config
+apu-config.out
Debug
Release
LibD
diff --git a/CHANGES b/CHANGES
index f6d8e6b..b534aa0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,7 +1,7 @@
Changes with APR-util 0.9.5
- *) If available, use 'readlink -f' to resolve symlinks in apu-config.
- [Justin Erenkrantz]
+ *) Fix build issues in paths containing symlinks. PR 8867.
+ [Joe Orton]
*) Fix corrupt output from the apr_xlate_* interfaces on AIX 4.x.
[Joe Orton]
diff --git a/Makefile.in b/Makefile.in
index 130588e..c0bc1ba 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -25,7 +25,7 @@
SUBDIRS = buckets crypto dbm encoding hooks ldap uri xml misc strmatch xlate
CLEAN_SUBDIRS = test
-CLEAN_TARGETS = exports.c export_vars.h aprutil.exp
+CLEAN_TARGETS = exports.c export_vars.h aprutil.exp apu-config.out
DISTCLEAN_TARGETS = config.cache config.log config.status libtool \
include/private/apu_config.h include/private/apu_private.h \
include/private/apu_select_dbm.h include/apr_ldap.h include/apu.h \
@@ -52,6 +52,10 @@
fi; \
fi
+apu-config.out: apu-config
+ sed 's,^\(location=\).*$$,\1installed,' < apu-config > $@
+
+install: $(TARGET_LIB) apu-config.out
install: $(TARGET_LIB)
if [ ! -d $(DESTDIR)$(includedir) ]; then \
@APR_SOURCE_DIR@/build/mkdir.sh $(DESTDIR)$(includedir); \
@@ -72,7 +76,7 @@
if [ ! -d $(DESTDIR)$(bindir) ]; then \
@APR_SOURCE_DIR@/build/mkdir.sh $(DESTDIR)$(bindir); \
fi;
- $(LIBTOOL) --mode=install cp apu-config $(DESTDIR)$(bindir)
+ $(LIBTOOL) --mode=install cp apu-config.out $(DESTDIR)$(bindir)/apu-config
chmod 755 $(DESTDIR)$(bindir)/apu-config
$(TARGET_LIB):
diff --git a/apu-config.in b/apu-config.in
index a570838..3919641 100644
--- a/apu-config.in
+++ b/apu-config.in
@@ -37,6 +37,9 @@
APR_XML_EXPAT_OLD="@APR_XML_EXPAT_OLD@"
APU_DB_VERSION="@apu_db_version@"
+# NOTE: the following line is modified during 'make install': alter with care!
+location=@APU_CONFIG_LOCATION@
+
show_usage()
{
cat << EOF
@@ -73,38 +76,6 @@
exit 1
fi
-thisdir="`dirname $0`"
-thisdir="`cd $thisdir && pwd`"
-if test -d $bindir; then
- tmpbindir="`cd $bindir && pwd`"
-else
- tmpbindir=""
-fi
-# If we have the realpath program, use it to resolve symlinks.
-# Otherwise, being in a symlinked dir may result in incorrect output.
-REALPATH=
-if test -x "`which realpath 2>/dev/null`"; then
- REALPATH=realpath
-elif test -x "`which readlink 2>/dev/null`"; then
- REALPATH="readlink -f"
-fi
-if test -n "$REALPATH"; then
- thisdir="`$REALPATH $thisdir`"
- if test -d "$APU_SOURCE_DIR"; then
- APR_SOURCE_DIR="`$REALPATH $APU_SOURCE_DIR`"
- fi
- if test -n "$tmpbindir"; then
- tmpbindir="`$REALPATH $tmpbindir`"
- fi
-fi
-if test "$tmpbindir" = "$thisdir"; then
- location=installed
-elif test "$APU_SOURCE_DIR" = "$thisdir"; then
- location=source
-else
- location=build
-fi
-
if test "$location" = "installed"; then
LA_FILE="$libdir/lib${APRUTIL_LIBNAME}.la"
@@ -112,7 +83,7 @@
LDFLAGS=`echo "$LDFLAGS" | sed -e "s $APU_BUILD_DIR/xml/expat $prefix g"`
INCLUDES=`echo "$INCLUDES" | sed -e "s $APU_BUILD_DIR/xml/expat $prefix g" -e "s -I$prefix/lib g"`
else
- LA_FILE="$thisdir/lib${APRUTIL_LIBNAME}.la"
+ LA_FILE="$APU_BUILD_DIR/lib${APRUTIL_LIBNAME}.la"
fi
flags=""
@@ -147,7 +118,7 @@
flags="$APU_SOURCE_DIR/include"
else
# this is for VPATH builds
- flags="$thisdir/include $APU_SOURCE_DIR/include"
+ flags="$APU_BUILD_DIR/include $APU_SOURCE_DIR/include"
fi
echo $flags
exit 0
@@ -159,7 +130,7 @@
flags="$flags -I$APU_SOURCE_DIR/include $INCLUDES"
else
# this is for VPATH builds
- flags="$flags -I$thisdir/include -I$APU_SOURCE_DIR/include $INCLUDES"
+ flags="$flags -I$APU_BUILD_DIR/include -I$APU_SOURCE_DIR/include $INCLUDES"
fi
;;
--ldflags)
@@ -178,7 +149,7 @@
### avoid using -L if libdir is a "standard" location like /usr/lib
flags="$flags -L$libdir -l$APRUTIL_LIBNAME"
else
- flags="$flags -L$thisdir -l$APRUTIL_LIBNAME"
+ flags="$flags -L$APU_BUILD_DIR -l$APRUTIL_LIBNAME"
fi
;;
--link-libtool)
diff --git a/configure.in b/configure.in
index aacf756..a68f9f5 100644
--- a/configure.in
+++ b/configure.in
@@ -28,8 +28,13 @@
if test "$abs_builddir" != "$abs_srcdir"; then
USE_VPATH=1
+ APU_CONFIG_LOCATION=build
+else
+ APU_CONFIG_LOCATION=source
fi
+AC_SUBST(APU_CONFIG_LOCATION)
+
AC_CANONICAL_SYSTEM
dnl