summaryrefslogtreecommitdiff
path: root/configure.in
blob: 738f22a65d87173612b89b3016e5296baca89d00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
dnl #
dnl # Autoconf configuration file for APR
dnl #
dnl # Process this file with autoconf to produce a configure script.
dnl # Use ./buildconf to prepare build files and run autoconf for APR.

AC_INIT(build/apr_common.m4)
AC_CONFIG_HEADER(include/arch/unix/apr_private.h)
AC_CONFIG_AUX_DIR(build)

dnl #
dnl # Include our own M4 macros along with those for libtool
dnl #
sinclude(build/apr_common.m4)
sinclude(build/apr_network.m4)
sinclude(build/apr_threads.m4)
sinclude(build/apr_hints.m4)
sinclude(build/libtool.m4)

AC_CANONICAL_SYSTEM
echo "Configuring APR library"
OS=$host
echo "Platform: $OS"

dnl # Some initial steps for configuration.  We setup the default directory
dnl # and which files are to be configured.

dnl Preload
APR_PRELOAD

dnl Absolute source/build directory
abs_srcdir=`(cd $srcdir && pwd)`
abs_builddir=`pwd`

if test "$abs_builddir" != "$abs_srcdir"; then
  USE_VPATH=1
fi

dnl Libtool needs this symbol
if test -n "$BUILD_BASE"; then
  top_builddir="$BUILD_BASE"
else
  top_builddir="$abs_builddir"
fi
AC_SUBST(top_builddir)

dnl Directory containing apr build macros, helpers, and make rules
dnl NOTE: make rules (rules.mk) will be in the builddir for vpath
dnl
apr_buildout=$abs_builddir/build
apr_builders=$abs_srcdir/build
AC_SUBST(apr_builders)

MKDIR=$apr_builders/mkdir.sh

# These added to allow default directories to be used...
DEFAULT_OSDIR="unix"
echo "(Default will be ${DEFAULT_OSDIR})"

apr_modules="file_io network_io threadproc misc locks time mmap shmem i18n user"

dnl # Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_AWK
AC_CHECK_PROG(RM, rm, rm)
AC_CHECK_TOOL(AR, ar, ar)

# This macro needs to be here in case we are on an AIX box.
AC_AIX

APR_EBCDIC
 
# Use /bin/sh if it exists, otherwise go looking for sh in the path
if test ".$SH" = . -a -f /bin/sh; then
  SH="/bin/sh"
fi
AC_CHECK_PROG(SH, sh, sh)

dnl
dnl prep libtool
dnl
echo "performing libtool configuration..."
AC_PROG_LIBTOOL

dnl #----------------------------- Checks for compiler flags
nl='
'
echo $ac_n "${nl}Check for compiler flags..."

AC_ARG_WITH(debug,[  --with-debug            Turn on debugging and compile time warnings],
        [if test "$GCC" = "yes"; then CFLAGS="$CFLAGS -g -Wall"; else CFLAGS="$CFLAGS -g"; fi])

AC_ARG_WITH(maintainer-mode,[  --with-maintainer-mode  Turn on debugging and compile time warnings],
        [if test "$GCC" = "yes"; then CFLAGS="$CFLAGS -g -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations"; else CFLAGS="$CFLAGS -g"; fi])

dnl # this is the place to put specific options for platform/compiler
dnl # combinations
case "$OS:$CC" in
    *-hp-hpux*:cc )
	CFLAGS="$CFLAGS -Ae +DAportable +Z"
	;;
    powerpc-*-beos:mwcc* )
        CPP="mwcc -E"
        CC="mwcc"
        AR="ar"
        ;;
    mips-sni-sysv4:cc )
	CFLAGS="$CFLAGS -Kthread"
	;;
esac

