1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
|
dnl Process this file with autoconf to produce a configure script.
# Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
#
# This file is part of the GNU MP Library.
#
# The GNU MP Library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
# The GNU MP Library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA.
AC_REVISION($Revision$)
AC_PREREQ(2.49)
AC_INIT(gmp-impl.h)
# If --target is not used then $target_alias is empty, but if say
# "./configure athlon-pc-freebsd3.5" is used, then all three of
# $build_alias, $host_alias and $target_alias are set to
# "athlon-pc-freebsd3.5".
#
if test -n "$target_alias" && test "$target_alias" != "$host_alias"; then
AC_MSG_ERROR([--target is not appropriate for GMP
Use --build=CPU-VENDOR-OS if you need to specify your CPU and/or system
explicitly. Use --host if cross-compiling (see "Installing GMP" in the
manual for more on this).])
fi
GMP_INIT(config.m4)
AC_CANONICAL_HOST
tmp_host=`echo $host_cpu | sed 's/\./_/'`
AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_$tmp_host)
GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_HOST_CPU_$tmp_host')", POST)
AM_INIT_AUTOMAKE(gmp, GMP_VERSION)
AM_CONFIG_HEADER(config.h:config.in)
AM_CONFIG_HEADER(gmp.h:gmp-h.in)
AM_CONFIG_HEADER(mp.h:mp-h.in)
AM_MAINTAINER_MODE
AC_ARG_ENABLE(assert,
AC_HELP_STRING([--enable-assert],[enable ASSERT checking [default=no]]),
[case $enableval in
yes|no) ;;
*) AC_MSG_ERROR([bad value $enableval for --enable-assert, need yes or no]) ;;
esac],
[enable_assert=no])
if test "$enable_assert" = "yes"; then
AC_DEFINE(WANT_ASSERT,1,
[./configure --enable-assert option, to enable some ASSERT()s])
fi
AC_ARG_ENABLE(alloca,
AC_HELP_STRING([--enable-alloca],[use alloca for temp space [default=detect]]),
[case $enableval in
yes|no|detect) ;;
*) AC_MSG_ERROR([bad value $enableval for --enable-alloca, need yes/no/detect]) ;;
esac],
[enable_alloca=detect])
if test "$enable_alloca" = "no"; then
AC_DEFINE(USE_STACK_ALLOC,1,
[./configure --disable-alloca option, to use stack-alloc.c, not alloca])
fi
AC_ARG_ENABLE(fft,
AC_HELP_STRING([--enable-fft],[enable FFTs for multiplication [default=no]]),
[case $enableval in
yes|no) ;;
*) AC_MSG_ERROR([bad value $enableval for --enable-fft, need yes or no]) ;;
esac],
[enable_fft=no])
if test "$enable_fft" = "yes"; then
AC_DEFINE(WANT_FFT,1,
[./configure --enable-fft option, to enable FFTs for multiplication])
fi
AC_ARG_ENABLE(mpbsd,
AC_HELP_STRING([--enable-mpbsd],
[build Berkley MP compatibility library [default=no]]),
[case $enableval in
yes|no) ;;
*) AC_MSG_ERROR([bad value $enableval for --enable-mpbsd, need yes or no]) ;;
esac],
[enable_mpbsd=no])
AM_CONDITIONAL(WANT_MPBSD, test "$enable_mpbsd" = "yes")
AC_ARG_ENABLE(mpfr,
AC_HELP_STRING([--enable-mpfr],[build MPFR [default=no]]),
[case $enableval in
yes|no) ;;
*) AC_MSG_ERROR([bad value $enableval for --enable-mpfr, need yes or no]) ;;
esac],
[enable_mpfr=no])
AM_CONDITIONAL(WANT_MPFR, test "$enable_mpfr" = "yes")
AC_ARG_ENABLE(profiling,
AC_HELP_STRING([--enable-profiling],
[build with profiler support [default=no]]),
[case $enableval in
no|prof|gprof) ;;
*) AC_MSG_ERROR([bad value $enableval for --enable-profiling, need no/prof/gprof]) ;;
esac],
[enable_profiling=no])
GMP_DEFINE_RAW(["define(<WANT_PROFILING>,<\`$enable_profiling'>)"])
# -fomit-frame-pointer is incompatible with -pg, on x86s at least
if test "$enable_profiling" = gprof; then
fomit_frame_pointer=
else
fomit_frame_pointer="-fomit-frame-pointer"
fi
# Table of compilers, options, and mpn paths. This code has a couple of
# related purposes
#
# - better default CC/CFLAGS selections than autoconf otherwise gives
# - default CC/CFLAGS selections for extra CPU types specific to GMP
# - a few tests for known bad compilers
# - choice of ABIs on suitable systems
# - selection of corresponding mpn search path
#
# After GMP specific searches and tests, the standard autoconf AC_PROG_CC is
# called. User selections of CC etc are respected.
#
# Care is taken not to use macros like AC_TRY_COMPILE during the GMP
# pre-testing, since they of course depend on AC_PROG_CC, and also some of
# them cache their results, which is not wanted.
#
# The ABI selection mechanism is unique to GMP. All that reaches autoconf
# is a different selection of CC/CFLAGS according to the best ABI the system
# supports, and/or what the user selects. Naturally the mpn assembler code
# selected is very dependent on the ABI.
#
# The closest the standard tools come to a notion of ABI is something like
# "sparc64" which encodes a CPU and an ABI together. This doesn't seem to
# scale well for GMP, where exact CPU types like "ultrasparc2" are wanted,
# separate from the ABI used on them.
#
#
# The variables set here are
#
# cclist the compiler choices
# xx_cflags flags for compiler xx
# xx_cppflags cpp flags for compiler xx
# xx_cflags_optlist list of sets of optional flags
# xx_cflags_yyy set yyy of optional flags for compiler xx
# xx_ldflags -Wc,-foo flags for libtool linking with compiler xx
# ar_flags extra flags for $AR
# nm_flags extra flags for $NM
# limb limb size, can be "longlong"
# path mpn search path
# extra_functions extra mpn functions
#
# Suppose xx_cflags_optlist="arch", then flags from $xx_cflags_arch are
# tried, and the first flag that works will be used. An optlist like "arch
# cpu optimize" can be used to get multiple independent sets of flags tried.
# The first that works from each will be used. If no flag in a set works
# then nothing from that set is added.
#
# For multiple ABIs, the scheme extends as follows.
#
# abilist set of ABI choices
# cclist_aa compiler choices in ABI aa
# xx_aa_cflags flags for xx in ABI aa
# xx_aa_cppflags cpp flags for xx in ABI aa
# xx_aa_cflags_optlist list of sets of optional flags in ABI aa
# xx_aa_cflags_yyy set yyy of optional flags for compiler xx in ABI aa
# xx_aa_ldflags -Wc,-foo flags for libtool linking
# ar_aa_flags extra flags for $AR in ABI aa
# nm_aa_flags extra flags for $NM in ABI aa
# limb_aa limb size in ABI aa, can be "longlong"
# path_aa mpn search path in ABI aa
# extra_functions_aa extra mpn functions in ABI aa
#
# As a convenience, the unadorned xx_cflags (etc) are used for the last ABI
# in ablist, if an xx_aa_cflags for that ABI isn't given. For example if
# abilist="64 32" then $cc_64_cflags will be used for the 64-bit ABI, but
# for the 32-bit either $cc_32_cflags or $cc_cflags is used, whichever is
# defined. This makes it easy to add some 64-bit compilers and flags to an
# unadorned 32-bit set.
#
# limb=longlong (or limb_aa=longlong) applies to all compilers within that
# ABI. It won't work to have some needing long long and some not, since a
# single instantiated gmp.h will be used by both.
#
# SPEED_CYCLECOUNTER, cyclecounter_size and CALLING_CONVENTIONS_OBJS are
# also set here, with an ABI suffix.
#
#
# "family" is a remant of past configuration schemes, now used only for
# setting up asm-syntax.h for m68k.
# abilist needs to be non-empty, "standard" is just a generic name here
abilist="standard"
family=generic
# FIXME: Prefer c89 to cc.
cclist="gcc cc"
gcc_cflags="-g -O2"
gcc_64_cflags="-g -O2"
cc_cflags="-O"
cc_64_cflags="-O"
SPEED_CYCLECOUNTER_OBJ=
cyclecounter_size=2
case $host in
a29k*-*-*)
path="a29k"
;;
alpha*-*-*)
path="alpha"
extra_functions="cntlz"
case $host in
alphaev5*-*-* | alphapca56*-*-*) path="alpha/ev5 alpha" ;;
alphaev6*-*-*) path="alpha/ev6 alpha/ev5 alpha" ;;
esac
SPEED_CYCLECOUNTER_OBJ=alpha.lo
cyclecounter_size=1
flavour=`echo $host_cpu | sed 's/^alpha//g'`
case "$flavour" in
# compilers don't seem to understand `ev67' and such.
ev6? | ev7*) flavour=ev6 ;;
ev* | pca*) ;;
*) flavour=ev4 ;;
esac
# FIXME: Maybe a feature test should find out whether -Wa,arch is
# necessary.
if test -n "$flavour"; then
gcc_cflags_optlist="cpu arch"
gcc_cflags_cpu="-mcpu=$flavour"
gcc_cflags_arch="-Wa,-arch,$flavour -Wa,-m$flavour"
fi
case $host in
*-cray-unicos*)
# FIXME: Is GCC available for these systems? Hopefully it doesn't
# hurt to check for it anyway.
cc_cflags="-O" # no -g, it silently disables all optimizations
GMP_INCLUDE_MPN(alpha/unicos.m4)
# Don't perform any assembly syntax tests on this beast.
gmp_asm_syntax_testing=no
# tune/alpha.asm assumes int==4bytes but unicos uses int=8bytes
SPEED_CYCLECOUNTER_OBJ=
;;
*-*-osf*)
cc_cflags_optlist="cpu"
cc_cflags="-arch $flavour -tune $flavour"
GMP_INCLUDE_MPN(alpha/default.m4)
;;
*)
GMP_INCLUDE_MPN(alpha/default.m4)
;;
esac
;;
# Cray vector machines.
# This must come after alpha* so that we can recognize present and future
# vector processors with a wildcard.
*-cray-unicos*)
gmp_asm_syntax_testing=no
cclist="cc"
cc_cflags="-O3 -htask0 -Wa,-B"
path="cray"
;;
arm*-*-*)
path="arm"
gcc_cflags="$gcc_cflags $fomit_frame_pointer"
extra_functions="udiv"
;;
clipper*-*-*)
path="clipper"
;;
# Fujitsu
[f30[01]-fujitsu-sysv*])
cclist="gcc vcc"
# FIXME: flags for vcc?
vcc_cflags="-g"
path="fujitsu"
;;
hppa*-*-*)
# HP cc is K&R by default, but AM_C_PROTOTYPES will add "-Ae", or "-Aa
# -D_HPUX_SOURCE", to put it into ansi mode, if possible.
# default to pa7100
gcc_cflags="-g -O2"
gcc_cflags_optlist="arch"
gcc_cflags_arch="-mpa-risc-1-1"
cc_cflags="+DA1.1 +O2"
path="hppa/hppa1_1/pa7100 hppa/hppa1_1 hppa"
extra_functions="udiv_qrnnd"
SPEED_CYCLECOUNTER_OBJ=hppa.lo
cyclecounter_size=1
case $host in
hppa1.0*-*-*)
# override back to plain 1.0
gcc_cflags_optlist=
cc_cflags="+O2"
path="hppa"
;;
hppa7000*-*-*)
path="hppa/hppa1_1 hppa"
;;
hppa2.0*-*-*)
abilist="2.0n 1.0"
# FIXME: It's suspected that an assembler feature test might be
# necessary before -mpa-risc-2-0 can be enabled, since it's not
# clear (as of gcc 2.95.2) whether that option always gives an
# explicit ".level 2.0" or whatever to the assembler. In any case,
# under gcc 2.95.2 it only enables a few extra floating point insns,
# so it's not very important.
#
# gmp_cflags_arch="-mpa-risc-2-0 -mpa-risc-1-1"
# FIXME: path should be "hppa/hppa2_0 hppa/hppa1_1 hppa"
path="hppa/hppa2_0 hppa/hppa1_1/pa7100 hppa/hppa1_1 hppa"
# no gcc support for long long in 2.0n
cclist_20n="cc"
# +O2 to cc triggers bug in mpz/powm.c (cvs version 1.4)
cc_20n_cflags="+DA2.0 +e +O3"
cc_20n_testlist="hpc-hppa-2-0"
path_20n="pa64"
limb_20n=longlong
extra_functions_20n="umul_ppmm udiv_qrnnd"
SPEED_CYCLECOUNTER_OBJ_20n=hppa2.lo
cyclecounter_size_20n=2
# ABI=2.0w is available for hppa2.0w and hppa2.0, but not for hppa2.0n.
case $host in
hppa2.0n-*-*) ;;
*)
# HPUX 11 or up is required to run 2.0w. Not sure about other
# systems (GNU/Linux for instance), but lets assume they're ok.
case $host in
[*-*-hpux1[1-9]*]) abilist="2.0w $abilist" ;;
*-*-hpux*) ;;
*) abilist="2.0w $abilist" ;;
esac
# gcc support for 2.0w is in progress
cclist_20w="cc"
cc_20w_cflags="+DD64 +O3"
cc_20w_testlist="hpc-hppa-2-0"
path_20w="pa64w"
extra_functions_20w="umul_ppmm udiv_qrnnd"
SPEED_CYCLECOUNTER_OBJ_20w=hppa2w.lo
cyclecounter_size_20w=2
;;
esac
;;
esac
;;
i960*-*-*)
path="i960"
;;
ia64*-*-*)
path="ia64"
GMP_INCLUDE_MPN(ia64/default.m4)
SPEED_CYCLECOUNTER_OBJ=ia64.lo
;;
# Motorola 68k
m68*-*-*)
family=m68k
path="m68k"
gcc_cflags="$gcc_cflags $fomit_frame_pointer"
case $host in
# Nexts are at least '020, and let m68k mean 68020-68040.
[m680[234]0*-*-* | m68k*-*-* | m68*-next-nextstep*])
path="m68k/mc68020 m68k"
;;
esac
;;
# Motorola 88k
m88k*-*-*)
path="m88k"
;;
m88110*-*-*)
# FIXME: Use `-O2'?
gcc_cflags="-g -O -m88110"
path="m88k/mc88110 m88k"
;;
# National Semiconductor 32k
ns32k*-*-*)
path="ns32k"
;;
# IRIX 5 and earlier can only run 32-bit o32.
#
# IRIX 6 and up can run n32 or 64, and GMP uses a 64-bit limb on both. It
# could run the mips2 code in n32 with a 32-bit limb, which we could
# perhaps call 32, but since that would just create a slower library, we
# don't give that option.
#
# Linux kernel 2.2.13 arch/mips/kernel/irixelf.c has a comment about not
# supporting n32 or 64.
#
# We here use ldflags for passing options with libtool to the compiler
# when generating the shared library.
[mips*-*-irix[6789]*])
abilist="64 n32"
# let the $found_compiler test below know that the cpu is recognised
path=dummy
cclist_n32="gcc cc"
gcc_n32_cflags="-g -O2 -mabi=n32"
gcc_n32_ldflags="-Wc,-mabi=n32"
cc_n32_cflags="-O2 -n32" # no -g, it disables all optimizations
cc_n32_ldflags="-Wc,-n32"
limb_n32=longlong
path_n32="mips3"
cclist_64="gcc cc"
gcc_64_cflags="-g -O2 -mabi=64"
gcc_64_ldflags="-Wc,-mabi=64"
cc_64_cflags="-O2 -64" # no -g, it disables all optimizations
cc_64_ldflags="-Wc,-64"
path_64="mips3"
GMP_INCLUDE_MPN(mips3/mips.m4)
;;
mips*-*-*)
path="mips2"
;;
powerpc*-*-*)
cclist="gcc"
gcc_cflags="-g -O2 -mpowerpc -Wa,-mppc"
path="powerpc32"
case $host in
*-*-aix*) cclist="gcc xlc"
xlc_cflags="-g -O2 -qarch=ppc -qmaxmem=20000" ;;
esac
case $host in
powerpc64*-*-*)
# CPU type powerpc64 forces to a 64-bit limb
case $host in
powerpc64-*-*) abilist="32L" ;;
*) abilist="32L 32" ;;
esac
cclist_32L="gcc"
gcc_32L_cflags="-g -O2 -mpowerpc64"
limb_32L=longlong
path_32L="powerpc64"
# On AIX a true 64-bit ABI is available.
case $host in
*-*-aix*)
# Need -Wc to pass object type flags through to the linker.
abilist="aix64 $abilist"
cclist_aix64="gcc xlc"
gcc_aix64_cflags="-g -O2 -maix64 -mpowerpc64"
gcc_aix64_ldflags="-Wc,-maix64"
xlc_aix64_cflags="-g -O2 -q64 -qtune=pwr3 -qmaxmem=20000"
xlc_aix64_ldflags="-Wc,-q64"
# Must indicate object type to ar and nm
ar_aix64_flags="-X64"
nm_aix64_flags="-X64"
path_aix64="powerpc64"
;;
esac
;;
esac
;;
# POWER
[power-*-* | power[12]-*-* | power2sc-*-*])
cclist="gcc"
extra_functions="udiv_w_sdiv"
path="power"
gcc_cflags_optlist="cpu"
case $host in
power-*-*) gcc_cflags_cpu="-mcpu=power -mpower" ;;
power1-*-*) gcc_cflags_cpu="-mcpu=rios1 -mpower" ;;
power2-*-*) gcc_cflags_cpu="-mcpu=rios2 -mpower" ;;
power2sc-*-*) gcc_cflags_cpu="-mcpu=rsc -mpower" ;;
esac
case $host in
*-*-aix*)
cclist="gcc xlc"
xlc_cflags="-g -O2 -qarch=pwr -qmaxmem=20000"
;;
esac
;;
# FIXME: ppc601 isn't accepted by config.sub.
ppc601-*-*)
path="power powerpc32"
;;
pyramid-*-*)
path="pyr"
;;
sh-*-*) path="sh" ;;
sh2-*-*) path="sh/sh2 sh" ;;
*sparc*-*-*)
# For cc and acc, -g disables -O, so it's not used
cclist="gcc acc cc"
path="sparc32"
gcc_cflags="-g -O2"
gcc_cflags_optlist="cpu"
gcc_cflags_cpu=
acc_cflags="-O2"
cc_cflags="-O2"
# FIXME: This should be selected according to the CPU
if test x${floating_point} = xno
then extra_functions="udiv_nfp"
else extra_functions="udiv_fp"
fi
case $host in
sparcv8*-*-* | supersparc*-*-* | microsparc*-*-*)
gcc_cflags_cpu="-mcpu=v8 -mv8"
acc_cflags="-O2 -cg92"
path="sparc32/v8 sparc32"
case $host in
*-*-solaris2.*) cc_cflags="-xtarget=native -xarch=v8 -xO4" ;;
esac
case $host in
supersparc*-*-*) path="sparc32/v8/supersparc sparc32/v8 sparc32"
extra_functions="udiv" ;;
esac
;;
# sparc64-*-linux-gnu is a misnomer, since there's no support for any
# 64-bit operations in user mode. We assume that a future release
# will have some 64-bit support and that the gcc options will be the
# same as on solaris.
#
# cc -xarch actually controls the ABI, hence it must be v8 for 32-bit,
# even though the chip is v9.
#
sparcv9*-*-* | ultrasparc*-*-* | sparc64-*-*)
path="sparc32/v9 sparc32/v8 sparc32"
extra_functions="udiv_fp"
SPEED_CYCLECOUNTER_OBJ=sparcv9.lo
gcc_cflags="-g -O2 -Wa,-xarch=v8plus"
gcc_cflags_cpu="-mcpu=ultrasparc -mcpu=v9 -mcpu=v8 -mv8"
cc_cflags="-xtarget=native -xarch=v8 -xO4"
case $host in
[*-*-solaris2.[7-9]])
# solaris prior to 2.6 doesn't save registers properly, so the
# 64-bit ABI is only available for 2.7 up
abilist="64 32"
path_64="sparc64"
cclist_64="gcc cc"
gcc_64_cflags="-g -O2 -m64 -mptr64 -Wa,-xarch=v9 -mcpu=v9"
cc_64_cflags="-xtarget=native -xarch=v9 -xO4"
;;
esac
;;
esac
;;
# VAX
vax*-*-*)
# Believe that vax gcc always accepts -fomit-frame-pointer, though it
# might not do anything. Cf. gcc/config/vax/vax.h which has
# FRAME_POINTER_REQUIRED=1 always.
#
gcc_cflags="-g -O2 $fomit_frame_pointer"
path="vax"
extra_functions="udiv_w_sdiv"
;;
# AMD and Intel x86 configurations
X86_PATTERN)
# Rumour has it gcc -O2 used to give worse register allocation than just
# -O, but lets assume that's no longer true.
gcc_cflags="-g -O2 $fomit_frame_pointer"
GMP_INCLUDE_MPN(x86/x86-defs.m4)
extra_functions="udiv umul"
CALLING_CONVENTIONS_OBJS='x86call.lo x86check$U.lo'
# Availability of rdtsc is checked at run-time.
SPEED_CYCLECOUNTER_OBJ=pentium.lo
# gcc 2.7.2 only knows i386 and i486, using -m386 or -m486. These
# represent -mcpu= since -m486 doesn't generate 486 specific insns. The
# -mcpu= and -march= options will fail, leaving just -m486.
#
# gcc 2.95.2 adds k6, pentium and pentiumpro, and allows -march= and
# -mcpu=.
#
# gcc 2.96 (pre-release gcc 3) adds athlon.
# Defaults for anything not otherwise mentioned.
path="x86"
gcc_cflags_optlist="cpu arch"
gcc_cflags_cpu="-mcpu=i486 -m486"
gcc_cflags_arch="-march=i486"
case $host in
i386*-*-*)
# Because i386 means generic x86, -mcpu=i486 is used since that
# should better suit newer processors.
# FIXME: How would a user ask for an actual 80386? Currently only by
# using CFLAGS="-mcpu=386" or whatever.
gcc_cflags_cpu="-mcpu=i486 -m486"
gcc_cflags_arch="-march=i386"
;;
i586*-*-* | pentium-*-* | pentiummmx-*-*)
gcc_cflags_cpu="-mcpu=pentium -m486"
gcc_cflags_arch="-march=pentium"
;;
[i686*-*-* | pentiumpro-*-* | pentium[23]-*-*])
gcc_cflags_cpu="-mcpu=pentiumpro -mcpu=i486 -m486"
gcc_cflags_arch="-march=pentiumpro -march=i486"
;;
k6*-*-*)
gcc_cflags_cpu="-mcpu=k6 -mcpu=i486 -m486"
gcc_cflags_arch="-march=k6 -march=i486"
;;
athlon-*-*)
# Athlon instruction costs are close to P6 (3 cycle load latency,
# 4-6 cycle mul, 40 cycle div, pairable adc, etc) so if gcc doesn't
# know athlon (eg. 2.95.2 doesn't) then fall back on pentiumpro.
gcc_cflags_cpu="-mcpu=athlon -mcpu=pentiumpro -mcpu=i486 -m486"
gcc_cflags_arch="-march=athlon -march=pentiumpro -march=i486"
;;
esac
case $host in
i486*-*-*) path="x86/i486 x86" ;;
i586*-*-* | pentium-*-*) path="x86/pentium x86" ;;
pentiummmx-*-*) path="x86/pentium/mmx x86/pentium x86" ;;
i686*-*-* | pentiumpro-*-*) path="x86/p6 x86" ;;
pentium2-*-*) path="x86/p6/mmx x86/p6 x86" ;;
pentium3-*-*) path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86";;
[k6[23]*-*-*]) path="x86/k6/k62mmx x86/k6/mmx x86/k6 x86" ;;
k6*-*-*) path="x86/k6/mmx x86/k6 x86" ;;
athlon-*-*) path="x86/k7/mmx x86/k7 x86" ;;
esac
;;
# FIXME: z8kx won't get through config.sub.
z8kx*-*-*)
path="z8000x"
extra_functions="udiv_w_sdiv"
;;
z8k*-*-*)
path="z8000"
extra_functions="udiv_w_sdiv"
;;
# Special CPU "none" selects generic C. -DNO_ASM is used to disable gcc
# asm blocks in longlong.h (since they're driven by cpp pre-defined
# symbols like __alpha rather than the configured $host_cpu).
#
none-*-*)
abilist="long longlong"
gcc_cppflags="-DNO_ASM"
gcc_longlong_cppflags="-DNO_ASM"
limb_longlong=longlong
;;
esac
CFLAGS_or_unset=${CFLAGS-'(unset)'}
CPPFLAGS_or_unset=${CPPFLAGS-'(unset)'}
cat >&AC_FD_CC <<EOF
configure:__line__: User:
ABI=$ABI
CC=$CC
CFLAGS=$CFLAGS_or_unset
CPPFLAGS=$CPPFLAGS_or_unset
MPN_PATH=$MPN_PATH
configure:__line__: GMP:
abilist=$abilist
cclist=$cclist
EOF
test_CFLAGS=${CFLAGS+set}
test_CPPFLAGS=${CPPFLAGS+set}
for abi in $abilist; do
abi_last="$abi"
done
# If the user specifies an ABI then it must be in $abilist, after that
# $abilist is restricted to just that choice.
#
if test -n "$ABI"; then
found=no
for abi in $abilist; do
if test $abi = "$ABI"; then found=yes; break; fi
done
if test $found = no; then
AC_MSG_ERROR([ABI=$ABI is not among the following valid choices: $abilist])
fi
abilist="$ABI"
fi
found_compiler=no
for abi in $abilist; do
# Suppose abilist="64 32", then for abi=64, will have abi1="_64" and
# abi2="_64". For abi=32, will have abi1="_32" and abi2="". This is how
# $gcc_cflags becomes a fallback for $gcc_32_cflags (the last in the
# abilist), but there's no fallback for $gcc_64_cflags.
#
abi1=[`echo _$abi | sed 's/[.]//g'`]
if test $abi = $abi_last; then abi2=; else abi2="$abi1"; fi
# Compiler choices under this ABI
eval cclist_chosen=\"\$cclist$abi1\"
test -n "$cclist_chosen" || eval cclist_chosen=\"\$cclist$abi2\"
# If there's a user specified $CC then don't use a list for
# $cclist_chosen, just a single value for $ccbase.
#
if test -n "$CC"; then
# The first word of $CC, stripped of any directory. For instance
# CC="/usr/local/bin/gcc -pipe" will give "gcc".
#
for ccbase in $CC; do break; done
ccbase=`echo $ccbase | sed 's:.*/::'`
# If this $ccbase is in $cclist_chosen then it's a compiler we know and
# we can do flags defaulting with it. If not, then $cclist_chosen is
# set to "unrecognised" so no default flags are used.
#
# "unrecognised" is used to avoid bad effects with eval if $ccbase has
# non-symbol characters. For instance ccbase=my+cc would end up with
# something like cflags="$my+cc_cflags" which would give
# cflags="+cc_cflags" rather than the intended empty string for an
# unknown compiler.
#
found=unrecognised
for i in $cclist_chosen; do
if test "$ccbase" = $i; then
found=$ccbase
break
fi
done
cclist_chosen=$found
fi
for ccbase in $cclist_chosen; do
# When cross compiling, look for a compiler with the $host_alias as a
# prefix, the same way that AC_CHECK_TOOL does. But don't do this to a
# user-selected $CC.
#
# $cross_compiling will be yes/no/maybe at this point. Do the host
# prefixing for "maybe" as well as "yes".
#
if test "$cross_compiling" != no && test -z "$CC"; then
cross_compiling_prefix="${host_alias}-"
fi
for ccprefix in $cross_compiling_prefix ""; do
cc="$CC"
test -n "$cc" || cc="$ccprefix$ccbase"
# If the compiler is gcc but installed under another name, then change
# $ccbase so as to use the flags we know for gcc. This helps for
# instance when specifying CC=gcc272 on Debian GNU/Linux, or the
# native cc which is really gcc on NeXT or MacOS-X.
#
# FIXME: There's a slight misfeature here. If cc is actually gcc but
# gcc is not a known compiler under this $abi then we'll end up
# testing it with no flags and it'll work, but chances are it won't be
# in the right mode for the ABI we desire. Let's quietly hope this
# doesn't happen.
#
if test $ccbase != gcc; then
GMP_PROG_CC_IS_GNU($cc,ccbase=gcc)
fi
# Any user CFLAGS, even an empty string, takes precendence
eval cflags=\"\$${ccbase}${abi1}_cflags\"
test -n "$cflags" || eval cflags=\"\$${ccbase}${abi2}_cflags\"
if test "$test_CFLAGS" = set; then cflags=$CFLAGS; fi
# Any user CPPFLAGS, even an empty string, takes precendence
eval cppflags=\"\$${ccbase}${abi1}_cppflags\"
test -n "$cppflags" || eval cppflags=\"\$${ccbase}${abi2}_cppflags\"
if test "$test_CPPFLAGS" = set; then cppflags=$CPPFLAGS; fi
# --enable-profiling adds -p/-pg even to user-specified CFLAGS
case "$enable_profiling" in
prof) cflags="$cflags -p" ;;
gprof) cflags="$cflags -pg" ;;
esac
GMP_PROG_CC_WORKS($cc $cflags $cppflags,,continue)
# The tests to perform on this $cc, if any
eval testlist=\"\$${ccbase}${abi1}_testlist\"
test -n "$testlist" || eval testlist=\"\$${ccbase}${abi2}_testlist\"
testlist_pass=yes
for tst in $testlist; do
case $tst in
hpc-hppa-2-0) GMP_HPC_HPPA_2_0($cc,,testlist_pass=no) ;;
esac
if test $testlist_pass = no; then break; fi
done
if test $testlist_pass = yes; then
found_compiler=yes
break
fi
done
if test $found_compiler = yes; then break; fi
done
if test $found_compiler = yes; then break; fi
done
# If we recognised the CPU, as indicated by $path being set, then insist
# that we have a working compiler, either from our $cclist choices or from
# $CC. We can't let AC_PROG_CC look around for a compiler because it might
# find one that we've rejected (for not supporting the modes our asm code
# demands, etc).
#
# If we didn't recognise the CPU (and this includes host_cpu=none), then
# fall through and let AC_PROG_CC look around for a compiler too. This is
# mostly in the interests of following a standard autoconf setup, after all
# we've already tested cc and gcc adequately (hopefully). As of autoconf
# 2.50 the only thing AC_PROG_CC really adds is a check for "cl" (Microsoft
# C on MS-DOS systems).
#
if test $found_compiler = no && test -n "$path"; then
AC_MSG_ERROR([could not find a working compiler])
fi
if test $found_compiler = yes; then
# If we're creating CFLAGS, then look for optional additions. If the user
# set CFLAGS then leave it alone.
#
if test "$test_CFLAGS" != set; then
eval optlist=\"\$${ccbase}${abi1}_cflags_optlist\"
test -n "$optlist" || eval optlist=\"\$${ccbase}${abi2}_cflags_optlist\"
for opt in $optlist; do
eval optflags=\"\$${ccbase}${abi1}_cflags_${opt}\"
test -n "$optflags" || eval optflags=\"\$${ccbase}${abi2}_cflags_${opt}\"
for flag in $optflags; do
case $flag in
-march=pentiumpro)
# buggy on some versions of gcc, exclude as necessary
GMP_GCC_MARCH_PENTIUMPRO($ccbase,$cc,,continue)
;;
esac
GMP_PROG_CC_WORKS($cc $cflags $cppflags $flag,
[cflags="$cflags $flag"
break])
done
done
fi
ABI="$abi"
CC="$cc"
CFLAGS="$cflags"
CPPFLAGS="$cppflags"
# Could easily have this in config.h too, if desired.
ABI_nodots=`echo $ABI | sed 's/\./_/'`
GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_ABI_$ABI_nodots')", POST)
# GMP_LDFLAGS substitution, selected according to ABI.
# These are needed on libgmp.la and libmp.la, but currently not on
# convenience libraries like tune/libspeed.la or mpz/libmpz.la.
#
eval GMP_LDFLAGS=\"\$${ccbase}${abi1}_ldflags\"
test -n "$GMP_LDFLAGS" || eval GMP_LDFLAGS=\"\$${ccbase}${abi1}_ldflags\"
AC_SUBST(GMP_LDFLAGS)
# extra_functions, selected according to ABI
eval tmp=\"\$extra_functions$abi1\"
test -n "$tmp" || eval tmp=\"\$extra_functions$abi2\"
extra_functions="$tmp"
# Cycle counter, selected according to ABI.
#
eval tmp=\"\$SPEED_CYCLECOUNTER_OBJ$abi1\"
test -n "$tmp" || eval tmp=\"\$SPEED_CYCLECOUNTER_OBJ$abi2\"
SPEED_CYCLECOUNTER_OBJ="$tmp"
eval tmp=\"\$cyclecounter_size$abi1\"
test -n "$tmp" || eval tmp=\"\$cyclecounter_size$abi2\"
cyclecounter_size="$tmp"
if test -n "$SPEED_CYCLECOUNTER_OBJ"; then
AC_DEFINE_UNQUOTED(HAVE_SPEED_CYCLECOUNTER, $cyclecounter_size,
[Tune directory speed_cyclecounter, undef=none, 1=32bits, 2=64bits)])
fi
AC_SUBST(SPEED_CYCLECOUNTER_OBJ)
# Calling conventions checking, selected according to ABI.
#
eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi1\"
test -n "$tmp" || eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi2\"
CALLING_CONVENTIONS_OBJS="$tmp"
if test -n "$CALLING_CONVENTIONS_OBJS"; then
AC_DEFINE(HAVE_CALLING_CONVENTIONS,1,
[Define if tests/libtests has calling conventions checking for the CPU])
fi
AC_SUBST(CALLING_CONVENTIONS_OBJS)
fi
# If the user gave an MPN_PATH, use that verbatim, otherwise choose
# according to the ABI and add "generic".
#
if test -n "$MPN_PATH"; then
path="$MPN_PATH"
else
eval tmp=\"\$path$abi1\"
test -n "$tmp" || eval tmp=\"\$path$abi2\"
path="$tmp generic"
fi
# Whether using a long long limb in this ABI.
eval limb_chosen=\"\$limb$abi1\"
test -n "$limb_chosen" || eval limb_chosen=\"\$limb$abi2\"
case $limb_chosen in
longlong) AC_DEFINE(_LONG_LONG_LIMB) ;;
esac
cat >&AC_FD_CC <<EOF
configure:__line__: Decided:
ABI=$ABI
CC=$CC
CFLAGS=$CFLAGS
CPPFLAGS=$CPPFLAGS
GMP_LDFLAGS=$GMP_LDFLAGS
path=$path
EOF
echo using ABI=\"$ABI\" CC=\"$CC\" CFLAGS=\"$CFLAGS\" CPPFLAGS=\"$CPPFLAGS\"
AC_PROG_CC
AC_PROG_CPP
case $host_cpu in
c90 | t90)
AC_EGREP_CPP(yes,
[#ifdef _CRAYIEEE
yes
#endif],
[add_path="cray/ieee"],
[add_path="cray/cfp"; extra_functions="mulwwc90"]) ;;
j90 | sv1)
extra_functions="mulwwj90"
add_path="cray/cfp $path" ;;
esac
if test -z "$MPN_PATH"; then
path="$add_path $path"
fi
# Automake ansi2knr support. This needs to be before compiler feature tests
# because it will change CC/CFLAGS to put the compiler into ansi mode, if it
# needs to, and if it can.
#
AM_C_PROTOTYPES
GMP_PROG_AR
GMP_PROG_NM
case $host in
# FIXME: On AIX 3 and 4, $libname.a is included in libtool
# $library_names_spec, so libgmp.a becomes a symlink to libgmp.so, making
# it impossible to build shared and static libraries simultaneously.
# Disable shared libraries by default, but let the user override with
# --enable-shared --disable-static.
#
# FIXME: This $libname.a problem looks like it might apply to *-*-amigaos*
# and *-*-os2* too, but wait for someone to test this before worrying
# about it. If there's a problem then of course libtool is the right
# place to fix it.
#
[*-*-aix[34]*])
if test -z "$enable_shared"; then enable_shared=no; fi ;;
# FIXME: On SCO 5, an explicit -lc is not wanted when making shared
# libraries. Giving it makes strange things happen, like ctype.h macros
# not working and profiler mcount calls segfaulting. Libtool ought to
# know about this, but as of Dec 2000 it doesn't, so forcibly disable -lc
# on relevant systems.
#
*-*-sco3.2v5*)
ac_cv_archive_cmds_need_lc=no ;;
# FIXME: Shared libraries aren't supported on unicos, but as of Dec 2000
# libtool doesn't seem to detect this correctly, so forcibly disable them.
#
*-*-unicos*)
enable_shared=no ;;
# It seems there are no shared libs on ultrix, and it is not very important
# to work on this. Just disable for now.
*-*-ultrix*)
enable_shared=no ;;
esac
AC_PROG_LIBTOOL
# Generate an error here if attempting to build both shared and static when
# $libname.a is in $library_names_spec (as mentioned above), rather than
# wait for ar or ld to fail.
#
if test "$enable_shared" = yes && test "$enable_static" = yes; then
case $library_names_spec in
*libname.a*)
AC_MSG_ERROR([cannot create both shared and static libraries on this system, --disable one of the two])
;;
esac
fi
# temporary fudge until swox libtool update
if test -n "$ac_cv_prog_cc_pic"; then lt_cv_prog_cc_pic=$ac_cv_prog_cc_pic; fi
# libtool $pic_flag for use by mpn/Makeasm.am.
#
CFLAGS_PIC=$lt_cv_prog_cc_pic
AC_SUBST(CFLAGS_PIC)
# i386 cygwin shared libraries are DLLs, and it seems they should be
# non-PIC, certainly libtool only uses -DDLL_EXPORT, and the assembler
# rejects ELF style _GLOBAL_OFFSET_TABLE_ expressions.
#
case $host in
*-*-cygwin*) ASMFLAGS_PIC= ;;
*) ASMFLAGS_PIC=-DPIC ;;
esac
AC_SUBST(ASMFLAGS_PIC)
# How to assemble, used with CFLAGS etc, see mpn/Makeasm.am.
# Using the compiler is a lot easier than figuring out how to invoke the
# assembler directly.
#
test -n "$CCAS" || CCAS="$CC -c"
AC_SUBST(CCAS)
case $host in
X86_PATTERN)
# If there's any mmx in the path, check whether the assembler supports
# it, and remove if not.
case "$path" in
*mmx*)
GMP_ASM_X86_MMX(,[
new_path=
for i in $path; do
case $i in
*mmx*) ;;
*) new_path="$new_path $i" ;;
esac
done
path="$new_path"
])
;;
esac
;;
esac
# The library and header checks are mostly for the benefit of supplementary
# programs. The library itself doesn't use anything weird.
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS(unistd.h sys/mman.h sys/param.h sys/resource.h sys/sysctl.h sys/systemcfg.h sys/time.h sys/times.h)
# optarg should be in unistd.h, which is already in the default includes
AC_CHECK_DECLS(optarg)
AC_TYPE_SIGNAL
AC_CHECK_TYPES(void)
AC_C_STRINGIZE
AC_C_INLINE
case $ac_cv_c_inline in
no) ;;
*) AC_DEFINE(HAVE_INLINE,1,[Define if an actual "inline" is available]) ;;
esac
# from libtool
AC_CHECK_LIBM
AC_SUBST(LIBM)
GMP_FUNC_ALLOCA
if test "$enable_alloca" = yes && test "$gmp_cv_func_alloca" = no; then
AC_MSG_ERROR([--enable-alloca=yes specified, but alloca not available])
fi
AC_CHECK_FUNCS(getpagesize getrusage gettimeofday mprotect popen processor_info read_real_time strtoul sysconf sysctl sysctlbyname times)
# Set `syntax' to one of <blank>, "mit", "elf", "aix", "macho".
syntax=
# For now, we use the old switch for setting syntax.
# FIXME: Remove when conversion to .asm is completed.
changequote(,)
case $host in
m680[234]0*-*-linuxaout* | m68k*-*-linuxaout* | \
m68k-next-nextstep* | \
m68000*-*-*)
syntax=mit
;;
m680[234]0*-*-linux* | m68k*-*-linux*)
syntax=elf
;;
m680[234]0*-*-* | m68k*-*-*)
syntax=mit
;;
esac
changequote([,])
# Pick the correct source files in $path and link them to mpn/.
# $gmp_mpn_functions lists all functions we need.
#
# The rule is to find a file with the function name and a .asm, .S,
# .s, or .c extension. Certain multi-function files with special names
# can provide some functions too. (mpn/Makefile.am passes
# -DOPERATION_<func> to get them to generate the right code.)
# FIXME: udiv and umul aren't in $gmp_mpn_functions_optional yet since
# there's some versions of those files which should be checked for bit
# rot first. Put them in $extra_functions for each host for now,
# change to standard optionals when all are ready.
# Note: The following lines defining $gmp_mpn_functions_optional
# and $gmp_mpn_functions are parsed by the "macos/configure"
# Perl script. So if you change the lines in a major way
# make sure to run and examine the output from
#
# % (cd macos; perl configure)
#
# Note: $gmp_mpn_functions must have mod_1 before pre_mod_1 so the former
# can optionally have the latter as an extra entrypoint.
gmp_mpn_functions_optional="copyi copyd com_n \
and_n andn_n nand_n ior_n iorn_n nior_n xor_n xnor_n \
gcd_finda invert_limb sqr_diagonal"
gmp_mpn_functions="$extra_functions inlines add_n sub_n mul_1 addmul_1 \
submul_1 lshift rshift diveby3 divis divrem divrem_1 divrem_2 \
mod_1 mode1o pre_mod_1 dump \
mul mul_fft mul_n mul_basecase sqr_basecase random \
random2 sqrtrem get_str set_str scan0 scan1 popcount hamdist cmp perfsqr \
bdivmod gcd_1 gcd gcdext tdiv_qr dc_divrem_n sb_divrem_mn jacbase \
$gmp_mpn_functions_optional"
# the list of all object files used by mpn/Makefile.in and the
# top-level Makefile.in, respectively
mpn_objects=
mpn_objs_in_libgmp="mpn/mp_bases.lo"
# links from the sources, to be removed by "make distclean"
gmp_srclinks=
define(MPN_SUFFIXES,[asm S s c])
for tmp_ext in MPN_SUFFIXES; do
eval found_$tmp_ext=no
done
for tmp_fn in $gmp_mpn_functions; do
for tmp_ext in MPN_SUFFIXES; do
test "$no_create" = yes || rm -f mpn/$tmp_fn.$tmp_ext
done
# Don't need pre_mod_1 if it's already been provided (by an asm mod_1).
case $tmp_fn in
pre_mod_1)
if test "$HAVE_NATIVE_mpn_preinv_mod_1" = yes; then continue; fi ;;
esac
# functions that can be provided by multi-function files
tmp_mulfunc=
case $tmp_fn in
add_n|sub_n) tmp_mulfunc="aors_n" ;;
addmul_1|submul_1) tmp_mulfunc="aorsmul_1" ;;
popcount|hamdist) tmp_mulfunc="popham" ;;
and_n|andn_n|nand_n | ior_n|iorn_n|nior_n | xor_n|xnor_n)
tmp_mulfunc="logops_n" ;;
lshift|rshift) tmp_mulfunc="lorrshift";;
esac
found=no
for tmp_dir in $path; do
for tmp_base in $tmp_fn $tmp_mulfunc; do
for tmp_ext in MPN_SUFFIXES; do
tmp_file=$srcdir/mpn/$tmp_dir/$tmp_base.$tmp_ext
if test -f $tmp_file; then
found=yes
eval found_$tmp_ext=yes
if test $tmp_ext = c; then
tmp_u='$U'
else
tmp_u=
fi
mpn_objects="$mpn_objects $tmp_fn$tmp_u.lo"
mpn_objs_in_libgmp="$mpn_objs_in_libgmp mpn/$tmp_fn$tmp_u.lo"
AC_CONFIG_LINKS(mpn/$tmp_fn.$tmp_ext:mpn/$tmp_dir/$tmp_base.$tmp_ext)
gmp_srclinks="$gmp_srclinks mpn/$tmp_fn.$tmp_ext"
# Duplicate AC_DEFINEs are harmless, so it doesn't matter
# that multi-function files get grepped here repeatedly.
# The PROLOGUE pattern has ".*" so that alpha PROLOGUE_GP matches.
gmp_ep=[`
sed -n 's/^[ ]*MULFUNC_PROLOGUE(\(.*\))/\1/p' $tmp_file ;
sed -n 's/^[ ]*PROLOGUE.*(\(.*\))/\1/p' $tmp_file
`]
for gmp_tmp in $gmp_ep; do
AC_DEFINE_UNQUOTED(HAVE_NATIVE_$gmp_tmp)
eval HAVE_NATIVE_$gmp_tmp=yes
done
case $tmp_fn in
sqr_basecase) sqr_basecase_source=$tmp_file ;;
esac
break
fi
done
if test $found = yes; then break ; fi
done
if test $found = yes; then break ; fi
done
if test $found = no; then
for tmp_optional in $gmp_mpn_functions_optional; do
if test $tmp_optional = $tmp_fn; then
found=yes
fi
done
if test $found = no; then
AC_MSG_ERROR([no version of $tmp_fn found in path: $path])
fi
fi
done
# All cycle counters are .asm files currently
if test -n "$SPEED_CYCLECOUNTER_OBJ"; then
found_asm=yes
fi
# Don't demand an m4 unless it's actually needed.
if test $found_asm = yes; then
GMP_PROG_M4
else
M4=m4-not-needed
fi
# Only do the GMP_ASM checks if there's a .S or .asm wanting them.
if test $found_asm = no && test $found_S = no; then
gmp_asm_syntax_testing=no
fi
if test "$gmp_asm_syntax_testing" != no; then
GMP_ASM_TEXT
GMP_ASM_DATA
GMP_ASM_RODATA
GMP_ASM_GLOBL
GMP_ASM_GLOBL_ATTR
GMP_ASM_LABEL_SUFFIX
GMP_ASM_TYPE
GMP_ASM_SIZE
GMP_ASM_LSYM_PREFIX
GMP_ASM_W32
GMP_ASM_UNDERSCORE(underscore=yes, underscore=no)
GMP_ASM_ALIGN_LOG(asm_align=log, asm_align=nolog)
case $host in
power*-*-*)
GMP_ASM_POWERPC_R_REGISTERS
GMP_INCLUDE_MPN(powerpc32/powerpc-defs.m4)
case $host in
powerpc64*-*-aix*) GMP_INCLUDE_MPN(powerpc64/aix.m4) ;;
*-*-aix*) GMP_INCLUDE_MPN(powerpc32/aix.m4) ;;
esac
;;
X86_PATTERN)
GMP_ASM_ALIGN_FILL_0x90
GMP_ASM_X86_SHLDL_CL
if test "$enable_profiling" != no; then
GMP_ASM_X86_MCOUNT
fi
;;
esac
# Build an asm-syntax.h file for hosts that include that from the
# assembly files.
# FIXME: Remove when conversion to .asm is completed.
#
case "${family}-${underscore}-${asm_align}-${syntax}" in
m68k-yes-log-mit)
echo '#define MIT_SYNTAX' >asm-syntax.h
cat $srcdir/mpn/underscore.h >>asm-syntax.h
echo '#include "'$srcdir'/mpn/m68k/syntax.h"' >>asm-syntax.h;;
m68k-no-nolog-elf)
echo '#define ELF_SYNTAX' >asm-syntax.h
echo '#define C_SYMBOL_NAME(name) name' >>asm-syntax.h
echo '#include "'$srcdir'/mpn/m68k/syntax.h"' >>asm-syntax.h;;
esac
fi
# Create link for gmp-mparam.h.
gmp_mparam_source=
for tmp_dir in $path; do
test "$no_create" = yes || rm -f gmp-mparam.h
tmp_file=$srcdir/mpn/$tmp_dir/gmp-mparam.h
if test -f $tmp_file; then
AC_CONFIG_LINKS(gmp-mparam.h:mpn/$tmp_dir/gmp-mparam.h)
gmp_srclinks="$gmp_srclinks gmp-mparam.h"
gmp_mparam_source=$tmp_file
break
fi
done
if test -z "$gmp_mparam_source"; then
AC_MSG_ERROR([no version of gmp-mparam.h found in path: $path])
fi
# Copy any KARATSUBA_SQR_THRESHOLD from gmp-mparam.h to config.m4.
# Some versions of sqr_basecase.asm use this.
tmp_gmp_karatsuba_sqr_threshold=`sed -n 's/^#define KARATSUBA_SQR_THRESHOLD[ ]*\([0-9][0-9]*\).*$/\1/p' $gmp_mparam_source`
if test -n "$tmp_gmp_karatsuba_sqr_threshold"; then
GMP_DEFINE_RAW(["define(<KARATSUBA_SQR_THRESHOLD>,<$tmp_gmp_karatsuba_sqr_threshold>)"])
fi
GMP_C_SIZES
GMP_C_ATTRIBUTE_NORETURN
GMP_C_ATTRIBUTE_CONST
# Exclude the mpn random functions from mpbsd since that would drag in the
# top-level rand things, all of which are unnecessary for libmp. There's
# other unnecessary objects there too actually, if we could be bothered
# figuring out exactly what.
#
mpn_objs_in_libmp=
for i in $mpn_objs_in_libgmp; do
case $i in
*random*) ;;
*) mpn_objs_in_libmp="$mpn_objs_in_libmp $i" ;;
esac
done
AC_SUBST(mpn_objs_in_libmp)
AC_SUBST(mpn_objects)
AC_SUBST(mpn_objs_in_libgmp)
AC_SUBST(gmp_srclinks)
# A recompiled sqr_basecase for use in the tune program, if necessary.
TUNE_SQR_OBJ=
test -d tune || mkdir tune
case $sqr_basecase_source in
*.asm)
sqr_max=[`sed -n 's/^def...(KARATSUBA_SQR_THRESHOLD_MAX, *\([0-9]*\))/\1/p' $sqr_basecase_source`]
if test -n "$sqr_max"; then
TUNE_SQR_OBJ=sqr_asm.o
AC_DEFINE_UNQUOTED(TUNE_KARATSUBA_SQR_MAX,$sqr_max,
[Maximum size the tune program can test for KARATSUBA_SQR_THRESHOLD])
fi
cat >tune/sqr_basecase.c <<EOF
/* not sure that an empty file can compile, so put in a dummy */
int sqr_basecase_dummy;
EOF
;;
*.c)
TUNE_SQR_OBJ=
AC_DEFINE(TUNE_KARATSUBA_SQR_MAX,KARATSUBA_SQR_MAX_GENERIC)
cat >tune/sqr_basecase.c <<EOF
#define TUNE_PROGRAM_BUILD 1
#define TUNE_PROGRAM_BUILD_SQR 1
#include "mpn/sqr_basecase.c"
EOF
;;
esac
AC_SUBST(TUNE_SQR_OBJ)
# Configs for demos/expr directory
if test $enable_mpfr = yes; then
AC_DEFINE(HAVE_MPFR,1)
else
AC_DEFINE(HAVE_MPFR,0)
fi
AM_CONFIG_HEADER(demos/expr/expr-impl.h:demos/expr/expr-impl-h.in)
# Create config.m4.
GMP_FINISH
# Create Makefiles
# FIXME: Upcoming version of autoconf/automake may not like broken lines.
# Right now automake isn't accepting the new AC_CONFIG_FILES scheme.
AC_OUTPUT(Makefile \
mpbsd/Makefile mpf/Makefile mpfr/Makefile mpn/Makefile mpq/Makefile \
mpz/Makefile \
mpfr/tests/Makefile \
tests/Makefile tests/devel/Makefile tests/mpbsd/Makefile \
tests/mpf/Makefile tests/mpq/Makefile tests/mpz/Makefile \
tests/rand/Makefile \
tune/Makefile \
demos/Makefile demos/calc/Makefile demos/expr/Makefile)
|