2 dnl Autoconf configuration file for APR
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.
7 AC_INIT(build/apr_common.m4)
8 AC_CONFIG_HEADER(include/arch/unix/apr_private.h)
9 AC_CONFIG_AUX_DIR(build)
12 dnl Include our own M4 macros along with those for libtool
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)
20 dnl Save user-defined environment settings for later restoration
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)
28 dnl Generate ./config.nice for reproducing runs of configure
30 APR_CONFIG_NICE(config.nice)
33 echo "Configuring APR library"
34 echo "Platform: $host"
36 dnl Some initial steps for configuration. We setup the default directory
37 dnl and which files are to be configured.
39 dnl Setup the directory macros now
41 # Absolute source/build directory
42 apr_srcdir=`(cd $srcdir && pwd)`
45 AC_SUBST(apr_builddir)
47 if test "$apr_builddir" != "$apr_srcdir"; then
49 APR_CONFIG_LOCATION=build
51 APR_CONFIG_LOCATION=source
54 AC_SUBST(APR_CONFIG_LOCATION)
56 # Libtool might need this symbol -- it must point to the location of
57 # the generated libtool script (not necessarily the "top" build dir).
59 top_builddir="$apr_builddir"
60 AC_SUBST(top_builddir)
62 # Directory containing apr build macros, helpers, and make rules
63 # NOTE: make rules (apr_rules.mk) will be in the builddir for vpath
65 apr_buildout=$apr_builddir/build
66 apr_builders=$apr_srcdir/build
67 AC_SUBST(apr_builders)
69 MKDIR=$apr_builders/mkdir.sh
71 dnl Initialize mkdir -p functionality.
72 APR_MKDIR_P_CHECK($apr_builders/mkdir.sh)
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`"
80 AC_SUBST(APR_DOTTED_VERSION)
81 AC_SUBST(APR_MAJOR_VERSION)
83 echo "APR Version: ${APR_DOTTED_VERSION}"
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)
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.
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.
104 dnl These added to allow default directories to be used...
106 echo "(Default will be ${DEFAULT_OSDIR})"
108 apr_modules="file_io network_io threadproc misc locks time mmap shmem user memory atomic poll support"
110 dnl Checks for programs.
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)
122 dnl Various OS checks that apparently set required flags
123 ifdef([AC_USE_SYSTEM_EXTENSIONS], [
124 AC_USE_SYSTEM_EXTENSIONS
133 dnl this is our library name
134 APR_LIBNAME="apr${libsuffix}"
135 AC_SUBST(APR_LIBNAME)
139 echo "performing libtool configuration..."
141 AC_ARG_ENABLE(experimental-libtool,[ --experimental-libtool Use experimental custom libtool (not included in source distribution)],
142 [experimental_libtool=$enableval],[experimental_libtool=no])
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
152 if test "x$LTFLAGS" = "x"; then
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.])
163 $CC $CFLAGS $CPPFLAGS -o $LIBTOOL $LIBTOOL_SRC
165 dnl libtoolize requires that the following not be indented
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
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)
180 AC_ARG_WITH(libtool, [ --without-libtool avoid using libtool to link the library],
181 [ use_libtool=$withval ], [ use_libtool="yes" ] )
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 \$@"
188 lib_target='-rpath $(libdir) $$objects'
189 export_lib_target='-rpath \$(libdir) \$\$objects'
191 lt_compile='$(COMPILE) -c $<'
192 link='$(AR) cr $(TARGET_LIB) $$objects; $(RANLIB) $(TARGET_LIB)'
200 apr_platform_runtime_link_flag="-R"
210 AC_SUBST(export_lib_target)
211 AC_SUBST(shlibpath_var)
215 dnl ----------------------------- Checks for compiler flags
218 echo "${nl}Check for compiler flags..."
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
227 if test "$ac_test_CFLAGS" != set; then
228 APR_REMOVEFROM(CFLAGS,-g)
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)
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)
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)
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
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`
303 APR_ADDTO(CPPFLAGS, -DAPR_POOL_DEBUG=$apr_pool_debug)
307 dnl Electric Fence malloc checker.
308 dnl --with-efence specifies the path to Electric Fence
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
316 [$apr_platform_runtime_link_flag$apr_efence_dir/lib])
319 AC_CHECK_LIB(efence, malloc,
320 [ APR_ADDTO(LIBS,-lefence) ],
321 [ AC_MSG_ERROR(Electric Fence requested but not detected) ])
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)
331 # this is the place to put specific options for platform/compiler
335 APR_ADDTO(CFLAGS,[-Ae +Z])
340 if echo "$CFLAGS " | grep '+DA' >/dev/null; then :
342 APR_ADDTO(CFLAGS,[+DAportable])
347 powerpc-*-beos:mwcc* )
348 APR_SETVAR(CPP,[mwcc -E])
354 dnl Check the depend program we can use
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
362 apr_force_atomic_generic=0
363 proc_mutex_is_global=0
364 nonportable_atomics_enabled=0
366 AC_ARG_ENABLE(nonportable-atomics,
367 [ --enable-nonportable-atomics Turn on optimized atomic code which may produce nonportable binaries],
369 if test "$enableval" = "yes"; then
370 nonportable_atomics_enabled=1
374 config_subdirs="none"
375 INSTALL_SUBDIRS="none"
377 i386-ibm-aix* | *-ibm-aix[[1-2]].* | *-ibm-aix3.* | *-ibm-aix4.1 | *-ibm-aix4.1.* | *-ibm-aix4.2 | *-ibm-aix4.2.*)
379 APR_ADDTO(LDFLAGS,-lld)
383 APR_ADDTO(CPPFLAGS,-DOS2)
384 APR_ADDTO(CFLAGS,-Zmt)
385 AC_CHECK_LIB(bsd, random)
387 enable_threads="system_threads"
390 proc_mutex_is_global=1
394 APR_ADDTO(CPPFLAGS,-DBEOS)
395 enable_threads="system_threads"
397 APR_CHECK_DEFINE(BONE_VERSION, sys/socket.h)
400 proc_mutex_is_global=1
420 APR_ADDTO(CPPFLAGS,-DCYGWIN)
425 apr_force_atomic_generic=1
428 if test "$nonportable_atomics_enabled" = 1; then
429 apr_force_atomic_generic=0
447 AC_SUBST(apr_force_atomic_generic)
448 AC_SUBST(proc_mutex_is_global)
450 AC_SUBST(INSTALL_SUBDIRS)
452 # For some platforms we need a version string which allows easy numeric
456 if test -x /sbin/sysctl; then
457 os_version=`/sbin/sysctl -n kern.osreldate`
463 os_version=`uname -r | sed -e 's/\(.\)\.\(.\)\.\(.\).*/\1\2\3/'`
466 os_version=`uname -r | sed -e 's/\(.\)\.\(.\).*/\1\2/'`
469 os_version=OS_VERSION_IS_NOT_SET
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)
487 dnl ----------------------------- Checking for Threads
488 echo "${nl}Checking for Threads..."
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" ] ) ] )
498 if test "$enable_threads" = "no"; then
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
508 APR_CHECK_PTHREADS_H([
512 AC_DEFINE(USE_THREADS, 1, [Define if APR supports threads]) ], [
516 APR_PTHREADS_CHECK_RESTORE ] )
517 elif test "$enable_threads" = "system_threads"; then
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
527 APR_CHECK_PTHREADS_H([
531 AC_DEFINE(USE_THREADS) ], [
535 APR_PTHREADS_CHECK_RESTORE ] )
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)
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])
553 # this might also require -DXOPEN_SOURCE=500, so leave after the
555 APR_CHECK_PTHREAD_RECURSIVE_MUTEX
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)
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])
574 if test "x$apr_gethostbyaddr_is_thread_safe" = "x"; then
575 AC_CHECK_LIB(c_r, gethostbyaddr, apr_gethostbyaddr_is_thread_safe=yes)
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])
581 AC_CHECK_FUNCS(gethostbyname_r gethostbyaddr_r)
583 echo "APR will be non-threaded"
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
597 AC_SUBST(have_sigsuspend)
598 AC_SUBST(have_sigwait)
602 dnl ----------------------------- Checking for missing POSIX thread functions
603 AC_CHECK_FUNCS([getpwnam_r getpwuid_r getgrnam_r getgrgid_r])
605 dnl ----------------------------- Checking for Shared Memory Support
606 echo "${nl}Checking for Shared Memory Support..."
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)
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>
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 \
623 APR_CHECK_DEFINE(MAP_ANON, sys/mman.h)
624 AC_CHECK_FILE(/dev/zero)
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)
631 #include <sys/types.h>
632 #include <sys/stat.h>
634 #ifdef HAVE_SYS_MMAN_H
635 #include <sys/mman.h>
641 fd = open("/dev/zero", O_RDWR);
645 m = mmap(0, sizeof(void*), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
646 if (m == (void *)-1) { /* aka MAP_FAILED */
649 if (munmap(m, sizeof(void*)) < 0) {
653 }], [], [ac_cv_file__dev_zero=no], [ac_cv_file__dev_zero=no])
655 AC_MSG_RESULT($ac_cv_file__dev_zero)
658 # Now we determine which one is our anonymous shmem preference.
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,
666 APR_DECIDE(USE_SHMEM_SHMGET_ANON, [SysV IPC shmget()])])
667 APR_IFALLYES(header:sys/mman.h func:mmap func:munmap file:/dev/zero,
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,
673 APR_DECIDE(USE_SHMEM_MMAP_ANON,
674 [4.4BSD-style mmap() via MAP_ANON])])
675 APR_IFALLYES(header:os2.h,
677 APR_DECIDE(USE_SHMEM_OS2_ANON, [OS/2 DosAllocSharedMem()])])
678 APR_IFALLYES(header:kernel/OS.h func:create_area,
680 APR_DECIDE(USE_SHMEM_BEOS_ANON,
684 # Linux has problems with MM_SHMT_MMANON even though it reports
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)
693 APR_DECISION_OVERRIDE(USE_SHMEM_SHMGET_ANON)
697 AC_DEFINE_UNQUOTED($ac_decision)
704 USE_SHMEM_SHMGET_ANON )
707 USE_SHMEM_MMAP_ZERO )
710 USE_SHMEM_MMAP_ANON )
715 AC_SUBST(useshmgetanon)
716 AC_SUBST(usemmapzero)
717 AC_SUBST(usemmapanon)
718 AC_SUBST(haveshmgetanon)
719 AC_SUBST(havemmapzero)
720 AC_SUBST(havemmapanon)
722 # Now we determine which one is our name-based shmem preference.
728 APR_BEGIN_DECISION([namebased memory allocation method])
729 APR_IFALLYES(header:sys/mman.h func:mmap func:munmap,
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
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,
741 APR_DECIDE(USE_SHMEM_SHMGET, [SysV IPC shmget()])])
742 APR_IFALLYES(header:kernel/OS.h func:create_area,
744 APR_DECIDE(USE_SHMEM_BEOS, [BeOS areas])])
745 APR_IFALLYES(header:os2.h,
747 APR_DECIDE(USE_SHMEM_OS2, [OS/2 DosAllocSharedMem()])])
750 # Linux has problems with MM_SHMT_MMANON even though it reports
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
761 AC_DEFINE_UNQUOTED($ac_decision)
787 # Do we have any shared memory support?
788 if test "$usemmaptmp$usemmapshm$usemmapzero$useshmget$usemmapanon$usebeosarea$useos2shm" = "0000000"; then
797 AC_SUBST(usebeosarea)
799 AC_SUBST(havemmaptmp)
800 AC_SUBST(havemmapshm)
802 AC_SUBST(havebeosarea)
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)
814 AC_CHECK_LIB(sendfile, sendfilev)
815 AC_CHECK_FUNCS(sendfile send_file sendfilev, [ sendfile="1" ])
816 AC_CHECK_FUNCS(utime utimes)
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.
822 AC_ARG_WITH(sendfile, [ --with-sendfile Override decision to use sendfile],
823 [ if test "$withval" = "yes"; then
828 orig_sendfile=$sendfile
831 # FreeBSD < 4.2 has issues with threads+sendfile
832 if test $os_version -le "401999"; then
833 if test "$threads" = "1"; then
842 # disable sendfile support for 2.2 on S/390
843 if test $os_version -lt 240; then
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
856 # darwin semantics in 9.0.0 appear to be fubar
860 if test "$orig_sendfile" != "$sendfile"; then
861 echo "sendfile support disabled to avoid system problem"
865 AC_CHECK_FUNCS(sigaction, [ have_sigaction="1" ], [ have_sigaction="0" ])
868 AC_CHECK_FUNCS(fork, [ fork="1" ], [ fork="0" ])
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
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
881 AC_CHECK_FUNCS(mmap, [ mmap="1" ], [ mmap="0" ])
882 if test "$native_mmap_emul" = "1"; then
885 AC_CHECK_FUNCS(memmove, [ have_memmove="1" ], [have_memmove="0" ])
886 AC_CHECK_FUNCS([getpass getpassphrase gmtime_r localtime_r hstrerror mkstemp])
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)
897 AC_SUBST(have_memmove)
899 APR_CHECK_SIGWAIT_ONE_ARG
900 APR_CHECK_DIRENT_INODE
901 APR_CHECK_DIRENT_TYPE
903 dnl ----------------------------- Checks for Any required Headers
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],
976 [#ifdef HAVE_NETINET_IN_H
977 #include <netinet/in.h>
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
983 AC_DEFINE([HAVE_NETINET_TCP_H], 1, [Defined if netinet/tcp.h is present])
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)
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)
1022 AC_SUBST(semaphoreh)
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])
1032 dnl ----------------------------- Checks for standard typedefs
1037 AC_CHECK_TYPE(ssize_t, int)
1047 dnl Checks for pointer size
1048 AC_CHECK_SIZEOF(void*, 4)
1050 if test "x$ac_cv_sizeof_voidp" != "x"; then
1051 voidp_size=$ac_cv_sizeof_voidp
1053 AC_ERROR([Cannot determine size of void*])
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)
1064 if test "$ac_cv_sizeof_short" = "2"; then
1067 if test "$ac_cv_sizeof_int" = "4"; then
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"'
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"'
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"
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'
1137 # If present, allow the C99 macro INT64_C to override our conversion.
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,
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>
1150 #endif], [apr_cv_define_INT64_C=yes], [apr_cv_define_INT64_C=no])])])
1152 if test "$apr_cv_define_INT64_C" = "yes"; then
1153 int64_literal='#define APR_INT64_C(val) INT64_C(val)'
1159 if test "$ac_cv_type_size_t" = "yes"; then
1160 size_t_value="size_t"
1162 size_t_value="apr_int32_t"
1164 if test "$ac_cv_type_ssize_t" = "yes"; then
1165 ssize_t_value="ssize_t"
1167 ssize_t_value="apr_int32_t"
1169 if test "$ac_cv_socklen_t" = "yes"; then
1170 socklen_t_value="socklen_t"
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"
1184 socklen_t_value="int"
1187 APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], ssize_t, 8)
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"'
1194 ssize_t_fmt='#error Can not determine the proper size for ssize_t'
1197 APR_CHECK_SIZEOF_EXTENDED([#include <stddef.h>], size_t, 8)
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"'
1204 size_t_fmt='#error Can not determine the proper size for size_t'
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.
1216 off_t_fmt='#define APR_OFF_T_FMT "ld"'
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'
1228 AC_ERROR([could not determine the size of off_t])
1231 AC_MSG_RESULT([$off_t_value])
1233 dnl define apr_ino_t in a manner independent of _FILE_OFFSET_BITS setting
1234 dnl default fallback
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")
1241 off_t_value='apr_int32_t'
1242 off_t_fmt='#define APR_OFF_T_FMT "d"'
1245 APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], pid_t, 8)
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'
1256 pid_t_fmt='#error Can not determine the proper size for pid_t'
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.
1267 size_t_fmt='#define APR_SIZE_T_FMT "ld"'
1272 size_t_fmt='#define APR_SIZE_T_FMT "lu"'
1275 pid_t_fmt='#define APR_PID_T_FMT "ld"'
1278 ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
1279 size_t_fmt='#define APR_SIZE_T_FMT "lu"'
1282 ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
1283 size_t_fmt='#define APR_SIZE_T_FMT "ld"'
1289 ssize_t_fmt='#define APR_SSIZE_T_FMT "d"'
1292 ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
1295 size_t_fmt='#define APR_SIZE_T_FMT "lu"'
1299 AC_SUBST(voidp_size)
1300 AC_SUBST(short_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)
1317 AC_SUBST(int64_literal)
1319 AC_SUBST(ino_t_value)
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")
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")
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)
1347 dnl ----------------------------- Checking for DSO support
1348 echo "${nl}Checking for DSO..."
1350 [ --disable-dso Disable DSO support ],
1351 [ tempdso=$enableval],
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) ],
1358 if test "$tempdso" = "no"; then
1359 AC_CHECK_FUNCS(dlopen, [ tempdso="dlfcn" ], [ tempdso="no" ])
1361 if test "$tempdso" = "no"; then
1362 AC_CHECK_LIB(dl, dlopen, [ tempdso="dlfcn" APR_ADDTO(LIBS,-ldl) ],
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) ],
1372 if test "$tempdso" = "no"; then
1373 echo "Weird: dlopen() was found but dlsym() was not found!"
1376 if test "$tempdso" = "no"; then
1377 AC_CHECK_LIB(root, load_image, tempdso="yes", tempdso="no")
1379 if test "$tempdso" = "no"; then
1381 *os390|*-os2*|*os400)
1388 if test "$tempdso" = "no"; then
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]);;
1397 apr_modules="$apr_modules dso"
1402 dnl ----------------------------- Checking for Processes
1403 echo "${nl}Checking for Processes..."
1405 AC_CHECK_FUNCS(waitpid)
1407 AC_ARG_ENABLE(other-child,
1408 [ --enable-other-child Enable reliable child processes ],
1409 [ if test "$enableval" = "yes"; then
1418 AC_MSG_CHECKING(for Variable Length Arrays)
1419 APR_TRY_COMPILE_NO_WARNING([],
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])
1429 AC_CACHE_CHECK(struct rlimit,ac_cv_struct_rlimit,[
1431 #include <sys/types.h>
1432 #include <sys/time.h>
1433 #include <sys/resource.h>
1436 struct rlimit limit;
1441 ac_cv_struct_rlimit=yes ], [
1442 ac_cv_struct_rlimit=no ], [
1443 ac_cv_struct_rlimit=no ] ) ] )
1445 test "x$ac_cv_struct_rlimit" = xyes && struct_rlimit=1
1446 AC_SUBST(struct_rlimit)
1448 dnl ----------------------------- Checking for Locking Characteristics
1449 echo "${nl}Checking for Locking..."
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)
1455 # Some systems return ENOSYS from sem_open.
1456 AC_CACHE_CHECK(for working sem_open,ac_cv_func_sem_open,[
1461 #include <semaphore.h>
1465 const char *sem_name = "/apr_autoconf";
1467 if (sizeof(int) < sizeof(sem_t *))
1469 psem = sem_open(sem_name, O_CREAT, 0644, 1);
1470 if (psem == (sem_t *)SEM_FAILED) {
1474 sem_unlink(sem_name);
1476 }], [ac_cv_func_sem_open=yes], [ac_cv_func_sem_open=no],
1477 [ac_cv_func_sem_open=no])])
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)
1482 #include <sys/types.h>
1483 #include <sys/ipc.h>
1484 #include <sys/sem.h>
1487 semctl(0, 0, 0, arg);
1488 ], [have_union_semun="1" union_semun=yes ]
1490 have_union_semun="0"
1492 AC_MSG_RESULT([$msg])
1493 AC_SUBST(have_union_semun)
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)
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)
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, [
1514 #include <sys/types.h>
1515 #include <pthread.h>
1518 pthread_mutex_t mutex;
1519 pthread_mutexattr_t attr;
1520 if (pthread_mutexattr_init(&attr))
1522 if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED))
1524 if (pthread_mutex_init(&mutex, &attr))
1526 if (pthread_mutexattr_destroy(&attr))
1528 if (pthread_mutex_destroy(&mutex))
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])
1535 if test "$ac_cv_func_pthread_mutexattr_setpshared" = "yes"; then
1536 APR_CHECK_PTHREAD_ROBUST_SHARED_MUTEX
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",
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
1552 hasprocpthreadser="1", hasprocpthreadser="0")
1553 APR_IFALLYES(struct:pthread_rw, hasrwlockser="1", hasrwlockser="0")
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)
1573 AC_DEFINE_UNQUOTED($ac_decision)
1580 case $ac_decision in
1581 USE_FLOCK_SERIALIZE )
1584 USE_FCNTL_SERIALIZE )
1587 USE_SYSVSEM_SERIALIZE )
1590 USE_POSIXSEM_SERIALIZE )
1593 USE_PROC_PTHREAD_SERIALIZE )
1598 AC_SUBST(hasflockser)
1599 AC_SUBST(hassysvser)
1600 AC_SUBST(hasposixser)
1601 AC_SUBST(hasfcntlser)
1602 AC_SUBST(hasprocpthreadser)
1603 AC_SUBST(hasrwlockser)
1608 AC_SUBST(procpthreadser)
1609 AC_SUBST(pthreadser)
1611 AC_MSG_CHECKING(if all interprocess locks affect threads)
1612 if test "x$apr_process_lock_is_global" = "xyes"; then
1620 AC_SUBST(proclockglobal)
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])
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])
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])
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])
1658 dnl ----------------------------- Checking for /dev/random
1659 AC_MSG_CHECKING(for entropy source)
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])
1668 AC_DEFINE_UNQUOTED(EGD_DEFAULT_SOCKET, ["$withval"])
1670 AC_MSG_RESULT(EGD-compatible daemon)
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" ])
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
1689 elif test "$apr_devrandom" != "no"; then
1690 if test -r "$apr_devrandom"; then
1693 AC_ERROR([$apr_devrandom not found or unreadable.])
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])
1703 if test "$rand" != "1"; then
1705 # we have built in support for OS/2
1707 AC_MSG_RESULT([Using OS/2 builtin random])
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)
1717 AC_MSG_RESULT(not found)
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)])
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])
1737 dnl ----------------------------- Checking for Networking Support
1738 echo "${nl}Checking for Networking support..."
1739 AC_MSG_CHECKING(for in_addr in netinet/in.h)
1741 #include <sys/types.h>
1742 #include <netinet/in.h>
1745 arg.s_addr = htonl(INADDR_ANY);
1746 ], [ have_in_addr="1"
1747 msg=yes ] , [ have_in_addr="0"
1749 AC_MSG_RESULT([$msg])
1751 AC_MSG_CHECKING([if fd == socket on this platform])
1752 if test "x$file_as_socket" != "x0" ; then
1759 AC_SUBST(have_in_addr)
1760 AC_SUBST(file_as_socket)
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
1767 APR_CHECK_TCP_NODELAY_INHERITED
1768 APR_CHECK_O_NONBLOCK_INHERITED
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"
1782 #include <linux/socket.h>
1787 apr_tcp_nopush_flag="3"
1788 have_corkable_tcp="1"
1795 if test "x$ac_cv_define_TCP_NOPUSH" = "xyes"; then
1796 apr_tcp_nopush_flag="TCP_NOPUSH"
1797 have_corkable_tcp="1"
1800 APR_CHECK_DEFINE(SO_ACCEPTFILTER, sys/socket.h)
1801 if test "x$ac_cv_define_SO_ACCEPTFILTER" = "xyes"; then
1809 AC_SUBST(apr_tcp_nopush_flag)
1810 AC_SUBST(have_corkable_tcp)
1811 AC_SUBST(acceptfilter)
1814 AC_CHECK_FUNCS(set_h_errno)
1815 APR_CHECK_RESOLV_RETRANS
1817 echo "${nl}Checking for IPv6 Networking support..."
1818 dnl Start of checking for IPv6 support...
1821 [ --disable-ipv6 Disable IPv6 support in APR.],
1822 [ if test "$enableval" = "no"; then
1823 user_disabled_ipv6=1
1825 [ user_disabled_ipv6=0 ] )
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
1842 if test "$user_disabled_ipv6" = 1; then
1843 ipv6_result="no -- disabled by user"
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
1852 ipv6_result="no -- no getnameinfo"
1855 ipv6_result="no -- no working getaddrinfo"
1858 ipv6_result="no -- no sockaddr_in6"
1861 ipv6_result="no -- the platform has known problems supporting IPv6"
1865 AC_MSG_CHECKING(if APR supports IPv6)
1866 AC_MSG_RESULT($ipv6_result)
1870 dnl Check for langinfo support
1872 AC_CHECK_HEADERS(langinfo.h)
1873 AC_CHECK_FUNCS(nl_langinfo)
1875 dnl Random late checks...
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])
1891 dnl ----------------------------- Finalize the variables
1893 echo "${nl}Restore user-defined environment settings..."
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)
1906 dnl ----------------------------- Construct the files
1912 AC_SUBST(DEFAULT_OSDIR)
1914 AC_SUBST(LIBTOOL_LIBS)
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
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 "
1926 MAKEFILE2="$MAKEFILE2 $dir/$DEFAULT_OSDIR/Makefile "
1927 SUBDIRS="$SUBDIRS $dir/$DEFAULT_OSDIR "
1931 if test -d $srcdir/test; then
1932 MAKEFILE3="test/Makefile test/internal/Makefile"
1937 # BSD/OS (BSDi) needs to use a different include syntax in the Makefiles
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"
1946 INCLUDE_RULES=".include \"$apr_buildout/apr_rules.mk\""
1950 INCLUDE_RULES="include $apr_buildout/apr_rules.mk"
1953 AC_SUBST(INCLUDE_RULES)
1955 SAVE_FILES="include/apr.h include/arch/unix/apr_private.h"
1957 for i in $SAVE_FILES; do
1958 test -r $i && mv $i $i.save
1961 dir=include/arch/unix
1962 test -d $dir || $MKDIR $dir
1965 $MAKEFILE1 $MAKEFILE2 $MAKEFILE3
1971 for i in $SAVE_FILES; do
1972 if cmp -s $i $i.save 2>/dev/null; then
1974 echo "$i is unchanged"
1981 dnl ----------------------------- Fixup Makefiles for VPATH support
1985 if test -n "$USE_VPATH"; then
1986 for makefile in $MAKEFILE1 $MAKEFILE2 $MAKEFILE3; do
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' \