1dnl
2dnl Process this file with autoconf to produce a configure script
3dnl
4
5AC_PREREQ(2.59)
6AC_INIT(export_vars.sh.in)
7
8AC_CONFIG_HEADER(include/private/apu_config.h)
9AC_CONFIG_AUX_DIR(build)
10
11sinclude(build/apu-conf.m4)
12sinclude(build/apu-iconv.m4)
13sinclude(build/apu-hints.m4)
14sinclude(build/apr_common.m4)
15sinclude(build/find_apr.m4)
16sinclude(build/crypto.m4)
17sinclude(build/dbm.m4)
18sinclude(build/dbd.m4)
19sinclude(build/dso.m4)
20
21dnl Generate ./config.nice for reproducing runs of configure
22dnl 
23APR_CONFIG_NICE(config.nice)
24
25dnl # Some initial steps for configuration.  We setup the default directory
26dnl # and which files are to be configured.
27
28dnl Absolute source/build directory
29abs_srcdir=`(cd $srcdir && pwd)`
30abs_builddir=`pwd`
31
32if test "$abs_builddir" != "$abs_srcdir"; then
33  USE_VPATH=1
34  APU_CONFIG_LOCATION=build
35else
36  APU_CONFIG_LOCATION=source
37fi
38
39AC_SUBST(APU_CONFIG_LOCATION)
40
41AC_CANONICAL_SYSTEM
42
43AC_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.
49case $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        ;;
59esac
60AC_SUBST(LT_NO_INSTALL)
61
62dnl
63dnl compute the top directory of the build
64dnl note: this is needed for LIBTOOL and exporting the bundled Expat
65dnl
66top_builddir="$abs_builddir"
67AC_SUBST(top_builddir)
68AC_SUBST(abs_srcdir)
69AC_SUBST(abs_builddir)
70
71dnl Initialize mkdir -p functionality.
72APR_MKDIR_P_CHECK($abs_srcdir/build/mkdir.sh)
73
74dnl get our version information
75get_version="$abs_srcdir/build/get-version.sh"
76version_hdr="$abs_srcdir/include/apu_version.h"
77APRUTIL_MAJOR_VERSION="`$get_version major $version_hdr APU`"
78APRUTIL_DOTTED_VERSION="`$get_version all $version_hdr APU`"
79
80APU_LTVERSION="-version-info `$get_version libtool $version_hdr APU`"
81
82AC_SUBST(APRUTIL_DOTTED_VERSION)
83AC_SUBST(APRUTIL_MAJOR_VERSION)
84AC_SUBST(APU_LTVERSION)
85
86echo "APR-util Version: ${APRUTIL_DOTTED_VERSION}"
87
88dnl Enable the layout handling code, then reparse the prefix-style
89dnl arguments due to autoconf being a PITA.
90APR_ENABLE_LAYOUT(apr-util)
91APR_PARSE_ARGUMENTS
92
93dnl load os-specific hints for apr-util
94APU_PRELOAD
95
96dnl
97dnl set up the compilation flags and stuff
98dnl
99
100APRUTIL_INCLUDES=""
101APRUTIL_PRIV_INCLUDES="-I$top_builddir/include -I$top_builddir/include/private"
102if test -n "$USE_VPATH"; then
103    APRUTIL_PRIV_INCLUDES="$APRUTIL_PRIV_INCLUDES -I$abs_srcdir/include/private -I$abs_srcdir/include"
104fi
105
106dnl
107dnl Find the APR includes directory and (possibly) the source (base) dir.
108dnl
109APU_FIND_APR
110
111dnl
112dnl even though we use apr_rules.mk for building apr-util, we need
113dnl to grab CC and CPP ahead of time so that apr-util config tests
114dnl use the same compiler as APR; we need the same compiler options
115dnl and feature test macros as well
116dnl
117APR_SETIFNULL(CC, `$apr_config --cc`)
118APR_SETIFNULL(CPP, `$apr_config --cpp`)
119APR_ADDTO(CFLAGS, `$apr_config --cflags`)
120APR_ADDTO(CPPFLAGS, `$apr_config --cppflags`)
121apr_shlibpath_var=`$apr_config --shlib-path-var`
122AC_SUBST(apr_shlibpath_var)
123
124dnl
125dnl  Find the APR-ICONV directory.
126dnl
127AC_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  ])
154AC_SUBST(APR_ICONV_DIR)
155
156dnl Find LDAP library
157dnl Determine what DBM backend type to use.
158dnl Find Expat
159dnl Find an iconv library
160APU_CHECK_CRYPTO
161APU_FIND_LDAP
162APU_CHECK_DBM
163APU_CHECK_DBD
164APU_CHECK_DBD_MYSQL
165APU_CHECK_DBD_SQLITE3
166APU_CHECK_DBD_SQLITE2
167APU_CHECK_DBD_ORACLE
168APU_CHECK_DBD_FREETDS
169APU_CHECK_DBD_ODBC
170APU_FIND_EXPAT
171APU_FIND_ICONV
172
173dnl Enable DSO build; must be last:
174APU_CHECK_UTIL_DSO
175
176AC_SEARCH_LIBS(crypt, crypt ufc)
177AC_MSG_CHECKING(if system crypt() function is threadsafe)
178if test "x$apu_crypt_threadsafe" = "x1"; then
179  AC_DEFINE(APU_CRYPT_THREADSAFE, 1, [Define if the system crypt() function is threadsafe])
180  msg="yes"
181else
182  msg="no"
183fi
184AC_MSG_RESULT([$msg])
185
186AC_CHECK_FUNCS(crypt_r, [ crypt_r="1" ], [ crypt_r="0" ])
187if test "$crypt_r" = "1"; then
188  APU_CHECK_CRYPT_R_STYLE
189fi
190
191so_ext=$APR_SO_EXT
192lib_target=$APR_LIB_TARGET
193AC_SUBST(so_ext)
194AC_SUBST(lib_target)
195
196APRUTIL_LIBNAME="aprutil${libsuffix}"
197AC_SUBST(APRUTIL_LIBNAME)
198
199# Set up destination directory for DSOs.
200APU_DSO_LIBDIR="\${libdir}/apr-util-${APRUTIL_MAJOR_VERSION}"
201# Set APU_HAVE_MODULES appropriately for the Makefile
202if test -n "$APU_MODULES"; then 
203   APU_HAVE_MODULES=yes
204else
205   APU_HAVE_MODULES=no
206fi
207# Define expanded libdir for apu_config.h
208APR_EXPAND_VAR(abs_dso_libdir, $APU_DSO_LIBDIR)
209AC_DEFINE_UNQUOTED([APU_DSO_LIBDIR], ["$abs_dso_libdir"],
210                   [Define to be absolute path to DSO directory])
211AC_SUBST(APU_HAVE_MODULES)
212AC_SUBST(APU_DSO_LIBDIR)
213AC_SUBST(APU_MODULES)
214AC_SUBST(EXTRA_OBJECTS)
215
216dnl
217dnl Prep all the flags and stuff for compilation and export to other builds
218dnl
219APR_ADDTO(APRUTIL_LIBS, [$APR_LIBS])
220
221AC_SUBST(APRUTIL_EXPORT_LIBS)
222AC_SUBST(APRUTIL_PRIV_INCLUDES)
223AC_SUBST(APRUTIL_INCLUDES)
224AC_SUBST(APRUTIL_LDFLAGS)
225AC_SUBST(APRUTIL_LIBS)
226AC_SUBST(LDFLAGS)
227
228dnl copy apr's rules.mk into our build directory.
229if test ! -d ./build; then
230   $mkdir_p build
231fi
232dnl
233dnl MinGW: If APR is shared, APR_DECLARE_EXPORT will be defined in the
234dnl        internal CPPFLAGS, but APR-Util needs APU_DECLARE_EXPORT instead.
235dnl        If APR is static, APR_DECLARE_STATIC will be defined in the
236dnl        internal CPPFLAGS, but APR-Util needs APU_DECLARE_STATIC too.
237dnl
238case $host in
239    *-mingw*)
240        sed -e 's/-DAPR_DECLARE_EXPORT/-DAPU_DECLARE_EXPORT/' \
241            -e 's/-DAPR_DECLARE_STATIC/-DAPU_DECLARE_STATIC -DAPR_DECLARE_STATIC/' \
242            < $APR_BUILD_DIR/apr_rules.mk > $abs_builddir/build/rules.mk
243        ;;
244    *)
245        cp $APR_BUILD_DIR/apr_rules.mk $abs_builddir/build/rules.mk
246        ;;
247esac
248
249dnl
250dnl BSD/OS (BSDi) needs to use a different include syntax in the Makefiles
251dnl
252case "$host_alias" in
253*bsdi* | BSD/OS)
254    # Check whether they've installed GNU make
255    if make --version > /dev/null 2>&1; then
256        INCLUDE_RULES="include $abs_builddir/build/rules.mk"
257        INCLUDE_OUTPUTS="include $abs_srcdir/build-outputs.mk"
258    else
259        INCLUDE_RULES=".include \"$abs_builddir/build/rules.mk\""
260        INCLUDE_OUTPUTS=".include \"$abs_srcdir/build-outputs.mk\""
261    fi
262    ;;
263*)
264    INCLUDE_RULES="include $abs_builddir/build/rules.mk"
265    INCLUDE_OUTPUTS="include $abs_srcdir/build-outputs.mk"
266    ;;
267esac
268AC_SUBST(INCLUDE_RULES)
269AC_SUBST(INCLUDE_OUTPUTS)
270
271for d in include include/private; do
272    test -d $top_builddir/$d || mkdir $top_builddir/$d
273done
274
275AC_CONFIG_FILES([Makefile export_vars.sh
276                 build/pkg/pkginfo apr-util.pc
277                 apu-$APRUTIL_MAJOR_VERSION-config:apu-config.in
278                 include/private/apu_select_dbm.h
279                 include/apr_ldap.h
280                 include/apu.h include/apu_want.h])
281
282AC_CONFIG_COMMANDS([default], [
283chmod +x apu-$APRUTIL_MAJOR_VERSION-config
284],[
285APRUTIL_MAJOR_VERSION=$APRUTIL_MAJOR_VERSION
286])
287
288if test -d $srcdir/test; then
289    AC_CONFIG_FILES([test/Makefile])
290fi
291
292AC_OUTPUT
293