forked from wayneeseguin/miniruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.in
2193 lines (2044 loc) · 60.4 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 Process this file with autoconf to produce a configure script.
AC_INIT()
AC_PREREQ(2.60)
AC_ARG_WITH(baseruby,
[ --with-baseruby=RUBY use RUBY as baseruby; RUBY is the pathname of ruby],
[
case "$withval" in
*ruby*)
BASERUBY=$withval
;;
*)
AC_MSG_ERROR(need ruby)
;;
esac
],
[
BASERUBY="ruby"
])
test "`RUBYOPT=- $BASERUBY -e 'p 42' 2>/dev/null`" = 42 ||
BASERUBY="echo executable host ruby is required. use --with-baseruby option.; false"
AC_SUBST(BASERUBY)
AC_DEFUN([RUBY_MINGW32],
[case "$host_os" in
cygwin*)
AC_CACHE_CHECK(for mingw32 environment, rb_cv_mingw32,
[AC_TRY_CPP([
#ifndef __MINGW32__
# error
#endif
], rb_cv_mingw32=yes,rb_cv_mingw32=no)
rm -f conftest*])
test "$rb_cv_mingw32" = yes && target_os="mingw32"
;;
esac])
AC_DEFUN([RUBY_CPPOUTFILE],
[AC_CACHE_CHECK(whether ${CPP} accepts -o, rb_cv_cppoutfile,
[cppflags=$CPPFLAGS
CPPFLAGS='-o conftest.i'
AC_TRY_CPP([], rb_cv_cppoutfile=yes, rb_cv_cppoutfile=no)
CPPFLAGS=$cppflags
rm -f conftest*])
if test "$rb_cv_cppoutfile" = yes; then
CPPOUTFILE='-o conftest.i'
elif test "$rb_cv_cppoutfile" = no; then
CPPOUTFILE='> conftest.i'
elif test -n "$rb_cv_cppoutfile"; then
CPPOUTFILE="$rb_cv_cppoutfile"
fi
AC_SUBST(CPPOUTFILE)])
AC_DEFUN([RUBY_PROG_GNU_LD],
[AC_CACHE_CHECK(whether the linker is GNU ld, rb_cv_prog_gnu_ld,
[if `$CC $CFLAGS $CPPFLAGS $LDFLAGS --print-prog-name=ld 2>&1` -v 2>&1 | grep "GNU ld" > /dev/null; then
rb_cv_prog_gnu_ld=yes
else
rb_cv_prog_gnu_ld=no
fi
])
GNU_LD=$rb_cv_prog_gnu_ld
AC_SUBST(GNU_LD)])
unset GREP_OPTIONS
rb_version=`grep '^#define RUBY_VERSION ' $srcdir/version.h`
MAJOR=`expr "$rb_version" : '#define RUBY_VERSION "\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*"'`
MINOR=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*"'`
TEENY=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)"'`
if test "$MAJOR" = ""; then
AC_MSG_ERROR(could not determine MAJOR number from version.h)
fi
if test "$MINOR" = ""; then
AC_MSG_ERROR(could not determine MINOR number from version.h)
fi
if test "$TEENY" = ""; then
AC_MSG_ERROR(could not determine TEENY number from version.h)
fi
AC_SUBST(MAJOR)
AC_SUBST(MINOR)
AC_SUBST(TEENY)
if test "$MAJOR" = "1"; then
AC_DEFINE(CANONICALIZATION_FOR_MATHN)
fi
dnl checks for alternative programs
AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [
case $withval in
no) : ${CC=cc}
;;
yes) : ${CC=gcc}
;;
*) CC=$withval
;;
esac])
dnl If the user switches compilers, we can't believe the cache
if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
then
AC_MSG_ERROR(cached CC is different -- throw away $cache_file
(it is also a good idea to do 'make clean' before compiling))
fi
if test "$program_prefix" = NONE; then
program_prefix=
fi
AC_CANONICAL_TARGET
target_os=`echo $target_os | sed 's/linux-gnu$/linux/;s/linux-gnu/linux-/'`
ac_install_sh='' # unusable for extension libraries.
ifelse(currently,disabled, [
dnl checks for fat-binary
AC_ARG_ENABLE(fat-binary,
[ --enable-fat-binary=ARCHS
build an Apple/NeXT Multi Architecture Binary (MAB);
ARCHS is a comma-delimited list of architectures for
which to build; if ARCHS is omitted, then the package
will be built for all architectures supported by the
platform ("ppc" for MacOS/X and Darwin; "ppc,i386"
for Rhapsody; "m68k,i386,sparc" for OpenStep;
"m68k,i386,sparc,hppa" for NextStep); if this option
is disabled or omitted entirely, then the package
will be built only for the target platform],
[fat_binary=$enableval], [fat_binary=no])
if test "$fat_binary" != no; then
AC_MSG_CHECKING([target architectures])
# Respect TARGET_ARCHS setting from environment if available.
if test -z "$TARGET_ARCHS"; then
# Respect ARCH given to --enable-fat-binary if present.
if test "$fat_binary" != yes; then
TARGET_ARCHS=`echo "$fat_binary" | tr ',' ' '`
else
# Choose a default set of architectures based upon platform.
case "$target_os" in
darwin*)
TARGET_ARCHS="ppc"
;;
rhapsody*)
TARGET_ARCHS="ppc i386"
;;
openstep*)
TARGET_ARCHS="m68k i386 sparc"
;;
nextstep*)
TARGET_ARCHS="m68k i386 sparc hppa"
;;
*)
TARGET_ARCHS=`arch`
esac
fi
fi
AC_MSG_RESULT([$TARGET_ARCHS])
# /usr/lib/arch_tool -archify_list $TARGET_ARCHS
ARCH_FLAG=
for archs in $TARGET_ARCHS
do
ARCH_FLAG="$ARCH_FLAG -arch $archs"
done
AC_DEFINE(NEXT_FAT_BINARY)
fi
], [fat_binary=no])
case $target_cpu in
i?86) frame_address=yes;;
*) frame_address=no;;
esac
AC_ARG_ENABLE(frame-address,
[ --enable-frame-address use GCC __builtin_frame_address(). ],
[frame_address=$enableval])
if test $frame_address = yes; then
AC_DEFINE(USE_BUILTIN_FRAME_ADDRESS)
fi
AC_ARG_PROGRAM
dnl Checks for programs.
: ${CFLAGS=} ${cflags='${optflags} ${debugflags} ${warnflags}'}
: ${CXXFLAGS=} ${cxxflags='${optflags} ${debugflags} ${warnflags}'}
if test x"${build}" != x"${host}"; then
AC_CHECK_TOOL(CC, gcc)
fi
AC_PROG_CC
AC_PROG_CXX
AC_PROG_GCC_TRADITIONAL
test $ac_cv_prog_cc_g = yes && : ${debugflags=-g}
if test "$GCC" = yes; then
linker_flag=-Wl,
: ${optflags=-O2} ${warnflags="-Wall -Wno-parentheses"}
else
linker_flag=
fi
CFLAGS="${CFLAGS} `eval echo $cflags`"
CXXFLAGS="${CXXFLAGS} `eval echo $cxxflags`"
RUBY_PROG_GNU_LD
RUBY_CPPOUTFILE
: ${OUTFLAG='-o '}
: ${COUTFLAG=${OUTFLAG}}
AC_SUBST(OUTFLAG)
AC_SUBST(COUTFLAG)
RUBY_MINGW32
AC_CHECK_TOOL(RANLIB, ranlib, :)
AC_CHECK_TOOL(AR, ar)
if test -z "$AR"; then
AC_CHECK_PROGS(AR, aal, ar)
fi
AC_CHECK_TOOL(AS, as)
ASFLAGS=$ASFLAGS
AC_SUBST(ASFLAGS)
case "$target_os" in
cygwin*|mingw*)
ac_cv_prog_OBJCOPY=":";;
esac
# BSD's ports and MacPorts prefix GNU binutils with 'g'
AC_CHECK_TOOLS(OBJDUMP, [objdump gobjdump])
AC_CHECK_TOOLS(OBJCOPY, [objcopy gobjcopy])
case "$target_os" in
cygwin*|mingw*)
AC_CHECK_TOOL(NM, nm)
AC_CHECK_TOOL(WINDRES, windres)
AC_CHECK_TOOL(DLLWRAP, dllwrap)
target_cpu=`echo $target_cpu | sed s/i.86/i386/`
case "$target_os" in
mingw*)
test "$rb_cv_msvcrt" = "" && unset rb_cv_msvcrt
AC_CACHE_CHECK(for mingw32 runtime DLL, rb_cv_msvcrt, [
AC_TRY_LINK([#include <stdio.h>],
[FILE* volatile f = stdin; return 0;],
[rb_cv_msvcrt=`$OBJDUMP -p conftest$ac_exeext |
tr A-Z a-z |
sed -n '/^[[ ]]*dll name: \(msvc.*\)\.dll$/{s//\1/p;q;}'`],
[rb_cv_msvcrt=msvcrt])
test "$rb_cv_msvcrt" = "" && rb_cv_msvcrt=msvcrt])
esac
: ${enable_shared=yes}
;;
aix*)
AC_CHECK_TOOL(NM, nm, /usr/ccs/bin/nm, /usr/ccs/bin:$PATH)
;;
hiuxmpp*)
# by TOYODA Eizi <toyoda@npd.kishou.go.jp>
AC_DEFINE(__HIUX_MPP__)
;;
esac
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_INSTALL
# checks for UNIX variants that set C preprocessor variables
AC_USE_SYSTEM_EXTENSIONS
AC_SUBST(RM, ['rm -f'])
AC_SUBST(CP, ['cp'])
if $as_mkdir_p; then
MAKEDIRS='mkdir -p'
else
MAKEDIRS='install -d'
fi
AC_SUBST(MAKEDIRS)
AC_SUBST(RMDIRS, ['$(top_srcdir)/tool/rmdirs'])
AC_SUBST(RMALL, ['rm -fr'])
dnl check for large file stuff
mv confdefs.h confdefs1.h
: > confdefs.h
AC_SYS_LARGEFILE
mv confdefs.h largefile.h
mv confdefs1.h confdefs.h
cat largefile.h >> confdefs.h
case "$target_os" in
mingw*)
ac_cv_type_off_t=yes
ac_cv_sizeof_off_t=8
;;
esac
AC_CHECK_TYPES([long long, off_t])
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(long long, 0)
AC_CHECK_SIZEOF(__int64, 0)
AC_CHECK_SIZEOF(off_t, 0)
AC_CHECK_SIZEOF(void*, 4)
AC_CHECK_SIZEOF(float, 4)
AC_CHECK_SIZEOF(double, 8)
AC_CHECK_SIZEOF(time_t, 0)
dnl RUBY_REPLACE_TYPE [typename] [default type] [macro type] [included]
AC_DEFUN([RUBY_REPLACE_TYPE], [dnl
AC_CHECK_TYPE([$1],
[AC_DEFINE_UNQUOTED(rb_[$1], [$1])],
[AC_DEFINE_UNQUOTED(rb_[$1], [$2])],
[$4])
AC_CACHE_CHECK([for convertible type of [$1]], rb_cv_[$1]_convertible, [
u= t=
AC_COMPILE_IFELSE(
[AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
[$4], [(rb_[$1])-1 > 0])],
[u=U])
if test x"$t" = x; then
AC_COMPILE_IFELSE(
[AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
[$4], [sizeof(rb_[$1]) > sizeof(long)])],
[t=LL])
fi
if test x"$t" = x; then
AC_COMPILE_IFELSE(
[AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
[$4], [sizeof(rb_[$1]) == sizeof(long)])],
[t=LONG])
fi
if test x"$t" = x; then
t=INT
fi
rb_cv_[$1]_convertible=${u}${t}])
AC_DEFINE_UNQUOTED([$3]2NUM[(v)], [${rb_cv_[$1]_convertible}2NUM(v)])
AC_DEFINE_UNQUOTED(NUM2[$3][(v)], [NUM2${rb_cv_[$1]_convertible}(v)])
])
RUBY_REPLACE_TYPE(pid_t, int, PIDT)
RUBY_REPLACE_TYPE(uid_t, int, UIDT)
RUBY_REPLACE_TYPE(gid_t, int, GIDT)
AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes,
[AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
rb_cv_have_prototypes=yes,
rb_cv_have_prototypes=no)])
if test "$rb_cv_have_prototypes" = yes; then
AC_DEFINE(HAVE_PROTOTYPES)
fi
AC_CACHE_CHECK(token paste string, rb_cv_tokenpaste,
[AC_TRY_COMPILE([#define paste(a,b) a##b],
[int xy = 1; return paste(x,y);],
rb_cv_tokenpaste=ansi,
rb_cv_tokenpaste=knr)])
if test "$rb_cv_tokenpaste" = ansi; then
AC_DEFINE(TOKEN_PASTE(x,y),[x##y])
else
AC_DEFINE(TOKEN_PASTE(x,y),[x/**/y])
fi
AC_CACHE_CHECK(stringization, rb_cv_stringization, [
rb_cv_stringization=no
for string in "#expr" '"expr"'; do
AC_COMPILE_IFELSE([
AC_LANG_BOOL_COMPILE_TRY([
#define STRINGIZE0(expr) $string
#define STRINGIZE(expr) STRINGIZE0(expr)
#undef real_test_for_stringization
#define test_for_stringization -.real_test_for_stringization.-
const char stringized[[]] = STRINGIZE(test_for_stringization);
], [sizeof(stringized) == 32])],
[rb_cv_stringization="$string"; break],
[rb_cv_stringization=no])
done]
)
AC_DEFINE(STRINGIZE(expr),STRINGIZE0(expr))
if test x"$rb_cv_stringization" != xno -a "$rb_cv_stringization" != "#expr"; then
AC_DEFINE_UNQUOTED(STRINGIZE0(expr),$rb_cv_stringization)
AC_DEFINE(OLD_FASHIONED_STRINGIZATION,1)
fi
AC_CACHE_CHECK([string literal concatenation],
rb_cv_string_literal_concatenation, [
AC_COMPILE_IFELSE([
AC_LANG_BOOL_COMPILE_TRY([
const char concatenated_literal[[]] = "literals" "to"
"be" "concatenated.";
], [sizeof(concatenated_literal) == 26])],
[rb_cv_string_literal_concatenation=yes],
[rb_cv_string_literal_concatenation=no])]
)
if test "$rb_cv_string_literal_concatenation" = no; then
AC_DEFINE(NO_STRING_LITERAL_CONCATENATION,1)
fi
AC_CACHE_CHECK(for variable length prototypes and stdarg.h, rb_cv_stdarg,
[AC_TRY_COMPILE([
#include <stdarg.h>
int foo(int x, ...) {
va_list va;
va_start(va, x);
va_arg(va, int);
va_arg(va, char *);
va_arg(va, double);
return 0;
}
], [return foo(10, "", 3.14);],
rb_cv_stdarg=yes,
rb_cv_stdarg=no)])
if test "$rb_cv_stdarg" = yes; then
AC_DEFINE(HAVE_STDARG_PROTOTYPES)
fi
AC_CACHE_CHECK(for variable length macro, rb_cv_va_args_macro,
[AC_TRY_COMPILE([@%:@define FOO(a, ...) foo(a, @%:@@%:@__VA_ARGS__)],
[FOO(1);FOO(1,2);FOO(1,2,3);],
rb_cv_va_args_macro=yes,
rb_cv_va_args_macro=no)])
if test "$rb_cv_va_args_macro" = yes; then
AC_DEFINE(HAVE_VA_ARGS_MACRO)
fi
AC_DEFUN([RUBY_FUNC_ATTRIBUTE], [dnl
m4_ifval([$2], dnl
[AS_VAR_PUSHDEF([attrib],[$2])], dnl
[AS_VAR_PUSHDEF([attrib],[FUNC_]AS_TR_CPP($1))] dnl
)dnl
m4_ifval([$3], dnl
[AS_VAR_PUSHDEF([rbcv],[$3])], dnl
[AS_VAR_PUSHDEF([rbcv],[rb_cv_func_][$1])]dnl
)dnl
AC_CACHE_CHECK(for [$1] function attribute, rbcv,
[rbcv=x
if test "${ac_c_werror_flag+set}"; then
rb_c_werror_flag="$ac_c_werror_flag"
else
unset rb_c_werror_flag
fi
ac_c_werror_flag=yes
for mac in "__attribute__ (($1)) x" "x __attribute__ (($1))" "__declspec($1) x" x; do
AC_TRY_COMPILE(
[#define ]attrib[(x) $mac
]attrib[(void conftest_attribute_check(void));], [],
[rbcv="$mac"; break])
done
if test "${rb_c_werror_flag+set}"; then
ac_c_werror_flag="$rb_c_werror_flag"
else
unset ac_c_werror_flag
fi
])
AC_DEFINE_UNQUOTED(attrib[(x)], $rbcv)
AS_VAR_POPDEF([attrib])
AS_VAR_POPDEF([rbcv])
])
RUBY_FUNC_ATTRIBUTE(noreturn, NORETURN)
RUBY_FUNC_ATTRIBUTE(deprecated, DEPRECATED)
RUBY_FUNC_ATTRIBUTE(noinline, NOINLINE)
RUBY_FUNC_ATTRIBUTE(stdcall)
RUBY_FUNC_ATTRIBUTE(cdecl)
RUBY_FUNC_ATTRIBUTE(fastcall)
if test "$GCC" = yes; then
AC_CACHE_CHECK([for function alias], [rb_cv_gcc_function_alias],
[rb_cv_gcc_function_alias=no
for a in alias weak,alias; do
AC_TRY_LINK([void foo(void) {}
void bar(void) __attribute__(($a("foo")));], [bar()],
[rb_cv_gcc_function_alias=$a; break])
done])
if test "$rb_cv_gcc_function_alias" = no; then
AC_DEFINE([RUBY_ALIAS_FUNCTION(old_prot, new_name, args)],
[VALUE old_prot {return new_name args;}])
else
AC_DEFINE_UNQUOTED([RUBY_ALIAS_FUNCTION(old_prot, new_name, args)],
[VALUE old_prot __attribute__(($rb_cv_gcc_function_alias(@%:@new_name)));])
fi
fi
AC_CACHE_CHECK([for RUBY_EXTERN], rb_cv_ruby_extern,
[rb_cv_ruby_extern=no
for mac in "__attribute__((dllimport))" "__declspec(dllimport)"; do
AC_TRY_COMPILE(
[extern $mac void conftest(void);],
[rb_cv_ruby_extern="extern $mac"; break])
done])
test "x$rb_cv_ruby_extern" = xno || AC_DEFINE_UNQUOTED(RUBY_EXTERN, $rb_cv_ruby_extern)
XCFLAGS="$XCFLAGS -DRUBY_EXPORT"
dnl Check whether we need to define sys_nerr locally
AC_CHECK_DECLS([sys_nerr], [], [], [$ac_includes_default
#include <errno.h>])
case "$target_os" in
freebsd*)
AC_CACHE_CHECK([whether pthread should be enabled by default],
rb_cv_enable_pthread_default,
[AC_TRY_CPP([
#include <osreldate.h>
#if __FreeBSD_version < 502102
#error pthread should be disabled on this platform
#endif
],
rb_cv_enable_pthread_default=yes,
rb_cv_enable_pthread_default=no)])
enable_pthread_default=$rb_cv_enable_pthread_default
;;
mingw*)
enable_pthread_default=no
;;
*)
enable_pthread_default=yes
;;
esac
AC_ARG_ENABLE(pthread,
[ --enable-pthread use pthread library.],
[enable_pthread=$enableval], [enable_pthread=$enable_pthread_default])
dnl Checks for libraries.
case "$target_os" in
*bsd*|dragonfly*)
;;
*)
ac_cv_func_daemon=no
;;
esac
case "$target_os" in
solaris*)
AC_DEFINE(SIZEOF_STRUCT_DIRENT_TOO_SMALL, 1)
LIBS="-lm $LIBS"
;;
nextstep*) ;;
openstep*) ;;
rhapsody*) ;;
darwin*) LIBS="-lobjc $LIBS"
CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE"
AC_TRY_CPP([#include <AvailabilityMacros.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1040
#error pre OS X 10.4
[!<===== pre OS X 10.4 =====>]
#endif
],
[
ac_cv_header_ucontext_h=no
],
[
AC_DEFINE(BROKEN_SETREUID, 1)
AC_DEFINE(BROKEN_SETREGID, 1)
])
ac_cv_lib_crypt_crypt=no
AC_CACHE_CHECK(for broken crypt with 8bit chars, rb_cv_broken_crypt,
[AC_TRY_RUN([
#include <stdio.h>
#include <unistd.h>
#include <string.h>
int
main()
{
char buf[256];
strcpy(buf, crypt("", "\xE0\xA0"));
return strcmp(buf, crypt("", "\xE0\xA0"));
}
],
rb_cv_broken_crypt=no,
rb_cv_broken_crypt=yes,
rb_cv_broken_crypt=yes)])
if test "$rb_cv_broken_crypt" = yes; then
AC_DEFINE(BROKEN_CRYPT, 1)
fi
;;
hpux*) LIBS="-lm $LIBS"
ac_cv_c_inline=no;;
human*) ac_cv_func_getpgrp_void=yes
ac_cv_func_setitimer=no
;;
beos*|haiku*) ac_cv_func_link=no
ac_cv_func_sched_yield=no
ac_cv_func_pthread_attr_setinheritsched=no
case "$target_os" in
beos*) ac_cv_header_net_socket_h=yes;;
haiku*) ac_cv_func_shutdown=no;;
esac
LIBS="$LIBS" # m lib is include in root under BeOS/Haiku
;;
cygwin*) ac_cv_header_langinfo_h=yes
AC_LIBOBJ([langinfo])
;;
mingw*) LIBS="-lshell32 -lws2_32 $LIBS"
ac_cv_header_a_out_h=no
ac_cv_header_pwd_h=no
ac_cv_header_utime_h=no
ac_cv_header_sys_ioctl_h=no
ac_cv_header_sys_param_h=no
ac_cv_header_sys_resource_h=no
ac_cv_header_sys_select_h=no
ac_cv_header_sys_time_h=no
ac_cv_header_sys_times_h=no
ac_cv_header_sys_socket_h=no
ac_cv_func_times=yes
ac_cv_func_waitpid=yes
ac_cv_func_fsync=yes
ac_cv_func_seekdir=yes
ac_cv_func_telldir=yes
ac_cv_func_isinf=yes
ac_cv_func_isnan=yes
ac_cv_func_finite=yes
ac_cv_func_link=yes
ac_cv_func_truncate=yes
ac_cv_func_fseeko=yes
ac_cv_func_ftello=yes
ac_cv_lib_crypt_crypt=no
ac_cv_func_getpgrp_void=no
ac_cv_func_setpgrp_void=yes
ac_cv_func_memcmp_working=yes
ac_cv_lib_dl_dlopen=no
rb_cv_binary_elf=no
rb_cv_negative_time_t=no
ac_cv_func_fcntl=yes
AC_LIBOBJ([langinfo])
;;
os2-emx*) LIBS="-lm $LIBS"
ac_cv_lib_dir_opendir=no;;
msdosdjgpp*) LIBS="-lm $LIBS"
ac_cv_func_getpgrp_void=yes
ac_cv_func_setitimer=no
ac_cv_sizeof_rlim_t=4
ac_cv_func_fork=no
ac_cv_func_setrlimit=no
ac_cv_header_sys_socket_h=no
;;
bsdi*) LIBS="-lm $LIBS"
AC_DEFINE(BROKEN_SETREUID, 1)
AC_DEFINE(BROKEN_SETREGID, 1)
ac_cv_sizeof_rlim_t=8;;
freebsd*) LIBS="-lm $LIBS"
;;
dragonfly*) LIBS="-lm $LIBS"
;;
bow) ac_cv_func_setitimer=no
;;
superux*) ac_cv_func_setitimer=no
;;
*) LIBS="-lm $LIBS";;
esac
AC_CHECK_LIB(crypt, crypt)
AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
AC_CHECK_LIB(socket, socketpair) # SunOS/Solaris
AC_CHECK_LIB(rt, clock_gettime) # GNU/Linux
case "$target_cpu" in
alpha*) case "$target_os"::"$GCC" in
*::yes) CFLAGS="-mieee $CFLAGS" ;; # gcc
osf*) CFLAGS="-ieee $CFLAGS" ;; # ccc
esac ;;
esac
ac_cv_header_net_socket_h=${ac_cv_header_net_socket_h=no}
if test "$ac_cv_header_net_socket_h" = yes; then
ac_cv_header_sys_socket_h=${ac_cv_header_sys_socket_h=no}
else
ac_cv_header_sys_socket_h=${ac_cv_header_sys_socket_h=yes}
fi
dnl Checks for header files.
AC_HEADER_DIRENT
dnl AC_HEADER_STDC has been checked in AC_USE_SYSTEM_EXTENSIONS
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(limits.h sys/file.h sys/ioctl.h sys/syscall.h\
fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
syscall.h pwd.h grp.h a.out.h utime.h direct.h sys/resource.h \
sys/mkdev.h sys/utime.h xti.h netinet/in_systm.h float.h ieeefp.h pthread.h \
ucontext.h intrinsics.h langinfo.h locale.h sys/sendfile.h time.h \
net/socket.h sys/socket.h)
dnl Check additional types.
AC_CHECK_SIZEOF(rlim_t, 0, [
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdio.h>
])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_CHECK_SIZEOF(size_t, 0)
AC_CHECK_SIZEOF(ptrdiff_t, $ac_cv_sizeof_size_t)
AC_STRUCT_ST_BLKSIZE
AC_STRUCT_ST_BLOCKS
AC_STRUCT_ST_RDEV
AC_CHECK_MEMBERS([struct stat.st_atim])
AC_CHECK_MEMBERS([struct stat.st_atimespec])
AC_CHECK_MEMBERS([struct stat.st_atimensec])
AC_CHECK_MEMBERS([struct stat.st_mtim])
AC_CHECK_MEMBERS([struct stat.st_mtimespec])
AC_CHECK_MEMBERS([struct stat.st_mtimensec])
AC_CHECK_MEMBERS([struct stat.st_ctim])
AC_CHECK_MEMBERS([struct stat.st_ctimespec])
AC_CHECK_MEMBERS([struct stat.st_ctimensec])
AC_CHECK_TYPES([struct timespec], [], [], [@%:@ifdef HAVE_TIME_H
@%:@include <time.h>
@%:@endif])
AC_CHECK_TYPE(fd_mask, [AC_DEFINE(HAVE_RB_FD_INIT, 1)])
dnl RUBY_DEFINT TYPENAME, SIZE, [SIGNED-OR-UNSIGNED], [INCLUDES = DEFAULT-INCLUDES]
AC_DEFUN([RUBY_DEFINT], [dnl
AC_CACHE_CHECK([for $1], [rb_cv_type_$1],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])
typedef $1 t; int s = sizeof(t) == 42;])],
[rb_cv_type_$1=yes],
[case m4_bmatch([$2], [^[1-9][0-9]*$], $2, [$ac_cv_sizeof_]AS_TR_SH($2)) in
"1") rb_cv_type_$1="m4_if([$3], [], [signed ], [$3 ])char";;
"$ac_cv_sizeof_short") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])short";;
"$ac_cv_sizeof_int") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])int";;
"$ac_cv_sizeof_long") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])long";;
"$ac_cv_sizeof_long_long") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])long long";;
"$ac_cv_sizeof___int64") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])__int64";;
*) rb_cv_type_$1=no;;
esac])])
if test "${rb_cv_type_$1}" != no; then
AC_DEFINE([HAVE_]AS_TR_CPP($1), 1)
test "${rb_cv_type_$1}" = yes || AC_DEFINE_UNQUOTED($1, [$rb_cv_type_$1])
fi
])
RUBY_DEFINT(int8_t, 1)
RUBY_DEFINT(uint8_t, 1, unsigned)
RUBY_DEFINT(int16_t, 2)
RUBY_DEFINT(uint16_t, 2, unsigned)
RUBY_DEFINT(int32_t, 4)
RUBY_DEFINT(uint32_t, 4, unsigned)
RUBY_DEFINT(int64_t, 8)
RUBY_DEFINT(uint64_t, 8, unsigned)
RUBY_DEFINT(int128_t, 16)
RUBY_DEFINT(uint128_t, 16, unsigned)
RUBY_DEFINT(intptr_t, void*)
RUBY_DEFINT(uintptr_t, void*, unsigned)
RUBY_DEFINT(ssize_t, size_t) dnl may differ from int, so not use AC_TYPE_SSIZE_T.
AC_CACHE_CHECK(for stack end address, rb_cv_stack_end_address,
[rb_cv_stack_end_address=no
for addr in __libc_stack_end _SEND; do
AC_TRY_LINK(
[extern void *$addr;],
[if (!$addr) return 1;],
[rb_cv_stack_end_address="$addr"; break])
done])
if test $rb_cv_stack_end_address != no; then
AC_DEFINE_UNQUOTED(STACK_END_ADDRESS, $rb_cv_stack_end_address)
fi
dnl Checks for library functions.
AC_TYPE_GETGROUPS
AC_TYPE_SIGNAL
case "${target_cpu}-${target_os}" in
powerpc-darwin*)
AC_LIBSOURCES(alloca.c)
AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.${ac_objext}])
AC_DEFINE(C_ALLOCA)
AC_DEFINE_UNQUOTED(alloca, alloca)
;;
*)
AC_FUNC_ALLOCA
;;
esac
AC_FUNC_MEMCMP
# http://sources.redhat.com/ml/libc-hacker/2005-08/msg00008.html
# Debian GNU/Linux Etch's libc6.1 2.3.6.ds1-13etch5 has this problem.
# Debian GNU/Linux Lenny's libc6.1 2.7-10 has no problem.
AC_CACHE_CHECK(for broken erfc of glibc-2.3.6 on IA64, rb_cv_broken_glibc_ia64_erfc,
[AC_TRY_RUN([
#include <math.h>
int
main()
{
erfc(10000.0);
return 0;
}
],
rb_cv_broken_glibc_ia64_erfc=no,
rb_cv_broken_glibc_ia64_erfc=yes,
rb_cv_broken_glibc_ia64_erfc=no)])
case $rb_cv_broken_glibc_ia64_erfc in
yes) ac_cv_func_erf=no;;
esac
AC_REPLACE_FUNCS(dup2 memmove strerror\
strchr strstr crypt flock vsnprintf\
isnan finite isinf hypot acosh erf tgamma lgamma_r cbrt \
strlcpy strlcat)
AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot fsync getcwd eaccess\
truncate ftruncate chsize times utimes utimensat fcntl lockf lstat\
link symlink readlink\
setitimer setruid seteuid setreuid setresuid setproctitle socketpair\
setrgid setegid setregid setresgid issetugid pause lchown lchmod\
getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
getpriority getrlimit setrlimit sysconf group_member\
dlopen sigprocmask sigaction sigsetjmp _setjmp _longjmp snprintf\
setsid telldir seekdir fchmod cosh sinh tanh log2 round signbit\
setuid setgid daemon select_large_fdset setenv unsetenv\
mktime timegm gmtime_r clock_gettime gettimeofday\
pread sendfile shutdown sigaltstack)
AC_CACHE_CHECK(for __builtin_setjmp, ac_cv_func___builtin_setjmp,
[AC_TRY_LINK([@%:@include <setjmp.h>
jmp_buf jb; void t(v) int v; {__builtin_longjmp(jb, v);}],
[__builtin_setjmp(jb);],
[ac_cv_func___builtin_setjmp=yes],
[ac_cv_func___builtin_setjmp=no])
])
test x$ac_cv_func__longjmp = xno && ac_cv_func__setjmp=no
AC_MSG_CHECKING(for setjmp type)
AC_ARG_WITH(setjmp-type,
[ --with-setjmp-type select setjmp type], [
case $withval in
__builtin_setjmp) setjmp_prefix=__builtin_;;
_setjmp) setjmp_prefix=_;;
sigsetjmp) setjmp_prefix=sig;;
setjmp) setjmp_prefix=;;
'') unset setjmp_prefix;;
*) AC_MSG_ERROR(invalid setjmp type: $withval);;
esac], [unset setjmp_prefix])
if test ${setjmp_prefix+set}; then
if test "${setjmp_prefix}" && eval test '$ac_cv_func_'${setjmp_prefix}setjmp = no; then
AC_MSG_ERROR(${setjmp_prefix}setjmp is not available)
fi
elif test "$ac_cv_func___builtin_setjmp" = yes; then
setjmp_prefix=__builtin_
elif test "$ac_cv_func__setjmp" = yes; then
setjmp_prefix=_
elif test "$ac_cv_func_sigsetjmp" = yes; then
case $target_os in
solaris*|cygwin*)
setjmp_prefix=;;
*)
setjmp_prefix=sig;;
esac
else
setjmp_prefix=
fi
if test x$setjmp_prefix = xsig; then
setjmp_sigmask=yes
else
unset setjmp_sigmask
fi
AC_MSG_RESULT(${setjmp_prefix}setjmp)
AC_DEFINE_UNQUOTED([RUBY_SETJMP(env)], [${setjmp_prefix}setjmp(env${setjmp_sigmask+,0})])
AC_DEFINE_UNQUOTED([RUBY_LONGJMP(env,val)], [${setjmp_prefix}longjmp(env,val)])
AC_DEFINE_UNQUOTED(RUBY_JMP_BUF, ${setjmp_sigmask+${setjmp_prefix}}jmp_buf)
AC_ARG_ENABLE(setreuid,
[ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.],
[use_setreuid=$enableval])
if test "$use_setreuid" = yes; then
AC_DEFINE(USE_SETREUID)
AC_DEFINE(USE_SETREGID)
fi
AC_STRUCT_TIMEZONE
AC_CACHE_CHECK(for struct tm.tm_gmtoff, rb_cv_member_struct_tm_tm_gmtoff,
[AC_TRY_COMPILE([#include <time.h>],
[struct tm t; t.tm_gmtoff = 3600;],
[rb_cv_member_struct_tm_tm_gmtoff=yes],
[rb_cv_member_struct_tm_tm_gmtoff=no])])
if test "$rb_cv_member_struct_tm_tm_gmtoff" = yes; then
AC_DEFINE(HAVE_STRUCT_TM_TM_GMTOFF)
fi
AC_CACHE_CHECK(for external int daylight, rb_cv_have_daylight,
[AC_TRY_LINK([#include <time.h>
int i;],
[i = daylight;],
rb_cv_have_daylight=yes,
rb_cv_have_daylight=no)])
if test "$rb_cv_have_daylight" = yes; then
AC_DEFINE(HAVE_DAYLIGHT)
fi
AC_DEFUN([RUBY_CHECK_VARTYPE], [dnl
AC_CACHE_CHECK([for external $1], rb_cv_var_$1,
[rb_cv_var_$1=no
AC_TRY_COMPILE([
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 1
#endif
$2
;
const volatile void *volatile t;],
[t = &(&$1)[0];],
[for t in $3; do
AC_TRY_COMPILE([
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 1
#endif
$2
;
extern $t $1;
const volatile void *volatile t;],
[t = &(&$1)[0];],
[rb_cv_var_$1=$t; break])
done])])
if test "[$rb_cv_var_]$1" != no; then
AC_DEFINE([HAVE_VAR_]m4_toupper($1))
AC_DEFINE_UNQUOTED([TYPEOF_VAR_]m4_toupper($1), $rb_cv_var_$1)
fi])
RUBY_CHECK_VARTYPE(timezone, [@%:@include <time.h>], [long int])
RUBY_CHECK_VARTYPE(altzone, [@%:@include <time.h>], [long int])
AC_CHECK_FUNCS(timezone)
if test "$ac_cv_func_timezone" = yes; then
AC_CACHE_CHECK([whether timezone requires zero arguments], rb_cv_func_timezone_void,
[AC_TRY_COMPILE([@%:@include <time.h>],
[(void)timezone(0, 0);],
[rb_cv_func_timezone_void=no],
[rb_cv_func_timezone_void=yes])]
)
if test $rb_cv_func_timezone_void = yes; then
AC_DEFINE(TIMEZONE_VOID)
fi
fi
AC_CACHE_CHECK(for negative time_t for gmtime(3), rb_cv_negative_time_t,
[AC_TRY_RUN([
#include <time.h>
void
check(tm, y, m, d, h, s)
struct tm *tm;
int y, m, d, h, s;
{
if (!tm ||
tm->tm_year != y ||
tm->tm_mon != m-1 ||
tm->tm_mday != d ||
tm->tm_hour != h ||
tm->tm_sec != s) {
exit(1);
}
}
int
main()
{
time_t t = -1;
struct tm *tm;
check(gmtime(&t), 69, 12, 31, 23, 59);
t = ~(time_t)0 << 31;
check(gmtime(&t), 1, 12, 13, 20, 52);
return 0;
}
],
rb_cv_negative_time_t=yes,
rb_cv_negative_time_t=no,
rb_cv_negative_time_t=yes)])
if test "$rb_cv_negative_time_t" = yes; then
AC_DEFINE(NEGATIVE_TIME_T)
fi
if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then
AC_DEFINE(POSIX_SIGNAL)
else
AC_CHECK_FUNCS(sigsetmask)
AC_CACHE_CHECK(for BSD signal semantics, rb_cv_bsd_signal,
[AC_TRY_RUN([
#include <stdio.h>
#include <signal.h>
void
sig_handler(dummy)
int dummy;
{
}
int
main()
{
signal(SIGINT, sig_handler);
kill(getpid(), SIGINT);
kill(getpid(), SIGINT);
return 0;
}
],
rb_cv_bsd_signal=yes,
rb_cv_bsd_signal=no,
rb_cv_bsd_signal=$ac_cv_func_sigsetmask)])
if test "$rb_cv_bsd_signal" = yes; then
AC_DEFINE(BSD_SIGNAL)
fi