configure.in 82.2 KB
Newer Older
powelld's avatar
powelld committed
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917
AC_SUBST(off_t_fmt) 
AC_SUBST(pid_t_fmt)
AC_SUBST(int64_literal) 
AC_SUBST(uint64_literal) 
AC_SUBST(stdint) 
AC_SUBST(bigendian)
AC_SUBST(aprlfs)
AC_SUBST(have_iovec)
AC_SUBST(ino_t_value)

dnl ----------------------------- Checking for string functions
AC_CHECK_FUNCS(strnicmp, have_strnicmp="1", have_strnicmp="0")
AC_CHECK_FUNCS(strncasecmp, have_strncasecmp="1", have_strncasecmp="0")
AC_CHECK_FUNCS(stricmp, have_stricmp="1", have_stricmp="0")
AC_CHECK_FUNCS(strcasecmp, have_strcasecmp="1", have_strcasecmp="0")
AC_CHECK_FUNCS(strdup, have_strdup="1", have_strdup="0")
AC_CHECK_FUNCS(strstr, have_strstr="1", have_strstr="0")
AC_CHECK_FUNCS(memchr, have_memchr="1", have_memchr="0")
AC_CHECK_FUNC($int64_strfn, have_int64_strfn="1", have_int64_strfn="0")

dnl ----------------------------- We have a fallback position
if test "$have_int64_strfn" = "0" && test "$int64_strfn" = "strtoll"; then
    int64_strfn="strtoq"
    AC_CHECK_FUNC(strtoq, [have_int64_strfn=1], [have_int64_strfn=0])
fi

if test "$have_int64_strfn" = "1"; then
  AC_DEFINE_UNQUOTED(APR_INT64_STRFN, [$int64_strfn],
      [Define as function which can be used for conversion of strings to apr_int64_t])
fi

AC_SUBST(have_strnicmp)
AC_SUBST(have_strncasecmp)
AC_SUBST(have_stricmp)
AC_SUBST(have_strcasecmp)
AC_SUBST(have_strdup)
AC_SUBST(have_strstr)
AC_SUBST(have_memchr)

if test "$off_t_strfn" = "apr_strtoi64" && test "$have_int64_strfn" = "1"; then
    off_t_strfn=$int64_strfn
fi
AC_DEFINE_UNQUOTED(APR_OFF_T_STRFN, [$off_t_strfn],
          [Define as function used for conversion of strings to apr_off_t])

dnl ----------------------------- Checking for DSO support
echo "${nl}Checking for DSO..."
AC_ARG_ENABLE(dso,
  [  --disable-dso           Disable DSO support ],
  [if test "x$enableval" = "xyes"; then
      dsotype=any
   else
      dsotype=$enableval
   fi
  ], [dsotype=any])

if test "$dsotype" = "any"; then
    if test "$dsotype" = "any"; then
      case $host in
        *darwin[[0-8]]\.*) 
          # Original Darwin, not for 9.0!:
          AC_CHECK_FUNC(NSLinkModule, [dsotype=dyld]);;
        hppa*-hpux[[1-9]]\.*|hppa*-hpux1[[01]]*)
          # shl is specific to parisc hpux SOM binaries, not used for 64 bit
          AC_CHECK_LIB(dld, shl_load, [have_shl=1])
          if test "$ac_cv_sizeof_voidp$have_shl" = "41"; then
            dsotype=shl; APR_ADDTO(LIBS,-ldld)
          fi;;
        *mingw*|*-os2*)
          # several 'other's below probably belong up here.  If they always
          # use a platform implementation and shouldn't test the dlopen/dlfcn
          # features, then bring them up here.
          # But if they -should- optionally use dlfcn, and/or need the config
          # detection of dlopen/dlsym, do not move them up.
          dsotype=other ;;
      esac
    fi
    # Normal POSIX:
    if test "$dsotype" = "any"; then
      AC_CHECK_FUNC(dlopen, [dsotype=dlfcn])
    fi
    if test "$dsotype" = "any"; then
      AC_CHECK_LIB(dl, dlopen, [dsotype=dlfcn; APR_ADDTO(LIBS,-ldl)])
    fi
    if test "$dsotype" = "dlfcn"; then
        # ReliantUnix has dlopen() in libc but dlsym() in libdl :(
        AC_CHECK_FUNC(dlsym, [], 
          [AC_CHECK_LIB(dl, dlsym, 
             [APR_ADDTO(LIBS, -ldl)],
             [dsotype=any
              echo "Weird: dlopen() was found but dlsym() was not found!"])])
    fi
    if test "$dsotype" = "any"; then
      # BeOS:
      AC_CHECK_LIB(root, load_image, [dsotype=other])
    fi
    # Everything else:
    if test "$dsotype" = "any"; then
        case $host in
        *os390|*os400|*-aix*)
          # Some -aix5 will use dl, no hassles.  Keep that pattern here.
          dsotype=other ;;
        *-hpux*)
          if test "$have_shl" = "1"; then
            dsotype=shl; APR_ADDTO(LIBS,-ldld)
          fi;;
        esac
    fi
