source: valtobtest/subversion-1.6.2/build/ac-macros/find_apu.m4 @ 3

Last change on this file since 3 was 3, checked in by valtob, 15 years ago

subversion source 1.6.2 as test

File size: 5.7 KB
Line 
1dnl
2dnl find_apu.m4 : locate the APR-util (APU) include files and libraries
3dnl
4dnl This macro file can be used by applications to find and use the APU
5dnl library. It provides a standardized mechanism for using APU. It supports
6dnl embedding APU into the application source, or locating an installed
7dnl copy of APU.
8dnl
9dnl APR_FIND_APU(srcdir, builddir, implicit-install-check, acceptable-majors)
10dnl
11dnl   where srcdir is the location of the bundled APU source directory, or
12dnl   empty if source is not bundled.
13dnl
14dnl   where builddir is the location where the bundled APU will be built,
15dnl   or empty if the build will occur in the srcdir.
16dnl
17dnl   where implicit-install-check set to 1 indicates if there is no
18dnl   --with-apr-util option specified, we will look for installed copies.
19dnl
20dnl   where acceptable-majors is a space separated list of acceptable major
21dnl   version numbers. Often only a single major version will be acceptable.
22dnl   If multiple versions are specified, and --with-apr-util=PREFIX or the
23dnl   implicit installed search are used, then the first (leftmost) version
24dnl   in the list that is found will be used.  Currently defaults to [0 1].
25dnl
26dnl Sets the following variables on exit:
27dnl
28dnl   apu_found : "yes", "no", "reconfig"
29dnl
30dnl   apu_config : If the apu-config tool exists, this refers to it.  If
31dnl                apu_found is "reconfig", then the bundled directory
32dnl                should be reconfigured *before* using apu_config.
33dnl
34dnl Note: this macro file assumes that apr-config has been installed; it
35dnl       is normally considered a required part of an APR installation.
36dnl
37dnl Note: At this time, we cannot find *both* a source dir and a build dir.
38dnl       If both are available, the build directory should be passed to
39dnl       the --with-apr-util switch.
40dnl
41dnl Note: the installation layout is presumed to follow the standard
42dnl       PREFIX/lib and PREFIX/include pattern. If the APU config file
43dnl       is available (and can be found), then non-standard layouts are
44dnl       possible, since it will be described in the config file.
45dnl
46dnl If a bundled source directory is available and needs to be (re)configured,
47dnl then apu_found is set to "reconfig". The caller should reconfigure the
48dnl (passed-in) source directory, placing the result in the build directory,
49dnl as appropriate.
50dnl
51dnl If apu_found is "yes" or "reconfig", then the caller should use the
52dnl value of apu_config to fetch any necessary build/link information.
53dnl
54
55AC_DEFUN([APR_FIND_APU], [
56  apu_found="no"
57
58  if test "$ac_cv_emxos2" = "yes"; then
59    # Scripts don't pass test -x on OS/2
60    TEST_X="test -f"
61  else
62    TEST_X="test -x"
63  fi
64
65  ifelse([$4], [],
66  [
67    ifdef(AC_WARNING,([$0: missing argument 4 (acceptable-majors): Defaulting to APU 0.x then APU 1.x]))
68    acceptable_majors="0 1"
69  ], [acceptable_majors="$4"])
70
71  apu_temp_acceptable_apu_config=""
72  for apu_temp_major in $acceptable_majors
73  do
74    case $apu_temp_major in
75      0)
76      apu_temp_acceptable_apu_config="$apu_temp_acceptable_apu_config apu-config"
77      ;;
78      *)
79      apu_temp_acceptable_apu_config="$apu_temp_acceptable_apu_config apu-$apu_temp_major-config"
80      ;;
81    esac
82  done
83
84  AC_MSG_CHECKING(for APR-util)
85  AC_ARG_WITH(apr-util,
86  [  --with-apr-util=PATH    prefix for installed APU, path to APU build tree,
87                          or the full path to apu-config],
88  [
89    if test "$withval" = "no" || test "$withval" = "yes"; then
90      AC_MSG_ERROR([--with-apr-util requires a directory or file to be provided])
91    fi
92
93    for apu_temp_apu_config_file in $apu_temp_acceptable_apu_config
94    do
95      for lookdir in "$withval/bin" "$withval"
96      do
97        if $TEST_X "$lookdir/$apu_temp_apu_config_file"; then
98          apu_found="yes"
99          apu_config="$lookdir/$apu_temp_apu_config_file"
100          break 2
101        fi
102      done
103    done
104
105    if test "$apu_found" != "yes" && $TEST_X "$withval" && $withval --help > /dev/null 2>&1 ; then
106      apu_found="yes"
107      apu_config="$withval"
108    fi
109
110    dnl if --with-apr-util is used, it is a fatal error for its argument
111    dnl to be invalid
112    if test "$apu_found" != "yes"; then
113      AC_MSG_ERROR([the --with-apr-util parameter is incorrect. It must specify an install prefix, a build directory, or an apu-config file.])
114    fi
115  ],[
116    dnl if we have a bundled source directory, use it
117    if test -d "$1"; then
118      apu_temp_abs_srcdir="`cd $1 && pwd`"
119      apu_found="reconfig"
120      apu_bundled_major="`sed -n '/#define.*APU_MAJOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p' \"$1/include/apu_version.h\"`"
121      case $apu_bundled_major in
122        "")
123          AC_MSG_ERROR([failed to find major version of bundled APU])
124        ;;
125        0)
126          apu_temp_apu_config_file="apu-config"
127        ;;
128        *)
129          apu_temp_apu_config_file="apu-$apu_bundled_major-config"
130        ;;
131      esac
132      if test -n "$2"; then
133        apu_config="$2/$apu_temp_apu_config_file"
134      else
135        apu_config="$1/$apu_temp_apu_config_file"
136      fi
137    fi
138    if test "$apu_found" = "no" && test -n "$3" && test "$3" = "1"; then
139      for apu_temp_apu_config_file in $apu_temp_acceptable_apu_config
140      do
141        if $apu_temp_apu_config_file --help > /dev/null 2>&1 ; then
142          apu_found="yes"
143          apu_config="$apu_temp_apu_config_file"
144          break
145        else
146          dnl look in some standard places (apparently not in builtin/default)
147          for lookdir in /usr /usr/local /opt/apr /usr/local/apache2 ; do
148            if $TEST_X "$lookdir/bin/$apu_temp_apu_config_file"; then
149              apu_found="yes"
150              apu_config="$lookdir/bin/$apu_temp_apu_config_file"
151              break 2
152            fi
153          done
154        fi
155      done
156    fi
157  ])
158
159  AC_MSG_RESULT($apu_found)
160])
Note: See TracBrowser for help on using the repository browser.