case "$OS" in
   *-os2*)
       CFLAGS="$CFLAGS -DOS2 -Zmt"
       OSDIR="os2"
       enable_threads="system_threads"
       eolstr="\\r\\n"
       file_as_socket="0"
       ;;
   *beos*)
       OSDIR="beos"
       CFLAGS="$CFLAGS -DBEOS"
       enable_threads="system_threads"
       config_subdirs="shmem/unix/mm"
       native_mmap_emul="1"
       USE_MM=yes
       APR_CHECK_DEFINE(BONE_VERSION, sys/socket.h)
       eolstr="\\n"
       file_as_socket="0"
       ;;
   *os390)
       OSDIR="os390"
       config_subdirs="shmem/unix/mm"
       USE_MM=yes
       eolstr="\\n"
       ;;
   *)
       OSDIR="unix"
       config_subdirs="shmem/unix/mm"
       USE_MM=yes
       eolstr="\\n"
       ;;
esac

AC_SUBST(eolstr)

dnl For some platforms we need a version string which allows easy numeric
dnl comparisons.
case "$OS" in
    *freebsd*)
        # 3.4-RELEASE: 340   4.1.1-RELEASE: 411
        os_version=`uname -r | sed -e 's/\(.\)\.\(.\)\.\(.\).*/\1\2\3/' | sed -e 's/\(.\)\.\(.\)\-.*/\1\20/'`
        ;;
     *)
        os_version=OS_VERSION_IS_NOT_SET
        ;;
esac

dnl #----------------------------- Checking for Threads
echo $ac_n "${nl}Checking for Threads...${nl}"

if test -z "$enable_threads"; then
	AC_ARG_ENABLE(threads,
	[  --enable-threads        Enable threading support in APR.],
	[ enable_threads=$enableval] ,
	[ APR_CHECK_PTHREADS_H([ enable_threads="pthread" ] ,
	                       [ enable_threads="no" ] ) ] )
fi

if test "$enable_threads" = "no"; then
echo "Don't enable threads"
    threads="0"
    pthreadh="0"
    pthreadser="0"
else
#
#   Play with CPPFLAGS given what was learned from APR_PRELOAD.
#
#   [Roy: I don't like this because it messes up an environment
#         variable that should remain pristine.  However, it is needed
#         for compatibility until all flag handling can be rewritten.]
#
    apr_save_cppflags="$CPPFLAGS"
    if test -n "$THREAD_CPPFLAGS"; then
        CPPFLAGS="$CPPFLAGS $THREAD_CPPFLAGS"
    fi
    if test "$enable_threads" = "pthread"; then
# We have specified pthreads for our threading library, just make sure
# that we have everything we need
      APR_PTHREADS_CHECK
      APR_CHECK_PTHREADS_H([
          threads="1"
          pthreadh="1"
          pthreadser="1"
          AC_DEFINE(USE_THREADS) ], [
          threads="0"
          pthreadh="0"
          pthreadser="0" ] )
    elif test "$enable_threads" = "system_threads"; then
        threads="1"
        pthreadh="0"
        pthreadser="0"
    else
# We basically specified that we wanted threads, but not how to implement
# them.  In this case, just look for pthreads.  In the future, we can check
# for other threading libraries as well.
      APR_PTHREADS_CHECK
      APR_CHECK_PTHREADS_H([
          threads="1"
          pthreadh="1"
          pthreadser="1"
          AC_DEFINE(USE_THREADS) ], [
          threads="0"
          pthreadser="0"
          pthreadh="0"
          CPPFLAGS="$apr_save_cppflags" ] )
    fi
    if test "$pthreadh" = "1"; then
        APR_CHECK_PTHREAD_GETSPECIFIC_TWO_ARGS
        APR_CHECK_PTHREAD_ATTR_GETDETACHSTATE_ONE_ARG
        AC_CHECK_FUNCS(pthread_key_delete)
    fi
fi

ac_cv_define_READDIR_IS_THREAD_SAFE=no
if test "$threads" = "1"; then
    echo "APR will use threads"
    AC_CHECK_LIB(c_r, readdir, AC_DEFINE(READDIR_IS_THREAD_SAFE))
else
    echo "APR will be non-threaded"
fi

