This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
4458 lines (4159 loc) · 144 KB
/
configure.ac
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_CONFIG_AUX_DIR(tool)
AC_PREREQ(2.67)
tooldir="$srcdir/tool"
AC_DISABLE_OPTION_CHECKING
m4_include([tool/m4/_colorize_result_prepare.m4])dnl
m4_include([tool/m4/ac_msg_result.m4])dnl
m4_include([tool/m4/colorize_result.m4])dnl
m4_include([tool/m4/ruby_append_option.m4])dnl
m4_include([tool/m4/ruby_append_options.m4])dnl
m4_include([tool/m4/ruby_check_builtin_func.m4])dnl
m4_include([tool/m4/ruby_check_builtin_setjmp.m4])dnl
m4_include([tool/m4/ruby_check_printf_prefix.m4])dnl
m4_include([tool/m4/ruby_check_setjmp.m4])dnl
m4_include([tool/m4/ruby_check_signedness.m4])dnl
m4_include([tool/m4/ruby_check_sizeof.m4])dnl
m4_include([tool/m4/ruby_check_sysconf.m4])dnl
m4_include([tool/m4/ruby_cppoutfile.m4])dnl
m4_include([tool/m4/ruby_decl_attribute.m4])dnl
m4_include([tool/m4/ruby_default_arch.m4])dnl
m4_include([tool/m4/ruby_define_if.m4])dnl
m4_include([tool/m4/ruby_defint.m4])dnl
m4_include([tool/m4/ruby_dtrace_available.m4])dnl
m4_include([tool/m4/ruby_dtrace_postprocess.m4])dnl
m4_include([tool/m4/ruby_func_attribute.m4])dnl
m4_include([tool/m4/ruby_mingw32.m4])dnl
m4_include([tool/m4/ruby_prepend_option.m4])dnl
m4_include([tool/m4/ruby_prog_gnu_ld.m4])dnl
m4_include([tool/m4/ruby_replace_funcs.m4])dnl
m4_include([tool/m4/ruby_replace_type.m4])dnl
m4_include([tool/m4/ruby_require_funcs.m4])dnl
m4_include([tool/m4/ruby_rm_recursive.m4])dnl
m4_include([tool/m4/ruby_setjmp_type.m4])dnl
m4_include([tool/m4/ruby_stack_grow_direction.m4])dnl
m4_include([tool/m4/ruby_thread.m4])dnl
m4_include([tool/m4/ruby_try_cflags.m4])dnl
m4_include([tool/m4/ruby_try_cxxflags.m4])dnl
m4_include([tool/m4/ruby_try_ldflags.m4])dnl
m4_include([tool/m4/ruby_universal_arch.m4])dnl
m4_include([tool/m4/ruby_wasm_tools.m4])dnl
m4_include([tool/m4/ruby_werror_flag.m4])dnl
m4_include([tool/m4/mmtk_ruby.m4])dnl
AC_ARG_VAR([cflags], [additional CFLAGS (ignored when CFLAGS is given)])dnl
AC_ARG_VAR([cppflags], [additional CPPFLAGS (ignored when CPPFLAGS is given)])dnl
AC_ARG_VAR([cxxflags], [additional CXXFLAGS (ignored when CXXFLAGS is given)])dnl
: "environment section" && {
HAVE_BASERUBY=yes
BASERUBY_VERSION=
AC_ARG_WITH(baseruby,
AS_HELP_STRING([--with-baseruby=RUBY], [use RUBY as baseruby; RUBY is the pathname of ruby]),
[AS_CASE(["$withval"],
[*ruby*],[BASERUBY=$withval],
[no],[HAVE_BASERUBY=no],
[AC_MSG_ERROR(need ruby)])
],
[
AC_PATH_PROG([BASERUBY], [ruby], [false])
])
AS_IF([test "$HAVE_BASERUBY" != no -a "`RUBYOPT=- $BASERUBY --disable=gems -e 'print 42 if RUBY_VERSION > "2.2"' 2>/dev/null`" = 42], [
BASERUBY="$BASERUBY --disable=gems"
BASERUBY_VERSION=`$BASERUBY -v`
$BASERUBY -C "$srcdir" tool/downloader.rb -d tool -e gnu config.guess config.sub >&AS_MESSAGE_FD
], [
BASERUBY="echo executable host ruby is required. use --with-baseruby option.; false"
HAVE_BASERUBY=no
])
AC_SUBST(BASERUBY)
AC_SUBST(HAVE_BASERUBY)
: ${GIT=git}
HAVE_GIT=yes
AC_ARG_WITH(git,
AS_HELP_STRING([--without-git], [never use git]),
[AS_CASE([$withval],
[no], [GIT=never-use HAVE_GIT=no],
[yes], [],
[GIT=$withval])])
AS_IF([test x"$HAVE_GIT" = xyes], [command -v "$GIT" > /dev/null || HAVE_GIT=no])
AC_SUBST(GIT)
AC_SUBST(HAVE_GIT)
eval `sed -n -e ['s/^@%:@define RUBY_[A-Z_]*VERSION_\([A-Z][A-Z][A-Z_0-9]*\) \([0-9][0-9]*\)$/\1=\2/p'] \
-e ['s/^@%:@define \(RUBY_PATCHLEVEL\) \(.*\)/\1=\2/p'] \
$srcdir/include/ruby/version.h $srcdir/version.h`
for v in MAJOR MINOR TEENY; do
AS_IF([eval "test \"\$$v\" = ''"], [
AC_MSG_ERROR(could not determine $v number from version.h)
])
done
AC_SUBST(MAJOR)
AC_SUBST(MINOR)
AC_SUBST(TEENY)
AC_SUBST(RUBY_API_VERSION, '$(MAJOR).$(MINOR)')
AC_SUBST(RUBY_PROGRAM_VERSION, '$(MAJOR).$(MINOR).$(TEENY)')
AS_IF([test "$program_prefix" = NONE], [
program_prefix=
])
AS_IF([test "$prefix" -ef .], [
AC_MSG_ERROR(--prefix cannot be the current working directory.)
])
RUBY_BASE_NAME=`echo ruby | sed "$program_transform_name"`
RUBYW_BASE_NAME=`echo rubyw | sed "$program_transform_name"`
AC_SUBST(RUBY_BASE_NAME)
AC_SUBST(RUBYW_BASE_NAME)
AC_SUBST(RUBY_VERSION_NAME, '${RUBY_BASE_NAME}-${ruby_version}')
dnl checks for alternative programs
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AS_CASE(["$target_cpu-$target_os"],
[aarch64-darwin*], [
target_cpu=arm64
AS_CASE(["$target_vendor"], [unknown], [target_vendor=apple target=${target/-unknown-/-apple-}])
target="${target/aarch64/arm64}"
target_alias="${target_alias/aarch64/arm64}"
])
AC_ARG_PROGRAM
RUBY_RM_RECURSIVE
AC_ARG_WITH(gcc,
AS_HELP_STRING([--without-gcc], [never use gcc]),
[
AS_CASE([$withval],
[no], [: ${CC=cc}],
[yes], [: ${CC=gcc}],
[CC=$withval])])
dnl If the user switches compilers, we can't believe the cache
AS_IF([test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"], [
AC_MSG_ERROR(cached CC is different -- throw away $cache_file
(it is also a good idea to do 'make clean' before compiling))
])
RUBY_WASM_TOOLS
AS_CASE(["${build_os}"],
[linux*|cygwin*|msys*], [
# Naruse prefers GCC on Linux
AC_CHECK_TOOLS([CC], [gcc clang cc])
],
[solaris*], [
# Clang on Solaris is largely untested.
# https://bugs.ruby-lang.org/issues/17949
AC_CHECK_TOOLS([CC], [cc gcc])
], [
# OpenBSD wants to prefer cc over gcc.
# See https://github.com/ruby/ruby/pull/2443
AC_CHECK_TOOLS([CC], [cl.exe clang cc gcc c99 /usr/ucb/cc])
])
AC_ARG_VAR([AR], [Archiver command])
AC_ARG_VAR([AS], [Assembler command])
AC_ARG_VAR([CC], [C compiler command])
AC_ARG_VAR([CXX], [C++ compiler command])
AC_ARG_VAR([LD], [Linker command])
AC_ARG_VAR([NM], [Symbol list command])
AC_ARG_VAR([OBJCOPY], [Objcopy command])
AC_ARG_VAR([OBJDUMP], [Objdump command])
AC_ARG_VAR([RANLIB], [Ranlib command])
AC_ARG_VAR([STRIP], [Strip command])
# We don't want to bother things like `ccache gcc`, `clang -shared-libgcc`, ...
set rb_dummy ${CC}
rb_CC=$2
AC_DEFUN([RUBY_CHECK_PROG_FOR_CC], [
rb_prog=`echo "${rb_CC}" | sed "$2"`
AC_CHECK_PROG([$1], [$rb_prog], [$rb_prog])
])
AS_CASE(["/${rb_CC} "],
[*@<:@\ /@:>@"cc "*], [
# Don't try g++/clang++ when CC=cc
AC_CHECK_PROGS([CXX], [cl.exe CC c++])
],
[*icc*], [
# Intel C++ has interprocedural optimizations. It tends to come with its
# own linker etc.
RUBY_CHECK_PROG_FOR_CC([AR], [s/icc/xiar/])
RUBY_CHECK_PROG_FOR_CC([CXX], [s/icc/icpc/])
RUBY_CHECK_PROG_FOR_CC([LD], [s/icc/xild/])
],
[*gcc*], [
# Ditto for GCC.
RUBY_CHECK_PROG_FOR_CC([LD], [s/gcc/ld/])
RUBY_CHECK_PROG_FOR_CC([AR], [s/gcc/gcc-ar/])
RUBY_CHECK_PROG_FOR_CC([CXX], [s/gcc/g++/])
RUBY_CHECK_PROG_FOR_CC([NM], [s/gcc/gcc-nm/])
RUBY_CHECK_PROG_FOR_CC([RANLIB], [s/gcc/gcc-ranlib/])
],
[*clang*], [
# Ditto for LLVM. Note however that llvm-as is a LLVM-IR to LLVM bitcode
# assembler that does not target your machine native binary.
: ${LD:="${CC}"} # ... try -fuse-ld=lld ?
RUBY_CHECK_PROG_FOR_CC([AR], [s/clang/llvm-ar/])
# RUBY_CHECK_PROG_FOR_CC([AS], [s/clang/llvm-as/])
RUBY_CHECK_PROG_FOR_CC([CXX], [s/clang/clang++/])
RUBY_CHECK_PROG_FOR_CC([NM], [s/clang/llvm-nm/])
RUBY_CHECK_PROG_FOR_CC([OBJCOPY], [s/clang/llvm-objcopy/])
RUBY_CHECK_PROG_FOR_CC([OBJDUMP], [s/clang/llvm-objdump/])
RUBY_CHECK_PROG_FOR_CC([RANLIB], [s/clang/llvm-ranlib/])
RUBY_CHECK_PROG_FOR_CC([STRIP], [s/clang/llvm-strip/])
])
AS_UNSET(rb_CC)
AS_UNSET(rb_dummy)
AS_CASE(["${build_os}"],
[solaris*], [
AC_PATH_TOOL([LD], [ld], [/usr/ccs/bin/ld], [/usr/ccs/bin:$PATH])
],
[aix*], [
AC_PATH_TOOL([NM], [nm], [/usr/ccs/bin/nm], [/usr/ccs/bin:$PATH])
])
AS_CASE(["${target_os}"],
[cygwin*|msys*|mingw*], [
ac_cv_prog_ac_ct_OBJCOPY=":"
])
rb_test_CFLAGS=${CFLAGS+yes}
rb_test_CXXFLAGS=${CXXFLAGS+yes}
# BSD's ports and MacPorts prefix GNU binutils with 'g'
dnl Seems necessarily in order to add -std=gnu99 option for gcc 4.9.
m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_C99])
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_RANLIB
AC_CHECK_TOOLS([AR], [gar ar])
AC_CHECK_TOOLS([AS], [gas as])
AC_CHECK_TOOLS([LD], [gld ld]) # ... try gold ?
AC_CHECK_TOOLS([NM], [gnm nm])
AC_CHECK_TOOLS([OBJCOPY], [gobjcopy objcopy])
AC_CHECK_TOOLS([OBJDUMP], [gobjdump objdump])
AC_CHECK_TOOLS([STRIP], [gstrip strip], [:])
AS_IF([test ! $rb_test_CFLAGS], [AS_UNSET(CFLAGS)]); AS_UNSET(rb_test_CFLAGS)
AS_IF([test ! $rb_test_CXXFLAGS], [AS_UNSET(CXXFLAGS)]); AS_UNSET(rb_save_CXXFLAGS)
AS_IF([test "${CXX}" = "g++" -a -z "${GXX}"], [
# AC_PROG_CXX sets $CXX to "g++" when it purposefully finds that there is
# _no_ g++. This brain-damaged design must be worked around. Thankfully,
# similar thing doesn't happen for AC_PROG_CC.
rb_there_is_in_fact_no_gplusplus_but_autoconf_is_cheating_us=true
])
test x"$target_alias" = x &&
target_os=`echo $target_os | sed 's/linux-gnu$/linux/;s/linux-gnu/linux-/'`
ac_install_sh='' # unusable for extension libraries.
AC_ARG_WITH(os-version-style,
AS_HELP_STRING([--with-os-version-style=TYPE],
[OS version number for target and target_os [[full]]]
[(full|teeny|minor+0|minor|major+0|major|none)]),
[os_version_style=$withval],
[os_version_style=full
AS_CASE($target_os, [[*[0-9].*]],
[AS_CASE([`/usr/bin/ruby -e 'puts RUBY_PLATFORM' 2>/dev/null`],
[[*-*[0-9].*.0]], [os_version_style=minor+0],
[[*-*[0-9].*.*]], [os_version_style=full],
[[*-*[0-9].0] ], [os_version_style=major+0],
[[*-*[0-9].*] ], [os_version_style=minor],
[[*-*[0-9]] ], [os_version_style=major],
)])
])
os_version_style_transform=
AS_CASE("${os_version_style}",
[full|teeny], [],
[minor+0], [os_version_style_transform=['s/\([0-9]\.[0-9][0-9]*\)\.[0-9][.0-9]*$/\1.0/']],
[minor], [os_version_style_transform=['s/\([0-9]\.[0-9][0-9]*\)\.[0-9][.0-9]*$/\1/']],
[major+0], [os_version_style_transform=['s/\([0-9]\)\.[0-9][.0-9]*$/\1.0/']],
[major], [os_version_style_transform=['s/\([0-9]\)\.[0-9][.0-9]*$/\1/']],
[none], [os_version_style_transform=['s/[0-9]*\.[0-9][.0-9]*$//']],
[AC_MSG_ERROR(unknown --with-os-version-style: $withval)])
AS_IF([test -z "$target_alias" -a -n "$os_version_style_transform"],
[
target=`echo ${target} | sed "$os_version_style_transform"`
target_os=`echo ${target_os} | sed "$os_version_style_transform"`
])
AC_ARG_WITH(arch,
AS_HELP_STRING([--with-arch=ARCHS],
[build an Apple/NeXT Multi Architecture Binary (MAB);
ARCHS is a comma-delimited list of architectures for
which to build; if this option is disabled or omitted
entirely, then the package will be built only for the
target platform]),
[target_archs="$withval"], [unset target_archs])
AC_ARG_ENABLE(load-relative,
AS_HELP_STRING([--enable-load-relative], [resolve load paths at run time]),
[load_relative=$enableval])
# checks for UNIX variants that set C preprocessor variables
AC_USE_SYSTEM_EXTENSIONS
dnl Checks for programs.
cflagspat=
test -z "$optflags" ||
cflagspat="$cflagspat;s|"`eval echo '"'"${optflags}"'"' | sed 's/[[][|.*]]/\\&/g;s/^ */ /;s/ *$/ /'`'| |g'
test -z "$debugflags" ||
cflagspat="$cflagspat;s|"`eval echo '"'"${debugflags}"'"' | sed 's/[[][|.*]]/\\&/g;s/^ */ /;s/ *$/ /'`'| |g'
test -z "$warnflags" ||
cflagspat="$cflagspat;s|"`eval echo '"'"${warnflags}"'"' | sed 's/[[][|.*]]/\\&/g;s/^ */ /;s/ *$/ /'`'| |g'
AS_IF([test -z "${CFLAGS+set}"], [
cflags=`echo " $cflags " | sed "$cflagspat;s/^ *//;s/ *$//"`
orig_cflags="$cflags"
cflags="$cflags "'${optflags} ${debugflags} ${warnflags}'
])
dnl AS_IF([test -z "${CXXFLAGS+set}"], [
dnl cxxflags=`echo " $cxxflags " | sed "$cflagspat;s/^ *//;s/ *$//"`
dnl orig_cxxflags="$cxxflags"
dnl cxxflags="$cxxflags "'${optflags} ${debugflags} ${warnflags}'
dnl ])
AS_CASE(["$host_os:$build_os"],
[darwin*:darwin*], [
# Following Apple deployed clang are broken
# clang version 1.0 (http://llvm.org/svn/llvm-project/cfe/tags/Apple/clang-23 exported)
# Apple clang version 2.0 (tags/Apple/clang-137) (based on LLVM 2.9svn)
# Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)
AC_PREPROC_IFELSE(
[AC_LANG_PROGRAM([
@%:@if defined __APPLE_CC__ && defined __clang_major__ && __clang_major__ < 3
@%:@error premature clang
@%:@endif
])],
[],
[AC_MSG_ERROR([clang version 3.0 or later is required])])
])
AS_CASE(["$target_os"],
[darwin*], [
AC_MSG_CHECKING(if minimum required OS X version is supported)
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <AvailabilityMacros.h>
@%:@if MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_5
@%:@error pre OS X 10.5
[!<===== pre OS X 10.5 =====>]
@%:@endif
]])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
AC_MSG_ERROR([Unsupported OS X version is required])])
AC_CACHE_CHECK([if thread-local storage is supported], [rb_cv_tls_supported],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[int __thread conftest;]])],
[rb_cv_tls_supported=yes],
[rb_cv_tls_supported=no])])
AS_IF([test x"$rb_cv_tls_supported" != xyes],
[AC_DEFINE(RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED)])
])
RUBY_MINGW32
AC_SUBST(GCC)
AC_SUBST(LD)
AS_IF([test "$GCC" = yes], [
linker_flag=-Wl,
: ${optflags=-O3}
gcc_major=`echo =__GNUC__ | $CC -E -xc - | sed '/^=/!d;s///'`
gcc_minor=`echo =__GNUC_MINOR__ | $CC -E -xc - | sed '/^=/!d;s///'`
test -n "$gcc_major" || gcc_major=0
test -n "$gcc_minor" || gcc_minor=0
icc_version=`echo =__ICC | $CC -E -xc - | sed '/^=/!d;s///;/^__ICC/d'`
test -n "$icc_version" || icc_version=0
# RUBY_APPEND_OPTIONS(XCFLAGS, ["-include ruby/config.h" "-include ruby/missing.h"])
AS_IF([test "$gcc_major" -lt 4], [
AC_MSG_ERROR([too old GCC: $gcc_major.$gcc_minor])
])
], [
linker_flag=
])
RUBY_PROG_GNU_LD
RUBY_CPPOUTFILE
: ${OUTFLAG='-o '}
: ${COUTFLAG=${OUTFLAG}}
: ${CSRCFLAG=''}
AC_SUBST(OUTFLAG)
AC_SUBST(COUTFLAG)
AC_SUBST(CSRCFLAG)
: ${MJIT_CC=$CC}
AS_IF([test "x$cross_compiling" = xno], [
AC_PATH_PROG([MJIT_CC], ${MJIT_CC})
# if $CC is in /usr/lib/ccache/$CC, search original $CC (disable ccache)
AS_IF([echo $RUBY_DEBUG | grep ci > /dev/null &&
echo $MJIT_CC | grep ^/usr/lib/ccache > /dev/null], [
PATH=`echo $PATH | sed "s/\/usr\/lib\/ccache://"` MJIT_CC=`which $CC`])
AS_CASE([$target_os],
[*mingw*], [command -v cygpath > /dev/null && MJIT_CC=`cygpath -ma $MJIT_CC`])
shift 2
MJIT_CC="$MJIT_CC${1+ }$*"
])
AS_CASE(["$build_os"],
[darwin1*.*], [
# Xcode linker warns for deprecated architecture and wrongly
# installed TBD files.
CC_WRAPPER=""
echo 'int main(void) {return 0;}' > conftest.c
AS_IF([$CC -framework Foundation -o conftest conftest.c 2>&1 |
grep '^ld: warning: text-based stub file' >/dev/null], [
CC_WRAPPER=`cd -P "${tooldir}" && pwd`/darwin-cc
CC="$CC_WRAPPER $CC"
])
rm -fr conftest*
])
AS_CASE(["$target_os"],
[wasi*], [
# Clang linker automatically uses wasm-opt with -O if it found.
# https://github.com/llvm/llvm-project/blob/812828984c10857a4cd260eb638c52a4411f9143/clang/lib/Driver/ToolChains/WebAssembly.cpp#L95-L118
# However optimization before asyncify causes misoptimization,
# so wrap clang to insert our fake wasm-opt, which does nothing, in PATH.
CC_WRAPPER=`cd -P "${tooldir}" && pwd`/wasm-clangw
CC="$CC_WRAPPER $CC"
])
cc_version=
for option in --version -v -V -qversion; do
cc_version_message=`$CC $option 2>&1`
cc_version_status=$?
AS_CASE($cc_version_status, [0], [:], [continue])
AS_CASE($cc_version_message, [*Warning*], [continue])
cc_version='$(CC) '$option
break
done
AC_SUBST(CC_VERSION, $cc_version)
AC_SUBST(CC_VERSION_MESSAGE, $cc_version_message)
: ${DLDFLAGS="$LDFLAGS"}
RUBY_UNIVERSAL_ARCH
AS_IF([test "$target_cpu" != "$host_cpu" -a "$GCC" = yes -a "$cross_compiling" = no -a "${universal_binary:-no}" = no], [
RUBY_DEFAULT_ARCH("$target_cpu")
])
host_os=$target_os
host_vendor=$target_vendor
host_cpu=$target_cpu
host=$target
host_alias=$target_alias
AC_CACHE_CHECK([for $AR flags], [rb_cv_arflags], [
AS_IF([$AR rcD conftest.a > /dev/null 2>&1 && rm conftest.a],
[rb_cv_arflags=rcD], [rb_cv_arflags=rcu])
])
AC_SUBST(ARFLAGS, ["$rb_cv_arflags "])
AC_SUBST(ASFLAGS)
AS_CASE(["$target_os"],
[cygwin*|msys*|mingw*], [
AC_CHECK_TOOL(WINDRES, windres)
AC_CHECK_TOOL(DLLWRAP, dllwrap)
target=`echo $target | sed "s/^$target_cpu-/-/"`
target_alias=`echo $target_alias | sed "s/^$target_cpu-/-/"`
target_cpu=`echo $target_cpu | sed s/i.86/i386/`
AS_CASE(["$target"], [-*], [ target="$target_cpu${target}"])
AS_CASE(["$target_alias"], [-*], [ target_alias="$target_cpu${target_alias}"])
AS_CASE(["$target_os"],
[mingw*], [
test "$rb_cv_msvcrt" = "" && unset rb_cv_msvcrt
AC_CACHE_CHECK(for mingw32 runtime DLL, rb_cv_msvcrt, [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@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;};
/^[[ ]]*dll name: \(ucrtbase\|api-ms-win-crt-.*\)\.dll$/{s//ucrt/p;q;}'`],
[rb_cv_msvcrt=msvcrt])
test "$rb_cv_msvcrt" = "" && rb_cv_msvcrt=msvcrt])
RT_VER=`echo "$rb_cv_msvcrt" | tr -cd [0-9]`
test "$RT_VER" = "" && RT_VER=60
test "$rb_cv_msvcrt" = "ucrt" && RT_VER=140
AC_DEFINE_UNQUOTED(RUBY_MSVCRT_VERSION, $RT_VER)
sysconfdir=
])
: ${enable_shared=yes}
],
[hiuxmpp*], [AC_DEFINE(__HIUX_MPP__)]) # by TOYODA Eizi <[email protected]>
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_PROG_MKDIR_P
AS_IF([test "x$MKDIR_P" = "x -d"], [
AS_IF([test x"$as_mkdir_p" != xfalse], [
MKDIR_P='mkdir -p'
echo "use 'mkdir -p' as MKDIR_P"
], [
AC_MSG_ERROR([mkdir -p is required])
])
])
MAKEDIRS="$MKDIR_P"
AC_SUBST(MAKEDIRS)
AC_CHECK_PROG([DTRACE], [${ac_tool_prefix}dtrace], [${ac_tool_prefix}dtrace])
AS_IF([test "$cross_compiling:$ac_cv_prog_DTRACE" = no: -a -n "$ac_tool_prefix"], [
AC_CHECK_PROG([DTRACE], [dtrace], [dtrace])
])
AC_CHECK_PROGS(DOT, dot)
AC_CHECK_PROGS(DOXYGEN, doxygen)
for prog in ${ac_tool_prefix:+${ac_tool_prefix}pkg-config} pkg-config; do
AC_CHECK_PROG(PKG_CONFIG, $prog, [$prog], [], [],
[`"$as_dir/$ac_word$ac_exec_ext" --print-errors --version > /dev/null 2>&1 || echo "$as_dir/$ac_word$ac_exec_ext"`])
test -z "${PKG_CONFIG}" || break
done
AC_MSG_CHECKING([whether it is Android])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@%:@ifndef __ANDROID__
@%:@error Not android
@%:@endif
]], [[]])],
[
AC_MSG_RESULT(yes)
target_os=${target_os}-android
AS_IF([test "x$cross_compiling" = xno], [
AC_MSG_CHECKING([for Android API version])
# hacky workaround: https://github.com/termux/termux-packages/issues/6176
rb_android_api=`getprop ro.build.version.sdk`
AC_MSG_RESULT($rb_android_api)
RUBY_APPEND_OPTIONS(CPPFLAGS, -D__ANDROID_API__=$rb_android_api -Wno-macro-redefined)
])
],
[AC_MSG_RESULT(no)])
AC_SUBST(RM, ['rm -f'])
AC_SUBST(CP, ['cp'])
RMDIRS='$(top_srcdir)/tool/rmdirs'
RMDIR=rmdir
mkdir "rmdirs_$$_test" "rmdirs_$$_test/a"
rmdir --ignore-fail-on-non-empty "rmdirs_$$_test" 2>/dev/null &&
RMDIR='rmdir --ignore-fail-on-non-empty'
$RMDIR -p "rmdirs_$$_test/a" 2>/dev/null &&
{ test -d "rmdirs_$$_test" || RMDIRS="$RMDIR -p"; }
rmdir "rmdirs_$$_test/a" "rmdirs_$$_test" 2>/dev/null
AC_SUBST(RMDIR)
AC_SUBST(RMDIRS)
AC_SUBST(RMALL, ['rm -fr'])
AC_MSG_CHECKING([for cd using physical directory])
rm -fr conf$$.dir
mkdir conf$$.dir &&
(cd conf$$.dir && mkdir src build && cd src &&
$as_ln_s ../build . > /dev/null 2>&1 && cd build &&
for chdir in 'cd -P' 'PWD= cd'; do
/bin/sh -c "$chdir ../src && echo '$chdir' > cdcmd" 2> /dev/null && break
done)
AS_IF([test -f conf$$.dir/src/cdcmd], [
read CHDIR < conf$$.dir/src/cdcmd 2> /dev/null
], [
CHDIR=cd
])
rm -fr conf$$.dir
AC_MSG_RESULT([$CHDIR])
AC_SUBST(CHDIR)
}
: "compiler section" && {
RUBY_WERROR_FLAG([
AC_MSG_CHECKING([whether CFLAGS is valid])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[AC_MSG_RESULT(yes)],
[
AC_MSG_RESULT(no)
AC_MSG_ERROR([something wrong with CFLAGS="$CFLAGS"])
]
)
AC_MSG_CHECKING([whether LDFLAGS is valid])
{
mkdir tmp.$$.try_link &&
cd tmp.$$.try_link &&
cp ../confdefs.h . &&
echo '<?xml?><plist><dict><key>CFBundleIdentifier</key><string></string></dict></plist>' > Info.plist &&
:
} || AC_MSG_ERROR([failed to make temporary directory])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[AC_MSG_RESULT(yes)],
[
cd .. && rm -fr tmp.$$.try_link
AC_MSG_RESULT(no)
AC_MSG_ERROR([something wrong with LDFLAGS="$LDFLAGS"])
]
)
cd .. && rm -fr tmp.$$.try_link
])
: ${RPATHFLAG=''}
rpathflag=''
AS_IF([test x"${RPATHFLAG}" = x], [
AS_CASE(["$target_os"],
[aix*], [rpathflag='-blibpath:'],
[for rpathflag in -R "-rpath "; do
AS_CASE("$rpathflag",
[*" "], [AS_CASE(["${linker_flag}"],
[*,], [rpathflag=`echo "$rpathflag" | tr ' ' ,`])])
rpathflag="${linker_flag}${rpathflag}"
RUBY_TRY_LDFLAGS([${rpathflag}.], [], [rpathflag=])
AS_IF([test "x${rpathflag}" != x], [])
done])
], [
rpathflag=`echo "$RPATHFLAG" | sed 's/%.*//'`
])
RUBY_TRY_LDFLAGS(-fdeclspec, [fdeclspec=yes], [fdeclspec=no])
AS_IF([test "$fdeclspec" = yes], [
RUBY_APPEND_OPTIONS(CFLAGS, -fdeclspec)
RUBY_APPEND_OPTIONS(cflags, -fdeclspec)
RUBY_APPEND_OPTIONS(orig_cflags, -fdeclspec)
])
RUBY_TRY_CXXFLAGS(-fdeclspec, [fdeclspec=yes], [fdeclspec=no])
AS_IF([test "$fdeclspec" = yes], [
RUBY_APPEND_OPTIONS(CXXFLAGS, -fdeclspec)
])
AS_CASE([$RUBY_PATCHLEVEL], [-*],
[RUBY_DEVEL=yes], [RUBY_DEVEL=no])
particular_werror_flags=$RUBY_DEVEL
AC_ARG_ENABLE(werror,
AS_HELP_STRING([--disable-werror],
[don't make warnings into errors
even if a compiler support -Werror feature
[[disabled by default unless development version]]]),
[particular_werror_flags=$enableval])
rb_cv_warnflags="$warnflags"
AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"],
[yes::*|yes:*:set:], [# GCC && (!warnflags || extra_warnflags)
AS_IF([test $gcc_major -le 6], [
extra_warnflags="$extra_warnflags -Wno-maybe-uninitialized"
])
# ICC doesn't support -Werror=
AS_IF([test $icc_version -gt 0], [
particular_werror_flags=no
])
for wflag in \
-Werror=extra-tokens \
-Werror=deprecated-declarations \
-Werror=division-by-zero -Werror=div-by-zero \
-Werror=duplicated-cond \
-Werror=implicit-function-declaration \
-Werror=implicit-int \
-Werror=misleading-indentation \
-Werror=pointer-arith \
-Werror=shorten-64-to-32 \
-Werror=write-strings \
-Werror=old-style-definition \
-Wimplicit-fallthrough=0 \
-Wmissing-noreturn \
-Wno-cast-function-type \
-Wno-constant-logical-operand \
-Wno-long-long \
-Wno-missing-field-initializers \
-Wno-overlength-strings \
-Wno-packed-bitfield-compat \
-Wno-parentheses-equality \
-Wno-self-assign \
-Wno-tautological-compare \
-Wno-unused-parameter \
-Wno-unused-value \
-Wsuggest-attribute=format \
-Wsuggest-attribute=noreturn \
-Wunused-variable \
-diag-disable=175,188,1684,2259,2312 \
$extra_warnflags \
; do
AS_IF([test "$particular_werror_flags" != yes], [
wflag=`echo x$wflag | sed 's/^x-Werror=/-W/;s/^x//'`
])
ok=no
RUBY_TRY_CFLAGS($wflag, [
RUBY_APPEND_OPTIONS(warnflags, $wflag)
ok=yes
])
AS_CASE([$ok:$wflag], [no:-Werror=*], [
wflag=`echo x$wflag | sed 's/^x-Werror=/-W/'`
RUBY_TRY_CFLAGS($wflag, [
RUBY_APPEND_OPTIONS(warnflags, $wflag)
particular_werror_flags=no
])
])
done
AS_IF([test "$particular_werror_flags" = "yes"], [
wflag=-Werror=undef
], [
wflag=-Wundef
])
RUBY_TRY_CFLAGS($wflag, [
RUBY_APPEND_OPTIONS(warnflags, $wflag)
], [], [
@%:@if !defined(RUBY_CONFIG_TEST_NEVER_DEFINED_SYMBOL)
@%:@elif RUBY_CONFIG_TEST_NEVER_DEFINED_SYMBOL
@%:@endif
])
AS_CASE([" $warnflags "],[*" -Wno-missing-field-initializers "*], [wflag="-Wall -Wextra"],
[wflag=-Wall])
RUBY_TRY_CFLAGS($wflag, [warnflags="$wflag${warnflags+ $warnflags}"])
# Disable warnflags while conftest. -Werror=* flags might make bad OS capability guess.
rb_cv_warnflags="$warnflags"
warnflags=
])
RUBY_TRY_CFLAGS(-Qunused-arguments, [RUBY_APPEND_OPTIONS(rb_cv_wsuppress_flags, -Qunused-arguments)])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
@%:@if !(defined(__SUNPRO_C)||defined(__SUNPRO_CC))
@%:@error not sunpro
@%:@endif],[])], [
for e in \
E_STATEMENT_NOT_REACHED \
E_INIT_SIGN_EXTEND \
E_INIT_DOES_NOT_FIT \
E_INITIALIZATION_TYPE_MISMATCH
do
RUBY_TRY_CFLAGS([-erroff=${e}], [
RUBY_APPEND_OPTIONS(rb_cv_warnflags, [-erroff=${e}])
])
done
])
AC_ARG_WITH(compress-debug-sections,
AS_HELP_STRING([--with-compress-debug-sections=type],
[enable debug section compression]),
[compress_debug_sections=$withval], [compress_debug_sections=])
AS_IF([test "$GCC" = yes], [
# -D_FORTIFY_SOURCE
# When defined _FORTIFY_SOURCE, glibc enables some additional sanity
# argument check. The performance drop is very little and Ubuntu enables
# _FORTIFY_SOURCE=2 by default. So, let's support it for protecting us from
# a mistake of silly C extensions.
# TODO: check if link succeeds with _FORTIFY_SOURCE=2.
AS_CASE(["$target_os"],
[mingw*], [
fortify_source=no
])
AC_ARG_ENABLE(fortify_source,
AS_HELP_STRING([--disable-fortify-source],
[disable -D_FORTIFY_SOURCE=2 option, which causes link error on mingw]),
[fortify_source=$enableval])
AS_IF([test "x$fortify_source" != xno], [
RUBY_TRY_CFLAGS([$optflags -D_FORTIFY_SOURCE=2], [RUBY_APPEND_OPTION(XCFLAGS, -D_FORTIFY_SOURCE=2)], [],
[@%:@include <stdio.h>])
])
: ${MJIT_HEADER_FLAGS='-P -dD'}
# -fstack-protector
AS_CASE(["$target_os"],
[mingw*|emscripten*|wasi*], [
stack_protector=no
])
AS_IF([test -z "${stack_protector+set}"], [
AS_FOR(option, opt, [-fstack-protector-strong -fstack-protector], [
RUBY_TRY_CFLAGS(option, [stack_protector=yes])
AS_IF([test "x$stack_protector" = xyes], [
RUBY_TRY_LDFLAGS(option, [], [stack_protector=])
])
AS_IF([test "x$stack_protector" = xyes], [stack_protector=option; break])
])
])
AS_CASE(["$stack_protector"], [-*], [
RUBY_APPEND_OPTION(XCFLAGS, $stack_protector)
RUBY_APPEND_OPTION(XLDFLAGS, $stack_protector)
RUBY_APPEND_OPTION(LDFLAGS, $stack_protector)
])
# aarch64 branch protection
AS_CASE(["$target_cpu"], [aarch64], [
AS_FOR(option, opt, [-mbranch-protection=pac-ret -msign-return-address=all], [
RUBY_TRY_CFLAGS(option, [branch_protection=yes], [branch_protection=no])
AS_IF([test "x$branch_protection" = xyes], [
RUBY_APPEND_OPTION(XCFLAGS, option)
break
])
])
])
AS_CASE("${compress_debug_sections:-zlib}",
[none|no], [], [
RUBY_TRY_LDFLAGS(${linker_flag}--compress-debug-sections=${compress_debug_sections:-zlib},
[compress_debug_sections=${compress_debug_sections:-zlib}],
[compress_debug_sections=no])
])
AS_IF([test "x$compress_debug_sections" != xno], [
RUBY_APPEND_OPTION(DLDFLAGS, ${linker_flag}--compress-debug-sections=$compress_debug_sections)
])
AS_CASE(["$target_os"],[mingw*], [
# On Windows platforms, system provided headers are VC++
# optimized. That is, C++ habits are often contaminated into
# various headers. Most frequent situation is the use of //
# comments. We bypass ANSI C mode for them. Otherwise
# extension libs cannot include those headers.
# Since math.h in some mingw64 wrongly declares frexp and modf
# to be pure, the variables pointed by the second arguments are
# considered uninitialized unexpectedly.
AC_CACHE_CHECK([whether frexp and modf are broken],
rb_cv_mingw64_broken_frexp_modf,
[
save_CFLAGS="$CFLAGS"
AS_IF([test "$particular_werror_flags" = "yes"], [
CFLAGS="$CFLAGS -Werror=uninitialized"
], [
CFLAGS="$CFLAGS -Werror -Wuninitialized"
])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>
int foo(double x)
{
int exp;
frexp(x, &exp);
return exp;
}]], [[if (foo(0.0)) return 1;]])],
[rb_cv_mingw64_broken_frexp_modf=no],
[rb_cv_mingw64_broken_frexp_modf=yes])
CFLAGS="$save_CFLAGS"
])
AS_IF([test "$rb_cv_mingw64_broken_frexp_modf" = yes], [
AC_DEFINE(RUBY_MINGW64_BROKEN_FREXP_MODF)
])
],
[cygwin*|msys*|darwin*|netbsd*], [
# need lgamma_r()
])
# ANSI (no XCFLAGS because this is C only)
AS_CASE(["$target_os"],
[solaris*], [
# Because "-std=gnu99" affects existence of functions on Solaris,
# "-std=gnu99" will be appended to CPPFLAGS.
for ansi_options in -std=gnu99; do
RUBY_TRY_CFLAGS(${ansi_options}, [
RUBY_APPEND_OPTIONS(CPPFLAGS, ${ansi_options})
], [ansi_options=])
test "x${ansi_options}" = x || break
done
],
[
# ANSI (no XCFLAGS because this is C only)
rb_tmp_std_check=`echo $CC $CFLAGS $optflags $warnflags $debugflags | fgrep std= | tr -d '\015'`
AS_IF([test "x$rb_tmp_std_check" = "x"],
[
for ansi_options in -std=gnu99; do
RUBY_TRY_CFLAGS(${ansi_options}, [
RUBY_APPEND_OPTIONS(warnflags, ${ansi_options})
RUBY_APPEND_OPTIONS(strict_warnflags, ${ansi_options})
], [ansi_options=])
test "x${ansi_options}" = x || break
done
])
])
# suppress annoying -Wstrict-overflow warnings
RUBY_TRY_CFLAGS(-fno-strict-overflow, [RUBY_APPEND_OPTION(XCFLAGS, -fno-strict-overflow)])
test "${debugflags+set}" || {RUBY_TRY_CFLAGS(-ggdb3, [debugflags=-ggdb3])}
test "${debugflags+set}" || {RUBY_TRY_CFLAGS(-ggdb, [debugflags=-ggdb])}
test "${debugflags+set}" || {RUBY_TRY_CFLAGS(-g3, [debugflags=-g3])}
])
test $ac_cv_prog_cc_g = yes && : ${debugflags=-g}
AS_IF([test "x$RUBY_DEVEL" = xyes], [RUBY_APPEND_OPTION(XCFLAGS, -DRUBY_DEVEL=1)])
AS_IF([test "$GCC" = ""], [
AS_CASE(["$target_os"],[aix*],[warnflags="$warnflags -qinfo=por" rb_cv_warnflags="$rb_cv_warnflags -qinfo=por"])
])
AS_IF([test "$GCC" = yes], [
RUBY_TRY_CFLAGS(-fvisibility=hidden, [visibility_option=yes], [visibility_option=no])
AC_SUBST(WERRORFLAG, "-Werror")
AS_IF([test "$visibility_option" = yes], [
RUBY_APPEND_OPTION(XCFLAGS, -fvisibility=hidden)
AC_DEFINE(RUBY_SYMBOL_EXPORT_BEGIN, [_Pragma("GCC visibility push(default)")])
AC_DEFINE(RUBY_SYMBOL_EXPORT_END, [_Pragma("GCC visibility pop")])
], [
RUBY_TRY_LDFLAGS([-Wl,-unexported_symbol,_Init_*], [visibility_option=ld], [visibility_option=no])
])
test "$visibility_option" = no || OBJCOPY=:
])
AS_IF([test "$GCC" = yes], [
# optflags
AS_CASE(["$target_os"], [mingw*], [
RUBY_TRY_CFLAGS(-fno-omit-frame-pointer, [optflags="${optflags+$optflags }-fno-omit-frame-pointer"])
RUBY_TRY_CFLAGS(-static-libgcc, [static_libgcc=yes], [static_libgcc=no])
AS_IF([test "$static_libgcc" = yes], [
RUBY_APPEND_OPTION(EXTLDFLAGS, -static-libgcc)
])
])
# disable fast-math
for oflag in -fno-fast-math; do
RUBY_TRY_CFLAGS($oflag, [RUBY_APPEND_OPTION(optflags, $oflag)])
done
for oflag in -fexcess-precision=standard -fp-model\ precise; do
RUBY_TRY_CFLAGS($oflag, [RUBY_APPEND_OPTION(XCFLAGS, $oflag)])
done
])
AS_CASE(["$target_cpu"], [[i[3-6]86*]], [
AC_CACHE_CHECK([for __sync_val_compare_and_swap], [rb_cv_gcc_compiler_cas], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[unsigned long atomic_var;]],
[[__sync_val_compare_and_swap(&atomic_var, 0, 1);]])],
[rb_cv_gcc_compiler_cas=yes],
[
save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -march=i486"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[unsigned long atomic_var;]],
[[__sync_val_compare_and_swap(&atomic_var, 0, 1);]])],
[rb_cv_gcc_compiler_cas=i486],
[rb_cv_gcc_compiler_cas=no])
CFLAGS="$save_CFLAGS"
])
])
AS_IF([test "$rb_cv_gcc_compiler_cas" = i486], [ARCH_FLAG="-march=i486"])
])
AC_ARG_WITH(opt-dir,
AS_HELP_STRING([--with-opt-dir=DIR-LIST],
[add optional headers and libraries directories separated by $PATH_SEPARATOR]),
[
val=`echo "$PATH_SEPARATOR$withval" | sed "s|$PATH_SEPARATOR\([[^$PATH_SEPARATOR]*]\)| -I\1/include|g;s/^ //"`
CPPFLAGS="$CPPFLAGS $val"
val=`echo "$PATH_SEPARATOR$withval" | sed "s|$PATH_SEPARATOR\([[^$PATH_SEPARATOR]*]\)| -L\1/lib${rpathflag:+ $rpathflag\\\\1/lib}|g;s/^ //"`
LDFLAGS="$LDFLAGS $val"
LDFLAGS_OPTDIR="$val"
OPT_DIR="$withval"
], [OPT_DIR=])
test -z "${ac_env_CFLAGS_set}" -a -n "${cflags+set}" && eval CFLAGS="\"$cflags $ARCH_FLAG\""
test -z "${ac_env_CXXFLAGS_set}" -a -n "${cxxflags+set}" && eval CXXFLAGS="\"$cxxflags $ARCH_FLAG\""
}
AC_CACHE_CHECK([whether compiler has statement and declarations in expressions],
rb_cv_have_stmt_and_decl_in_expr,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[ __extension__ ({ int a = 0; a; }); ]])],
[rb_cv_have_stmt_and_decl_in_expr=yes],
[rb_cv_have_stmt_and_decl_in_expr=no])])
AS_IF([test "$rb_cv_have_stmt_and_decl_in_expr" = yes], [
AC_DEFINE(HAVE_STMT_AND_DECL_IN_EXPR)
])
: "header and library section" && {
AC_ARG_WITH(winnt-ver,
AS_HELP_STRING([--with-winnt-ver=0xXXXX], [target Windows NT version (default to 0x0600)]),
[with_winnt_ver="$withval"], [with_winnt_ver="0x0600"])
AS_CASE(["$target_os"],
[mingw*], [
RUBY_APPEND_OPTION(CPPFLAGS, -D_WIN32_WINNT=$with_winnt_ver)
RUBY_APPEND_OPTION(CPPFLAGS, -D__MINGW_USE_VC2005_COMPAT)
])
RUBY_THREAD
dnl Checks for libraries.
AS_CASE(["$target_os"],[*bsd*|dragonfly*],[],[ac_cv_func_daemon=no])
AS_CASE(["$target_os"], [*android*], [
AS_CASE(["$target_cpu"], [arm*], [
ac_cv_func___builtin_setjmp=no
])
])
AS_UNSET(ORIG_LIBS)
POSTLINK=:
AC_SUBST(POSTLINK)
cleanlibs=
AC_SUBST(cleanlibs)
AS_CASE(["$target_os"],
[nextstep*], [ ],
[openstep*], [ ],
[rhapsody*], [ ],
[darwin*], [
ORIG_LIBS="$LIBS"
RUBY_PREPEND_OPTION(LIBS, -lobjc)
RUBY_APPEND_OPTIONS(CPPFLAGS, -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT)
AC_CACHE_CHECK([whether syscall(2) is deprecated], rb_cv_syscall_deprecated,
[RUBY_WERROR_FLAG([
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <unistd.h>]],
[[if (syscall(0)) return 1;]])],
[rb_cv_syscall_deprecated=no],
[rb_cv_syscall_deprecated=yes])])])
AS_IF([test $rb_cv_syscall_deprecated = yes], [
ac_cv_func___syscall=no
ac_cv_func_syscall=no
ac_cv_header_sys_syscall_h=no
ac_cv_header_syscall_h=no