1
dnl -------------------------------------------------------- -*- autoconf -*-
2
dnl Licensed to the Apache Software Foundation (ASF) under one or more
3
dnl contributor license agreements. See the NOTICE file distributed with
4
dnl this work for additional information regarding copyright ownership.
5
dnl The ASF licenses this file to You under the Apache License, Version 2.0
6
dnl (the "License"); you may not use this file except in compliance with
7
dnl the License. You may obtain a copy of the License at
9
dnl http://www.apache.org/licenses/LICENSE-2.0
11
dnl Unless required by applicable law or agreed to in writing, software
12
dnl distributed under the License is distributed on an "AS IS" BASIS,
13
dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
dnl See the License for the specific language governing permissions and
15
dnl limitations under the License.
18
dnl find_apu.m4 : locate the APR-util (APU) include files and libraries
20
dnl This macro file can be used by applications to find and use the APU
21
dnl library. It provides a standardized mechanism for using APU. It supports
22
dnl embedding APU into the application source, or locating an installed
25
dnl APR_FIND_APU(srcdir, builddir, implicit-install-check, acceptable-majors,
28
dnl where srcdir is the location of the bundled APU source directory, or
29
dnl empty if source is not bundled.
31
dnl where builddir is the location where the bundled APU will be built,
32
dnl or empty if the build will occur in the srcdir.
34
dnl where implicit-install-check set to 1 indicates if there is no
35
dnl --with-apr-util option specified, we will look for installed copies.
37
dnl where acceptable-majors is a space separated list of acceptable major
38
dnl version numbers. Often only a single major version will be acceptable.
39
dnl If multiple versions are specified, and --with-apr-util=PREFIX or the
40
dnl implicit installed search are used, then the first (leftmost) version
41
dnl in the list that is found will be used. Currently defaults to [0 1].
43
dnl where detailed-check is an M4 macro which sets the apu_acceptable to
44
dnl either "yes" or "no". The macro will be invoked for each installed
45
dnl copy of APU found, with the apu_config variable set appropriately.
46
dnl Only installed copies of APU which are considered acceptable by
47
dnl this macro will be considered found. If no installed copies are
48
dnl considered acceptable by this macro, apu_found will be set to either
49
dnl either "no" or "reconfig".
51
dnl Sets the following variables on exit:
53
dnl apu_found : "yes", "no", "reconfig"
55
dnl apu_config : If the apu-config tool exists, this refers to it. If
56
dnl apu_found is "reconfig", then the bundled directory
57
dnl should be reconfigured *before* using apu_config.
59
dnl Note: this macro file assumes that apr-config has been installed; it
60
dnl is normally considered a required part of an APR installation.
62
dnl Note: At this time, we cannot find *both* a source dir and a build dir.
63
dnl If both are available, the build directory should be passed to
64
dnl the --with-apr-util switch.
66
dnl Note: the installation layout is presumed to follow the standard
67
dnl PREFIX/lib and PREFIX/include pattern. If the APU config file
68
dnl is available (and can be found), then non-standard layouts are
69
dnl possible, since it will be described in the config file.
71
dnl If a bundled source directory is available and needs to be (re)configured,
72
dnl then apu_found is set to "reconfig". The caller should reconfigure the
73
dnl (passed-in) source directory, placing the result in the build directory,
76
dnl If apu_found is "yes" or "reconfig", then the caller should use the
77
dnl value of apu_config to fetch any necessary build/link information.
80
AC_DEFUN([APR_FIND_APU], [
83
if test "$target_os" = "os2-emx"; then
84
# Scripts don't pass test -x on OS/2
92
ifdef(AC_WARNING,([$0: missing argument 4 (acceptable-majors): Defaulting to APU 0.x then APU 1.x]))
93
acceptable_majors="0 1"
94
], [acceptable_majors="$4"])
96
apu_temp_acceptable_apu_config=""
97
for apu_temp_major in $acceptable_majors
99
case $apu_temp_major in
101
apu_temp_acceptable_apu_config="$apu_temp_acceptable_apu_config apu-config"
104
apu_temp_acceptable_apu_config="$apu_temp_acceptable_apu_config apu-$apu_temp_major-config"
109
AC_MSG_CHECKING(for APR-util)
110
AC_ARG_WITH(apr-util,
111
[ --with-apr-util=PATH prefix for installed APU or the full path to
114
if test "$withval" = "no" || test "$withval" = "yes"; then
115
AC_MSG_ERROR([--with-apr-util requires a directory or file to be provided])
118
for apu_temp_apu_config_file in $apu_temp_acceptable_apu_config
120
for lookdir in "$withval/bin" "$withval"
122
if $TEST_X "$lookdir/$apu_temp_apu_config_file"; then
123
apu_config="$lookdir/$apu_temp_apu_config_file"
124
ifelse([$5], [], [], [
127
if test "$apu_acceptable" != "yes"; then
128
AC_MSG_WARN([Found APU in $apu_config, but it is considered unacceptable])
137
if test "$apu_found" != "yes" && $TEST_X "$withval" && $withval --help > /dev/null 2>&1 ; then
138
apu_config="$withval"
139
ifelse([$5], [], [apu_found="yes"], [
142
if test "$apu_acceptable" = "yes"; then
147
dnl if --with-apr-util is used, it is a fatal error for its argument
149
if test "$apu_found" != "yes"; then
150
AC_MSG_ERROR([the --with-apr-util parameter is incorrect. It must specify an install prefix, a build directory, or an apu-config file.])
153
if test -n "$3" && test "$3" = "1"; then
154
for apu_temp_apu_config_file in $apu_temp_acceptable_apu_config
156
if $apu_temp_apu_config_file --help > /dev/null 2>&1 ; then
157
apu_config="$apu_temp_apu_config_file"
158
ifelse([$5], [], [], [
161
if test "$apu_acceptable" != "yes"; then
162
AC_MSG_WARN([skipped APR-util at $apu_config, version not acceptable])
168
dnl look in some standard places (apparently not in builtin/default)
169
for lookdir in /usr /usr/local /usr/local/apr /opt/apr; do
170
if $TEST_X "$lookdir/bin/$apu_temp_apu_config_file"; then
171
apu_config="$lookdir/bin/$apu_temp_apu_config_file"
172
ifelse([$5], [], [], [
175
if test "$apu_acceptable" != "yes"; then
176
AC_MSG_WARN([skipped APR-util at $apu_config, version not acceptable])
186
dnl if we have not found anything yet and have bundled source, use that
187
if test "$apu_found" = "no" && test -d "$1"; then
188
apu_temp_abs_srcdir="`cd \"$1\" && pwd`"
190
apu_bundled_major="`sed -n '/#define.*APU_MAJOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p' \"$1/include/apu_version.h\"`"
191
case $apu_bundled_major in
193
AC_MSG_ERROR([failed to find major version of bundled APU])
196
apu_temp_apu_config_file="apu-config"
199
apu_temp_apu_config_file="apu-$apu_bundled_major-config"
202
if test -n "$2"; then
203
apu_config="$2/$apu_temp_apu_config_file"
205
apu_config="$1/$apu_temp_apu_config_file"
210
AC_MSG_RESULT($apu_found)