AC_CHECK_FUNCS(sigwait, [ have_sigwait="1" ], [ have_sigwait="0" ]) 
dnl AC_CHECK_FUNCS doesn't work for this on Tru64 since the function
dnl is renamed in signal.h.  Todo: Autodetect
case "$OS" in
    *alpha*-dec-osf* )
        have_sigwait="1"
        ;;
esac

AC_SUBST(threads)
AC_SUBST(have_sigwait)

AC_CHECK_FUNCS(poll)

dnl #----------------------------- Checking for missing POSIX thread functions
AC_CHECK_FUNCS(getpwnam_r)
AC_CHECK_FUNCS(getpwuid_r)
AC_CHECK_FUNCS(getgrgid_r)

dnl #----------------------------- Checking for Shared Memory Support 
echo $ac_n "${nl}Checking for Shared Memory Support...${nl}"

# run the MM config script regardless of whether we are going to use
# it or not.  When we have a much better idea of who is using MM, we can
# run this on a more conditional basis.
mm_dir=shmem/unix/mm

dnl #----------------------------- Prepare mm directory for VPATH support
if test "$USE_MM" = "yes"; then
  if test -n "$USE_VPATH"; then
    test -d $mm_dir || $MKDIR $mm_dir

    for i in shtool config.guess config.sub fbtool ltconfig \
             ltmain.sh mm_vers.c; do
      test -r $mm_dir/$i || ln -s $abs_srcdir/$mm_dir/$i $mm_dir/$i
    done
  fi
  APR_SUBDIR_CONFIG($config_subdirs)
fi

AC_MSG_CHECKING(for Shared memory support)
AC_ARG_ENABLE(shmem,
  [  --enable-shmem          Enable shared memory support in APR. ],
  [ ],
  ac_cv_enable_shmem="mm" )

sharedmem="0"
anonymous_shm="0"
filebased_shm="0"
keybased_shm="0"
if test "$ac_cv_enable_shmem" = "mm"; then
  sharedmem="1"
  anonymous_shm="1"
  AC_MSG_RESULT(anonymous)
  if test "$USE_MM" = "yes"; then
    LIBTOOL_LIBS="$abs_builddir/shmem/unix/mm/libmm.la"
  fi
elif test "$ac_cv_enable_shmem" = "file"; then
  sharedmem="1"
  filebased_shm="1"
  AC_MSG_RESULT(file based)
elif test "$ac_cv_enable_shmem" = "key"; then
  sharedmem="1"
  keybased_shm="1"
  AC_MSG_RESULT(key based)
else
  AC_MSG_RESULT(no)
fi
AC_SUBST(sharedmem)
AC_SUBST(anonymous_shm)
AC_SUBST(filebased_shm)
AC_SUBST(keybased_shm)

APR_CHECK_DEFINE(MM_SHMT_MMFILE, $srcdir/shmem/unix/mm/mm_conf.h) 

if test "$ac_cv_define_MM_SHMT_MMFILE" = "yes"; then
    file_based="1"
    mem_based="0"
else
    file_based="0"
    mem_based="1"
fi

AC_SUBST(mem_based)
AC_SUBST(file_based)

if test ".$SYS_SW" = ".AIX"; then
    CFLAGS="$CFLAGS -U__STR__"
    case "$SYS_KV" in
        [12]*)
            AC_DEFINE(USEBCOPY)
            OSDIR="aix"
            ;;
        3*)
            AC_DEFINE(NEED_RLIM_T)
            OSDIR="aix"
            ;;
        41*)
            AC_DEFINE(NEED_RLIM_T)
            OSDIR="aix"
            ;;
        42*)
            OSDIR="aix"
            ;;
    esac
fi

dnl #----------------------------- Checks for Any required Libraries
AC_CHECK_LIB(nsl,gethostbyname)
AC_SEARCH_LIBS(gethostname, nsl)
AC_CHECK_LIB(socket,socket)
AC_SEARCH_LIBS(crypt, crypt ufc)
AC_CHECK_LIB(truerand,main)
AC_CHECK_LIB(iconv,iconv)
AC_CHECK_LIB(m,modf)