fi

if test "$dsotype" = "any"; then
    AC_MSG_ERROR([Could not detect suitable DSO implementation])
elif test "$dsotype" = "no"; then
    aprdso="0"
else
    case "$dsotype" in
    dlfcn) AC_DEFINE(DSO_USE_DLFCN, 1, [Define if DSO support uses dlfcn.h]);;
    shl)   AC_DEFINE(DSO_USE_SHL, 1, [Define if DSO support uses shl_load]);;
    dyld)  AC_DEFINE(DSO_USE_DYLD, 1, [Define if DSO support uses dyld.h]);;
    other) ;; # Use whatever is in dso/OSDIR
    *) AC_MSG_ERROR([Unknown DSO implementation "$dsotype"]);;
    esac
    aprdso="1"
    apr_modules="$apr_modules dso"
fi

AC_SUBST(aprdso)

dnl ----------------------------- Checking for Processes
echo "${nl}Checking for Processes..."

AC_CHECK_FUNCS(waitpid)

AC_ARG_ENABLE(other-child,
  [  --enable-other-child    Enable reliable child processes ],
  [ if test "$enableval" = "yes"; then
        oc="1"
    else
        oc="0"
    fi ],
  [ oc=1 ] ) 
  
AC_SUBST(oc) 

if test -z "$have_proc_invoked"; then
  have_proc_invoked="0"
fi

AC_SUBST(have_proc_invoked)

AC_MSG_CHECKING(for Variable Length Arrays)
APR_TRY_COMPILE_NO_WARNING([],
[
    int foo[argc];
    foo[0] = 0;
], vla_msg=yes, vla_msg=no )
AC_MSG_RESULT([$vla_msg])
if test "$vla_msg" = "yes"; then
    AC_DEFINE(HAVE_VLA, 1, [Define if C compiler supports VLA])
fi

AC_CACHE_CHECK(struct rlimit,ac_cv_struct_rlimit,[
AC_TRY_RUN([
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
main()
{
    struct rlimit limit;
    limit.rlim_cur = 0;
    limit.rlim_max = 0;
    exit(0);
}], [
    ac_cv_struct_rlimit=yes ], [
    ac_cv_struct_rlimit=no ], [
    ac_cv_struct_rlimit=no ] ) ] )
struct_rlimit=0
test "x$ac_cv_struct_rlimit" = xyes && struct_rlimit=1
AC_SUBST(struct_rlimit)

dnl ----------------------------- Checking for Locking Characteristics 
echo "${nl}Checking for Locking..."

AC_CHECK_FUNCS(semget semctl flock)
AC_CHECK_HEADERS(semaphore.h OS.h)
AC_SEARCH_LIBS(sem_open, rt)
AC_CHECK_FUNCS(sem_close sem_unlink sem_post sem_wait create_sem)

