1dnl Process this file with autoconf to produce a configure script. 2 3 4define(GMP_COPYRIGHT,[[ 5 6Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 72007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 8 9This file is part of the GNU MP Library. 10 11The GNU MP Library is free software; you can redistribute it and/or modify 12it under the terms of the GNU Lesser General Public License as published 13by the Free Software Foundation; either version 3 of the License, or (at 14your option) any later version. 15 16The GNU MP Library is distributed in the hope that it will be useful, but 17WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 18or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 19License for more details. 20 21You should have received a copy of the GNU Lesser General Public License 22along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 23]]) 24 25AC_COPYRIGHT(GMP_COPYRIGHT) 26AH_TOP(/*GMP_COPYRIGHT*/) 27 28AC_REVISION($Revision$) 29AC_PREREQ(2.59) 30AC_INIT(GNU MP, GMP_VERSION, [gmp-bugs@gmplib.org, see http://gmplib.org/manual/Reporting-Bugs.html], gmp) 31AC_CONFIG_SRCDIR(gmp-impl.h) 32m4_pattern_forbid([^[ \t]*GMP_]) 33m4_pattern_allow(GMP_LDFLAGS) 34m4_pattern_allow(GMP_LIMB_BITS) 35m4_pattern_allow(GMP_MPARAM_H_SUGGEST) 36m4_pattern_allow(GMP_NAIL_BITS) 37m4_pattern_allow(GMP_NUMB_BITS) 38 39# If --target is not used then $target_alias is empty, but if say 40# "./configure athlon-pc-freebsd3.5" is used, then all three of 41# $build_alias, $host_alias and $target_alias are set to 42# "athlon-pc-freebsd3.5". 43# 44if test -n "$target_alias" && test "$target_alias" != "$host_alias"; then 45 AC_MSG_ERROR([--target is not appropriate for GMP 46Use --build=CPU-VENDOR-OS if you need to specify your CPU and/or system 47explicitly. Use --host if cross-compiling (see "Installing GMP" in the 48manual for more on this).]) 49fi 50 51GMP_INIT(config.m4) 52 53AC_CANONICAL_HOST 54 55dnl Automake "no-dependencies" is used because include file dependencies 56dnl are not useful to us. Pretty much everything depends just on gmp.h, 57dnl gmp-impl.h and longlong.h, and yet only rarely does everything need to 58dnl be rebuilt for changes to those files. 59dnl 60dnl "no-dependencies" also helps with the way we're setup to run 61dnl AC_PROG_CXX only conditionally. If dependencies are used then recent 62dnl automake (eg 1.7.2) appends an AM_CONDITIONAL to AC_PROG_CXX, and then 63dnl gets upset if it's not actually executed. 64dnl 65dnl Note that there's a copy of these options in the top-level Makefile.am, 66dnl so update there too if changing anything. 67dnl 68AM_INIT_AUTOMAKE([1.8 gnu no-dependencies $(top_builddir)/ansi2knr]) 69AM_CONFIG_HEADER(config.h:config.in) 70AM_MAINTAINER_MODE 71 72 73AC_ARG_ENABLE(assert, 74AC_HELP_STRING([--enable-assert],[enable ASSERT checking [[default=no]]]), 75[case $enableval in 76yes|no) ;; 77*) AC_MSG_ERROR([bad value $enableval for --enable-assert, need yes or no]) ;; 78esac], 79[enable_assert=no]) 80 81if test "$enable_assert" = "yes"; then 82 AC_DEFINE(WANT_ASSERT,1, 83 [Define to 1 to enable ASSERT checking, per --enable-assert]) 84 want_assert_01=1 85else 86 want_assert_01=0 87fi 88GMP_DEFINE_RAW(["define(<WANT_ASSERT>,$want_assert_01)"]) 89 90 91AC_ARG_ENABLE(alloca, 92AC_HELP_STRING([--enable-alloca],[how to get temp memory [[default=reentrant]]]), 93[case $enableval in 94alloca|malloc-reentrant|malloc-notreentrant) ;; 95yes|no|reentrant|notreentrant) ;; 96debug) ;; 97*) 98 AC_MSG_ERROR([bad value $enableval for --enable-alloca, need one of: 99yes no reentrant notreentrant alloca malloc-reentrant malloc-notreentrant debug]) ;; 100esac], 101[enable_alloca=reentrant]) 102 103 104# IMPROVE ME: The default for C++ is disabled. The tests currently 105# performed below for a working C++ compiler are not particularly strong, 106# and in general can't be expected to get the right setup on their own. The 107# most significant problem is getting the ABI the same. Defaulting CXXFLAGS 108# to CFLAGS takes only a small step towards this. It's also probably worth 109# worrying whether the C and C++ runtimes from say gcc and a vendor C++ can 110# work together. Some rather broken C++ installations were encountered 111# during testing, and though such things clearly aren't GMP's problem, if 112# --enable-cxx=detect were to be the default then some careful checks of 113# which, if any, C++ compiler on the system is up to scratch would be 114# wanted. 115# 116AC_ARG_ENABLE(cxx, 117AC_HELP_STRING([--enable-cxx],[enable C++ support [[default=no]]]), 118[case $enableval in 119yes|no|detect) ;; 120*) AC_MSG_ERROR([bad value $enableval for --enable-cxx, need yes/no/detect]) ;; 121esac], 122[enable_cxx=no]) 123 124 125AC_ARG_ENABLE(fft, 126AC_HELP_STRING([--enable-fft],[enable FFTs for multiplication [[default=yes]]]), 127[case $enableval in 128yes|no) ;; 129*) AC_MSG_ERROR([bad value $enableval for --enable-fft, need yes or no]) ;; 130esac], 131[enable_fft=yes]) 132 133if test "$enable_fft" = "yes"; then 134 AC_DEFINE(WANT_FFT,1, 135 [Define to 1 to enable FFTs for multiplication, per --enable-fft]) 136fi 137 138 139AC_ARG_ENABLE(old-fft-full, 140AC_HELP_STRING([--enable-old-fft-full],[enable old mpn_mul_fft_full for multiplication [[default=no]]]), 141[case $enableval in 142yes|no) ;; 143*) AC_MSG_ERROR([bad value $enableval for --enable-old-fft-full, need yes or no]) ;; 144esac], 145[enable_old_fft_full=no]) 146 147if test "$enable_old_fft_full" = "yes"; then 148 AC_DEFINE(WANT_OLD_FFT_FULL,1, 149 [Define to 1 to enable old mpn_mul_fft_full for multiplication, per --enable-old-fft-full]) 150fi 151 152 153AC_ARG_ENABLE(mpbsd, 154AC_HELP_STRING([--enable-mpbsd], 155 [build Berkeley MP compatibility library [[default=no]]]), 156[case $enableval in 157yes|no) ;; 158*) AC_MSG_ERROR([bad value $enableval for --enable-mpbsd, need yes or no]) ;; 159esac], 160[enable_mpbsd=no]) 161AM_CONDITIONAL(WANT_MPBSD, test "$enable_mpbsd" = "yes") 162 163 164AC_ARG_ENABLE(nails, 165AC_HELP_STRING([--enable-nails],[use nails on limbs [[default=no]]]), 166[case $enableval in 167[yes|no|[02468]|[0-9][02468]]) ;; 168[*[13579]]) 169 AC_MSG_ERROR([bad value $enableval for --enable-nails, only even nail sizes supported]) ;; 170*) 171 AC_MSG_ERROR([bad value $enableval for --enable-nails, need yes/no/number]) ;; 172esac], 173[enable_nails=no]) 174 175case $enable_nails in 176yes) GMP_NAIL_BITS=2 ;; 177no) GMP_NAIL_BITS=0 ;; 178*) GMP_NAIL_BITS=$enable_nails ;; 179esac 180AC_SUBST(GMP_NAIL_BITS) 181 182 183AC_ARG_ENABLE(profiling, 184AC_HELP_STRING([--enable-profiling], 185 [build with profiler support [[default=no]]]), 186[case $enableval in 187no|prof|gprof|instrument) ;; 188*) AC_MSG_ERROR([bad value $enableval for --enable-profiling, need no/prof/gprof/instrument]) ;; 189esac], 190[enable_profiling=no]) 191 192case $enable_profiling in 193 prof) 194 AC_DEFINE(WANT_PROFILING_PROF, 1, 195 [Define to 1 if --enable-profiling=prof]) 196 ;; 197 gprof) 198 AC_DEFINE(WANT_PROFILING_GPROF, 1, 199 [Define to 1 if --enable-profiling=gprof]) 200 ;; 201 instrument) 202 AC_DEFINE(WANT_PROFILING_INSTRUMENT, 1, 203 [Define to 1 if --enable-profiling=instrument]) 204 ;; 205esac 206 207GMP_DEFINE_RAW(["define(<WANT_PROFILING>,<\`$enable_profiling'>)"]) 208 209# -fomit-frame-pointer is incompatible with -pg on some chips 210if test "$enable_profiling" = gprof; then 211 fomit_frame_pointer= 212else 213 fomit_frame_pointer="-fomit-frame-pointer" 214fi 215 216 217AC_ARG_WITH(readline, 218AC_HELP_STRING([--with-readline], 219 [readline support in calc demo program [[default=detect]]]), 220[case $withval in 221yes|no|detect) ;; 222*) AC_MSG_ERROR([bad value $withval for --with-readline, need yes/no/detect]) ;; 223esac], 224[with_readline=detect]) 225 226 227AC_ARG_ENABLE(fat, 228AC_HELP_STRING([--enable-fat], 229 [build a fat binary on systems that support it [[default=no]]]), 230[case $enableval in 231yes|no) ;; 232*) AC_MSG_ERROR([bad value $enableval for --enable-fat, need yes or no]) ;; 233esac], 234[enable_fat=no]) 235 236 237AC_ARG_ENABLE(minithres, 238AC_HELP_STRING([--enable-minithres], 239 [choose minimal thresholds for testing [[default=no]]]), 240[case $enableval in 241yes|no) ;; 242*) AC_MSG_ERROR([bad value $enableval for --enable-minithres, need yes or no]) ;; 243esac], 244[enable_minithres=no]) 245 246 247 248tmp_host=`echo $host_cpu | sed 's/\./_/'` 249AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_$tmp_host) 250GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_HOST_CPU_$tmp_host')", POST) 251 252dnl The HAVE_HOST_CPU_ list here only needs to have entries for those which 253dnl are going to be tested, not everything that can possibly be selected. 254dnl 255dnl The HAVE_HOST_CPU_FAMILY_ list similarly, and note that the AC_DEFINEs 256dnl for these are under the cpu specific setups below. 257 258AH_VERBATIM([HAVE_HOST_CPU_1], 259[/* Define one of these to 1 for the host CPU family. 260 If your CPU is not in any of these families, leave all undefined. 261 For an AMD64 chip, define "x86" in ABI=32, but not in ABI=64. */ 262#undef HAVE_HOST_CPU_FAMILY_alpha 263#undef HAVE_HOST_CPU_FAMILY_m68k 264#undef HAVE_HOST_CPU_FAMILY_power 265#undef HAVE_HOST_CPU_FAMILY_powerpc 266#undef HAVE_HOST_CPU_FAMILY_x86 267#undef HAVE_HOST_CPU_FAMILY_x86_64 268 269/* Define one of the following to 1 for the host CPU, as per the output of 270 ./config.guess. If your CPU is not listed here, leave all undefined. */ 271#undef HAVE_HOST_CPU_alphaev67 272#undef HAVE_HOST_CPU_alphaev68 273#undef HAVE_HOST_CPU_alphaev7 274#undef HAVE_HOST_CPU_m68020 275#undef HAVE_HOST_CPU_m68030 276#undef HAVE_HOST_CPU_m68040 277#undef HAVE_HOST_CPU_m68060 278#undef HAVE_HOST_CPU_m68360 279#undef HAVE_HOST_CPU_powerpc604 280#undef HAVE_HOST_CPU_powerpc604e 281#undef HAVE_HOST_CPU_powerpc750 282#undef HAVE_HOST_CPU_powerpc7400 283#undef HAVE_HOST_CPU_supersparc 284#undef HAVE_HOST_CPU_i386 285#undef HAVE_HOST_CPU_i586 286#undef HAVE_HOST_CPU_i686 287#undef HAVE_HOST_CPU_pentium 288#undef HAVE_HOST_CPU_pentiummmx 289#undef HAVE_HOST_CPU_pentiumpro 290#undef HAVE_HOST_CPU_pentium2 291#undef HAVE_HOST_CPU_pentium3 292#undef HAVE_HOST_CPU_s390_z900 293#undef HAVE_HOST_CPU_s390_z990 294#undef HAVE_HOST_CPU_s390_z9 295#undef HAVE_HOST_CPU_s390_z10 296#undef HAVE_HOST_CPU_s390_z196 297 298/* Define to 1 iff we have a s390 with 64-bit registers. */ 299#undef HAVE_HOST_CPU_s390_zarch]) 300 301 302# Table of compilers, options, and mpn paths. This code has various related 303# purposes 304# 305# - better default CC/CFLAGS selections than autoconf otherwise gives 306# - default CC/CFLAGS selections for extra CPU types specific to GMP 307# - a few tests for known bad compilers 308# - choice of ABIs on suitable systems 309# - selection of corresponding mpn search path 310# 311# After GMP specific searches and tests, the standard autoconf AC_PROG_CC is 312# called. User selections of CC etc are respected. 313# 314# Care is taken not to use macros like AC_TRY_COMPILE during the GMP 315# pre-testing, since they of course depend on AC_PROG_CC, and also some of 316# them cache their results, which is not wanted. 317# 318# The ABI selection mechanism is unique to GMP. All that reaches autoconf 319# is a different selection of CC/CFLAGS according to the best ABI the system 320# supports, and/or what the user selects. Naturally the mpn assembler code 321# selected is very dependent on the ABI. 322# 323# The closest the standard tools come to a notion of ABI is something like 324# "sparc64" which encodes a CPU and an ABI together. This doesn't seem to 325# scale well for GMP, where exact CPU types like "ultrasparc2" are wanted, 326# separate from the ABI used on them. 327# 328# 329# The variables set here are 330# 331# cclist the compiler choices 332# xx_cflags flags for compiler xx 333# xx_cflags_maybe flags for compiler xx, if they work 334# xx_cppflags cpp flags for compiler xx 335# xx_cflags_optlist list of sets of optional flags 336# xx_cflags_yyy set yyy of optional flags for compiler xx 337# xx_ldflags -Wc,-foo flags for libtool linking with compiler xx 338# ar_flags extra flags for $AR 339# nm_flags extra flags for $NM 340# limb limb size, can be "longlong" 341# path mpn search path 342# extra_functions extra mpn functions 343# fat_path fat binary mpn search path [if fat binary desired] 344# fat_functions fat functions 345# fat_thresholds fat thresholds 346# 347# Suppose xx_cflags_optlist="arch", then flags from $xx_cflags_arch are 348# tried, and the first flag that works will be used. An optlist like "arch 349# cpu optimize" can be used to get multiple independent sets of flags tried. 350# The first that works from each will be used. If no flag in a set works 351# then nothing from that set is added. 352# 353# For multiple ABIs, the scheme extends as follows. 354# 355# abilist set of ABI choices 356# cclist_aa compiler choices in ABI aa 357# xx_aa_cflags flags for xx in ABI aa 358# xx_aa_cflags_maybe flags for xx in ABI aa, if they work 359# xx_aa_cppflags cpp flags for xx in ABI aa 360# xx_aa_cflags_optlist list of sets of optional flags in ABI aa 361# xx_aa_cflags_yyy set yyy of optional flags for compiler xx in ABI aa 362# xx_aa_ldflags -Wc,-foo flags for libtool linking 363# ar_aa_flags extra flags for $AR in ABI aa 364# nm_aa_flags extra flags for $NM in ABI aa 365# limb_aa limb size in ABI aa, can be "longlong" 366# path_aa mpn search path in ABI aa 367# extra_functions_aa extra mpn functions in ABI aa 368# 369# As a convenience, the unadorned xx_cflags (etc) are used for the last ABI 370# in ablist, if an xx_aa_cflags for that ABI isn't given. For example if 371# abilist="64 32" then $cc_64_cflags will be used for the 64-bit ABI, but 372# for the 32-bit either $cc_32_cflags or $cc_cflags is used, whichever is 373# defined. This makes it easy to add some 64-bit compilers and flags to an 374# unadorned 32-bit set. 375# 376# limb=longlong (or limb_aa=longlong) applies to all compilers within that 377# ABI. It won't work to have some needing long long and some not, since a 378# single instantiated gmp.h will be used by both. 379# 380# SPEED_CYCLECOUNTER, cyclecounter_size and CALLING_CONVENTIONS_OBJS are 381# also set here, with an ABI suffix. 382# 383# 384# 385# A table-driven approach like this to mapping cpu type to good compiler 386# options is a bit of a maintenance burden, but there's not much uniformity 387# between options specifications on different compilers. Some sort of 388# separately updatable tool might be cute. 389# 390# The use of lots of variables like this, direct and indirect, tends to 391# obscure when and how various things are done, but unfortunately it's 392# pretty much the only way. If shell subroutines were portable then actual 393# code like "if this .. do that" could be written, but attempting the same 394# with full copies of GMP_PROG_CC_WORKS etc expanded at every point would 395# hugely bloat the output. 396 397 398AC_ARG_VAR(ABI, [desired ABI (for processors supporting more than one ABI)]) 399 400# abilist needs to be non-empty, "standard" is just a generic name here 401abilist="standard" 402 403# FIXME: We'd like to prefer an ANSI compiler, perhaps by preferring 404# c89 over cc here. But note that on HP-UX c89 provides a castrated 405# environment, and would want to be excluded somehow. Maybe 406# AC_PROG_CC_STDC already does enough to stick cc into ANSI mode and 407# we don't need to worry. 408# 409cclist="gcc cc" 410 411gcc_cflags="-O2 -pedantic" 412gcc_64_cflags="-O2 -pedantic" 413cc_cflags="-O" 414cc_64_cflags="-O" 415 416SPEED_CYCLECOUNTER_OBJ= 417cyclecounter_size=2 418 419AC_SUBST(HAVE_HOST_CPU_FAMILY_power, 0) 420AC_SUBST(HAVE_HOST_CPU_FAMILY_powerpc,0) 421 422case $host in 423 424 a29k*-*-*) 425 path="a29k" 426 ;; 427 428 429 alpha*-*-*) 430 AC_DEFINE(HAVE_HOST_CPU_FAMILY_alpha) 431 case $host_cpu in 432 alphaev5* | alphapca5*) 433 path="alpha/ev5 alpha" ;; 434 alphaev67 | alphaev68 | alphaev7*) 435 path="alpha/ev67 alpha/ev6 alpha" ;; 436 alphaev6) 437 path="alpha/ev6 alpha" ;; 438 *) 439 path="alpha" ;; 440 esac 441 extra_functions="cntlz" 442 gcc_cflags_optlist="asm cpu oldas" # need asm ahead of cpu, see below 443 gcc_cflags_oldas="-Wa,-oldas" # see GMP_GCC_WA_OLDAS. 444 445 # gcc 2.7.2.3 doesn't know any -mcpu= for alpha, apparently. 446 # gcc 2.95 knows -mcpu= ev4, ev5, ev56, pca56, ev6. 447 # gcc 3.0 adds nothing. 448 # gcc 3.1 adds ev45, ev67 (but ev45 is the same as ev4). 449 # gcc 3.2 adds nothing. 450 # 451 # gcc version "2.9-gnupro-99r1" under "-O2 -mcpu=ev6" strikes internal 452 # compiler errors too easily and is rejected by GMP_PROG_CC_WORKS. Each 453 # -mcpu=ev6 below has a fallback to -mcpu=ev56 for this reason. 454 # 455 case $host_cpu in 456 alpha) gcc_cflags_cpu="-mcpu=ev4" ;; 457 alphaev5) gcc_cflags_cpu="-mcpu=ev5" ;; 458 alphaev56) gcc_cflags_cpu="-mcpu=ev56" ;; 459 alphapca56 | alphapca57) 460 gcc_cflags_cpu="-mcpu=pca56" ;; 461 alphaev6) gcc_cflags_cpu="-mcpu=ev6 -mcpu=ev56" ;; 462 alphaev67 | alphaev68 | alphaev7*) 463 gcc_cflags_cpu="-mcpu=ev67 -mcpu=ev6 -mcpu=ev56" ;; 464 esac 465 466 # gcc version "2.9-gnupro-99r1" on alphaev68-dec-osf5.1 has been seen 467 # accepting -mcpu=ev6, but not putting the assembler in the right mode 468 # for what it produces. We need to do this for it, and need to do it 469 # before testing the -mcpu options. 470 # 471 # On old versions of gcc, which don't know -mcpu=, we believe an 472 # explicit -Wa,-mev5 etc will be necessary to put the assembler in 473 # the right mode for our .asm files and longlong.h asm blocks. 474 # 475 # On newer versions of gcc, when -mcpu= is known, we must give a -Wa 476 # which is at least as high as the code gcc will generate. gcc 477 # establishes what it needs with a ".arch" directive, our command line 478 # option seems to override that. 479 # 480 # gas prior to 2.14 doesn't accept -mev67, but -mev6 seems enough for 481 # ctlz and cttz (in 2.10.0 at least). 482 # 483 # OSF `as' accepts ev68 but stupidly treats it as ev4. -arch only seems 484 # to affect insns like ldbu which are expanded as macros when necessary. 485 # Insns like ctlz which were never available as macros are always 486 # accepted and always generate their plain code. 487 # 488 case $host_cpu in 489 alpha) gcc_cflags_asm="-Wa,-arch,ev4 -Wa,-mev4" ;; 490 alphaev5) gcc_cflags_asm="-Wa,-arch,ev5 -Wa,-mev5" ;; 491 alphaev56) gcc_cflags_asm="-Wa,-arch,ev56 -Wa,-mev56" ;; 492 alphapca56 | alphapca57) 493 gcc_cflags_asm="-Wa,-arch,pca56 -Wa,-mpca56" ;; 494 alphaev6) gcc_cflags_asm="-Wa,-arch,ev6 -Wa,-mev6" ;; 495 alphaev67 | alphaev68 | alphaev7*) 496 gcc_cflags_asm="-Wa,-arch,ev67 -Wa,-mev67 -Wa,-arch,ev6 -Wa,-mev6" ;; 497 esac 498 499 # It might be better to ask "cc" whether it's Cray C or DEC C, 500 # instead of relying on the OS part of $host. But it's hard to 501 # imagine either of those compilers anywhere except their native 502 # systems. 503 # 504 GMP_INCLUDE_MPN(alpha/alpha-defs.m4) 505 case $host in 506 *-cray-unicos*) 507 cc_cflags="-O" # no -g, it silently disables all optimizations 508 GMP_INCLUDE_MPN(alpha/unicos.m4) 509 # Don't perform any assembly syntax tests on this beast. 510 gmp_asm_syntax_testing=no 511 ;; 512 *-*-osf*) 513 GMP_INCLUDE_MPN(alpha/default.m4) 514 cc_cflags="" 515 cc_cflags_optlist="opt cpu" 516 517 # not sure if -fast works on old versions, so make it optional 518 cc_cflags_opt="-fast -O2" 519 520 # DEC C V5.9-005 knows ev4, ev5, ev56, pca56, ev6. 521 # Compaq C V6.3-029 adds ev67. 522 # 523 case $host_cpu in 524 alpha) cc_cflags_cpu="-arch~ev4~-tune~ev4" ;; 525 alphaev5) cc_cflags_cpu="-arch~ev5~-tune~ev5" ;; 526 alphaev56) cc_cflags_cpu="-arch~ev56~-tune~ev56" ;; 527 alphapca56 | alphapca57) 528 cc_cflags_cpu="-arch~pca56~-tune~pca56" ;; 529 alphaev6) cc_cflags_cpu="-arch~ev6~-tune~ev6" ;; 530 alphaev67 | alphaev68 | alphaev7*) 531 cc_cflags_cpu="-arch~ev67~-tune~ev67 -arch~ev6~-tune~ev6" ;; 532 esac 533 ;; 534 *) 535 GMP_INCLUDE_MPN(alpha/default.m4) 536 ;; 537 esac 538 539 case $host in 540 *-*-unicos*) 541 # tune/alpha.asm assumes int==4bytes but unicos uses int==8bytes 542 ;; 543 *) 544 SPEED_CYCLECOUNTER_OBJ=alpha.lo 545 cyclecounter_size=1 ;; 546 esac 547 ;; 548 549 550 # Cray vector machines. 551 # This must come after alpha* so that we can recognize present and future 552 # vector processors with a wildcard. 553 *-cray-unicos*) 554 gmp_asm_syntax_testing=no 555 cclist="cc" 556 # We used to have -hscalar0 here as a workaround for miscompilation of 557 # mpz/import.c, but let's hope Cray fixes their bugs instead, since 558 # -hscalar0 causes disastrously poor code to be generated. 559 cc_cflags="-O3 -hnofastmd -htask0 -Wa,-B" 560 path="cray" 561 ;; 562 563 564 arm*-*-*) 565 path="arm" 566 gcc_cflags="$gcc_cflags $fomit_frame_pointer" 567 gcc_testlist="gcc-arm-umodsi" 568 GMP_INCLUDE_MPN(arm/arm-defs.m4) 569 ;; 570 571 572 clipper*-*-*) 573 path="clipper" 574 ;; 575 576 577 # Fujitsu 578 [f30[01]-fujitsu-sysv*]) 579 cclist="gcc vcc" 580 # FIXME: flags for vcc? 581 vcc_cflags="-g" 582 path="fujitsu" 583 ;; 584 585 586 hppa*-*-*) 587 # HP cc (the one sold separately) is K&R by default, but AM_C_PROTOTYPES 588 # will add "-Ae", or "-Aa -D_HPUX_SOURCE", to put it into ansi mode, if 589 # possible. 590 # 591 # gcc for hppa 2.0 can be built either for 2.0n (32-bit) or 2.0w 592 # (64-bit), but not both, so there's no option to choose the desired 593 # mode, we must instead detect which of the two it is. This is done by 594 # checking sizeof(long), either 4 or 8 bytes respectively. Do this in 595 # ABI=1.0 too, in case someone tries to build that with a 2.0w gcc. 596 # 597 gcc_cflags_optlist="arch" 598 gcc_testlist="sizeof-long-4" 599 SPEED_CYCLECOUNTER_OBJ=hppa.lo 600 cyclecounter_size=1 601 602 # FIXME: For hppa2.0*, path should be "pa32/hppa2_0 pa32/hppa1_1 pa32". 603 # (Can't remember why this isn't done already, have to check what .asm 604 # files are available in each and how they run on a typical 2.0 cpu.) 605 # 606 case $host_cpu in 607 hppa1.0*) path="pa32" ;; 608 hppa7000*) path="pa32/hppa1_1 pa32" ;; 609 hppa2.0* | hppa64) 610 path="pa32/hppa2_0 pa32/hppa1_1/pa7100 pa32/hppa1_1 pa32" ;; 611 *) # default to 7100 612 path="pa32/hppa1_1/pa7100 pa32/hppa1_1 pa32" ;; 613 esac 614 615 # gcc 2.7.2.3 knows -mpa-risc-1-0 and -mpa-risc-1-1 616 # gcc 2.95 adds -mpa-risc-2-0, plus synonyms -march=1.0, 1.1 and 2.0 617 # 618 # We don't use -mpa-risc-2-0 in ABI=1.0 because 64-bit registers may not 619 # be saved by the kernel on an old system. Actually gcc (as of 3.2) 620 # only adds a few float instructions with -mpa-risc-2-0, so it would 621 # probably be safe, but let's not take the chance. In any case, a 622 # configuration like --host=hppa2.0 ABI=1.0 is far from optimal. 623 # 624 case $host_cpu in 625 hppa1.0*) gcc_cflags_arch="-mpa-risc-1-0" ;; 626 *) # default to 7100 627 gcc_cflags_arch="-mpa-risc-1-1" ;; 628 esac 629 630 case $host_cpu in 631 hppa1.0*) cc_cflags="+O2" ;; 632 *) # default to 7100 633 cc_cflags="+DA1.1 +O2" ;; 634 esac 635 636 case $host in 637 hppa2.0*-*-* | hppa64-*-*) 638 cclist_20n="gcc cc" 639 abilist="2.0n 1.0" 640 path_20n="pa64" 641 limb_20n=longlong 642 any_20n_testlist="sizeof-long-4" 643 SPEED_CYCLECOUNTER_OBJ_20n=hppa2.lo 644 cyclecounter_size_20n=2 645 646 # -mpa-risc-2-0 is only an optional flag, in case an old gcc is 647 # used. Assembler support for 2.0 is essential though, for our asm 648 # files. 649 gcc_20n_cflags="-O2" 650 gcc_20n_cflags_optlist="arch" 651 gcc_20n_cflags_arch="-mpa-risc-2-0 -mpa-risc-1-1" 652 gcc_20n_testlist="sizeof-long-4 hppa-level-2.0" 653 654 cc_20n_cflags="+DA2.0 +e +O2 -Wl,+vnocompatwarnings" 655 cc_20n_testlist="hpc-hppa-2-0" 656 657 # ABI=2.0w is available for hppa2.0w and hppa2.0, but not for 658 # hppa2.0n, on the assumption that that the latter indicates a 659 # desire for ABI=2.0n. 660 case $host in 661 hppa2.0n-*-*) ;; 662 *) 663 # HPUX 10 and earlier cannot run 2.0w. Not sure about other 664 # systems (GNU/Linux for instance), but lets assume they're ok. 665 case $host in 666 [*-*-hpux[1-9] | *-*-hpux[1-9].* | *-*-hpux10 | *-*-hpux10.*]) ;; 667 [*-*-linux*]) abilist="1.0" ;; # due to linux permanent kernel bug 668 *) abilist="2.0w $abilist" ;; 669 esac 670 671 cclist_20w="gcc cc" 672 gcc_20w_cflags="-O2 -mpa-risc-2-0" 673 cc_20w_cflags="+DD64 +O2" 674 cc_20w_testlist="hpc-hppa-2-0" 675 path_20w="pa64" 676 any_20w_testlist="sizeof-long-8" 677 SPEED_CYCLECOUNTER_OBJ_20w=hppa2w.lo 678 cyclecounter_size_20w=2 679 ;; 680 esac 681 ;; 682 esac 683 ;; 684 685 686 i960*-*-*) 687 path="i960" 688 ;; 689 690 691 IA64_PATTERN) 692 abilist="64" 693 GMP_INCLUDE_MPN(ia64/ia64-defs.m4) 694 SPEED_CYCLECOUNTER_OBJ=ia64.lo 695 696 case $host_cpu in 697 itanium) path="ia64/itanium ia64" ;; 698 itanium2) path="ia64/itanium2 ia64" ;; 699 *) path="ia64" ;; 700 esac 701 702 gcc_64_cflags_optlist="tune" 703 gcc_32_cflags_optlist=$gcc_64_cflags_optlist 704 705 # gcc pre-release 3.4 adds -mtune itanium and itanium2 706 case $host_cpu in 707 itanium) gcc_cflags_tune="-mtune=itanium" ;; 708 itanium2) gcc_cflags_tune="-mtune=itanium2" ;; 709 esac 710 711 case $host in 712 *-*-linux*) 713 cclist="gcc icc" 714 icc_cflags="-no-gcc" 715 icc_cflags_optlist="opt" 716 # Don't use -O3, it is for "large data sets" and also miscompiles GMP. 717 # But icc miscompiles GMP at any optimization level, at higher levels 718 # it miscompiles more files... 719 icc_cflags_opt="-O2 -O1" 720 ;; 721 722 *-*-hpux*) 723 # HP cc sometimes gets internal errors if the optimization level is 724 # too high. GMP_PROG_CC_WORKS detects this, the "_opt" fallbacks 725 # let us use whatever seems to work. 726 # 727 abilist="32 64" 728 729 cclist_32="gcc cc" 730 path_32="ia64" 731 cc_32_cflags="" 732 cc_32_cflags_optlist="opt" 733 cc_32_cflags_opt="+O3 +O2 +O1" 734 gcc_32_cflags="-milp32 -O2" 735 limb_32=longlong 736 SPEED_CYCLECOUNTER_OBJ_32=ia64.lo 737 cyclecounter_size_32=2 738 739 # Must have +DD64 in CPPFLAGS to get the right __LP64__ for headers, 740 # but also need it in CFLAGS for linking programs, since automake 741 # only uses CFLAGS when linking, not CPPFLAGS. 742 # FIXME: Maybe should use cc_64_ldflags for this, but that would 743 # need GMP_LDFLAGS used consistently by all the programs. 744 # 745 cc_64_cflags="+DD64" 746 cc_64_cppflags="+DD64" 747 cc_64_cflags_optlist="opt" 748 cc_64_cflags_opt="+O3 +O2 +O1" 749 gcc_64_cflags="$gcc_64_cflags -mlp64" 750 ;; 751 esac 752 ;; 753 754 755 # Motorola 68k 756 # 757 M68K_PATTERN) 758 AC_DEFINE(HAVE_HOST_CPU_FAMILY_m68k) 759 GMP_INCLUDE_MPN(m68k/m68k-defs.m4) 760 gcc_cflags="$gcc_cflags $fomit_frame_pointer" 761 gcc_cflags_optlist="arch" 762 763 # gcc 2.7.2 knows -m68000, -m68020, -m68030, -m68040. 764 # gcc 2.95 adds -mcpu32, -m68060. 765 # FIXME: Maybe "-m68020 -mnobitfield" would suit cpu32 on 2.7.2. 766 # 767 case $host_cpu in 768 m68020) gcc_cflags_arch="-m68020" ;; 769 m68030) gcc_cflags_arch="-m68030" ;; 770 m68040) gcc_cflags_arch="-m68040" ;; 771 m68060) gcc_cflags_arch="-m68060 -m68000" ;; 772 m68360) gcc_cflags_arch="-mcpu32 -m68000" ;; 773 *) gcc_cflags_arch="-m68000" ;; 774 esac 775 776 # FIXME: m68k/mc68020 looks like it's ok for cpu32, but this wants to be 777 # tested. Will need to introduce an m68k/cpu32 if m68k/mc68020 ever uses 778 # the bitfield instructions. 779 case $host_cpu in 780 [m680[234]0 | m68360]) path="m68k/mc68020 m68k" ;; 781 *) path="m68k" ;; 782 esac 783 ;; 784 785 786 # Motorola 88k 787 m88k*-*-*) 788 path="m88k" 789 ;; 790 m88110*-*-*) 791 gcc_cflags="$gcc_cflags -m88110" 792 path="m88k/mc88110 m88k" 793 ;; 794 795 796 # National Semiconductor 32k 797 ns32k*-*-*) 798 path="ns32k" 799 ;; 800 801 802 # IRIX 5 and earlier can only run 32-bit o32. 803 # 804 # IRIX 6 and up always has a 64-bit mips CPU can run n32 or 64. n32 is 805 # preferred over 64, but only because that's been the default in past 806 # versions of GMP. The two are equally efficient. 807 # 808 # Linux kernel 2.2.13 arch/mips/kernel/irixelf.c has a comment about not 809 # supporting n32 or 64. 810 # 811 # For reference, libtool (eg. 1.5.6) recognises the n32 ABI and knows the 812 # right options to use when linking (both cc and gcc), so no need for 813 # anything special from us. 814 # 815 mips*-*-*) 816 abilist="o32" 817 gcc_cflags_optlist="abi" 818 gcc_cflags_abi="-mabi=32" 819 gcc_testlist="gcc-mips-o32" 820 path="mips32" 821 cc_cflags="-O2 -o32" # no -g, it disables all optimizations 822 # this suits both mips32 and mips64 823 GMP_INCLUDE_MPN(mips32/mips-defs.m4) 824 825 case $host in 826 [mips64*-*-* | mips*-*-irix[6789]*]) 827 abilist="n32 64 o32" 828 829 cclist_n32="gcc cc" 830 gcc_n32_cflags="-O2 -mabi=n32" 831 cc_n32_cflags="-O2 -n32" # no -g, it disables all optimizations 832 limb_n32=longlong 833 path_n32="mips64" 834 835 cclist_64="gcc cc" 836 gcc_64_cflags="$gcc_64_cflags -mabi=64" 837 gcc_64_ldflags="-Wc,-mabi=64" 838 cc_64_cflags="-O2 -64" # no -g, it disables all optimizations 839 cc_64_ldflags="-Wc,-64" 840 path_64="mips64" 841 ;; 842 esac 843 ;; 844 845 846 # Darwin (powerpc-apple-darwin1.3) has it's hacked gcc installed as cc. 847 # Our usual "gcc in disguise" detection means gcc_cflags etc here gets 848 # used. 849 # 850 # The darwin pre-compiling preprocessor is disabled with -no-cpp-precomp 851 # since it doesn't like "__attribute__ ((mode (SI)))" etc in gmp-impl.h, 852 # and so always ends up running the plain preprocessor anyway. This could 853 # be done in CPPFLAGS rather than CFLAGS, but there's not many places 854 # preprocessing is done separately, and this is only a speedup, the normal 855 # preprocessor gets run if there's any problems. 856 # 857 # We used to use -Wa,-mppc with gcc, but can't remember exactly why. 858 # Presumably it was for old versions of gcc where -mpowerpc doesn't put 859 # the assembler in the right mode. In any case -Wa,-mppc is not good, for 860 # instance -mcpu=604 makes recent gcc use -m604 to get access to the 861 # "fsel" instruction, but a -Wa,-mppc overrides that, making code that 862 # comes out with fsel fail. 863 # 864 # (Note also that the darwin assembler doesn't accept "-mppc", so any 865 # -Wa,-mppc was used only if it worked. The right flag on darwin would be 866 # "-arch ppc" or some such, but that's already the default.) 867 # 868 [powerpc*-*-* | power[3-9]-*-*]) 869 AC_DEFINE(HAVE_HOST_CPU_FAMILY_powerpc) 870 HAVE_HOST_CPU_FAMILY_powerpc=1 871 abilist="32" 872 cclist="gcc cc" 873 cc_cflags="-O2" 874 gcc_32_cflags="$gcc_cflags -mpowerpc" 875 gcc_cflags_optlist="precomp subtype asm cpu" 876 gcc_cflags_precomp="-no-cpp-precomp" 877 gcc_cflags_subtype="-force_cpusubtype_ALL" # for vmx on darwin 878 gcc_cflags_asm="" 879 gcc_cflags_cpu="" 880 vmx_path="" 881 882 # grab this object, though it's not a true cycle counter routine 883 SPEED_CYCLECOUNTER_OBJ=powerpc.lo 884 cyclecounter_size=0 885 886 case $host_cpu in 887 powerpc740 | powerpc750) 888 path="powerpc32/750 powerpc32" ;; 889 powerpc7400 | powerpc7410) 890 path="powerpc32/vmx powerpc32/750 powerpc32" ;; 891 [powerpc74[45]?]) 892 path="powerpc32/vmx powerpc32" ;; 893 *) 894 path="powerpc32" ;; 895 esac 896 897 case $host_cpu in 898 powerpc401) gcc_cflags_cpu="-mcpu=401" ;; 899 powerpc403) gcc_cflags_cpu="-mcpu=403" 900 xlc_cflags_arch="-qarch=403 -qarch=ppc" ;; 901 powerpc405) gcc_cflags_cpu="-mcpu=405" ;; 902 powerpc505) gcc_cflags_cpu="-mcpu=505" ;; 903 powerpc601) gcc_cflags_cpu="-mcpu=601" 904 xlc_cflags_arch="-qarch=601 -qarch=ppc" ;; 905 powerpc602) gcc_cflags_cpu="-mcpu=602" 906 xlc_cflags_arch="-qarch=602 -qarch=ppc" ;; 907 powerpc603) gcc_cflags_cpu="-mcpu=603" 908 xlc_cflags_arch="-qarch=603 -qarch=ppc" ;; 909 powerpc603e) gcc_cflags_cpu="-mcpu=603e -mcpu=603" 910 xlc_cflags_arch="-qarch=603 -qarch=ppc" ;; 911 powerpc604) gcc_cflags_cpu="-mcpu=604" 912 xlc_cflags_arch="-qarch=604 -qarch=ppc" ;; 913 powerpc604e) gcc_cflags_cpu="-mcpu=604e -mcpu=604" 914 xlc_cflags_arch="-qarch=604 -qarch=ppc" ;; 915 powerpc620) gcc_cflags_cpu="-mcpu=620" ;; 916 powerpc630) gcc_cflags_cpu="-mcpu=630" 917 xlc_cflags_arch="-qarch=pwr3" 918 cpu_path="p3 p3-p7" ;; 919 powerpc740) gcc_cflags_cpu="-mcpu=740" ;; 920 powerpc7400 | powerpc7410) 921 gcc_cflags_asm="-Wa,-maltivec" 922 gcc_cflags_cpu="-mcpu=7400 -mcpu=750" ;; 923 [powerpc74[45]?]) 924 gcc_cflags_asm="-Wa,-maltivec" 925 gcc_cflags_cpu="-mcpu=7450" ;; 926 powerpc750) gcc_cflags_cpu="-mcpu=750" ;; 927 powerpc801) gcc_cflags_cpu="-mcpu=801" ;; 928 powerpc821) gcc_cflags_cpu="-mcpu=821" ;; 929 powerpc823) gcc_cflags_cpu="-mcpu=823" ;; 930 powerpc860) gcc_cflags_cpu="-mcpu=860" ;; 931 powerpc970) gcc_cflags_cpu="-mtune=970" 932 xlc_cflags_arch="-qarch=970 -qarch=pwr3" 933 vmx_path="powerpc64/vmx" 934 cpu_path="p4 p3-p7" ;; 935 power4) gcc_cflags_cpu="-mtune=power4" 936 xlc_cflags_arch="-qarch=pwr4" 937 cpu_path="p4 p3-p7" ;; 938 power5) gcc_cflags_cpu="-mtune=power5 -mtune=power4" 939 xlc_cflags_arch="-qarch=pwr5" 940 cpu_path="p5 p4 p3-p7" ;; 941 power6) gcc_cflags_cpu="-mtune=power6" 942 xlc_cflags_arch="-qarch=pwr6" 943 cpu_path="p6 p3-p7" ;; 944 power7) gcc_cflags_cpu="-mtune=power7 -mtune=power5" 945 xlc_cflags_arch="-qarch=pwr7 -qarch=pwr5" 946 cpu_path="p7 p5 p4 p3-p7" ;; 947 esac 948 949 case $host in 950 *-*-aix*) 951 cclist="gcc xlc cc" 952 gcc_32_cflags_maybe="-maix32" 953 xlc_cflags="-O2 -qmaxmem=20000" 954 xlc_cflags_optlist="arch" 955 xlc_32_cflags_maybe="-q32" 956 ar_32_flags="-X32" 957 nm_32_flags="-X32" 958 esac 959 960 case $host in 961 POWERPC64_PATTERN) 962 case $host in 963 *-*-aix*) 964 # On AIX a true 64-bit ABI is available. 965 # Need -Wc to pass object type flags through to the linker. 966 abilist="aix64 $abilist" 967 cclist_aix64="gcc xlc" 968 gcc_aix64_cflags="-O2 -maix64 -mpowerpc64" 969 gcc_aix64_cflags_optlist="cpu" 970 gcc_aix64_ldflags="-Wc,-maix64" 971 xlc_aix64_cflags="-O2 -q64 -qmaxmem=20000" 972 xlc_aix64_cflags_optlist="arch" 973 xlc_aix64_ldflags="-Wc,-q64" 974 # Must indicate object type to ar and nm 975 ar_aix64_flags="-X64" 976 nm_aix64_flags="-X64" 977 path_aix64="" 978 for i in $cpu_path; do path_aix64="${path_aix64}powerpc64/mode64/$i "; done 979 path_aix64="${path_aix64}powerpc64/mode64 $vmx_path powerpc64" 980 # grab this object, though it's not a true cycle counter routine 981 SPEED_CYCLECOUNTER_OBJ_aix64=powerpc64.lo 982 cyclecounter_size_aix64=0 983 ;; 984 *-*-darwin*) 985 # On Darwin we can use 64-bit instructions with a longlong limb, 986 # but the chip still in 32-bit mode. 987 # In theory this can be used on any OS which knows how to save 988 # 64-bit registers in a context switch. 989 # 990 # Note that we must use -mpowerpc64 with gcc, since the 991 # longlong.h macros expect limb operands in a single 64-bit 992 # register, not two 32-bit registers as would be given for a 993 # long long without -mpowerpc64. In theory we could detect and 994 # accommodate both styles, but the proper 64-bit registers will 995 # be fastest and are what we really want to use. 996 # 997 # One would think -mpowerpc64 would set the assembler in the right 998 # mode to handle 64-bit instructions. But for that, also 999 # -force_cpusubtype_ALL is needed. 1000 # 1001 # Do not use -fast for Darwin, it actually adds options 1002 # incompatible with a shared library. 1003 # 1004 abilist="mode64 mode32 $abilist" 1005 gcc_32_cflags_maybe="-m32" 1006 gcc_cflags_opt="-O3 -O2 -O1" # will this become used? 1007 cclist_mode32="gcc" 1008 gcc_mode32_cflags_maybe="-m32" 1009 gcc_mode32_cflags="-mpowerpc64" 1010 gcc_mode32_cflags_optlist="subtype cpu opt" 1011 gcc_mode32_cflags_subtype="-force_cpusubtype_ALL" 1012 gcc_mode32_cflags_opt="-O3 -O2 -O1" 1013 path_mode32="powerpc64/mode32 $vmx_path powerpc64" 1014 limb_mode32=longlong 1015 cclist_mode64="gcc" 1016 gcc_mode64_cflags="-m64" 1017 gcc_mode64_cflags_optlist="cpu opt" 1018 gcc_mode64_cflags_opt="-O3 -O2 -O1" 1019 path_mode64="" 1020 for i in $cpu_path; do path_mode64="${path_mode64}powerpc64/mode64/$i "; done 1021 path_mode64="${path_mode64}powerpc64/mode64 $vmx_path powerpc64" 1022 SPEED_CYCLECOUNTER_OBJ_mode64=powerpc64.lo 1023 cyclecounter_size_mode64=0 1024 any_mode64_testlist="sizeof-long-8" 1025 ;; 1026 *-*-linux* | *-*-*bsd*) 1027 # On GNU/Linux, assume the processor is in 64-bit mode. Some 1028 # environments have a gcc that is always in 64-bit mode, while 1029 # others require -m64, hence the use of cflags_maybe. The 1030 # sizeof-long-8 test checks the mode is right (for the no option 1031 # case). 1032 # 1033 # -mpowerpc64 is not used, since it should be the default in 1034 # 64-bit mode. (We need its effect for the various longlong.h 1035 # asm macros to be right of course.) 1036 # 1037 # gcc64 was an early port of gcc to 64-bit mode, but should be 1038 # obsolete before too long. We prefer plain gcc when it knows 1039 # 64-bits. 1040 # 1041 abilist="mode64 mode32 $abilist" 1042 gcc_32_cflags_maybe="-m32" 1043 cclist_mode32="gcc" 1044 gcc_mode32_cflags_maybe="-m32" 1045 gcc_mode32_cflags="-mpowerpc64" 1046 gcc_mode32_cflags_optlist="cpu opt" 1047 gcc_mode32_cflags_opt="-O3 -O2 -O1" 1048 path_mode32="powerpc64/mode32 $vmx_path powerpc64" 1049 limb_mode32=longlong 1050 cclist_mode64="gcc gcc64" 1051 gcc_mode64_cflags_maybe="-m64" 1052 gcc_mode64_cflags_optlist="cpu opt" 1053 gcc_mode64_cflags_opt="-O3 -O2 -O1" 1054 path_mode64="" 1055 for i in $cpu_path; do path_mode64="${path_mode64}powerpc64/mode64/$i "; done 1056 path_mode64="${path_mode64}powerpc64/mode64 $vmx_path powerpc64" 1057 SPEED_CYCLECOUNTER_OBJ_mode64=powerpc64.lo 1058 cyclecounter_size_mode64=0 1059 any_mode64_testlist="sizeof-long-8" 1060 ;; 1061 esac 1062 ;; 1063 esac 1064 ;; 1065 1066 1067 # POWER 32-bit 1068 [power-*-* | power[12]-*-* | power2sc-*-*]) 1069 AC_DEFINE(HAVE_HOST_CPU_FAMILY_power) 1070 HAVE_HOST_CPU_FAMILY_power=1 1071 cclist="gcc" 1072 extra_functions="udiv_w_sdiv" 1073 path="power" 1074 1075 # gcc 2.7.2 knows rios1, rios2, rsc 1076 # 1077 # -mcpu=rios2 can tickle an AIX assembler bug (see GMP_PROG_CC_WORKS) so 1078 # there needs to be a fallback to just -mpower. 1079 # 1080 gcc_cflags_optlist="cpu" 1081 case $host in 1082 power-*-*) gcc_cflags_cpu="-mcpu=power -mpower" ;; 1083 power1-*-*) gcc_cflags_cpu="-mcpu=rios1 -mpower" ;; 1084 power2-*-*) gcc_cflags_cpu="-mcpu=rios2 -mpower" ;; 1085 power2sc-*-*) gcc_cflags_cpu="-mcpu=rsc -mpower" ;; 1086 esac 1087 case $host in 1088 *-*-aix*) 1089 cclist="gcc xlc" 1090 xlc_cflags="-O2 -qarch=pwr -qmaxmem=20000" 1091 ;; 1092 esac 1093 ;; 1094 1095 1096 pyramid-*-*) 1097 path="pyr" 1098 ;; 1099 1100 1101 # IBM System/390 and z/Architecture 1102 S390_PATTERN | S390X_PATTERN) 1103 abilist="32" 1104 gcc_cflags="$gcc_cflags $fomit_frame_pointer" 1105 gcc_cflags_optlist="arch" 1106 path="s390_32" 1107 extra_functions="udiv_w_sdiv" 1108 gcc_32_cflags_maybe="-m31" 1109 1110 case $host_cpu in 1111 s390) 1112 ;; 1113 z900 | z900esa) 1114 cpu="z900" 1115 gccarch="$cpu" 1116 path="s390_32/esame/$cpu s390_32/esame s390_32" 1117 gcc_cflags_arch="-march=$gccarch" 1118 AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu) 1119 AC_DEFINE(HAVE_HOST_CPU_s390_zarch) 1120 extra_functions="" 1121 ;; 1122 z990 | z990esa) 1123 cpu="z990" 1124 gccarch="$cpu" 1125 path="s390_32/esame/$cpu s390_32/esame s390_32" 1126 gcc_cflags_arch="-march=$gccarch" 1127 AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu) 1128 AC_DEFINE(HAVE_HOST_CPU_s390_zarch) 1129 extra_functions="" 1130 ;; 1131 z9 | z9esa) 1132 cpu="z9" 1133 gccarch="z9-109" 1134 path="s390_32/esame/$cpu s390_32/esame s390_32" 1135 gcc_cflags_arch="-march=$gccarch" 1136 AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu) 1137 AC_DEFINE(HAVE_HOST_CPU_s390_zarch) 1138 extra_functions="" 1139 ;; 1140 z10 | z10esa) 1141 cpu="z10" 1142 gccarch="z10" 1143 path="s390_32/esame/$cpu s390_32/esame s390_32" 1144 gcc_cflags_arch="-march=$gccarch" 1145 AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu) 1146 AC_DEFINE(HAVE_HOST_CPU_s390_zarch) 1147 extra_functions="" 1148 ;; 1149 z196 | z196esa) 1150 cpu="z196" 1151 gccarch="z196" 1152 path="s390_32/esame/$cpu s390_32/esame s390_32" 1153 gcc_cflags_arch="-march=$gccarch" 1154 AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu) 1155 AC_DEFINE(HAVE_HOST_CPU_s390_zarch) 1156 extra_functions="" 1157 ;; 1158 esac 1159 1160 case $host in 1161 S390X_PATTERN) 1162 abilist="64 32" 1163 cclist_64="gcc" 1164 gcc_64_cflags_optlist="arch" 1165 gcc_64_cflags="$gcc_cflags -m64" 1166 path_64="s390_64/$host_cpu s390_64" 1167 extra_functions="" 1168 ;; 1169 esac 1170 ;; 1171 1172 1173 sh-*-*) path="sh" ;; 1174 [sh[2-4]-*-*]) path="sh/sh2 sh" ;; 1175 1176 1177 *sparc*-*-*) 1178 # sizeof(long)==4 or 8 is tested, to ensure we get the right ABI. We've 1179 # had various bug reports where users have set CFLAGS for their desired 1180 # mode, but not set our ABI. For some reason it's sparc where this 1181 # keeps coming up, presumably users there are accustomed to driving the 1182 # compiler mode that way. The effect of our testlist setting is to 1183 # reject ABI=64 in favour of ABI=32 if the user has forced the flags to 1184 # 32-bit mode. 1185 # 1186 abilist="32" 1187 cclist="gcc acc cc" 1188 any_testlist="sizeof-long-4" 1189 GMP_INCLUDE_MPN(sparc32/sparc-defs.m4) 1190 1191 case $host_cpu in 1192 sparcv8 | microsparc | turbosparc) 1193 path="sparc32/v8 sparc32" ;; 1194 supersparc) 1195 path="sparc32/v8/supersparc sparc32/v8 sparc32" ;; 1196 sparc64 | sparcv9* | ultrasparc*) 1197 path="sparc32/v9 sparc32/v8 sparc32" ;; 1198 *) 1199 path="sparc32" ;; 1200 esac 1201 1202 # gcc 2.7.2 doesn't know about v9 and doesn't pass -xarch=v8plus to the 1203 # assembler. Add it explicitly since the solaris assembler won't accept 1204 # our sparc32/v9 asm code without it. gas accepts -xarch=v8plus too, so 1205 # it can be in the cflags unconditionally (though gas doesn't need it). 1206 # 1207 # gcc -m32 is needed to force 32-bit mode on a dual-ABI system, but past 1208 # gcc doesn't know that flag, hence cflags_maybe. Note that -m32 cannot 1209 # be done through the optlist since the plain cflags would be run first 1210 # and we don't want to require the default mode (whatever it is) works. 1211 # 1212 # Note it's gcc_32_cflags_maybe and not gcc_cflags_maybe because the 1213 # latter would be used in the 64-bit ABI on systems like "*bsd" where 1214 # abilist="64" only. 1215 # 1216 case $host_cpu in 1217 sparc64 | sparcv9* | ultrasparc*) 1218 gcc_cflags="$gcc_cflags -Wa,-xarch=v8plus" ;; 1219 *) 1220 gcc_cflags="$gcc_cflags" ;; 1221 esac 1222 gcc_32_cflags_maybe="-m32" 1223 gcc_cflags_optlist="cpu" 1224 1225 # gcc 2.7.2 knows -mcypress, -msupersparc, -mv8, -msparclite. 1226 # gcc 2.95 knows -mcpu= v7, hypersparc, sparclite86x, f930, f934, 1227 # sparclet, tsc701, v9, ultrasparc. A warning is given that the 1228 # plain -m forms will disappear. 1229 # gcc 3.0 adds nothing. 1230 # gcc 3.1 adds nothing. 1231 # gcc 3.2 adds nothing. 1232 # gcc 3.3 adds ultrasparc3. 1233 # 1234 case $host_cpu in 1235 supersparc) gcc_cflags_cpu="-mcpu=supersparc -msupersparc" ;; 1236 sparcv8 | microsparc | turbosparc) 1237 gcc_cflags_cpu="-mcpu=v8 -mv8" ;; 1238 sparc64 | sparcv9*) gcc_cflags_cpu="-mcpu=v9 -mv8" ;; 1239 ultrasparc3) gcc_cflags_cpu="-mcpu=ultrasparc3 -mcpu=ultrasparc -mv8" ;; 1240 ultrasparc*) gcc_cflags_cpu="-mcpu=ultrasparc -mv8" ;; 1241 *) gcc_cflags_cpu="-mcpu=v7 -mcypress" ;; 1242 esac 1243 1244 # SunPRO cc and acc, and SunOS bundled cc 1245 case $host in 1246 *-*-solaris* | *-*-sunos*) 1247 # Note no -g, it disables all optimizations. 1248 cc_cflags= 1249 cc_cflags_optlist="opt arch cpu" 1250 1251 # SunOS cc doesn't know -xO4, fallback to -O2. 1252 cc_cflags_opt="-xO4 -O2" 1253 1254 # SunOS cc doesn't know -xarch, apparently always generating v7 1255 # code, so make this optional 1256 case $host_cpu in 1257 sparcv8 | microsparc | supersparc | turbosparc) 1258 cc_cflags_arch="-xarch=v8" ;; 1259 sparc64 | sparcv9* | ultrasparc*) cc_cflags_arch="-xarch=v8plus" ;; 1260 *) cc_cflags_arch="-xarch=v7" ;; 1261 esac 1262 1263 # SunOS cc doesn't know -xchip and doesn't seem to have an equivalent. 1264 # SunPRO cc 5 recognises -xchip=generic, old, super, super2, micro, 1265 # micro2, hyper, hyper2, powerup, ultra, ultra2, ultra2i. 1266 # SunPRO cc 6 adds -xchip=ultra2e, ultra3cu. 1267 # 1268 # FIXME: Which of ultra, ultra2 or ultra2i is the best fallback for 1269 # ultrasparc3? 1270 # 1271 case $host_cpu in 1272 supersparc) cc_cflags_cpu="-xchip=super" ;; 1273 microsparc) cc_cflags_cpu="-xchip=micro" ;; 1274 turbosparc) cc_cflags_cpu="-xchip=micro2" ;; 1275 ultrasparc) cc_cflags_cpu="-xchip=ultra" ;; 1276 ultrasparc2) cc_cflags_cpu="-xchip=ultra2" ;; 1277 ultrasparc2i) cc_cflags_cpu="-xchip=ultra2i" ;; 1278 ultrasparc3) cc_cflags_cpu="-xchip=ultra3 -xchip=ultra" ;; 1279 *) cc_cflags_cpu="-xchip=generic" ;; 1280 esac 1281 esac 1282 1283 case $host_cpu in 1284 sparc64 | sparcv9* | ultrasparc*) 1285 case $host in 1286 # Solaris 6 and earlier cannot run ABI=64 since it doesn't save 1287 # registers properly, so ABI=32 is left as the only choice. 1288 # 1289 [*-*-solaris2.[0-6] | *-*-solaris2.[0-6].*]) ;; 1290 1291 # BSD sparc64 ports are 64-bit-only systems, so ABI=64 is the only 1292 # choice. In fact they need no special compiler flags, gcc -m64 1293 # is the default, but it doesn't hurt to add it. v9 CPUs always 1294 # use the sparc64 port, since the plain 32-bit sparc ports don't 1295 # run on a v9. 1296 # 1297 *-*-*bsd*) abilist="64" ;; 1298 1299 # For all other systems, we try both 64 and 32. 1300 # 1301 # GNU/Linux sparc64 has only recently gained a 64-bit user mode. 1302 # In the past sparc64 meant a v9 cpu, but there were no 64-bit 1303 # operations in user mode. We assume that if "gcc -m64" works 1304 # then the system is suitable. Hopefully even if someone attempts 1305 # to put a new gcc and/or glibc on an old system it won't run. 1306 # 1307 *) abilist="64 32" ;; 1308 esac 1309 1310 case $host_cpu in 1311 ultrasparc | ultrasparc2 | ultrasparc2i) 1312 path_64="sparc64/ultrasparc12 sparc64" ;; 1313 [ultrasparc[34]]) 1314 path_64="sparc64/ultrasparc34 sparc64/ultrasparc1234 sparc64" ;; 1315 [ultrasparct[1234]]) 1316 path_64="sparc64" ;; 1317 *) 1318 path_64="sparc64" 1319 esac 1320 1321 cclist_64="gcc" 1322 any_64_testlist="sizeof-long-8" 1323 1324 # gcc -mptr64 is probably implied by -m64, but we're not sure if 1325 # this was always so. On Solaris in the past we always used both 1326 # "-m64 -mptr64". 1327 # 1328 # gcc -Wa,-xarch=v9 is thought to be necessary in some cases on 1329 # solaris, but it would seem likely that if gcc is going to generate 1330 # 64-bit code it will have to add that option itself where needed. 1331 # An extra copy of this option should be harmless though, but leave 1332 # it until we're sure. (Might want -xarch=v9a or -xarch=v9b for the 1333 # higher cpu types instead.) 1334 # 1335 gcc_64_cflags="$gcc_64_cflags -m64 -mptr64" 1336 gcc_64_ldflags="-Wc,-m64" 1337 gcc_64_cflags_optlist="cpu" 1338 1339 case $host in 1340 *-*-solaris*) 1341 # Sun cc. 1342 # 1343 # We used to have -fast and some fixup options here, but it 1344 # recurrently caused problems with miscompilation. Of course, 1345 # -fast is documented as miscompiling things for the sake of speed. 1346 # 1347 cclist_64="$cclist_64 cc" 1348 cc_64_cflags="-xO3 -xarch=v9" 1349 cc_64_cflags_optlist="cpu" 1350 ;; 1351 esac 1352 1353 # using the v9 %tick register 1354 SPEED_CYCLECOUNTER_OBJ_32=sparcv9.lo 1355 SPEED_CYCLECOUNTER_OBJ_64=sparcv9.lo 1356 cyclecounter_size_32=2 1357 cyclecounter_size_64=2 1358 ;; 1359 esac 1360 ;; 1361 1362 1363 # VAX 1364 vax*-*-*) 1365 # Currently gcc (version 3.0) on vax always uses a frame pointer 1366 # (config/vax/vax.h FRAME_POINTER_REQUIRED=1), so -fomit-frame-pointer 1367 # will be ignored. 1368 # 1369 gcc_cflags="$gcc_cflags $fomit_frame_pointer" 1370 path="vax" 1371 extra_functions="udiv_w_sdiv" 1372 ;; 1373 1374 1375 # AMD and Intel x86 configurations, including AMD64 1376 # 1377 # Rumour has it gcc -O2 used to give worse register allocation than just 1378 # -O, but lets assume that's no longer true. 1379 # 1380 # -m32 forces 32-bit mode on a bi-arch 32/64 amd64 build of gcc. -m64 is 1381 # the default in such a build (we think), so -m32 is essential for ABI=32. 1382 # This is, of course, done for any $host_cpu, not just x86_64, so we can 1383 # get such a gcc into the right mode to cross-compile to say i486-*-*. 1384 # 1385 # -m32 is not available in gcc 2.95 and earlier, hence cflags_maybe to use 1386 # it when it works. We check sizeof(long)==4 to ensure we get the right 1387 # mode, in case -m32 has failed not because it's an old gcc, but because 1388 # it's a dual 32/64-bit gcc without a 32-bit libc, or whatever. 1389 # 1390 X86_PATTERN | X86_64_PATTERN) 1391 abilist="32" 1392 cclist="gcc icc cc" 1393 gcc_cflags="$gcc_cflags $fomit_frame_pointer" 1394 gcc_32_cflags_maybe="-m32" 1395 icc_cflags="-no-gcc" 1396 icc_cflags_optlist="opt" 1397 icc_cflags_opt="-O3 -O2 -O1" 1398 any_32_testlist="sizeof-long-4" 1399 CALLING_CONVENTIONS_OBJS='x86call.lo x86check$U.lo' 1400 1401 # Availability of rdtsc is checked at run-time. 1402 SPEED_CYCLECOUNTER_OBJ=pentium.lo 1403 1404 # gcc 2.7.2 only knows i386 and i486, using -m386 or -m486. These 1405 # represent -mcpu= since -m486 doesn't generate 486 specific insns. 1406 # gcc 2.95 adds k6, pentium and pentiumpro, and takes -march= and -mcpu=. 1407 # gcc 3.0 adds athlon. 1408 # gcc 3.1 adds k6-2, k6-3, pentium-mmx, pentium2, pentium3, pentium4, 1409 # athlon-tbird, athlon-4, athlon-xp, athlon-mp. 1410 # gcc 3.2 adds winchip2. 1411 # gcc 3.3 adds winchip-c6. 1412 # gcc 3.3.1 from mandrake adds k8 and knows -mtune. 1413 # gcc 3.4 adds c3, c3-2, k8, and deprecates -mcpu in favour of -mtune. 1414 # 1415 # In gcc 2.95.[0123], -march=pentiumpro provoked a stack slot bug in an 1416 # old version of mpz/powm.c. Seems to be fine with the current code, so 1417 # no need for any restrictions on that option. 1418 # 1419 # -march=pentiumpro can fail if the assembler doesn't know "cmov" 1420 # (eg. solaris 2.8 native "as"), so always have -march=pentium after 1421 # that as a fallback. 1422 # 1423 # -march=pentium4 and -march=k8 enable SSE2 instructions, which may or 1424 # may not be supported by the assembler and/or the OS, and is bad in gcc 1425 # prior to 3.3. The tests will reject these if no good, so fallbacks 1426 # like "-march=pentium4 -mno-sse2" are given to try also without SSE2. 1427 # Note the relevant -march types are listed in the optflags handling 1428 # below, be sure to update there if adding new types emitting SSE2. 1429 # 1430 # -mtune is used at the start of each cpu option list to give something 1431 # gcc 3.4 will use, thereby avoiding warnings from -mcpu. -mcpu forms 1432 # are retained for use by prior gcc. For example pentium has 1433 # "-mtune=pentium -mcpu=pentium ...", the -mtune is for 3.4 and the 1434 # -mcpu for prior. If there's a brand new choice in 3.4 for a chip, 1435 # like k8 for x86_64, then it can be the -mtune at the start, no need to 1436 # duplicate anything. 1437 # 1438 gcc_cflags_optlist="cpu arch" 1439 case $host_cpu in 1440 i386*) 1441 gcc_cflags_cpu="-mtune=i386 -mcpu=i386 -m386" 1442 gcc_cflags_arch="-march=i386" 1443 path="x86" 1444 ;; 1445 i486*) 1446 gcc_cflags_cpu="-mtune=i486 -mcpu=i486 -m486" 1447 gcc_cflags_arch="-march=i486" 1448 path="x86/i486 x86" 1449 ;; 1450 i586 | pentium) 1451 gcc_cflags_cpu="-mtune=pentium -mcpu=pentium -m486" 1452 gcc_cflags_arch="-march=pentium" 1453 path="x86/pentium x86" 1454 ;; 1455 pentiummmx) 1456 gcc_cflags_cpu="-mtune=pentium-mmx -mcpu=pentium-mmx -mcpu=pentium -m486" 1457 gcc_cflags_arch="-march=pentium-mmx -march=pentium" 1458 path="x86/pentium/mmx x86/pentium x86" 1459 ;; 1460 i686 | pentiumpro) 1461 gcc_cflags_cpu="-mtune=pentiumpro -mcpu=pentiumpro -mcpu=i486 -m486" 1462 gcc_cflags_arch="-march=pentiumpro -march=pentium" 1463 path="x86/p6 x86" 1464 ;; 1465 pentium2) 1466 gcc_cflags_cpu="-mtune=pentium2 -mcpu=pentium2 -mcpu=pentiumpro -mcpu=i486 -m486" 1467 gcc_cflags_arch="-march=pentium2 -march=pentiumpro -march=pentium" 1468 path="x86/p6/mmx x86/p6 x86" 1469 ;; 1470 pentium3) 1471 gcc_cflags_cpu="-mtune=pentium3 -mcpu=pentium3 -mcpu=pentiumpro -mcpu=i486 -m486" 1472 gcc_cflags_arch="-march=pentium3 -march=pentiumpro -march=pentium" 1473 path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86" 1474 ;; 1475 pentiumm) 1476 gcc_cflags_cpu="-mtune=pentium3 -mcpu=pentium3 -mcpu=pentiumpro -mcpu=i486 -m486" 1477 gcc_cflags_arch="-march=pentium3 -march=pentiumpro -march=pentium" 1478 path="x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86" 1479 ;; 1480 k6) 1481 gcc_cflags_cpu="-mtune=k6 -mcpu=k6 -mcpu=i486 -m486" 1482 gcc_cflags_arch="-march=k6" 1483 path="x86/k6/mmx x86/k6 x86" 1484 ;; 1485 k62) 1486 gcc_cflags_cpu="-mtune=k6-2 -mcpu=k6-2 -mcpu=k6 -mcpu=i486 -m486" 1487 gcc_cflags_arch="-march=k6-2 -march=k6" 1488 path="x86/k6/k62mmx x86/k6/mmx x86/k6 x86" 1489 ;; 1490 k63) 1491 gcc_cflags_cpu="-mtune=k6-3 -mcpu=k6-3 -mcpu=k6 -mcpu=i486 -m486" 1492 gcc_cflags_arch="-march=k6-3 -march=k6" 1493 path="x86/k6/k62mmx x86/k6/mmx x86/k6 x86" 1494 ;; 1495 geode) 1496 gcc_cflags_cpu="-mtune=k6-3 -mcpu=k6-3 -mcpu=k6 -mcpu=i486 -m486" 1497 gcc_cflags_arch="-march=k6-3 -march=k6" 1498 path="x86/geode x86/k6/k62mmx x86/k6/mmx x86/k6 x86" 1499 ;; 1500 athlon) 1501 # Athlon instruction costs are close to P6 (3 cycle load latency, 1502 # 4-6 cycle mul, 40 cycle div, pairable adc, etc) so if gcc doesn't 1503 # know athlon (eg. 2.95.2 doesn't) then fall back on pentiumpro. 1504 gcc_cflags_cpu="-mtune=athlon -mcpu=athlon -mcpu=pentiumpro -mcpu=i486 -m486" 1505 gcc_cflags_arch="-march=athlon -march=pentiumpro -march=pentium" 1506 path="x86/k7/mmx x86/k7 x86" 1507 ;; 1508 i786 | pentium4) 1509 # pentiumpro is the primary fallback when gcc doesn't know pentium4. 1510 # This gets us cmov to eliminate branches. Maybe "athlon" would be 1511 # a possibility on gcc 3.0. 1512 # 1513 gcc_cflags_cpu="-mtune=pentium4 -mcpu=pentium4 -mcpu=pentiumpro -mcpu=i486 -m486" 1514 gcc_cflags_arch="-march=pentium4 -march=pentium4~-mno-sse2 -march=pentiumpro -march=pentium" 1515 gcc_64_cflags_cpu="-mtune=nocona" 1516 path="x86/pentium4/sse2 x86/pentium4/mmx x86/pentium4 x86" 1517 path_64="x86_64/pentium4 x86_64" 1518 ;; 1519 viac32) 1520 # Not sure of the best fallbacks here for -mcpu. 1521 # c3-2 has sse and mmx, so pentium3 is good for -march. 1522 gcc_cflags_cpu="-mtune=c3-2 -mcpu=c3-2 -mcpu=i486 -m486" 1523 gcc_cflags_arch="-march=c3-2 -march=pentium3 -march=pentiumpro -march=pentium" 1524 path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86" 1525 ;; 1526 viac3*) 1527 # Not sure of the best fallbacks here. 1528 gcc_cflags_cpu="-mtune=c3 -mcpu=c3 -mcpu=i486 -m486" 1529 gcc_cflags_arch="-march=c3 -march=pentium-mmx -march=pentium" 1530 path="x86/pentium/mmx x86/pentium x86" 1531 ;; 1532 athlon64 | k8 | x86_64) 1533 gcc_cflags_cpu="-mtune=k8 -mcpu=athlon -mcpu=pentiumpro -mcpu=i486 -m486" 1534 gcc_cflags_arch="-march=k8 -march=k8~-mno-sse2 -march=athlon -march=pentiumpro -march=pentium" 1535 path="x86/k8 x86/k7/mmx x86/k7 x86" 1536 path_64="x86_64/k8 x86_64" 1537 ;; 1538 k10) 1539 gcc_cflags_cpu="-mtune=amdfam10 -mtune=k8" 1540 gcc_cflags_arch="-march=amdfam10 -march=k8 -march=k8~-mno-sse2" 1541 path="x86/k10 x86/k8 x86/k7/mmx x86/k7 x86" 1542 path_64="x86_64/k10 x86_64/k8 x86_64" 1543 ;; 1544 bobcat) 1545 gcc_cflags_cpu="-mtune=btver1 -mtune=amdfam10 -mtune=k8" 1546 gcc_cflags_arch="-march=btver1 -march=amdfam10 -march=k8 -march=k8~-mno-sse2" 1547 path="x86/bobcat x86/k7/mmx x86/k7 x86" 1548 path_64="x86_64/bobcat x86_64/k10 x86_64/k8 x86_64" 1549 ;; 1550 bulldozer | bd1) 1551 gcc_cflags_cpu="-mtune=bdver1 -mtune=amdfam10 -mtune=k8" 1552 gcc_cflags_arch="-march=bdver1 -march=amdfam10 -march=k8 -march=k8~-mno-sse2" 1553 path="x86/bd1 x86/k7/mmx x86/k7 x86" 1554 path_64="x86_64/bd1 x86_64" 1555 ;; 1556 core2) 1557 gcc_cflags_cpu="-mtune=core2 -mtune=k8" 1558 gcc_cflags_arch="-march=core2 -march=core2~-mno-sse2 -march=k8 -march=k8~-mno-sse2" 1559 path="x86/core2 x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86" 1560 path_64="x86_64/core2 x86_64" 1561 ;; 1562 corei | coreinhm | coreiwsm) 1563 gcc_cflags_cpu="-mtune=corei7 -mtune=core2 -mtune=k8" 1564 gcc_cflags_arch="-march=corei7 -march=core2 -march=core2~-mno-sse2 -march=k8 -march=k8~-mno-sse2" 1565 path="x86/coreinhm x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86" 1566 path_64="x86_64/coreinhm x86_64/core2 x86_64" 1567 ;; 1568 coreisbr) 1569 gcc_cflags_cpu="-mtune=corei7 -mtune=core2 -mtune=k8" 1570 gcc_cflags_arch="-march=corei7 -march=core2 -march=core2~-mno-sse2 -march=k8 -march=k8~-mno-sse2" 1571 path="x86/coreisbr x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86" 1572 path_64="x86_64/coreisbr x86_64/coreinhm x86_64/core2 x86_64" 1573 ;; 1574 atom) 1575 gcc_cflags_cpu="-mtune=atom -mtune=pentium3" 1576 gcc_cflags_arch="-march=atom -march=pentium3" 1577 path="x86/atom/sse2 x86/atom/mmx x86/atom x86" 1578 path_64="x86_64/atom x86_64" 1579 ;; 1580 nano) 1581 gcc_cflags_cpu="-mtune=nano" 1582 gcc_cflags_arch="-march=nano" 1583 path="x86/nano x86" 1584 path_64="x86_64/nano x86_64" 1585 ;; 1586 *) 1587 gcc_cflags_cpu="-mtune=i486 -mcpu=i486 -m486" 1588 gcc_cflags_arch="-march=i486" 1589 path="x86" 1590 path_64="x86_64" 1591 ;; 1592 esac 1593 1594 case $host in 1595 X86_64_PATTERN) 1596 cclist_64="gcc" 1597 gcc_64_cflags="$gcc_64_cflags -m64" 1598 gcc_64_cflags_optlist="cpu arch" 1599 CALLING_CONVENTIONS_OBJS_64='amd64call.lo amd64check$U.lo' 1600 SPEED_CYCLECOUNTER_OBJ_64=x86_64.lo 1601 cyclecounter_size_64=2 1602 abilist="64 32" 1603 1604 case $host in 1605 *-*-solaris*) 1606 # Sun cc. 1607 cclist_64="$cclist_64 cc" 1608 cc_64_cflags="-xO3 -m64" 1609 ;; 1610 *-*-mingw* | *-*-cygwin) 1611 limb_64=longlong 1612 path_64="" # Windows amd64 calling conventions are *different* 1613 # Silence many pedantic warnings for w64. FIXME. 1614 gcc_64_cflags="$gcc_64_cflags -std=gnu99" 1615 ;; 1616 esac 1617 ;; 1618 esac 1619 ;; 1620 1621 1622 # FIXME: z8kx won't get through config.sub. Could make 16 versus 32 bit 1623 # limb an ABI option perhaps. 1624 z8kx*-*-*) 1625 path="z8000x" 1626 extra_functions="udiv_w_sdiv" 1627 ;; 1628 z8k*-*-*) 1629 path="z8000" 1630 extra_functions="udiv_w_sdiv" 1631 ;; 1632 1633 1634 # Special CPU "none" selects generic C. -DNO_ASM is used to disable gcc 1635 # asm blocks in longlong.h (since they're driven by cpp pre-defined 1636 # symbols like __alpha rather than the configured $host_cpu). 1637 # 1638 none-*-*) 1639 abilist="long longlong" 1640 cclist_long=$cclist 1641 gcc_long_cflags=$gcc_cflags 1642 gcc_long_cppflags="-DNO_ASM" 1643 cc_long_cflags=$cc_cflags 1644 cclist_longlong=$cclist 1645 gcc_longlong_cflags=$gcc_cflags 1646 gcc_longlong_cppflags="-DNO_ASM" 1647 cc_longlong_cflags=$cc_cflags 1648 limb_longlong=longlong 1649 ;; 1650 1651esac 1652 1653# mingw can be built by the cygwin gcc if -mno-cygwin is added. For 1654# convenience add this automatically if it works. Actual mingw gcc accepts 1655# -mno-cygwin too, but of course is the default. mingw only runs on the 1656# x86s, but allow any CPU here so as to catch "none" too. 1657# 1658case $host in 1659 *-*-mingw*) 1660 gcc_cflags_optlist="$gcc_cflags_optlist nocygwin" 1661 gcc_cflags_nocygwin="-mno-cygwin" 1662 ;; 1663esac 1664 1665 1666CFLAGS_or_unset=${CFLAGS-'(unset)'} 1667CPPFLAGS_or_unset=${CPPFLAGS-'(unset)'} 1668 1669cat >&AC_FD_CC <<EOF 1670User: 1671ABI=$ABI 1672CC=$CC 1673CFLAGS=$CFLAGS_or_unset 1674CPPFLAGS=$CPPFLAGS_or_unset 1675MPN_PATH=$MPN_PATH 1676GMP: 1677abilist=$abilist 1678cclist=$cclist 1679EOF 1680 1681 1682test_CFLAGS=${CFLAGS+set} 1683test_CPPFLAGS=${CPPFLAGS+set} 1684 1685for abi in $abilist; do 1686 abi_last="$abi" 1687done 1688 1689# If the user specifies an ABI then it must be in $abilist, after that 1690# $abilist is restricted to just that choice. 1691# 1692if test -n "$ABI"; then 1693 found=no 1694 for abi in $abilist; do 1695 if test $abi = "$ABI"; then found=yes; break; fi 1696 done 1697 if test $found = no; then 1698 AC_MSG_ERROR([ABI=$ABI is not among the following valid choices: $abilist]) 1699 fi 1700 abilist="$ABI" 1701fi 1702 1703found_compiler=no 1704 1705for abi in $abilist; do 1706 1707 echo "checking ABI=$abi" 1708 1709 # Suppose abilist="64 32", then for abi=64, will have abi1="_64" and 1710 # abi2="_64". For abi=32, will have abi1="_32" and abi2="". This is how 1711 # $gcc_cflags becomes a fallback for $gcc_32_cflags (the last in the 1712 # abilist), but there's no fallback for $gcc_64_cflags. 1713 # 1714 abi1=[`echo _$abi | sed 's/[.]//g'`] 1715 if test $abi = $abi_last; then abi2=; else abi2="$abi1"; fi 1716 1717 # Compiler choices under this ABI 1718 eval cclist_chosen=\"\$cclist$abi1\" 1719 test -n "$cclist_chosen" || eval cclist_chosen=\"\$cclist$abi2\" 1720 1721 # If there's a user specified $CC then don't use a list for 1722 # $cclist_chosen, just a single value for $ccbase. 1723 # 1724 if test -n "$CC"; then 1725 1726 # The first word of $CC, stripped of any directory. For instance 1727 # CC="/usr/local/bin/gcc -pipe" will give "gcc". 1728 # 1729 for ccbase in $CC; do break; done 1730 ccbase=`echo $ccbase | sed 's:.*/::'` 1731 1732 # If this $ccbase is in $cclist_chosen then it's a compiler we know and 1733 # we can do flags defaulting with it. If not, then $cclist_chosen is 1734 # set to "unrecognised" so no default flags are used. 1735 # 1736 # "unrecognised" is used to avoid bad effects with eval if $ccbase has 1737 # non-symbol characters. For instance ccbase=my+cc would end up with 1738 # something like cflags="$my+cc_cflags" which would give 1739 # cflags="+cc_cflags" rather than the intended empty string for an 1740 # unknown compiler. 1741 # 1742 found=unrecognised 1743 for i in $cclist_chosen; do 1744 if test "$ccbase" = $i; then 1745 found=$ccbase 1746 break 1747 fi 1748 done 1749 cclist_chosen=$found 1750 fi 1751 1752 for ccbase in $cclist_chosen; do 1753 1754 # When cross compiling, look for a compiler with the $host_alias as a 1755 # prefix, the same way that AC_CHECK_TOOL does. But don't do this to a 1756 # user-selected $CC. 1757 # 1758 # $cross_compiling will be yes/no/maybe at this point. Do the host 1759 # prefixing for "maybe" as well as "yes". 1760 # 1761 if test "$cross_compiling" != no && test -z "$CC"; then 1762 cross_compiling_prefix="${host_alias}-" 1763 fi 1764 1765 for ccprefix in $cross_compiling_prefix ""; do 1766 1767 cc="$CC" 1768 test -n "$cc" || cc="$ccprefix$ccbase" 1769 1770 # If the compiler is gcc but installed under another name, then change 1771 # $ccbase so as to use the flags we know for gcc. This helps for 1772 # instance when specifying CC=gcc272 on Debian GNU/Linux, or the 1773 # native cc which is really gcc on NeXT or MacOS-X. 1774 # 1775 # FIXME: There's a slight misfeature here. If cc is actually gcc but 1776 # gcc is not a known compiler under this $abi then we'll end up 1777 # testing it with no flags and it'll work, but chances are it won't be 1778 # in the right mode for the ABI we desire. Let's quietly hope this 1779 # doesn't happen. 1780 # 1781 if test $ccbase != gcc; then 1782 GMP_PROG_CC_IS_GNU($cc,ccbase=gcc) 1783 fi 1784 1785 # Similarly if the compiler is IBM xlc but invoked as cc or whatever 1786 # then change $ccbase and make the default xlc flags available. 1787 if test $ccbase != xlc; then 1788 GMP_PROG_CC_IS_XLC($cc,ccbase=xlc) 1789 fi 1790 1791 # acc was Sun's first unbundled compiler back in the SunOS days, or 1792 # something like that, but today its man page says it's not meant to 1793 # be used directly (instead via /usr/ucb/cc). The options are pretty 1794 # much the same as the main SunPRO cc, so share those configs. 1795 # 1796 case $host in 1797 *sparc*-*-solaris* | *sparc*-*-sunos*) 1798 if test "$ccbase" = acc; then ccbase=cc; fi ;; 1799 esac 1800 1801 for tmp_cflags_maybe in yes no; do 1802 eval cflags=\"\$${ccbase}${abi1}_cflags\" 1803 test -n "$cflags" || eval cflags=\"\$${ccbase}${abi2}_cflags\" 1804 1805 if test "$tmp_cflags_maybe" = yes; then 1806 # don't try cflags_maybe when the user set CFLAGS 1807 if test "$test_CFLAGS" = set; then continue; fi 1808 eval cflags_maybe=\"\$${ccbase}${abi1}_cflags_maybe\" 1809 test -n "$cflags_maybe" || eval cflags_maybe=\"\$${ccbase}${abi2}_cflags_maybe\" 1810 # don't try cflags_maybe if there's nothing set 1811 if test -z "$cflags_maybe"; then continue; fi 1812 cflags="$cflags_maybe $cflags" 1813 fi 1814 1815 # Any user CFLAGS, even an empty string, takes precedence 1816 if test "$test_CFLAGS" = set; then cflags=$CFLAGS; fi 1817 1818 # Any user CPPFLAGS, even an empty string, takes precedence 1819 eval cppflags=\"\$${ccbase}${abi1}_cppflags\" 1820 test -n "$cppflags" || eval cppflags=\"\$${ccbase}${abi2}_cppflags\" 1821 if test "$test_CPPFLAGS" = set; then cppflags=$CPPFLAGS; fi 1822 1823 # --enable-profiling adds -p/-pg even to user-specified CFLAGS. 1824 # This is convenient, but it's perhaps a bit naughty to modify user 1825 # CFLAGS. 1826 case "$enable_profiling" in 1827 prof) cflags="$cflags -p" ;; 1828 gprof) cflags="$cflags -pg" ;; 1829 instrument) cflags="$cflags -finstrument-functions" ;; 1830 esac 1831 1832 GMP_PROG_CC_WORKS($cc $cflags $cppflags,,continue) 1833 1834 # If we're supposed to be using a "long long" for a limb, check that 1835 # it works. 1836 eval limb_chosen=\"\$limb$abi1\" 1837 test -n "$limb_chosen" || eval limb_chosen=\"\$limb$abi2\" 1838 if test "$limb_chosen" = longlong; then 1839 GMP_PROG_CC_WORKS_LONGLONG($cc $cflags $cppflags,,continue) 1840 fi 1841 1842 # The tests to perform on this $cc, if any 1843 eval testlist=\"\$${ccbase}${abi1}_testlist\" 1844 test -n "$testlist" || eval testlist=\"\$${ccbase}${abi2}_testlist\" 1845 test -n "$testlist" || eval testlist=\"\$any${abi1}_testlist\" 1846 test -n "$testlist" || eval testlist=\"\$any${abi2}_testlist\" 1847 1848 testlist_pass=yes 1849 for tst in $testlist; do 1850 case $tst in 1851 hpc-hppa-2-0) GMP_HPC_HPPA_2_0($cc,,testlist_pass=no) ;; 1852 gcc-arm-umodsi) GMP_GCC_ARM_UMODSI($cc,,testlist_pass=no) ;; 1853 gcc-mips-o32) GMP_GCC_MIPS_O32($cc,,testlist_pass=no) ;; 1854 hppa-level-2.0) GMP_HPPA_LEVEL_20($cc $cflags,,testlist_pass=no) ;; 1855 sizeof*) GMP_C_TEST_SIZEOF($cc $cflags,$tst,,testlist_pass=no) ;; 1856 esac 1857 if test $testlist_pass = no; then break; fi 1858 done 1859 1860 if test $testlist_pass = yes; then 1861 found_compiler=yes 1862 break 1863 fi 1864 done 1865 1866 if test $found_compiler = yes; then break; fi 1867 done 1868 1869 if test $found_compiler = yes; then break; fi 1870 done 1871 1872 if test $found_compiler = yes; then break; fi 1873done 1874 1875 1876# If we recognised the CPU, as indicated by $path being set, then insist 1877# that we have a working compiler, either from our $cclist choices or from 1878# $CC. We can't let AC_PROG_CC look around for a compiler because it might 1879# find one that we've rejected (for not supporting the modes our asm code 1880# demands, etc). 1881# 1882# If we didn't recognise the CPU (and this includes host_cpu=none), then 1883# fall through and let AC_PROG_CC look around for a compiler too. This is 1884# mostly in the interests of following a standard autoconf setup, after all 1885# we've already tested cc and gcc adequately (hopefully). As of autoconf 1886# 2.50 the only thing AC_PROG_CC really adds is a check for "cl" (Microsoft 1887# C on MS-DOS systems). 1888# 1889if test $found_compiler = no && test -n "$path"; then 1890 AC_MSG_ERROR([could not find a working compiler, see config.log for details]) 1891fi 1892 1893case $host in 1894 X86_PATTERN | X86_64_PATTERN) 1895 # If the user asked for a fat build, override the path and flags set above 1896 if test $enable_fat = yes; then 1897 gcc_cflags_cpu="" 1898 gcc_cflags_arch="" 1899 1900 if test "$abi" = 32; then 1901 extra_functions="$extra_functions fat fat_entry" 1902 path="x86/fat x86" 1903 fat_path="x86 x86/fat x86/i486 1904 x86/k6 x86/k6/mmx x86/k6/k62mmx 1905 x86/k7 x86/k7/mmx 1906 x86/pentium x86/pentium/mmx 1907 x86/p6 x86/p6/mmx x86/p6/p3mmx x86/p6/sse2 1908 x86/pentium4 x86/pentium4/mmx x86/pentium4/sse2" 1909 fi 1910 1911 if test "$abi" = 64; then 1912 gcc_64_cflags="" 1913 extra_functions_64="$extra_functions_64 fat fat_entry" 1914 path_64="x86_64/fat x86_64" 1915 fat_path="x86_64 x86_64/fat x86_64/pentium4 x86_64/core2 x86_64/coreinhm x86_64/coreisbr x86_64/atom x86_64/nano" 1916 fi 1917 1918 fat_functions="add_n addmul_1 copyd copyi 1919 dive_1 diveby3 divrem_1 gcd_1 lshift 1920 mod_1 mod_34lsub1 mode1o mul_1 mul_basecase 1921 pre_divrem_1 pre_mod_1 rshift 1922 sqr_basecase sub_n submul_1" 1923 fat_thresholds="MUL_TOOM22_THRESHOLD MUL_TOOM33_THRESHOLD 1924 SQR_TOOM2_THRESHOLD SQR_TOOM3_THRESHOLD" 1925 fi 1926 ;; 1927esac 1928 1929 1930if test $found_compiler = yes; then 1931 1932 # If we're creating CFLAGS, then look for optional additions. If the user 1933 # set CFLAGS then leave it alone. 1934 # 1935 if test "$test_CFLAGS" != set; then 1936 eval optlist=\"\$${ccbase}${abi1}_cflags_optlist\" 1937 test -n "$optlist" || eval optlist=\"\$${ccbase}${abi2}_cflags_optlist\" 1938 1939 for opt in $optlist; do 1940 eval optflags=\"\$${ccbase}${abi1}_cflags_${opt}\" 1941 test -n "$optflags" || eval optflags=\"\$${ccbase}${abi2}_cflags_${opt}\" 1942 test -n "$optflags" || eval optflags=\"\$${ccbase}_cflags_${opt}\" 1943 1944 for flag in $optflags; do 1945 1946 # ~ represents a space in an option spec 1947 flag=`echo "$flag" | tr '~' ' '` 1948 1949 case $flag in 1950 -march=pentium4 | -march=k8) 1951 # For -march settings which enable SSE2 we exclude certain bad 1952 # gcc versions and we need an OS knowing how to save xmm regs. 1953 # 1954 # This is only for ABI=32, any 64-bit gcc is good and any OS 1955 # knowing x86_64 will know xmm. 1956 # 1957 # -march=k8 was only introduced in gcc 3.3, so we shouldn't need 1958 # the GMP_GCC_PENTIUM4_SSE2 check (for gcc 3.2 and prior). But 1959 # it doesn't hurt to run it anyway, sharing code with the 1960 # pentium4 case. 1961 # 1962 if test "$abi" = 32; then 1963 GMP_GCC_PENTIUM4_SSE2($cc $cflags $cppflags,, continue) 1964 GMP_OS_X86_XMM($cc $cflags $cppflags,, continue) 1965 fi 1966 ;; 1967 -no-cpp-precomp) 1968 # special check, avoiding a warning 1969 GMP_GCC_NO_CPP_PRECOMP($ccbase,$cc,$cflags, 1970 [cflags="$cflags $flag" 1971 break], 1972 [continue]) 1973 ;; 1974 -Wa,-m*) 1975 case $host in 1976 alpha*-*-*) 1977 GMP_GCC_WA_MCPU($cc $cflags, $flag, , [continue]) 1978 ;; 1979 esac 1980 ;; 1981 -Wa,-oldas) 1982 GMP_GCC_WA_OLDAS($cc $cflags $cppflags, 1983 [cflags="$cflags $flag" 1984 break], 1985 [continue]) 1986 ;; 1987 esac 1988 1989 GMP_PROG_CC_WORKS($cc $cflags $cppflags $flag, 1990 [cflags="$cflags $flag" 1991 break]) 1992 done 1993 done 1994 fi 1995 1996 ABI="$abi" 1997 CC="$cc" 1998 CFLAGS="$cflags" 1999 CPPFLAGS="$cppflags" 2000 2001 2002 # Could easily have this in config.h too, if desired. 2003 ABI_nodots=`echo $ABI | sed 's/\./_/'` 2004 GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_ABI_$ABI_nodots')", POST) 2005 2006 2007 # GMP_LDFLAGS substitution, selected according to ABI. 2008 # These are needed on libgmp.la and libmp.la, but currently not on 2009 # convenience libraries like tune/libspeed.la or mpz/libmpz.la. 2010 # 2011 eval GMP_LDFLAGS=\"\$${ccbase}${abi1}_ldflags\" 2012 test -n "$GMP_LDFLAGS" || eval GMP_LDFLAGS=\"\$${ccbase}${abi1}_ldflags\" 2013 AC_SUBST(GMP_LDFLAGS) 2014 AC_SUBST(LIBGMP_LDFLAGS) 2015 AC_SUBST(LIBGMPXX_LDFLAGS) 2016 2017 # extra_functions, selected according to ABI 2018 eval tmp=\"\$extra_functions$abi1\" 2019 test -n "$tmp" || eval tmp=\"\$extra_functions$abi2\" 2020 extra_functions="$tmp" 2021 2022 2023 # Cycle counter, selected according to ABI. 2024 # 2025 eval tmp=\"\$SPEED_CYCLECOUNTER_OBJ$abi1\" 2026 test -n "$tmp" || eval tmp=\"\$SPEED_CYCLECOUNTER_OBJ$abi2\" 2027 SPEED_CYCLECOUNTER_OBJ="$tmp" 2028 eval tmp=\"\$cyclecounter_size$abi1\" 2029 test -n "$tmp" || eval tmp=\"\$cyclecounter_size$abi2\" 2030 cyclecounter_size="$tmp" 2031 2032 if test -n "$SPEED_CYCLECOUNTER_OBJ"; then 2033 AC_DEFINE_UNQUOTED(HAVE_SPEED_CYCLECOUNTER, $cyclecounter_size, 2034 [Tune directory speed_cyclecounter, undef=none, 1=32bits, 2=64bits)]) 2035 fi 2036 AC_SUBST(SPEED_CYCLECOUNTER_OBJ) 2037 2038 2039 # Calling conventions checking, selected according to ABI. 2040 # 2041 eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi1\" 2042 test -n "$tmp" || eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi2\" 2043 CALLING_CONVENTIONS_OBJS="$tmp" 2044 2045 if test -n "$CALLING_CONVENTIONS_OBJS"; then 2046 AC_DEFINE(HAVE_CALLING_CONVENTIONS,1, 2047 [Define to 1 if tests/libtests has calling conventions checking for the CPU]) 2048 fi 2049 AC_SUBST(CALLING_CONVENTIONS_OBJS) 2050 2051fi 2052 2053 2054# If the user gave an MPN_PATH, use that verbatim, otherwise choose 2055# according to the ABI and add "generic". 2056# 2057if test -n "$MPN_PATH"; then 2058 path="$MPN_PATH" 2059else 2060 eval tmp=\"\$path$abi1\" 2061 test -n "$tmp" || eval tmp=\"\$path$abi2\" 2062 path="$tmp generic" 2063fi 2064 2065 2066# Long long limb setup for gmp.h. 2067case $limb_chosen in 2068longlong) DEFN_LONG_LONG_LIMB="#define _LONG_LONG_LIMB 1" ;; 2069*) DEFN_LONG_LONG_LIMB="/* #undef _LONG_LONG_LIMB */" ;; 2070esac 2071AC_SUBST(DEFN_LONG_LONG_LIMB) 2072 2073 2074# The C compiler and preprocessor, put into ANSI mode if possible. 2075AC_PROG_CC 2076AC_PROG_CC_STDC 2077AC_PROG_CPP 2078GMP_H_ANSI 2079 2080 2081# The C compiler on the build system, and associated tests. 2082GMP_PROG_CC_FOR_BUILD 2083GMP_PROG_CPP_FOR_BUILD 2084GMP_PROG_EXEEXT_FOR_BUILD 2085GMP_C_FOR_BUILD_ANSI 2086GMP_CHECK_LIBM_FOR_BUILD 2087 2088 2089# How to assemble, used with CFLAGS etc, see mpn/Makeasm.am. 2090# Using the compiler is a lot easier than figuring out how to invoke the 2091# assembler directly. 2092# 2093test -n "$CCAS" || CCAS="$CC -c" 2094AC_SUBST(CCAS) 2095 2096 2097# The C++ compiler, if desired. 2098want_cxx=no 2099if test $enable_cxx != no; then 2100 test_CXXFLAGS=${CXXFLAGS+set} 2101 AC_PROG_CXX 2102 2103 echo "CXXFLAGS chosen by autoconf: $CXXFLAGS" >&AC_FD_CC 2104 cxxflags_ac_prog_cxx=$CXXFLAGS 2105 cxxflags_list=ac_prog_cxx 2106 2107 # If the user didn't specify $CXXFLAGS, then try $CFLAGS, with -g removed 2108 # if AC_PROG_CXX thinks that doesn't work. $CFLAGS stands a good chance 2109 # of working, eg. on a GNU system where CC=gcc and CXX=g++. 2110 # 2111 if test "$test_CXXFLAGS" != set; then 2112 cxxflags_cflags=$CFLAGS 2113 cxxflags_list="cflags $cxxflags_list" 2114 if test "$ac_prog_cxx_g" = no; then 2115 cxxflags_cflags=`echo "$cxxflags_cflags" | sed -e 's/ -g //' -e 's/^-g //' -e 's/ -g$//'` 2116 fi 2117 fi 2118 2119 # See if the C++ compiler works. If the user specified CXXFLAGS then all 2120 # we're doing is checking whether AC_PROG_CXX succeeded, since it doesn't 2121 # give a fatal error, just leaves CXX set to a default g++. If on the 2122 # other hand the user didn't specify CXXFLAGS then we get to try here our 2123 # $cxxflags_list alternatives. 2124 # 2125 # Automake includes $CPPFLAGS in a C++ compile, so we do the same here. 2126 # 2127 for cxxflags_choice in $cxxflags_list; do 2128 eval CXXFLAGS=\"\$cxxflags_$cxxflags_choice\" 2129 GMP_PROG_CXX_WORKS($CXX $CPPFLAGS $CXXFLAGS, 2130 [want_cxx=yes 2131 break]) 2132 done 2133 2134 # If --enable-cxx=yes but a C++ compiler can't be found, then abort. 2135 if test $want_cxx = no && test $enable_cxx = yes; then 2136 AC_MSG_ERROR([C++ compiler not available, see config.log for details]) 2137 fi 2138fi 2139 2140AM_CONDITIONAL(WANT_CXX, test $want_cxx = yes) 2141 2142# FIXME: We're not interested in CXXCPP for ourselves, but if we don't do it 2143# here then AC_PROG_LIBTOOL will AC_REQUIRE it (via _LT_AC_TAGCONFIG) and 2144# hence execute it unconditionally, and that will fail if there's no C++ 2145# compiler (and no generic /lib/cpp). 2146# 2147if test $want_cxx = yes; then 2148 AC_PROG_CXXCPP 2149fi 2150 2151 2152# Path setups for Cray, according to IEEE or CFP. These must come after 2153# deciding the compiler. 2154# 2155GMP_CRAY_OPTIONS( 2156 [add_path="cray/ieee"], 2157 [add_path="cray/cfp"; extra_functions="mulwwc90"], 2158 [add_path="cray/cfp"; extra_functions="mulwwj90"]) 2159 2160 2161if test -z "$MPN_PATH"; then 2162 path="$add_path $path" 2163fi 2164 2165# For a nail build, also look in "nails" subdirectories. 2166# 2167if test $GMP_NAIL_BITS != 0 && test -z "$MPN_PATH"; then 2168 new_path= 2169 for i in $path; do 2170 case $i in 2171 generic) new_path="$new_path $i" ;; 2172 *) new_path="$new_path $i/nails $i" ;; 2173 esac 2174 done 2175 path=$new_path 2176fi 2177 2178 2179# Put all directories into CPUVEC_list so as to get a full set of 2180# CPUVEC_SETUP_$tmp_suffix defines into config.h, even if some of them are 2181# empty because mmx and/or sse2 had to be dropped. 2182# 2183for i in $fat_path; do 2184 GMP_FAT_SUFFIX(tmp_suffix, $i) 2185 CPUVEC_list="$CPUVEC_list CPUVEC_SETUP_$tmp_suffix" 2186done 2187 2188 2189# If there's any sse2 or mmx in the path, check whether the assembler 2190# supports it, and remove if not. 2191# 2192# We only need this in ABI=32, for ABI=64 on x86_64 we can assume a new 2193# enough assembler. 2194# 2195case $host in 2196 X86_PATTERN | X86_64_PATTERN) 2197 if test "$ABI" = 32; then 2198 case "$path $fat_path" in 2199 *mmx*) GMP_ASM_X86_MMX( , [GMP_STRIP_PATH(*mmx*)]) ;; 2200 esac 2201 case "$path $fat_path" in 2202 *sse2*) GMP_ASM_X86_SSE2( , [GMP_STRIP_PATH(sse2)]) ;; 2203 esac 2204 fi 2205 ;; 2206esac 2207 2208 2209cat >&AC_FD_CC <<EOF 2210Decided: 2211ABI=$ABI 2212CC=$CC 2213CFLAGS=$CFLAGS 2214CPPFLAGS=$CPPFLAGS 2215GMP_LDFLAGS=$GMP_LDFLAGS 2216CXX=$CXX 2217CXXFLAGS=$CXXFLAGS 2218path=$path 2219EOF 2220echo "using ABI=\"$ABI\"" 2221echo " CC=\"$CC\"" 2222echo " CFLAGS=\"$CFLAGS\"" 2223echo " CPPFLAGS=\"$CPPFLAGS\"" 2224if test $want_cxx = yes; then 2225 echo " CXX=\"$CXX\"" 2226 echo " CXXFLAGS=\"$CXXFLAGS\"" 2227fi 2228echo " MPN_PATH=\"$path\"" 2229 2230 2231# Automake ansi2knr support. 2232AM_C_PROTOTYPES 2233 2234CL_AS_NOEXECSTACK 2235 2236GMP_PROG_AR 2237GMP_PROG_NM 2238 2239case $host in 2240 # FIXME: On AIX 3 and 4, $libname.a is included in libtool 2241 # $library_names_spec, so libgmp.a becomes a symlink to libgmp.so, making 2242 # it impossible to build shared and static libraries simultaneously. 2243 # Disable shared libraries by default, but let the user override with 2244 # --enable-shared --disable-static. 2245 # 2246 # FIXME: This $libname.a problem looks like it might apply to *-*-amigaos* 2247 # and *-*-os2* too, but wait for someone to test this before worrying 2248 # about it. If there is a problem then of course libtool is the right 2249 # place to fix it. 2250 # 2251 [*-*-aix[34]*]) 2252 if test -z "$enable_shared"; then enable_shared=no; fi ;; 2253esac 2254 2255 2256# Configs for Windows DLLs. 2257 2258AC_LIBTOOL_WIN32_DLL 2259 2260AC_SUBST(LIBGMP_DLL,0) 2261case $host in 2262 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) 2263 # By default, build only static. 2264 if test -z "$enable_shared"; then 2265 enable_shared=no 2266 fi 2267 # Don't allow both static and DLL. 2268 if test "$enable_shared" != no && test "$enable_static" != no; then 2269 AC_MSG_ERROR([cannot build both static and DLL, since gmp.h is different for each. 2270Use "--disable-static --enable-shared" to build just a DLL.]) 2271 fi 2272 2273 # "-no-undefined" is required when building a DLL, see documentation on 2274 # AC_LIBTOOL_WIN32_DLL. 2275 # 2276 # "-Wl,--export-all-symbols" is a bit of a hack, it gets all libgmp and 2277 # libgmpxx functions and variables exported. This is what libtool did 2278 # in the past, and it's convenient for us in the test programs. 2279 # 2280 # Maybe it'd be prudent to check for --export-all-symbols before using 2281 # it, but it seems to have been in ld since at least 2000, and there's 2282 # not really any alternative we want to take up at the moment. 2283 # 2284 # "-Wl,output-def" is used to get a .def file for use by MS lib to make 2285 # a .lib import library, described in the manual. libgmp-3.dll.def 2286 # corresponds to the libmp-3.dll.def generated by libtool (as a result 2287 # of -export-symbols on that library). 2288 # 2289 # Incidentally, libtool does generate an import library libgmp.dll.a, 2290 # but it's "ar" format and cannot be used by the MS linker. There 2291 # doesn't seem to be any GNU tool for generating or converting to .lib. 2292 # 2293 # FIXME: The .def files produced by -Wl,output-def include isascii, 2294 # iscsym, iscsymf and toascii, apparently because mingw ctype.h doesn't 2295 # inline isascii (used in gmp). It gives an extern inline for 2296 # __isascii, but for some reason not the plain isascii. 2297 # 2298 if test "$enable_shared" = yes; then 2299 GMP_LDFLAGS="$GMP_LDFLAGS -no-undefined -Wl,--export-all-symbols" 2300 LIBGMP_LDFLAGS="$LIBGMP_LDFLAGS -Wl,--output-def,.libs/libgmp-3.dll.def" 2301 LIBGMPXX_LDFLAGS="$LIBGMP_LDFLAGS -Wl,--output-def,.libs/libgmpxx-3.dll.def" 2302 LIBGMP_DLL=1 2303 fi 2304 ;; 2305esac 2306 2307 2308# Ensure that $CONFIG_SHELL is available for AC_LIBTOOL_SYS_MAX_CMD_LEN. 2309# It's often set already by _LT_AC_PROG_ECHO_BACKSLASH or 2310# _AS_LINENO_PREPARE, but not always. 2311# 2312# The symptom of CONFIG_SHELL unset is some "expr" errors during the test, 2313# and an empty result. This only happens when invoked as "sh configure", 2314# ie. no path, and can be seen for instance on ia64-*-hpux*. 2315# 2316# FIXME: Newer libtool should have it's own fix for this. 2317# 2318if test -z "$CONFIG_SHELL"; then 2319 CONFIG_SHELL=$SHELL 2320fi 2321 2322# Enable CXX in libtool only if we want it, and never enable GCJ, nor RC on 2323# mingw and cygwin. Under --disable-cxx this avoids some error messages 2324# from libtool arising from the fact we didn't actually run AC_PROG_CXX. 2325# Notice that any user-supplied --with-tags setting takes precedence. 2326# 2327# FIXME: Is this the right way to get this effect? Very possibly not, but 2328# the current _LT_AC_TAGCONFIG doesn't really suggest an alternative. 2329# 2330if test "${with_tags+set}" != set; then 2331 if test $want_cxx = yes; then 2332 with_tags=CXX 2333 else 2334 with_tags= 2335 fi 2336fi 2337 2338# The dead hand of AC_REQUIRE makes AC_PROG_LIBTOOL expand and execute 2339# AC_PROG_F77, even when F77 is not in the selected with_tags. This is 2340# probably harmless, but it's unsightly and bloats our configure, so pretend 2341# AC_PROG_F77 has been expanded already. 2342# 2343# FIXME: Rumour has it libtool will one day provide a way for a configure.in 2344# to say what it wants from among supported languages etc. 2345# 2346AC_PROVIDE([AC_PROG_F77]) 2347 2348AC_PROG_LIBTOOL 2349 2350# Generate an error here if attempting to build both shared and static when 2351# $libname.a is in $library_names_spec (as mentioned above), rather than 2352# wait for ar or ld to fail. 2353# 2354if test "$enable_shared" = yes && test "$enable_static" = yes; then 2355 case $library_names_spec in 2356 *libname.a*) 2357 AC_MSG_ERROR([cannot create both shared and static libraries on this system, --disable one of the two]) 2358 ;; 2359 esac 2360fi 2361 2362AM_CONDITIONAL(ENABLE_STATIC, test "$enable_static" = yes) 2363 2364 2365# Many of these library and header checks are for the benefit of 2366# supplementary programs. libgmp doesn't use anything too weird. 2367 2368AC_HEADER_STDC 2369AC_HEADER_TIME 2370 2371# Reasons for testing: 2372# float.h - not in SunOS bundled cc 2373# invent.h - IRIX specific 2374# langinfo.h - X/Open standard only, not in djgpp for instance 2375# locale.h - old systems won't have this 2376# nl_types.h - X/Open standard only, not in djgpp for instance 2377# (usually langinfo.h gives nl_item etc, but not on netbsd 1.4.1) 2378# sys/attributes.h - IRIX specific 2379# sys/iograph.h - IRIX specific 2380# sys/mman.h - not in Cray Unicos 2381# sys/param.h - not in mingw 2382# sys/processor.h - solaris specific, though also present in macos 2383# sys/pstat.h - HPUX specific 2384# sys/resource.h - not in mingw 2385# sys/sysctl.h - not in mingw 2386# sys/sysinfo.h - OSF specific 2387# sys/syssgi.h - IRIX specific 2388# sys/systemcfg.h - AIX specific 2389# sys/time.h - autoconf suggests testing, don't know anywhere without it 2390# sys/times.h - not in mingw 2391# machine/hal_sysinfo.h - OSF specific 2392# 2393# inttypes.h, stdint.h, unistd.h and sys/types.h are already in the autoconf 2394# default tests 2395# 2396AC_CHECK_HEADERS(fcntl.h float.h invent.h langinfo.h locale.h nl_types.h sys/attributes.h sys/iograph.h sys/mman.h sys/param.h sys/processor.h sys/pstat.h sys/sysinfo.h sys/syssgi.h sys/systemcfg.h sys/time.h sys/times.h) 2397 2398# On SunOS, sys/resource.h needs sys/time.h (for struct timeval) 2399AC_CHECK_HEADERS(sys/resource.h,,, 2400[#if TIME_WITH_SYS_TIME 2401# include <sys/time.h> 2402# include <time.h> 2403#else 2404# if HAVE_SYS_TIME_H 2405# include <sys/time.h> 2406# else 2407# include <time.h> 2408# endif 2409#endif]) 2410 2411# On NetBSD and OpenBSD, sys/sysctl.h needs sys/param.h for various constants 2412AC_CHECK_HEADERS(sys/sysctl.h,,, 2413[#if HAVE_SYS_PARAM_H 2414# include <sys/param.h> 2415#endif]) 2416 2417# On OSF 4.0, <machine/hal_sysinfo.h> must have <sys/sysinfo.h> for ulong_t 2418AC_CHECK_HEADERS(machine/hal_sysinfo.h,,, 2419[#if HAVE_SYS_SYSINFO_H 2420# include <sys/sysinfo.h> 2421#endif]) 2422 2423# Reasons for testing: 2424# optarg - not declared in mingw 2425# fgetc, fscanf, ungetc, vfprintf - not declared in SunOS 4 2426# sys_errlist, sys_nerr - not declared in SunOS 4 2427# 2428# optarg should be in unistd.h and the rest in stdio.h, both of which are 2429# in the autoconf default includes. 2430# 2431# sys_errlist and sys_nerr are supposed to be in <errno.h> on SunOS according 2432# to the man page (but aren't), in glibc they're in stdio.h. 2433# 2434AC_CHECK_DECLS([fgetc, fscanf, optarg, ungetc, vfprintf]) 2435AC_CHECK_DECLS([sys_errlist, sys_nerr], , , 2436[#include <stdio.h> 2437#include <errno.h>]) 2438 2439AC_TYPE_SIGNAL 2440 2441# Reasons for testing: 2442# intmax_t - C99 2443# long double - not in the HP bundled K&R cc 2444# long long - only in reasonably recent compilers 2445# ptrdiff_t - seems to be everywhere, maybe don't need to check this 2446# quad_t - BSD specific 2447# uint_least32_t - C99 2448# 2449# the default includes are sufficient for all these types 2450# 2451AC_CHECK_TYPES([intmax_t, long double, long long, ptrdiff_t, quad_t, 2452 uint_least32_t, intptr_t]) 2453 2454AC_C_STRINGIZE 2455 2456# FIXME: Really want #ifndef __cplusplus around the #define volatile 2457# replacement autoconf gives, since volatile is always available in C++. 2458# But we don't use it in C++ currently. 2459AC_C_VOLATILE 2460 2461AC_C_RESTRICT 2462 2463GMP_C_STDARG 2464GMP_C_ATTRIBUTE_CONST 2465GMP_C_ATTRIBUTE_MALLOC 2466GMP_C_ATTRIBUTE_MODE 2467GMP_C_ATTRIBUTE_NORETURN 2468 2469GMP_H_EXTERN_INLINE 2470 2471# from libtool 2472AC_CHECK_LIBM 2473AC_SUBST(LIBM) 2474 2475GMP_FUNC_ALLOCA 2476GMP_OPTION_ALLOCA 2477 2478GMP_H_HAVE_FILE 2479 2480AC_C_BIGENDIAN( 2481 [AC_DEFINE(HAVE_LIMB_BIG_ENDIAN, 1) 2482 GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_LIMB_BIG_ENDIAN')", POST)], 2483 [AC_DEFINE(HAVE_LIMB_LITTLE_ENDIAN, 1) 2484 GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_LIMB_LITTLE_ENDIAN')", POST) 2485 ], [:]) 2486AH_VERBATIM([HAVE_LIMB], 2487[/* Define one of these to 1 for the endianness of `mp_limb_t'. 2488 If the endianness is not a simple big or little, or you don't know what 2489 it is, then leave both undefined. */ 2490#undef HAVE_LIMB_BIG_ENDIAN 2491#undef HAVE_LIMB_LITTLE_ENDIAN]) 2492 2493GMP_C_DOUBLE_FORMAT 2494 2495 2496# Reasons for testing: 2497# alarm - not in mingw 2498# attr_get - IRIX specific 2499# clock_gettime - not in glibc 2.2.4, only very recent systems 2500# cputime - not in glibc 2501# getsysinfo - OSF specific 2502# getrusage - not in mingw 2503# gettimeofday - not in mingw 2504# mmap - not in mingw, djgpp 2505# nl_langinfo - X/Open standard only, not in djgpp for instance 2506# obstack_vprintf - glibc specific 2507# processor_info - solaris specific 2508# pstat_getprocessor - HPUX specific (10.x and up) 2509# raise - an ANSI-ism, though probably almost universal by now 2510# read_real_time - AIX specific 2511# sigaction - not in mingw 2512# sigaltstack - not in mingw, or old AIX (reputedly) 2513# sigstack - not in mingw 2514# strerror - not in SunOS 2515# strnlen - glibc extension (some other systems too) 2516# syssgi - IRIX specific 2517# times - not in mingw 2518# 2519# clock_gettime is in librt on *-*-osf5.1. We could look for it 2520# there, but that's not worth bothering with unless it has a decent 2521# resolution (in a quick test clock_getres said only 1 millisecond). 2522# 2523# AC_FUNC_STRNLEN is not used because we don't want the AC_LIBOBJ 2524# replacement setups it gives. It detects a faulty strnlen on AIX, but 2525# missing out on that test is ok since our only use of strnlen is in 2526# __gmp_replacement_vsnprintf which is not required on AIX since it has a 2527# vsnprintf. 2528# 2529AC_CHECK_FUNCS(alarm attr_get clock clock_gettime cputime getpagesize getrusage gettimeofday getsysinfo localeconv memset mmap mprotect nl_langinfo obstack_vprintf popen processor_info pstat_getprocessor raise read_real_time sigaction sigaltstack sigstack syssgi strchr strerror strnlen strtol strtoul sysconf sysctl sysctlbyname times) 2530 2531GMP_FUNC_VSNPRINTF 2532GMP_FUNC_SSCANF_WRITABLE_INPUT 2533 2534# Reasons for checking: 2535# pst_processor psp_iticksperclktick - not in hpux 9 2536# 2537AC_CHECK_MEMBER(struct pst_processor.psp_iticksperclktick, 2538 [AC_DEFINE(HAVE_PSP_ITICKSPERCLKTICK, 1, 2539[Define to 1 if <sys/pstat.h> `struct pst_processor' exists 2540and contains `psp_iticksperclktick'.])],, 2541 [#include <sys/pstat.h>]) 2542 2543# C++ tests, when required 2544# 2545if test $enable_cxx = yes; then 2546 AC_LANG_PUSH(C++) 2547 2548 # Reasons for testing: 2549 # <sstream> - not in g++ 2.95.2 2550 # std::locale - not in g++ 2.95.4 2551 # 2552 AC_CHECK_HEADERS([sstream]) 2553 AC_CHECK_TYPES([std::locale],,,[#include <locale>]) 2554 2555 AC_LANG_POP(C++) 2556fi 2557 2558 2559# Pick the correct source files in $path and link them to mpn/. 2560# $gmp_mpn_functions lists all functions we need. 2561# 2562# The rule is to find a file with the function name and a .asm, .S, 2563# .s, or .c extension. Certain multi-function files with special names 2564# can provide some functions too. (mpn/Makefile.am passes 2565# -DOPERATION_<func> to get them to generate the right code.) 2566 2567# Note: $gmp_mpn_functions must have mod_1 before pre_mod_1 so the former 2568# can optionally provide the latter as an extra entrypoint. Likewise 2569# divrem_1 and pre_divrem_1. 2570 2571gmp_mpn_functions_optional="umul udiv \ 2572 invert_limb sqr_diagonal \ 2573 mul_2 mul_3 mul_4 \ 2574 addmul_2 addmul_3 addmul_4 addmul_5 addmul_6 addmul_7 addmul_8 \ 2575 addlsh1_n sublsh1_n rsblsh1_n rsh1add_n rsh1sub_n \ 2576 addlsh2_n sublsh2_n rsblsh2_n \ 2577 addlsh_n sublsh_n rsblsh_n \ 2578 add_n_sub_n addaddmul_1msb0" 2579 2580gmp_mpn_functions="$extra_functions \ 2581 add add_1 add_n sub sub_1 sub_n neg com mul_1 addmul_1 \ 2582 submul_1 lshift rshift dive_1 diveby3 divis divrem divrem_1 divrem_2 \ 2583 fib2_ui mod_1 mod_34lsub1 mode1o pre_divrem_1 pre_mod_1 dump \ 2584 mod_1_1 mod_1_2 mod_1_3 mod_1_4 lshiftc \ 2585 mul mul_fft mul_n sqr mul_basecase sqr_basecase nussbaumer_mul \ 2586 random random2 pow_1 \ 2587 rootrem sqrtrem get_str set_str scan0 scan1 popcount hamdist cmp \ 2588 perfsqr perfpow \ 2589 gcd_1 gcd gcdext_1 gcdext gcd_lehmer gcd_subdiv_step \ 2590 gcdext_lehmer gcdext_subdiv_step \ 2591 div_q tdiv_qr jacbase get_d \ 2592 matrix22_mul hgcd2 hgcd mullo_n mullo_basecase \ 2593 toom22_mul toom32_mul toom42_mul toom52_mul toom62_mul \ 2594 toom33_mul toom43_mul toom53_mul toom63_mul \ 2595 toom44_mul \ 2596 toom6h_mul toom6_sqr toom8h_mul toom8_sqr \ 2597 toom_couple_handling \ 2598 toom2_sqr toom3_sqr toom4_sqr \ 2599 toom_eval_dgr3_pm1 toom_eval_dgr3_pm2 \ 2600 toom_eval_pm1 toom_eval_pm2 toom_eval_pm2exp toom_eval_pm2rexp \ 2601 toom_interpolate_5pts toom_interpolate_6pts toom_interpolate_7pts \ 2602 toom_interpolate_8pts toom_interpolate_12pts toom_interpolate_16pts \ 2603 invertappr invert binvert mulmod_bnm1 sqrmod_bnm1 \ 2604 sbpi1_div_q sbpi1_div_qr sbpi1_divappr_q \ 2605 dcpi1_div_q dcpi1_div_qr dcpi1_divappr_q \ 2606 mu_div_qr mu_divappr_q mu_div_q \ 2607 bdiv_q_1 \ 2608 sbpi1_bdiv_q sbpi1_bdiv_qr \ 2609 dcpi1_bdiv_q dcpi1_bdiv_qr \ 2610 mu_bdiv_q mu_bdiv_qr \ 2611 bdiv_q bdiv_qr \ 2612 divexact bdiv_dbm1c redc_1 redc_2 redc_n powm powlo powm_sec subcnd_n \ 2613 redc_1_sec trialdiv remove \ 2614 and_n andn_n nand_n ior_n iorn_n nior_n xor_n xnor_n \ 2615 copyi copyd zero \ 2616 $gmp_mpn_functions_optional" 2617 2618define(GMP_MULFUNC_CHOICES, 2619[# functions that can be provided by multi-function files 2620tmp_mulfunc= 2621case $tmp_fn in 2622 add_n|sub_n) tmp_mulfunc="aors_n" ;; 2623 addmul_1|submul_1) tmp_mulfunc="aorsmul_1" ;; 2624 popcount|hamdist) tmp_mulfunc="popham" ;; 2625 and_n|andn_n|nand_n | ior_n|iorn_n|nior_n | xor_n|xnor_n) 2626 tmp_mulfunc="logops_n" ;; 2627 lshift|rshift) tmp_mulfunc="lorrshift";; 2628 addlsh1_n) 2629 tmp_mulfunc="aorslsh1_n aorrlsh1_n";; 2630 sublsh1_n) 2631 tmp_mulfunc="aorslsh1_n sorrlsh1_n";; 2632 rsblsh1_n) 2633 tmp_mulfunc="aorrlsh1_n sorrlsh1_n";; 2634 addlsh2_n) 2635 tmp_mulfunc="aorslsh2_n aorrlsh2_n";; 2636 sublsh2_n) 2637 tmp_mulfunc="aorslsh2_n sorrlsh2_n";; 2638 rsblsh2_n) 2639 tmp_mulfunc="aorrlsh2_n sorrlsh2_n";; 2640 addlsh_n) 2641 tmp_mulfunc="aorslsh_n aorrlsh_n";; 2642 sublsh_n) 2643 tmp_mulfunc="aorslsh_n sorrlsh_n";; 2644 rsblsh_n) 2645 tmp_mulfunc="aorrlsh_n sorrlsh_n";; 2646 rsh1add_n|rsh1sub_n) 2647 tmp_mulfunc="rsh1aors_n";; 2648esac 2649]) 2650 2651# the list of all object files used by mpn/Makefile.in and the 2652# top-level Makefile.in, respectively 2653mpn_objects= 2654mpn_objs_in_libgmp= 2655 2656# links from the sources, to be removed by "make distclean" 2657gmp_srclinks= 2658 2659 2660# mpn_relative_top_srcdir is $top_srcdir, but for use from within the mpn 2661# build directory. If $srcdir is relative then we use a relative path too, 2662# so the two trees can be moved together. 2663case $srcdir in 2664 [[\\/]* | ?:[\\/]*]) # absolute, as per autoconf 2665 mpn_relative_top_srcdir=$srcdir ;; 2666 *) # relative 2667 mpn_relative_top_srcdir=../$srcdir ;; 2668esac 2669 2670 2671define(MPN_SUFFIXES,[asm S s c]) 2672 2673dnl Usage: GMP_FILE_TO_FUNCTION_BASE(func,file) 2674dnl 2675dnl Set $func to the function base name for $file, eg. dive_1 gives 2676dnl divexact_1. 2677dnl 2678define(GMP_FILE_TO_FUNCTION, 2679[case $$2 in 2680 dive_1) $1=divexact_1 ;; 2681 diveby3) $1=divexact_by3c ;; 2682 pre_divrem_1) $1=preinv_divrem_1 ;; 2683 mode1o) $1=modexact_1c_odd ;; 2684 pre_mod_1) $1=preinv_mod_1 ;; 2685 *) $1=$$2 ;; 2686esac 2687]) 2688 2689# Fat binary setups. 2690# 2691# We proceed through each $fat_path directory, and look for $fat_function 2692# routines there. Those found are incorporated in the build by generating a 2693# little mpn/<foo>.asm or mpn/<foo>.c file in the build directory, with 2694# suitable function renaming, and adding that to $mpn_objects (the same as a 2695# normal mpn file). 2696# 2697# fat.h is generated with macros to let internal calls to each $fat_function 2698# go directly through __gmpn_cpuvec, plus macros and declarations helping to 2699# setup that structure, on a per-directory basis ready for 2700# mpn/<cpu>/fat/fat.c. 2701# 2702# fat.h includes thresholds listed in $fat_thresholds, extracted from 2703# gmp-mparam.h in each directory. An overall maximum for each threshold is 2704# established, for use in making fixed size arrays of temporary space. 2705# (Eg. MUL_TOOM33_THRESHOLD_LIMIT used by mpn/generic/mul.c.) 2706# 2707# It'd be possible to do some of this manually, but when there's more than a 2708# few functions and a few directories it becomes very tedious, and very 2709# prone to having some routine accidentally omitted. On that basis it seems 2710# best to automate as much as possible, even if the code to do so is a bit 2711# ugly. 2712# 2713 2714if test -n "$fat_path"; then 2715 # Usually the mpn build directory is created with mpn/Makefile 2716 # instantiation, but we want to write to it sooner. 2717 mkdir mpn 2>/dev/null 2718 2719 echo "/* fat.h - setups for fat binaries." >fat.h 2720 echo " Generated by configure - DO NOT EDIT. */" >>fat.h 2721 2722 AC_DEFINE(WANT_FAT_BINARY, 1, [Define to 1 when building a fat binary.]) 2723 GMP_DEFINE(WANT_FAT_BINARY, yes) 2724 2725 # Don't want normal copies of fat functions 2726 for tmp_fn in $fat_functions; do 2727 GMP_REMOVE_FROM_LIST(gmp_mpn_functions, $tmp_fn) 2728 GMP_REMOVE_FROM_LIST(gmp_mpn_functions_optional, $tmp_fn) 2729 done 2730 2731 for tmp_fn in $fat_functions; do 2732 GMP_FILE_TO_FUNCTION(tmp_fbase,tmp_fn) 2733 echo " 2734#ifndef OPERATION_$tmp_fn 2735#undef mpn_$tmp_fbase 2736#define mpn_$tmp_fbase (*__gmpn_cpuvec.$tmp_fbase) 2737#endif 2738DECL_$tmp_fbase (__MPN(${tmp_fbase}_init));" >>fat.h 2739 # encourage various macros to use fat functions 2740 AC_DEFINE_UNQUOTED(HAVE_NATIVE_mpn_$tmp_fbase) 2741 done 2742 2743 echo "" >>fat.h 2744 echo "/* variable thresholds */" >>fat.h 2745 for tmp_tn in $fat_thresholds; do 2746 echo "#undef $tmp_tn" >>fat.h 2747 echo "#define $tmp_tn CPUVEC_THRESHOLD (`echo $tmp_tn | tr [A-Z] [a-z]`)" >>fat.h 2748 done 2749 2750 echo " 2751/* Copy all fields into __gmpn_cpuvec. 2752 memcpy is not used because it might operate byte-wise (depending on its 2753 implementation), and we need the function pointer writes to be atomic. 2754 "volatile" discourages the compiler from trying to optimize this. */ 2755#define CPUVEC_INSTALL(vec) \\ 2756 do { \\ 2757 volatile struct cpuvec_t *p = &__gmpn_cpuvec; \\" >>fat.h 2758 for tmp_fn in $fat_functions; do 2759 GMP_FILE_TO_FUNCTION(tmp_fbase,tmp_fn) 2760 echo " p->$tmp_fbase = vec.$tmp_fbase; \\" >>fat.h 2761 done 2762 for tmp_tn in $fat_thresholds; do 2763 tmp_field_name=`echo $tmp_tn | tr [[A-Z]] [[a-z]]` 2764 echo " p->$tmp_field_name = vec.$tmp_field_name; \\" >>fat.h 2765 done 2766 echo " } while (0)" >>fat.h 2767 2768 echo " 2769/* A helper to check all fields are filled. */ 2770#define ASSERT_CPUVEC(vec) \\ 2771 do { \\" >>fat.h 2772 for tmp_fn in $fat_functions; do 2773 GMP_FILE_TO_FUNCTION(tmp_fbase,tmp_fn) 2774 echo " ASSERT (vec.$tmp_fbase != NULL); \\" >>fat.h 2775 done 2776 for tmp_tn in $fat_thresholds; do 2777 tmp_field_name=`echo $tmp_tn | tr [[A-Z]] [[a-z]]` 2778 echo " ASSERT (vec.$tmp_field_name != 0); \\" >>fat.h 2779 done 2780 echo " } while (0)" >>fat.h 2781 2782 echo " 2783/* Call ITERATE(field) for each fat threshold field. */ 2784#define ITERATE_FAT_THRESHOLDS() \\ 2785 do { \\" >>fat.h 2786 for tmp_tn in $fat_thresholds; do 2787 tmp_field_name=`echo $tmp_tn | tr [[A-Z]] [[a-z]]` 2788 echo " ITERATE ($tmp_tn, $tmp_field_name); \\" >>fat.h 2789 done 2790 echo " } while (0)" >>fat.h 2791 2792 for tmp_dir in $fat_path; do 2793 CPUVEC_SETUP= 2794 THRESH_ASM_SETUP= 2795 echo "" >>fat.h 2796 GMP_FAT_SUFFIX(tmp_suffix, $tmp_dir) 2797 2798 # In order to keep names unique on a DOS 8.3 filesystem, use a prefix 2799 # (rather than a suffix) for the generated file names, and abbreviate. 2800 case $tmp_suffix in 2801 pentium) tmp_prefix=p ;; 2802 pentium_mmx) tmp_prefix=pm ;; 2803 p6_mmx) tmp_prefix=p2 ;; 2804 p6_p3mmx) tmp_prefix=p3 ;; 2805 pentium4) tmp_prefix=p4 ;; 2806 pentium4_mmx) tmp_prefix=p4m ;; 2807 pentium4_sse2) tmp_prefix=p4s ;; 2808 k6_mmx) tmp_prefix=k6m ;; 2809 k6_k62mmx) tmp_prefix=k62 ;; 2810 k7_mmx) tmp_prefix=k7m ;; 2811 *) tmp_prefix=$tmp_suffix ;; 2812 esac 2813 2814 # Extract desired thresholds from gmp-mparam.h file in this directory, 2815 # if present. 2816 tmp_mparam=$srcdir/mpn/$tmp_dir/gmp-mparam.h 2817 if test -f $tmp_mparam; then 2818 for tmp_tn in $fat_thresholds; do 2819 tmp_thresh=`sed -n "s/^#define $tmp_tn[ ]*\\([0-9][0-9]*\\).*$/\\1/p" $tmp_mparam` 2820 if test -n "$tmp_thresh"; then 2821 THRESH_ASM_SETUP=["${THRESH_ASM_SETUP}define($tmp_tn,$tmp_thresh) 2822"] 2823 CPUVEC_SETUP="$CPUVEC_SETUP decided_cpuvec.`echo $tmp_tn | tr [[A-Z]] [[a-z]]` = $tmp_thresh; \\ 2824" 2825 eval tmp_limit=\$${tmp_tn}_LIMIT 2826 if test -z "$tmp_limit"; then 2827 tmp_limit=0 2828 fi 2829 if test $tmp_thresh -gt $tmp_limit; then 2830 eval ${tmp_tn}_LIMIT=$tmp_thresh 2831 fi 2832 fi 2833 done 2834 fi 2835 2836 for tmp_fn in $fat_functions; do 2837 GMP_MULFUNC_CHOICES 2838 2839 for tmp_base in $tmp_fn $tmp_mulfunc; do 2840 for tmp_ext in MPN_SUFFIXES; do 2841 tmp_file=$srcdir/mpn/$tmp_dir/$tmp_base.$tmp_ext 2842 if test -f $tmp_file; then 2843 2844 mpn_objects="$mpn_objects ${tmp_prefix}_$tmp_fn.lo" 2845 mpn_objs_in_libgmp="$mpn_objs_in_libgmp mpn/${tmp_prefix}_$tmp_fn.lo" 2846 2847 GMP_FILE_TO_FUNCTION(tmp_fbase,tmp_fn) 2848 2849 # carry-in variant, eg. divrem_1c or modexact_1c_odd 2850 case $tmp_fbase in 2851 *_1*) tmp_fbasec=`echo $tmp_fbase | sed 's/_1/_1c/'` ;; 2852 *) tmp_fbasec=${tmp_fbase}c ;; 2853 esac 2854 2855 # Create a little file doing an include from srcdir. The 2856 # OPERATION and renamings aren't all needed all the time, but 2857 # they don't hurt if unused. 2858 # 2859 # FIXME: Should generate these via config.status commands. 2860 # Would need them all in one AC_CONFIG_COMMANDS though, since 2861 # that macro doesn't accept a set of separate commands generated 2862 # by shell code. 2863 # 2864 case $tmp_ext in 2865 asm) 2866 # hide the d-n-l from autoconf's error checking 2867 tmp_d_n_l=d""nl 2868 echo ["$tmp_d_n_l mpn_$tmp_fbase - from $tmp_dir directory for fat binary. 2869$tmp_d_n_l Generated by configure - DO NOT EDIT. 2870 2871define(OPERATION_$tmp_fn) 2872define(__gmpn_$tmp_fbase, __gmpn_${tmp_fbase}_$tmp_suffix) 2873define(__gmpn_$tmp_fbasec,__gmpn_${tmp_fbasec}_${tmp_suffix}) 2874define(__gmpn_preinv_${tmp_fbase},__gmpn_preinv_${tmp_fbase}_${tmp_suffix}) 2875 2876$tmp_d_n_l For k6 and k7 gcd_1 calling their corresponding mpn_modexact_1_odd 2877ifdef(\`__gmpn_modexact_1_odd',, 2878\`define(__gmpn_modexact_1_odd,__gmpn_modexact_1_odd_${tmp_suffix})') 2879 2880$THRESH_ASM_SETUP 2881include][($mpn_relative_top_srcdir/mpn/$tmp_dir/$tmp_base.asm) 2882"] >mpn/${tmp_prefix}_$tmp_fn.asm 2883 ;; 2884 c) 2885 echo ["/* mpn_$tmp_fbase - from $tmp_dir directory for fat binary. 2886 Generated by configure - DO NOT EDIT. */ 2887 2888#define OPERATION_$tmp_fn 1 2889#define __gmpn_$tmp_fbase __gmpn_${tmp_fbase}_$tmp_suffix 2890#define __gmpn_$tmp_fbasec __gmpn_${tmp_fbasec}_${tmp_suffix} 2891#define __gmpn_preinv_${tmp_fbase} __gmpn_preinv_${tmp_fbase}_${tmp_suffix} 2892 2893#include \"$mpn_relative_top_srcdir/mpn/$tmp_dir/$tmp_base.c\" 2894"] >mpn/${tmp_prefix}_$tmp_fn.c 2895 ;; 2896 esac 2897 2898 # Prototype, and append to CPUVEC_SETUP for this directory. 2899 echo "DECL_$tmp_fbase (__gmpn_${tmp_fbase}_$tmp_suffix);" >>fat.h 2900 CPUVEC_SETUP="$CPUVEC_SETUP decided_cpuvec.$tmp_fbase = __gmpn_${tmp_fbase}_${tmp_suffix}; \\ 2901" 2902 # Ditto for any preinv variant (preinv_divrem_1, preinv_mod_1). 2903 if grep "^PROLOGUE(mpn_preinv_$tmp_fn)" $tmp_file >/dev/null; then 2904 echo "DECL_preinv_$tmp_fbase (__gmpn_preinv_${tmp_fbase}_$tmp_suffix);" >>fat.h 2905 CPUVEC_SETUP="$CPUVEC_SETUP decided_cpuvec.preinv_$tmp_fbase = __gmpn_preinv_${tmp_fbase}_${tmp_suffix}; \\ 2906" 2907 fi 2908 fi 2909 done 2910 done 2911 done 2912 2913 # Emit CPUVEC_SETUP for this directory 2914 echo "" >>fat.h 2915 echo "#define CPUVEC_SETUP_$tmp_suffix \\" >>fat.h 2916 echo " do { \\" >>fat.h 2917 echo "$CPUVEC_SETUP } while (0)" >>fat.h 2918 done 2919 2920 # Emit threshold limits 2921 echo "" >>fat.h 2922 for tmp_tn in $fat_thresholds; do 2923 eval tmp_limit=\$${tmp_tn}_LIMIT 2924 echo "#define ${tmp_tn}_LIMIT $tmp_limit" >>fat.h 2925 done 2926fi 2927 2928 2929# Normal binary setups. 2930# 2931 2932for tmp_ext in MPN_SUFFIXES; do 2933 eval found_$tmp_ext=no 2934done 2935 2936for tmp_fn in $gmp_mpn_functions; do 2937 for tmp_ext in MPN_SUFFIXES; do 2938 test "$no_create" = yes || rm -f mpn/$tmp_fn.$tmp_ext 2939 done 2940 2941 # mpn_preinv_divrem_1 might have been provided by divrem_1.asm, likewise 2942 # mpn_preinv_mod_1 by mod_1.asm. 2943 case $tmp_fn in 2944 pre_divrem_1) 2945 if test "$HAVE_NATIVE_mpn_preinv_divrem_1" = yes; then continue; fi ;; 2946 pre_mod_1) 2947 if test "$HAVE_NATIVE_mpn_preinv_mod_1" = yes; then continue; fi ;; 2948 esac 2949 2950 GMP_MULFUNC_CHOICES 2951 2952 found=no 2953 for tmp_dir in $path; do 2954 for tmp_base in $tmp_fn $tmp_mulfunc; do 2955 for tmp_ext in MPN_SUFFIXES; do 2956 tmp_file=$srcdir/mpn/$tmp_dir/$tmp_base.$tmp_ext 2957 if test -f $tmp_file; then 2958 2959 # For a nails build, check if the file supports our nail bits. 2960 # Generic code always supports all nails. 2961 # 2962 # FIXME: When a multi-function file is selected to provide one of 2963 # the nails-neutral routines, like logops_n for and_n, the 2964 # PROLOGUE grepping will create HAVE_NATIVE_mpn_<foo> defines for 2965 # all functions in that file, even if they haven't all been 2966 # nailified. Not sure what to do about this, it's only really a 2967 # problem for logops_n, and it's not too terrible to insist those 2968 # get nailified always. 2969 # 2970 if test $GMP_NAIL_BITS != 0 && test $tmp_dir != generic; then 2971 case $tmp_fn in 2972 and_n | ior_n | xor_n | andn_n | \ 2973 copyi | copyd | \ 2974 popcount | hamdist | \ 2975 udiv | udiv_w_sdiv | umul | \ 2976 cntlz | invert_limb) 2977 # these operations are either unaffected by nails or defined 2978 # to operate on full limbs 2979 ;; 2980 *) 2981 nails=[`sed -n 's/^[ ]*NAILS_SUPPORT(\(.*\))/\1/p' $tmp_file `] 2982 for n in $nails; do 2983 case $n in 2984 *-*) 2985 n_start=`echo "$n" | sed -n 's/\(.*\)-.*/\1/p'` 2986 n_end=`echo "$n" | sed -n 's/.*-\(.*\)/\1/p'` 2987 ;; 2988 *) 2989 n_start=$n 2990 n_end=$n 2991 ;; 2992 esac 2993 if test $GMP_NAIL_BITS -ge $n_start && test $GMP_NAIL_BITS -le $n_end; then 2994 found=yes 2995 break 2996 fi 2997 done 2998 if test $found != yes; then 2999 continue 3000 fi 3001 ;; 3002 esac 3003 fi 3004 3005 found=yes 3006 eval found_$tmp_ext=yes 3007 3008 if test $tmp_ext = c; then 3009 tmp_u='$U' 3010 else 3011 tmp_u= 3012 fi 3013 3014 mpn_objects="$mpn_objects $tmp_fn$tmp_u.lo" 3015 mpn_objs_in_libgmp="$mpn_objs_in_libgmp mpn/$tmp_fn$tmp_u.lo" 3016 AC_CONFIG_LINKS(mpn/$tmp_fn.$tmp_ext:mpn/$tmp_dir/$tmp_base.$tmp_ext) 3017 gmp_srclinks="$gmp_srclinks mpn/$tmp_fn.$tmp_ext" 3018 3019 # Duplicate AC_DEFINEs are harmless, so it doesn't matter 3020 # that multi-function files get grepped here repeatedly. 3021 # The PROLOGUE pattern excludes the optional second parameter. 3022 gmp_ep=[` 3023 sed -n 's/^[ ]*MULFUNC_PROLOGUE(\(.*\))/\1/p' $tmp_file ; 3024 sed -n 's/^[ ]*PROLOGUE(\([^,]*\).*)/\1/p' $tmp_file 3025 `] 3026 for gmp_tmp in $gmp_ep; do 3027 AC_DEFINE_UNQUOTED(HAVE_NATIVE_$gmp_tmp) 3028 eval HAVE_NATIVE_$gmp_tmp=yes 3029 done 3030 3031 case $tmp_fn in 3032 sqr_basecase) sqr_basecase_source=$tmp_file ;; 3033 esac 3034 3035 break 3036 fi 3037 done 3038 if test $found = yes; then break ; fi 3039 done 3040 if test $found = yes; then break ; fi 3041 done 3042 3043 if test $found = no; then 3044 for tmp_optional in $gmp_mpn_functions_optional; do 3045 if test $tmp_optional = $tmp_fn; then 3046 found=yes 3047 fi 3048 done 3049 if test $found = no; then 3050 AC_MSG_ERROR([no version of $tmp_fn found in path: $path]) 3051 fi 3052 fi 3053done 3054 3055# All cycle counters are .asm files currently 3056if test -n "$SPEED_CYCLECOUNTER_OBJ"; then 3057 found_asm=yes 3058fi 3059 3060dnl The following list only needs to have templates for those defines which 3061dnl are going to be tested by the code, there's no need to have every 3062dnl possible mpn routine. 3063 3064AH_VERBATIM([HAVE_NATIVE], 3065[/* Define to 1 each of the following for which a native (ie. CPU specific) 3066 implementation of the corresponding routine exists. */ 3067#undef HAVE_NATIVE_mpn_add_n 3068#undef HAVE_NATIVE_mpn_add_n_sub_n 3069#undef HAVE_NATIVE_mpn_add_nc 3070#undef HAVE_NATIVE_mpn_addaddmul_1msb0 3071#undef HAVE_NATIVE_mpn_addlsh1_n 3072#undef HAVE_NATIVE_mpn_addlsh2_n 3073#undef HAVE_NATIVE_mpn_addlsh_n 3074#undef HAVE_NATIVE_mpn_addmul_1c 3075#undef HAVE_NATIVE_mpn_addmul_2 3076#undef HAVE_NATIVE_mpn_addmul_3 3077#undef HAVE_NATIVE_mpn_addmul_4 3078#undef HAVE_NATIVE_mpn_addmul_5 3079#undef HAVE_NATIVE_mpn_addmul_6 3080#undef HAVE_NATIVE_mpn_addmul_7 3081#undef HAVE_NATIVE_mpn_addmul_8 3082#undef HAVE_NATIVE_mpn_and_n 3083#undef HAVE_NATIVE_mpn_andn_n 3084#undef HAVE_NATIVE_mpn_bdiv_dbm1c 3085#undef HAVE_NATIVE_mpn_bdiv_q_1 3086#undef HAVE_NATIVE_mpn_pi1_bdiv_q_1 3087#undef HAVE_NATIVE_mpn_com 3088#undef HAVE_NATIVE_mpn_copyd 3089#undef HAVE_NATIVE_mpn_copyi 3090#undef HAVE_NATIVE_mpn_divexact_1 3091#undef HAVE_NATIVE_mpn_divexact_by3c 3092#undef HAVE_NATIVE_mpn_divrem_1 3093#undef HAVE_NATIVE_mpn_divrem_1c 3094#undef HAVE_NATIVE_mpn_divrem_2 3095#undef HAVE_NATIVE_mpn_gcd_1 3096#undef HAVE_NATIVE_mpn_hamdist 3097#undef HAVE_NATIVE_mpn_invert_limb 3098#undef HAVE_NATIVE_mpn_ior_n 3099#undef HAVE_NATIVE_mpn_iorn_n 3100#undef HAVE_NATIVE_mpn_lshift 3101#undef HAVE_NATIVE_mpn_lshiftc 3102#undef HAVE_NATIVE_mpn_lshsub_n 3103#undef HAVE_NATIVE_mpn_mod_1 3104#undef HAVE_NATIVE_mpn_mod_1_1p 3105#undef HAVE_NATIVE_mpn_mod_1c 3106#undef HAVE_NATIVE_mpn_mod_1s_2p 3107#undef HAVE_NATIVE_mpn_mod_1s_4p 3108#undef HAVE_NATIVE_mpn_mod_34lsub1 3109#undef HAVE_NATIVE_mpn_modexact_1_odd 3110#undef HAVE_NATIVE_mpn_modexact_1c_odd 3111#undef HAVE_NATIVE_mpn_mul_1 3112#undef HAVE_NATIVE_mpn_mul_1c 3113#undef HAVE_NATIVE_mpn_mul_2 3114#undef HAVE_NATIVE_mpn_mul_3 3115#undef HAVE_NATIVE_mpn_mul_4 3116#undef HAVE_NATIVE_mpn_mul_basecase 3117#undef HAVE_NATIVE_mpn_nand_n 3118#undef HAVE_NATIVE_mpn_nior_n 3119#undef HAVE_NATIVE_mpn_popcount 3120#undef HAVE_NATIVE_mpn_preinv_divrem_1 3121#undef HAVE_NATIVE_mpn_preinv_mod_1 3122#undef HAVE_NATIVE_mpn_redc_1 3123#undef HAVE_NATIVE_mpn_redc_2 3124#undef HAVE_NATIVE_mpn_rsblsh1_n 3125#undef HAVE_NATIVE_mpn_rsblsh2_n 3126#undef HAVE_NATIVE_mpn_rsblsh_n 3127#undef HAVE_NATIVE_mpn_rsh1add_n 3128#undef HAVE_NATIVE_mpn_rsh1add_nc 3129#undef HAVE_NATIVE_mpn_rsh1sub_n 3130#undef HAVE_NATIVE_mpn_rsh1sub_nc 3131#undef HAVE_NATIVE_mpn_rshift 3132#undef HAVE_NATIVE_mpn_sqr_basecase 3133#undef HAVE_NATIVE_mpn_sqr_diagonal 3134#undef HAVE_NATIVE_mpn_sub_n 3135#undef HAVE_NATIVE_mpn_sub_nc 3136#undef HAVE_NATIVE_mpn_sublsh1_n 3137#undef HAVE_NATIVE_mpn_sublsh2_n 3138#undef HAVE_NATIVE_mpn_sublsh_n 3139#undef HAVE_NATIVE_mpn_submul_1c 3140#undef HAVE_NATIVE_mpn_udiv_qrnnd 3141#undef HAVE_NATIVE_mpn_udiv_qrnnd_r 3142#undef HAVE_NATIVE_mpn_umul_ppmm 3143#undef HAVE_NATIVE_mpn_umul_ppmm_r 3144#undef HAVE_NATIVE_mpn_xor_n 3145#undef HAVE_NATIVE_mpn_xnor_n]) 3146 3147 3148# Don't demand an m4 unless it's actually needed. 3149if test $found_asm = yes; then 3150 GMP_PROG_M4 3151 GMP_M4_M4WRAP_SPURIOUS 3152# else 3153# It's unclear why this m4-not-needed stuff was ever done. 3154# if test -z "$M4" ; then 3155# M4=m4-not-needed 3156# fi 3157fi 3158 3159# Only do the GMP_ASM checks if there's a .S or .asm wanting them. 3160if test $found_asm = no && test $found_S = no; then 3161 gmp_asm_syntax_testing=no 3162fi 3163 3164if test "$gmp_asm_syntax_testing" != no; then 3165 GMP_ASM_TEXT 3166 GMP_ASM_DATA 3167 GMP_ASM_LABEL_SUFFIX 3168 GMP_ASM_GLOBL 3169 GMP_ASM_GLOBL_ATTR 3170 GMP_ASM_UNDERSCORE 3171 GMP_ASM_RODATA 3172 GMP_ASM_TYPE 3173 GMP_ASM_SIZE 3174 GMP_ASM_LSYM_PREFIX 3175 GMP_ASM_W32 3176 GMP_ASM_ALIGN_LOG 3177 3178 case $host in 3179 hppa*-*-*) 3180 # for both pa32 and pa64 3181 GMP_INCLUDE_MPN(pa32/pa-defs.m4) 3182 ;; 3183 IA64_PATTERN) 3184 GMP_ASM_IA64_ALIGN_OK 3185 ;; 3186 M68K_PATTERN) 3187 GMP_ASM_M68K_INSTRUCTION 3188 GMP_ASM_M68K_ADDRESSING 3189 GMP_ASM_M68K_BRANCHES 3190 ;; 3191 [powerpc*-*-* | power[3-9]-*-*]) 3192 GMP_ASM_POWERPC_PIC_ALWAYS 3193 GMP_ASM_POWERPC_R_REGISTERS 3194 GMP_INCLUDE_MPN(powerpc32/powerpc-defs.m4) 3195 case $host in 3196 *-*-aix*) 3197 case $ABI in 3198 64 | aix64) GMP_INCLUDE_MPN(powerpc64/aix.m4) ;; 3199 *) GMP_INCLUDE_MPN(powerpc32/aix.m4) ;; 3200 esac 3201 ;; 3202 *-*-linux* | *-*-*bsd*) 3203 case $ABI in 3204 mode64) GMP_INCLUDE_MPN(powerpc64/elf.m4) ;; 3205 mode32 | 32) GMP_INCLUDE_MPN(powerpc32/elf.m4) ;; 3206 esac 3207 ;; 3208 *-*-darwin*) 3209 case $ABI in 3210 mode64) GMP_INCLUDE_MPN(powerpc64/darwin.m4) ;; 3211 mode32 | 32) GMP_INCLUDE_MPN(powerpc32/darwin.m4) ;; 3212 esac 3213 ;; 3214 *) 3215 # Assume unrecognized operating system is the powerpc eABI 3216 GMP_INCLUDE_MPN(powerpc32/eabi.m4) 3217 ;; 3218 esac 3219 ;; 3220 power*-*-aix*) 3221 GMP_INCLUDE_MPN(powerpc32/aix.m4) 3222 ;; 3223 sparcv9*-*-* | ultrasparc*-*-* | sparc64-*-*) 3224 case $ABI in 3225 64) 3226 GMP_ASM_SPARC_REGISTER 3227 ;; 3228 esac 3229 ;; 3230 X86_PATTERN | X86_64_PATTERN) 3231 GMP_ASM_ALIGN_FILL_0x90 3232 case $ABI in 3233 32) 3234 GMP_INCLUDE_MPN(x86/x86-defs.m4) 3235 AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86) 3236 GMP_ASM_COFF_TYPE 3237 GMP_ASM_X86_GOT_UNDERSCORE 3238 GMP_ASM_X86_SHLDL_CL 3239 case $enable_profiling in 3240 prof | gprof) GMP_ASM_X86_MCOUNT ;; 3241 esac 3242 case $host in 3243 *-*-darwin*) 3244 GMP_INCLUDE_MPN(x86/darwin.m4) ;; 3245 esac 3246 ;; 3247 64) 3248 GMP_INCLUDE_MPN(x86_64/x86_64-defs.m4) 3249 AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86_64) 3250 case $host in 3251 *-*-darwin*) 3252 GMP_INCLUDE_MPN(x86_64/darwin.m4) ;; 3253 esac 3254 ;; 3255 esac 3256 ;; 3257 esac 3258fi 3259 3260# For --enable-minithres, prepend "minithres" to path so that its special 3261# gmp-mparam.h will be used. 3262if test $enable_minithres = yes; then 3263 path="minithres $path" 3264fi 3265 3266# Create link for gmp-mparam.h. 3267gmp_mparam_source= 3268for gmp_mparam_dir in $path; do 3269 test "$no_create" = yes || rm -f gmp-mparam.h 3270 tmp_file=$srcdir/mpn/$gmp_mparam_dir/gmp-mparam.h 3271 if test -f $tmp_file; then 3272 AC_CONFIG_LINKS(gmp-mparam.h:mpn/$gmp_mparam_dir/gmp-mparam.h) 3273 gmp_srclinks="$gmp_srclinks gmp-mparam.h" 3274 gmp_mparam_source=$tmp_file 3275 break 3276 fi 3277done 3278if test -z "$gmp_mparam_source"; then 3279 AC_MSG_ERROR([no version of gmp-mparam.h found in path: $path]) 3280fi 3281 3282# For a helpful message from tune/tuneup.c 3283gmp_mparam_suggest=$gmp_mparam_source 3284if test "$gmp_mparam_dir" = generic; then 3285 for i in $path; do break; done 3286 if test "$i" != generic; then 3287 gmp_mparam_suggest="new file $srcdir/mpn/$i/gmp-mparam.h" 3288 fi 3289fi 3290AC_DEFINE_UNQUOTED(GMP_MPARAM_H_SUGGEST, "$gmp_mparam_source", 3291[The gmp-mparam.h file (a string) the tune program should suggest updating.]) 3292 3293 3294# Copy any SQR_TOOM2_THRESHOLD from gmp-mparam.h to config.m4. 3295# Some versions of sqr_basecase.asm use this. 3296# Fat binaries do this on a per-file basis, so skip in that case. 3297# 3298if test -z "$fat_path"; then 3299 tmp_gmp_karatsuba_sqr_threshold=`sed -n 's/^#define SQR_TOOM2_THRESHOLD[ ]*\([0-9][0-9]*\).*$/\1/p' $gmp_mparam_source` 3300 if test -n "$tmp_gmp_karatsuba_sqr_threshold"; then 3301 GMP_DEFINE_RAW(["define(<SQR_TOOM2_THRESHOLD>,<$tmp_gmp_karatsuba_sqr_threshold>)"]) 3302 fi 3303fi 3304 3305 3306# Sizes of some types, needed at preprocessing time. 3307# 3308# FIXME: The assumption that GMP_LIMB_BITS is 8*sizeof(mp_limb_t) might 3309# be slightly rash, but it's true everywhere we know of and ought to be true 3310# of any sensible system. In a generic C build, grepping LONG_BIT out of 3311# <limits.h> might be an alternative, for maximum portability. 3312# 3313AC_CHECK_SIZEOF(void *) 3314AC_CHECK_SIZEOF(unsigned short) 3315AC_CHECK_SIZEOF(unsigned) 3316AC_CHECK_SIZEOF(unsigned long) 3317AC_CHECK_SIZEOF(mp_limb_t, , GMP_INCLUDE_GMP_H) 3318if test "$ac_cv_sizeof_mp_limb_t" = 0; then 3319 AC_MSG_ERROR([Oops, mp_limb_t doesn't seem to work]) 3320fi 3321AC_SUBST(GMP_LIMB_BITS, `expr 8 \* $ac_cv_sizeof_mp_limb_t`) 3322GMP_DEFINE_RAW(["define(<SIZEOF_UNSIGNED>,<$ac_cv_sizeof_unsigned>)"]) 3323 3324# Check compiler limb size matches gmp-mparam.h 3325# 3326# FIXME: Some of the cycle counter objects in the tune directory depend on 3327# the size of ulong, it'd be possible to check that here, though a mismatch 3328# probably wouldn't want to be fatal, none of the libgmp assembler code 3329# depends on ulong. 3330# 3331mparam_bits=[`sed -n 's/^#define GMP_LIMB_BITS[ ][ ]*\([0-9]*\).*$/\1/p' $gmp_mparam_source`] 3332if test -n "$mparam_bits" && test "$mparam_bits" -ne $GMP_LIMB_BITS; then 3333 if test "$test_CFLAGS" = set; then 3334 AC_MSG_ERROR([Oops, mp_limb_t is $GMP_LIMB_BITS bits, but the assembler code 3335in this configuration expects $mparam_bits bits. 3336You appear to have set \$CFLAGS, perhaps you also need to tell GMP the 3337intended ABI, see "ABI and ISA" in the manual.]) 3338 else 3339 AC_MSG_ERROR([Oops, mp_limb_t is $GMP_LIMB_BITS bits, but the assembler code 3340in this configuration expects $mparam_bits bits.]) 3341 fi 3342fi 3343 3344GMP_DEFINE_RAW(["define(<GMP_LIMB_BITS>,$GMP_LIMB_BITS)"]) 3345GMP_DEFINE_RAW(["define(<GMP_NAIL_BITS>,$GMP_NAIL_BITS)"]) 3346GMP_DEFINE_RAW(["define(<GMP_NUMB_BITS>,eval(GMP_LIMB_BITS-GMP_NAIL_BITS))"]) 3347 3348 3349# Exclude the mpn random functions from mpbsd since that would drag in the 3350# top-level rand things, all of which are unnecessary for libmp. There's 3351# other unnecessary objects too actually, if we could be bothered figuring 3352# out exactly which they are. 3353# 3354mpn_objs_in_libmp= 3355for i in $mpn_objs_in_libgmp; do 3356 case $i in 3357 *random*) ;; 3358 *) mpn_objs_in_libmp="$mpn_objs_in_libmp $i" ;; 3359 esac 3360done 3361AC_SUBST(mpn_objs_in_libmp) 3362 3363AC_SUBST(mpn_objects) 3364AC_SUBST(mpn_objs_in_libgmp) 3365AC_SUBST(gmp_srclinks) 3366 3367 3368# A recompiled sqr_basecase for use in the tune program, if necessary. 3369TUNE_SQR_OBJ= 3370test -d tune || mkdir tune 3371case $sqr_basecase_source in 3372 *.asm) 3373 sqr_max=[`sed -n 's/^def...(SQR_TOOM2_THRESHOLD_MAX, *\([0-9]*\))/\1/p' $sqr_basecase_source`] 3374 if test -n "$sqr_max"; then 3375 TUNE_SQR_OBJ=sqr_asm.o 3376 AC_DEFINE_UNQUOTED(TUNE_SQR_TOOM2_MAX,$sqr_max, 3377 [Maximum size the tune program can test for SQR_TOOM2_THRESHOLD]) 3378 fi 3379 cat >tune/sqr_basecase.c <<EOF 3380/* not sure that an empty file can compile, so put in a dummy */ 3381int sqr_basecase_dummy; 3382EOF 3383 ;; 3384 *.c) 3385 TUNE_SQR_OBJ= 3386 AC_DEFINE(TUNE_SQR_TOOM2_MAX,SQR_TOOM2_MAX_GENERIC) 3387 cat >tune/sqr_basecase.c <<EOF 3388#define TUNE_PROGRAM_BUILD 1 3389#define TUNE_PROGRAM_BUILD_SQR 1 3390#include "mpn/sqr_basecase.c" 3391EOF 3392 ;; 3393esac 3394AC_SUBST(TUNE_SQR_OBJ) 3395 3396 3397# Configs for demos/pexpr.c. 3398# 3399AC_CONFIG_FILES(demos/pexpr-config.h:demos/pexpr-config-h.in) 3400GMP_SUBST_CHECK_FUNCS(clock, cputime, getrusage, gettimeofday, sigaction, sigaltstack, sigstack) 3401GMP_SUBST_CHECK_HEADERS(sys/resource.h) 3402AC_CHECK_TYPES([stack_t], HAVE_STACK_T_01=1, HAVE_STACK_T_01=0, 3403 [#include <signal.h>]) 3404AC_SUBST(HAVE_STACK_T_01) 3405 3406# Configs for demos/calc directory 3407# 3408# AC_SUBST+AC_CONFIG_FILES is used for calc-config.h, rather than AC_DEFINE+ 3409# AC_CONFIG_HEADERS, since with the latter automake (1.8) will then put the 3410# directory (ie. demos/calc) into $(DEFAULT_INCLUDES) for every Makefile.in, 3411# which would look very strange. 3412# 3413# -lcurses is required by libreadline. On a typical SVR4 style system this 3414# normally doesn't have to be given explicitly, since libreadline.so will 3415# have a NEEDED record for it. But if someone for some reason is using only 3416# a static libreadline.a then we must give -lcurses. Readline (as of 3417# version 4.3) doesn't use libtool, so we can't rely on a .la to cover 3418# necessary dependencies. 3419# 3420# On a couple of systems we've seen libreadline available, but the headers 3421# not in the default include path, so check for readline/readline.h. We've 3422# also seen readline/history.h missing, not sure if that's just a broken 3423# install or a very old version, but check that too. 3424# 3425AC_CONFIG_FILES(demos/calc/calc-config.h:demos/calc/calc-config-h.in) 3426LIBCURSES= 3427if test $with_readline != no; then 3428 AC_CHECK_LIB(ncurses, tputs, [LIBCURSES=-lncurses], 3429 [AC_CHECK_LIB(curses, tputs, [LIBCURSES=-lcurses])]) 3430fi 3431AC_SUBST(LIBCURSES) 3432use_readline=$with_readline 3433if test $with_readline = detect; then 3434 use_readline=no 3435 AC_CHECK_LIB(readline, readline, 3436 [AC_CHECK_HEADER(readline/readline.h, 3437 [AC_CHECK_HEADER(readline/history.h, use_readline=yes)])], 3438 , $LIBCURSES) 3439 AC_MSG_CHECKING(readline detected) 3440 AC_MSG_RESULT($use_readline) 3441fi 3442if test $use_readline = yes; then 3443 AC_SUBST(WITH_READLINE_01, 1) 3444 AC_SUBST(LIBREADLINE, -lreadline) 3445else 3446 WITH_READLINE_01=0 3447fi 3448AC_PROG_YACC 3449AM_PROG_LEX 3450 3451# Configs for demos/expr directory 3452# 3453# Libtool already runs an AC_CHECK_TOOL for ranlib, but we give 3454# AC_PROG_RANLIB anyway since automake is supposed to complain if it's not 3455# called. (Automake 1.8.4 doesn't, at least not when the only library is in 3456# an EXTRA_LIBRARIES.) 3457# 3458AC_PROG_RANLIB 3459 3460 3461# Create config.m4. 3462GMP_FINISH 3463 3464# Create Makefiles 3465# FIXME: Upcoming version of autoconf/automake may not like broken lines. 3466# Right now automake isn't accepting the new AC_CONFIG_FILES scheme. 3467 3468AC_OUTPUT(Makefile \ 3469 mpbsd/Makefile mpf/Makefile mpn/Makefile mpq/Makefile \ 3470 mpz/Makefile printf/Makefile scanf/Makefile cxx/Makefile \ 3471 tests/Makefile tests/devel/Makefile tests/mpbsd/Makefile \ 3472 tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile \ 3473 tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile \ 3474 tests/cxx/Makefile \ 3475 doc/Makefile tune/Makefile \ 3476 demos/Makefile demos/calc/Makefile demos/expr/Makefile \ 3477 gmp.h:gmp-h.in mp.h:mp-h.in) 3478