dnl #----------------------------- Checks for Any required Functions
dnl Checks for library functions. (N.B. poll is further down)
AC_CHECK_FUNCS(strcasecmp stricmp setsid nl_langinfo)
AC_CHECK_FUNCS(setrlimit, [ have_setrlimit="1" ], [ have_setrlimit="0" ]) 
AC_CHECK_FUNCS(getrlimit, [ have_getrlimit="1" ], [ have_getrlimit="0" ]) 
AC_CHECK_FUNCS(writev)
sendfile="0"
AC_CHECK_FUNCS(sendfile send_file, [ sendfile="1" ])

dnl THIS MUST COME AFTER THE THREAD TESTS - FreeBSD doesn't always have a
dnl threaded poll() and we don't want to use sendfile on early FreeBSD 
dnl systems if we are also using threads.

AC_ARG_WITH(sendfile, [  --with-sendfile  Force sendfile to be on or off],
  [ if test "$withval" = "yes"; then
        sendfile="1"
    else
        sendfile="0"
    fi ] )

orig_sendfile=$sendfile
case "$OS" in
    *freebsd*)
        if test $os_version -le "410"; then
            if test "$threads" = "1"; then
                sendfile="0"
            fi
        fi
        ;;
    *alpha*-dec-osf* )
        sendfile="0"
        ;;
    s390-*-linux-gnu)
        sendfile="0"
        ;;
esac       
if test "$orig_sendfile" != "$sendfile"; then
  echo "sendfile support disabled to avoid system problem"
fi
AC_SUBST(sendfile)

AC_CHECK_FUNCS(sigaction, [ have_sigaction="1" ], [ have_sigaction="0" ]) 
AC_DECL_SYS_SIGLIST

AC_CHECK_FUNCS(fork, [ fork="1" ], [ fork="0" ])
AC_CHECK_FUNCS(getpass)
APR_CHECK_INET_ADDR
APR_CHECK_INET_NETWORK
AC_SUBST(apr_inaddr_none)
AC_CHECK_FUNC(_getch)
AC_CHECK_FUNCS(gmtime_r localtime_r)
AC_CHECK_FUNCS(iconv, [ iconv="1" ], [ iconv="0" ])
if test "$iconv" = "1"; then
  APR_CHECK_ICONV_INBUF
fi
AC_CHECK_FUNCS(mmap, [ mmap="1" ], [ mmap="0" ])
if test "$native_mmap_emul" = "1"; then
    mmap="1"
fi
AC_CHECK_FUNCS(hstrerror)
AC_CHECK_FUNCS(memmove, [ have_memmove="1" ], [have_memmove="0" ])
AC_CHECK_FUNCS(mkstemp)

AC_SUBST(fork)
AC_SUBST(have_inet_addr)
AC_SUBST(have_inet_network)
AC_SUBST(have_sigaction)
AC_SUBST(have_setrlimit)
AC_SUBST(have_getrlimit)
AC_SUBST(iconv)
AC_SUBST(mmap)
AC_SUBST(have_memmove)

APR_CHECK_SIGWAIT_ONE_ARG

dnl #----------------------------- Checks for Any required Headers
AC_HEADER_STDC

APR_FLAG_HEADERS(
    ByteOrder.h		\
    conio.h		\
    crypt.h		\
    ctype.h		\
    dir.h		\
    dirent.h		\
    dl.h		\
    dlfcn.h		\
    errno.h		\
    fcntl.h		\
    grp.h		\
    iconv.h		\
    io.h		\
    langinfo.h		\
    limits.h		\
    malloc.h		\
    memory.h		\
    netdb.h		\
    osreldate.h		\
    poll.h		\
    process.h		\
    pwd.h		\
    signal.h		\
    stdarg.h		\
    stddef.h		\
    stdio.h		\
    stdlib.h		\
    string.h		\
    strings.h		\
    sysapi.h		\
    sysgtime.h		\
    termios.h		\
    time.h		\
    tpfeq.h		\
    tpfio.h		\
    unistd.h		\
    unix.h		\
    arpa/inet.h		\
    kernel/OS.h		\
    net/errno.h		\
    netinet/in.h	\
    sys/file.h		\
    sys/mman.h		\
    sys/poll.h		\
    sys/resource.h	\
    sys/select.h	\
    sys/sem.h		\
    sys/sendfile.h	\
    sys/signal.h	\
    sys/socket.h	\
    sys/stat.h		\
    sys/syslimits.h	\
    sys/time.h		\
    sys/types.h		\
    sys/uio.h		\
    sys/wait.h)