# Some systems return ENOSYS from sem_open.
AC_CACHE_CHECK(for working sem_open,ac_cv_func_sem_open,[
AC_TRY_RUN([
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <semaphore.h>
#ifndef SEM_FAILED
#define SEM_FAILED (-1)
#endif
main()
{
    sem_t *psem;
    const char *sem_name = "/apr_autoconf";

    psem = sem_open(sem_name, O_CREAT, 0644, 1);
    if (psem == (sem_t *)SEM_FAILED) {
	exit(1);
    }
    sem_close(psem);
    psem = sem_open(sem_name, O_CREAT | O_EXCL, 0644, 1);
    if (psem != (sem_t *)SEM_FAILED) {
        sem_close(psem);
        exit(1);
    }
    sem_unlink(sem_name);
    exit(0);
}], [ac_cv_func_sem_open=yes], [ac_cv_func_sem_open=no],
[ac_cv_func_sem_open=no])])

# It's stupid, but not all platforms have union semun, even those that need it.
AC_MSG_CHECKING(for union semun in sys/sem.h)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
],[
union semun arg;
semctl(0, 0, 0, arg);
], [have_union_semun="1" union_semun=yes ]
msg=yes, [
have_union_semun="0"
msg=no ] )
AC_MSG_RESULT([$msg])
AC_SUBST(have_union_semun)

dnl Checks for libraries.
APR_CHECK_DEFINE(LOCK_EX, sys/file.h)
APR_CHECK_DEFINE(F_SETLK, fcntl.h)
APR_CHECK_DEFINE(SEM_UNDO, sys/sem.h)

# We are assuming that if the platform doesn't have POLLIN, it doesn't have
# any POLL definitions.
APR_CHECK_DEFINE_FILES(POLLIN, poll.h sys/poll.h)

if test "$threads" = "1"; then
    APR_CHECK_DEFINE(PTHREAD_PROCESS_SHARED, pthread.h)
    AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
    # Some systems have setpshared and define PROCESS_SHARED, but don't 
    # really support PROCESS_SHARED locks.  So, we must validate that we 
    # can go through the steps without receiving some sort of system error.
    # Linux and older versions of AIX have this problem.
    APR_IFALLYES(header:pthread.h define:PTHREAD_PROCESS_SHARED func:pthread_mutexattr_setpshared, [
      AC_CACHE_CHECK([for working PROCESS_SHARED locks], apr_cv_process_shared_works, [
      AC_TRY_RUN([
#include <sys/types.h>
#include <pthread.h>
        int main()
        {
            pthread_mutex_t mutex;
            pthread_mutexattr_t attr;
            if (pthread_mutexattr_init(&attr))
                exit(1);
            if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED))
                exit(2);
            if (pthread_mutex_init(&mutex, &attr))
                exit(3);
            if (pthread_mutexattr_destroy(&attr))
                exit(4);
            if (pthread_mutex_destroy(&mutex))
                exit(5);
            exit(0);
        }], [apr_cv_process_shared_works=yes], [apr_cv_process_shared_works=no])])
      # Override detection of pthread_mutexattr_setpshared
      ac_cv_func_pthread_mutexattr_setpshared=$apr_cv_process_shared_works])

    if test "$ac_cv_func_pthread_mutexattr_setpshared" = "yes"; then
        APR_CHECK_PTHREAD_ROBUST_SHARED_MUTEX
    fi
fi

# See which lock mechanisms we can support on this system.
APR_IFALLYES(header:semaphore.h func:sem_open func:sem_close dnl
             func:sem_unlink func:sem_post func:sem_wait,
             hasposixser="1", hasposixser="0")
APR_IFALLYES(func:semget func:semctl define:SEM_UNDO, hassysvser="1", 
             hassysvser="0")
APR_IFALLYES(func:flock define:LOCK_EX, hasflockser="1", hasflockser="0")
APR_IFALLYES(header:fcntl.h define:F_SETLK, hasfcntlser="1", hasfcntlser="0")
# note: the current APR use of shared mutex requires /dev/zero
APR_IFALLYES(header:pthread.h define:PTHREAD_PROCESS_SHARED dnl
             func:pthread_mutexattr_setpshared dnl
             file:/dev/zero,
             hasprocpthreadser="1", hasprocpthreadser="0")
APR_IFALLYES(header:OS.h func:create_sem, hasbeossem="1", hasbeossem="0")

