gstein 02/02/06 03:41:57
Modified: . apr-config.in
build find_apr.m4
Log:
Big revamp of the find_apr.m4 script for locating an installed/bundled
copy of APR. Some associated changes in apr-config to better support
the concept, and to fix some issues with apps using it for flags.
* find_apr.m4: dramatic simplification. if we can find apr-config,
then we can get all the possible information we might need:
libraries, includes, linker flags, etc. So, most of the code was
cut and we now just look for apr-config. The parameters to
APR_FIND_APR have been clarified and cleand up to better support
VPATH builds.
* apr-config.in: glom all flags together to prevent newlines from
getting in there.
Revision Changes Path
1.7 +21 -13 apr/apr-config.in
Index: apr-config.in
===================================================================
RCS file: /home/cvs/apr/apr-config.in,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- apr-config.in 4 Feb 2002 01:05:17 -0000 1.6
+++ apr-config.in 6 Feb 2002 11:41:57 -0000 1.7
@@ -123,6 +123,8 @@
LA_FILE="$thisdir/libapr.la"
fi
+flags=""
+
while test $# -gt 0; do
# Normalize the prefix.
case "$1" in
@@ -137,52 +139,54 @@
;;
--prefix)
echo $prefix
+ exit 0
;;
--cflags)
- echo $CFLAGS
+ flags="$flags $CFLAGS"
;;
--cppflags)
- echo $CPPFLAGS
+ flags="$flags $CPPFLAGS"
;;
--libs)
- echo $LIBS
+ flags="$flags $LIBS"
;;
--ldflags)
- echo $LDFLAGS
+ flags="$flags $LDFLAGS"
;;
--includes)
if test "$location" = "installed"; then
- echo "-I$includedir $EXTRA_INCLUDES"
+ flags="$flags -I$includedir $EXTRA_INCLUDES"
elif test "$location" = "source"; then
- echo "-I$APR_SOURCE_DIR/include $EXTRA_INCLUDES"
+ flags="$flags -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES"
else
- echo "-I$thisdir/include -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES"
+ flags="$flags -I$thisdir/include -I$APR_SOURCE_DIR/include
$EXTRA_INCLUDES"
fi
;;
--srcdir)
echo $APR_SOURCE_DIR
+ exit 0
;;
--link-ld)
if test "$location" = "installed"; then
### avoid using -L if libdir is a "standard" location like /usr/lib
- echo "-L$libdir -lapr"
+ flags="$flags -L$libdir -lapr"
else
- echo "-L$thisdir -lapr"
+ flags="$flags -L$thisdir -lapr"
fi
;;
--link-libtool)
if test -f "$LA_FILE"; then
- echo $LA_FILE
+ flags="$flags $LA_FILE"
elif test "$location" = "installed"; then
### avoid using -L if libdir is a "standard" location like /usr/lib
- echo "-L$libdir -lapr"
+ flags="$flags -L$libdir -lapr"
else
- echo "-L$thisdir -lapr"
+ flags="$flags-L$thisdir -lapr"
fi
;;
--apr-la-file)
if test -f "$LA_FILE"; then
- echo $LA_FILE
+ flags="$flags $LA_FILE"
fi
;;
--help)
@@ -198,5 +202,9 @@
# Next please.
shift
done
+
+if test -n "$flags"; then
+ echo "$flags"
+fi
exit 0
1.7 +55 -136 apr/build/find_apr.m4
Index: find_apr.m4
===================================================================
RCS file: /home/cvs/apr/build/find_apr.m4,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- find_apr.m4 1 Feb 2002 03:11:16 -0000 1.6
+++ find_apr.m4 6 Feb 2002 11:41:57 -0000 1.7
@@ -6,179 +6,98 @@
dnl embedding APR into the application source, or locating an installed
dnl copy of APR.
dnl
-dnl APR_FIND_APR([srcdir, path])
+dnl APR_FIND_APR([srcdir [, builddir]])
dnl
dnl where srcdir is the location of the bundled APR source directory, or
dnl empty if source is not bundled.
-dnl where path is the prefix to the location where the bundled APR will
-dnl will be built.
dnl
+dnl where blddir is the location where the bundled APR will will be built,
+dnl or empty if the build will occur in the srcdir.
dnl
-dnl Sets the following variables on exit:
-dnl
-dnl apr_libdir : A custom directory to use for linking (the -L switch).
-dnl If APR exists in a standard location, this variable
-dnl will be empty
-dnl
-dnl apr_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 apr_includes : Where the APR 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 apr_srcdir : If an APR source tree is available and needs to be
-dnl (re)configured, this refers to it.
-dnl
-dnl apr_config : If the apr-config tool exists, this refers to it.
dnl
-dnl apr_vars : If the APR config file (APRVARS) exists, this refers to it.
+dnl Sets the following variables on exit:
dnl
dnl apr_found : "yes", "no", "reconfig"
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 (apr_srcdir will be empty).
-dnl
-dnl Note: the installation layout is presumed to follow the standard
-dnl PREFIX/lib and PREFIX/include pattern. If the APR 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 apr_found is "yes" or "reconfig", then the caller should link using
-dnl apr_la_file, if available; otherwise, -lapr should be used (and if
-dnl apr_libdir is not null, then -L$apr_libdir). If apr_includes is not null,
-dnl then it should be used during compilation.
+dnl apr_config : If the apr-config tool exists, this refers to it. If
+dnl apr_found is "reconfig", then the bundled directory
+dnl should be reconfigured *before* using apr_config.
+dnl
+dnl Note: this macro file assumes that apr-config has been installed; it
+dnl is normally considered a required part of an APR installation.
+dnl
+dnl If a bundled source directory is available and needs to be
(re)configured,
+dnl then apr_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 If a source directory is available and needs to be (re)configured, then
-dnl apr_srcdir specifies the directory and apr_found is "reconfig".
+dnl If apr_found is "yes" or "reconfig", then the caller should use the
+dnl value of apr_config to fetch any necessary build/link information.
dnl
AC_DEFUN(APR_FIND_APR, [
apr_found="no"
- preserve_LIBS="$LIBS"
- preserve_LDFLAGS="$LDFLAGS"
- preserve_CFLAGS="$CFLAGS"
-
AC_MSG_CHECKING(for APR)
AC_ARG_WITH(apr,
- [ --with-apr=DIR prefix for installed APR, or path to APR build
tree],
+ [ --with-apr=DIR|FILE prefix for installed APR, path to APR build
tree,
+ or the full path to apr-config],
[
if test "$withval" = "no" || test "$withval" = "yes"; then
AC_MSG_ERROR([--with-apr requires a directory to be provided])
fi
if test -x "$withval/bin/apr-config"; then
- apr_config="$withval/bin/apr-config"
- CFLAGS="$CFLAGS `$withval/bin/apr-config --cflags`"
- LIBS="$LIBS `$withval/bin/apr-config --libs`"
- LDFLAGS="$LDFLAGS `$withval/bin/apr-config --ldflags`"
- else
- apr_config=""
+ apr_found="yes"
+ apr_config="$withval/bin/apr-config"
+ elif test -f "$withval/apr-config"; then
+ apr_found="yes"
+ apr_config="$withval/apr-config"
+ elif test -x "$withval" && $withval --help > /dev/null 2>&1 ; then
+ apr_found="yes"
+ apr_config="$withval"
fi
- LIBS="$LIBS -lapr"
- LDFLAGS="$preserve_LDFLAGS -L$withval/lib"
- AC_TRY_LINK_FUNC(apr_initialize, [
- if test -f "$withval/include/apr.h"; then
- dnl found an installed version of APR
- apr_found="yes"
- apr_libdir="$withval/lib"
- apr_includes="-I$withval/include"
- fi
- ], [
- dnl look for a build tree (note: already configured/built)
- if test -f "$withval/libapr.la"; then
- apr_found="yes"
- apr_libdir=""
- apr_la_file="$withval/libapr.la"
- apr_vars="$withval/APRVARS"
- if test -x $withval/apr-config; then
- apr_config="$withval/apr-config"
- else
- apr_config=""
- fi
- apr_includes="-I$withval/include"
- if test ! -f "$withval/APRVARS.in"; then
- dnl extract the APR source directory without polluting our
- dnl shell variable space
- apr_srcdir="`sed -n '/APR_SOURCE_DIR/s/.*"\(.*\)"/\1/p' $apr_vars`"
- apr_includes="$apr_includes -I$apr_srcdir/include"
- fi
- fi
- ])
-
dnl if --with-apr is used, then the target prefix/directory must be valid
if test "$apr_found" != "yes"; then
- AC_MSG_ERROR([
-The directory given to --with-apr does not specify a prefix for an installed
-APR, nor an APR build directory.])
+ AC_MSG_ERROR([the --with-apr parameter is incorrect. It must specify
an install prefix, a
+build directory, or an apr-config file.])
fi
],[
dnl always look in the builtin/default places
- LIBS="$LIBS -lapr"
- AC_TRY_LINK_FUNC(apr_initialize, [
- dnl We don't have to do anything.
- apr_found="yes"
- apr_srcdir=""
- apr_libdir=""
- apr_includes=""
- apr_la_file=""
- apr_config=""
- apr_vars=""
- ], [
- dnl look in the some standard places (apparently not in
builtin/default)
+ if apr-config --help > /dev/null 2>&1 ; then
+ apr_found="yes"
+ apr_config="apr-config"
+ else
+ dnl look in some standard places (apparently not in builtin/default)
for lookdir in /usr /usr/local /opt/apr ; do
- if test "$apr_found" != "yes"; then
- LDFLAGS="$preserve_LDFLAGS -L$lookdir/lib"
- AC_TRY_LINK_FUNC(apr_initialize, [
- apr_found="yes"
- apr_libdir="$lookdir/lib"
- apr_includes="-I$lookdir/include"
- if test -x "$withval/bin/apr-config"; then
- apr_config="$withval/bin/apr-config"
- else
- apr_config=""
- fi
- ])
+ if test -x "$lookdir/bin/apr-config"; then
+ apr_found="yes"
+ apr_config="$lookdir/bin/apr-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 "$apr_found" = "no" && test -n "$1" && test -x "$1/configure";
then
- apr_found="reconfig"
- apr_srcdir="$1"
- if test -n "$2"; then
- apr_builddir="$2/"
- else
- apr_builddir=""
+ fi
+ dnl if we have a bundled source directory, then we may have more work
+ if test -n "$1"; then
+ apr_temp_abs_srcdir="`cd $1 && pwd`"
+ if test "$apr_found" = "yes" \
+ -a "`$apr_config --srcdir`" = "$apr_temp_abs_srcdir"; then
+ dnl the installed apr-config represents our source directory, so
+ dnl pretend we didn't see it and just use our bundled source
+ apr_found="no"
fi
- apr_libdir=""
- apr_la_file="$apr_builddir$apr_srcdir/libapr.la"
- apr_vars="$apr_builddir$apr_srcdir/APRVARS"
- if test -f "$apr_builddir$apr_srcdir/apr-config.in"; then
- apr_config="$apr_builddir$apr_srcdir/apr-config"
- else
- apr_config=""
+ dnl We could not find an apr-config; use the bundled one
+ if test "$apr_found" = "no"; then
+ apr_found="reconfig"
+ if test -n "$2"; then
+ apr_config="$2/apr-config"
+ else
+ apr_config="$1/apr-config"
+ fi
fi
- apr_includes="-I$apr_builddir$apr_srcdir/include"
fi
])
- if test "$apr_found" != "no" && test "$apr_libdir" != ""; then
- if test "$apr_vars" = "" && test -f "$apr_libdir/APRVARS"; then
- apr_vars="$apr_libdir/APRVARS"
- fi
- if test "$apr_la_file" = "" && test -f "$apr_libdir/libapr.la"; then
- apr_la_file="$apr_libdir/libapr.la"
- fi
- fi
-
AC_MSG_RESULT($apr_found)
- CFLAGS="$preserve_CFLAGS"
- LIBS="$preserve_LIBS"
- LDFLAGS="$preserve_LDFLAGS"
])