dnl IRIX 6.5 has a problem in <netinet/tcp.h> which prevents it from
dnl being included by itself.  Check for <netinet/tcp.h> manually,
dnl including another header file first.
AC_MSG_CHECKING(for netinet/tcp.h)
AC_TRY_CPP([
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include <netinet/tcp.h>
], netinet_tcph="1", netinet_tcph="0")
if test $netinet_tcph = 1; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

AC_SUBST(arpa_ineth)
AC_SUBST(conioh)
AC_SUBST(ctypeh)
AC_SUBST(crypth)
AC_SUBST(errnoh)
AC_SUBST(direnth)
AC_SUBST(fcntlh)
AC_SUBST(ioh)
AC_SUBST(limitsh)
AC_SUBST(netdbh)
AC_SUBST(sys_syslimitsh)
AC_SUBST(netinet_inh)
AC_SUBST(netinet_tcph)
AC_SUBST(stdargh)
AC_SUBST(stdioh)
AC_SUBST(stdlibh)
AC_SUBST(stringh)
AC_SUBST(stringsh)
AC_SUBST(sys_sendfileh)
AC_SUBST(sys_signalh)
AC_SUBST(sys_socketh)
AC_SUBST(sys_typesh)
AC_SUBST(sys_timeh)
AC_SUBST(sys_uioh)
AC_SUBST(unistdh)
AC_SUBST(signalh)
AC_SUBST(sys_waith)
AC_SUBST(pthreadh)

dnl #----------------------------- Checking for h_errno in <netdb.h>
if test "$netdbh" = "1"; then
  APR_CHECK_H_ERRNO_FLAG
  if test "$ac_cv_h_errno_cflags" = "no"; then
    AC_MSG_ERROR([can not find h_errno in netdb.h])
  fi
fi

dnl #----------------------------- Checks for standard typedefs
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_CHECK_TYPE(ssize_t, int)
AC_C_INLINE
AC_C_CONST
AC_TYPE_SIZE_T
AC_FUNC_SETPGRP

APR_CHECK_SOCKLEN_T

APR_INADDR_NONE

dnl # Checks for integer size
AC_CHECK_SIZEOF(char, 1)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(long double, 12)
AC_CHECK_SIZEOF(long long, 8)

if test "$ac_cv_sizeof_short" = "2"; then
    short_value=short
fi
if test "$ac_cv_sizeof_int" = "4"; then
    int_value=int
fi
if test "$ac_cv_sizeof_long" = "8"; then
    long_value=long
fi
if test "$ac_cv_sizeof_long_double" = "8"; then
    long_value="long double"
fi
if test "$ac_cv_sizeof_long_long" = "8"; then
    if test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_long"; then
        long_value="long"
    else
        long_value="long long"
    fi
fi
if test "$ac_cv_sizeof_longlong" = "8"; then
    long_value="__int64"
fi

if test "$ac_cv_type_off_t" = "yes"; then
    off_t_value="off_t"
else
    off_t_value="apr_int32_t"
fi
if test "$ac_cv_type_size_t" = "yes"; then
    size_t_value="size_t"
else
    size_t_value="apr_int32_t"
fi
if test "$ac_cv_type_ssize_t" = "yes"; then
    ssize_t_value="ssize_t"
else
    ssize_t_value="apr_int32_t"
fi
if test "$ac_cv_socklen_t" = "yes"; then
    socklen_t_value="socklen_t"