# See which lock mechanism we'll select by default on this system.
# The last APR_DECIDE to execute sets the default.
# At this stage, we match the ordering in Apache 1.3
# which is (highest to lowest): sysvsem -> fcntl -> flock.
# POSIX semaphores and cross-process pthread mutexes are not
# used by default since they have less desirable behaviour when
# e.g. a process holding the mutex segfaults.
# The BEOSSEM decision doesn't require any substitutions but is
# included here to prevent the fcntl() branch being selected
# from the decision making.
APR_BEGIN_DECISION([apr_lock implementation method])
APR_IFALLYES(func:flock define:LOCK_EX,
            APR_DECIDE(USE_FLOCK_SERIALIZE, [4.2BSD-style flock()]))
APR_IFALLYES(header:fcntl.h define:F_SETLK,
            APR_DECIDE(USE_FCNTL_SERIALIZE, [SVR4-style fcntl()]))
APR_IFALLYES(func:semget func:semctl define:SEM_UNDO,
            APR_DECIDE(USE_SYSVSEM_SERIALIZE, [SysV IPC semget()]))
APR_IFALLYES(header:OS.h func:create_sem, 
            APR_DECIDE(USE_BEOSSEM, [BeOS Semaphores])) 
if test "x$apr_lock_method" != "x"; then
    APR_DECISION_FORCE($apr_lock_method)
fi
APR_END_DECISION
AC_DEFINE_UNQUOTED($ac_decision)

flockser="0"
sysvser="0"
posixser="0"
procpthreadser="0"
fcntlser="0"
case $ac_decision in
    USE_FLOCK_SERIALIZE )
        flockser="1"
        ;;
    USE_FCNTL_SERIALIZE )
        fcntlser="1"
        ;;
    USE_SYSVSEM_SERIALIZE )
        sysvser="1"
        ;;
    USE_POSIXSEM_SERIALIZE )
        posixser="1"
        ;;
    USE_PROC_PTHREAD_SERIALIZE )
        procpthreadser="1"
        ;;
    USE_BEOSSEM )
        beossem="1"
        ;;
esac

if test $hasfcntlser = "1"; then
AC_MSG_CHECKING(if fcntl returns EACCES when F_SETLK is already held)
AC_TRY_RUN([
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#include <fcntl.h>
#include <errno.h>

int fd;
struct flock proc_mutex_lock_it = {0};
const char *fname = "conftest.fcntl";

int main()
{
    int rc, status;;
    proc_mutex_lock_it.l_whence = SEEK_SET;   /* from current point */
    proc_mutex_lock_it.l_type = F_WRLCK;      /* set exclusive/write lock */

    fd = creat(fname, S_IRWXU);
    unlink(fname);

    if (rc = lockit()) {
        exit(-1);
    }

    if (fork()) {
        wait(&status);
    }
    else {
      return(lockit());
    }

    close(fd);
    exit(WEXITSTATUS(status) != EACCES);
}

int lockit() {
    int rc;
    do {
        rc = fcntl(fd, F_SETLK, &proc_mutex_lock_it);
    } while ( rc < 0 && errno == EINTR);

    return (rc < 0) ? errno : 0;
}], [apr_fcntl_tryacquire_eacces=1], [apr_fcntl_tryacquire_eacces=0], [apr_fcntl_tryacquire_eacces=0])
fi

if test "$apr_fcntl_tryacquire_eacces" = "1"; then
  AC_DEFINE(FCNTL_TRYACQUIRE_EACCES, 1, [Define if fcntl returns EACCES when F_SETLK is already held])
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi


AC_SUBST(hasflockser)
AC_SUBST(hassysvser)
AC_SUBST(hasposixser)
AC_SUBST(hasfcntlser)
AC_SUBST(hasprocpthreadser)
AC_SUBST(flockser)
AC_SUBST(sysvser)
AC_SUBST(posixser)
AC_SUBST(fcntlser)
AC_SUBST(procpthreadser)
AC_SUBST(pthreadser)

AC_MSG_CHECKING(if all interprocess locks affect threads)
if test "x$apr_process_lock_is_global" = "xyes"; then
    proclockglobal="1"
    AC_MSG_RESULT(yes)
