]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/apr-util/configure.in
Move SYSCTL_ADD_PROC() to unlocked context in if_ure to avoid lock order reversal.
[FreeBSD/FreeBSD.git] / contrib / apr-util / configure.in
1 dnl
2 dnl Process this file with autoconf to produce a configure script
3 dnl
4
5 AC_PREREQ(2.59)
6 AC_INIT(export_vars.sh.in)
7
8 AC_CONFIG_HEADER(include/private/apu_config.h)
9 AC_CONFIG_AUX_DIR(build)
10
11 sinclude(build/apu-conf.m4)
12 sinclude(build/apu-iconv.m4)
13 sinclude(build/apu-hints.m4)
14 sinclude(build/apr_common.m4)
15 sinclude(build/find_apr.m4)
16 sinclude(build/crypto.m4)
17 sinclude(build/dbm.m4)
18 sinclude(build/dbd.m4)
19 sinclude(build/dso.m4)
20
21 dnl Generate ./config.nice for reproducing runs of configure
22 dnl 
23 APR_CONFIG_NICE(config.nice)
24
25 dnl # Some initial steps for configuration.  We setup the default directory
26 dnl # and which files are to be configured.
27
28 dnl Absolute source/build directory
29 abs_srcdir=`(cd $srcdir && pwd)`
30 abs_builddir=`pwd`
31
32 if test "$abs_builddir" != "$abs_srcdir"; then
33   USE_VPATH=1
34   APU_CONFIG_LOCATION=build
35 else
36   APU_CONFIG_LOCATION=source
37 fi
38
39 AC_SUBST(APU_CONFIG_LOCATION)
40
41 AC_CANONICAL_SYSTEM
42
43 AC_PROG_INSTALL
44
45 # Use -no-install or -no-fast-install to link the test 
46 # programs on all platforms but Darwin, where it would cause
47 # the programs to be linked against installed versions of
48 # libapr instead of those just built.
49 case $host in
50     *-apple-darwin*)
51         LT_NO_INSTALL=""
52         ;;
53     *-mingw*)
54         LT_NO_INSTALL="-no-fast-install"
55         ;;
56     *)
57         LT_NO_INSTALL="-no-install"
58         ;;
59 esac
60 AC_SUBST(LT_NO_INSTALL)
61
62 dnl
63 dnl compute the top directory of the build
64 dnl note: this is needed for LIBTOOL and exporting the bundled Expat
65 dnl
66 top_builddir="$abs_builddir"
67 AC_SUBST(top_builddir)
68 AC_SUBST(abs_srcdir)
69 AC_SUBST(abs_builddir)
70
71 dnl Initialize mkdir -p functionality.
72 APR_MKDIR_P_CHECK($abs_srcdir/build/mkdir.sh)
73
74 dnl get our version information
75 get_version="$abs_srcdir/build/get-version.sh"
76 version_hdr="$abs_srcdir/include/apu_version.h"
77 APRUTIL_MAJOR_VERSION="`$get_version major $version_hdr APU`"
78 APRUTIL_DOTTED_VERSION="`$get_version all $version_hdr APU`"
79
80 APU_LTVERSION="-version-info `$get_version libtool $version_hdr APU`"
81
82 AC_SUBST(APRUTIL_DOTTED_VERSION)
83 AC_SUBST(APRUTIL_MAJOR_VERSION)
84 AC_SUBST(APU_LTVERSION)
85
86 echo "APR-util Version: ${APRUTIL_DOTTED_VERSION}"
87
88 dnl Enable the layout handling code, then reparse the prefix-style
89 dnl arguments due to autoconf being a PITA.
90 APR_ENABLE_LAYOUT(apr-util)
91 APR_PARSE_ARGUMENTS
92
93 dnl load os-specific hints for apr-util
94 APU_PRELOAD
95
96 dnl
97 dnl set up the compilation flags and stuff
98 dnl
99
100 APRUTIL_INCLUDES=""
101 APRUTIL_PRIV_INCLUDES="-I$top_builddir/include -I$top_builddir/include/private"
102 if test -n "$USE_VPATH"; then
103     APRUTIL_PRIV_INCLUDES="$APRUTIL_PRIV_INCLUDES -I$abs_srcdir/include/private -I$abs_srcdir/include"
104 fi
105
106 dnl
107 dnl Find the APR includes directory and (possibly) the source (base) dir.
108 dnl
109 APU_FIND_APR
110
111 dnl
112 dnl even though we use apr_rules.mk for building apr-util, we need
113 dnl to grab CC and CPP ahead of time so that apr-util config tests
114 dnl use the same compiler as APR; we need the same compiler options
115 dnl and feature test macros as well
116 dnl
117 APR_SETIFNULL(CC, `$apr_config --cc`)
118 APR_SETIFNULL(CPP, `$apr_config --cpp`)
119 APR_ADDTO(CFLAGS, `$apr_config --cflags`)
120 APR_ADDTO(CPPFLAGS, `$apr_config --cppflags`)
121 apr_shlibpath_var=`$apr_config --shlib-path-var`
122 AC_SUBST(apr_shlibpath_var)
123
124 dnl
125 dnl  Find the APR-ICONV directory.
126 dnl
127 AC_ARG_WITH(apr-iconv,
128             [  --with-apr-iconv=DIR    relative path to apr-iconv source],
129   [ apu_apriconv_dir="$withval"
130     if test "$apu_apriconv_dir" != "no"; then
131       if test -d "$apu_apriconv_dir"; then
132         APR_SUBDIR_CONFIG("$apu_apriconv_dir",
133                           [$apache_apr_flags \
134                              --prefix=$prefix \
135                              --exec-prefix=$exec_prefix \
136                              --libdir=$libdir \
137                              --includedir=$includedir \
138                              --bindir=$bindir \
139                              --datadir=$datadir \
140                              --with-installbuilddir=$installbuilddir],
141                           [--enable-layout=*|\'--enable-layout=*])
142         APRUTIL_EXPORT_LIBS="$abs_srcdir/$apu_apriconv_dir/lib/libapriconv.la \
143                              $APRUTIL_EXPORT_LIBS"
144         APRUTIL_INCLUDES="-I$abs_srcdir/$apu_apriconv_dir/include \
145                           $APRUTIL_INCLUDES"
146         APR_ICONV_DIR="$apu_apriconv_dir"
147       else
148        APR_ICONV_DIR=""
149       fi
150     else
151       APR_ICONV_DIR=""
152     fi
153   ])
154 AC_SUBST(APR_ICONV_DIR)
155
156 dnl Find LDAP library
157 dnl Determine what DBM backend type to use.
158 dnl Find Expat
159 dnl Find an iconv library
160 APU_CHECK_CRYPTO
161 APU_FIND_LDAP
162 APU_CHECK_DBM
163 APU_CHECK_DBD
164 APU_CHECK_DBD_MYSQL
165 APU_CHECK_DBD_SQLITE3
166 APU_CHECK_DBD_SQLITE2
167 APU_CHECK_DBD_ORACLE
168 APU_CHECK_DBD_ODBC
169 APU_FIND_EXPAT
170 APU_FIND_ICONV
171
172 dnl Enable DSO build; must be last:
173 APU_CHECK_UTIL_DSO
174
175 AC_SEARCH_LIBS(crypt, crypt ufc)
176 AC_MSG_CHECKING(if system crypt() function is threadsafe)
177 if test "x$apu_crypt_threadsafe" = "x1"; then
178   AC_DEFINE(APU_CRYPT_THREADSAFE, 1, [Define if the system crypt() function is threadsafe])
179   msg="yes"
180 else
181   msg="no"
182 fi
183 AC_MSG_RESULT([$msg])
184
185 AC_CHECK_FUNCS(crypt_r, [ crypt_r="1" ], [ crypt_r="0" ])
186 if test "$crypt_r" = "1"; then
187   APU_CHECK_CRYPT_R_STYLE
188 fi
189
190 AC_CACHE_CHECK([whether the compiler handles weak symbols], [apu_cv_weak_symbols],
191 [AC_TRY_RUN([
192 __attribute__ ((weak))
193 int weak_noop(void)
194 {
195     return 0;
196 }
197 int main()
198 {
199     return weak_noop();
200 }], [apu_cv_weak_symbols=yes], [apu_cv_weak_symbols=no], [apu_cv_weak_symbols=no])])
201
202 if test "$apu_cv_weak_symbols" = "yes"; then
203     AC_DEFINE(HAVE_WEAK_SYMBOLS, 1, [Define if compiler handles weak symbols])
204 fi
205
206 AC_CACHE_CHECK([for memset_s support], [apu_cv_memset_s],
207 [AC_TRY_RUN([
208 #ifdef HAVE_STRING_H
209 #define __STDC_WANT_LIB_EXT1__ 1
210 #include <string.h>
211 #endif
212
213 int main(int argc, const char **argv)
214 {
215     char buf[1] = {1};
216     return memset_s(buf, sizeof buf, 0, sizeof buf) != 0 || *buf != '\0';
217 }], [apu_cv_memset_s=yes], [apu_cv_memset_s=no], [apu_cv_memset_s=no])])
218
219 if test "$apu_cv_memset_s" = "yes"; then
220    AC_DEFINE([HAVE_MEMSET_S], 1, [Define if memset_s function is supported])
221 fi
222
223 AC_CACHE_CHECK([for explicit_bzero support], [apu_cv_explicit_bzero],
224 [AC_TRY_RUN([
225 #ifdef HAVE_STRING_H
226 #include <string.h>
227 #endif
228 #ifdef HAVE_STRINGS_H
229 #include <strings.h>
230 #endif
231
232 int main(int argc, const char **argv)
233 {
234     char buf[1] = {1};
235     explicit_bzero(buf, sizeof buf);
236     return *buf != '\0';
237 }], [apu_cv_explicit_bzero=yes], [apu_cv_explicit_bzero=no], [apu_cv_explicit_bzero=no])])
238
239 if test "$apu_cv_explicit_bzero" = "yes"; then
240    AC_DEFINE([HAVE_EXPLICIT_BZERO], 1, [Define if explicit_bzero function is supported])
241 fi
242
243 so_ext=$APR_SO_EXT
244 lib_target=$APR_LIB_TARGET
245 AC_SUBST(so_ext)
246 AC_SUBST(lib_target)
247
248 APRUTIL_LIBNAME="aprutil${libsuffix}"
249 AC_SUBST(APRUTIL_LIBNAME)
250
251 # Set up destination directory for DSOs.
252 APU_DSO_LIBDIR="\${libdir}/apr-util-${APRUTIL_MAJOR_VERSION}"
253 # Set APU_HAVE_MODULES appropriately for the Makefile
254 if test -n "$APU_MODULES"; then 
255    APU_HAVE_MODULES=yes
256 else
257    APU_HAVE_MODULES=no
258 fi
259 # Define expanded libdir for apu_config.h
260 APR_EXPAND_VAR(abs_dso_libdir, $APU_DSO_LIBDIR)
261 AC_DEFINE_UNQUOTED([APU_DSO_LIBDIR], ["$abs_dso_libdir"],
262                    [Define to be absolute path to DSO directory])
263 AC_SUBST(APU_HAVE_MODULES)
264 AC_SUBST(APU_DSO_LIBDIR)
265 AC_SUBST(APU_MODULES)
266 AC_SUBST(EXTRA_OBJECTS)
267
268 dnl
269 dnl Prep all the flags and stuff for compilation and export to other builds
270 dnl
271 APR_ADDTO(APRUTIL_LIBS, [$APR_LIBS])
272
273 AC_SUBST(APRUTIL_EXPORT_LIBS)
274 AC_SUBST(APRUTIL_PRIV_INCLUDES)
275 AC_SUBST(APRUTIL_INCLUDES)
276 AC_SUBST(APRUTIL_LDFLAGS)
277 AC_SUBST(APRUTIL_LIBS)
278 AC_SUBST(LDFLAGS)
279
280 dnl copy apr's rules.mk into our build directory.
281 if test ! -d ./build; then
282    $mkdir_p build
283 fi
284 dnl
285 dnl MinGW: If APR is shared, APR_DECLARE_EXPORT will be defined in the
286 dnl        internal CPPFLAGS, but APR-Util needs APU_DECLARE_EXPORT instead.
287 dnl        If APR is static, APR_DECLARE_STATIC will be defined in the
288 dnl        internal CPPFLAGS, but APR-Util needs APU_DECLARE_STATIC too.
289 dnl
290 case $host in
291     *-mingw*)
292         sed -e 's/-DAPR_DECLARE_EXPORT/-DAPU_DECLARE_EXPORT/' \
293             -e 's/-DAPR_DECLARE_STATIC/-DAPU_DECLARE_STATIC -DAPR_DECLARE_STATIC/' \
294             < $APR_BUILD_DIR/apr_rules.mk > $abs_builddir/build/rules.mk
295         ;;
296     *)
297         cp $APR_BUILD_DIR/apr_rules.mk $abs_builddir/build/rules.mk
298         ;;
299 esac
300
301 dnl
302 dnl BSD/OS (BSDi) needs to use a different include syntax in the Makefiles
303 dnl
304 case "$host_alias" in
305 *bsdi* | BSD/OS)
306     # Check whether they've installed GNU make
307     if make --version > /dev/null 2>&1; then
308         INCLUDE_RULES="include $abs_builddir/build/rules.mk"
309         INCLUDE_OUTPUTS="include $abs_srcdir/build-outputs.mk"
310     else
311         INCLUDE_RULES=".include \"$abs_builddir/build/rules.mk\""
312         INCLUDE_OUTPUTS=".include \"$abs_srcdir/build-outputs.mk\""
313     fi
314     ;;
315 *)
316     INCLUDE_RULES="include $abs_builddir/build/rules.mk"
317     INCLUDE_OUTPUTS="include $abs_srcdir/build-outputs.mk"
318     ;;
319 esac
320 AC_SUBST(INCLUDE_RULES)
321 AC_SUBST(INCLUDE_OUTPUTS)
322
323 for d in include include/private; do
324     test -d $top_builddir/$d || mkdir $top_builddir/$d
325 done
326
327 AC_CONFIG_FILES([Makefile export_vars.sh
328                  build/pkg/pkginfo apr-util.pc
329                  apu-$APRUTIL_MAJOR_VERSION-config:apu-config.in
330                  include/private/apu_select_dbm.h
331                  include/apr_ldap.h
332                  include/apu.h include/apu_want.h])
333
334 AC_CONFIG_COMMANDS([default], [
335 chmod +x apu-$APRUTIL_MAJOR_VERSION-config
336 ],[
337 APRUTIL_MAJOR_VERSION=$APRUTIL_MAJOR_VERSION
338 ])
339
340 if test -d $srcdir/test; then
341     AC_CONFIG_FILES([test/Makefile])
342 fi
343
344 AC_OUTPUT