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
|
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
# Copyright (c) 2023 Albin Ahlbäck
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 6
# This code is modified to print CC instead of *language* compiler
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether $CC accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS
# Test for CXX compiler
AC_DEFUN([AX_CXX_CHECK_COMPILE_FLAG],
[AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether $CXX accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CXX_CHECK_COMPILE_FLAGS
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
dnl AX_INIT
dnl -----------------------
dnl If build directory is not source directory, this function throws if source
dnl directory is already configured.
AC_DEFUN([AX_INIT],[dnl
if test "$ac_abs_confdir" != "`pwd`"; dnl ' Vim syntax fix
then
if test -f $srcdir/config.status;
then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
fi])
dnl Copyright (C) 2024 Albin Ahlbäck
dnl
dnl This file is part of FLINT.
dnl
dnl FLINT is free software: you can redistribute it and/or modify it under
dnl the terms of the GNU Lesser General Public License (LGPL) as published
dnl by the Free Software Foundation; either version 3 of the License, or
dnl (at your option) any later version. See <https://www.gnu.org/licenses/>.
dnl NOTE: The first two patterns are taken from GMP. The license is down below.
define(X86_PATTERN,
[[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-* | geode*-*-* | atom-*-*]])
define(X86_64_PATTERN,
[[athlon64-*-* | k8-*-* | k10-*-* | bobcat-*-* | jaguar-*-* | bulldozer-*-* | piledriver-*-* | steamroller-*-* | excavator-*-* | pentium4-*-* | atom-*-* | silvermont-*-* | goldmont-*-* | tremont-*-* | core2-*-* | corei*-*-* | x86_64-*-* | x86_64v[1234]-*-* | nano-*-* | nehalem-*-* | westmere-*-* | sandybridge-*-* | ivybridge-*-* | haswell-*-* | zen-*-* | zen[2345]-*-* | broadwell-*-* | skylake-*-* | skylake_server-*-* | cannonlake-*-* | kabylake-*-* | cometlake-*-* | icelake-*-* | icelake_server-*-* | rocketlake-*-* | tigerlake-*-* | alderlake-*-* | raptorlake-*-* | meteorlake-*-* | knightslanding-*-* | sapphirerapids-*-*]])
define(X86_64_ADX_PATTERN,
[[zen-*-* | zen[2345]-*-* | broadwell-*-* | skylake-*-* | skylake_server-*-* | cannonlake-*-* | kabylake-*-* | cometlake-*-* | icelake-*-* | icelake_server-*-* | rocketlake-*-* | tigerlake-*-* | alderlake-*-* | raptorlake-*-* | meteorlake-*-* | knightslanding-*-* | sapphirerapids-*-*]])
define(ARM64_PATTERN,
[[armcortexa53-*-* | armcortexa53neon-*-* | armcortexa55-*-* | armcortexa55neon-*-* | armcortexa57-*-* | armcortexa57neon-*-* | armcortexa7[2-9]-*-* | armcortexa7[2-9]neon-*-* | armexynosm1-*-* | armthunderx-*-* | armxgene1-*-* | aarch64*-*-* | applem[1-9]*-*-* | armv8*-*-*]])
define(SLOW_VROUNDPD_PATTERN,
[[haswell* | broadwell* | skylake* | kabylake* | icelake* | tigerlake* | rocketlake* | alderlake* | raptorlake* | meteorlake*]])
define(FAST_VROUNDPD_PATTERN,
[[znver[2-4]* | sandybridge* | ivybridge*]])
dnl FLINT_CC_IS_GCC([action-if-true],[action-if-false])
dnl -----------------------
dnl Checks if compiler is GCC.
AC_DEFUN([FLINT_CC_IS_GCC],
[AC_CACHE_CHECK([if compiler is GCC],
flint_cv_cc_is_gcc,
[flint_cv_cc_is_gcc="no"
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
#if !(defined(__GNUC__) && !defined(__clang__))
#error
error
#endif
],[])],
[flint_cv_cc_is_gcc="yes"])
])
AS_VAR_IF([flint_cv_cc_is_gcc],"yes",
[m4_default([$1], :)],
[m4_default([$2], :)])
])
dnl FLINT_CC_IS_CLANG([action-if-true],[action-if-false])
dnl -----------------------
dnl Checks if compiler is clang.
AC_DEFUN([FLINT_CC_IS_CLANG],
[AC_CACHE_CHECK([if compiler is Clang],
flint_cv_cc_is_clang,
[flint_cv_cc_is_clang="no"
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
#ifndef __clang__
#error
error
#endif
],[])],
[flint_cv_cc_is_clang="yes"])
])
AS_VAR_IF([flint_cv_cc_is_clang],"yes",
[m4_default([$1], :)],
[m4_default([$2], :)])
])
dnl FLINT_CHECK_CPU_SET_T([action-if-true],[action-if-false])
dnl -----------------------
dnl Checks if cpu_set_t is supported.
dnl
dnl FIXME: Does this cover all BSD systems?
AC_DEFUN([FLINT_CHECK_CPU_SET_T],
[AC_CACHE_CHECK([if cpu_set_t is supported],
flint_cv_check_cpu_set_t,
[flint_cv_check_cpu_set_t="no"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#define _GNU_SOURCE
#include <sched.h>
#include <pthread.h>
],
[cpu_set_t s;
CPU_ZERO(&s);
pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), 0);])],
[flint_cv_check_cpu_set_t="yes"])
])
AS_VAR_IF([flint_cv_check_cpu_set_t],"yes",
[m4_default([$1], :)],
[m4_default([$2], :)])
])
dnl FLINT_CHECK_PRAGMA(string,define,[prestring])
dnl ---------------------------------
AC_DEFUN([FLINT_CHECK_PRAGMA],[
tmp_CFLAGS="$CFLAGS"
CFLAGS="-Werror -Wunknown-pragmas"
if test "x$3" != "x";
then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([${pragma_cc_prefix}$3${pragma_cc_suffix}
${pragma_cc_prefix}$1${pragma_cc_suffix}],[])],[tmp="yes"],[tmp="no"])
else
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([${pragma_cc_prefix}$1${pragma_cc_suffix}],[])],
[tmp="yes"],[tmp="no"])
fi
CFLAGS="$tmp_CFLAGS"
if test "$tmp" = "yes";
then
AC_DEFINE_UNQUOTED($2,${pragma_cc_prefix}$1${pragma_cc_suffix})
fi
])
dnl FLINT_CHECK_PRAGMAS
dnl -------------------
dnl Checks pragmas available and push them into config header.
AC_DEFUN([FLINT_CHECK_PRAGMAS],
[AC_REQUIRE([FLINT_CC_IS_GCC])
AC_REQUIRE([FLINT_CC_IS_CLANG])
AH_VERBATIM([PRAGMAS],
[/* Define the following to what diagnostic pragmas your compiler allows.
These are used to silence certain warnings. */
#define DIAGNOSTIC_PUSH
#define DIAGNOSTIC_POP
#define DIAGNOSTIC_IGNORE_INCOMPATIBLE_FUNCTION_POINTER_TYPES
#define DIAGNOSTIC_IGNORE_DISCARDED_QUALIFIERS
#define DIAGNOSTIC_IGNORE_FORMAT
#define DIAGNOSTIC_IGNORE_DANGLING_POINTER
#define DIAGNOSTIC_IGNORE_CAST_FUNCTION_TYPE
#define DIAGNOSTIC_IGNORE_OVERLENGTH_STRINGS
#define DIAGNOSTIC_IGNORE_UNUSED_VARIABLE
#define DIAGNOSTIC_IGNORE_MAYBE_UNINITIALIZED
/* Define the following to what optimization pragmas your compiler allows. */
#define PUSH_OPTIONS
#define POP_OPTIONS
#define OPTIMIZE_O2
#define OPTIMIZE_OSIZE
#define OPTIMIZE_UNROLL_LOOPS])
flint_cv_pragma_compiler=""
if test "$flint_cv_cc_is_clang" = "yes";
then
flint_cv_pragma_compiler="clang"
elif test "$flint_cv_cc_is_gcc" = "yes";
then
flint_cv_pragma_compiler="GCC"
fi
if test "x$flint_cv_pragma_compiler" != "x";
then
pragma_cc_prefix='_Pragma("'"$flint_cv_pragma_compiler "
pragma_cc_suffix='")'
FLINT_CHECK_PRAGMA([diagnostic push],[DIAGNOSTIC_PUSH])
FLINT_CHECK_PRAGMA([diagnostic pop],[DIAGNOSTIC_POP],[diagnostic push])
FLINT_CHECK_PRAGMA([diagnostic ignored \"-Wincompatible-function-pointer-types\"],[DIAGNOSTIC_IGNORE_INCOMPATIBLE_FUNCTION_POINTER_TYPES])
FLINT_CHECK_PRAGMA([diagnostic ignored \"-Wdiscarded-qualifiers\"],[DIAGNOSTIC_IGNORE_DISCARDED_QUALIFIERS])
FLINT_CHECK_PRAGMA([diagnostic ignored \"-Wformat\"],[DIAGNOSTIC_IGNORE_FORMAT])
FLINT_CHECK_PRAGMA([diagnostic ignored \"-Wdangling-pointer\"],[DIAGNOSTIC_IGNORE_DANGLING_POINTER])
FLINT_CHECK_PRAGMA([diagnostic ignored \"-Wcast-function-type\"],[DIAGNOSTIC_IGNORE_CAST_FUNCTION_TYPE])
FLINT_CHECK_PRAGMA([diagnostic ignored \"-Woverlength-strings\"],[DIAGNOSTIC_IGNORE_OVERLENGTH_STRINGS])
FLINT_CHECK_PRAGMA([diagnostic ignored \"-Wunused-variable\"],[DIAGNOSTIC_IGNORE_UNUSED_VARIABLE])
FLINT_CHECK_PRAGMA([diagnostic ignored \"-Wmaybe-uninitialized\"],[DIAGNOSTIC_IGNORE_MAYBE_UNINITIALIZED])
FLINT_CHECK_PRAGMA([push_options],[PUSH_OPTIONS])
FLINT_CHECK_PRAGMA([pop_options],[POP_OPTIONS])
FLINT_CHECK_PRAGMA([optimize (\"O2\")],[OPTIMIZE_O2])
FLINT_CHECK_PRAGMA([optimize (\"Os\")],[OPTIMIZE_OSIZE])
FLINT_CHECK_PRAGMA([optimize (\"unroll-loops\")],[OPTIMIZE_UNROLL_LOOPS])
fi
])
dnl FLINT_CHECK_NTL([action-if-true],[action-if-false])
dnl -----------------------
dnl Checks if linking with NTL works.
AC_DEFUN([FLINT_CHECK_NTL],
[AC_REQUIRE([AC_PROG_CXX])
AC_CACHE_CHECK([if linking with NTL works],
flint_cv_check_ntl,
[flint_cv_check_ntl="no"
save_LIBS="$LIBS"
LIBS="-lntl $LIBS"
AC_LANG_PUSH([C++])
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <NTL/ZZ.h>
]], [NTL::ZZ a, b, c;
std::cin >> a;
std::cin >> b;
c = (a+1)*(b+1);
std::cout << c << "\n";])],
[flint_cv_check_ntl="yes"])
AC_LANG_POP([C++])
LIBS="$save_LIBS"
])
AS_VAR_IF([flint_cv_check_ntl],"yes",
[m4_default([$1], :)],
[m4_default([$2], :)])
])
dnl FLINT_PREPROC_IFELSE(input,[action-if-true],[action-if-false])
dnl -----------------------
dnl Runs preprocessor with CFLAGS.
dnl
dnl FIXME: Autoconf states that some compilers do not accept CFLAGS in the
dnl preprocessor. Which ones is it? GCC and Clang certainly does. If it does
dnl not allow CFLAGS into preprocessor, we should just compile normally.
AC_DEFUN([FLINT_PREPROC_IFELSE],
[AC_REQUIRE([AC_PROG_CPP])
save_ac_cpp="$ac_cpp"
ac_cpp="$CPP $CFLAGS $CPPFLAGS"
AC_PREPROC_IFELSE($@)
ac_cpp="$ac_cpp"
])
dnl FLINT_CHECK_GMP_H(MAJOR, MINOR, PATCHLEVEL)
dnl -----------------------
dnl Checks that gmp.h can be found and that its version fullfills the version
dnl requirement.
AC_DEFUN([FLINT_CHECK_GMP_H],
[AC_CHECK_HEADER([gmp.h],,AC_MSG_ERROR([Could not find gmp.h]))
AC_MSG_CHECKING([if version of GMP is greater than $1.$2.$3])
AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
[#include <gmp.h>
],[#if (__GNU_MP_VERSION < $1) \
|| (__GNU_MP_VERSION == $1 && __GNU_MP_VERSION_MINOR < $2) \
|| (__GNU_MP_VERSION == $1 && __GNU_MP_VERSION_MINOR == $2 && __GNU_MP_VERSION_PATCHLEVEL < $3)
# error GMP version $1.$2.$3 or later is required
#endif
]
)],
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no])
AC_MSG_ERROR([GMP version $1.$2.$3 or later is required.])
)
])
dnl FLINT_CHECK_MPFR_H(MAJOR, MINOR, PATCHLEVEL)
dnl -----------------------
dnl Checks that mpfr.h can be found and that its version fullfills the version
dnl requirement.
AC_DEFUN([FLINT_CHECK_MPFR_H],
[AC_REQUIRE([FLINT_CHECK_GMP_H])
AC_CHECK_HEADER([mpfr.h],,AC_MSG_ERROR([Could not find mpfr.h]))
AC_MSG_CHECKING([if version of MPFR is greater than $1.$2.$3])
AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
[#include <mpfr.h>
],[#if (MPFR_VERSION_MAJOR < $1) \
|| (MPFR_VERSION_MAJOR == $1 && MPFR_VERSION_MINOR < $2) \
|| (MPFR_VERSION_MAJOR == $1 && MPFR_VERSION_MINOR == $2 && MPFR_VERSION_PATCHLEVEL < $3)
# error MPFR version $1.$2.$3 or later is required
#endif
]
)],
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no])
AC_MSG_ERROR([MPFR version $1.$2.$3 or later is required.])
)
])
dnl FLINT_GMP_LONG_LONG_LIMB([action-success][,action-fail])
dnl -----------------------
dnl Check if GMP uses long long limb.
AC_DEFUN([FLINT_GMP_LONG_LONG_LIMB],
[AC_REQUIRE([FLINT_CHECK_GMP_H])
AC_CACHE_CHECK([if GMP defines mp_limb_t as unsigned long long int],
flint_cv_gmp_long_long_limb,
[AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
[
#include <gmp.h>
],[
#if !defined(_LONG_LONG_LIMB)
# error mp_limb_t != unsigned long long int
#endif
]
)],
flint_cv_gmp_long_long_limb="yes",
flint_cv_gmp_long_long_limb="no"
)])
AS_VAR_IF([flint_cv_gmp_long_long_limb],"yes",
[m4_default([$1], :)],
[m4_default([$2], :)])
])
dnl FLINT_ABI
dnl -----------------------
dnl Checks what ABI to use. First checks if ABI is given. If none where given,
dnl check GMP's configuration.
AC_DEFUN([FLINT_ABI],
[AC_REQUIRE([FLINT_CHECK_GMP_H])
AC_ARG_VAR(ABI, [Desired ABI])
AC_CACHE_CHECK([for desired ABI],
flint_cv_abi,
[if test -n "$ABI";
then
flint_cv_abi="$ABI"
else
AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
[
#include <gmp.h>
],[
#if GMP_LIMB_BITS == 32
#error Dead man
error
#endif
]
)],
flint_cv_abi="64",
flint_cv_abi="32"
)
fi
])
])
dnl FLINT_HAVE_FFT_SMALL_ARM_H
dnl -----------------------
dnl Checks if system have headers for fft_small on Arm. Will only run if on
dnl arm64.
AC_DEFUN([FLINT_HAVE_FFT_SMALL_ARM_H],
[case $host in
ARM64_PATTERN)
AC_CHECK_HEADERS([arm_neon.h],
flint_cv_have_fft_small_arm_h="yes",
flint_cv_have_fft_small_arm_h="no")
;;
esac])
dnl FLINT_HAVE_FFT_SMALL_ARM_I
dnl -----------------------
dnl Checks if system supports Arm NEON instructions.
AC_DEFUN([FLINT_HAVE_FFT_SMALL_ARM_I],
[case $host in
ARM64_PATTERN)
AC_CACHE_CHECK([if system have required ARM instruction set for fft_small],
flint_cv_have_fft_small_arm_i,
[FLINT_PREPROC_IFELSE([AC_LANG_SOURCE([
#if !defined(__ARM_NEON)
#error Dead man
error
#endif
])],
flint_cv_have_fft_small_arm_i="yes",
flint_cv_have_fft_small_arm_i="no")])
;;
esac])
dnl FLINT_HAVE_FFT_SMALL_X86_H
dnl -----------------------
dnl Checks if system have headers for fft_small on x86.
AC_DEFUN([FLINT_HAVE_FFT_SMALL_X86_H],
[case $host in
X86_64_PATTERN)
AC_CHECK_HEADERS([immintrin.h],
flint_cv_have_fft_small_x86_h="yes",
flint_cv_have_fft_small_x86_h="no")
;;
esac])
dnl FLINT_HAVE_FFT_SMALL_X86_I
dnl -----------------------
dnl Checks if system supports AVX2 instructions.
AC_DEFUN([FLINT_HAVE_FFT_SMALL_X86_I],
[case $host in
X86_64_PATTERN)
AC_CACHE_CHECK([if system have required x86_64 instruction set for fft_small],
flint_cv_have_fft_small_x86_i,
[FLINT_PREPROC_IFELSE([AC_LANG_SOURCE([
#if !defined(__AVX2__)
#error Dead man
error
#endif
])],
flint_cv_have_fft_small_x86_i="yes",
flint_cv_have_fft_small_x86_i="no")])
;;
esac])
dnl FLINT_CHECK_FFT_SMALL([action-success][,action-fail])
dnl -----------------------
dnl Checks if fft_small module is available.
dnl Do "action-success" if this succeeds, "action-fail" if not.
AC_DEFUN([FLINT_CHECK_FFT_SMALL],
[AC_REQUIRE([FLINT_ABI])
AC_REQUIRE([FLINT_HAVE_FFT_SMALL_ARM_H])
AC_REQUIRE([FLINT_HAVE_FFT_SMALL_ARM_I])
AC_REQUIRE([FLINT_HAVE_FFT_SMALL_X86_H])
AC_REQUIRE([FLINT_HAVE_FFT_SMALL_X86_I])
AC_CACHE_CHECK([if system can use FLINT's fft_small module],
flint_cv_check_fft_small,
[flint_cv_check_fft_small="no"
if test "$flint_cv_abi" = "64";
then
if test "$flint_cv_have_fft_small_arm_h" = "yes" && test "$flint_cv_have_fft_small_arm_i" = "yes";
then
flint_cv_check_fft_small="yes"
fi
if test "$flint_cv_have_fft_small_x86_h" = "yes" && test "$flint_cv_have_fft_small_x86_i" = "yes";
then
flint_cv_check_fft_small="yes"
fi
fi
])
AS_VAR_IF([flint_cv_check_fft_small],"yes",
[m4_default([$1], :)],
[m4_default([$2], :)])
])
dnl GMP specific autoconf macros
dnl (Taken from GMP 6.3.0)
dnl
dnl Copyright 2000-2006, 2009, 2011, 2013-2018 Free Software Foundation, Inc.
dnl
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
dnl GMP_INIT([M4-DEF-FILE])
dnl -----------------------
dnl Initializations for GMP config.m4 generation.
dnl
dnl FIXME: The generated config.m4 doesn't get recreated by config.status.
dnl Maybe the relevant "echo"s should go through AC_CONFIG_COMMANDS.
dnl NOTE: This is different from GMP.
AC_DEFUN([GMP_INIT],
[ifelse([$1], , gmp_configm4=config.m4, gmp_configm4="[$1]")
gmp_tmpconfigm4=cnfm4.tmp
gmp_tmpconfigm4i=cnfm4i.tmp
gmp_tmpconfigm4p=cnfm4p.tmp
rm -f $gmp_tmpconfigm4 $gmp_tmpconfigm4i $gmp_tmpconfigm4p
echo ["define(<CONFIG_TOP_SRCDIR>,<\`$srcdir'>)"] >>$gmp_tmpconfigm4
echo ["include][(CONFIG_TOP_SRCDIR\`/src/mpn_extras/asm-defs.m4')"] >>$gmp_tmpconfigm4i
])
dnl GMP_FINISH
dnl ----------
dnl Create config.m4 from its accumulated parts.
dnl
dnl __CONFIG_M4_INCLUDED__ is used so that a second or subsequent include
dnl of config.m4 is harmless.
dnl
dnl A separate ifdef on the angle bracket quoted part ensures the quoting
dnl style there is respected. The basic defines from gmp_tmpconfigm4 are
dnl fully quoted but are still put under an ifdef in case any have been
dnl redefined by one of the m4 include files.
dnl
dnl Doing a big ifdef within asm-defs.m4 and/or other macro files wouldn't
dnl work, since it'd interpret parentheses and quotes in dnl comments, and
dnl having a whole file as a macro argument would overflow the string space
dnl on BSD m4.
AC_DEFUN([GMP_FINISH],
[AC_REQUIRE([GMP_INIT])
echo "creating $gmp_configm4"
echo ["d""nl $gmp_configm4. Generated automatically by configure."] > $gmp_configm4
if test -f $gmp_tmpconfigm4; then
echo ["changequote(<,>)"] >> $gmp_configm4
echo ["ifdef(<__CONFIG_M4_INCLUDED__>,,<"] >> $gmp_configm4
cat $gmp_tmpconfigm4 >> $gmp_configm4
echo [">)"] >> $gmp_configm4
echo ["changequote(\`,')"] >> $gmp_configm4
rm $gmp_tmpconfigm4
fi
echo ["ifdef(\`__CONFIG_M4_INCLUDED__',,\`"] >> $gmp_configm4
if test -f $gmp_tmpconfigm4i; then
cat $gmp_tmpconfigm4i >> $gmp_configm4
rm $gmp_tmpconfigm4i
fi
if test -f $gmp_tmpconfigm4p; then
cat $gmp_tmpconfigm4p >> $gmp_configm4
rm $gmp_tmpconfigm4p
fi
echo ["')"] >> $gmp_configm4
echo ["define(\`__CONFIG_M4_INCLUDED__')"] >> $gmp_configm4
])
dnl GMP_INCLUDE_MPN(FILE)
dnl ---------------------
dnl Add an include_mpn(`FILE') to config.m4. FILE should be a path
dnl relative to the mpn source directory, for example
dnl
dnl GMP_INCLUDE_MPN(`x86/x86-defs.m4')
dnl
AC_DEFUN([GMP_INCLUDE_MPN],
[AC_REQUIRE([GMP_INIT])
echo ["include][(CONFIG_TOP_SRCDIR\`/$1')"] >>$gmp_tmpconfigm4i
])
dnl GMP_PROG_M4
dnl -----------
dnl Find a working m4, either in $PATH or likely locations, and setup $M4
dnl and an AC_SUBST accordingly. If $M4 is already set then it's a user
dnl choice and is accepted with no checks. GMP_PROG_M4 is like
dnl AC_PATH_PROG or AC_CHECK_PROG, but tests each m4 found to see if it's
dnl good enough.
dnl
dnl See mpn/asm-defs.m4 for details on the known bad m4s.
AC_DEFUN([GMP_PROG_M4],
[AC_ARG_VAR(M4,[m4 macro processor])
AC_CACHE_CHECK([for suitable m4],
gmp_cv_prog_m4,
[if test -n "$M4"; then
gmp_cv_prog_m4="$M4"
else
cat >conftest.m4 <<\EOF
dnl Must protect this against being expanded during autoconf m4!
dnl Dont put "dnl"s in this as autoconf will flag an error for unexpanded
dnl macros.
[define(dollarhash,``$][#'')ifelse(dollarhash(x),1,`define(t1,Y)',
``bad: $][# not supported (SunOS /usr/bin/m4)
'')ifelse(eval(89),89,`define(t2,Y)',
`bad: eval() doesnt support 8 or 9 in a constant (OpenBSD 2.6 m4)
')ifelse(eval(9,9),10,`define(t3,Y)',
`bad: eval() doesnt support radix in eval (FreeBSD 8.x,9.0,9.1,9.2 m4)
')ifelse(t1`'t2`'t3,YYY,`good
')]
EOF
dnl ' <- balance the quotes for emacs sh-mode
echo "trying m4" >&AS_MESSAGE_LOG_FD
gmp_tmp_val=`(m4 conftest.m4) 2>&AS_MESSAGE_LOG_FD`
echo "$gmp_tmp_val" >&AS_MESSAGE_LOG_FD
if test "$gmp_tmp_val" = good; then
gmp_cv_prog_m4="m4"
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
dnl $ac_dummy forces splitting on constant user-supplied paths.
dnl POSIX.2 word splitting is done only on the output of word expansions,
dnl not every word. This closes a longstanding sh security hole.
ac_dummy="$PATH:/usr/5bin"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
echo "trying $ac_dir/m4" >&AS_MESSAGE_LOG_FD
gmp_tmp_val=`($ac_dir/m4 conftest.m4) 2>&AS_MESSAGE_LOG_FD`
echo "$gmp_tmp_val" >&AS_MESSAGE_LOG_FD
if test "$gmp_tmp_val" = good; then
gmp_cv_prog_m4="$ac_dir/m4"
break
fi
done
IFS="$ac_save_ifs"
if test -z "$gmp_cv_prog_m4"; then
AC_MSG_ERROR([No usable m4 in \$PATH or /usr/5bin (see config.log for reasons).])
fi
fi
rm -f conftest.m4
fi])
M4="$gmp_cv_prog_m4"
AC_SUBST(M4)
])
dnl GMP_PATH_NM
dnl -----------
dnl GMP additions to libtool LT_PATH_NM.
dnl
dnl Note that if LT_PATH_NM can't find a working nm it still leaves
dnl $NM set to "nm", so $NM can't be assumed to actually work.
dnl
dnl A user-selected $NM is always left unchanged. LT_PATH_NM is still run
dnl to get the "checking" message printed though.
dnl
dnl Perhaps it'd be worthwhile checking that nm works, by running it on an
dnl actual object file. For instance on sparcv9 solaris old versions of
dnl GNU nm don't recognise 64-bit objects. Checking would give a better
dnl error message than just a failure in later tests like GMP_ASM_W32 etc.
dnl
dnl On the other hand it's not really normal autoconf practice to take too
dnl much trouble over detecting a broken set of tools. And libtool doesn't
dnl do anything at all for say ranlib or strip. So for now we're inclined
dnl to just demand that the user provides a coherent environment.
AC_DEFUN([GMP_PATH_NM],
[
gmp_user_NM=$NM
dnl Is already called in LT_INIT
dnl LT_PATH_NM
# FIXME: When cross compiling (ie. $ac_tool_prefix not empty), libtool
# defaults to plain "nm" if a "${ac_tool_prefix}nm" is not found. In this
# case run it again to try the native "nm", firstly so that likely locations
# are searched, secondly so that -B or -p are added if necessary for BSD
# format. This is necessary for instance on OSF with "./configure
# --build=alphaev5-dec-osf --host=alphaev6-dec-osf".
#
if test -z "$gmp_user_NM" && test -n "$ac_tool_prefix" && test "$NM" = nm; then
$as_unset lt_cv_path_NM
gmp_save_ac_tool_prefix=$ac_tool_prefix
ac_tool_prefix=
NM=
LT_PATH_NM
ac_tool_prefix=$gmp_save_ac_tool_prefix
fi
if test -z "$gmp_user_NM"; then
eval nmflags=\"\$nm${abi1}_flags\"
test -n "$nmflags" || eval nmflags=\"\$nm${abi2}_flags\"
if test -n "$nmflags"; then
AC_MSG_CHECKING([for extra nm flags])
NM="$NM $nmflags"
AC_MSG_RESULT([$nmflags])
fi
fi
])
dnl GMP_DEFINE(MACRO, DEFINITION [, LOCATION])
dnl ------------------------------------------
dnl Define M4 macro MACRO as DEFINITION in temporary file.
dnl
dnl If LOCATION is `POST', the definition will appear after any include()
dnl directives inserted by GMP_INCLUDE. Mind the quoting! No shell
dnl variables will get expanded. Don't forget to invoke GMP_FINISH to
dnl create file config.m4. config.m4 uses `<' and '>' as quote characters
dnl for all defines.
AC_DEFUN([GMP_DEFINE],
[AC_REQUIRE([GMP_INIT])
echo ['define(<$1>, <$2>)'] >>ifelse([$3], [POST],
$gmp_tmpconfigm4p, $gmp_tmpconfigm4)
])
dnl GMP_DEFINE_RAW(STRING [, LOCATION])
dnl ------------------------------------
dnl Put STRING into config.m4 file.
dnl
dnl If LOCATION is `POST', the definition will appear after any include()
dnl directives inserted by GMP_INCLUDE. Don't forget to invoke GMP_FINISH
dnl to create file config.m4.
AC_DEFUN([GMP_DEFINE_RAW],
[AC_REQUIRE([GMP_INIT])
echo [$1] >> ifelse([$2], [POST], $gmp_tmpconfigm4p, $gmp_tmpconfigm4)
])
dnl GMP_TRY_ASSEMBLE(asm-code,[action-success][,action-fail])
dnl ----------------------------------------------------------
dnl Attempt to assemble the given code.
dnl Do "action-success" if this succeeds, "action-fail" if not.
dnl
dnl conftest.o and conftest.out are available for inspection in
dnl "action-success". If either action does a "break" out of a loop then
dnl an explicit "rm -f conftest*" will be necessary.
dnl
dnl This is not unlike AC_TRY_COMPILE, but there's no default includes or
dnl anything in "asm-code", everything wanted must be given explicitly.
AC_DEFUN([GMP_TRY_ASSEMBLE],
[cat >conftest.s <<EOF
[$1]
EOF
gmp_assemble="$CC -c $CFLAGS $CPPFLAGS conftest.s >conftest.out 2>&1"
if AC_TRY_EVAL(gmp_assemble); then
cat conftest.out >&AS_MESSAGE_LOG_FD
ifelse([$2],,:,[$2])
else
cat conftest.out >&AS_MESSAGE_LOG_FD
echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
cat conftest.s >&AS_MESSAGE_LOG_FD
ifelse([$3],,:,[$3])
fi
rm -f conftest*
])
dnl CL_ASM_NOEXECSTACK
dnl -------------------
dnl
dnl Checks whether the stack can be marked nonexecutable by passing an option
dnl to the C-compiler when acting on .s files. Appends that option to ASMFLAGS.
dnl This macro is adapted from one found in GLIBC-2.3.5.
dnl
dnl FIXME: This test looks broken. It tests that a file with
dnl .note.GNU-stack... can be compiled/assembled with -Wa,--noexecstack. It
dnl does not determine if that command-line option has any effect on general
dnl asm code.
AC_DEFUN([CL_ASM_NOEXECSTACK],
[AC_REQUIRE([AC_PROG_CC])
AC_CACHE_CHECK([whether assembler supports --noexecstack option],
cl_cv_asm_noexecstack,
[dnl
cat > conftest.c <<EOF
void foo() {}
EOF
if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS
-S -o conftest.s conftest.c >/dev/null]) \
&& grep .note.GNU-stack conftest.s >/dev/null \
&& AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -Wa,--noexecstack
-c -o conftest.o conftest.s >/dev/null])
then
cl_cv_asm_noexecstack=yes
else
cl_cv_asm_noexecstack=no
fi
rm -f conftest*])
if test "$cl_cv_asm_noexecstack" = yes; then
ASMFLAGS="$ASMFLAGS -Wa,--noexecstack"
fi
AC_SUBST(ASMFLAGS)
])
dnl GMP_ASM_LABEL_SUFFIX
dnl --------------------
dnl : - is usual.
dnl empty - hppa on HP-UX doesn't use a :, just the label name
dnl
dnl Note that it's necessary to test the empty case first, since HP "as"
dnl will accept "somelabel:", and take it to mean a label with a name that
dnl happens to end in a colon.
AC_DEFUN([GMP_ASM_LABEL_SUFFIX],
[AC_REQUIRE([GMP_ASM_TEXT])
AC_CACHE_CHECK([for assembler label suffix],
gmp_cv_asm_label_suffix,
[gmp_cv_asm_label_suffix=unknown
for i in "" ":"; do
echo "trying $i" >&AS_MESSAGE_LOG_FD
GMP_TRY_ASSEMBLE(
[ $gmp_cv_asm_text
somelabel$i],
[gmp_cv_asm_label_suffix=$i
rm -f conftest*
break],
[cat conftest.out >&AS_MESSAGE_LOG_FD])
done
if test "$gmp_cv_asm_label_suffix" = "unknown"; then
AC_MSG_ERROR([Cannot determine label suffix])
fi
])
echo ["define(<LABEL_SUFFIX>, <$gmp_cv_asm_label_suffix>)"] >> $gmp_tmpconfigm4
])
dnl GMP_ASM_UNDERSCORE
dnl ------------------
dnl Determine whether global symbols need to be prefixed with an underscore.
dnl The output from "nm" is grepped to see what a typical symbol looks like.
dnl
dnl This test used to grep the .o file directly, but that failed with greps
dnl that don't like binary files (eg. SunOS 4).
dnl
dnl This test also used to construct an assembler file with and without an
dnl underscore and try to link that to a C file, to see which worked.
dnl Although that's what will happen in the real build we don't really want
dnl to depend on creating asm files within configure for every possible CPU
dnl (or at least we don't want to do that more than we have to).
dnl
dnl The fallback on no underscore is based on the assumption that the world
dnl is moving towards non-underscore systems. There should actually be no
dnl good reason for nm to fail though.
AC_DEFUN([GMP_ASM_UNDERSCORE],
[AC_REQUIRE([GMP_PATH_NM])
AC_CACHE_CHECK([if globals are prefixed by underscore],
gmp_cv_asm_underscore,
[gmp_cv_asm_underscore="unknown"
cat >conftest.c <<EOF
int gurkmacka;
EOF
gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD"
if AC_TRY_EVAL(gmp_compile); then
$NM conftest.$OBJEXT >conftest.out
if grep "[[ ]]_gurkmacka" conftest.out >/dev/null; then
gmp_cv_asm_underscore=yes
elif grep "[[ ]]gurkmacka" conftest.out >/dev/null; then
gmp_cv_asm_underscore=no
else
echo "configure: $NM doesn't have gurkmacka:" >&AS_MESSAGE_LOG_FD
cat conftest.out >&AS_MESSAGE_LOG_FD
fi
else
echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
cat conftest.c >&AS_MESSAGE_LOG_FD
fi
rm -f conftest*
])
case $gmp_cv_asm_underscore in
yes)
GMP_DEFINE(GSYM_PREFIX, [_]) ;;
no)
GMP_DEFINE(GSYM_PREFIX, []) ;;
*)
AC_MSG_WARN([+----------------------------------------------------------])
AC_MSG_WARN([| Cannot determine global symbol prefix.])
AC_MSG_WARN([| $NM output doesn't contain a global data symbol.])
AC_MSG_WARN([| Will proceed with no underscore.])
AC_MSG_WARN([| If this is wrong then you'll get link errors referring])
AC_MSG_WARN([| to ___gmpn_add_n (note three underscores).])
AC_MSG_WARN([| In this case do a fresh build with an override,])
AC_MSG_WARN([| ./configure gmp_cv_asm_underscore=yes])
AC_MSG_WARN([+----------------------------------------------------------])
GMP_DEFINE(GSYM_PREFIX, [])
;;
esac
])
dnl GMP_ASM_ALIGN_LOG
dnl -----------------
dnl Is parameter to `.align' logarithmic?
AC_DEFUN([GMP_ASM_ALIGN_LOG],
[AC_REQUIRE([GMP_ASM_GLOBL])
AC_REQUIRE([GMP_ASM_BYTE])
AC_REQUIRE([GMP_ASM_DATA])
AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])
AC_REQUIRE([GMP_PATH_NM])
AC_CACHE_CHECK([if .align assembly directive is logarithmic],
gmp_cv_asm_align_log,
[GMP_TRY_ASSEMBLE(
[ $gmp_cv_asm_data
.align 4
$gmp_cv_asm_globl foo
$gmp_cv_asm_byte 1
.align 4
foo$gmp_cv_asm_label_suffix
$gmp_cv_asm_byte 2],
[gmp_tmp_val=[`$NM conftest.$OBJEXT | grep foo | \
sed -e 's;[[][0-9][]]\(.*\);\1;' -e 's;[^1-9]*\([0-9]*\).*;\1;'`]
if test "$gmp_tmp_val" = "10" || test "$gmp_tmp_val" = "16"; then
gmp_cv_asm_align_log=yes
else
gmp_cv_asm_align_log=no
fi],
[AC_MSG_ERROR([cannot assemble alignment test])])])
GMP_DEFINE_RAW(["define(<ALIGN_LOGARITHMIC>,<$gmp_cv_asm_align_log>)"])
])
dnl GMP_ASM_ALIGN_FILL_0x90
dnl -----------------------
dnl Determine whether a ",0x90" suffix works on a .align directive.
dnl This is only meant for use on x86, 0x90 being a "nop".
dnl
dnl Old gas, eg. 1.92.3
dnl Needs ",0x90" or else the fill is 0x00, which can't be executed
dnl across.
dnl
dnl New gas, eg. 2.91
dnl Generates multi-byte nop fills even when ",0x90" is given.
dnl
dnl Solaris 2.6 as
dnl ",0x90" is not allowed, causes a fatal error.
dnl
dnl Solaris 2.8 as
dnl ",0x90" does nothing, generates a warning that it's being ignored.
dnl
dnl SCO OpenServer 5 as
dnl Second parameter is max bytes to fill, not a fill pattern.
dnl ",0x90" is an error due to being bigger than the first parameter.
dnl Multi-byte nop fills are generated in text segments.
dnl
dnl Note that both solaris "as"s only care about ",0x90" if they actually
dnl have to use it to fill something, hence the .byte in the test. It's
dnl the second .align which provokes the error or warning.
dnl
dnl The warning from solaris 2.8 is suppressed to stop anyone worrying that
dnl something might be wrong.
AC_DEFUN([GMP_ASM_ALIGN_FILL_0x90],
[AC_REQUIRE([GMP_ASM_TEXT])
AC_CACHE_CHECK([if the .align directive accepts an 0x90 fill in .text],
gmp_cv_asm_align_fill_0x90,
[GMP_TRY_ASSEMBLE(
[ $gmp_cv_asm_text
.align 4, 0x90
.byte 0
.align 4, 0x90],
[if grep "Warning: Fill parameter ignored for executable section" conftest.out >/dev/null; then
echo "Suppressing this warning by omitting 0x90" 1>&AS_MESSAGE_LOG_FD
gmp_cv_asm_align_fill_0x90=no
else
gmp_cv_asm_align_fill_0x90=yes
fi],
[gmp_cv_asm_align_fill_0x90=no])])
GMP_DEFINE_RAW(["define(<ALIGN_FILL_0x90>,<$gmp_cv_asm_align_fill_0x90>)"])
])
dnl GMP_ASM_BYTE
dnl ------------
dnl .byte - is usual.
dnl data1 - required by ia64 (on hpux at least).
dnl
dnl This macro is just to support other configure tests, not any actual asm
dnl code.
AC_DEFUN([GMP_ASM_BYTE],
[AC_REQUIRE([GMP_ASM_TEXT])
AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])
AC_CACHE_CHECK([for assembler byte directive],
gmp_cv_asm_byte,
[for i in .byte data1; do
echo "trying $i" >&AS_MESSAGE_LOG_FD
GMP_TRY_ASSEMBLE(
[ $gmp_cv_asm_data
$i 0
],
[gmp_cv_asm_byte=$i
rm -f conftest*
break],
[cat conftest.out >&AS_MESSAGE_LOG_FD])
done
if test -z "$gmp_cv_asm_byte"; then
AC_MSG_ERROR([Cannot determine how to emit a data byte])
fi
])
])
dnl GMP_ASM_TEXT
dnl ------------
dnl .text - is usual.
dnl .code - is needed by the hppa on HP-UX (but ia64 HP-UX uses .text)
dnl .csect .text[PR] - is for AIX.
AC_DEFUN([GMP_ASM_TEXT],
[AC_CACHE_CHECK([how to switch to text section],
gmp_cv_asm_text,
[for i in ".text" ".code" [".csect .text[PR]"]; do
echo "trying $i" >&AS_MESSAGE_LOG_FD
GMP_TRY_ASSEMBLE([ $i],
[gmp_cv_asm_text=$i
rm -f conftest*
break])
done
if test -z "$gmp_cv_asm_text"; then
AC_MSG_ERROR([Cannot determine text section directive])
fi
])
echo ["define(<TEXT>, <$gmp_cv_asm_text>)"] >> $gmp_tmpconfigm4
])
dnl GMP_ASM_DATA
dnl ------------
dnl Can we say `.data'?
AC_DEFUN([GMP_ASM_DATA],
[AC_CACHE_CHECK([how to switch to data section],
gmp_cv_asm_data,
[case $host in
*-*-aix*) gmp_cv_asm_data=[".csect .data[RW]"] ;;
*) gmp_cv_asm_data=".data" ;;
esac
])
echo ["define(<DATA>, <$gmp_cv_asm_data>)"] >> $gmp_tmpconfigm4
])
dnl GMP_ASM_RODATA
dnl --------------
dnl Find out how to switch to the read-only data section.
dnl
dnl The compiler output is grepped for the right directive. It's not
dnl considered wise to just probe for ".section .rodata" or whatever works,
dnl since arbitrary section names might be accepted, but not necessarily do
dnl the right thing when they get to the linker.
dnl
dnl Only a few asm files use RODATA, so this code is perhaps a bit
dnl excessive right now, but should find more uses in the future.
dnl
dnl FIXME: gcc on aix generates something like ".csect _foo.ro_c[RO],3"
dnl where foo is the object file. Might need to check for that if we use
dnl RODATA there.
AC_DEFUN([GMP_ASM_RODATA],
[AC_REQUIRE([GMP_ASM_TEXT])
AC_REQUIRE([GMP_ASM_DATA])
AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])
AC_REQUIRE([GMP_ASM_UNDERSCORE])
AC_CACHE_CHECK([how to switch to read-only data section],
gmp_cv_asm_rodata,
[
dnl Default to DATA on CPUs with split code/data caching, and TEXT
dnl elsewhere. i386 means generic x86, so use DATA on it.
case $host in
X86_64_PATTERN)
gmp_cv_asm_rodata="$gmp_cv_asm_data" ;;
*)
gmp_cv_asm_rodata="$gmp_cv_asm_text" ;;
esac
cat >conftest.c <<EOF
extern const int foo[[]]; /* Suppresses C++'s suppression of foo */
const int foo[[]] = {1,2,3};
EOF
echo "Test program:" >&AS_MESSAGE_LOG_FD
cat conftest.c >&AS_MESSAGE_LOG_FD
gmp_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c >&AS_MESSAGE_LOG_FD"
if AC_TRY_EVAL(gmp_compile); then
echo "Compiler output:" >&AS_MESSAGE_LOG_FD
cat conftest.s >&AS_MESSAGE_LOG_FD
if test $gmp_cv_asm_underscore = yes; then
tmp_gsym_prefix=_
else
tmp_gsym_prefix=
fi
# must see our label
if grep "^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix" conftest.s >/dev/null 2>&AS_MESSAGE_LOG_FD; then
# take the last directive before our label (hence skipping segments
# getting debugging info etc)
tmp_match=`sed -n ["/^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix/q
/^[. ]*data/p
/^[. ]*rdata/p
/^[. ]*text/p
/^[. ]*section/p
/^[. ]*csect/p
/^[. ]*CSECT/p"] conftest.s | sed -n '$p'`
echo "Match: $tmp_match" >&AS_MESSAGE_LOG_FD
if test -n "$tmp_match"; then
gmp_cv_asm_rodata=$tmp_match
fi
else
echo "Couldn't find label: ^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix" >&AS_MESSAGE_LOG_FD
fi
fi
rm -f conftest*
])
echo ["define(<RODATA>, <$gmp_cv_asm_rodata>)"] >> $gmp_tmpconfigm4
])
dnl GMP_ASM_GLOBL
dnl -------------
dnl The assembler directive to mark a label as a global symbol.
dnl
dnl ia64 - .global is standard, according to the Intel documentation.
dnl
dnl hppa - ".export foo,entry" is demanded by HP hppa "as". ".global" is a
dnl kind of import.
dnl
dnl other - .globl is usual.
dnl
dnl "gas" tends to accept .globl everywhere, in addition to .export or
dnl .global or whatever the system assembler demands.
AC_DEFUN([GMP_ASM_GLOBL],
[AC_REQUIRE([GMP_ASM_TEXT])
AC_CACHE_CHECK([for assembler global directive],
gmp_cv_asm_globl,
[case $host in
dnl We do not support HPPA or IA64 assembly
dnl hppa*-*-*) gmp_cv_asm_globl=.export ;;
dnl IA64_PATTERN) gmp_cv_asm_globl=.global ;;
*) gmp_cv_asm_globl=.globl ;;
esac
])
echo ["define(<GLOBL>, <$gmp_cv_asm_globl>)"] >> $gmp_tmpconfigm4
])
dnl GMP_ASM_GLOBL_ATTR
dnl ------------------
dnl Do we need something after `GLOBL symbol'?
AC_DEFUN([GMP_ASM_GLOBL_ATTR],
[AC_REQUIRE([GMP_ASM_GLOBL])
AC_CACHE_CHECK([for assembler global directive attribute],
gmp_cv_asm_globl_attr,
[case $gmp_cv_asm_globl in
.export) gmp_cv_asm_globl_attr=",entry" ;;
*) gmp_cv_asm_globl_attr="" ;;
esac
])
echo ["define(<GLOBL_ATTR>, <$gmp_cv_asm_globl_attr>)"] >> $gmp_tmpconfigm4
])
dnl GMP_ASM_TYPE
dnl ------------
dnl Can we say ".type", and how?
dnl
dnl For i386 GNU/Linux ELF systems, and very likely other ELF systems,
dnl .type and .size are important on functions in shared libraries. If
dnl .type is omitted and the mainline program references that function then
dnl the code will be copied down to the mainline at load time like a piece
dnl of data. If .size is wrong or missing (it defaults to 4 bytes or some
dnl such) then incorrect bytes will be copied and a segv is the most likely
dnl result. In any case such copying is not what's wanted, a .type
dnl directive will ensure a PLT entry is used.
dnl
dnl In GMP the assembler functions are normally only used from within the
dnl library (since most programs are not interested in the low level
dnl routines), and in those circumstances a missing .type isn't fatal,
dnl letting the problem go unnoticed. tests/mpn/t-asmtype.c aims to check
dnl for it.
AC_DEFUN([GMP_ASM_TYPE],
[AC_CACHE_CHECK([for assembler .type directive],
gmp_cv_asm_type,
[gmp_cv_asm_type=
for gmp_tmp_prefix in @ \# %; do
GMP_TRY_ASSEMBLE([ .type sym,${gmp_tmp_prefix}function],
[if grep "\.type pseudo-op used outside of \.def/\.endef ignored" conftest.out >/dev/null; then : ;
else
gmp_cv_asm_type=".type \$][1,${gmp_tmp_prefix}\$][2"
break
fi])
done
rm -f conftest*
])
echo ["define(<TYPE>, <$gmp_cv_asm_type>)"] >> $gmp_tmpconfigm4
])
dnl GMP_ASM_SIZE
dnl ------------
dnl Can we say `.size'?
AC_DEFUN([GMP_ASM_SIZE],
[AC_CACHE_CHECK([for assembler .size directive],
gmp_cv_asm_size,
[gmp_cv_asm_size=
GMP_TRY_ASSEMBLE([ .size sym,1],
[if grep "\.size pseudo-op used outside of \.def/\.endef ignored" conftest.out >/dev/null; then : ;
else
gmp_cv_asm_size=".size \$][1,\$][2"
fi])
])
echo ["define(<SIZE>, <$gmp_cv_asm_size>)"] >> $gmp_tmpconfigm4
])
dnl GMP_ASM_COFF_TYPE
dnl -----------------
dnl Determine whether the assembler supports COFF type information.
dnl
dnl Currently this is only needed for mingw (and cygwin perhaps) and so is
dnl run only on the x86s, but it ought to work anywhere.
dnl
dnl On MINGW, recent versions of the linker have an automatic import scheme
dnl for data in a DLL which is referenced by a mainline but without
dnl __declspec (__dllimport__) on the prototype. It seems functions
dnl without type information are treated as data, or something, and calls
dnl to them from the mainline will crash. gcc puts type information on the
dnl C functions it generates, we need to do the same for assembler
dnl functions.
dnl
dnl This applies only to functions without __declspec(__dllimport__),
dnl ie. without __GMP_DECLSPEC in the case of libgmp, so it also works just
dnl to ensure all assembler functions used from outside libgmp have
dnl __GMP_DECLSPEC on their prototypes. But this isn't an ideal situation,
dnl since we don't want perfectly valid calls going wrong just because
dnl there wasn't a prototype in scope.
dnl
dnl When an auto-import takes place, the following warning is given by the
dnl linker. This shouldn't be seen for any functions.
dnl
dnl Info: resolving _foo by linking to __imp__foo (auto-import)
dnl
dnl
dnl COFF type directives look like the following
dnl
dnl .def _foo
dnl .scl 2
dnl .type 32
dnl .endef
dnl
dnl _foo is the symbol with GSYM_PREFIX (_). .scl is the storage class, 2
dnl for external, 3 for static. .type is the object type, 32 for a
dnl function.
dnl
dnl On an ELF system, this is (correctly) rejected due to .def, .endef and
dnl .scl being invalid, and .type not having enough arguments.
AC_DEFUN([GMP_ASM_COFF_TYPE],
[AC_REQUIRE([GMP_ASM_TEXT])
AC_REQUIRE([GMP_ASM_GLOBL])
AC_REQUIRE([GMP_ASM_GLOBL_ATTR])
AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])
AC_REQUIRE([GMP_ASM_UNDERSCORE])
AC_CACHE_CHECK([for assembler COFF type directives],
gmp_cv_asm_x86_coff_type,
[GMP_TRY_ASSEMBLE(
[ $gmp_cv_asm_text
$gmp_cv_asm_globl ${tmp_gsym_prefix}foo$gmp_cv_asm_globl_attr
.def ${tmp_gsym_prefix}foo
.scl 2
.type 32
.endef
${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix
],
[gmp_cv_asm_x86_coff_type=yes],
[gmp_cv_asm_x86_coff_type=no])
])
echo ["define(<HAVE_COFF_TYPE>, <$gmp_cv_asm_x86_coff_type>)"] >> $gmp_tmpconfigm4
])
dnl GMP_ASM_LSYM_PREFIX
dnl -------------------
dnl What is the prefix for a local label?
dnl
dnl The prefixes tested are,
dnl
dnl L - usual for underscore systems
dnl .L - usual for non-underscore systems
dnl $ - alpha (gas and OSF system assembler)
dnl L$ - hppa (gas and HP-UX system assembler)
dnl
dnl The default is "L" if the tests fail for any reason. There's a good
dnl chance this will be adequate, since on most systems labels are local
dnl anyway unless given a ".globl", and an "L" will avoid clashes with
dnl other identifiers.
dnl
dnl For gas, ".L" is normally purely local to the assembler, it doesn't get
dnl put into the object file at all. This style is preferred, to keep the
dnl object files nice and clean.
dnl
dnl BSD format nm produces a line like
dnl
dnl 00000000 t Lgurkmacka
dnl
dnl The symbol code is normally "t" for text, but any lower case letter
dnl indicates a local definition.
dnl
dnl Code "n" is for a debugging symbol, OSF "nm -B" gives that as an upper
dnl case "N" for a local.
dnl
dnl HP-UX nm prints an error message (though seems to give a 0 exit) if
dnl there's no symbols at all in an object file, hence the use of "dummy".
AC_DEFUN([GMP_ASM_LSYM_PREFIX],
[AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])
AC_REQUIRE([GMP_ASM_TEXT])
AC_REQUIRE([GMP_PATH_NM])
AC_CACHE_CHECK([for assembler local label prefix],
gmp_cv_asm_lsym_prefix,
[gmp_tmp_pre_appears=yes
for gmp_tmp_pre in L .L $L $ L$; do
echo "Trying $gmp_tmp_pre" >&AS_MESSAGE_LOG_FD
GMP_TRY_ASSEMBLE(
[ $gmp_cv_asm_text
dummy${gmp_cv_asm_label_suffix}
${gmp_tmp_pre}gurkmacka${gmp_cv_asm_label_suffix}],
[if $NM conftest.$OBJEXT >conftest.nm 2>&AS_MESSAGE_LOG_FD; then : ; else
cat conftest.nm >&AS_MESSAGE_LOG_FD
AC_MSG_WARN(["$NM" failure])
break
fi
cat conftest.nm >&AS_MESSAGE_LOG_FD
if grep gurkmacka conftest.nm >/dev/null; then : ; else
# no mention of the symbol, this is good
echo "$gmp_tmp_pre label doesn't appear in object file at all (good)" >&AS_MESSAGE_LOG_FD
gmp_cv_asm_lsym_prefix="$gmp_tmp_pre"
gmp_tmp_pre_appears=no
break
fi
if grep [' [a-zN] .*gurkmacka'] conftest.nm >/dev/null; then
# symbol mentioned as a local, use this if nothing better
echo "$gmp_tmp_pre label is local but still in object file" >&AS_MESSAGE_LOG_FD
if test -z "$gmp_cv_asm_lsym_prefix"; then
gmp_cv_asm_lsym_prefix="$gmp_tmp_pre"
fi
else
echo "$gmp_tmp_pre label is something unknown" >&AS_MESSAGE_LOG_FD
fi
])
done
rm -f conftest*
if test -z "$gmp_cv_asm_lsym_prefix"; then
gmp_cv_asm_lsym_prefix=L
AC_MSG_WARN([cannot determine local label, using default $gmp_cv_asm_lsym_prefix])
fi
# for development purposes, note whether we got a purely temporary local label
echo "Local label appears in object files: $gmp_tmp_pre_appears" >&AS_MESSAGE_LOG_FD
])
echo ["define(<LSYM_PREFIX>, <${gmp_cv_asm_lsym_prefix}>)"] >> $gmp_tmpconfigm4
AC_DEFINE_UNQUOTED(LSYM_PREFIX, "$gmp_cv_asm_lsym_prefix",
[Assembler local label prefix])
])
|