else
    proclockglobal="0"
    AC_MSG_RESULT(no)
fi

AC_SUBST(proclockglobal)

AC_MSG_CHECKING(if POSIX sems affect threads in the same process)
if test "x$apr_posixsem_is_global" = "xyes"; then
  AC_DEFINE(POSIXSEM_IS_GLOBAL, 1, 
            [Define if POSIX semaphores affect threads within the process])
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(if SysV sems affect threads in the same process)
if test "x$apr_sysvsem_is_global" = "xyes"; then
  AC_DEFINE(SYSVSEM_IS_GLOBAL, 1,
            [Define if SysV semaphores affect threads within the process])
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(if fcntl locks affect threads in the same process)
if test "x$apr_fcntl_is_global" = "xyes"; then
  AC_DEFINE(FCNTL_IS_GLOBAL, 1,
            [Define if fcntl locks affect threads within the process])
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(if flock locks affect threads in the same process)
if test "x$apr_flock_is_global" = "xyes"; then
  AC_DEFINE(FLOCK_IS_GLOBAL, 1,
            [Define if flock locks affect threads within the process])
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

dnl ----------------------------- Checking for /dev/random 
AC_MSG_CHECKING(for entropy source)

why_no_rand=""

AC_ARG_WITH(egd, 
  [  --with-egd[[=DIR]]        use EGD-compatible socket],
  [ AC_DEFINE(HAVE_EGD, 1, [Define if EGD is supported])
    if test "$withval" = "yes"; then
        AC_DEFINE_UNQUOTED(EGD_DEFAULT_SOCKET, ["/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"], 
         [Define to list of paths to EGD sockets])
    else
        AC_DEFINE_UNQUOTED(EGD_DEFAULT_SOCKET, ["$withval"])
    fi
    AC_MSG_RESULT(EGD-compatible daemon)
    rand="1"
  ])

if test "$rand" != "1"; then
  AC_ARG_WITH(devrandom,
    [  --with-devrandom[[=DEV]]  use /dev/random or compatible [[searches by default]]],
    [ apr_devrandom="$withval" ], [ apr_devrandom="yes" ])

  if test "$apr_devrandom" = "yes"; then
    # /dev/random on OpenBSD doesn't provide random data, so
    # prefer /dev/arandom, which does; see random(4).
    for f in /dev/arandom /dev/urandom /dev/random; do
      if test -r $f; then
        apr_devrandom=$f
        rand=1
        break
      fi
    done
  elif test "$apr_devrandom" != "no"; then
    if test -r "$apr_devrandom"; then
      rand="1"
    else
      AC_ERROR([$apr_devrandom not found or unreadable.])
    fi
  fi

  if test "$rand" = "1"; then
    case $host in
      *os390)
        if test $os_version -lt 1700; then
          rand="0"
          why_no_rand=" ($apr_devrandom unusable on z/OS before V1R7)"
        fi
        ;;
    esac
  fi

  if test "$rand" = "1"; then
    AC_DEFINE_UNQUOTED(DEV_RANDOM, ["$apr_devrandom"], [Define to path of random device])
    AC_MSG_RESULT([$apr_devrandom])
  fi
fi

if test "$rand" != "1"; then
    case $host in
        # we have built in support for OS/2
        *-os2*)
            AC_MSG_RESULT([Using OS/2 builtin random])
            rand="1"
            ;;
        *)
            if test "$rand" != "1"; then
              if test "$ac_cv_lib_truerand_main" = "yes"; then
                AC_DEFINE(HAVE_TRUERAND, 1, [Define if truerand is supported])
                AC_MSG_RESULT(truerand)
                rand="1"
              else
                AC_MSG_RESULT(not found$why_no_rand)
                rand="0"
              fi
            fi
            ;;
    esac
fi

AC_SUBST(rand)