else
    socklen_t_value="int"
fi

APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], ssize_t, 8)

if test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
    ssize_t_fmt='#define APR_SSIZE_T_FMT "d"'
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then
    ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
else
    ssize_t_fmt='#error Can not determine the proper size for ssize_t'
fi

APR_CHECK_SIZEOF_EXTENDED([#include <stddef.h>], size_t, 8)

if test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_int"; then
    size_t_fmt='#define APR_SIZE_T_FMT "d"'
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long"; then
    size_t_fmt='#define APR_SIZE_T_FMT "ld"'
else
    size_t_fmt='#error Can not determine the proper size for size_t'
fi

APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], off_t, 8)

if test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_int"; then
    off_t_fmt='#define APR_OFF_T_FMT "d"'
elif test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_long"; then
    off_t_fmt='#define APR_OFF_T_FMT "ld"'
elif test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_long_long"; then
    off_t_fmt='#define APR_OFF_T_FMT "qd"'
else
    off_t_fmt='#error Can not determine the proper size for off_t'
fi

APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], pid_t, 8)

if test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_int"; then
    os_proc_t_fmt='#define APR_OS_PROC_T_FMT "d"'
elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_long"; then
    os_proc_t_fmt='#define APR_OS_PROC_T_FMT "ld"'
elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_long_long"; then
    os_proc_t_fmt='#define APR_OS_PROC_T_FMT "qd"'
else
    os_proc_t_fmt='#error Can not determine the proper size for pid_t'
fi

# Basically, we have tried to figure out the correct format strings
# for APR types which vary between platforms, but we don't always get 
# it right.  If you find that we don't get it right for your platform, 
# you can override our decision below.
case "$OS" in
   *linux* | *os2_emx | *-solaris*)
       off_t_fmt='#define APR_OFF_T_FMT "ld"'
       ;;
   *aix4*)
       ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
       size_t_fmt='#define APR_SIZE_T_FMT "ld"'
       off_t_fmt='#define APR_OFF_T_FMT "ld"'
       ;;
    *beos*)
        ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
        size_t_fmt='#define APR_SIZE_T_FMT "ld"'
        ;;
esac

AC_SUBST(short_value)
AC_SUBST(int_value)
AC_SUBST(long_value)
AC_SUBST(off_t_value)
AC_SUBST(size_t_value)
AC_SUBST(ssize_t_value)
AC_SUBST(socklen_t_value)
AC_SUBST(ssize_t_fmt) 
AC_SUBST(size_t_fmt)
AC_SUBST(off_t_fmt) 
AC_SUBST(os_proc_t_fmt)

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_SUBST(have_strnicmp)
AC_SUBST(have_strncasecmp)
AC_SUBST(have_stricmp)
AC_SUBST(have_strcasecmp)
AC_SUBST(have_strdup)
AC_SUBST(have_strstr)

dnl #----------------------------- Checking for DSO support
echo $ac_n "${nl}Checking for DSO...${nl}"
AC_ARG_ENABLE(dso,
  [  --enable-dso            Enable dso support ],
  [ tempdso=$enableval],
  [ 
    AC_CHECK_LIB(dl, dlopen, [ tempdso="yes" LIBS="$LIBS -ldl" ], 
                 tempdso="no")
    if test "$tempdso" = "no"; then
      AC_CHECK_FUNCS(dlopen, [ tempdso="yes" ], [ tempdso="no" ])
    fi
    if test "$tempdso" = "no"; then
      AC_CHECK_LIB(root, load_image, tempdso="yes", tempdso="no")
    fi
    if test "$tempdso" = "no"; then
      AC_CHECK_LIB(dld, shl_load, [ tempdso="yes" LIBS="$LIBS -ldld" ],
                   tempdso="no")
    fi
    if test "$tempdso" = "no"; then
        case $OS in
            *os390|*-os2*)
                tempdso="yes"
                ;;
        esac
    fi
 ] )

if test "$tempdso" = "no"; then
    aprdso="0"
