jerenkrantz 02/02/14 18:44:24
Modified: . apu-config.in
build find_apu.m4
Log:
Rework apu-config and find_apu.m4 to match gstein's rewrite of APR variants.
Revision Changes Path
1.5 +78 -14 apr-util/apu-config.in
Index: apu-config.in
===================================================================
RCS file: /home/cvs/apr-util/apu-config.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- apu-config.in 24 Jan 2002 04:39:38 -0000 1.4
+++ apu-config.in 15 Feb 2002 02:44:24 -0000 1.5
@@ -55,16 +55,18 @@
# APR-util script designed to allow easy command line access to APR-util
# configuration parameters.
-PREFIX="@prefix@"
-EXEC_PREFIX="@exec_prefix@"
-BINDIR="@bindir@"
-LIBDIR="@libdir@"
-TOP_SRCDIR="@top_srcdir@"
-TOP_BUILDDIR="@top_builddir@"
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
+bindir="@bindir@"
+libdir="@libdir@"
+
LIBS="@APRUTIL_EXPORT_LIBS@"
INCLUDES="@APRUTIL_INCLUDES@"
LDFLAGS="@APRUTIL_LDFLAGS@"
+APU_SOURCE_DIR="@top_srcdir@"
+APU_BUILD_DIR="@top_builddir@"
+
show_usage()
{
cat << EOF
@@ -75,7 +77,19 @@
--includes print include information
--ldflags print linker flags
--libs print library information
+ --srcdir print APR-util source directory
+ --link-ld print link switch(es) for linking to APR-util
+ --link-libtool print the libtool inputs for linking to APR-util
+ --apu-la-file print the path to the .la file, if available
--help print this help
+
+When linking with libtool, an application should do something like:
+ APU_LIBS="\`apu-config --link-libtool --libs\`"
+or when linking directly:
+ APU_LIBS="\`apu-config --link-ld --libs\`"
+
+An application should use the results of --includes, and --ldflags in
+their build process.
EOF
}
@@ -84,6 +98,24 @@
exit 1
fi
+thisdir="`dirname $0`"
+thisdir="`cd $thisdir && pwd`"
+if test "$bindir" = "$thisdir"; then
+ location=installed
+elif test "$APR_SOURCE_DIR" = "$thisdir"; then
+ location=source
+else
+ location=build
+fi
+
+if test "$location" = "installed"; then
+ LA_FILE="$libdir/libaprutil.la"
+else
+ LA_FILE="$thisdir/libaprutil.la"
+fi
+
+flags=""
+
while test $# -gt 0; do
# Normalize the prefix.
case "$1" in
@@ -97,25 +129,53 @@
prefix=$optarg
;;
--prefix)
- echo $PREFIX
+ echo $prefix
+ exit 0
;;
--libs)
- if [ -f $PREFIX/lib/libexpat.la ] ; then
- TMP_BUILDDIR=`echo "$TOP_BUILDDIR/xml/expat" | sed 's/\\//\\\\\\//g'`
- TMP_PREFIX=`echo $PREFIX | sed 's/\\//\\\\\\//g'`
+ if test "$location" = "installed" && -f $PREFIX/lib/libexpat.la; then
+ TMP_BUILDDIR=`echo "$APU_BUILD_DIR/xml/expat" | sed 's/\\//\\\\\\//g'`
+ TMP_PREFIX=`echo $prefix | sed 's/\\//\\\\\\//g'`
LIBS=`echo "$LIBS" | sed "s/$TMP_BUILDDIR/$TMP_PREFIX/g"`
fi
- echo "$LIBS"
+ flags="$flags $LIBS"
;;
--includes)
- echo $INCLUDES
+ flags="$flags $INCLUDES"
;;
--ldflags)
- echo $LDFLAGS
+ flags="$flags $LDFLAGS"
+ ;;
+ --srcdir)
+ echo $APU_SOURCE_DIR
+ exit 0
+ ;;
+ --link-ld)
+ if test "$location" = "installed"; then
+ ### avoid using -L if libdir is a "standard" location like /usr/lib
+ flags="$flags -L$libdir -laprutil"
+ else
+ flags="$flags -L$thisdir -laprutil"
+ fi
+ ;;
+ --link-libtool)
+ if test -f "$LA_FILE"; then
+ flags="$flags $LA_FILE"
+ elif test "$location" = "installed"; then
+ ### avoid using -L if libdir is a "standard" location like /usr/lib
+ flags="$flags -L$libdir -laprutil"
+ else
+ flags="$flags -L$thisdir -laprutil"
+ fi
+ ;;
+ --apu-la-file)
+ if test -f "$LA_FILE"; then
+ flags="$flags $LA_FILE"
+ fi
;;
--help)
show_usage
- exit 1
+ exit 0
;;
*)
show_usage
@@ -126,5 +186,9 @@
# Next please.
shift
done
+
+if test -n "$flags"; then
+ echo "$flags"
+fi
exit 0
1.4 +45 -95 apr-util/build/find_apu.m4
Index: find_apu.m4
===================================================================
RCS file: /home/cvs/apr-util/build/find_apu.m4,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- find_apu.m4 15 Feb 2002 00:19:15 -0000 1.3
+++ find_apu.m4 15 Feb 2002 02:44:24 -0000 1.4
@@ -15,51 +15,33 @@
dnl
dnl Sets the following variables on exit:
dnl
-dnl apu_libdir : A custom directory to use for linking (the -L switch).
-dnl If APU exists in a standard location, this variable
-dnl will be empty
-dnl
-dnl apu_la_file : If a libtool .la file exists, this will refer to it. If
-dnl there is no .la file, then this variable will be empty.
-dnl
-dnl apu_includes : Where the APU includes are located, if a non-standard
-dnl location. This variable has the format "-Idir -Idir".
-dnl It may specify more than one directory.
-dnl
-dnl apu_srcdir : If an APU source tree is available and needs to be
-dnl (re)configured, this refers to it.
-dnl
-dnl apu_config : If the apr-config tool exists, this refers to it.
-dnl
dnl apu_found : "yes", "no", "reconfig"
dnl
+dnl apu_config : If the apu-config tool exists, this refers to it. If
+dnl apu_found is "reconfig", then the bundled directory
+dnl should be reconfigured *before* using apu_config.
+dnl
dnl Note: At this time, we cannot find *both* a source dir and a build dir.
dnl If both are available, the build directory should be passed to
-dnl the --with-apr switch (apu_srcdir will be empty).
+dnl the --with-apr-util switch.
dnl
dnl Note: the installation layout is presumed to follow the standard
dnl PREFIX/lib and PREFIX/include pattern. If the APU config file
dnl is available (and can be found), then non-standard layouts are
dnl possible, since it will be described in the config file.
dnl
-dnl If apu_found is "yes" or "reconfig", then the caller should link using
-dnl apu_la_file, if available; otherwise, -lapr should be used (and if
-dnl apu_libdir is not null, then -L$apr_libdir). If apr_includes is not null,
-dnl then it should be used during compilation.
-dnl
-dnl If a source directory is available and needs to be (re)configured, then
-dnl apu_srcdir specifies the directory and apr_found is "reconfig".
+dnl If a bundled source directory is available and needs to be
(re)configured,
+dnl then apu_found is set to "reconfig". The caller should reconfigure the
+dnl (passed-in) source directory, placing the result in the build directory,
+dnl as appropriate.
dnl
-dnl Note: This m4 macro set makes the assumption that APR has already
-dnl been found and properly configured.
+dnl If apu_found is "yes" or "reconfig", then the caller should use the
+dnl value of apu_config to fetch any necessary build/link information.
dnl
AC_DEFUN(APR_FIND_APU, [
apu_found="no"
- preserve_LIBS="$LIBS"
- preserve_LDFLAGS="$LDFLAGS"
-
AC_MSG_CHECKING(for APR-util)
AC_ARG_WITH(apr-util,
[ --with-apr-util=DIR prefix for installed APU, or path to APU build
tree],
@@ -69,90 +51,58 @@
fi
if test -x "$withval/bin/apu-config"; then
+ apu_found="yes"
apu_config="$withval/bin/apu-config"
+ elif test -x "$withval/apu-config"; then
+ dnl Already configured build dir
apu_found="yes"
- apu_libdir="$withval/lib"
- apu_includes="-I$withval/include"
- else
- dnl look for a build tree (note: already configured/built)
- if test -f "$withval/libaprutil.la"; then
- apu_found="yes"
- apu_libdir=""
- apu_la_file="$withval/libaprutil.la"
- if test -x "$withval/apu-config"; then
- apu_config="$withval/apu-config"
- else
- apu_config=""
- fi
- apu_includes="-I$withval/include"
- fi
+ apu_config="$withval/apu-config"
+ elif test -x "$withval" && $withval --help > /dev/null 2>&1 ; then
+ apu_found="yes"
+ apu_config="$withval"
fi
- dnl if --with-apr is used, then the target prefix/directory must be valid
+ dnl if --with-apr-util is used, then the target prefix/directory must
+ dnl be valid
if test "$apu_found" != "yes"; then
AC_MSG_ERROR([
The directory given to --with-apr-util does not specify a prefix for an
installed APU, nor an APR-util build directory.])
fi
],[
- dnl always look in the builtin/default places
- LIBS="$LIBS -laprutil"
- AC_TRY_LINK_FUNC(apr_uri_parse, [
- dnl We don't have to do anything.
- apu_found="yes"
- apu_srcdir=""
- apu_libdir=""
- apu_includes=""
- apu_libtool=""
- apu_la_file=""
- apu_config=""
- ], [
+ if apu-config --help > /dev/null 2>&1 ; then
+ apu_found="yes"
+ apu_config="apu-config"
+ else
dnl look in the some standard places (apparently not in
builtin/default)
for lookdir in /usr /usr/local /opt/apr ; do
- if test "$apu_found" != "yes"; then
- LDFLAGS="$preserve_LDFLAGS -L$lookdir/lib"
- AC_TRY_LINK_FUNC(apr_uri_parse, [
- apu_found="yes"
- apu_libdir="$lookdir/lib"
- apu_includes="-I$lookdir/include"
- if test -x "$withval/bin/apu-config"; then
- apu_config="$withval/bin/apu-config"
- else
- apu_config=""
- fi
- ])
+ if test -x "$lookdir/bin/apu-config"; then
+ apu_found="yes"
+ apu_config="$lookdir/bin/apu-config"
+ break
fi
done
- ])
- dnl We attempt to guess what the data will be *after* configure is run.
- dnl Note, if we don't see configure, but do have configure.in, it'd be
- dnl nice to run buildconf, but that's for another day.
- if test "$apu_found" = "no" && test -d "$1" && test -x "$1/configure";
then
- apu_found="reconfig"
- apu_srcdir="$1"
- if test -n "$2"; then
- apu_builddir="$2/"
- else
- apu_builddir=""
+ fi
+ dnl if we have a bundled source directory, then we may have more work
+ if test -d "$1"; then
+ apu_temp_abs_srcdir="`cd $1 && pwd`"
+ if test "$apu_found" = "yes" \
+ && test "`$apu_config --srcdir`" = "$apu_temp_abs_srcdir"; then
+ dnl the installed apu-config represents our source directory, so
+ dnl pretend we didn't see it and just use our bundled source
+ apu_found="no"
fi
- apu_libdir=""
- apu_la_file="$apu_builddir$apu_srcdir/libaprutil.la"
- if test -f "$apu_builddir$apu_srcdir/apu-config.in"; then
- apu_config="$apu_builddir$apu_srcdir/apu-config"
- else
- apu_config=""
+ dnl We could not find an apu-config; use the bundled one
+ if test "$apu_found" = "no"; then
+ apu_found="reconfig"
+ if test -n "$2"; then
+ apu_config="$2/apu-config"
+ else
+ apu_config="$1/apu-config"
+ fi
fi
- apu_includes="-I$apu_builddir$apu_srcdir/include"
fi
])
- if test "$apu_found" != "no" && test "$apr_libdir" != ""; then
- if test "$apu_la_file" = "" && test -f "$apr_libdir/libapr.la"; then
- apu_la_file="$apr_libdir/libaprutil.la"
- fi
- fi
-
AC_MSG_RESULT($apu_found)
- LIBS="$preserve_LIBS"
- LDFLAGS="$preserve_LDFLAGS"
])