dnl ----------------------------- Checking for File Info Support 
echo "${nl}Checking for File Info Support..."
AC_CHECK_MEMBERS([struct stat.st_blocks, struct stat.st_atimensec,
struct stat.st_ctimensec, struct stat.st_mtimensec, struct stat.st_atim.tv_nsec,
struct stat.st_ctim.tv_nsec, struct stat.st_mtim.tv_nsec,
struct stat.st_atime_n, struct stat.st_ctime_n, struct stat.st_mtime_n],,,[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif])

APR_CHECK_DIRENT_INODE
APR_CHECK_DIRENT_TYPE

dnl ----------------------------- Checking for UUID Support 
echo "${nl}Checking for OS UUID Support..."

AC_CHECK_HEADERS(uuid.h uuid/uuid.h sys/uuid.h, break)

apr_revert_save_LIBS=$LIBS

# Prefer the flavor(s) that live in libc;
AC_SEARCH_LIBS(uuid_create, uuid)
AC_SEARCH_LIBS(uuid_generate, uuid)
if test "$ac_cv_search_uuid_create" = "none required" -o \
        "$ac_cv_search_uuid_generate" = "none required"; then
 LIBS=$apr_revert_save_LIBS
fi

AC_CHECK_FUNCS(uuid_create uuid_generate)

AC_CACHE_CHECK([for os uuid usability], [apr_cv_osuuid], [
# Ensure this test closely mirrors misc/unix/rand.c!
uuid_includes="
#if defined(HAVE_SYS_TYPES_H)
#include <sys/types.h>
#endif
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#if defined(HAVE_UUID_H)
#include <uuid.h>
#elif defined(HAVE_UUID_UUID_H)
#include <uuid/uuid.h>
#elif defined(HAVE_SYS_UUID_H)
#include <sys/uuid.h>
#endif
"
 apr_cv_osuuid=no
 if test $ac_cv_func_uuid_create = yes; then
  AC_TRY_LINK([$uuid_includes], [
    uuid_t g;
    uint32_t s;
    uuid_create(&g, &s);
    if (s == uuid_s_ok) s = 0;
  ], [apr_cv_osuuid=yes], [apr_cv_func_uuid_create=no])
 fi
 if test $ac_cv_func_uuid_generate = yes; then
  AC_TRY_LINK([$uuid_includes], [
    uuid_t g;
    uuid_generate(g);
  ], [apr_cv_osuuid=yes], [apr_cv_func_uuid_generate=no])
 fi 
])

if test $apr_cv_osuuid = yes; then
  osuuid="1"
else
  osuuid="0"
  LIBS=$apr_revert_save_LIBS
fi
AC_SUBST(osuuid)


dnl ----------------------------- Checking for Time Support 
echo "${nl}Checking for Time Support..."

AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.__tm_gmtoff],,,[
#include <sys/types.h>
#include <time.h>])

dnl ----------------------------- Checking for Networking Support 
echo "${nl}Checking for Networking support..."
APR_TYPE_IN_ADDR
if test "$ac_cv_type_in_addr" = "yes"; then
  have_in_addr="1"
else
  have_in_addr="0"
fi

AC_MSG_CHECKING([if fd == socket on this platform])
if test "x$file_as_socket" != "x0" ; then
    file_as_socket="1";
    echo "yes"
else
    echo "no"
fi

AC_SUBST(have_in_addr)
AC_SUBST(file_as_socket)

if test "$ac_cv_func_poll $file_as_socket" = "yes 1"; then
    AC_DEFINE(WAITIO_USES_POLL, 1,
              [Define if apr_wait_for_io_or_timeout() uses poll(2)])
fi

# Check the types only if we have gethostbyname_r
if test "$ac_cv_func_gethostbyname_r" = "yes"; then
    APR_CHECK_GETHOSTBYNAME_R_STYLE
fi

# Check the types only if we have getservbyname_r
if test "$ac_cv_func_getservbyname_r" = "yes"; then
    APR_CHECK_GETSERVBYNAME_R_STYLE
fi

APR_CHECK_TCP_NODELAY_INHERITED
APR_CHECK_O_NONBLOCK_INHERITED
APR_CHECK_TCP_NODELAY_WITH_CORK

# Look for a way of corking TCP...
APR_CHECK_DEFINE(TCP_CORK, netinet/tcp.h)
APR_CHECK_DEFINE(TCP_NOPUSH, netinet/tcp.h)
apr_tcp_nopush_flag="0"
have_corkable_tcp="0"
if test "x$ac_cv_define_TCP_CORK" = "xyes"; then
    apr_tcp_nopush_flag="TCP_CORK"
    have_corkable_tcp="1"
else
    case $host in
        *linux*)
            AC_EGREP_CPP(yes,[
#include <linux/socket.h>
#ifdef TCP_CORK
yes
#endif
            ],[
                apr_tcp_nopush_flag="3"
                have_corkable_tcp="1"
            ])
            ;;
        *)
            ;;
    esac