else
    aprdso="1"
    apr_modules="$apr_modules dso"
fi

AC_SUBST(aprdso)

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

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) 

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 $ac_n "${nl}Checking for Locking...${nl}"

AC_CHECK_FUNCS(semget semctl)

# 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(CODESET, langinfo.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)
fi

# The last APR_DECIDE to execute sets the default
APR_BEGIN_DECISION([apr_lock implementation method])
APR_IFALLYES(func:semget func:semctl,
            APR_DECIDE(USE_SYSVSEM_SERIALIZE, [SysV IPC semget()]))
APR_IFALLYES(header:sys/file.h 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(header:pthread.h define:PTHREAD_PROCESS_SHARED dnl
            custom:with_pthread_cross,
            APR_DECIDE(USE_PROC_PTHREAD_SERIALIZE, [pthread mutex]))
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"
procpthreadser="0"
fcntlser="0"
case $ac_decision in
    USE_FLOCK_SERIALIZE )
        flockser="1"
        ;;
    USE_SYSVSEM_SERIALIZE )
        sysvser="1"
        ;;
    USE_FCNTL_SERIALIZE )
        fcntlser="1"
        ;;
    USE_PROC_PTHREAD_SERIALIZE )
        procpthreadser="1"
        ;;
esac

AC_SUBST(flockser)
AC_SUBST(sysvser)
AC_SUBST(fcntlser)
AC_SUBST(procpthreadser)
AC_SUBST(pthreadser)

AC_MSG_CHECKING(if interprocess lock affects 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)

dnl #----------------------------- Checking for /dev/random 
AC_MSG_CHECKING(for /dev/random)

if test -r "/dev/random"; then
    AC_DEFINE(DEV_RANDOM, [/dev/random])
    AC_MSG_RESULT(/dev/random)
    rand="1"
elif test -r "/dev/urandom"; then
    AC_DEFINE(DEV_RANDOM, [/dev/urandom])
    AC_MSG_RESULT(/dev/urandom)
    rand="1"
else
    AC_MSG_RESULT(not found);

    case "$OS" in
        # we have built in support for OS/2
        *-os2*)
            rand="1"
            ;;
        # no other choice, try for truerand
        *)
            if test "$ac_cv_lib_truerand_main" = "yes"; then
                rand="1"
            else
                rand="0"
            fi
            ;;
    esac
fi

AC_SUBST(rand)
dnl #----------------------------- Checking for Time Support 
echo $ac_n "${nl}Checking for Time Support...${nl}"
AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
  ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])

if test "$ac_cv_struct_tm_gmtoff" = "yes"; then
    AC_DEFINE(HAVE_GMTOFF)
fi

dnl #----------------------------- Checking for Networking Support 
echo $ac_n "${nl}Checking for Networking support...${nl}"
AC_MSG_CHECKING(for in_addr in netinet/in.h)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netinet/in.h>
],[
struct in_addr arg;
arg.s_addr = htonl(INADDR_ANY);
], [ have_in_addr="1" 
msg=yes ] , [ have_in_addr="0"
msg=no ])
AC_MSG_RESULT([$msg])

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

AC_SUBST(have_in_addr)
AC_SUBST(file_as_socket)

APR_CHECK_SOCKADDR_SA_LEN

APR_CHECK_GETHOSTBYNAME_NAS

dnl # 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 $OS 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
AC_SUBST(apr_tcp_nopush_flag)
AC_SUBST(have_corkable_tcp)

echo $ac_n "${nl}Checking for IPv6 Networking support...${nl}"
dnl # Start of checking for IPv6 support...
AC_SEARCH_LIBS(getaddrinfo, inet6)
AC_SEARCH_LIBS(getnameinfo, inet6)
APR_CHECK_WORKING_GETADDRINFO
AC_CHECK_FUNCS(getnameinfo)
AC_CHECK_FUNCS(getipnodebyname)
AC_CHECK_FUNCS(getipnodebyaddr)
APR_CHECK_SOCKADDR_IN6
AC_MSG_CHECKING(if APR supports IPv6)
have_ipv6="0"
if test "x$have_sockaddr_in6" = "x1"; then
    if test "x$ac_cv_working_getaddrinfo" = "xyes"; then
        if test "x$ac_cv_func_getnameinfo" = "xyes"; then
            have_ipv6="1"
            AC_MSG_RESULT("yes")
        else
            AC_MSG_RESULT("no -- no getnameinfo")
        fi
    else
        AC_MSG_RESULT("no -- no working getaddrinfo")
    fi
