forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 4
/
acinclude.m4
4525 lines (4104 loc) · 142 KB
/
acinclude.m4
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 GLIBCXX_CONDITIONAL (NAME, SHELL-TEST)
dnl
dnl Exactly like AM_CONDITIONAL, but delays evaluation of the test until the
dnl end of configure. This lets tested variables be reassigned, and the
dnl conditional will depend on the final state of the variable. For a simple
dnl example of why this is needed, see GLIBCXX_ENABLE_HOSTED.
dnl
m4_define([_m4_divert(glibcxx_diversion)], 8000)dnl
AC_DEFUN([GLIBCXX_CONDITIONAL], [dnl
m4_divert_text([glibcxx_diversion],dnl
AM_CONDITIONAL([$1],[$2])
)dnl
])dnl
AC_DEFUN([GLIBCXX_EVALUATE_CONDITIONALS], [m4_undivert([glibcxx_diversion])])dnl
dnl
dnl Check to see what architecture and operating system we are compiling
dnl for. Also, if architecture- or OS-specific flags are required for
dnl compilation, pick them up here.
dnl
AC_DEFUN([GLIBCXX_CHECK_HOST], [
. $glibcxx_srcdir/configure.host
AC_MSG_NOTICE([CPU config directory is $cpu_include_dir])
AC_MSG_NOTICE([OS config directory is $os_include_dir])
])
dnl
dnl Initialize the rest of the library configury. At this point we have
dnl variables like $host.
dnl
dnl Sets:
dnl SUBDIRS
dnl Substs:
dnl glibcxx_builddir (absolute path)
dnl glibcxx_srcdir (absolute path)
dnl toplevel_builddir (absolute path)
dnl toplevel_srcdir (absolute path)
dnl with_cross_host
dnl with_newlib
dnl with_target_subdir
dnl plus
dnl - the variables in GLIBCXX_CHECK_HOST / configure.host
dnl - default settings for all AM_CONFITIONAL test variables
dnl - lots of tools, like CC and CXX
dnl
AC_DEFUN([GLIBCXX_CONFIGURE], [
# Keep these sync'd with the list in Makefile.am. The first provides an
# expandable list at autoconf time; the second provides an expandable list
# (i.e., shell variable) at configure time.
m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/filesystem doc po testsuite python])
SUBDIRS='glibcxx_SUBDIRS'
# These need to be absolute paths, yet at the same time need to
# canonicalize only relative paths, because then amd will not unmount
# drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
glibcxx_builddir=`${PWDCMD-pwd}`
case $srcdir in
[\\/$]* | ?:[\\/]*) glibcxx_srcdir=${srcdir} ;;
*) glibcxx_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
esac
toplevel_builddir=${glibcxx_builddir}/..
toplevel_srcdir=${glibcxx_srcdir}/..
AC_SUBST(glibcxx_builddir)
AC_SUBST(glibcxx_srcdir)
AC_SUBST(toplevel_builddir)
AC_SUBST(toplevel_srcdir)
# We use these options to decide which functions to include. They are
# set from the top level.
AC_ARG_WITH([target-subdir],
AC_HELP_STRING([--with-target-subdir=SUBDIR],
[configuring in a subdirectory]))
AC_ARG_WITH([cross-host],
AC_HELP_STRING([--with-cross-host=HOST],
[configuring with a cross compiler]))
AC_ARG_WITH([newlib],
AC_HELP_STRING([--with-newlib],
[assume newlib as a system C library]))
# Will set LN_S to either 'ln -s', 'ln', or 'cp -p' (if linking isn't
# available). Uncomment the next line to force a particular method.
AC_PROG_LN_S
#LN_S='cp -p'
AC_CHECK_TOOL(AS, as)
AC_CHECK_TOOL(AR, ar)
AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
AM_MAINTAINER_MODE
# Set up safe default values for all subsequent AM_CONDITIONAL tests
# which are themselves conditionally expanded.
## (Right now, this only matters for enable_wchar_t, but nothing prevents
## other macros from doing the same. This should be automated.) -pme
# Check for C library flavor since GNU/Linux platforms use different
# configuration directories depending on the C library in use.
AC_EGREP_CPP([_using_uclibc], [
#include <stdio.h>
#if __UCLIBC__
_using_uclibc
#endif
], uclibc=yes, uclibc=no)
AC_EGREP_CPP([_using_bionic], [
#include <stdio.h>
#if __BIONIC__
_using_bionic
#endif
], bionic=yes, bionic=no)
# Find platform-specific directories containing configuration info.
# Also possibly modify flags used elsewhere, as needed by the platform.
GLIBCXX_CHECK_HOST
])
dnl
dnl Tests for newer compiler features, or features that are present in newer
dnl compiler versions but not older compiler versions still in use, should
dnl be placed here.
dnl
dnl Defines:
dnl WERROR='-Werror' if requested and possible; g++'s that lack the
dnl new inlining code or the new system_header pragma will die on -Werror.
dnl Leave it out by default and use maint-mode to use it.
dnl SECTION_FLAGS='-ffunction-sections -fdata-sections' if
dnl compiler supports it and the user has not requested debug mode.
dnl
AC_DEFUN([GLIBCXX_CHECK_COMPILER_FEATURES], [
# All these tests are for C++; save the language and the compiler flags.
# The CXXFLAGS thing is suspicious, but based on similar bits previously
# found in GLIBCXX_CONFIGURE.
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_test_CXXFLAGS="${CXXFLAGS+set}"
ac_save_CXXFLAGS="$CXXFLAGS"
# Check for maintainer-mode bits.
if test x"$USE_MAINTAINER_MODE" = xno; then
WERROR=''
else
WERROR='-Werror'
fi
# Check for -ffunction-sections -fdata-sections
AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
CXXFLAGS='-g -Werror -ffunction-sections -fdata-sections'
AC_TRY_COMPILE([int foo; void bar() { };],, [ac_fdsections=yes], [ac_fdsections=no])
if test "$ac_test_CXXFLAGS" = set; then
CXXFLAGS="$ac_save_CXXFLAGS"
else
# this is the suspicious part
CXXFLAGS=''
fi
if test x"$ac_fdsections" = x"yes"; then
SECTION_FLAGS='-ffunction-sections -fdata-sections'
fi
AC_MSG_RESULT($ac_fdsections)
AC_LANG_RESTORE
AC_SUBST(WERROR)
AC_SUBST(SECTION_FLAGS)
])
dnl
dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
dnl the native linker is in use, all variables will be defined to something
dnl safe (like an empty string).
dnl
dnl Defines:
dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
dnl OPT_LDFLAGS='-Wl,-O1' and '-z,relro' if possible
dnl LD (as a side effect of testing)
dnl Sets:
dnl with_gnu_ld
dnl glibcxx_ld_is_gold (set to "no" or "yes")
dnl glibcxx_gnu_ld_version (possibly)
dnl
dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
dnl set glibcxx_gnu_ld_version to 12345. Zeros cause problems.
dnl
AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
# If we're not using GNU ld, then there's no point in even trying these
# tests. Check for that first. We should have already tested for gld
# by now (in libtool), but require it now just to be safe...
test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
AC_REQUIRE([AC_PROG_LD])
AC_REQUIRE([AC_PROG_AWK])
# The name set by libtool depends on the version of libtool. Shame on us
# for depending on an impl detail, but c'est la vie. Older versions used
# ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
# top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
# makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
# set (hence we're using an older libtool), then set it.
if test x${with_gnu_ld+set} != xset; then
if test x${ac_cv_prog_gnu_ld+set} != xset; then
# We got through "ac_require(ac_prog_ld)" and still not set? Huh?
with_gnu_ld=no
else
with_gnu_ld=$ac_cv_prog_gnu_ld
fi
fi
# Start by getting the version number. I think the libtool test already
# does some of this, but throws away the result.
glibcxx_ld_is_gold=no
if test x"$with_gnu_ld" = x"yes"; then
AC_MSG_CHECKING([for ld version])
changequote(,)
if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
glibcxx_ld_is_gold=yes
fi
ldver=`$LD --version 2>/dev/null |
sed -e 's/GNU gold /GNU ld /;s/GNU ld version /GNU ld /;s/GNU ld ([^)]*) /GNU ld /;s/GNU ld \([0-9.][0-9.]*\).*/\1/; q'`
changequote([,])
glibcxx_gnu_ld_version=`echo $ldver | \
$AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
AC_MSG_RESULT($glibcxx_gnu_ld_version)
fi
# Set --gc-sections.
glibcxx_have_gc_sections=no
if test "$glibcxx_ld_is_gold" = "yes"; then
if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
glibcxx_have_gc_sections=yes
fi
else
glibcxx_gcsections_min_ld=21602
if test x"$with_gnu_ld" = x"yes" &&
test $glibcxx_gnu_ld_version -gt $glibcxx_gcsections_min_ld ; then
glibcxx_have_gc_sections=yes
fi
fi
if test "$glibcxx_have_gc_sections" = "yes"; then
# Sufficiently young GNU ld it is! Joy and bunny rabbits!
# NB: This flag only works reliably after 2.16.1. Configure tests
# for this are difficult, so hard wire a value that should work.
ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS='-Wl,--gc-sections'
# Check for -Wl,--gc-sections
AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
AC_TRY_LINK([ int one(void) { return 1; }
int two(void) { return 2; }
], [ two(); ] , [ac_gcsections=yes], [ac_gcsections=no])
if test "$ac_gcsections" = "yes"; then
rm -f conftest.c
touch conftest.c
if $CC -c conftest.c; then
if $LD --gc-sections -o conftest conftest.o 2>&1 | \
grep "Warning: gc-sections option ignored" > /dev/null; then
ac_gcsections=no
fi
fi
rm -f conftest.c conftest.o conftest
fi
if test "$ac_gcsections" = "yes"; then
SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
fi
AC_MSG_RESULT($ac_gcsections)
if test "$ac_test_CFLAGS" = set; then
CFLAGS="$ac_save_CFLAGS"
else
# this is the suspicious part
CFLAGS=''
fi
fi
# Set -z,relro.
# Note this is only for shared objects.
ac_ld_relro=no
if test x"$with_gnu_ld" = x"yes"; then
AC_MSG_CHECKING([for ld that supports -Wl,-z,relro])
cxx_z_relo=`$LD -v --help 2>/dev/null | grep "z relro"`
if test -n "$cxx_z_relo"; then
OPT_LDFLAGS="-Wl,-z,relro"
ac_ld_relro=yes
fi
AC_MSG_RESULT($ac_ld_relro)
fi
# Set linker optimization flags.
if test x"$with_gnu_ld" = x"yes"; then
OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
fi
AC_SUBST(SECTION_LDFLAGS)
AC_SUBST(OPT_LDFLAGS)
])
dnl
dnl Check for headers for, and arguments to, the setrlimit() function.
dnl Used only in testsuite_hooks.h. Called from GLIBCXX_CONFIGURE_TESTSUITE.
dnl
dnl Defines:
dnl _GLIBCXX_RES_LIMITS if we can set artificial resource limits
dnl various HAVE_LIMIT_* for individual limit names
dnl
AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT_ancilliary], [
AC_MSG_CHECKING([for RLIMIT_$1])
AC_TRY_COMPILE(
[#include <unistd.h>
#include <sys/time.h>
#include <sys/resource.h>
],
[ int f = RLIMIT_$1 ; ],
[glibcxx_mresult=1], [glibcxx_mresult=0])
AC_DEFINE_UNQUOTED(HAVE_LIMIT_$1, $glibcxx_mresult,
[Only used in build directory testsuite_hooks.h.])
if test $glibcxx_mresult = 1 ; then res=yes ; else res=no ; fi
AC_MSG_RESULT($res)
])
AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT], [
setrlimit_have_headers=yes
AC_CHECK_HEADERS(unistd.h sys/time.h sys/resource.h,
[],
[setrlimit_have_headers=no])
# If don't have the headers, then we can't run the tests now, and we
# won't be seeing any of these during testsuite compilation.
if test $setrlimit_have_headers = yes; then
# Can't do these in a loop, else the resulting syntax is wrong.
GLIBCXX_CHECK_SETRLIMIT_ancilliary(DATA)
GLIBCXX_CHECK_SETRLIMIT_ancilliary(RSS)
GLIBCXX_CHECK_SETRLIMIT_ancilliary(VMEM)
GLIBCXX_CHECK_SETRLIMIT_ancilliary(AS)
GLIBCXX_CHECK_SETRLIMIT_ancilliary(FSIZE)
# Check for rlimit, setrlimit.
AC_CACHE_VAL(glibcxx_cv_setrlimit, [
AC_TRY_COMPILE(
[#include <unistd.h>
#include <sys/time.h>
#include <sys/resource.h>
],
[struct rlimit r;
setrlimit(0, &r);],
[glibcxx_cv_setrlimit=yes], [glibcxx_cv_setrlimit=no])
])
fi
AC_MSG_CHECKING([for testsuite resource limits support])
if test $setrlimit_have_headers = yes && test $glibcxx_cv_setrlimit = yes; then
ac_res_limits=yes
AC_DEFINE(_GLIBCXX_RES_LIMITS, 1,
[Define if using setrlimit to set resource limits during
"make check"])
else
ac_res_limits=no
fi
AC_MSG_RESULT($ac_res_limits)
])
dnl
dnl Check whether S_ISREG (Posix) or S_IFREG is available in <sys/stat.h>.
dnl Define HAVE_S_ISREG / HAVE_S_IFREG appropriately.
dnl
AC_DEFUN([GLIBCXX_CHECK_S_ISREG_OR_S_IFREG], [
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -fno-exceptions"
AC_MSG_CHECKING([for S_ISREG or S_IFREG])
AC_CACHE_VAL(glibcxx_cv_S_ISREG, [
GCC_TRY_COMPILE_OR_LINK(
[#include <sys/stat.h>],
[struct stat buffer;
fstat(0, &buffer);
S_ISREG(buffer.st_mode);],
[glibcxx_cv_S_ISREG=yes],
[glibcxx_cv_S_ISREG=no])
])
AC_CACHE_VAL(glibcxx_cv_S_IFREG, [
GCC_TRY_COMPILE_OR_LINK(
[#include <sys/stat.h>],
[struct stat buffer;
fstat(0, &buffer);
S_IFREG & buffer.st_mode;],
[glibcxx_cv_S_IFREG=yes],
[glibcxx_cv_S_IFREG=no])
])
res=no
if test $glibcxx_cv_S_ISREG = yes; then
AC_DEFINE(HAVE_S_ISREG, 1,
[Define if S_ISREG is available in <sys/stat.h>.])
res=S_ISREG
elif test $glibcxx_cv_S_IFREG = yes; then
AC_DEFINE(HAVE_S_IFREG, 1,
[Define if S_IFREG is available in <sys/stat.h>.])
res=S_IFREG
fi
AC_MSG_RESULT($res)
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
dnl
dnl Check whether poll is available in <poll.h>, and define HAVE_POLL.
dnl
AC_DEFUN([GLIBCXX_CHECK_POLL], [
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -fno-exceptions"
AC_MSG_CHECKING([for poll])
AC_CACHE_VAL(glibcxx_cv_POLL, [
GCC_TRY_COMPILE_OR_LINK(
[#include <poll.h>],
[struct pollfd pfd[1];
pfd[0].events = POLLIN;
poll(pfd, 1, 0);],
[glibcxx_cv_POLL=yes],
[glibcxx_cv_POLL=no])
])
if test $glibcxx_cv_POLL = yes; then
AC_DEFINE(HAVE_POLL, 1, [Define if poll is available in <poll.h>.])
fi
AC_MSG_RESULT($glibcxx_cv_POLL)
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
dnl
dnl Check whether writev is available in <sys/uio.h>, and define HAVE_WRITEV.
dnl
AC_DEFUN([GLIBCXX_CHECK_WRITEV], [
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -fno-exceptions"
AC_MSG_CHECKING([for writev])
AC_CACHE_VAL(glibcxx_cv_WRITEV, [
GCC_TRY_COMPILE_OR_LINK(
[#include <sys/uio.h>],
[struct iovec iov[2];
writev(0, iov, 0);],
[glibcxx_cv_WRITEV=yes],
[glibcxx_cv_WRITEV=no])
])
if test $glibcxx_cv_WRITEV = yes; then
AC_DEFINE(HAVE_WRITEV, 1, [Define if writev is available in <sys/uio.h>.])
fi
AC_MSG_RESULT($glibcxx_cv_WRITEV)
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
dnl
dnl Check whether int64_t is available in <stdint.h>, and define HAVE_INT64_T.
dnl Also check whether int64_t is actually a typedef to long or long long.
dnl
AC_DEFUN([GLIBCXX_CHECK_INT64_T], [
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_MSG_CHECKING([for int64_t])
AC_CACHE_VAL(glibcxx_cv_INT64_T, [
AC_TRY_COMPILE(
[#include <stdint.h>],
[int64_t var;],
[glibcxx_cv_INT64_T=yes],
[glibcxx_cv_INT64_T=no])
])
if test $glibcxx_cv_INT64_T = yes; then
AC_DEFINE(HAVE_INT64_T, 1, [Define if int64_t is available in <stdint.h>.])
AC_MSG_RESULT($glibcxx_cv_INT64_T)
AC_MSG_CHECKING([for int64_t as long])
AC_CACHE_VAL(glibcxx_cv_int64_t_long, [
AC_TRY_COMPILE(
[#include <stdint.h>
template<typename, typename> struct same { enum { value = -1 }; };
template<typename Tp> struct same<Tp, Tp> { enum { value = 1 }; };
int array[same<int64_t, long>::value];], [],
[glibcxx_cv_int64_t_long=yes], [glibcxx_cv_int64_t_long=no])
])
if test $glibcxx_cv_int64_t_long = yes; then
AC_DEFINE(HAVE_INT64_T_LONG, 1, [Define if int64_t is a long.])
AC_MSG_RESULT($glibcxx_cv_int64_t_long)
fi
AC_MSG_CHECKING([for int64_t as long long])
AC_CACHE_VAL(glibcxx_cv_int64_t_long_long, [
AC_TRY_COMPILE(
[#include <stdint.h>
template<typename, typename> struct same { enum { value = -1 }; };
template<typename Tp> struct same<Tp, Tp> { enum { value = 1 }; };
int array[same<int64_t, long long>::value];], [],
[glibcxx_cv_int64_t_long_long=yes], [glibcxx_cv_int64_t_long_long=no])
])
if test $glibcxx_cv_int64_t_long_long = yes; then
AC_DEFINE(HAVE_INT64_T_LONG_LONG, 1, [Define if int64_t is a long long.])
AC_MSG_RESULT($glibcxx_cv_int64_t_long_long)
fi
fi
AC_LANG_RESTORE
])
dnl
dnl Check whether LFS support is available.
dnl
AC_DEFUN([GLIBCXX_CHECK_LFS], [
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -fno-exceptions"
AC_MSG_CHECKING([for LFS support])
AC_CACHE_VAL(glibcxx_cv_LFS, [
GCC_TRY_COMPILE_OR_LINK(
[#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
],
[FILE* fp;
fopen64("t", "w");
fseeko64(fp, 0, SEEK_CUR);
ftello64(fp);
lseek64(1, 0, SEEK_CUR);
struct stat64 buf;
fstat64(1, &buf);],
[glibcxx_cv_LFS=yes],
[glibcxx_cv_LFS=no])
])
if test $glibcxx_cv_LFS = yes; then
AC_DEFINE(_GLIBCXX_USE_LFS, 1, [Define if LFS support is available.])
fi
AC_MSG_RESULT($glibcxx_cv_LFS)
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
dnl
dnl Check for whether a fully dynamic basic_string implementation should
dnl be turned on, that does not put empty objects in per-process static
dnl memory (mostly useful together with shared memory allocators, see PR
dnl libstdc++/16612 for details).
dnl
dnl --enable-fully-dynamic-string defines _GLIBCXX_FULLY_DYNAMIC_STRING to 1
dnl --disable-fully-dynamic-string defines _GLIBCXX_FULLY_DYNAMIC_STRING to 0
dnl otherwise undefined
dnl + Usage: GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING[(DEFAULT)]
dnl Where DEFAULT is either `yes' or `no'.
dnl
AC_DEFUN([GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING], [
GLIBCXX_ENABLE(fully-dynamic-string,$1,,[do not put empty strings in per-process static memory])
if test $enable_fully_dynamic_string = yes; then
enable_fully_dynamic_string_def=1
else
enable_fully_dynamic_string_def=0
fi
AC_DEFINE_UNQUOTED([_GLIBCXX_FULLY_DYNAMIC_STRING], [${enable_fully_dynamic_string_def}],
[Define to 1 if a fully dynamic basic_string is wanted, 0 to disable, undefined for platform defaults])
])
dnl
dnl Does any necessary configuration of the testsuite directory. Generates
dnl the testsuite_hooks.h header.
dnl
dnl GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE must be done before this.
dnl
dnl Sets:
dnl enable_abi_check
dnl GLIBCXX_TEST_WCHAR_T
dnl GLIBCXX_TEST_THREAD
dnl Substs:
dnl baseline_dir
dnl baseline_subdir_switch
dnl
AC_DEFUN([GLIBCXX_CONFIGURE_TESTSUITE], [
# Do checks for resource limit functions.
GLIBCXX_CHECK_SETRLIMIT
if $GLIBCXX_IS_NATIVE ; then
# Look for setenv, so that extended locale tests can be performed.
GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
fi
if $GLIBCXX_IS_NATIVE && test $is_hosted = yes &&
test $enable_symvers != no; then
case "$host" in
*-*-cygwin*)
enable_abi_check=no ;;
*)
enable_abi_check=yes ;;
esac
else
# Only build this as native, since automake does not understand
# CXX_FOR_BUILD.
enable_abi_check=no
fi
# Export file names for ABI checking.
baseline_dir="$glibcxx_srcdir/config/abi/post/${abi_baseline_pair}"
AC_SUBST(baseline_dir)
baseline_subdir_switch="$abi_baseline_subdir_switch"
AC_SUBST(baseline_subdir_switch)
])
dnl
dnl Does any necessary configuration for docbook in the docs directory.
dnl
dnl XSLTPROC must be set before this
dnl
dnl Sets:
dnl glibcxx_stylesheets
dnl Substs:
dnl XSL_STYLE_DIR
dnl
AC_DEFUN([GLIBCXX_CONFIGURE_DOCBOOK], [
AC_MSG_CHECKING([for docbook stylesheets for documentation creation])
glibcxx_stylesheets=no
if test x${XSLTPROC} = xyes && echo '<title/>' | xsltproc --noout --nonet --xinclude http://docbook.sourceforge.net/release/xsl-ns/current/xhtml-1_1/docbook.xsl - 2>/dev/null; then
glibcxx_stylesheets=yes
fi
AC_MSG_RESULT($glibcxx_stylesheets)
AC_MSG_CHECKING([for local stylesheet directory])
glibcxx_local_stylesheets=no
if test x"$glibcxx_stylesheets" = x"yes"; then
if test -d /usr/share/sgml/docbook/xsl-ns-stylesheets; then
glibcxx_local_stylesheets=yes
XSL_STYLE_DIR=/usr/share/sgml/docbook/xsl-ns-stylesheets
fi
if test -d /usr/share/xml/docbook/stylesheet/docbook-xsl-ns; then
glibcxx_local_stylesheets=yes
XSL_STYLE_DIR=/usr/share/xml/docbook/stylesheet/docbook-xsl-ns
fi
if test -d /usr/share/xml/docbook/stylesheet/nwalsh5/current; then
glibcxx_local_stylesheets=yes
XSL_STYLE_DIR=/usr/share/xml/docbook/stylesheet/nwalsh5/current
fi
fi
AC_MSG_RESULT($glibcxx_local_stylesheets)
if test x"$glibcxx_local_stylesheets" = x"yes"; then
AC_SUBST(XSL_STYLE_DIR)
AC_MSG_NOTICE($XSL_STYLE_DIR)
else
glibcxx_stylesheets=no
fi
# Check for epub3 dependencies.
AC_MSG_CHECKING([for epub3 stylesheets for documentation creation])
glibcxx_epub_stylesheets=no
if test x"$glibcxx_local_stylesheets" = x"yes"; then
if test -f "$XSL_STYLE_DIR/epub3/chunk.xsl"; then
glibcxx_epub_stylesheets=yes
fi
fi
AC_MSG_RESULT($glibcxx_epub_stylesheets)
AM_CONDITIONAL(BUILD_EPUB, test x"$glibcxx_epub_stylesheets" = x"yes")
])
dnl
dnl Set up *_INCLUDES variables for all sundry Makefile.am's.
dnl
dnl Substs:
dnl GLIBCXX_INCLUDES
dnl TOPLEVEL_INCLUDES
dnl
AC_DEFUN([GLIBCXX_EXPORT_INCLUDES], [
# Used for every C++ compile we perform.
GLIBCXX_INCLUDES="\
-I$glibcxx_builddir/include/$host_alias \
-I$glibcxx_builddir/include \
-I$glibcxx_srcdir/libsupc++"
# For Canadian crosses, pick this up too.
if test $CANADIAN = yes; then
GLIBCXX_INCLUDES="$GLIBCXX_INCLUDES -I\${includedir}"
fi
# Stuff in the actual top level. Currently only used by libsupc++ to
# get unwind* headers from the libgcc dir.
#TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/libgcc -I$(toplevel_srcdir)/include'
TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/libgcc'
# Now, export this to all the little Makefiles....
AC_SUBST(GLIBCXX_INCLUDES)
AC_SUBST(TOPLEVEL_INCLUDES)
])
dnl
dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
dnl (SECTION_FLAGS is done under CHECK_COMPILER_FEATURES.)
dnl
dnl Substs:
dnl OPTIMIZE_CXXFLAGS
dnl WARN_FLAGS
dnl
AC_DEFUN([GLIBCXX_EXPORT_FLAGS], [
# Optimization flags that are probably a good idea for thrill-seekers. Just
# uncomment the lines below and make, everything else is ready to go...
# Alternatively OPTIMIZE_CXXFLAGS can be set in configure.host.
# OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
AC_SUBST(OPTIMIZE_CXXFLAGS)
WARN_FLAGS='-Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi'
AC_SUBST(WARN_FLAGS)
])
dnl
dnl All installation directory information is determined here.
dnl
dnl Substs:
dnl gxx_install_dir
dnl glibcxx_prefixdir
dnl glibcxx_toolexecdir
dnl glibcxx_toolexeclibdir
dnl
dnl Assumes cross_compiling bits already done, and with_cross_host in
dnl particular.
dnl
dnl This logic must match gcc/configure.ac's setting of gcc_gxx_include_dir.
dnl config/gxx-include-dir.m4 must be kept consistant with this as well.
AC_DEFUN([GLIBCXX_EXPORT_INSTALL_INFO], [
glibcxx_toolexecdir=no
glibcxx_toolexeclibdir=no
glibcxx_prefixdir=$prefix
AC_MSG_CHECKING([for gxx-include-dir])
AC_ARG_WITH([gxx-include-dir],
AC_HELP_STRING([--with-gxx-include-dir=DIR],
[installation directory for include files]),
[case "$withval" in
yes) AC_MSG_ERROR([Missing directory for --with-gxx-include-dir]) ;;
no) gxx_include_dir=no ;;
*) gxx_include_dir=$withval ;;
esac],
[gxx_include_dir=no])
AC_MSG_RESULT($gxx_include_dir)
AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
AC_ARG_ENABLE([version-specific-runtime-libs],
AC_HELP_STRING([--enable-version-specific-runtime-libs],
[Specify that runtime libraries should be installed in a compiler-specific directory]),
[case "$enableval" in
yes) version_specific_libs=yes ;;
no) version_specific_libs=no ;;
*) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
esac],
[version_specific_libs=no])
AC_MSG_RESULT($version_specific_libs)
# Default case for install directory for include files.
if test $version_specific_libs = no && test $gxx_include_dir = no; then
gxx_include_dir='include/c++/${gcc_version}'
if test -n "$with_cross_host" &&
test x"$with_cross_host" != x"no"; then
gxx_include_dir='${prefix}/${target_alias}/'"$gxx_include_dir"
else
gxx_include_dir='${prefix}/'"$gxx_include_dir"
fi
fi
# Version-specific runtime libs processing.
if test $version_specific_libs = yes; then
# Need the gcc compiler version to know where to install libraries
# and header files if --enable-version-specific-runtime-libs option
# is selected. FIXME: these variables are misnamed, there are
# no executables installed in _toolexecdir or _toolexeclibdir.
if test x"$gxx_include_dir" = x"no"; then
gxx_include_dir='${libdir}/gcc/${host_alias}/${gcc_version}/include/c++'
fi
glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
glibcxx_toolexeclibdir='${toolexecdir}/${gcc_version}$(MULTISUBDIR)'
fi
# Calculate glibcxx_toolexecdir, glibcxx_toolexeclibdir
# Install a library built with a cross compiler in tooldir, not libdir.
if test x"$glibcxx_toolexecdir" = x"no"; then
if test -n "$with_cross_host" &&
test x"$with_cross_host" != x"no"; then
glibcxx_toolexecdir='${exec_prefix}/${host_alias}'
glibcxx_toolexeclibdir='${toolexecdir}/lib'
else
glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
glibcxx_toolexeclibdir='${libdir}'
fi
multi_os_directory=`$CXX -print-multi-os-directory`
case $multi_os_directory in
.) ;; # Avoid trailing /.
*) glibcxx_toolexeclibdir=$glibcxx_toolexeclibdir/$multi_os_directory ;;
esac
fi
AC_MSG_CHECKING([for install location])
AC_MSG_RESULT($gxx_include_dir)
AC_SUBST(glibcxx_prefixdir)
AC_SUBST(gxx_include_dir)
AC_SUBST(glibcxx_toolexecdir)
AC_SUBST(glibcxx_toolexeclibdir)
])
dnl
dnl GLIBCXX_ENABLE
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
dnl
dnl See manual/appendix_porting.html#appendix.porting.build_hacking for
dnl documentation.
dnl
m4_define([GLIBCXX_ENABLE],[dnl
m4_define([_g_switch],[--enable-$1])dnl
m4_define([_g_help],[AC_HELP_STRING([_g_switch$3],[$4 @<:@default=$2@:>@])])dnl
AC_ARG_ENABLE([$1],m4_dquote(_g_help),
m4_bmatch([$5],
[^permit ],
[[
case "$enableval" in
m4_bpatsubst([$5],[permit ])) ;;
*) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
dnl Idea for future: generate a URL pointing to
dnl "onlinedocs/configopts.html#whatever"
esac
]],
[^$],
[[
case "$enableval" in
yes|no) ;;
*) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
esac
]],
[[$5]]),
[enable_]m4_bpatsubst([$1],-,_)[=][$2])
m4_undefine([_g_switch])dnl
m4_undefine([_g_help])dnl
])
dnl
dnl Check for ISO/IEC 9899:1999 "C99" support.
dnl
dnl --enable-c99 defines _GLIBCXX_USE_C99
dnl --disable-c99 leaves _GLIBCXX_USE_C99 undefined
dnl + Usage: GLIBCXX_ENABLE_C99[(DEFAULT)]
dnl Where DEFAULT is either `yes' or `no'.
dnl + If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
dnl
AC_DEFUN([GLIBCXX_ENABLE_C99], [
GLIBCXX_ENABLE(c99,$1,,[turns on ISO/IEC 9899:1999 support])
if test x"$enable_c99" = x"yes"; then
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
# Use -std=c++98 (instead of -std=gnu++98) because leaving __STRICT_ANSI__
# undefined may cause fake C99 facilities, like pre-standard snprintf,
# to be spuriously enabled.
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -std=c++98"
ac_save_LIBS="$LIBS"
ac_save_gcc_no_link="$gcc_no_link"
if test x$gcc_no_link != xyes; then
# Use -fno-exceptions to that the C driver can link these tests without
# hitting undefined references to personality routines.
CXXFLAGS="$CXXFLAGS -fno-exceptions"
AC_CHECK_LIB(m, sin, [LIBS="$LIBS -lm"], [
# Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
gcc_no_link=yes
])
fi
# Check for the existence of <math.h> functions used if C99 is enabled.
AC_MSG_CHECKING([for ISO C99 support in <math.h> for C++98])
AC_CACHE_VAL(glibcxx_cv_c99_math_cxx98, [
GCC_TRY_COMPILE_OR_LINK(
[#include <math.h>
volatile double d1, d2;
volatile int i;],
[i = fpclassify(d1);
i = isfinite(d1);
i = isinf(d1);
i = isnan(d1);
i = isnormal(d1);
i = signbit(d1);
i = isgreater(d1, d2);
i = isgreaterequal(d1, d2);
i = isless(d1, d2);
i = islessequal(d1, d2);
i = islessgreater(d1, d2);
i = islessgreater(d1, d2);
i = isunordered(d1, d2);
], [glibcxx_cv_c99_math_cxx98=yes], [glibcxx_cv_c99_math_cxx98=no])
])
AC_MSG_RESULT($glibcxx_cv_c99_math_cxx98)
if test x"$glibcxx_cv_c99_math_cxx98" = x"yes"; then
AC_DEFINE(_GLIBCXX98_USE_C99_MATH, 1,
[Define if C99 functions or macros in <math.h> should be imported
in <cmath> in namespace std for C++98.])
fi
# Check for the existence of <complex.h> complex math functions.
# This is necessary even though libstdc++ uses the builtin versions
# of these functions, because if the builtin cannot be used, a reference
# to the library function is emitted.
AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
if test x"$ac_has_complex_h" = x"yes"; then
AC_MSG_CHECKING([for ISO C99 support in <complex.h> for C++98])
AC_CACHE_VAL(glibcxx_cv_c99_complex_cxx98, [
GCC_TRY_COMPILE_OR_LINK(
[#include <complex.h>
typedef __complex__ float float_type;
typedef __complex__ double double_type;
typedef __complex__ long double ld_type;
volatile float_type tmpf;
volatile double_type tmpd;
volatile ld_type tmpld;
volatile float f;
volatile double d;
volatile long double ld;],
[f = cabsf(tmpf);
f = cargf(tmpf);
tmpf = ccosf(tmpf);
tmpf = ccoshf(tmpf);
tmpf = cexpf(tmpf);
tmpf = clogf(tmpf);
tmpf = csinf(tmpf);
tmpf = csinhf(tmpf);
tmpf = csqrtf(tmpf);
tmpf = ctanf(tmpf);
tmpf = ctanhf(tmpf);
tmpf = cpowf(tmpf, tmpf);
tmpf = cprojf(tmpf);
d = cabs(tmpd);
d = carg(tmpd);
tmpd = ccos(tmpd);
tmpd = ccosh(tmpd);
tmpd = cexp(tmpd);
tmpd = clog(tmpd);
tmpd = csin(tmpd);
tmpd = csinh(tmpd);
tmpd = csqrt(tmpd);
tmpd = ctan(tmpd);
tmpd = ctanh(tmpd);
tmpd = cpow(tmpd, tmpd);
tmpd = cproj(tmpd);
ld = cabsl(tmpld);
ld = cargl(tmpld);
tmpld = ccosl(tmpld);
tmpld = ccoshl(tmpld);
tmpld = cexpl(tmpld);
tmpld = clogl(tmpld);
tmpld = csinl(tmpld);
tmpld = csinhl(tmpld);
tmpld = csqrtl(tmpld);
tmpld = ctanl(tmpld);
tmpld = ctanhl(tmpld);
tmpld = cpowl(tmpld, tmpld);
tmpld = cprojl(tmpld);
], [glibcxx_cv_c99_complex_cxx98=yes], [glibcxx_cv_c99_complex_cxx98=no])
])
fi
AC_MSG_RESULT($glibcxx_cv_c99_complex_cxx98)
if test x"$glibcxx_cv_c99_complex_cxx98" = x"yes"; then
AC_DEFINE(_GLIBCXX98_USE_C99_COMPLEX, 1,