fi
if test "x$ac_cv_define_TCP_NOPUSH" = "xyes"; then
    apr_tcp_nopush_flag="TCP_NOPUSH"
    have_corkable_tcp="1"
fi

APR_CHECK_DEFINE(SO_ACCEPTFILTER, sys/socket.h)
if test "x$ac_cv_define_SO_ACCEPTFILTER" = "xyes"; then
    acceptfilter="1"
else
    acceptfilter="0"
fi

APR_CHECK_SCTP
APR_CHECK_MCAST

AC_SUBST(apr_tcp_nopush_flag)
AC_SUBST(have_corkable_tcp)
AC_SUBST(acceptfilter)
AC_SUBST(have_sctp)

AC_CHECK_FUNCS(set_h_errno)

echo "${nl}Checking for IPv6 Networking support..."
dnl Start of checking for IPv6 support...

AC_ARG_ENABLE(ipv6,
  [  --disable-ipv6          Disable IPv6 support in APR.],
  [ if test "$enableval" = "no"; then
        user_disabled_ipv6=1
    fi ],
  [ user_disabled_ipv6=0 ] )

case $host in
  *)
    broken_ipv6=0
esac

AC_SEARCH_LIBS(getaddrinfo, socket inet6)
AC_SEARCH_LIBS(gai_strerror, socket inet6)
AC_SEARCH_LIBS(getnameinfo, socket inet6)
AC_CHECK_FUNCS(gai_strerror)
APR_CHECK_WORKING_GETADDRINFO
APR_CHECK_NEGATIVE_EAI
APR_CHECK_WORKING_GETNAMEINFO
APR_CHECK_SOCKADDR_IN6
APR_CHECK_SOCKADDR_STORAGE
APR_CHECK_SOCKADDR_UN

have_ipv6="0"
if test "$user_disabled_ipv6" = 1; then
    ipv6_result="no -- disabled by user"
else
    if test "x$broken_ipv6" = "x0"; then
        if test "x$have_sockaddr_in6" = "x1"; then
            if test "x$ac_cv_working_getaddrinfo" = "xyes"; then
                if test "x$ac_cv_working_getnameinfo" = "xyes"; then
                    APR_CHECK_GETADDRINFO_ADDRCONFIG
                    have_ipv6="1"
                    ipv6_result="yes"
                else
                    ipv6_result="no -- no getnameinfo"
                fi
            else
                ipv6_result="no -- no working getaddrinfo"
            fi
        else
            ipv6_result="no -- no sockaddr_in6"
        fi
    else
        ipv6_result="no -- the platform has known problems supporting IPv6"
    fi
fi

AC_MSG_CHECKING(if APR supports IPv6)
AC_MSG_RESULT($ipv6_result)

AC_SUBST(have_ipv6)

# hstrerror is only needed if IPv6 is not enabled,
# so getaddrinfo/gai_strerror are not used.
if test $have_ipv6 = 0; then
  AC_SEARCH_LIBS(hstrerror, resolv,
    [AC_DEFINE(HAVE_HSTRERROR, 1, [Define if hstrerror is present])])
fi

dnl Check for langinfo support

AC_CHECK_HEADERS(langinfo.h)
AC_CHECK_FUNCS(nl_langinfo)

dnl ------------------------------ Defaults for some platform nuances

dnl Do we have a Win32-centric Unicode FS?
APR_SETIFNULL(have_unicode_fs, [0])
AC_SUBST(have_unicode_fs)

