bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / srclib / apr / configure.in
1 dnl 
2 dnl Autoconf configuration file for APR
3 dnl 
4 dnl Process this file with autoconf to produce a configure script.
5 dnl Use ./buildconf to prepare build files and run autoconf for APR.
6
7 AC_INIT(build/apr_common.m4)
8 AC_CONFIG_HEADER(include/arch/unix/apr_private.h)
9 AC_CONFIG_AUX_DIR(build)
10
11 dnl 
12 dnl Include our own M4 macros along with those for libtool
13 dnl 
14 sinclude(build/apr_common.m4)
15 sinclude(build/apr_network.m4)
16 sinclude(build/apr_threads.m4)
17 sinclude(build/apr_hints.m4)
18 sinclude(build/libtool.m4)
19
20 dnl Save user-defined environment settings for later restoration
21 dnl
22 APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
23 APR_SAVE_THE_ENVIRONMENT(CFLAGS)
24 APR_SAVE_THE_ENVIRONMENT(LDFLAGS)
25 APR_SAVE_THE_ENVIRONMENT(LIBS)
26 APR_SAVE_THE_ENVIRONMENT(INCLUDES)
27
28 dnl Generate ./config.nice for reproducing runs of configure
29 dnl
30 APR_CONFIG_NICE(config.nice)
31
32 AC_CANONICAL_SYSTEM
33 echo "Configuring APR library"
34 echo "Platform: $host"
35
36 dnl Some initial steps for configuration.  We setup the default directory
37 dnl and which files are to be configured.
38
39 dnl Setup the directory macros now
40
41 # Absolute source/build directory
42 apr_srcdir=`(cd $srcdir && pwd)`
43 apr_builddir=`pwd`
44 AC_SUBST(apr_srcdir)
45 AC_SUBST(apr_builddir)
46
47 if test "$apr_builddir" != "$apr_srcdir"; then
48   USE_VPATH=1
49   APR_CONFIG_LOCATION=build
50 else
51   APR_CONFIG_LOCATION=source
52 fi
53
54 AC_SUBST(APR_CONFIG_LOCATION)
55
56 # Libtool might need this symbol -- it must point to the location of
57 # the generated libtool script (not necessarily the "top" build dir).
58 #
59 top_builddir="$apr_builddir"
60 AC_SUBST(top_builddir)
61
62 # Directory containing apr build macros, helpers, and make rules
63 # NOTE: make rules (apr_rules.mk) will be in the builddir for vpath
64 #
65 apr_buildout=$apr_builddir/build
66 apr_builders=$apr_srcdir/build
67 AC_SUBST(apr_builders)
68
69 MKDIR=$apr_builders/mkdir.sh
70
71 dnl Initialize mkdir -p functionality.
72 APR_MKDIR_P_CHECK($apr_builders/mkdir.sh)
73
74 # get our version information
75 get_version="$apr_builders/get-version.sh"
76 version_hdr="$apr_srcdir/include/apr_version.h"
77 APR_MAJOR_VERSION="`$get_version major $version_hdr APR`"
78 APR_DOTTED_VERSION="`$get_version all $version_hdr APR`"
79
80 AC_SUBST(APR_DOTTED_VERSION)
81 AC_SUBST(APR_MAJOR_VERSION)
82
83 echo "APR Version: ${APR_DOTTED_VERSION}"
84
85 dnl Enable the layout handling code, then reparse the prefix-style
86 dnl arguments due to autoconf being a PITA.
87 APR_ENABLE_LAYOUT(apr)
88 APR_PARSE_ARGUMENTS
89
90 dnl Set optional CC hints here in case autoconf makes an inappropriate choice.
91 dnl This allows us to suggest what the compiler should be, but still
92 dnl allows the user to override CC externally.
93 APR_CC_HINTS
94
95 dnl Do the various CC checks *before* preloading values. The preload code
96 dnl may need to use compiler characteristics to make decisions. This macro
97 dnl can only be used once within a configure script, so this prevents a
98 dnl preload section from invoking the macro to get compiler info.
99 AC_PROG_CC
100
101 dnl Preload
102 APR_PRELOAD
103
104 dnl These added to allow default directories to be used...
105 DEFAULT_OSDIR="unix"
106 echo "(Default will be ${DEFAULT_OSDIR})"
107
108 apr_modules="file_io network_io threadproc misc locks time mmap shmem user memory atomic poll support"
109
110 dnl Checks for programs.
111 AC_PROG_MAKE_SET
112 AC_PROG_CPP
113 AC_PROG_AWK
114 AC_PROG_LN_S
115 AC_PROG_RANLIB
116 AC_PROG_INSTALL
117 AC_CHECK_PROG(RM, rm, rm)
118 AC_CHECK_PROG(AS, as, as)
119 AC_CHECK_PROG(ASCPP, cpp, cpp)
120 AC_CHECK_TOOL(AR, ar, ar)
121
122 dnl Various OS checks that apparently set required flags
123 ifdef([AC_USE_SYSTEM_EXTENSIONS], [
124 AC_USE_SYSTEM_EXTENSIONS
125 ], [
126 AC_AIX
127 AC_MINIX
128 ])
129
130 AC_ISC_POSIX
131 APR_EBCDIC
132
133 dnl this is our library name
134 APR_LIBNAME="apr${libsuffix}"
135 AC_SUBST(APR_LIBNAME)
136
137 dnl prep libtool
138 dnl
139 echo "performing libtool configuration..."
140
141 AC_ARG_ENABLE(experimental-libtool,[  --experimental-libtool Use experimental custom libtool (not included in source distribution)],
142   [experimental_libtool=$enableval],[experimental_libtool=no])
143
144 case $host in
145 *os2*)
146     # Use a custom-made libtool replacement
147     echo "using aplibtool"
148     LIBTOOL="$srcdir/build/aplibtool"
149     gcc $CFLAGS $CPPFLAGS -o $LIBTOOL.exe $LIBTOOL.c
150     ;;
151 *)
152     if test "x$LTFLAGS" = "x"; then
153         LTFLAGS='--silent'
154     fi
155     if test "$experimental_libtool" = "yes"; then
156         # Use a custom-made libtool replacement
157         echo "using jlibtool"
158         LIBTOOL="$apr_builddir/libtool"
159         LIBTOOL_SRC="$apr_srcdir/build/jlibtool.c"
160         if test ! -f $LIBTOOL_SRC; then
161           AC_MSG_ERROR([Experimental libtool source not found.  It is not included with APR by default.])
162         fi
163         $CC $CFLAGS $CPPFLAGS -o $LIBTOOL $LIBTOOL_SRC
164     else
165     dnl libtoolize requires that the following not be indented
166 AC_PROG_LIBTOOL
167         # get libtool's setting of shlibpath_var
168         eval `grep "^shlibpath_var=[[A-Z_]]*$" $apr_builddir/libtool`
169         if test "x$shlibpath_var" = "x"; then
170             shlibpath_var=REPLACE_WITH_YOUR_SHLIBPATH_VAR
171         fi
172     fi
173     ;;
174 esac
175
176 AC_ARG_WITH(installbuilddir, [  --with-installbuilddir=DIR location to store APR build files (defaults to '${datadir}/build')],
177   [ installbuilddir=$withval ], [ installbuilddir="${datadir}/build" ] )
178 AC_SUBST(installbuilddir)
179
180 AC_ARG_WITH(libtool, [  --without-libtool       avoid using libtool to link the library],
181   [ use_libtool=$withval ], [ use_libtool="yes" ] )
182
183 if test "x$use_libtool" = "xyes"; then
184       lt_compile='$(LIBTOOL) $(LTFLAGS) --mode=compile $(COMPILE) -c $< && touch $@'
185       LT_VERSION="-version-info `$get_version libtool $version_hdr APR`"
186       link="\$(LIBTOOL) \$(LTFLAGS) --mode=link \$(LT_LDFLAGS) \$(COMPILE) ${LT_VERSION} \$(ALL_LDFLAGS) -o \$@"
187       so_ext='lo'
188       lib_target='-rpath $(libdir) $$objects'
189       export_lib_target='-rpath \$(libdir) \$\$objects'
190 else
191       lt_compile='$(COMPILE) -c $<'
192       link='$(AR) cr $(TARGET_LIB) $$objects; $(RANLIB) $(TARGET_LIB)'
193       so_ext='o'
194       lib_target=''
195       export_lib_target=''
196 fi
197
198 case $host in
199     *-solaris2*)
200         apr_platform_runtime_link_flag="-R"
201         ;;
202     *)
203         ;;
204 esac
205
206 AC_SUBST(lt_compile)
207 AC_SUBST(link)
208 AC_SUBST(so_ext)
209 AC_SUBST(lib_target)
210 AC_SUBST(export_lib_target)
211 AC_SUBST(shlibpath_var)
212 AC_SUBST(LTFLAGS)
213 AC_SUBST(LT_LDFLAGS)
214
215 dnl ----------------------------- Checks for compiler flags
216 nl='
217 '
218 echo "${nl}Check for compiler flags..."
219
220 dnl AC_PROG_CC sets -g in CFLAGS (and -O2 for gcc) by default.
221 dnl On OS/390 this causes the compiler to insert extra debugger
222 dnl hook instructions.  That's fine for debug/maintainer builds, not fine
223 dnl otherwise.
224
225 case $host in
226     *os390)
227         if test "$ac_test_CFLAGS" != set; then
228            APR_REMOVEFROM(CFLAGS,-g)
229         fi
230         ;;
231 esac
232
233 AC_ARG_ENABLE(debug,[  --enable-debug          Turn on debugging and compile time warnings],
234   [APR_ADDTO(CFLAGS,-g)
235    if test "$GCC" = "yes"; then
236      APR_ADDTO(CFLAGS,-Wall)
237    elif test "$AIX_XLC" = "yes"; then
238      APR_ADDTO(CFLAGS,-qfullpath)
239    fi
240 ])dnl
241
242 AC_ARG_ENABLE(maintainer-mode,[  --enable-maintainer-mode  Turn on debugging and compile time warnings],
243   [APR_ADDTO(CFLAGS,-g)
244    if test "$GCC" = "yes"; then
245      APR_ADDTO(CFLAGS,[-Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations])
246    elif test "$AIX_XLC" = "yes"; then
247      APR_ADDTO(CFLAGS,-qfullpath -qinitauto=FE -qcheck=all -qinfo=pro)
248    fi
249 ])dnl
250
251 AC_ARG_ENABLE(profile,[  --enable-profile        Turn on profiling for the build (GCC)],
252   if test "$GCC" = "yes"; then
253     APR_ADDTO(CFLAGS, -pg)
254     APR_REMOVEFROM(CFLAGS, -g)
255     if test "$host" = "i586-pc-beos"; then
256         APR_REMOVEFROM(CFLAGS, -O2)
257         APR_ADDTO(CFLAGS, -O1)
258         APR_ADDTO(LDFLAGS, -p)
259     fi
260   fi
261 )dnl
262
263 AC_ARG_ENABLE(pool-debug,
264   [  --enable-pool-debug[[=yes|no|verbose|verbose-alloc|lifetime|owner|all]]    Turn on pools debugging],
265   [ if test -z "$enableval"; then
266         APR_ADDTO(CPPFLAGS, -DAPR_POOL_DEBUG=1)
267     elif test ! "$enableval" = "no"; then
268         apr_pool_debug=1
269     
270         for i in $enableval
271         do
272             flag=0
273         
274             case $i in
275             yes)
276                 flag=1
277                 ;;
278             verbose)
279                 flag=2
280                 ;;
281             lifetime)
282                 flag=4
283                 ;;
284             owner)
285                 flag=8
286                 ;;
287             verbose-alloc)
288                 flag=16
289                 ;;
290             all)
291                 apr_pool_debug=31
292                 ;;
293             *)
294                 ;;
295             esac
296
297             if test $flag -gt 0; then
298                 apr_pool_debug=`expr '(' $apr_pool_debug - $apr_pool_debug % \
299                     '(' $flag '*' 2 ')' ')' + $flag + $apr_pool_debug % $flag`
300             fi
301         done
302       
303         APR_ADDTO(CPPFLAGS, -DAPR_POOL_DEBUG=$apr_pool_debug)
304     fi
305   ])
306
307 dnl Electric Fence malloc checker.
308 dnl --with-efence specifies the path to Electric Fence
309 AC_ARG_WITH(efence, 
310   [  --with-efence[[=DIR]]     path to Electric Fence installation], 
311   [ apr_efence_dir="$withval"
312     if test "$apr_efence_dir" != "yes"; then
313       APR_ADDTO(LDFLAGS,[-L$apr_efence_dir/lib])
314       if test "x$apr_platform_runtime_link_flag" != "x"; then
315           APR_ADDTO(LDFLAGS, 
316                     [$apr_platform_runtime_link_flag$apr_efence_dir/lib])
317       fi
318     fi
319     AC_CHECK_LIB(efence, malloc, 
320                  [ APR_ADDTO(LIBS,-lefence) ],
321                  [ AC_MSG_ERROR(Electric Fence requested but not detected) ])
322   ])
323
324 if test "$host" = "i586-pc-beos"; then
325   AC_ARG_ENABLE(malloc-debug,[  --enable-malloc-debug   Switch on malloc_debug for BeOS],
326     APR_REMOVEFROM(CFLAGS, -O2)
327     APR_ADDTO(CPPFLAGS, -fcheck-memory-usage -D_KERNEL_MODE)
328   ) dnl
329 fi
330
331 # this is the place to put specific options for platform/compiler
332 # combinations
333 case "$host:$CC" in
334     *-hp-hpux*:cc )
335         APR_ADDTO(CFLAGS,[-Ae +Z])
336         case $host in
337           ia64-* )
338             ;;
339           * )
340             if echo "$CFLAGS " | grep '+DA' >/dev/null; then :
341             else
342               APR_ADDTO(CFLAGS,[+DAportable])
343             fi 
344             ;;
345         esac
346         ;;
347     powerpc-*-beos:mwcc* )
348         APR_SETVAR(CPP,[mwcc -E])
349         APR_SETVAR(CC,mwcc)
350         APR_SETVAR(AR,ar)
351         ;;
352 esac
353
354 dnl Check the depend program we can use
355 APR_CHECK_DEPEND
356
357 # force_atomic_generic flag 
358 # this will be set we find a cpu/OS combo
359 # which is historical and doesn't work with the method
360 # we are using for the more up to date cpu/OS
361 # (ie.. old sparcs)
362 apr_force_atomic_generic=0
363 proc_mutex_is_global=0
364 nonportable_atomics_enabled=0
365
366 AC_ARG_ENABLE(nonportable-atomics,
367 [  --enable-nonportable-atomics  Turn on optimized atomic code which may produce nonportable binaries],
368 [
369     if test "$enableval" = "yes"; then
370         nonportable_atomics_enabled=1
371     fi
372 ])
373
374 config_subdirs="none"
375 INSTALL_SUBDIRS="none"
376 case $host in
377    i386-ibm-aix* | *-ibm-aix[[1-2]].* | *-ibm-aix3.* | *-ibm-aix4.1 | *-ibm-aix4.1.* | *-ibm-aix4.2 | *-ibm-aix4.2.*)
378        OSDIR="aix"
379        APR_ADDTO(LDFLAGS,-lld)
380        eolstr="\\n"
381        ;;
382    *-os2*)
383        APR_ADDTO(CPPFLAGS,-DOS2)
384        APR_ADDTO(CFLAGS,-Zmt)
385        AC_CHECK_LIB(bsd, random)
386        OSDIR="os2"
387        enable_threads="system_threads"
388        eolstr="\\r\\n"
389        file_as_socket="0"
390        proc_mutex_is_global=1
391        ;;
392    *beos*)
393        OSDIR="beos"
394        APR_ADDTO(CPPFLAGS,-DBEOS)
395        enable_threads="system_threads"
396        native_mmap_emul="1"
397        APR_CHECK_DEFINE(BONE_VERSION, sys/socket.h)
398        eolstr="\\n"
399        osver=`uname -r`
400        proc_mutex_is_global=1
401        case $osver in
402           5.0.4)
403              file_as_socket="1"
404              ;;
405           *)
406              file_as_socket="0"
407              ;;
408        esac
409        ;;
410    *os390)
411        OSDIR="os390"
412        eolstr="\\n"
413        ;;
414    *os400)
415        OSDIR="as400"
416        eolstr="\\n"
417        ;;
418    *cygwin*)
419        OSDIR="unix"
420        APR_ADDTO(CPPFLAGS,-DCYGWIN)
421        enable_threads="no"
422        eolstr="\\n"
423        ;;
424    *linux*)
425        apr_force_atomic_generic=1
426        case $host_cpu in
427          i486|i586|i686)
428             if test "$nonportable_atomics_enabled" = 1; then
429               apr_force_atomic_generic=0
430             fi
431             ;;
432        esac
433        OSDIR="unix"
434        eolstr="\\n"
435        ;;
436    *hpux10* ) 
437        enable_threads="no"
438        OSDIR="unix"
439        eolstr="\\n"
440        ;;
441    *)
442        OSDIR="unix"
443        eolstr="\\n"
444        ;;
445 esac
446
447 AC_SUBST(apr_force_atomic_generic)
448 AC_SUBST(proc_mutex_is_global)
449 AC_SUBST(eolstr)
450 AC_SUBST(INSTALL_SUBDIRS)
451
452 # For some platforms we need a version string which allows easy numeric
453 # comparisons.
454 case $host in
455     *freebsd*)
456         if test -x /sbin/sysctl; then
457             os_version=`/sbin/sysctl -n kern.osreldate`
458         else
459             os_version=000000
460         fi
461         ;;
462     *linux*)
463         os_version=`uname -r | sed -e 's/\(.\)\.\(.\)\.\(.\).*/\1\2\3/'`
464         ;;
465     *darwin*)
466         os_version=`uname -r | sed -e 's/\(.\)\.\(.\).*/\1\2/'`
467         ;;
468     *)
469         os_version=OS_VERSION_IS_NOT_SET
470         ;;
471 esac
472
473 dnl ----------------------------- Checks for Any required Libraries
474 dnl Note: Autoconf will always append LIBS with an extra " " in AC_CHECK_LIB.
475 dnl It should check for LIBS being empty and set LIBS equal to the new value 
476 dnl without the extra " " in that case, but they didn't do that.  So, we
477 dnl end up LIBS="-lm -lcrypt -lnsl  -ldl" which is an annoyance.
478 AC_CHECK_LIB(resolv, res_init)
479 AC_CHECK_LIB(nsl, gethostbyname)
480 AC_SEARCH_LIBS(gethostname, nsl)
481 AC_CHECK_LIB(socket, socket)
482 AC_SEARCH_LIBS(crypt, crypt ufc)
483 AC_CHECK_LIB(truerand, main)
484 AC_SEARCH_LIBS(modf, m)
485 AC_SEARCH_LIBS(sqrt, m)
486
487 dnl ----------------------------- Checking for Threads
488 echo "${nl}Checking for Threads..."
489
490 if test -z "$enable_threads"; then
491         AC_ARG_ENABLE(threads,
492         [  --enable-threads        Enable threading support in APR.],
493         [ enable_threads=$enableval] ,
494         [ APR_CHECK_PTHREADS_H([ enable_threads="pthread" ] ,
495                                [ enable_threads="no" ] ) ] )
496 fi
497
498 if test "$enable_threads" = "no"; then
499     threads="0"
500     pthreadh="0"
501     pthreadser="0"
502 else
503     if test "$enable_threads" = "pthread"; then
504 # We have specified pthreads for our threading library, just make sure
505 # that we have everything we need
506       APR_PTHREADS_CHECK_SAVE
507       APR_PTHREADS_CHECK
508       APR_CHECK_PTHREADS_H([
509           threads="1"
510           pthreadh="1"
511           pthreadser="1"
512           AC_DEFINE(USE_THREADS, 1, [Define if APR supports threads]) ], [
513           threads="0"
514           pthreadh="0"
515           pthreadser="0"
516           APR_PTHREADS_CHECK_RESTORE ] )
517     elif test "$enable_threads" = "system_threads"; then
518         threads="1"
519         pthreadh="0"
520         pthreadser="0"
521     else
522 # We basically specified that we wanted threads, but not how to implement
523 # them.  In this case, just look for pthreads.  In the future, we can check
524 # for other threading libraries as well.
525       APR_PTHREADS_CHECK_SAVE
526       APR_PTHREADS_CHECK
527       APR_CHECK_PTHREADS_H([
528           threads="1"
529           pthreadh="1"
530           pthreadser="1"
531           AC_DEFINE(USE_THREADS) ], [
532           threads="0"
533           pthreadser="0"
534           pthreadh="0"
535           APR_PTHREADS_CHECK_RESTORE ] )
536     fi
537     if test "$pthreadh" = "1"; then
538         APR_CHECK_PTHREAD_GETSPECIFIC_TWO_ARGS
539         APR_CHECK_PTHREAD_ATTR_GETDETACHSTATE_ONE_ARG
540         AC_CHECK_FUNCS(pthread_key_delete pthread_rwlock_init)
541
542         if test "$ac_cv_func_pthread_rwlock_init" = "yes"; then
543             dnl ----------------------------- Checking for pthread_rwlock_t
544             AC_CACHE_CHECK([for pthread_rwlock_t], [apr_cv_type_rwlock_t],
545             AC_TRY_COMPILE([#include <sys/types.h>
546 #include <pthread.h>], [pthread_rwlock_t *rwlock;],
547               [apr_cv_type_rwlock_t=yes], [apr_cv_type_rwlock_t=no], 
548               [apr_cv_type_rwlock_t=no]))
549             if test "$apr_cv_type_rwlock_t" = "yes"; then
550                AC_DEFINE(HAVE_PTHREAD_RWLOCKS, 1, [Define if pthread rwlocks are available])
551             fi
552         fi
553         # this might also require -DXOPEN_SOURCE=500, so leave after the
554         # rwlock check.
555         APR_CHECK_PTHREAD_RECURSIVE_MUTEX
556     fi
557 fi
558
559 ac_cv_define_READDIR_IS_THREAD_SAFE=no
560 ac_cv_define_GETHOSTBYNAME_IS_THREAD_SAFE=no
561 ac_cv_define_GETHOSTBYADDR_IS_THREAD_SAFE=no
562 if test "$threads" = "1"; then
563     echo "APR will use threads"
564     AC_CHECK_LIB(c_r, readdir,
565         AC_DEFINE(READDIR_IS_THREAD_SAFE, 1, 
566                   [Define if readdir is thread safe]))
567     if test "x$apr_gethostbyname_is_thread_safe" = "x"; then
568         AC_CHECK_LIB(c_r, gethostbyname, apr_gethostbyname_is_thread_safe=yes)
569     fi
570     if test "$apr_gethostbyname_is_thread_safe" = "yes"; then
571         AC_DEFINE(GETHOSTBYNAME_IS_THREAD_SAFE, 1,
572                   [Define if gethostbyname is thread safe])
573     fi
574     if test "x$apr_gethostbyaddr_is_thread_safe" = "x"; then
575         AC_CHECK_LIB(c_r, gethostbyaddr, apr_gethostbyaddr_is_thread_safe=yes)
576     fi
577     if test "$apr_gethostbyaddr_is_thread_safe" = "yes"; then
578         AC_DEFINE(GETHOSTBYADDR_IS_THREAD_SAFE, 1, 
579                   [Define if gethostbyaddr is thread safe])
580     fi
581     AC_CHECK_FUNCS(gethostbyname_r gethostbyaddr_r)
582 else
583     echo "APR will be non-threaded"
584 fi
585
586 AC_CHECK_FUNCS(sigsuspend, [ have_sigsuspend="1" ], [ have_sigsuspend="0" ])
587 AC_CHECK_FUNCS(sigwait, [ have_sigwait="1" ], [ have_sigwait="0" ]) 
588 dnl AC_CHECK_FUNCS doesn't work for this on Tru64 since the function
589 dnl is renamed in signal.h.  Todo: Autodetect
590 case $host in
591     *alpha*-dec-osf* )
592         have_sigwait="1"
593         ;;
594 esac
595
596 AC_SUBST(threads)
597 AC_SUBST(have_sigsuspend)
598 AC_SUBST(have_sigwait)
599
600 AC_CHECK_FUNCS(poll)
601
602 dnl ----------------------------- Checking for missing POSIX thread functions
603 AC_CHECK_FUNCS([getpwnam_r getpwuid_r getgrnam_r getgrgid_r])
604
605 dnl ----------------------------- Checking for Shared Memory Support 
606 echo "${nl}Checking for Shared Memory Support..."
607
608 # The real-time POSIX extensions (e.g. shm_*, sem_*) may only
609 # be available if linking against librt.
610 AC_SEARCH_LIBS(shm_open, rt)
611
612 case $host in
613  *-sysv*)
614    ac_includes_default="$ac_includes_default
615 #if HAVE_SYS_MUTEX_H /* needed to define lock_t for sys/shm.h */
616 # include <sys/mutex.h>
617 #endif";;
618 esac
619
620 AC_CHECK_HEADERS([sys/mman.h sys/ipc.h sys/mutex.h sys/shm.h sys/file.h kernel/OS.h os2.h])
621 AC_CHECK_FUNCS([mmap munmap shm_open shm_unlink shmget shmat shmdt shmctl \
622                 create_area])
623 APR_CHECK_DEFINE(MAP_ANON, sys/mman.h)
624 AC_CHECK_FILE(/dev/zero)
625
626 # Not all systems can mmap /dev/zero (such as HP-UX).  Check for that.
627 if test "$ac_cv_func_mmap" = "yes" &&
628    test "$ac_cv_file__dev_zero" = "yes"; then
629     AC_MSG_CHECKING(for mmap that can map /dev/zero)
630     AC_TRY_RUN([
631 #include <sys/types.h>
632 #include <sys/stat.h>
633 #include <fcntl.h>
634 #ifdef HAVE_SYS_MMAN_H
635 #include <sys/mman.h>
636 #endif
637     int main()
638     {
639         int fd;
640         void *m;
641         fd = open("/dev/zero", O_RDWR);
642         if (fd < 0) {
643             return 1;
644         }
645         m = mmap(0, sizeof(void*), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
646         if (m == (void *)-1) {  /* aka MAP_FAILED */
647             return 2;
648         }
649         if (munmap(m, sizeof(void*)) < 0) {
650             return 3;
651         }
652         return 0;
653     }], [], [ac_cv_file__dev_zero=no], [ac_cv_file__dev_zero=no])
654
655     AC_MSG_RESULT($ac_cv_file__dev_zero)
656 fi
657
658 # Now we determine which one is our anonymous shmem preference.
659 haveshmgetanon="0"
660 havemmapzero="0"
661 havemmapanon="0"
662 APR_BEGIN_DECISION([anonymous shared memory allocation method])
663 APR_IFALLYES(header:sys/ipc.h header:sys/shm.h header:sys/file.h dnl
664              func:shmget func:shmat func:shmdt func:shmctl,
665              [haveshmgetanon="1"
666               APR_DECIDE(USE_SHMEM_SHMGET_ANON, [SysV IPC shmget()])])
667 APR_IFALLYES(header:sys/mman.h func:mmap func:munmap file:/dev/zero,
668              [havemmapzero="1"
669               APR_DECIDE(USE_SHMEM_MMAP_ZERO, 
670                   [SVR4-style mmap() on /dev/zero])])
671 APR_IFALLYES(header:sys/mman.h func:mmap func:munmap define:MAP_ANON,
672              [havemmapanon="1"
673               APR_DECIDE(USE_SHMEM_MMAP_ANON, 
674                   [4.4BSD-style mmap() via MAP_ANON])])
675 APR_IFALLYES(header:os2.h,
676              [haveos2shm="1"
677               APR_DECIDE(USE_SHMEM_OS2_ANON, [OS/2 DosAllocSharedMem()])])
678 APR_IFALLYES(header:kernel/OS.h func:create_area,
679              [havebeosshm="1"
680               APR_DECIDE(USE_SHMEM_BEOS_ANON,
681                          [BeOS areas])])
682 case $host in
683     *linux* ) 
684         # Linux has problems with MM_SHMT_MMANON even though it reports
685         # that it has it.
686         # FIXME - find exact 2.3 version that MMANON was fixed in.  It is
687         # confirmed fixed in 2.4 series.
688         if test $os_version -le "240"; then
689             APR_DECISION_OVERRIDE(USE_SHMEM_MMAP_ZERO USE_SHMEM_SHMGET_ANON)
690         fi
691         ;;
692     *hpux11* ) 
693         APR_DECISION_OVERRIDE(USE_SHMEM_SHMGET_ANON)
694         ;;
695 esac
696 APR_END_DECISION
697 AC_DEFINE_UNQUOTED($ac_decision)
698
699 useshmgetanon="0"
700 usemmapzero="0"
701 usemmapanon="0"
702
703 case $ac_decision in
704     USE_SHMEM_SHMGET_ANON )
705         useshmgetanon="1"
706         ;;
707     USE_SHMEM_MMAP_ZERO )
708         usemmapzero="1"
709         ;;
710     USE_SHMEM_MMAP_ANON )
711         usemmapanon="1"
712         ;;
713 esac
714
715 AC_SUBST(useshmgetanon)
716 AC_SUBST(usemmapzero)
717 AC_SUBST(usemmapanon)
718 AC_SUBST(haveshmgetanon)
719 AC_SUBST(havemmapzero)
720 AC_SUBST(havemmapanon)
721
722 # Now we determine which one is our name-based shmem preference.
723 havemmaptmp="0"
724 havemmapshm="0"
725 haveshmget="0"
726 havebeosarea="0"
727 haveos2shm="0"
728 APR_BEGIN_DECISION([namebased memory allocation method])
729 APR_IFALLYES(header:sys/mman.h func:mmap func:munmap,
730              [havemmaptmp="1"
731               APR_DECIDE(USE_SHMEM_MMAP_TMP, 
732                   [Classical mmap() on temporary file])])
733 APR_IFALLYES(header:sys/mman.h func:mmap func:munmap func:shm_open dnl
734              func:shm_unlink,
735              [havemmapshm="1"
736               APR_DECIDE(USE_SHMEM_MMAP_SHM, 
737                   [mmap() via POSIX.1 shm_open() on temporary file])])
738 APR_IFALLYES(header:sys/ipc.h header:sys/shm.h header:sys/file.h dnl
739              func:shmget func:shmat func:shmdt func:shmctl,
740              [haveshmget="1"
741               APR_DECIDE(USE_SHMEM_SHMGET, [SysV IPC shmget()])])
742 APR_IFALLYES(header:kernel/OS.h func:create_area,
743              [havebeosshm="1"
744               APR_DECIDE(USE_SHMEM_BEOS, [BeOS areas])])
745 APR_IFALLYES(header:os2.h,
746              [haveos2shm="1"
747               APR_DECIDE(USE_SHMEM_OS2, [OS/2 DosAllocSharedMem()])])
748 case $host in
749     *linux* ) 
750         # Linux has problems with MM_SHMT_MMANON even though it reports
751         # that it has it.
752         # FIXME - find exact 2.3 version that MMANON was fixed in.  It is
753         # confirmed fixed in 2.4 series.
754         if test $os_version -le "240"; then
755             APR_DECISION_OVERRIDE(USE_SHMEM_MMAP_TMP USE_SHMEM_MMAP_SHM dnl
756                                   USE_SHMEM_SHMGET)
757         fi
758         ;;
759 esac
760 APR_END_DECISION
761 AC_DEFINE_UNQUOTED($ac_decision)
762
763 usemmaptmp="0"
764 usemmapshm="0"
765 useshmget="0"
766 usebeosarea="0"
767 useos2shm="0"
768
769 case $ac_decision in
770     USE_SHMEM_MMAP_TMP )
771         usemmaptmp="1"
772         ;;
773     USE_SHMEM_MMAP_SHM )
774         usemmapshm="1"
775         ;;
776     USE_SHMEM_SHMGET )
777         useshmget="1"
778         ;;
779     USE_SHMEM_BEOS )
780         usebeosarea="1"
781         ;;
782     USE_SHMEM_OS2 )
783         useos2shm="1"
784         ;;
785 esac
786
787 # Do we have any shared memory support?
788 if test "$usemmaptmp$usemmapshm$usemmapzero$useshmget$usemmapanon$usebeosarea$useos2shm" = "0000000"; then
789   sharedmem="0"
790 else
791   sharedmem="1"
792 fi
793
794 AC_SUBST(usemmaptmp)
795 AC_SUBST(usemmapshm)
796 AC_SUBST(useshmget)
797 AC_SUBST(usebeosarea)
798 AC_SUBST(useos2shm)
799 AC_SUBST(havemmaptmp)
800 AC_SUBST(havemmapshm)
801 AC_SUBST(haveshmget)
802 AC_SUBST(havebeosarea)
803 AC_SUBST(haveos2shm)
804 AC_SUBST(sharedmem)
805
806 dnl ----------------------------- Checks for Any required Functions
807 dnl Checks for library functions. (N.B. poll is further down)
808 AC_CHECK_FUNCS(alloca calloc strcasecmp stricmp setsid isinf isnan)
809 AC_CHECK_FUNCS(getenv putenv setenv unsetenv)
810 AC_CHECK_FUNCS(setrlimit, [ have_setrlimit="1" ], [ have_setrlimit="0" ]) 
811 AC_CHECK_FUNCS(getrlimit, [ have_getrlimit="1" ], [ have_getrlimit="0" ]) 
812 AC_CHECK_FUNCS(writev)
813 sendfile="0"
814 AC_CHECK_LIB(sendfile, sendfilev)
815 AC_CHECK_FUNCS(sendfile send_file sendfilev, [ sendfile="1" ])
816 AC_CHECK_FUNCS(utime utimes)
817
818 dnl THIS MUST COME AFTER THE THREAD TESTS - FreeBSD doesn't always have a
819 dnl threaded poll() and we don't want to use sendfile on early FreeBSD 
820 dnl systems if we are also using threads.
821
822 AC_ARG_WITH(sendfile, [  --with-sendfile         Override decision to use sendfile],
823   [ if test "$withval" = "yes"; then
824         sendfile="1"
825     else
826         sendfile="0"
827     fi ], [
828     orig_sendfile=$sendfile
829     case $host in
830         *freebsd*)
831             # FreeBSD < 4.2 has issues with threads+sendfile
832             if test $os_version -le "401999"; then
833                 if test "$threads" = "1"; then
834                     sendfile="0"
835                 fi
836             fi
837             ;;
838         *alpha*-dec-osf* )
839             sendfile="0"
840             ;;
841         s390-*-linux-gnu)
842             # disable sendfile support for 2.2 on S/390
843             if test $os_version -lt 240; then
844                 sendfile="0"
845             fi
846             ;;
847         *aix*)
848             # compiler-independent check for 64-bit build
849             AC_CHECK_SIZEOF(void*, 4)
850             if test "x$ac_cv_sizeof_voidp" = "x8"; then
851                 # sendfile not working for 64-bit build
852                 sendfile="0"
853             fi
854             ;;
855         *darwin*)
856             # darwin semantics in 9.0.0 appear to be fubar
857             sendfile="0"
858             ;;
859     esac       
860     if test "$orig_sendfile" != "$sendfile"; then
861       echo "sendfile support disabled to avoid system problem"
862     fi ] )
863 AC_SUBST(sendfile)
864
865 AC_CHECK_FUNCS(sigaction, [ have_sigaction="1" ], [ have_sigaction="0" ]) 
866 AC_DECL_SYS_SIGLIST
867
868 AC_CHECK_FUNCS(fork, [ fork="1" ], [ fork="0" ])
869 APR_CHECK_INET_ADDR
870 APR_CHECK_INET_NETWORK
871 AC_SUBST(apr_inaddr_none)
872 AC_CHECK_FUNC(_getch)
873 AC_CHECK_FUNCS(strerror_r, [ strerror_r="1" ], [ strerror_r="0" ])
874 if test "$strerror_r" = "1"; then
875   APR_CHECK_STRERROR_R_RC
876 fi
877 AC_CHECK_FUNCS(crypt_r, [ crypt_r="1" ], [ crypt_r="0" ])
878 if test "$crypt_r" = "1"; then
879   APR_CHECK_CRYPT_R_STYLE
880 fi
881 AC_CHECK_FUNCS(mmap, [ mmap="1" ], [ mmap="0" ])
882 if test "$native_mmap_emul" = "1"; then
883     mmap="1"
884 fi
885 AC_CHECK_FUNCS(memmove, [ have_memmove="1" ], [have_memmove="0" ])
886 AC_CHECK_FUNCS([getpass getpassphrase gmtime_r localtime_r hstrerror mkstemp])
887
888 AC_SUBST(fork)
889 AC_SUBST(have_inet_addr)
890 AC_SUBST(tcp_nodelay_inherited)
891 AC_SUBST(o_nonblock_inherited)
892 AC_SUBST(have_inet_network)
893 AC_SUBST(have_sigaction)
894 AC_SUBST(have_setrlimit)
895 AC_SUBST(have_getrlimit)
896 AC_SUBST(mmap)
897 AC_SUBST(have_memmove)
898
899 APR_CHECK_SIGWAIT_ONE_ARG
900 APR_CHECK_DIRENT_INODE
901 APR_CHECK_DIRENT_TYPE
902
903 dnl ----------------------------- Checks for Any required Headers
904 AC_HEADER_STDC
905
906 APR_FLAG_HEADERS(
907     alloca.h            \
908     ByteOrder.h         \
909     conio.h             \
910     crypt.h             \
911     ctype.h             \
912     dir.h               \
913     dirent.h            \
914     dl.h                \
915     dlfcn.h             \
916     errno.h             \
917     fcntl.h             \
918     grp.h               \
919     io.h                \
920     limits.h            \
921     mach-o/dyld.h       \
922     malloc.h            \
923     memory.h            \
924     netdb.h             \
925     osreldate.h         \
926     poll.h              \
927     process.h           \
928     pwd.h               \
929     semaphore.h         \
930     signal.h            \
931     stdarg.h            \
932     stddef.h            \
933     stdio.h             \
934     stdlib.h            \
935     string.h            \
936     strings.h           \
937     sysapi.h            \
938     sysgtime.h          \
939     termios.h           \
940     time.h              \
941     tpfeq.h             \
942     tpfio.h             \
943     unistd.h            \
944     unix.h              \
945     arpa/inet.h         \
946     kernel/OS.h         \
947     net/errno.h         \
948     netinet/in.h        \
949     netinet/sctp.h      \
950     netinet/sctp_uio.h  \
951     sys/file.h          \
952     sys/ioctl.h         \
953     sys/mman.h          \
954     sys/poll.h          \
955     sys/resource.h      \
956     sys/select.h        \
957     sys/sem.h           \
958     sys/sendfile.h      \
959     sys/signal.h        \
960     sys/socket.h        \
961     sys/sockio.h        \
962     sys/stat.h          \
963     sys/sysctl.h        \
964     sys/syslimits.h     \
965     sys/time.h          \
966     sys/types.h         \
967     sys/uio.h           \
968     sys/un.h            \
969     sys/wait.h)
970
971 # IRIX 6.5 has a problem in <netinet/tcp.h> which prevents it from
972 # being included by itself.  Check for <netinet/tcp.h> manually,
973 # including another header file first.
974 AC_CACHE_CHECK([for netinet/tcp.h], [apr_cv_hdr_netinet_tcp_h],
975 [AC_TRY_CPP(
976 [#ifdef HAVE_NETINET_IN_H
977 #include <netinet/in.h>
978 #endif
979 #include <netinet/tcp.h>
980 ], [apr_cv_hdr_netinet_tcp_h=yes], [apr_cv_hdr_netinet_tcp_h=no])])
981 if test "$apr_cv_hdr_netinet_tcp_h" = "yes"; then
982    netinet_tcph=1
983    AC_DEFINE([HAVE_NETINET_TCP_H], 1, [Defined if netinet/tcp.h is present])
984 else
985    netinet_tcph=0
986 fi
987
988 AC_SUBST(arpa_ineth)
989 AC_SUBST(conioh)
990 AC_SUBST(ctypeh)
991 AC_SUBST(crypth)
992 AC_SUBST(errnoh)
993 AC_SUBST(direnth)
994 AC_SUBST(fcntlh)
995 AC_SUBST(ioh)
996 AC_SUBST(limitsh)
997 AC_SUBST(netdbh)
998 AC_SUBST(sys_syslimitsh)
999 AC_SUBST(netinet_inh)
1000 AC_SUBST(netinet_sctph)
1001 AC_SUBST(netinet_sctp_uioh)
1002 AC_SUBST(netinet_tcph)
1003 AC_SUBST(stdargh)
1004 AC_SUBST(stdioh)
1005 AC_SUBST(stdlibh)
1006 AC_SUBST(stringh)
1007 AC_SUBST(stringsh)
1008 AC_SUBST(sys_ioctlh)
1009 AC_SUBST(sys_sendfileh)
1010 AC_SUBST(sys_signalh)
1011 AC_SUBST(sys_socketh)
1012 AC_SUBST(sys_sockioh)
1013 AC_SUBST(sys_typesh)
1014 AC_SUBST(sys_timeh)
1015 AC_SUBST(sys_uioh)
1016 AC_SUBST(sys_unh)
1017 AC_SUBST(timeh)
1018 AC_SUBST(unistdh)
1019 AC_SUBST(signalh)
1020 AC_SUBST(sys_waith)
1021 AC_SUBST(pthreadh)
1022 AC_SUBST(semaphoreh)
1023
1024 # Checking for h_errno in <netdb.h>
1025 if test "$netdbh" = "1"; then
1026   APR_CHECK_H_ERRNO_FLAG
1027   if test "$ac_cv_h_errno_cflags" = "no"; then
1028     AC_MSG_ERROR([can not find h_errno in netdb.h])
1029   fi
1030 fi
1031
1032 dnl ----------------------------- Checks for standard typedefs
1033 AC_TYPE_OFF_T
1034 AC_TYPE_PID_T
1035 AC_TYPE_SIZE_T
1036 AC_TYPE_UID_T
1037 AC_CHECK_TYPE(ssize_t, int)
1038 AC_C_INLINE
1039 AC_C_CONST
1040 AC_TYPE_SIZE_T
1041 AC_FUNC_SETPGRP
1042
1043 APR_CHECK_SOCKLEN_T
1044
1045 APR_INADDR_NONE
1046
1047 dnl Checks for pointer size
1048 AC_CHECK_SIZEOF(void*, 4)
1049
1050 if test "x$ac_cv_sizeof_voidp" != "x"; then
1051     voidp_size=$ac_cv_sizeof_voidp
1052 else
1053     AC_ERROR([Cannot determine size of void*])
1054 fi
1055
1056 dnl Checks for integer size
1057 AC_CHECK_SIZEOF(char, 1)
1058 AC_CHECK_SIZEOF(int, 4)
1059 AC_CHECK_SIZEOF(long, 4)
1060 AC_CHECK_SIZEOF(short, 2)
1061 AC_CHECK_SIZEOF(long double, 12)
1062 AC_CHECK_SIZEOF(long long, 8)
1063
1064 if test "$ac_cv_sizeof_short" = "2"; then
1065     short_value=short
1066 fi
1067 if test "$ac_cv_sizeof_int" = "4"; then
1068     int_value=int
1069 fi
1070 # Now we need to find what apr_int64_t (sizeof == 8) will be.
1071 # The first match is our preference.
1072 if test "$ac_cv_sizeof_int" = "8"; then
1073     int64_literal='#define APR_INT64_C(val) (val)'
1074     int64_t_fmt='#define APR_INT64_T_FMT "d"'
1075     int64_t_fmt_len='#define APR_INT64_T_FMT_LEN 1'
1076     uint64_t_fmt='#define APR_UINT64_T_FMT "u"'
1077     uint64_t_fmt_len='#define APR_UINT64_T_FMT_LEN 1'
1078     uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "x"'
1079     int64_value="int"
1080     long_value=int
1081     int64_strfn="strtoi"
1082 elif test "$ac_cv_sizeof_long" = "8"; then
1083     int64_literal='#define APR_INT64_C(val) (val##L)'
1084     int64_t_fmt='#define APR_INT64_T_FMT "ld"'
1085     int64_t_fmt_len='#define APR_INT64_T_FMT_LEN 2'
1086     uint64_t_fmt='#define APR_UINT64_T_FMT "lu"'
1087     uint64_t_fmt_len='#define APR_UINT64_T_FMT_LEN 2'
1088     uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "lx"'
1089     int64_value="long"
1090     long_value=long
1091     int64_strfn="strtol"
1092 elif test "$ac_cv_sizeof_long_long" = "8"; then
1093     int64_literal='#define APR_INT64_C(val) (val##LL)'
1094     # Linux, Solaris, FreeBSD all support ll with printf.
1095     # BSD 4.4 originated 'q'.  Solaris is more popular and 
1096     # doesn't support 'q'.  Solaris wins.  Exceptions can
1097     # go to the OS-dependent section.
1098     int64_t_fmt='#define APR_INT64_T_FMT "lld"'
1099     int64_t_fmt_len='#define APR_INT64_T_FMT_LEN 3'
1100     uint64_t_fmt='#define APR_UINT64_T_FMT "llu"'
1101     uint64_t_fmt_len='#define APR_UINT64_T_FMT_LEN 3'
1102     uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "llx"'
1103     int64_value="long long"
1104     long_value="long long"
1105     int64_strfn="strtoll"
1106 elif test "$ac_cv_sizeof_long_double" = "8"; then
1107     int64_literal='#define APR_INT64_C(val) (val##LD)'
1108     int64_t_fmt='#define APR_INT64_T_FMT "Ld"'
1109     int64_t_fmt_len='#define APR_INT64_T_FMT_LEN 2'
1110     uint64_t_fmt='#define APR_UINT64_T_FMT "Lu"'
1111     uint64_t_fmt_len='#define APR_UINT64_T_FMT_LEN 2'
1112     uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "Lx"'
1113     int64_value="long double"
1114     long_value="long double"
1115     int64_strfn="strtoll"
1116 elif test "$ac_cv_sizeof_longlong" = "8"; then
1117     int64_literal='#define APR_INT64_C(val) (val##LL)'
1118     int64_t_fmt='#define APR_INT64_T_FMT "qd"'
1119     int64_t_fmt_len='#define APR_INT64_T_FMT_LEN 2'
1120     uint64_t_fmt='#define APR_UINT64_T_FMT "qu"'
1121     uint64_t_fmt_len='#define APR_UINT64_T_FMT_LEN 2'
1122     uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "qx"'
1123     int64_value="__int64"
1124     long_value="__int64"
1125     int64_strfn="strtoll"
1126 else
1127     # int64_literal may be overriden if your compiler thinks you have
1128     # a 64-bit value but APR does not agree.
1129     int64_literal='#error Can not determine the proper size for apr_int64_t'
1130     int64_t_fmt='#error Can not determine the proper size for apr_int64_t'
1131     int64_t_fmt_len='#error Can not determine the proper size for apr_int64_t'
1132     uint64_t_fmt='#error Can not determine the proper size for apr_int64_t'
1133     uint64_t_fmt_len='#error Can not determine the proper size for apr_int64_t'
1134     uint64_t_hex_fmt='#error Can not determine the proper size for apr_uint64_t'
1135 fi
1136
1137 # If present, allow the C99 macro INT64_C to override our conversion.
1138 #
1139 # HP-UX's ANSI C compiler provides this without any includes, so we
1140 # will first look for INT64_C without adding stdint.h
1141 AC_CACHE_CHECK([for INT64_C], [apr_cv_define_INT64_C], [
1142 AC_EGREP_CPP(YES_IS_DEFINED,
1143 [#ifdef INT64_C
1144 YES_IS_DEFINED
1145 #endif], [apr_cv_define_INT64_C=yes], [
1146     # Now check for INT64_C in stdint.h
1147     AC_EGREP_CPP(YES_IS_DEFINED, [#include <stdint.h>
1148 #ifdef INT64_C
1149 YES_IS_DEFINED
1150 #endif], [apr_cv_define_INT64_C=yes], [apr_cv_define_INT64_C=no])])])
1151
1152 if test "$apr_cv_define_INT64_C" = "yes"; then
1153     int64_literal='#define APR_INT64_C(val) INT64_C(val)'
1154     stdint=1
1155 else
1156     stdint=0
1157 fi
1158
1159 if test "$ac_cv_type_size_t" = "yes"; then
1160     size_t_value="size_t"
1161 else
1162     size_t_value="apr_int32_t"
1163 fi
1164 if test "$ac_cv_type_ssize_t" = "yes"; then
1165     ssize_t_value="ssize_t"
1166 else
1167     ssize_t_value="apr_int32_t"
1168 fi
1169 if test "$ac_cv_socklen_t" = "yes"; then
1170     socklen_t_value="socklen_t"
1171     case $host in
1172         *-hp-hpux*)
1173             if test "$ac_cv_sizeof_long" = "8"; then
1174                 # 64-bit HP-UX requires 32-bit socklens in
1175                 # kernel, but user-space declarations say
1176                 # 64-bit (socklen_t == size_t == long).
1177                 # This will result in many compile warnings,
1178                 # but we're functionally busted otherwise.
1179                 socklen_t_value="int"
1180             fi
1181             ;;
1182     esac
1183 else
1184     socklen_t_value="int"
1185 fi
1186
1187 APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], ssize_t, 8)
1188
1189 if test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
1190     ssize_t_fmt='#define APR_SSIZE_T_FMT "d"'
1191 elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then
1192     ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
1193 else
1194     ssize_t_fmt='#error Can not determine the proper size for ssize_t'
1195 fi
1196
1197 APR_CHECK_SIZEOF_EXTENDED([#include <stddef.h>], size_t, 8)
1198
1199 if test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_int"; then
1200     size_t_fmt='#define APR_SIZE_T_FMT "d"'
1201 elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long"; then
1202     size_t_fmt='#define APR_SIZE_T_FMT "ld"'
1203 else
1204     size_t_fmt='#error Can not determine the proper size for size_t'
1205 fi
1206
1207 if test "$ac_cv_type_off_t" = "yes"; then
1208     APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], off_t, 8)
1209     AC_MSG_CHECKING([which type to use for apr_off_t])
1210     if test "${ac_cv_sizeof_off_t}${ac_cv_sizeof_long}" = "44"; then
1211         # Special case: off_t may change size with _FILE_OFFSET_BITS
1212         # on 32-bit systems with LFS support.  To avoid compatibility
1213         # issues when other packages do define _FILE_OFFSET_BITS,
1214         # hard-code apr_off_t to long.
1215         off_t_value=long
1216         off_t_fmt='#define APR_OFF_T_FMT "ld"'
1217     else
1218         off_t_value=off_t
1219         # off_t is more commonly a long than an int; prefer that case
1220         # where int and long are the same size.
1221         if test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_long"; then
1222             off_t_fmt='#define APR_OFF_T_FMT "ld"'
1223         elif test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_int"; then
1224             off_t_fmt='#define APR_OFF_T_FMT "d"'
1225         elif test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_long_long"; then
1226             off_t_fmt='#define APR_OFF_T_FMT APR_INT64_T_FMT'
1227         else
1228             AC_ERROR([could not determine the size of off_t])
1229         fi
1230     fi
1231     AC_MSG_RESULT([$off_t_value])
1232     
1233     dnl define apr_ino_t in a manner independent of _FILE_OFFSET_BITS setting
1234     dnl default fallback
1235     ino_t_value=ino_t
1236     APR_CHECK_TYPES_COMPATIBLE(ino_t, unsigned long long, ino_t_value="unsigned long long")
1237     APR_CHECK_TYPES_COMPATIBLE(ino_t, unsigned long, ino_t_value="unsigned long")
1238     APR_CHECK_TYPES_COMPATIBLE(ino_t, unsigned int, ino_t_value="unsigned int")
1239
1240 else
1241     off_t_value='apr_int32_t'
1242     off_t_fmt='#define APR_OFF_T_FMT "d"'
1243 fi
1244
1245 APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], pid_t, 8)
1246
1247 if test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_short"; then
1248     pid_t_fmt='#define APR_PID_T_FMT "hd"'
1249 elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_int"; then
1250     pid_t_fmt='#define APR_PID_T_FMT "d"'
1251 elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_long"; then
1252     pid_t_fmt='#define APR_PID_T_FMT "ld"'
1253 elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_long_long"; then
1254     pid_t_fmt='#define APR_PID_T_FMT APR_INT64_T_FMT'
1255 else
1256     pid_t_fmt='#error Can not determine the proper size for pid_t'
1257 fi
1258
1259 # Basically, we have tried to figure out the correct format strings
1260 # for APR types which vary between platforms, but we don't always get 
1261 # it right.  If you find that we don't get it right for your platform, 
1262 # you can override our decision below.
1263 case $host in
1264    *linux*)
1265        case $host in
1266            s390*)
1267                size_t_fmt='#define APR_SIZE_T_FMT "ld"'
1268                ;;
1269        esac
1270        ;;
1271    *os2_emx)
1272        size_t_fmt='#define APR_SIZE_T_FMT "lu"'
1273        ;;
1274    *-solaris*)
1275        pid_t_fmt='#define APR_PID_T_FMT "ld"'
1276        ;;
1277    *aix4*|*aix5*)
1278        ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
1279        size_t_fmt='#define APR_SIZE_T_FMT "lu"'
1280        ;;
1281     *beos*)
1282         ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
1283         size_t_fmt='#define APR_SIZE_T_FMT "ld"'
1284         ;;
1285     *apple-darwin*)
1286         osver=`uname -r`
1287         case $osver in
1288            [[0-7]].*)
1289               ssize_t_fmt='#define APR_SSIZE_T_FMT "d"'
1290               ;;
1291            *)
1292               ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
1293               ;;
1294         esac
1295         size_t_fmt='#define APR_SIZE_T_FMT "lu"'
1296         ;;
1297 esac
1298
1299 AC_SUBST(voidp_size)
1300 AC_SUBST(short_value)
1301 AC_SUBST(int_value)
1302 AC_SUBST(long_value)
1303 AC_SUBST(int64_value)
1304 AC_SUBST(off_t_value)
1305 AC_SUBST(size_t_value)
1306 AC_SUBST(ssize_t_value)
1307 AC_SUBST(socklen_t_value)
1308 AC_SUBST(int64_t_fmt) 
1309 AC_SUBST(int64_t_fmt_len) 
1310 AC_SUBST(uint64_t_fmt) 
1311 AC_SUBST(uint64_t_fmt_len) 
1312 AC_SUBST(uint64_t_hex_fmt) 
1313 AC_SUBST(ssize_t_fmt) 
1314 AC_SUBST(size_t_fmt)
1315 AC_SUBST(off_t_fmt) 
1316 AC_SUBST(pid_t_fmt)
1317 AC_SUBST(int64_literal) 
1318 AC_SUBST(stdint) 
1319 AC_SUBST(ino_t_value)
1320
1321 dnl ----------------------------- Checking for string functions
1322 AC_CHECK_FUNCS(strnicmp, have_strnicmp="1", have_strnicmp="0")
1323 AC_CHECK_FUNCS(strncasecmp, have_strncasecmp="1", have_strncasecmp="0")
1324 AC_CHECK_FUNCS(stricmp, have_stricmp="1", have_stricmp="0")
1325 AC_CHECK_FUNCS(strcasecmp, have_strcasecmp="1", have_strcasecmp="0")
1326 AC_CHECK_FUNCS(strdup, have_strdup="1", have_strdup="0")
1327 AC_CHECK_FUNCS(strstr, have_strstr="1", have_strstr="0")
1328 AC_CHECK_FUNCS(memchr, have_memchr="1", have_memchr="0")
1329 AC_CHECK_FUNCS($int64_strfn, have_int64_strfn="1", have_int64_strfn="0")
1330
1331 dnl ----------------------------- We have a fallback position
1332 if test "$have_int64_strfn" = "0" && test "$int64_strfn" = "strtoll"; then
1333     int64_strfn="strtoq"
1334     AC_CHECK_FUNCS($int64_strfn, have_int64_strfn="1", have_int64_strfn="0")
1335 fi
1336
1337 AC_SUBST(have_strnicmp)
1338 AC_SUBST(have_strncasecmp)
1339 AC_SUBST(have_stricmp)
1340 AC_SUBST(have_strcasecmp)
1341 AC_SUBST(have_strdup)
1342 AC_SUBST(have_strstr)
1343 AC_SUBST(have_memchr)
1344 AC_SUBST(have_int64_strfn)
1345 AC_SUBST(int64_strfn)
1346
1347 dnl ----------------------------- Checking for DSO support
1348 echo "${nl}Checking for DSO..."
1349 AC_ARG_ENABLE(dso,
1350   [  --disable-dso           Disable DSO support ],
1351   [ tempdso=$enableval],
1352   [ 
1353     AC_CHECK_FUNCS(NSLinkModule, [ tempdso="dyld" ], [ tempdso="no" ])
1354     if test "$tempdso" = "no"; then
1355       AC_CHECK_LIB(dld, shl_load, [ tempdso="shl" APR_ADDTO(LIBS,-ldld) ],
1356                    tempdso="no")
1357     fi
1358     if test "$tempdso" = "no"; then
1359       AC_CHECK_FUNCS(dlopen, [ tempdso="dlfcn" ], [ tempdso="no" ])
1360     fi
1361     if test "$tempdso" = "no"; then
1362       AC_CHECK_LIB(dl, dlopen, [ tempdso="dlfcn" APR_ADDTO(LIBS,-ldl) ], 
1363                    tempdso="no")
1364     fi
1365     if test "$tempdso" = "dlfcn"; then
1366         # ReliantUnix has dlopen() in libc but dlsym() in libdl :(
1367         AC_CHECK_FUNCS(dlsym, [ tempdso="dlfcn" ], [ tempdso="no" ])
1368         if test "$tempdso" = "no"; then
1369             AC_CHECK_LIB(dl, dlsym, [ tempdso="dlfcn" APR_ADDTO(LIBS, -ldl) ],
1370                          tempdso="no")
1371         fi
1372         if test "$tempdso" = "no"; then
1373             echo "Weird: dlopen() was found but dlsym() was not found!"
1374         fi
1375     fi
1376     if test "$tempdso" = "no"; then
1377       AC_CHECK_LIB(root, load_image, tempdso="yes", tempdso="no")
1378     fi
1379     if test "$tempdso" = "no"; then
1380         case $host in
1381             *os390|*-os2*|*os400)
1382                 tempdso="yes"
1383                 ;;
1384         esac
1385     fi
1386  ] )
1387
1388 if test "$tempdso" = "no"; then
1389     aprdso="0"
1390 else
1391     case "$tempdso" in
1392     dlfcn) AC_DEFINE(DSO_USE_DLFCN, 1, [Define if DSO support uses dlfcn.h]);;
1393     shl)   AC_DEFINE(DSO_USE_SHL, 1, [Define if DSO support uses shl_load]);;
1394     dyld)  AC_DEFINE(DSO_USE_DYLD, 1, [Define if DSO support uses dyld.h]);;
1395     esac
1396     aprdso="1"
1397     apr_modules="$apr_modules dso"
1398 fi
1399
1400 AC_SUBST(aprdso)
1401
1402 dnl ----------------------------- Checking for Processes
1403 echo "${nl}Checking for Processes..."
1404
1405 AC_CHECK_FUNCS(waitpid)
1406
1407 AC_ARG_ENABLE(other-child,
1408   [  --enable-other-child    Enable reliable child processes ],
1409   [ if test "$enableval" = "yes"; then
1410         oc="1"
1411     else
1412         oc="0"
1413     fi ],
1414   [ oc=1 ] ) 
1415   
1416 AC_SUBST(oc) 
1417
1418 AC_MSG_CHECKING(for Variable Length Arrays)
1419 APR_TRY_COMPILE_NO_WARNING([],
1420 [
1421     int foo[argc];
1422     foo[0] = 0;
1423 ], vla_msg=yes, vla_msg=no )
1424 AC_MSG_RESULT([$vla_msg])
1425 if test "$vla_msg" = "yes"; then
1426     AC_DEFINE(HAVE_VLA, 1, [Define if C compiler supports VLA])
1427 fi
1428
1429 AC_CACHE_CHECK(struct rlimit,ac_cv_struct_rlimit,[
1430 AC_TRY_RUN([
1431 #include <sys/types.h>
1432 #include <sys/time.h>
1433 #include <sys/resource.h>
1434 main()
1435 {
1436     struct rlimit limit;
1437     limit.rlim_cur = 0;
1438     limit.rlim_max = 0;
1439     exit(0);
1440 }], [
1441     ac_cv_struct_rlimit=yes ], [
1442     ac_cv_struct_rlimit=no ], [
1443     ac_cv_struct_rlimit=no ] ) ] )
1444 struct_rlimit=0
1445 test "x$ac_cv_struct_rlimit" = xyes && struct_rlimit=1
1446 AC_SUBST(struct_rlimit)
1447
1448 dnl ----------------------------- Checking for Locking Characteristics 
1449 echo "${nl}Checking for Locking..."
1450
1451 AC_CHECK_FUNCS(semget semctl flock)
1452 AC_CHECK_HEADERS(semaphore.h)
1453 AC_CHECK_FUNCS(sem_close sem_unlink sem_post sem_wait)
1454
1455 # Some systems return ENOSYS from sem_open.
1456 AC_CACHE_CHECK(for working sem_open,ac_cv_func_sem_open,[
1457 AC_TRY_RUN([
1458 #include <errno.h>
1459 #include <stdlib.h>
1460 #include <fcntl.h>
1461 #include <semaphore.h>
1462 main()
1463 {
1464     sem_t *psem;
1465     const char *sem_name = "/apr_autoconf";
1466
1467     if (sizeof(int) < sizeof(sem_t *))
1468         exit(1);
1469     psem = sem_open(sem_name, O_CREAT, 0644, 1);
1470     if (psem == (sem_t *)SEM_FAILED) {
1471         exit(1);
1472     }
1473     sem_close(psem);
1474     sem_unlink(sem_name);
1475     exit(0);
1476 }], [ac_cv_func_sem_open=yes], [ac_cv_func_sem_open=no],
1477 [ac_cv_func_sem_open=no])])
1478
1479 # It's stupid, but not all platforms have union semun, even those that need it.
1480 AC_MSG_CHECKING(for union semun in sys/sem.h)
1481 AC_TRY_COMPILE([
1482 #include <sys/types.h>
1483 #include <sys/ipc.h>
1484 #include <sys/sem.h>
1485 ],[
1486 union semun arg;
1487 semctl(0, 0, 0, arg);
1488 ], [have_union_semun="1" union_semun=yes ]
1489 msg=yes, [
1490 have_union_semun="0"
1491 msg=no ] )
1492 AC_MSG_RESULT([$msg])
1493 AC_SUBST(have_union_semun)
1494
1495 dnl Checks for libraries.
1496 APR_CHECK_DEFINE(LOCK_EX, sys/file.h)
1497 APR_CHECK_DEFINE(F_SETLK, fcntl.h)
1498 APR_CHECK_DEFINE(SEM_UNDO, sys/sem.h)
1499
1500 # We are assuming that if the platform doesn't have POLLIN, it doesn't have
1501 # any POLL definitions.
1502 APR_CHECK_DEFINE_FILES(POLLIN, poll.h sys/poll.h)
1503
1504 if test "$threads" = "1"; then
1505     APR_CHECK_DEFINE(PTHREAD_PROCESS_SHARED, pthread.h)
1506     AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
1507     # Some systems have setpshared and define PROCESS_SHARED, but don't 
1508     # really support PROCESS_SHARED locks.  So, we must validate that we 
1509     # can go through the steps without receiving some sort of system error.
1510     # Linux and older versions of AIX have this problem.
1511     APR_IFALLYES(header:pthread.h define:PTHREAD_PROCESS_SHARED func:pthread_mutexattr_setpshared, [
1512       AC_CACHE_CHECK([for working PROCESS_SHARED locks], apr_cv_process_shared_works, [
1513       AC_TRY_RUN([
1514 #include <sys/types.h>
1515 #include <pthread.h>
1516         int main()
1517         {
1518             pthread_mutex_t mutex;
1519             pthread_mutexattr_t attr;
1520             if (pthread_mutexattr_init(&attr))
1521                 exit(1);
1522             if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED))
1523                 exit(2);
1524             if (pthread_mutex_init(&mutex, &attr))
1525                 exit(3);
1526             if (pthread_mutexattr_destroy(&attr))
1527                 exit(4);
1528             if (pthread_mutex_destroy(&mutex))
1529                 exit(5);
1530             exit(0);
1531         }], [apr_cv_process_shared_works=yes], [apr_cv_process_shared_works=no])])
1532       # Override detection of pthread_mutexattr_setpshared
1533       ac_cv_func_pthread_mutexattr_setpshared=$apr_cv_process_shared_works])
1534
1535     if test "$ac_cv_func_pthread_mutexattr_setpshared" = "yes"; then
1536         APR_CHECK_PTHREAD_ROBUST_SHARED_MUTEX
1537     fi
1538 fi
1539
1540 # See which lock mechanisms we can support on this system.
1541 APR_IFALLYES(header:semaphore.h func:sem_open func:sem_close dnl
1542              func:sem_unlink func:sem_post func:sem_wait,
1543              hasposixser="1", hasposixser="0")
1544 APR_IFALLYES(func:semget func:semctl define:SEM_UNDO, hassysvser="1", 
1545              hassysvser="0")
1546 APR_IFALLYES(func:flock define:LOCK_EX, hasflockser="1", hasflockser="0")
1547 APR_IFALLYES(header:fcntl.h define:F_SETLK, hasfcntlser="1", hasfcntlser="0")
1548 # note: the current APR use of shared mutex requires /dev/zero
1549 APR_IFALLYES(header:pthread.h define:PTHREAD_PROCESS_SHARED dnl
1550              func:pthread_mutexattr_setpshared dnl
1551              file:/dev/zero,
1552              hasprocpthreadser="1", hasprocpthreadser="0")
1553 APR_IFALLYES(struct:pthread_rw, hasrwlockser="1", hasrwlockser="0")
1554
1555 # See which lock mechanism we'll select by default on this system.
1556 # The last APR_DECIDE to execute sets the default.
1557 # At this stage, we match the ordering in Apache 1.3
1558 # which is (highest to lowest): sysvsem -> fcntl -> flock.
1559 # POSIX semaphores and cross-process pthread mutexes are not
1560 # used by default since they have less desirable behaviour when
1561 # e.g. a process holding the mutex segfaults.
1562 APR_BEGIN_DECISION([apr_lock implementation method])
1563 APR_IFALLYES(func:flock define:LOCK_EX,
1564             APR_DECIDE(USE_FLOCK_SERIALIZE, [4.2BSD-style flock()]))
1565 APR_IFALLYES(header:fcntl.h define:F_SETLK,
1566             APR_DECIDE(USE_FCNTL_SERIALIZE, [SVR4-style fcntl()]))
1567 APR_IFALLYES(func:semget func:semctl define:SEM_UNDO,
1568             APR_DECIDE(USE_SYSVSEM_SERIALIZE, [SysV IPC semget()]))
1569 if test "x$apr_lock_method" != "x"; then
1570     APR_DECISION_FORCE($apr_lock_method)
1571 fi
1572 APR_END_DECISION
1573 AC_DEFINE_UNQUOTED($ac_decision)
1574
1575 flockser="0"
1576 sysvser="0"
1577 posixser="0"
1578 procpthreadser="0"
1579 fcntlser="0"
1580 case $ac_decision in
1581     USE_FLOCK_SERIALIZE )
1582         flockser="1"
1583         ;;
1584     USE_FCNTL_SERIALIZE )
1585         fcntlser="1"
1586         ;;
1587     USE_SYSVSEM_SERIALIZE )
1588         sysvser="1"
1589         ;;
1590     USE_POSIXSEM_SERIALIZE )
1591         posixser="1"
1592         ;;
1593     USE_PROC_PTHREAD_SERIALIZE )
1594         procpthreadser="1"
1595         ;;
1596 esac
1597
1598 AC_SUBST(hasflockser)
1599 AC_SUBST(hassysvser)
1600 AC_SUBST(hasposixser)
1601 AC_SUBST(hasfcntlser)
1602 AC_SUBST(hasprocpthreadser)
1603 AC_SUBST(hasrwlockser)
1604 AC_SUBST(flockser)
1605 AC_SUBST(sysvser)
1606 AC_SUBST(posixser)
1607 AC_SUBST(fcntlser)
1608 AC_SUBST(procpthreadser)
1609 AC_SUBST(pthreadser)
1610
1611 AC_MSG_CHECKING(if all interprocess locks affect threads)
1612 if test "x$apr_process_lock_is_global" = "xyes"; then
1613     proclockglobal="1"
1614     AC_MSG_RESULT(yes)
1615 else
1616     proclockglobal="0"
1617     AC_MSG_RESULT(no)
1618 fi
1619
1620 AC_SUBST(proclockglobal)
1621
1622 AC_MSG_CHECKING(if POSIX sems affect threads in the same process)
1623 if test "x$apr_posixsem_is_global" = "xyes"; then
1624   AC_DEFINE(POSIXSEM_IS_GLOBAL, 1, 
1625             [Define if POSIX semaphores affect threads within the process])
1626   AC_MSG_RESULT(yes)
1627 else
1628   AC_MSG_RESULT(no)
1629 fi
1630
1631 AC_MSG_CHECKING(if SysV sems affect threads in the same process)
1632 if test "x$apr_sysvsem_is_global" = "xyes"; then
1633   AC_DEFINE(SYSVSEM_IS_GLOBAL, 1,
1634             [Define if SysV semaphores affect threads within the process])
1635   AC_MSG_RESULT(yes)
1636 else
1637   AC_MSG_RESULT(no)
1638 fi
1639
1640 AC_MSG_CHECKING(if fcntl locks affect threads in the same process)
1641 if test "x$apr_fcntl_is_global" = "xyes"; then
1642   AC_DEFINE(FCNTL_IS_GLOBAL, 1,
1643             [Define if fcntl locks affect threads within the process])
1644   AC_MSG_RESULT(yes)
1645 else
1646   AC_MSG_RESULT(no)
1647 fi
1648
1649 AC_MSG_CHECKING(if flock locks affect threads in the same process)
1650 if test "x$apr_flock_is_global" = "xyes"; then
1651   AC_DEFINE(FLOCK_IS_GLOBAL, 1,
1652             [Define if flock locks affect threads within the process])
1653   AC_MSG_RESULT(yes)
1654 else
1655   AC_MSG_RESULT(no)
1656 fi
1657
1658 dnl ----------------------------- Checking for /dev/random 
1659 AC_MSG_CHECKING(for entropy source)
1660
1661 AC_ARG_WITH(egd, 
1662   [  --with-egd[[=DIR]]        use EGD-compatible socket],
1663   [ AC_DEFINE(HAVE_EGD, 1, [Define if EGD is supported])
1664     if test "$withval" = "yes"; then
1665         AC_DEFINE_UNQUOTED(EGD_DEFAULT_SOCKET, ["/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"], 
1666          [Define to list of paths to EGD sockets])
1667     else
1668         AC_DEFINE_UNQUOTED(EGD_DEFAULT_SOCKET, ["$withval"])
1669     fi
1670     AC_MSG_RESULT(EGD-compatible daemon)
1671     rand="1"
1672   ])
1673
1674 if test "$rand" != "1"; then
1675   AC_ARG_WITH(devrandom,
1676     [  --with-devrandom[[=DEV]]  use /dev/random or compatible [[searches by default]]],
1677     [ apr_devrandom="$withval" ], [ apr_devrandom="yes" ])
1678
1679   if test "$apr_devrandom" = "yes"; then
1680     # /dev/random on OpenBSD doesn't provide random data, so
1681     # prefer /dev/arandom, which does; see random(4).
1682     for f in /dev/arandom /dev/random /dev/urandom; do
1683       if test -r $f; then
1684         apr_devrandom=$f
1685         rand=1
1686         break
1687       fi
1688     done
1689   elif test "$apr_devrandom" != "no"; then
1690     if test -r "$apr_devrandom"; then
1691       rand="1"
1692     else
1693       AC_ERROR([$apr_devrandom not found or unreadable.])
1694     fi
1695   fi
1696
1697   if test "$rand" = "1"; then
1698     AC_DEFINE_UNQUOTED(DEV_RANDOM, ["$apr_devrandom"], [Define to path of random device])
1699     AC_MSG_RESULT([$apr_devrandom])
1700   fi
1701 fi
1702
1703 if test "$rand" != "1"; then
1704     case $host in
1705         # we have built in support for OS/2
1706         *-os2*)
1707             AC_MSG_RESULT([Using OS/2 builtin random])
1708             rand="1"
1709             ;;
1710         *)
1711             if test "$rand" != "1"; then
1712               if test "$ac_cv_lib_truerand_main" = "yes"; then
1713                 AC_DEFINE(HAVE_TRUERAND, 1, [Define if truerand is supported])
1714                 AC_MSG_RESULT(truerand)
1715                 rand="1"
1716               else
1717                 AC_MSG_RESULT(not found)
1718                 rand="0"
1719               fi
1720             fi
1721             ;;
1722     esac
1723 fi
1724
1725 AC_SUBST(rand)
1726 dnl ----------------------------- Checking for Time Support 
1727 echo "${nl}Checking for Time Support..."
1728 AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
1729 [AC_TRY_COMPILE([#include <sys/types.h>
1730 #include <time.h>], [struct tm tm; tm.tm_gmtoff;],
1731   ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
1732
1733 if test "$ac_cv_struct_tm_gmtoff" = "yes"; then
1734     AC_DEFINE(HAVE_GMTOFF, 1, [Define if struct tm has a tm_gmtoff field])
1735 fi
1736
1737 dnl ----------------------------- Checking for Networking Support 
1738 echo "${nl}Checking for Networking support..."
1739 AC_MSG_CHECKING(for in_addr in netinet/in.h)
1740 AC_TRY_COMPILE([
1741 #include <sys/types.h>
1742 #include <netinet/in.h>
1743 ],[
1744 struct in_addr arg;
1745 arg.s_addr = htonl(INADDR_ANY);
1746 ], [ have_in_addr="1" 
1747 msg=yes ] , [ have_in_addr="0"
1748 msg=no ])
1749 AC_MSG_RESULT([$msg])
1750
1751 AC_MSG_CHECKING([if fd == socket on this platform])
1752 if test "x$file_as_socket" != "x0" ; then
1753     file_as_socket="1";
1754     echo "yes"
1755 else
1756     echo "no"
1757 fi
1758
1759 AC_SUBST(have_in_addr)
1760 AC_SUBST(file_as_socket)
1761
1762 # Check the types only if we have gethostbyname_r
1763 if test "$ac_cv_func_gethostbyname_r" = "yes"; then
1764     APR_CHECK_GETHOSTBYNAME_R_STYLE
1765 fi
1766
1767 APR_CHECK_TCP_NODELAY_INHERITED
1768 APR_CHECK_O_NONBLOCK_INHERITED
1769
1770 # Look for a way of corking TCP...
1771 APR_CHECK_DEFINE(TCP_CORK, netinet/tcp.h)
1772 APR_CHECK_DEFINE(TCP_NOPUSH, netinet/tcp.h)
1773 apr_tcp_nopush_flag="0"
1774 have_corkable_tcp="0"
1775 if test "x$ac_cv_define_TCP_CORK" = "xyes"; then
1776     apr_tcp_nopush_flag="TCP_CORK"
1777     have_corkable_tcp="1"
1778 else
1779     case $host in
1780         *linux*)
1781             AC_EGREP_CPP(yes,[
1782 #include <linux/socket.h>
1783 #ifdef TCP_CORK
1784 yes
1785 #endif
1786             ],[
1787                 apr_tcp_nopush_flag="3"
1788                 have_corkable_tcp="1"
1789             ])
1790             ;;
1791         *)
1792             ;;
1793     esac
1794 fi
1795 if test "x$ac_cv_define_TCP_NOPUSH" = "xyes"; then
1796     apr_tcp_nopush_flag="TCP_NOPUSH"
1797     have_corkable_tcp="1"
1798 fi
1799
1800 APR_CHECK_DEFINE(SO_ACCEPTFILTER, sys/socket.h)
1801 if test "x$ac_cv_define_SO_ACCEPTFILTER" = "xyes"; then
1802     acceptfilter="1"
1803 else
1804     acceptfilter="0"
1805 fi
1806
1807 APR_CHECK_SCTP
1808
1809 AC_SUBST(apr_tcp_nopush_flag)
1810 AC_SUBST(have_corkable_tcp)
1811 AC_SUBST(acceptfilter)
1812 AC_SUBST(have_sctp)
1813
1814 AC_CHECK_FUNCS(set_h_errno)
1815 APR_CHECK_RESOLV_RETRANS
1816
1817 echo "${nl}Checking for IPv6 Networking support..."
1818 dnl Start of checking for IPv6 support...
1819
1820 AC_ARG_ENABLE(ipv6,
1821   [  --disable-ipv6          Disable IPv6 support in APR.],
1822   [ if test "$enableval" = "no"; then
1823         user_disabled_ipv6=1
1824     fi ],
1825   [ user_disabled_ipv6=0 ] )
1826
1827 case $host in
1828   *)
1829     broken_ipv6=0
1830 esac
1831
1832 AC_SEARCH_LIBS(getaddrinfo, socket inet6)
1833 AC_SEARCH_LIBS(gai_strerror, socket inet6)
1834 AC_SEARCH_LIBS(getnameinfo, socket inet6)
1835 AC_CHECK_FUNCS(gai_strerror)
1836 APR_CHECK_WORKING_GETADDRINFO
1837 APR_CHECK_NEGATIVE_EAI
1838 APR_CHECK_WORKING_GETNAMEINFO
1839 APR_CHECK_SOCKADDR_IN6
1840
1841 have_ipv6="0"
1842 if test "$user_disabled_ipv6" = 1; then
1843     ipv6_result="no -- disabled by user"
1844 else
1845     if test "x$broken_ipv6" = "x0"; then
1846         if test "x$have_sockaddr_in6" = "x1"; then
1847             if test "x$ac_cv_working_getaddrinfo" = "xyes"; then
1848                 if test "x$ac_cv_working_getnameinfo" = "xyes"; then
1849                     have_ipv6="1"
1850                     ipv6_result="yes"
1851                 else
1852                     ipv6_result="no -- no getnameinfo"
1853                 fi
1854             else
1855                 ipv6_result="no -- no working getaddrinfo"
1856             fi
1857         else
1858             ipv6_result="no -- no sockaddr_in6"
1859         fi
1860     else
1861         ipv6_result="no -- the platform has known problems supporting IPv6"
1862     fi
1863 fi
1864
1865 AC_MSG_CHECKING(if APR supports IPv6)
1866 AC_MSG_RESULT($ipv6_result)
1867
1868 AC_SUBST(have_ipv6)
1869
1870 dnl Check for langinfo support
1871
1872 AC_CHECK_HEADERS(langinfo.h)
1873 AC_CHECK_FUNCS(nl_langinfo)
1874
1875 dnl Random late checks...
1876
1877 # AC_CHECK_FUNCS is not sufficient since the function may be usable when
1878 # struct stat64 is not exposed (e.g. HP-UX).  Note that fstat64 only
1879 # happens to be usable on Linux because -D_GNU_SOURCE is picked up
1880 # by the earlier crypt_r check.
1881 AC_CACHE_CHECK([for usable fstat64], [apr_cv_func_fstat64],
1882  [AC_TRY_COMPILE([#include <sys/types.h>
1883 #include <sys/stat.h>
1884 #include <unistd.h>], [struct stat64 st; fstat64(0, &st);],
1885   [apr_cv_func_fstat64=yes], [apr_cv_func_fstat64=no])])
1886 if test $apr_cv_func_fstat64 = yes; then
1887   AC_DEFINE(HAVE_FSTAT64, 1, [Define if fstat64 can be used])
1888 fi
1889
1890
1891 dnl ----------------------------- Finalize the variables
1892
1893 echo "${nl}Restore user-defined environment settings..."
1894
1895 APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, EXTRA_)
1896 APR_RESTORE_THE_ENVIRONMENT(CFLAGS, EXTRA_)
1897 APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, EXTRA_)
1898 APR_RESTORE_THE_ENVIRONMENT(LIBS, EXTRA_)
1899 APR_RESTORE_THE_ENVIRONMENT(INCLUDES, EXTRA_)
1900 AC_SUBST(NOTEST_CPPFLAGS)
1901 AC_SUBST(NOTEST_CFLAGS)
1902 AC_SUBST(NOTEST_LDFLAGS)
1903 AC_SUBST(NOTEST_LIBS)
1904 AC_SUBST(NOTEST_INCLUDES)
1905
1906 dnl ----------------------------- Construct the files
1907
1908 AC_SUBST(LDLIBS)
1909 AC_SUBST(AR)
1910 AC_SUBST(RM)
1911 AC_SUBST(OSDIR)
1912 AC_SUBST(DEFAULT_OSDIR)
1913 AC_SUBST(EXEEXT)
1914 AC_SUBST(LIBTOOL_LIBS)
1915
1916 echo "${nl}Construct Makefiles and header files."
1917 MAKEFILE1="Makefile strings/Makefile passwd/Makefile tables/Makefile build/Makefile"
1918 SUBDIRS="strings passwd tables "
1919 for dir in $apr_modules
1920 do
1921     test -d $dir || $MKDIR $dir
1922     if test -f $srcdir/$dir/$OSDIR/Makefile.in; then
1923         MAKEFILE2="$MAKEFILE2 $dir/$OSDIR/Makefile "
1924         SUBDIRS="$SUBDIRS $dir/$OSDIR "
1925     else
1926         MAKEFILE2="$MAKEFILE2 $dir/$DEFAULT_OSDIR/Makefile "
1927         SUBDIRS="$SUBDIRS $dir/$DEFAULT_OSDIR "
1928     fi
1929 done
1930
1931 if test -d $srcdir/test; then
1932     MAKEFILE3="test/Makefile test/internal/Makefile"
1933 fi
1934 AC_SUBST(SUBDIRS)
1935
1936 #
1937 # BSD/OS (BSDi) needs to use a different include syntax in the Makefiles
1938 #
1939 case $host in
1940 *bsdi*)
1941     # Check whether they've installed GNU make
1942     if make --version > /dev/null 2>&1; then 
1943         INCLUDE_RULES="include $apr_buildout/apr_rules.mk"
1944     else
1945         # BSDi make
1946         INCLUDE_RULES=".include \"$apr_buildout/apr_rules.mk\""
1947     fi
1948     ;;
1949 *)
1950     INCLUDE_RULES="include $apr_buildout/apr_rules.mk"
1951     ;;
1952 esac
1953 AC_SUBST(INCLUDE_RULES)
1954
1955 SAVE_FILES="include/apr.h include/arch/unix/apr_private.h"
1956
1957 for i in $SAVE_FILES; do
1958   test -r $i && mv $i $i.save
1959 done
1960
1961 dir=include/arch/unix
1962 test -d $dir || $MKDIR $dir
1963
1964 AC_OUTPUT([
1965         $MAKEFILE1 $MAKEFILE2 $MAKEFILE3
1966         include/apr.h
1967         build/apr_rules.mk
1968         build/pkg/pkginfo
1969         apr-config
1970 ],[
1971 for i in $SAVE_FILES; do
1972   if cmp -s $i $i.save 2>/dev/null; then
1973     mv $i.save $i
1974     echo "$i is unchanged"
1975   fi
1976   rm -f $i.save
1977 done
1978 chmod +x apr-config
1979 ])
1980
1981 dnl ----------------------------- Fixup Makefiles for VPATH support
1982
1983 changequote({,})
1984
1985 if test -n "$USE_VPATH"; then
1986   for makefile in $MAKEFILE1 $MAKEFILE2 $MAKEFILE3; do
1987     cat $makefile | \
1988         sed \
1989                 -e 's#-I\($(INCDIR[0-9]*)\)#-I\1 -I$(srcdir)/\1#g' \
1990                 -e 's#-I\($(OSDIR[0-9]*)\)#-I\1 -I$(srcdir)/\1#g' \
1991                 -e 's#-I\($(DEFOSDIR[0-9]*)\)#-I\1 -I$(srcdir)/\1#g' \
1992                 > tmp
1993     cp tmp $makefile
1994   done
1995   rm -f tmp
1996 fi
1997
1998 changequote([,])