forked from apache/apr
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.in
2774 lines (2460 loc) · 80.2 KB
/
configure.in
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
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_PREREQ(2.59)
AC_INIT(build/apr_common.m4)
AC_CONFIG_HEADER(include/arch/unix/apr_private.h)
AC_CONFIG_AUX_DIR(build)
AC_CONFIG_MACRO_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_win32.m4)
sinclude(build/apr_hints.m4)
sinclude(build/libtool.m4)
sinclude(build/ltsugar.m4)
sinclude(build/argz.m4)
sinclude(build/ltoptions.m4)
sinclude(build/ltversion.m4)
sinclude(build/lt~obsolete.m4)
sinclude(build/apu-conf.m4)
sinclude(build/xml.m4)
sinclude(build/apu-hints.m4)
sinclude(build/crypto.m4)
sinclude(build/dbm.m4)
sinclude(build/dbd.m4)
sinclude(build/dso.m4)
sinclude(build/iconv.m4)
dnl Hard-coded top of apr_private.h:
AH_TOP([
#ifndef APR_PRIVATE_H
#define APR_PRIVATE_H
/* Pick up publicly advertised headers and symbols before the
* APR internal private headers and symbols
*/
#include <apr.h>
])
dnl Hard-coded inclusion at the tail end of apr_private.h:
AH_BOTTOM([
/* switch this on if we have a BeOS version below BONE */
#if defined(BEOS) && !defined(HAVE_BONE_VERSION)
#define BEOS_R5 1
#else
#define BEOS_BONE 1
#endif
/*
* Darwin 10's default compiler (gcc42) builds for both 64 and
* 32 bit architectures unless specifically told not to.
* In those cases, we need to override types depending on how
* we're being built at compile time.
* NOTE: This is an ugly work-around for Darwin's
* concept of universal binaries, a single package
* (executable, lib, etc...) which contains both 32
* and 64 bit versions. The issue is that if APR is
* built universally, if something else is compiled
* against it, some bit sizes will depend on whether
* it is 32 or 64 bit. This is determined by the __LP64__
* flag. Since we need to support both, we have to
* handle OS X unqiuely.
*/
#ifdef DARWIN_10
#undef APR_OFF_T_STRFN
#undef APR_INT64_STRFN
#undef SIZEOF_LONG
#undef SIZEOF_SIZE_T
#undef SIZEOF_SSIZE_T
#undef SIZEOF_VOIDP
#undef SIZEOF_STRUCT_IOVEC
#ifdef __LP64__
#define APR_INT64_STRFN strtol
#define SIZEOF_LONG 8
#define SIZEOF_SIZE_T 8
#define SIZEOF_SSIZE_T 8
#define SIZEOF_VOIDP 8
#define SIZEOF_STRUCT_IOVEC 16
#else
#define APR_INT64_STRFN strtoll
#define SIZEOF_LONG 4
#define SIZEOF_SIZE_T 4
#define SIZEOF_SSIZE_T 4
#define SIZEOF_VOIDP 4
#define SIZEOF_STRUCT_IOVEC 8
#endif
#undef APR_OFF_T_STRFN
#define APR_OFF_T_STRFN APR_INT64_STRFN
#undef SETPGRP_VOID
#ifdef __DARWIN_UNIX03
#define SETPGRP_VOID 1
#else
/* #undef SETPGRP_VOID */
#endif
#endif /* DARWIN_10 */
#endif /* APR_PRIVATE_H */
])
dnl Save user-defined environment settings for later restoration
dnl
APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
APR_SAVE_THE_ENVIRONMENT(CFLAGS)
APR_SAVE_THE_ENVIRONMENT(LDFLAGS)
APR_SAVE_THE_ENVIRONMENT(LIBS)
APR_SAVE_THE_ENVIRONMENT(INCLUDES)
dnl Generate ./config.nice for reproducing runs of configure
dnl
APR_CONFIG_NICE(config.nice)
AC_CANONICAL_SYSTEM
echo "Configuring APR library"
echo "Platform: $host"
dnl Some initial steps for configuration. We setup the default directory
dnl and which files are to be configured.
dnl Setup the directory macros now
# Absolute source/build directory
apr_srcdir=`(cd $srcdir && pwd)`
apr_builddir=`pwd`
AC_SUBST(apr_srcdir)
AC_SUBST(apr_builddir)
if test "$apr_builddir" != "$apr_srcdir"; then
USE_VPATH=1
APR_CONFIG_LOCATION=build
else
APR_CONFIG_LOCATION=source
fi
AC_SUBST(APR_CONFIG_LOCATION)
# Libtool might need this symbol -- it must point to the location of
# the generated libtool script (not necessarily the "top" build dir).
#
top_builddir="$apr_builddir"
AC_SUBST(top_builddir)
# Directory containing apr build macros, helpers, and make rules
# NOTE: make rules (apr_rules.mk) will be in the builddir for vpath
#
apr_buildout=$apr_builddir/build
apr_builders=$apr_srcdir/build
AC_SUBST(apr_builders)
MKDIR=$apr_builders/mkdir.sh
dnl Initialize mkdir -p functionality.
APR_MKDIR_P_CHECK($apr_builders/mkdir.sh)
# get our version information
get_version="$apr_builders/get-version.sh"
version_hdr="$apr_srcdir/include/apr_version.h"
APR_MAJOR_VERSION="`$get_version major $version_hdr APR`"
APR_DOTTED_VERSION="`$get_version all $version_hdr APR`"
AC_SUBST(APR_DOTTED_VERSION)
AC_SUBST(APR_MAJOR_VERSION)
echo "APR Version: ${APR_DOTTED_VERSION}"
dnl Enable the layout handling code, then reparse the prefix-style
dnl arguments due to autoconf being a PITA.
APR_ENABLE_LAYOUT(apr)
APR_PARSE_ARGUMENTS
dnl Set optional CC hints here in case autoconf makes an inappropriate choice.
dnl This allows us to suggest what the compiler should be, but still
dnl allows the user to override CC externally.
APR_CC_HINTS
dnl Do the various CC checks *before* preloading values. The preload code
dnl may need to use compiler characteristics to make decisions. This macro
dnl can only be used once within a configure script, so this prevents a
dnl preload section from invoking the macro to get compiler info.
AC_PROG_CC
dnl AC_PROG_SED is only avaliable in recent autoconf versions.
dnl Use AC_CHECK_PROG instead if AC_PROG_SED is not present.
ifdef([AC_PROG_SED],
[AC_PROG_SED],
[AC_CHECK_PROG(SED, sed, sed)])
dnl Preload
APR_PRELOAD
dnl 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 user memory atomic poll support random"
dnl Checks for programs.
AC_PROG_MAKE_SET
AC_PROG_CPP
AC_PROG_AWK
AC_PROG_LN_S
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_CHECK_PROG(RM, rm, rm)
AC_CHECK_PROG(AS, as, as)
AC_CHECK_PROG(ASCPP, cpp, cpp)
AC_CHECK_TOOL(AR, ar, ar)
dnl Various OS checks that apparently set required flags
ifdef([AC_USE_SYSTEM_EXTENSIONS], [
AC_USE_SYSTEM_EXTENSIONS
], [
AC_AIX
AC_MINIX
])
AC_ISC_POSIX
APR_EBCDIC
dnl this is our library name
APR_LIBNAME="apr${libsuffix}"
AC_SUBST(APR_LIBNAME)
dnl prep libtool
dnl
echo "performing libtool configuration..."
AC_ARG_ENABLE(experimental-libtool,[ --enable-experimental-libtool Use experimental custom libtool],
[experimental_libtool=$enableval],[experimental_libtool=no])
dnl Workarounds for busted Libtool 2.x when we don't call AC_PROG_LIBTOOL
if test "x$Xsed" = "x"; then
Xsed="$SED -e 1s/^X//"
fi
case $host in
*-os2*)
# Use a custom-made libtool replacement
echo "using aplibtool"
LIBTOOL="$apr_builddir/build/aplibtool"
LIBTOOL_SRC="$apr_srcdir/build/aplibtool.c"
$CC $CFLAGS $CPPFLAGS -o $LIBTOOL.exe $LIBTOOL_SRC
;;
*)
if test "x$LTFLAGS" = "x"; then
LTFLAGS='--silent'
fi
if test "$experimental_libtool" = "yes"; then
# Use a custom-made libtool replacement
echo "using jlibtool"
LIBTOOL="$apr_builddir/libtool"
LIBTOOL_SRC="$apr_srcdir/build/jlibtool.c"
$CC $CFLAGS $CPPFLAGS -o $LIBTOOL $LIBTOOL_SRC
eval `$apr_builddir/libtool --config | grep "^shlibpath_var=[[A-Z_]]*$"`
if test "x$shlibpath_var" = "x"; then
shlibpath_var=REPLACE_WITH_YOUR_SHLIBPATH_VAR
fi
else
dnl libtoolize requires that the following not be indented
dnl should become LT_INIT(win32-dll)
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
# get libtool's setting of shlibpath_var
eval `grep "^shlibpath_var=[[A-Z_]]*$" $apr_builddir/libtool`
if test "x$shlibpath_var" = "x"; then
shlibpath_var=REPLACE_WITH_YOUR_SHLIBPATH_VAR
fi
fi
;;
esac
AC_ARG_WITH(installbuilddir, [ --with-installbuilddir=DIR location to store APR build files (defaults to '${datadir}/build')],
[ installbuilddir=$withval ], [ installbuilddir="${datadir}/build-${APR_MAJOR_VERSION}" ] )
AC_SUBST(installbuilddir)
AC_ARG_WITH(libtool, [ --without-libtool avoid using libtool to link the library],
[ use_libtool=$withval ], [ use_libtool="yes" ] )
if test "x$use_libtool" = "xyes"; then
lt_compile='$(LIBTOOL) $(LTFLAGS) --mode=compile $(COMPILE) -o $@ -c $< && touch $@'
LT_VERSION="-version-info `$get_version libtool $version_hdr APR`"
link="\$(LIBTOOL) \$(LTFLAGS) --mode=link \$(COMPILE) \$(LT_LDFLAGS) \$(LT_VERSION) \$(ALL_LDFLAGS) -o \$@"
so_ext='lo'
lib_target='-rpath $(libdir) $(OBJECTS)'
export_lib_target='-rpath \$(libdir) \$(OBJECTS)'
else
lt_compile='$(COMPILE) -o $@ -c $<'
link='$(AR) cr $(TARGET_LIB) $(OBJECTS); $(RANLIB) $(TARGET_LIB)'
so_ext='o'
lib_target=''
export_lib_target=''
fi
case $host in
*-solaris2*)
apr_platform_runtime_link_flag="-R"
;;
*-mingw* | *-cygwin*)
LT_LDFLAGS="$LT_LDFLAGS -no-undefined"
;;
*)
;;
esac
AC_SUBST(lt_compile)
AC_SUBST(link)
AC_SUBST(so_ext)
AC_SUBST(lib_target)
AC_SUBST(export_lib_target)
AC_SUBST(shlibpath_var)
AC_SUBST(LTFLAGS)
AC_SUBST(LT_LDFLAGS)
AC_SUBST(LT_VERSION)
dnl ----------------------------- Checks for compiler flags
nl='
'
echo "${nl}Check for compiler flags..."
dnl AC_PROG_CC sets -g in CFLAGS (and -O2 for gcc) by default.
dnl On OS/390 this causes the compiler to insert extra debugger
dnl hook instructions. That's fine for debug/maintainer builds, not fine
dnl otherwise.
case $host in
*os390)
if test "$ac_test_CFLAGS" != set; then
APR_REMOVEFROM(CFLAGS,-g)
fi
;;
esac
AC_ARG_ENABLE(debug,[ --enable-debug Turn on debugging and compile time warnings],
[APR_ADDTO(CFLAGS,-g)
if test "$GCC" = "yes"; then
APR_ADDTO(CFLAGS,-Wall)
elif test "$AIX_XLC" = "yes"; then
APR_ADDTO(CFLAGS,-qfullpath)
fi
])dnl
AC_ARG_ENABLE(maintainer-mode,[ --enable-maintainer-mode Turn on debugging and compile time warnings],
[APR_ADDTO(CFLAGS,-g)
if test "$GCC" = "yes"; then
APR_ADDTO(CFLAGS,[-Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations])
elif test "$AIX_XLC" = "yes"; then
APR_ADDTO(CFLAGS,-qfullpath -qinitauto=FE -qcheck=all -qinfo=pro)
fi
])dnl
AC_ARG_ENABLE(profile,[ --enable-profile Turn on profiling for the build (GCC)],
if test "$GCC" = "yes"; then
APR_ADDTO(CFLAGS, -pg)
APR_REMOVEFROM(CFLAGS, -g)
if test "$host" = "i586-pc-beos"; then
APR_REMOVEFROM(CFLAGS, -O2)
APR_ADDTO(CFLAGS, -O1)
APR_ADDTO(LDFLAGS, -p)
fi
fi
)dnl
AC_ARG_ENABLE(pool-debug,
[ --enable-pool-debug[[=yes|no|verbose|verbose-alloc|lifetime|owner|all]] Turn on pools debugging],
[ if test -z "$enableval"; then
APR_ADDTO(CPPFLAGS, -DAPR_POOL_DEBUG=1)
elif test ! "$enableval" = "no"; then
apr_pool_debug=1
for i in $enableval
do
flag=0
case $i in
yes)
flag=1
;;
verbose)
flag=2
;;
lifetime)
flag=4
;;
owner)
flag=8
;;
verbose-alloc)
flag=16
;;
all)
apr_pool_debug=31
;;
*)
;;
esac
if test $flag -gt 0; then
apr_pool_debug=`expr '(' $apr_pool_debug - $apr_pool_debug % \
'(' $flag '*' 2 ')' ')' + $flag + $apr_pool_debug % $flag`
fi
done
APR_ADDTO(CPPFLAGS, -DAPR_POOL_DEBUG=$apr_pool_debug)
fi
])
if test "$host" = "i586-pc-beos"; then
AC_ARG_ENABLE(malloc-debug,[ --enable-malloc-debug Switch on malloc_debug for BeOS],
APR_REMOVEFROM(CFLAGS, -O2)
APR_ADDTO(CPPFLAGS, -fcheck-memory-usage -D_KERNEL_MODE)
) dnl
fi
# this is the place to put specific options for platform/compiler
# combinations
case "$host:$CC" in
*-hp-hpux*:cc )
APR_ADDTO(CFLAGS,[-Ae +Z])
case $host in
ia64-* )
;;
* )
if echo "$CFLAGS " | grep '+DA' >/dev/null; then :
else
APR_ADDTO(CFLAGS,[+DAportable])
fi
;;
esac
;;
powerpc-*-beos:mwcc* )
APR_SETVAR(CPP,[mwcc -E])
APR_SETVAR(CC,mwcc)
APR_SETVAR(AR,ar)
;;
dnl If building static APR, both the APR build and the app build
dnl need -DAPR_DECLARE_STATIC to generate the right linkage from
dnl APR_DECLARE et al.
dnl If building dynamic APR, the APR build needs APR_DECLARE_EXPORT
dnl and the app build should have neither define.
*-mingw* | *-cygwin*)
if test "$enable_shared" = "yes"; then
APR_ADDTO(INTERNAL_CPPFLAGS, -DAPR_DECLARE_EXPORT)
else
APR_ADDTO(CPPFLAGS, -DAPR_DECLARE_STATIC)
fi
;;
esac
AC_CACHE_CHECK([whether the compiler provides atomic builtins], [ap_cv_atomic_builtins],
[AC_TRY_RUN([
int main()
{
unsigned long val = 1010, tmp, *mem = &val;
if (__sync_fetch_and_add(&val, 1010) != 1010 || val != 2020)
return 1;
tmp = val;
if (__sync_fetch_and_sub(mem, 1010) != tmp || val != 1010)
return 1;
if (__sync_sub_and_fetch(&val, 1010) != 0 || val != 0)
return 1;
tmp = 3030;
if (__sync_val_compare_and_swap(mem, 0, tmp) != 0 || val != tmp)
return 1;
if (__sync_lock_test_and_set(&val, 4040) != 3030)
return 1;
mem = &tmp;
if (__sync_val_compare_and_swap(&mem, &tmp, &val) != &tmp)
return 1;
__sync_synchronize();
if (mem != &val)
return 1;
return 0;
}], [ap_cv_atomic_builtins=yes], [ap_cv_atomic_builtins=no], [ap_cv_atomic_builtins=no])])
if test "$ap_cv_atomic_builtins" = "yes"; then
AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1, [Define if compiler provides atomic builtins])
fi
case $host in
powerpc-405-*)
# The IBM ppc405cr processor has a bugged stwcx instruction.
AC_DEFINE(PPC405_ERRATA, 1, [Define on PowerPC 405 where errata 77 applies])
;;
*)
;;
esac
dnl Check the depend program we can use
APR_CHECK_DEPEND
proc_mutex_is_global=0
config_subdirs="none"
INSTALL_SUBDIRS="none"
OBJECTS_PLATFORM='$(OBJECTS_unix)'
case $host in
i386-ibm-aix* | *-ibm-aix[[1-2]].* | *-ibm-aix3.* | *-ibm-aix4.1 | *-ibm-aix4.1.* | *-ibm-aix4.2 | *-ibm-aix4.2.*)
OSDIR="aix"
APR_ADDTO(LDFLAGS,-lld)
eolstr="\\n"
OBJECTS_PLATFORM='$(OBJECTS_aix)'
;;
*-os2*)
APR_ADDTO(CPPFLAGS,-DOS2)
APR_ADDTO(CFLAGS,-Zmt)
AC_CHECK_LIB(bsd, random)
OSDIR="os2"
enable_threads="system_threads"
eolstr="\\r\\n"
file_as_socket="0"
proc_mutex_is_global=1
OBJECTS_PLATFORM='$(OBJECTS_os2)'
;;
*beos*)
OSDIR="beos"
APR_ADDTO(CPPFLAGS,-DBEOS)
enable_threads="system_threads"
native_mmap_emul="1"
APR_CHECK_DEFINE(BONE_VERSION, sys/socket.h)
eolstr="\\n"
osver=`uname -r`
proc_mutex_is_global=1
OBJECTS_PLATFORM='$(OBJECTS_beos)'
case $osver in
5.0.4)
file_as_socket="1"
;;
*)
file_as_socket="0"
;;
esac
;;
*os390)
OSDIR="os390"
OBJECTS_PLATFORM='$(OBJECTS_os390)'
eolstr="\\n"
;;
*os400)
OSDIR="as400"
eolstr="\\n"
;;
*mingw*)
OSDIR="win32"
enable_threads="system_threads"
eolstr="\\r\\n"
file_as_socket=0
proc_mutex_is_global=1
OBJECTS_PLATFORM='$(OBJECTS_win32)'
;;
*cygwin*)
OSDIR="unix"
enable_threads="no"
eolstr="\\n"
;;
*hpux10* )
enable_threads="no"
OSDIR="unix"
eolstr="\\n"
;;
*)
OSDIR="unix"
eolstr="\\n"
;;
esac
AC_SUBST(OBJECTS_PLATFORM)
# Check whether LFS has explicitly been disabled
AC_ARG_ENABLE(lfs,[ --disable-lfs Disable large file support on 32-bit platforms],
[apr_lfs_choice=$enableval], [apr_lfs_choice=yes])
if test "$apr_lfs_choice" = "yes"; then
# Check whether the transitional LFS API is sufficient
AC_CACHE_CHECK([whether to enable -D_LARGEFILE64_SOURCE], [apr_cv_use_lfs64], [
apr_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
AC_TRY_RUN([
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
void main(void)
{
int fd, ret = 0;
struct stat64 st;
off64_t off = 4242;
if (sizeof(off64_t) != 8 || sizeof(off_t) != 4)
exit(1);
if ((fd = open("conftest.lfs", O_LARGEFILE|O_CREAT|O_WRONLY, 0644)) < 0)
exit(2);
if (ftruncate64(fd, off) != 0)
ret = 3;
else if (fstat64(fd, &st) != 0 || st.st_size != off)
ret = 4;
else if (lseek64(fd, off, SEEK_SET) != off)
ret = 5;
else if (close(fd) != 0)
ret = 6;
else if (lstat64("conftest.lfs", &st) != 0 || st.st_size != off)
ret = 7;
else if (stat64("conftest.lfs", &st) != 0 || st.st_size != off)
ret = 8;
unlink("conftest.lfs");
exit(ret);
}], [apr_cv_use_lfs64=yes], [apr_cv_use_lfs64=no], [apr_cv_use_lfs64=no])
CPPFLAGS=$apr_save_CPPFLAGS])
if test "$apr_cv_use_lfs64" = "yes"; then
APR_ADDTO(CPPFLAGS, [-D_LARGEFILE64_SOURCE])
fi
fi
AC_ARG_ENABLE(nonportable-atomics,
[ --enable-nonportable-atomics Use optimized atomic code which may produce nonportable binaries],
[if test $enableval = yes; then
force_generic_atomics=no
else
force_generic_atomics=yes
fi
],
[case $host_cpu in
i[[456]]86) force_generic_atomics=yes ;;
*) force_generic_atomics=no ;;
esac
])
if test $force_generic_atomics = yes; then
AC_DEFINE([USE_ATOMICS_GENERIC], 1,
[Define if use of generic atomics is requested])
fi
AC_SUBST(proc_mutex_is_global)
AC_SUBST(eolstr)
AC_SUBST(INSTALL_SUBDIRS)
# For some platforms we need a version string which allows easy numeric
# comparisons.
case $host in
*freebsd*)
if test -x /sbin/sysctl; then
os_version=`/sbin/sysctl -n kern.osreldate`
else
os_version=000000
fi
;;
*linux*)
os_version=`uname -r | sed -e 's/\(.\)\.\(.\)\.\(.\).*/\1\2\3/'`
;;
*os390)
os_version=`uname -r | sed -e 's/\.//g'`
;;
*)
os_version=OS_VERSION_IS_NOT_SET
;;
esac
echo "${nl}Checking for libraries..."
dnl ----------------------------- Checks for Any required Libraries
dnl Note: Autoconf will always append LIBS with an extra " " in AC_CHECK_LIB.
dnl It should check for LIBS being empty and set LIBS equal to the new value
dnl without the extra " " in that case, but they didn't do that. So, we
dnl end up LIBS="-lm -lcrypt -lnsl -ldl" which is an annoyance.
case $host in
*-mingw*)
APR_ADDTO(LIBS,[-lshell32 -ladvapi32 -lws2_32 -lrpcrt4 -lmswsock])
ac_cv_func_CreateFileMapping=yes
;;
*)
AC_SEARCH_LIBS(gethostbyname, nsl)
AC_SEARCH_LIBS(gethostname, nsl)
AC_SEARCH_LIBS(socket, socket)
AC_SEARCH_LIBS(crypt, crypt ufc)
AC_CHECK_LIB(truerand, main)
AC_SEARCH_LIBS(modf, m)
;;
esac
dnl ----------------------------- Checking for Threads
echo "${nl}Checking for Threads..."
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
threads="0"
pthreadh="0"
pthreadser="0"
else
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_SAVE
APR_PTHREADS_CHECK
APR_CHECK_PTHREADS_H([
threads="1"
pthreadh="1"
pthreadser="1" ], [
threads="0"
pthreadh="0"
pthreadser="0"
APR_PTHREADS_CHECK_RESTORE ] )
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_SAVE
APR_PTHREADS_CHECK
APR_CHECK_PTHREADS_H([
threads="1"
pthreadh="1"
pthreadser="1" ], [
threads="0"
pthreadser="0"
pthreadh="0"
APR_PTHREADS_CHECK_RESTORE ] )
fi
if test "$pthreadh" = "1"; then
APR_CHECK_PTHREAD_GETSPECIFIC_TWO_ARGS
APR_CHECK_PTHREAD_ATTR_GETDETACHSTATE_ONE_ARG
APR_CHECK_PTHREAD_RECURSIVE_MUTEX
AC_CHECK_FUNCS([pthread_key_delete pthread_rwlock_init \
pthread_attr_setguardsize pthread_yield])
if test "$ac_cv_func_pthread_rwlock_init" = "yes"; then
dnl ----------------------------- Checking for pthread_rwlock_t
AC_CACHE_CHECK([for pthread_rwlock_t], [apr_cv_type_rwlock_t],
AC_TRY_COMPILE([#include <sys/types.h>
#include <pthread.h>], [pthread_rwlock_t *rwlock;],
[apr_cv_type_rwlock_t=yes], [apr_cv_type_rwlock_t=no],
[apr_cv_type_rwlock_t=no]))
if test "$apr_cv_type_rwlock_t" = "yes"; then
AC_DEFINE(HAVE_PTHREAD_RWLOCKS, 1, [Define if pthread rwlocks are available])
fi
fi
if test "$ac_cv_func_pthread_yield" = "no"; then
dnl ----------------------------- Checking for sched_yield
AC_CHECK_HEADERS([sched.h])
AC_CHECK_FUNCS([sched_yield])
fi
fi
fi
ac_cv_define_READDIR_IS_THREAD_SAFE=no
ac_cv_define_GETHOSTBYNAME_IS_THREAD_SAFE=no
ac_cv_define_GETHOSTBYADDR_IS_THREAD_SAFE=no
ac_cv_define_GETSERVBYNAME_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, 1,
[Define if readdir is thread safe]))
if test "x$apr_gethostbyname_is_thread_safe" = "x"; then
AC_CHECK_LIB(c_r, gethostbyname, apr_gethostbyname_is_thread_safe=yes)
fi
if test "$apr_gethostbyname_is_thread_safe" = "yes"; then
AC_DEFINE(GETHOSTBYNAME_IS_THREAD_SAFE, 1,
[Define if gethostbyname is thread safe])
fi
if test "x$apr_gethostbyaddr_is_thread_safe" = "x"; then
AC_CHECK_LIB(c_r, gethostbyaddr, apr_gethostbyaddr_is_thread_safe=yes)
fi
if test "$apr_gethostbyaddr_is_thread_safe" = "yes"; then
AC_DEFINE(GETHOSTBYADDR_IS_THREAD_SAFE, 1,
[Define if gethostbyaddr is thread safe])
fi
if test "x$apr_getservbyname_is_thread_safe" = "x"; then
AC_CHECK_LIB(c_r, getservbyname, apr_getservbyname_is_thread_safe=yes)
fi
if test "$apr_getservbyname_is_thread_safe" = "yes"; then
AC_DEFINE(GETSERVBYNAME_IS_THREAD_SAFE, 1,
[Define if getservbyname is thread safe])
fi
AC_CHECK_FUNCS(gethostbyname_r gethostbyaddr_r getservbyname_r)
else
echo "APR will be non-threaded"
fi
dnl Electric Fence malloc checker.
dnl --with-efence specifies the path to Electric Fence.
dnl This test should remain after the threads checks since libefence
dnl may depend on libpthread.
AC_ARG_WITH(efence,
[ --with-efence[[=DIR]] path to Electric Fence installation],
[ apr_efence_dir="$withval"
if test "$apr_efence_dir" != "yes"; then
APR_ADDTO(LDFLAGS,[-L$apr_efence_dir/lib])
if test "x$apr_platform_runtime_link_flag" != "x"; then
APR_ADDTO(LDFLAGS,
[$apr_platform_runtime_link_flag$apr_efence_dir/lib])
fi
fi
AC_CHECK_LIB(efence, malloc,
[ APR_ADDTO(LIBS,-lefence) ],
[ AC_MSG_ERROR(Electric Fence requested but not detected) ])
])
AC_CHECK_FUNCS(sigsuspend, [ have_sigsuspend="1" ], [ have_sigsuspend="0" ])
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 $host in
*alpha*-dec-osf* )
have_sigwait="1"
;;
esac
AC_SUBST(threads)
AC_SUBST(have_sigsuspend)
AC_SUBST(have_sigwait)
AC_CHECK_FUNCS(poll kqueue port_create)
# Check for the Linux epoll interface; epoll* may be available in libc
# but return ENOSYS on a pre-2.6 kernel, so do a run-time check.
AC_CACHE_CHECK([for epoll support], [apr_cv_epoll],
[AC_TRY_RUN([
#include <sys/epoll.h>
#include <unistd.h>
int main()
{
return epoll_create(5) == -1;
}], [apr_cv_epoll=yes], [apr_cv_epoll=no], [apr_cv_epoll=no])])
if test "$apr_cv_epoll" = "yes"; then
AC_DEFINE([HAVE_EPOLL], 1, [Define if the epoll interface is supported])
fi
dnl ----------------------------- Checking for extended file descriptor handling
# test for epoll_create1
AC_CACHE_CHECK([for epoll_create1 support], [apr_cv_epoll_create1],
[AC_TRY_RUN([
#include <sys/epoll.h>
#include <unistd.h>
int main()
{
return epoll_create1(0) == -1;
}], [apr_cv_epoll_create1=yes], [apr_cv_epoll_create1=no], [apr_cv_epoll_create1=no])])
if test "$apr_cv_epoll_create1" = "yes"; then
AC_DEFINE([HAVE_EPOLL_CREATE1], 1, [Define if epoll_create1 function is supported])
fi
# test for dup3
AC_CACHE_CHECK([for dup3 support], [apr_cv_dup3],
[AC_TRY_RUN([
#include <unistd.h>
int main()
{
return dup3(STDOUT_FILENO, STDERR_FILENO, 0) == -1;
}], [apr_cv_dup3=yes], [apr_cv_dup3=no], [apr_cv_dup3=no])])
if test "$apr_cv_dup3" = "yes"; then
AC_DEFINE([HAVE_DUP3], 1, [Define if dup3 function is supported])
fi
# Test for accept4(). Create a non-blocking socket, bind it to
# an unspecified port & address (kernel picks), and attempt to
# call accept4() on it. If the syscall is wired up (i.e. the
# kernel is new enough), it should return EAGAIN.
AC_CACHE_CHECK([for accept4 support], [apr_cv_accept4],
[AC_TRY_RUN([
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char **argv)
{
int fd;
struct sockaddr_in sin;
if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0)) == -1)
return 1;
memset(&sin, 0, sizeof sin);
sin.sin_family = AF_INET;
if (bind(fd, (struct sockaddr *) &sin, sizeof sin) == -1)
return 2;
if (listen(fd, 5) == -1)
return 3;
if (accept4(fd, NULL, 0, SOCK_NONBLOCK) == 0
|| errno == EAGAIN || errno == EWOULDBLOCK)
return 0;
return 4;
}], [apr_cv_accept4=yes], [apr_cv_accept4=no], [apr_cv_accept4=no])])
if test "$apr_cv_accept4" = "yes"; then
AC_DEFINE([HAVE_ACCEPT4], 1, [Define if accept4 function is supported])
fi
AC_CACHE_CHECK([for SOCK_CLOEXEC support], [apr_cv_sock_cloexec],
[AC_TRY_RUN([
#include <sys/types.h>
#include <sys/socket.h>
int main()
{
return socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0) == -1;
}], [apr_cv_sock_cloexec=yes], [apr_cv_sock_cloexec=no], [apr_cv_sock_cloexec=no])])
if test "$apr_cv_sock_cloexec" = "yes"; then
AC_DEFINE([HAVE_SOCK_CLOEXEC], 1, [Define if the SOCK_CLOEXEC flag is supported])
fi
dnl ----------------------------- Checking for fdatasync: OS X doesn't have it
AC_CHECK_FUNCS(fdatasync)
dnl ----------------------------- Checking for missing POSIX thread functions
AC_CHECK_FUNCS([getpwnam_r getpwuid_r getgrnam_r getgrgid_r])
dnl ----------------------------- Checking for Shared Memory Support
echo "${nl}Checking for Shared Memory Support..."
# The real-time POSIX extensions (e.g. shm_*, sem_*) may only
# be available if linking against librt.
AC_SEARCH_LIBS(shm_open, rt)
case $host in
*-sysv*)
ac_includes_default="$ac_includes_default
#if HAVE_SYS_MUTEX_H /* needed to define lock_t for sys/shm.h */
# include <sys/mutex.h>
#endif";;
esac
AC_CHECK_HEADERS([sys/types.h sys/mman.h sys/ipc.h sys/mutex.h sys/shm.h sys/file.h kernel/OS.h os2.h windows.h])
AC_CHECK_FUNCS([mmap munmap shm_open shm_unlink shmget shmat shmdt shmctl \
create_area])
APR_CHECK_DEFINE(MAP_ANON, sys/mman.h)
AC_CHECK_FILE(/dev/zero)
# Not all systems can mmap /dev/zero (such as HP-UX). Check for that.
if test "$ac_cv_func_mmap" = "yes" &&
test "$ac_cv_file__dev_zero" = "yes"; then
AC_MSG_CHECKING(for mmap that can map /dev/zero)
AC_TRY_RUN([
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
int main()
{
int fd;