APR_SETIFNULL(apr_has_xthread_files, [0])
AC_SUBST(apr_has_xthread_files)

APR_SETIFNULL(apr_procattr_user_set_requires_password, [0])
AC_SUBST(apr_procattr_user_set_requires_password)

APR_SETIFNULL(apr_thread_func, [])
AC_SUBST(apr_thread_func)

APR_SETIFNULL(apr_has_user, [1])
AC_SUBST(apr_has_user)

dnl ----------------------------- Finalize the variables

echo "${nl}Restore user-defined environment settings..."

APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(CFLAGS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(LIBS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(INCLUDES, EXTRA_)
AC_SUBST(NOTEST_CPPFLAGS)
AC_SUBST(NOTEST_CFLAGS)
AC_SUBST(NOTEST_LDFLAGS)
AC_SUBST(NOTEST_LIBS)
AC_SUBST(NOTEST_INCLUDES)

dnl ----------------------------- Construct the files

AC_SUBST(INTERNAL_CPPFLAGS)
AC_SUBST(LDLIBS)
AC_SUBST(INCLUDES)
AC_SUBST(AR)
AC_SUBST(RM)
AC_SUBST(OSDIR)
AC_SUBST(DEFAULT_OSDIR)
AC_SUBST(EXEEXT)
AC_SUBST(LIBTOOL_LIBS)

# Use -no-install or -no-fast-install to link the test 
# programs on all platforms but Darwin, where it would cause
# the programs to be linked against installed versions of
# libapr instead of those just built.
case $host in
    *-apple-darwin*)
        LT_NO_INSTALL=""
        ;;
    *-mingw*)
        LT_NO_INSTALL="-no-fast-install"
        ;;
    *)
        LT_NO_INSTALL="-no-install"
        ;;
esac
AC_SUBST(LT_NO_INSTALL)

#
# BSD/OS (BSDi) needs to use a different include syntax in the Makefiles
#
case $host in
*bsdi*)
    # Check whether they've installed GNU make
    if make --version > /dev/null 2>&1; then 
	INCLUDE_RULES="include $apr_buildout/apr_rules.mk"
	INCLUDE_OUTPUTS="include $apr_srcdir/build-outputs.mk"
    else
	# BSDi make
	INCLUDE_RULES=".include \"$apr_buildout/apr_rules.mk\""
	INCLUDE_OUTPUTS=".include \"$apr_srcdir/build-outputs.mk\""
    fi
    ;;
*)
    INCLUDE_RULES="include $apr_buildout/apr_rules.mk"
    INCLUDE_OUTPUTS="include $apr_srcdir/build-outputs.mk"
    ;;
esac
AC_SUBST(INCLUDE_RULES)
AC_SUBST(INCLUDE_OUTPUTS)

AC_CONFIG_FILES([Makefile
                 include/apr.h
                 build/apr_rules.mk
                 build/pkg/pkginfo
                 apr-$APR_MAJOR_VERSION-config:apr-config.in
                 apr.pc])

if test -d $srcdir/test; then
   AC_CONFIG_FILES([test/Makefile test/internal/Makefile])
fi

dir=include/arch/unix
test -d $dir || $MKDIR $dir

AC_CONFIG_COMMANDS([default], [
# Commands run at the end of config.status:
for i in $APR_SAVE_HEADERS; do
  if cmp -s $i $i.save 2>/dev/null; then
    mv $i.save $i
    AC_MSG_NOTICE([$i is unchanged])
  fi
  rm -f $i.save
done
chmod +x apr-$APR_MAJOR_VERSION-config
],[
dnl This section is expanded by configure UNQUOTED so variable 
dnl references must be backslash-escaped as necessary.

# Commands run at the beginning of config.status:
APR_SAVE_HEADERS="include/apr.h include/arch/unix/apr_private.h"
APR_MAJOR_VERSION=$APR_MAJOR_VERSION
APR_PLATFORM=$host

for apri in \${APR_SAVE_HEADERS}; do
  test -r \${apri} && mv \${apri} \${apri}.save
done
])

AC_OUTPUT