1 | dnl |
---|
2 | dnl find_apu.m4 : locate the APR-util (APU) include files and libraries |
---|
3 | dnl |
---|
4 | dnl This macro file can be used by applications to find and use the APU |
---|
5 | dnl library. It provides a standardized mechanism for using APU. It supports |
---|
6 | dnl embedding APU into the application source, or locating an installed |
---|
7 | dnl copy of APU. |
---|
8 | dnl |
---|
9 | dnl APR_FIND_APU(srcdir, builddir, implicit-install-check, acceptable-majors) |
---|
10 | dnl |
---|
11 | dnl where srcdir is the location of the bundled APU source directory, or |
---|
12 | dnl empty if source is not bundled. |
---|
13 | dnl |
---|
14 | dnl where builddir is the location where the bundled APU will be built, |
---|
15 | dnl or empty if the build will occur in the srcdir. |
---|
16 | dnl |
---|
17 | dnl where implicit-install-check set to 1 indicates if there is no |
---|
18 | dnl --with-apr-util option specified, we will look for installed copies. |
---|
19 | dnl |
---|
20 | dnl where acceptable-majors is a space separated list of acceptable major |
---|
21 | dnl version numbers. Often only a single major version will be acceptable. |
---|
22 | dnl If multiple versions are specified, and --with-apr-util=PREFIX or the |
---|
23 | dnl implicit installed search are used, then the first (leftmost) version |
---|
24 | dnl in the list that is found will be used. Currently defaults to [0 1]. |
---|
25 | dnl |
---|
26 | dnl Sets the following variables on exit: |
---|
27 | dnl |
---|
28 | dnl apu_found : "yes", "no", "reconfig" |
---|
29 | dnl |
---|
30 | dnl apu_config : If the apu-config tool exists, this refers to it. If |
---|
31 | dnl apu_found is "reconfig", then the bundled directory |
---|
32 | dnl should be reconfigured *before* using apu_config. |
---|
33 | dnl |
---|
34 | dnl Note: this macro file assumes that apr-config has been installed; it |
---|
35 | dnl is normally considered a required part of an APR installation. |
---|
36 | dnl |
---|
37 | dnl Note: At this time, we cannot find *both* a source dir and a build dir. |
---|
38 | dnl If both are available, the build directory should be passed to |
---|
39 | dnl the --with-apr-util switch. |
---|
40 | dnl |
---|
41 | dnl Note: the installation layout is presumed to follow the standard |
---|
42 | dnl PREFIX/lib and PREFIX/include pattern. If the APU config file |
---|
43 | dnl is available (and can be found), then non-standard layouts are |
---|
44 | dnl possible, since it will be described in the config file. |
---|
45 | dnl |
---|
46 | dnl If a bundled source directory is available and needs to be (re)configured, |
---|
47 | dnl then apu_found is set to "reconfig". The caller should reconfigure the |
---|
48 | dnl (passed-in) source directory, placing the result in the build directory, |
---|
49 | dnl as appropriate. |
---|
50 | dnl |
---|
51 | dnl If apu_found is "yes" or "reconfig", then the caller should use the |
---|
52 | dnl value of apu_config to fetch any necessary build/link information. |
---|
53 | dnl |
---|
54 | |
---|
55 | AC_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 | ]) |
---|