Fix memory leak when maintaining resources. When extra resources are
[apr-util.git] / configure.in
blob13868711209c18f30206122c5111d9210953293c
1 dnl
2 dnl Process this file with autoconf to produce a configure script
3 dnl
5 AC_PREREQ(2.13)
6 AC_INIT(export_vars.sh.in)
8 AC_CONFIG_HEADER(include/private/apu_config.h)
9 AC_CONFIG_AUX_DIR(build)
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/dbm.m4)
18 dnl Generate ./config.nice for reproducing runs of configure
19 dnl 
20 APR_CONFIG_NICE(config.nice)
22 dnl # Some initial steps for configuration.  We setup the default directory
23 dnl # and which files are to be configured.
25 dnl Absolute source/build directory
26 abs_srcdir=`(cd $srcdir && pwd)`
27 abs_builddir=`pwd`
29 if test "$abs_builddir" != "$abs_srcdir"; then
30   USE_VPATH=1
31   APU_CONFIG_LOCATION=build
32 else
33   APU_CONFIG_LOCATION=source
36 AC_SUBST(APU_CONFIG_LOCATION)
38 AC_CANONICAL_SYSTEM
40 AC_PROG_INSTALL
42 dnl
43 dnl compute the top directory of the build
44 dnl note: this is needed for LIBTOOL and exporting the bundled Expat
45 dnl
46 top_builddir="$abs_builddir"
47 AC_SUBST(top_builddir)
48 AC_SUBST(abs_srcdir)
49 AC_SUBST(abs_builddir)
51 dnl Initialize mkdir -p functionality.
52 APR_MKDIR_P_CHECK($abs_srcdir/build/mkdir.sh)
54 dnl get our version information
55 get_version="$abs_srcdir/build/get-version.sh"
56 version_hdr="$abs_srcdir/include/apu_version.h"
57 APRUTIL_MAJOR_VERSION="`$get_version major $version_hdr APU`"
58 APRUTIL_DOTTED_VERSION="`$get_version all $version_hdr APU`"
60 AC_SUBST(APRUTIL_DOTTED_VERSION)
61 AC_SUBST(APRUTIL_MAJOR_VERSION)
63 echo "APR-util Version: ${APRUTIL_DOTTED_VERSION}"
65 dnl Enable the layout handling code, then reparse the prefix-style
66 dnl arguments due to autoconf being a PITA.
67 APR_ENABLE_LAYOUT(apr-util)
68 APR_PARSE_ARGUMENTS
70 dnl load os-specific hints for apr-util
71 APU_PRELOAD
73 dnl
74 dnl set up the compilation flags and stuff
75 dnl
77 APRUTIL_INCLUDES=""
78 APRUTIL_PRIV_INCLUDES="-I$top_builddir/include -I$top_builddir/include/private"
79 if test -n "$USE_VPATH"; then
80     APRUTIL_PRIV_INCLUDES="$APRUTIL_PRIV_INCLUDES -I$abs_srcdir/include/private -I$abs_srcdir/include"
83 dnl
84 dnl Find the APR includes directory and (possibly) the source (base) dir.
85 dnl
86 APU_FIND_APR
88 dnl
89 dnl even though we use apr_rules.mk for building apr-util, we need
90 dnl to grab CC and CPP ahead of time so that apr-util config tests
91 dnl use the same compiler as APR; we need the same compiler options
92 dnl and feature test macros as well
93 dnl
94 APR_SETIFNULL(CC, `$apr_config --cc`)
95 APR_SETIFNULL(CPP, `$apr_config --cpp`)
96 APR_ADDTO(CFLAGS, `$apr_config --cflags`)
97 APR_ADDTO(CPPFLAGS, `$apr_config --cppflags`)
99 dnl Find LDAP library
100 dnl Determine what DBM backend type to use.
101 dnl Find Expat
102 dnl Find an iconv library
103 APU_FIND_LDAP
104 APU_CHECK_DBM
105 APU_FIND_EXPAT
106 APU_FIND_ICONV
108 AC_SEARCH_LIBS(crypt, crypt ufc)
109 AC_MSG_CHECKING(if system crypt() function is threadsafe)
110 if test "x$apu_crypt_threadsafe" = "x1"; then
111   AC_DEFINE(APU_CRYPT_THREADSAFE, 1, [Define if the system crypt() function is threadsafe])
112   msg="yes"
113 else
114   msg="no"
116 AC_MSG_RESULT([$msg])
118 AC_CHECK_FUNCS(crypt_r, [ crypt_r="1" ], [ crypt_r="0" ])
119 if test "$crypt_r" = "1"; then
120   APU_CHECK_CRYPT_R_STYLE
123 so_ext=$APR_SO_EXT
124 lib_target=$APR_LIB_TARGET
125 AC_SUBST(so_ext)
126 AC_SUBST(lib_target)
128 APRUTIL_LIBNAME="aprutil${libsuffix}"
129 AC_SUBST(APRUTIL_LIBNAME)
131 EXTRA_OS_LINK=""
132 host_alias=`uname -s`
133 case "$host_alias" in
134     dnl ### BeOS requires that ALL symbols resolve at LINK time!
135     dnl ### 
136     dnl ### So, if we're building on BeOS then we need to add in the
137     dnl ### apr and expat libraries to the build or it'll die a truly horrible
138     dnl ### death. We now use the apr-config tool to determine the correct
139     dnl ### library to link against :)
140 *AIX*|*Darwin*|*BeOS*)
141     dnl need such stuff as -liconv to be specified when building libaprutil.la
142     EXTRA_OS_LINK='$(APRUTIL_LDFLAGS) $(APRUTIL_LIBS)'
143     ;;
145     ;;
146 esac
148 AC_SUBST(EXTRA_OS_LINK)
151 dnl Prep all the flags and stuff for compilation and export to other builds
153 APR_ADDTO(APRUTIL_LIBS, [$APR_LIBS])
155 AC_SUBST(APRUTIL_EXPORT_LIBS)
156 AC_SUBST(APRUTIL_PRIV_INCLUDES)
157 AC_SUBST(APRUTIL_INCLUDES)
158 AC_SUBST(APRUTIL_LDFLAGS)
159 AC_SUBST(APRUTIL_LIBS)
160 AC_SUBST(LDFLAGS)
162 dnl copy apr's rules.mk into our build directory.
163 if test ! -d ./build; then
164    $mkdir_p build
166 cp $APR_BUILD_DIR/apr_rules.mk $abs_builddir/build/rules.mk
169 dnl BSD/OS (BSDi) needs to use a different include syntax in the Makefiles
171 case "$host_alias" in
172 *bsdi* | BSD/OS)
173     # Check whether they've installed GNU make
174     if make --version > /dev/null 2>&1; then
175         INCLUDE_RULES="include $abs_builddir/build/rules.mk"
176         INCLUDE_OUTPUTS="include $abs_srcdir/build-outputs.mk"
177     else
178         INCLUDE_RULES=".include \"$abs_builddir/build/rules.mk\""
179         INCLUDE_OUTPUTS=".include \"$abs_srcdir/build-outputs.mk\""
180     fi
181     ;;
183     INCLUDE_RULES="include $abs_builddir/build/rules.mk"
184     INCLUDE_OUTPUTS="include $abs_srcdir/build-outputs.mk"
185     ;;
186 esac
187 AC_SUBST(INCLUDE_RULES)
188 AC_SUBST(INCLUDE_OUTPUTS)
190 if test -d $srcdir/test; then
191     test_Makefile="test/Makefile"
194 if test ! -d "$top_builddir/include/private"; then
195     mkdir $top_builddir/include
196     mkdir $top_builddir/include/private
200 dnl everthing is done. 
201 MAKEFILES="Makefile $test_Makefile"
202 AC_OUTPUT([
203     export_vars.sh
204     apu-$APRUTIL_MAJOR_VERSION-config:apu-config.in
205     apr-util.pc
206     include/private/apu_select_dbm.h
207     include/apr_ldap.h
208     include/apu.h
209     include/apu_want.h
210     $MAKEFILES
211         ],[
212 chmod +x apu-$APRUTIL_MAJOR_VERSION-config
214 APRUTIL_MAJOR_VERSION=$APRUTIL_MAJOR_VERSION