else
    AC_MSG_RESULT("no -- no sockaddr_in6");
fi
AC_SUBST(have_ipv6)

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

AC_SUBST(LDLIBS)
AC_SUBST(OPTIM)
AC_SUBST(AR)
AC_SUBST(RM)
AC_SUBST(OSDIR)
AC_SUBST(DEFAULT_OSDIR)
AC_SUBST(EXEEXT)
AC_SUBST(THREAD_CPPFLAGS)
AC_SUBST(THREAD_CFLAGS)
AC_SUBST(LIBTOOL_LIBS)

echo "${nl}Construct Makefiles and header files."
MAKEFILE1="Makefile lib/Makefile strings/Makefile passwd/Makefile tables/Makefile"
SUBDIRS="lib strings passwd tables "
for dir in $apr_modules
do
    test -d $dir || $MKDIR $dir
    if test -f $srcdir/$dir/$OSDIR/Makefile.in; then
        MAKEFILE2="$MAKEFILE2 $dir/$OSDIR/Makefile "
        SUBDIRS="$SUBDIRS $dir/$OSDIR "
    else
        MAKEFILE2="$MAKEFILE2 $dir/$DEFAULT_OSDIR/Makefile "
        SUBDIRS="$SUBDIRS $dir/$DEFAULT_OSDIR "
    fi
done

if test -d ./test; then
    MAKEFILE3="test/Makefile"
fi
AC_SUBST(SUBDIRS)

if test -n "$CPPFLAGS"; then
  CFLAGS="$CFLAGS $CPPFLAGS"
fi

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

SAVE_FILES="include/apr.h include/arch/unix/apr_private.h"

for i in $SAVE_FILES; do
  test -r $i && mv $i $i.save
done

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

AC_OUTPUT([
	$MAKEFILE1 $MAKEFILE2 $MAKEFILE3
	include/apr.h
	APRVARS
	build/rules.mk
],[
for i in $SAVE_FILES; do
  if cmp -s $i $i.save 2>/dev/null; then
    mv $i.save $i
    echo "$i is unchanged"
  fi
  rm -f $i.save
done
])

dnl #----------------------------- Fixup Makefiles for VPATH support

changequote({,})

if test -n "$USE_VPATH"; then
  if test -n "$USE_MM"; then
    MAKEFILE3="$MAKEFILE3 $mm_dir/Makefile"
  fi
  for makefile in $MAKEFILE1 $MAKEFILE2 $MAKEFILE3; do
    dir=`echo $makefile|sed 's%[^/][^/]*$%%'`
    (cat <<EOF
srcdir = $abs_srcdir/$dir
VPATH  = $abs_srcdir/$dir

EOF
)    |  cat - $makefile | \
        sed \
		-e 's#-I\($(INCDIR[0-9]*)\)#-I\1 -I$(srcdir)\1#g' \
		-e 's#-I\($(OSDIR[0-9]*)\)#-I\1 -I$(srcdir)\1#g' \
		-e 's#-I\($(DEFOSDIR[0-9]*)\)#-I\1 -I$(srcdir)\1#g' \
		> tmp
    cp tmp $makefile
  done
  if test -n "$USE_MM"; then
    cat $mm_dir/Makefile | \
       sed \
       -e 's#\($(CFLAGS)\)#\1 -I$(srcdir) -I.#' \
       -e '/mm_global\.c/d' \
       > tmp
    cp tmp $mm_dir/Makefile
  fi
  rm -f tmp
fi

changequote([,])