apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject cvs commit: apr-util/build find_apu.m4
Date Thu, 17 Jan 2002 01:49:23 GMT
jerenkrantz    02/01/16 17:49:23

  Modified:    .        CHANGES
  Added:       build    find_apu.m4
  Log:
  Provide a m4 macro that allows programs to easily find APR-util.
  
  Note that this is heavily based on APR's find_apr.m4.
  
  Revision  Changes    Path
  1.50      +3 -0      apr-util/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr-util/CHANGES,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- CHANGES	17 Jan 2002 00:50:12 -0000	1.49
  +++ CHANGES	17 Jan 2002 01:49:23 -0000	1.50
  @@ -1,5 +1,8 @@
   Changes with APR-util b1  
   
  +  *) Add find_apu.m4 to allow third-party programs that use APR-util
  +     to have a standard m4 macro for detection.  [Justin Erenkrantz]
  +
     *) Add apu-config - a shell script to allow third-party programs
        easy access to APR configuration parameters.  [Justin Erenkrantz]
   
  
  
  
  1.1                  apr-util/build/find_apu.m4
  
  Index: find_apu.m4
  ===================================================================
  dnl
  dnl find_apu.m4 : locate the APR-util (APU) include files and libraries
  dnl
  dnl This macro file can be used by applications to find and use the APU
  dnl library. It provides a standardized mechanism for using APU. It supports
  dnl embedding APU into the application source, or locating an installed
  dnl copy of APU.
  dnl
  dnl APR_FIND_APU([srcdir])
  dnl
  dnl   where srcdir is the location of the bundled APU source directory, or
  dnl   empty if source is not bundled.
  dnl
  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 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
  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
  dnl Note: This m4 macro set makes the assumption that APR has already
  dnl       been found and properly configured.
  dnl
  
  AC_DEFUN(APR_FIND_APU, [
    apu_found="no"
  
    preserve_LIBS="$LIBS"
    preserve_LDFLAGS="$LDFLAGS"
    preserve_CFLAGS="$CFLAGS"
  
    dnl We're going to be running our tests with gcc not libtool.  So,
    dnl attempt to setup APR correctly for the interim period.  We just
    dnl need to link not run, so -lapr should be fine if everything else
    dnl has been setup.
    if test -n "$apr_la_file"; then
      LIBS="$LIBS -lapr"  
    fi
  
    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],
    [
      if test "$withval" = "no" || test "$withval" = "yes"; then
        AC_MSG_ERROR([--with-apr-util requires a directory to be provided])
      fi
  
      if test -x "$withval/bin/apu-config"; then
         apu_config="$withval/bin/apu-config"
         dnl FIXME: Convert libexpat.la to -lexpat
         APU_LIBS=`$withval/bin/apu-config --libs`
         TMP_WITHVAL=`echo "$withval/lib/libexpat.la" | sed 's/\\//\\\\\\//g'`
         APU_LIBS=`echo $APU_LIBS | sed "s/$TMP_WITHVAL/-lexpat/g"`
         LIBS="$LIBS $APU_LIBS"
      else
         apu_config=""
      fi
  
      LIBS="$LIBS -laprutil"
      LDFLAGS="$preserve_LDFLAGS -L$withval/lib"
      AC_TRY_LINK_FUNC(apr_uri_parse, [
        if test -f "$withval/include/apu.h"; then
          dnl found an installed version of APU
          apu_found="yes"
          apu_libdir="$withval/lib"
          apu_includes="-I$withval/include"
        fi
      ], [
        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
      ])
  
      dnl if --with-apr is used, then the target prefix/directory must 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=""
        ], [
        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
            ])
          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 -n "$1" && test -x "$1/configure";
then
        apu_found="reconfig"
        apu_srcdir="$1"
        apu_libdir=""
        apu_la_file="$apu_srcdir/libaprutil.la"
        if test -f "$apu_srcdir/apu-config.in"; then
          apu_config="$apu_srcdir/apu-config"
        else
          apu_config=""
        fi
        apu_includes="-I$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)
    CFLAGS="$preserve_CFLAGS"
    LIBS="$preserve_LIBS"
    LDFLAGS="$preserve_LDFLAGS"
  ])
  
  
  

Mime
View raw message