On Fri, Dec 14, 2001 at 05:11:53PM -0600, Karl Fogel wrote:
> Justin Erenkrantz <jerenkrantz@ebuilt.com> writes:
> > Per gstein's comments, let's factor out configuration of APR into
> > a standard find_apr.m4 (see apr/build/find_apr.m4 - copy the
> > latest version into ac-helpers/).
> >
> > I tried to maintain as much of the original logic as possible.
> > I hopefully succeeded. Please review, test, and give feedback. =)
>
> Can you post a log message for this too? It really helps when
> reviewing the patch.
I have included the latest find_apr.m4 at the end of the message.
You should also be able to take it from apr/build/find_apr.m4 at
any point. This patch should switch the knowledge from SVN to
APR about how best to detect APR by relying on a common m4
macro provided by APR itself. =) -- justin
ac-helpers/apr.m4 (SVN_LIB_APR): Refactor the APR detection code
to take advantage of APR's find_apr.m4 APR_FIND_APR macro.
ac-helpers/apr.m4 (SVN_FIND_APR): Removed as find_apr.m4 will
handle this.
configure.in: Add find_apr.m4 as an included file to source.
ac-helpers/find_apr.m4: Imported from APR CVS repository. This
file provides the common APR_FIND_APR macro.
Index: ./ac-helpers/apr.m4
===================================================================
--- ./ac-helpers/.svn/text-base/apr.m4.svn-base Mon Dec 10 01:49:38 2001
+++ ./ac-helpers/apr.m4 Tue Dec 11 02:20:48 2001
@@ -3,133 +3,54 @@
dnl Check configure options and assign variables related to
dnl the Apache Portable Runtime (APR) library.
dnl
-dnl If there is a apr/ subdir we assme we want to use it. In that
-dnl case an option telling us to use a locally installed apr
-dnl triggers an error.
-dnl
-dnl TODO : check apr version, link a test program
-
AC_DEFUN(SVN_LIB_APR,
[
AC_MSG_NOTICE([Apache Portable Runtime (APR) library configuration])
- AC_ARG_WITH(apr-libs,
- [AC_HELP_STRING([--with-apr-libs=PREFIX],
- [Use Apache Portable Runtime (APR) library at PREFIX])],
- [
- if test -d $abs_srcdir/apr ; then
- AC_MSG_ERROR([--with-apr-libs option but apr/ subdir exists.
-Please either remove that subdir or don't use the --with-apr-libs option.])
- fi
-
- if test "$withval" = "yes" ; then
- AC_MSG_ERROR([--with-apr-libs requires an argument.])
- else
- APRVARS="$withval/APRVARS"
- APR_LIBS="$withval"
- fi
- ])
-
- AC_ARG_WITH(apr-includes,
- [AC_HELP_STRING([--with-apr-includes=PREFIX],
- [Use Apache Portable Runtime (APR) includes at PREFIX])],
- [
- if test -d $abs_srcdir/apr ; then
- AC_MSG_ERROR([--with-apr-includes option but apr/ subdir exists.
-Please either remove that subdir or don't use the --with-apr-includes option.])
- fi
-
- if test "$withval" = "yes" ; then
- AC_MSG_ERROR([--with-apr-includes requires an argument.])
- else
- APR_INCLUDES="$withval"
- fi
- ])
-
- AC_ARG_WITH(apr,
- [AC_HELP_STRING([--with-apr=PREFIX],
- [Use Apache Portable Runtime (APR) at PREFIX])],
- [
- if test -d $abs_srcdir/apr ; then
- AC_MSG_ERROR([--with-apr option but apr/ subdir exists.
-Please either remove that subdir or don't use the --with-apr option.])
- fi
-
- if test "$withval" != "yes" ; then
- APR_INCLUDES="$withval/include"
- APRVARS="$withval/lib/APRVARS"
- APR_LIBS="$withval/lib"
- fi
- ])
-
- if test -d $abs_srcdir/apr ; then
- echo "Using apr found in source directory"
- APR_INCLUDES='$(abs_builddir)/apr/include'
- APR_LIBS='$(abs_builddir)/apr'
- APRVARS=$abs_builddir/apr/APRVARS
- SVN_SUBDIR_CONFIG(apr)
- SVN_SUBDIRS="$SVN_SUBDIRS apr"
- else
- SVN_FIND_APR
+ APR_FIND_APR(apr)
+
+ if test $apr_found = "no"; then
+ AC_MSG_WARN([APR not found])
+ SVN_DOWNLOAD_APR
fi
+ if test $apr_found = "reconfig"; then
+ SVN_SUBDIR_CONFIG($apr_srcdir)
+ SVN_SUBDIRS="$SVN_SUBDIRS $apr_srcdir"
+ fi
dnl Get libraries and thread flags from APR ---------------------
- if test -f "$APRVARS"; then
- . "$APRVARS"
+ if test -x "$apr_config"; then
+ CPPFLAGS="$CPPFLAGS `$apr_config --cppflags`"
+ CFLAGS="$CFLAGS `$apr_config --cflags`"
+ LIBS="$LIBS `$apr_config --libs`"
+ else if test -f "$apr_vars"; then
+ . "$apr_config"
CPPFLAGS="$CPPFLAGS $EXTRA_CPPFLAGS"
CFLAGS="$CFLAGS $EXTRA_CFLAGS"
LIBS="$LIBS $EXTRA_LIBS"
else
- AC_MSG_WARN([APRVARS not found])
+ AC_MSG_WARN([apr-config or APRVARS not found])
SVN_DOWNLOAD_APR
fi
+ fi
- if test -n "$APR_INCLUDES" ; then
- SVN_EXTRA_INCLUDES="$SVN_EXTRA_INCLUDES -I$APR_INCLUDES"
- if test "$abs_srcdir" != "$abs_builddir" && test -d $abs_srcdir/apr ; then
+ SVN_EXTRA_INCLUDES="$SVN_EXTRA_INCLUDES $apr_includes"
+ if test "$abs_srcdir" != "$abs_builddir" && test -d $abs_srcdir/apr ; then
SVN_EXTRA_INCLUDES="$SVN_EXTRA_INCLUDES -I$abs_srcdir/apr/include"
- fi
fi
- if test -z "$APR_LIBS" ; then
+ if test -z "$apr_la_file" ; then
SVN_APR_LIBS="-lapr $LIBTOOL_LIBS"
else
- SVN_APR_LIBS="$APR_LIBS/libapr.la $LIBTOOL_LIBS"
+ SVN_APR_LIBS="$apr_la_file $LIBTOOL_LIBS"
fi
AC_SUBST(SVN_APR_LIBS)
])
-
-dnl SVN_FIND_APR()
-dnl Look in standard places for APRVARS, apr.h, and -lapr.
-AC_DEFUN(SVN_FIND_APR,
-[
- CPPFLAGS_save=$CPPFLAGS
- if test -n "$APR_INCLUDES" ; then
- CPPFLAGS="$CPPFLAGS -I$APR_INCLUDES"
- fi
- AC_CHECK_HEADER(apr.h, apr_h="yes", apr_h="no")
- if test "$apr_h" = "no" ; then
- echo "Couldn't find apr.h"
- SVN_DOWNLOAD_APR
- fi
-
- CPPFLAGS=$CPPFLAGS_save
- if test -z "$APRVARS" ; then
- dirs="/etc /usr/lib /usr/local/lib /opt/apr/lib"
- for dir in $dirs; do
- if test -f $dir/APRVARS ; then
- APRVARS=$dir/APRVARS
- break
- fi
- done
- fi
-])
-
dnl SVN_DOWNLOAD_APR()
dnl no apr found, print out a message telling the user what to do
Index: ./configure.in
===================================================================
--- ./.svn/text-base/configure.in.svn-base Mon Dec 10 01:49:24 2001
+++ ./configure.in Tue Dec 11 01:50:05 2001
@@ -30,6 +30,7 @@
sinclude(ac-helpers/svn-apache.m4)
sinclude(ac-helpers/svn-macros.m4)
sinclude(ac-helpers/neon.m4)
+sinclude(ac-helpers/find_apr.m4)
sinclude(ac-helpers/apr.m4)
sinclude(ac-helpers/aprutil.m4)
Index: ./ac-helpers/find_apr.m4
===================================================================
dnl
dnl find_apr.m4 : locate the APR include files and libraries
dnl
dnl This macro file can be used by applications to find and use the APR
dnl library. It provides a standardized mechanism for using APR. It supports
dnl embedding APR into the application source, or locating an installed
dnl copy of APR.
dnl
dnl APR_FIND_APR([srcdir])
dnl
dnl where srcdir is the location of the bundled APR source directory, or
dnl empty if source is not bundled.
dnl
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
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
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
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],
[
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=""
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.])
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)
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
])
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"
apr_libdir=""
apr_la_file="$apr_srcdir/libapr.la"
apr_vars="$apr_srcdir/APRVARS"
if test -f "$apr_srcdir/apr-config.in"; then
apr_config="$apr_srcdir/apr-config"
else
apr_config=""
fi
apr_includes="-I$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"
])
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:53 2006