1 dnl Process this file with autoconf to produce a configure script.
4 define(GMP_COPYRIGHT,[[
6 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
7 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
9 This file is part of the GNU MP Library.
11 The GNU MP Library is free software; you can redistribute it and/or modify
12 it under the terms of the GNU Lesser General Public License as published
13 by the Free Software Foundation; either version 3 of the License, or (at
14 your option) any later version.
16 The GNU MP Library is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19 License for more details.
21 You should have received a copy of the GNU Lesser General Public License
22 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
25 AC_COPYRIGHT(GMP_COPYRIGHT)
26 AH_TOP(/*GMP_COPYRIGHT*/)
28 AC_REVISION($Revision$)
30 AC_INIT(GNU MP, GMP_VERSION, gmp-bugs@gmplib.org, gmp)
31 AC_CONFIG_SRCDIR(gmp-impl.h)
32 m4_pattern_forbid([^[ \t]*GMP_])
33 m4_pattern_allow(GMP_LDFLAGS)
34 m4_pattern_allow(GMP_LIMB_BITS)
35 m4_pattern_allow(GMP_MPARAM_H_SUGGEST)
36 m4_pattern_allow(GMP_NAIL_BITS)
37 m4_pattern_allow(GMP_NUMB_BITS)
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".
44 if test -n "$target_alias" && test "$target_alias" != "$host_alias"; then
45 AC_MSG_ERROR([--target is not appropriate for GMP
46 Use --build=CPU-VENDOR-OS if you need to specify your CPU and/or system
47 explicitly. Use --host if cross-compiling (see "Installing GMP" in the
48 manual for more on this).])
55 dnl Automake "no-dependencies" is used because include file dependencies
56 dnl are not useful to us. Pretty much everything depends just on gmp.h,
57 dnl gmp-impl.h and longlong.h, and yet only rarely does everything need to
58 dnl be rebuilt for changes to those files.
60 dnl "no-dependencies" also helps with the way we're setup to run
61 dnl AC_PROG_CXX only conditionally. If dependencies are used then recent
62 dnl automake (eg 1.7.2) appends an AM_CONDITIONAL to AC_PROG_CXX, and then
63 dnl gets upset if it's not actually executed.
65 dnl Note that there's a copy of these options in the top-level Makefile.am,
66 dnl so update there too if changing anything.
68 AM_INIT_AUTOMAKE([1.8 gnu no-dependencies $(top_builddir)/ansi2knr])
69 AM_CONFIG_HEADER(config.h:config.in)
74 AC_HELP_STRING([--enable-assert],[enable ASSERT checking [[default=no]]]),
77 *) AC_MSG_ERROR([bad value $enableval for --enable-assert, need yes or no]) ;;
81 if test "$enable_assert" = "yes"; then
82 AC_DEFINE(WANT_ASSERT,1,
83 [Define to 1 to enable ASSERT checking, per --enable-assert])
88 GMP_DEFINE_RAW(["define(<WANT_ASSERT>,$want_assert_01)"])
92 AC_HELP_STRING([--enable-alloca],[how to get temp memory [[default=reentrant]]]),
94 alloca|malloc-reentrant|malloc-notreentrant) ;;
95 yes|no|reentrant|notreentrant) ;;
98 AC_MSG_ERROR([bad value $enableval for --enable-alloca, need one of:
99 yes no reentrant notreentrant alloca malloc-reentrant malloc-notreentrant debug]) ;;
101 [enable_alloca=reentrant])
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
117 AC_HELP_STRING([--enable-cxx],[enable C++ support [[default=no]]]),
120 *) AC_MSG_ERROR([bad value $enableval for --enable-cxx, need yes/no/detect]) ;;
126 AC_HELP_STRING([--enable-fft],[enable FFTs for multiplication [[default=yes]]]),
129 *) AC_MSG_ERROR([bad value $enableval for --enable-fft, need yes or no]) ;;
133 if test "$enable_fft" = "yes"; then
134 AC_DEFINE(WANT_FFT,1,
135 [Define to 1 to enable FFTs for multiplication, per --enable-fft])
139 AC_ARG_ENABLE(old-fft-full,
140 AC_HELP_STRING([--enable-old-fft-full],[enable old mpn_mul_fft_full for multiplication [[default=no]]]),
143 *) AC_MSG_ERROR([bad value $enableval for --enable-old-fft-full, need yes or no]) ;;
145 [enable_old_fft_full=no])
147 if 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])
154 AC_HELP_STRING([--enable-mpbsd],
155 [build Berkeley MP compatibility library [[default=no]]]),
158 *) AC_MSG_ERROR([bad value $enableval for --enable-mpbsd, need yes or no]) ;;
161 AM_CONDITIONAL(WANT_MPBSD, test "$enable_mpbsd" = "yes")
165 AC_HELP_STRING([--enable-nails],[use nails on limbs [[default=no]]]),
167 [yes|no|[02468]|[0-9][02468]]) ;;
169 AC_MSG_ERROR([bad value $enableval for --enable-nails, only even nail sizes supported]) ;;
171 AC_MSG_ERROR([bad value $enableval for --enable-nails, need yes/no/number]) ;;
175 case $enable_nails in
176 yes) GMP_NAIL_BITS=2 ;;
177 no) GMP_NAIL_BITS=0 ;;
178 *) GMP_NAIL_BITS=$enable_nails ;;
180 AC_SUBST(GMP_NAIL_BITS)
183 AC_ARG_ENABLE(profiling,
184 AC_HELP_STRING([--enable-profiling],
185 [build with profiler support [[default=no]]]),
187 no|prof|gprof|instrument) ;;
188 *) AC_MSG_ERROR([bad value $enableval for --enable-profiling, need no/prof/gprof/instrument]) ;;
190 [enable_profiling=no])
192 case $enable_profiling in
194 AC_DEFINE(WANT_PROFILING_PROF, 1,
195 [Define to 1 if --enable-profiling=prof])
198 AC_DEFINE(WANT_PROFILING_GPROF, 1,
199 [Define to 1 if --enable-profiling=gprof])
202 AC_DEFINE(WANT_PROFILING_INSTRUMENT, 1,
203 [Define to 1 if --enable-profiling=instrument])
207 GMP_DEFINE_RAW(["define(<WANT_PROFILING>,<\`$enable_profiling'>)"])
209 # -fomit-frame-pointer is incompatible with -pg on some chips
210 if test "$enable_profiling" = gprof; then
213 fomit_frame_pointer="-fomit-frame-pointer"
217 AC_ARG_WITH(readline,
218 AC_HELP_STRING([--with-readline],
219 [readline support in calc demo program [[default=detect]]]),
222 *) AC_MSG_ERROR([bad value $withval for --with-readline, need yes/no/detect]) ;;
224 [with_readline=detect])
228 AC_HELP_STRING([--enable-fat],
229 [build a fat binary on systems that support it [[default=no]]]),
232 *) AC_MSG_ERROR([bad value $enableval for --enable-fat, need yes or no]) ;;
237 AC_ARG_ENABLE(minithres,
238 AC_HELP_STRING([--enable-minithres],
239 [choose minimal thresholds for testing [[default=no]]]),
242 *) AC_MSG_ERROR([bad value $enableval for --enable-minithres, need yes or no]) ;;
244 [enable_minithres=no])
248 tmp_host=`echo $host_cpu | sed 's/\./_/'`
249 AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_$tmp_host)
250 GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_HOST_CPU_$tmp_host')", POST)
252 dnl The HAVE_HOST_CPU_ list here only needs to have entries for those which
253 dnl are going to be tested, not everything that can possibly be selected.
255 dnl The HAVE_HOST_CPU_FAMILY_ list similarly, and note that the AC_DEFINEs
256 dnl for these are under the cpu specific setups below.
258 AH_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
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])
294 # Table of compilers, options, and mpn paths. This code has various related
297 # - better default CC/CFLAGS selections than autoconf otherwise gives
298 # - default CC/CFLAGS selections for extra CPU types specific to GMP
299 # - a few tests for known bad compilers
300 # - choice of ABIs on suitable systems
301 # - selection of corresponding mpn search path
303 # After GMP specific searches and tests, the standard autoconf AC_PROG_CC is
304 # called. User selections of CC etc are respected.
306 # Care is taken not to use macros like AC_TRY_COMPILE during the GMP
307 # pre-testing, since they of course depend on AC_PROG_CC, and also some of
308 # them cache their results, which is not wanted.
310 # The ABI selection mechanism is unique to GMP. All that reaches autoconf
311 # is a different selection of CC/CFLAGS according to the best ABI the system
312 # supports, and/or what the user selects. Naturally the mpn assembler code
313 # selected is very dependent on the ABI.
315 # The closest the standard tools come to a notion of ABI is something like
316 # "sparc64" which encodes a CPU and an ABI together. This doesn't seem to
317 # scale well for GMP, where exact CPU types like "ultrasparc2" are wanted,
318 # separate from the ABI used on them.
321 # The variables set here are
323 # cclist the compiler choices
324 # xx_cflags flags for compiler xx
325 # xx_cflags_maybe flags for compiler xx, if they work
326 # xx_cppflags cpp flags for compiler xx
327 # xx_cflags_optlist list of sets of optional flags
328 # xx_cflags_yyy set yyy of optional flags for compiler xx
329 # xx_ldflags -Wc,-foo flags for libtool linking with compiler xx
330 # ar_flags extra flags for $AR
331 # nm_flags extra flags for $NM
332 # limb limb size, can be "longlong"
333 # path mpn search path
334 # extra_functions extra mpn functions
335 # fat_path fat binary mpn search path [if fat binary desired]
336 # fat_functions fat functions
337 # fat_thresholds fat thresholds
339 # Suppose xx_cflags_optlist="arch", then flags from $xx_cflags_arch are
340 # tried, and the first flag that works will be used. An optlist like "arch
341 # cpu optimize" can be used to get multiple independent sets of flags tried.
342 # The first that works from each will be used. If no flag in a set works
343 # then nothing from that set is added.
345 # For multiple ABIs, the scheme extends as follows.
347 # abilist set of ABI choices
348 # cclist_aa compiler choices in ABI aa
349 # xx_aa_cflags flags for xx in ABI aa
350 # xx_aa_cflags_maybe flags for xx in ABI aa, if they work
351 # xx_aa_cppflags cpp flags for xx in ABI aa
352 # xx_aa_cflags_optlist list of sets of optional flags in ABI aa
353 # xx_aa_cflags_yyy set yyy of optional flags for compiler xx in ABI aa
354 # xx_aa_ldflags -Wc,-foo flags for libtool linking
355 # ar_aa_flags extra flags for $AR in ABI aa
356 # nm_aa_flags extra flags for $NM in ABI aa
357 # limb_aa limb size in ABI aa, can be "longlong"
358 # path_aa mpn search path in ABI aa
359 # extra_functions_aa extra mpn functions in ABI aa
361 # As a convenience, the unadorned xx_cflags (etc) are used for the last ABI
362 # in ablist, if an xx_aa_cflags for that ABI isn't given. For example if
363 # abilist="64 32" then $cc_64_cflags will be used for the 64-bit ABI, but
364 # for the 32-bit either $cc_32_cflags or $cc_cflags is used, whichever is
365 # defined. This makes it easy to add some 64-bit compilers and flags to an
366 # unadorned 32-bit set.
368 # limb=longlong (or limb_aa=longlong) applies to all compilers within that
369 # ABI. It won't work to have some needing long long and some not, since a
370 # single instantiated gmp.h will be used by both.
372 # SPEED_CYCLECOUNTER, cyclecounter_size and CALLING_CONVENTIONS_OBJS are
373 # also set here, with an ABI suffix.
377 # A table-driven approach like this to mapping cpu type to good compiler
378 # options is a bit of a maintenance burden, but there's not much uniformity
379 # between options specifications on different compilers. Some sort of
380 # separately updatable tool might be cute.
382 # The use of lots of variables like this, direct and indirect, tends to
383 # obscure when and how various things are done, but unfortunately it's
384 # pretty much the only way. If shell subroutines were portable then actual
385 # code like "if this .. do that" could be written, but attempting the same
386 # with full copies of GMP_PROG_CC_WORKS etc expanded at every point would
387 # hugely bloat the output.
390 AC_ARG_VAR(ABI, [desired ABI (for processors supporting more than one ABI)])
392 # abilist needs to be non-empty, "standard" is just a generic name here
395 # FIXME: We'd like to prefer an ANSI compiler, perhaps by preferring
396 # c89 over cc here. But note that on HP-UX c89 provides a castrated
397 # environment, and would want to be excluded somehow. Maybe
398 # AC_PROG_CC_STDC already does enough to stick cc into ANSI mode and
399 # we don't need to worry.
403 gcc_cflags="-O2 -pedantic"
404 gcc_64_cflags="-O2 -pedantic"
408 SPEED_CYCLECOUNTER_OBJ=
411 AC_SUBST(HAVE_HOST_CPU_FAMILY_power, 0)
412 AC_SUBST(HAVE_HOST_CPU_FAMILY_powerpc,0)
422 AC_DEFINE(HAVE_HOST_CPU_FAMILY_alpha)
424 alphaev5* | alphapca5*)
425 path="alpha/ev5 alpha" ;;
426 alphaev67 | alphaev68 | alphaev7*)
427 path="alpha/ev67 alpha/ev6 alpha" ;;
429 path="alpha/ev6 alpha" ;;
433 extra_functions="cntlz"
434 gcc_cflags_optlist="asm cpu oldas" # need asm ahead of cpu, see below
435 gcc_cflags_oldas="-Wa,-oldas" # see GMP_GCC_WA_OLDAS.
437 # gcc 2.7.2.3 doesn't know any -mcpu= for alpha, apparently.
438 # gcc 2.95 knows -mcpu= ev4, ev5, ev56, pca56, ev6.
439 # gcc 3.0 adds nothing.
440 # gcc 3.1 adds ev45, ev67 (but ev45 is the same as ev4).
441 # gcc 3.2 adds nothing.
443 # gcc version "2.9-gnupro-99r1" under "-O2 -mcpu=ev6" strikes internal
444 # compiler errors too easily and is rejected by GMP_PROG_CC_WORKS. Each
445 # -mcpu=ev6 below has a fallback to -mcpu=ev56 for this reason.
448 alpha) gcc_cflags_cpu="-mcpu=ev4" ;;
449 alphaev5) gcc_cflags_cpu="-mcpu=ev5" ;;
450 alphaev56) gcc_cflags_cpu="-mcpu=ev56" ;;
451 alphapca56 | alphapca57)
452 gcc_cflags_cpu="-mcpu=pca56" ;;
453 alphaev6) gcc_cflags_cpu="-mcpu=ev6 -mcpu=ev56" ;;
454 alphaev67 | alphaev68 | alphaev7*)
455 gcc_cflags_cpu="-mcpu=ev67 -mcpu=ev6 -mcpu=ev56" ;;
458 # gcc version "2.9-gnupro-99r1" on alphaev68-dec-osf5.1 has been seen
459 # accepting -mcpu=ev6, but not putting the assembler in the right mode
460 # for what it produces. We need to do this for it, and need to do it
461 # before testing the -mcpu options.
463 # On old versions of gcc, which don't know -mcpu=, we believe an
464 # explicit -Wa,-mev5 etc will be necessary to put the assembler in
465 # the right mode for our .asm files and longlong.h asm blocks.
467 # On newer versions of gcc, when -mcpu= is known, we must give a -Wa
468 # which is at least as high as the code gcc will generate. gcc
469 # establishes what it needs with a ".arch" directive, our command line
470 # option seems to override that.
472 # gas prior to 2.14 doesn't accept -mev67, but -mev6 seems enough for
473 # ctlz and cttz (in 2.10.0 at least).
475 # OSF `as' accepts ev68 but stupidly treats it as ev4. -arch only seems
476 # to affect insns like ldbu which are expanded as macros when necessary.
477 # Insns like ctlz which were never available as macros are always
478 # accepted and always generate their plain code.
481 alpha) gcc_cflags_asm="-Wa,-arch,ev4 -Wa,-mev4" ;;
482 alphaev5) gcc_cflags_asm="-Wa,-arch,ev5 -Wa,-mev5" ;;
483 alphaev56) gcc_cflags_asm="-Wa,-arch,ev56 -Wa,-mev56" ;;
484 alphapca56 | alphapca57)
485 gcc_cflags_asm="-Wa,-arch,pca56 -Wa,-mpca56" ;;
486 alphaev6) gcc_cflags_asm="-Wa,-arch,ev6 -Wa,-mev6" ;;
487 alphaev67 | alphaev68 | alphaev7*)
488 gcc_cflags_asm="-Wa,-arch,ev67 -Wa,-mev67 -Wa,-arch,ev6 -Wa,-mev6" ;;
491 # It might be better to ask "cc" whether it's Cray C or DEC C,
492 # instead of relying on the OS part of $host. But it's hard to
493 # imagine either of those compilers anywhere except their native
496 GMP_INCLUDE_MPN(alpha/alpha-defs.m4)
499 cc_cflags="-O" # no -g, it silently disables all optimizations
500 GMP_INCLUDE_MPN(alpha/unicos.m4)
501 # Don't perform any assembly syntax tests on this beast.
502 gmp_asm_syntax_testing=no
505 GMP_INCLUDE_MPN(alpha/default.m4)
507 cc_cflags_optlist="opt cpu"
509 # not sure if -fast works on old versions, so make it optional
510 cc_cflags_opt="-fast -O2"
512 # DEC C V5.9-005 knows ev4, ev5, ev56, pca56, ev6.
513 # Compaq C V6.3-029 adds ev67.
516 alpha) cc_cflags_cpu="-arch~ev4~-tune~ev4" ;;
517 alphaev5) cc_cflags_cpu="-arch~ev5~-tune~ev5" ;;
518 alphaev56) cc_cflags_cpu="-arch~ev56~-tune~ev56" ;;
519 alphapca56 | alphapca57)
520 cc_cflags_cpu="-arch~pca56~-tune~pca56" ;;
521 alphaev6) cc_cflags_cpu="-arch~ev6~-tune~ev6" ;;
522 alphaev67 | alphaev68 | alphaev7*)
523 cc_cflags_cpu="-arch~ev67~-tune~ev67 -arch~ev6~-tune~ev6" ;;
527 GMP_INCLUDE_MPN(alpha/default.m4)
533 # tune/alpha.asm assumes int==4bytes but unicos uses int==8bytes
536 SPEED_CYCLECOUNTER_OBJ=alpha.lo
537 cyclecounter_size=1 ;;
542 # Cray vector machines.
543 # This must come after alpha* so that we can recognize present and future
544 # vector processors with a wildcard.
546 gmp_asm_syntax_testing=no
548 # We used to have -hscalar0 here as a workaround for miscompilation of
549 # mpz/import.c, but let's hope Cray fixes their bugs instead, since
550 # -hscalar0 causes disastrously poor code to be generated.
551 cc_cflags="-O3 -hnofastmd -htask0 -Wa,-B"
558 gcc_cflags="$gcc_cflags $fomit_frame_pointer"
559 gcc_testlist="gcc-arm-umodsi"
560 GMP_INCLUDE_MPN(arm/arm-defs.m4)
570 [f30[01]-fujitsu-sysv*])
572 # FIXME: flags for vcc?
579 # HP cc (the one sold separately) is K&R by default, but AM_C_PROTOTYPES
580 # will add "-Ae", or "-Aa -D_HPUX_SOURCE", to put it into ansi mode, if
583 # gcc for hppa 2.0 can be built either for 2.0n (32-bit) or 2.0w
584 # (64-bit), but not both, so there's no option to choose the desired
585 # mode, we must instead detect which of the two it is. This is done by
586 # checking sizeof(long), either 4 or 8 bytes respectively. Do this in
587 # ABI=1.0 too, in case someone tries to build that with a 2.0w gcc.
589 gcc_cflags_optlist="arch"
590 gcc_testlist="sizeof-long-4"
591 SPEED_CYCLECOUNTER_OBJ=hppa.lo
594 # FIXME: For hppa2.0*, path should be "pa32/hppa2_0 pa32/hppa1_1 pa32".
595 # (Can't remember why this isn't done already, have to check what .asm
596 # files are available in each and how they run on a typical 2.0 cpu.)
599 hppa1.0*) path="pa32" ;;
600 hppa7000*) path="pa32/hppa1_1 pa32" ;;
602 path="pa32/hppa2_0 pa32/hppa1_1/pa7100 pa32/hppa1_1 pa32" ;;
604 path="pa32/hppa1_1/pa7100 pa32/hppa1_1 pa32" ;;
607 # gcc 2.7.2.3 knows -mpa-risc-1-0 and -mpa-risc-1-1
608 # gcc 2.95 adds -mpa-risc-2-0, plus synonyms -march=1.0, 1.1 and 2.0
610 # We don't use -mpa-risc-2-0 in ABI=1.0 because 64-bit registers may not
611 # be saved by the kernel on an old system. Actually gcc (as of 3.2)
612 # only adds a few float instructions with -mpa-risc-2-0, so it would
613 # probably be safe, but let's not take the chance. In any case, a
614 # configuration like --host=hppa2.0 ABI=1.0 is far from optimal.
617 hppa1.0*) gcc_cflags_arch="-mpa-risc-1-0" ;;
619 gcc_cflags_arch="-mpa-risc-1-1" ;;
623 hppa1.0*) cc_cflags="+O2" ;;
625 cc_cflags="+DA1.1 +O2" ;;
629 hppa2.0*-*-* | hppa64-*-*)
634 any_20n_testlist="sizeof-long-4"
635 SPEED_CYCLECOUNTER_OBJ_20n=hppa2.lo
636 cyclecounter_size_20n=2
638 # -mpa-risc-2-0 is only an optional flag, in case an old gcc is
639 # used. Assembler support for 2.0 is essential though, for our asm
642 gcc_20n_cflags_optlist="arch"
643 gcc_20n_cflags_arch="-mpa-risc-2-0 -mpa-risc-1-1"
644 gcc_20n_testlist="sizeof-long-4 hppa-level-2.0"
646 cc_20n_cflags="+DA2.0 +e +O2 -Wl,+vnocompatwarnings"
647 cc_20n_testlist="hpc-hppa-2-0"
649 # ABI=2.0w is available for hppa2.0w and hppa2.0, but not for
650 # hppa2.0n, on the assumption that that the latter indicates a
651 # desire for ABI=2.0n.
655 # HPUX 10 and earlier cannot run 2.0w. Not sure about other
656 # systems (GNU/Linux for instance), but lets assume they're ok.
658 [*-*-hpux[1-9] | *-*-hpux[1-9].* | *-*-hpux10 | *-*-hpux10.*]) ;;
659 *) abilist="2.0w $abilist" ;;
663 gcc_20w_cflags="-O2 -mpa-risc-2-0"
664 cc_20w_cflags="+DD64 +O2"
665 cc_20w_testlist="hpc-hppa-2-0"
667 any_20w_testlist="sizeof-long-8"
668 SPEED_CYCLECOUNTER_OBJ_20w=hppa2w.lo
669 cyclecounter_size_20w=2
684 GMP_INCLUDE_MPN(ia64/ia64-defs.m4)
685 SPEED_CYCLECOUNTER_OBJ=ia64.lo
688 itanium) path="ia64/itanium ia64" ;;
689 itanium2) path="ia64/itanium2 ia64" ;;
693 gcc_64_cflags_optlist="tune"
694 gcc_32_cflags_optlist=$gcc_64_cflags_optlist
696 # gcc pre-release 3.4 adds -mtune itanium and itanium2
698 itanium) gcc_cflags_tune="-mtune=itanium" ;;
699 itanium2) gcc_cflags_tune="-mtune=itanium2" ;;
706 icc_cflags_optlist="opt"
707 # Don't use -O3, it is for "large data sets" and also miscompiles GMP.
708 # But icc miscompiles GMP at any optimization level, at higher levels
709 # it miscompiles more files...
710 icc_cflags_opt="-O2 -O1"
714 # HP cc sometimes gets internal errors if the optimization level is
715 # too high. GMP_PROG_CC_WORKS detects this, the "_opt" fallbacks
716 # let us use whatever seems to work.
723 cc_32_cflags_optlist="opt"
724 cc_32_cflags_opt="+O3 +O2 +O1"
725 gcc_32_cflags="-milp32 -O2"
727 SPEED_CYCLECOUNTER_OBJ_32=ia64.lo
728 cyclecounter_size_32=2
730 # Must have +DD64 in CPPFLAGS to get the right __LP64__ for headers,
731 # but also need it in CFLAGS for linking programs, since automake
732 # only uses CFLAGS when linking, not CPPFLAGS.
733 # FIXME: Maybe should use cc_64_ldflags for this, but that would
734 # need GMP_LDFLAGS used consistently by all the programs.
737 cc_64_cppflags="+DD64"
738 cc_64_cflags_optlist="opt"
739 cc_64_cflags_opt="+O3 +O2 +O1"
740 gcc_64_cflags="$gcc_64_cflags -mlp64"
749 AC_DEFINE(HAVE_HOST_CPU_FAMILY_m68k)
750 GMP_INCLUDE_MPN(m68k/m68k-defs.m4)
751 gcc_cflags="$gcc_cflags $fomit_frame_pointer"
752 gcc_cflags_optlist="arch"
754 # gcc 2.7.2 knows -m68000, -m68020, -m68030, -m68040.
755 # gcc 2.95 adds -mcpu32, -m68060.
756 # FIXME: Maybe "-m68020 -mnobitfield" would suit cpu32 on 2.7.2.
759 m68020) gcc_cflags_arch="-m68020" ;;
760 m68030) gcc_cflags_arch="-m68030" ;;
761 m68040) gcc_cflags_arch="-m68040" ;;
762 m68060) gcc_cflags_arch="-m68060 -m68000" ;;
763 m68360) gcc_cflags_arch="-mcpu32 -m68000" ;;
764 *) gcc_cflags_arch="-m68000" ;;
767 # FIXME: m68k/mc68020 looks like it's ok for cpu32, but this wants to be
768 # tested. Will need to introduce an m68k/cpu32 if m68k/mc68020 ever uses
769 # the bitfield instructions.
771 [m680[234]0 | m68360]) path="m68k/mc68020 m68k" ;;
782 gcc_cflags="$gcc_cflags -m88110"
783 path="m88k/mc88110 m88k"
787 # National Semiconductor 32k
793 # IRIX 5 and earlier can only run 32-bit o32.
795 # IRIX 6 and up always has a 64-bit mips CPU can run n32 or 64. n32 is
796 # preferred over 64, but only because that's been the default in past
797 # versions of GMP. The two are equally efficient.
799 # Linux kernel 2.2.13 arch/mips/kernel/irixelf.c has a comment about not
800 # supporting n32 or 64.
802 # For reference, libtool (eg. 1.5.6) recognises the n32 ABI and knows the
803 # right options to use when linking (both cc and gcc), so no need for
804 # anything special from us.
808 gcc_cflags_optlist="abi"
809 gcc_cflags_abi="-mabi=32"
810 gcc_testlist="gcc-mips-o32"
812 cc_cflags="-O2 -o32" # no -g, it disables all optimizations
813 # this suits both mips32 and mips64
814 GMP_INCLUDE_MPN(mips32/mips-defs.m4)
817 [mips64*-*-* | mips*-*-irix[6789]*])
821 gcc_n32_cflags="-O2 -mabi=n32"
822 cc_n32_cflags="-O2 -n32" # no -g, it disables all optimizations
827 gcc_64_cflags="$gcc_64_cflags -mabi=64"
828 gcc_64_ldflags="-Wc,-mabi=64"
829 cc_64_cflags="-O2 -64" # no -g, it disables all optimizations
830 cc_64_ldflags="-Wc,-64"
837 # Darwin (powerpc-apple-darwin1.3) has it's hacked gcc installed as cc.
838 # Our usual "gcc in disguise" detection means gcc_cflags etc here gets
841 # The darwin pre-compiling preprocessor is disabled with -no-cpp-precomp
842 # since it doesn't like "__attribute__ ((mode (SI)))" etc in gmp-impl.h,
843 # and so always ends up running the plain preprocessor anyway. This could
844 # be done in CPPFLAGS rather than CFLAGS, but there's not many places
845 # preprocessing is done separately, and this is only a speedup, the normal
846 # preprocessor gets run if there's any problems.
848 # We used to use -Wa,-mppc with gcc, but can't remember exactly why.
849 # Presumably it was for old versions of gcc where -mpowerpc doesn't put
850 # the assembler in the right mode. In any case -Wa,-mppc is not good, for
851 # instance -mcpu=604 makes recent gcc use -m604 to get access to the
852 # "fsel" instruction, but a -Wa,-mppc overrides that, making code that
853 # comes out with fsel fail.
855 # (Note also that the darwin assembler doesn't accept "-mppc", so any
856 # -Wa,-mppc was used only if it worked. The right flag on darwin would be
857 # "-arch ppc" or some such, but that's already the default.)
859 [powerpc*-*-* | power[3-9]-*-*])
860 AC_DEFINE(HAVE_HOST_CPU_FAMILY_powerpc)
861 HAVE_HOST_CPU_FAMILY_powerpc=1
865 gcc_cflags="$gcc_cflags -mpowerpc"
866 gcc_cflags_optlist="precomp subtype asm cpu"
867 gcc_cflags_precomp="-no-cpp-precomp"
868 gcc_cflags_subtype="-force_cpusubtype_ALL" # for vmx on darwin
873 # grab this object, though it's not a true cycle counter routine
874 SPEED_CYCLECOUNTER_OBJ=powerpc.lo
878 powerpc740 | powerpc750)
879 path="powerpc32/750 powerpc32" ;;
880 powerpc7400 | powerpc7410)
881 path="powerpc32/vmx powerpc32/750 powerpc32" ;;
883 path="powerpc32/vmx powerpc32" ;;
888 # gcc 2.7.2 knows -mcpu=403, 601, 603, 604.
889 # gcc 2.95 adds 401, 505, 602, 603e, ec603e, 604e, 620, 740, 750,
890 # 801, 821, 823, 860.
891 # gcc 3.0 adds 630, rs64a.
892 # gcc 3.1 adds 405, 7400, 7450.
893 # gcc 3.2 adds nothing.
894 # gcc 3.3 adds power3, power4, 8540. power3 seems to be a synonym for 630.
895 # gcc pre-release 3.4 adds 405fp, 440, 440fp, 970.
897 # FIXME: The way 603e falls back to 603 for gcc 2.7.2 should be
898 # done for all the others too. But what would be the correct
902 powerpc401) gcc_cflags_cpu="-mcpu=401" ;;
903 powerpc403) gcc_cflags_cpu="-mcpu=403" ;;
904 powerpc405) gcc_cflags_cpu="-mcpu=405" ;;
905 powerpc505) gcc_cflags_cpu="-mcpu=505" ;;
906 powerpc601) gcc_cflags_cpu="-mcpu=601" ;;
907 powerpc602) gcc_cflags_cpu="-mcpu=602" ;;
908 powerpc603) gcc_cflags_cpu="-mcpu=603" ;;
909 powerpc603e) gcc_cflags_cpu="-mcpu=603e -mcpu=603" ;;
910 powerpc604) gcc_cflags_cpu="-mcpu=604" ;;
911 powerpc604e) gcc_cflags_cpu="-mcpu=604e -mcpu=604" ;;
912 powerpc620) gcc_cflags_cpu="-mcpu=620" ;;
913 powerpc630) gcc_cflags_cpu="-mcpu=630"
915 powerpc740) gcc_cflags_cpu="-mcpu=740" ;;
916 powerpc7400 | powerpc7410)
917 gcc_cflags_asm="-Wa,-maltivec"
918 gcc_cflags_cpu="-mcpu=7400 -mcpu=750" ;;
920 gcc_cflags_asm="-Wa,-maltivec"
921 gcc_cflags_cpu="-mcpu=7450" ;;
922 powerpc750) gcc_cflags_cpu="-mcpu=750" ;;
923 powerpc801) gcc_cflags_cpu="-mcpu=801" ;;
924 powerpc821) gcc_cflags_cpu="-mcpu=821" ;;
925 powerpc823) gcc_cflags_cpu="-mcpu=823" ;;
926 powerpc860) gcc_cflags_cpu="-mcpu=860" ;;
927 powerpc970) gcc_cflags_cpu="-mtune=970"
928 vmx_path="powerpc64/vmx"
930 power4) gcc_cflags_cpu="-mtune=power4"
932 power5) gcc_cflags_cpu="-mtune=power5 -mtune=power4"
934 power6) gcc_cflags_cpu="-mtune=power6"
941 xlc_cflags="-O2 -qmaxmem=20000"
942 xlc_cflags_optlist="arch"
944 # xlc (what version?) knows -qarch=ppc, ppcgr, 601, 602, 603, 604,
946 # -qarch=ppc is needed, so ensure everything falls back to that.
947 # FIXME: Perhaps newer versions know more flavours.
950 powerpc403) xlc_cflags_arch="-qarch=403 -qarch=ppc" ;;
951 powerpc601) xlc_cflags_arch="-qarch=601 -qarch=ppc" ;;
952 powerpc602) xlc_cflags_arch="-qarch=602 -qarch=ppc" ;;
953 powerpc603) xlc_cflags_arch="-qarch=603 -qarch=ppc" ;;
954 powerpc603e) xlc_cflags_arch="-qarch=603 -qarch=ppc" ;;
955 powerpc604) xlc_cflags_arch="-qarch=604 -qarch=ppc" ;;
956 powerpc604e) xlc_cflags_arch="-qarch=604 -qarch=ppc" ;;
957 *) xlc_cflags_arch="-qarch=ppc" ;;
966 # On AIX a true 64-bit ABI is available.
967 # Need -Wc to pass object type flags through to the linker.
968 abilist="aix64 $abilist"
969 cclist_aix64="gcc xlc"
970 gcc_aix64_cflags="-O2 -maix64 -mpowerpc64"
971 gcc_aix64_cflags_optlist="cpu"
972 gcc_aix64_ldflags="-Wc,-maix64"
973 xlc_aix64_cflags="-O2 -q64 -qtune=pwr3 -qmaxmem=20000"
974 xlc_aix64_ldflags="-Wc,-q64"
975 # Must indicate object type to ar and nm
976 ar_aix64_flags="-X64"
977 nm_aix64_flags="-X64"
979 for i in $cpu_path; do path_aix64="${path_aix64}powerpc64/mode64/$i "; done
980 path_aix64="${path_aix64}powerpc64/mode64 $vmx_path powerpc64"
981 # grab this object, though it's not a true cycle counter routine
982 SPEED_CYCLECOUNTER_OBJ_aix64=powerpc64.lo
983 cyclecounter_size_aix64=0
986 # On Darwin we can use 64-bit instructions with a longlong limb,
987 # but the chip still in 32-bit mode.
988 # In theory this can be used on any OS which knows how to save
989 # 64-bit registers in a context switch.
991 # Note that we must use -mpowerpc64 with gcc, since the
992 # longlong.h macros expect limb operands in a single 64-bit
993 # register, not two 32-bit registers as would be given for a
994 # long long without -mpowerpc64. In theory we could detect and
995 # accommodate both styles, but the proper 64-bit registers will
996 # be fastest and are what we really want to use.
998 # One would think -mpowerpc64 would set the assembler in the right
999 # mode to handle 64-bit instructions. But for that, also
1000 # -force_cpusubtype_ALL is needed.
1002 # Do not use -fast for Darwin, it actually adds options
1003 # incompatible with a shared library.
1005 abilist="mode64 mode32 $abilist"
1006 gcc_cflags_opt="-O3 -O2 -O1" # will this become used?
1008 gcc_mode32_cflags="-mpowerpc64"
1009 gcc_mode32_cflags_optlist="subtype cpu opt"
1010 gcc_mode32_cflags_subtype="-force_cpusubtype_ALL"
1011 gcc_mode32_cflags_opt="-O3 -O2 -O1"
1012 path_mode32="powerpc64/mode32 $vmx_path powerpc64"
1013 limb_mode32=longlong
1015 gcc_mode64_cflags="-m64"
1016 gcc_mode64_cflags_optlist="cpu opt"
1017 gcc_mode64_cflags_opt="-O3 -O2 -O1"
1019 for i in $cpu_path; do path_mode64="${path_mode64}powerpc64/mode64/$i "; done
1020 path_mode64="${path_mode64}powerpc64/mode64 $vmx_path powerpc64"
1021 SPEED_CYCLECOUNTER_OBJ_mode64=powerpc64.lo
1022 cyclecounter_size_mode64=0
1023 any_mode64_testlist="sizeof-long-8"
1025 *-*-linux* | *-*-*bsd*)
1026 # On GNU/Linux, assume the processor is in 64-bit mode. Some
1027 # environments have a gcc that is always in 64-bit mode, while
1028 # others require -m64, hence the use of cflags_maybe. The
1029 # sizeof-long-8 test checks the mode is right (for the no option
1032 # -mpowerpc64 is not used, since it should be the default in
1033 # 64-bit mode. (We need its effect for the various longlong.h
1034 # asm macros to be right of course.)
1036 # gcc64 was an early port of gcc to 64-bit mode, but should be
1037 # obsolete before too long. We prefer plain gcc when it knows
1040 abilist="mode64 mode32 $abilist"
1042 gcc_mode32_cflags="-mpowerpc64"
1043 gcc_mode32_cflags_optlist="cpu opt"
1044 gcc_mode32_cflags_opt="-O3 -O2 -O1"
1045 path_mode32="powerpc64/mode32 $vmx_path powerpc64"
1046 limb_mode32=longlong
1047 cclist_mode64="gcc gcc64"
1048 gcc_mode64_cflags_maybe="-m64"
1049 gcc_mode64_cflags_optlist="cpu opt"
1050 gcc_mode64_cflags_opt="-O3 -O2 -O1"
1052 for i in $cpu_path; do path_mode64="${path_mode64}powerpc64/mode64/$i "; done
1053 path_mode64="${path_mode64}powerpc64/mode64 $vmx_path powerpc64"
1054 SPEED_CYCLECOUNTER_OBJ_mode64=powerpc64.lo
1055 cyclecounter_size_mode64=0
1056 any_mode64_testlist="sizeof-long-8"
1065 [power-*-* | power[12]-*-* | power2sc-*-*])
1066 AC_DEFINE(HAVE_HOST_CPU_FAMILY_power)
1067 HAVE_HOST_CPU_FAMILY_power=1
1069 extra_functions="udiv_w_sdiv"
1072 # gcc 2.7.2 knows rios1, rios2, rsc
1074 # -mcpu=rios2 can tickle an AIX assembler bug (see GMP_PROG_CC_WORKS) so
1075 # there needs to be a fallback to just -mpower.
1077 gcc_cflags_optlist="cpu"
1079 power-*-*) gcc_cflags_cpu="-mcpu=power -mpower" ;;
1080 power1-*-*) gcc_cflags_cpu="-mcpu=rios1 -mpower" ;;
1081 power2-*-*) gcc_cflags_cpu="-mcpu=rios2 -mpower" ;;
1082 power2sc-*-*) gcc_cflags_cpu="-mcpu=rsc -mpower" ;;
1087 xlc_cflags="-O2 -qarch=pwr -qmaxmem=20000"
1098 # IBM s/370 and similar
1100 gcc_cflags="$gcc_cflags $fomit_frame_pointer"
1102 extra_functions="udiv_w_sdiv"
1106 sh-*-*) path="sh" ;;
1107 sh2-*-*) path="sh/sh2 sh" ;;
1111 # sizeof(long)==4 or 8 is tested, to ensure we get the right ABI. We've
1112 # had various bug reports where users have set CFLAGS for their desired
1113 # mode, but not set our ABI. For some reason it's sparc where this
1114 # keeps coming up, presumably users there are accustomed to driving the
1115 # compiler mode that way. The effect of our testlist setting is to
1116 # reject ABI=64 in favour of ABI=32 if the user has forced the flags to
1121 any_testlist="sizeof-long-4"
1122 GMP_INCLUDE_MPN(sparc32/sparc-defs.m4)
1125 sparcv8 | microsparc | turbosparc)
1126 path="sparc32/v8 sparc32" ;;
1128 path="sparc32/v8/supersparc sparc32/v8 sparc32" ;;
1129 sparc64 | sparcv9* | ultrasparc*)
1130 path="sparc32/v9 sparc32/v8 sparc32" ;;
1135 # gcc 2.7.2 doesn't know about v9 and doesn't pass -xarch=v8plus to the
1136 # assembler. Add it explicitly since the solaris assembler won't accept
1137 # our sparc32/v9 asm code without it. gas accepts -xarch=v8plus too, so
1138 # it can be in the cflags unconditionally (though gas doesn't need it).
1140 # gcc -m32 is needed to force 32-bit mode on a dual-ABI system, but past
1141 # gcc doesn't know that flag, hence cflags_maybe. Note that -m32 cannot
1142 # be done through the optlist since the plain cflags would be run first
1143 # and we don't want to require the default mode (whatever it is) works.
1145 # Note it's gcc_32_cflags_maybe and not gcc_cflags_maybe because the
1146 # latter would be used in the 64-bit ABI on systems like "*bsd" where
1147 # abilist="64" only.
1150 sparc64 | sparcv9* | ultrasparc*)
1151 gcc_cflags="$gcc_cflags -Wa,-xarch=v8plus" ;;
1153 gcc_cflags="$gcc_cflags" ;;
1155 gcc_32_cflags_maybe="-m32"
1156 gcc_cflags_optlist="cpu"
1158 # gcc 2.7.2 knows -mcypress, -msupersparc, -mv8, -msparclite.
1159 # gcc 2.95 knows -mcpu= v7, hypersparc, sparclite86x, f930, f934,
1160 # sparclet, tsc701, v9, ultrasparc. A warning is given that the
1161 # plain -m forms will disappear.
1162 # gcc 3.0 adds nothing.
1163 # gcc 3.1 adds nothing.
1164 # gcc 3.2 adds nothing.
1165 # gcc 3.3 adds ultrasparc3.
1168 supersparc) gcc_cflags_cpu="-mcpu=supersparc -msupersparc" ;;
1169 sparcv8 | microsparc | turbosparc)
1170 gcc_cflags_cpu="-mcpu=v8 -mv8" ;;
1171 sparc64 | sparcv9*) gcc_cflags_cpu="-mcpu=v9 -mv8" ;;
1172 ultrasparc3) gcc_cflags_cpu="-mcpu=ultrasparc3 -mcpu=ultrasparc -mv8" ;;
1173 ultrasparc*) gcc_cflags_cpu="-mcpu=ultrasparc -mv8" ;;
1174 *) gcc_cflags_cpu="-mcpu=v7 -mcypress" ;;
1177 # SunPRO cc and acc, and SunOS bundled cc
1179 *-*-solaris* | *-*-sunos*)
1180 # Note no -g, it disables all optimizations.
1182 cc_cflags_optlist="opt arch cpu"
1184 # SunOS cc doesn't know -xO4, fallback to -O2.
1185 cc_cflags_opt="-xO4 -O2"
1187 # SunOS cc doesn't know -xarch, apparently always generating v7
1188 # code, so make this optional
1190 sparcv8 | microsparc | supersparc | turbosparc)
1191 cc_cflags_arch="-xarch=v8" ;;
1192 sparc64 | sparcv9* | ultrasparc*) cc_cflags_arch="-xarch=v8plus" ;;
1193 *) cc_cflags_arch="-xarch=v7" ;;
1196 # SunOS cc doesn't know -xchip and doesn't seem to have an equivalent.
1197 # SunPRO cc 5 recognises -xchip=generic, old, super, super2, micro,
1198 # micro2, hyper, hyper2, powerup, ultra, ultra2, ultra2i.
1199 # SunPRO cc 6 adds -xchip=ultra2e, ultra3cu.
1201 # FIXME: Which of ultra, ultra2 or ultra2i is the best fallback for
1205 supersparc) cc_cflags_cpu="-xchip=super" ;;
1206 microsparc) cc_cflags_cpu="-xchip=micro" ;;
1207 turbosparc) cc_cflags_cpu="-xchip=micro2" ;;
1208 ultrasparc) cc_cflags_cpu="-xchip=ultra" ;;
1209 ultrasparc2) cc_cflags_cpu="-xchip=ultra2" ;;
1210 ultrasparc2i) cc_cflags_cpu="-xchip=ultra2i" ;;
1211 ultrasparc3) cc_cflags_cpu="-xchip=ultra3 -xchip=ultra" ;;
1212 *) cc_cflags_cpu="-xchip=generic" ;;
1217 sparc64 | sparcv9* | ultrasparc*)
1219 # Solaris 6 and earlier cannot run ABI=64 since it doesn't save
1220 # registers properly, so ABI=32 is left as the only choice.
1222 [*-*-solaris2.[0-6] | *-*-solaris2.[0-6].*]) ;;
1224 # BSD sparc64 ports are 64-bit-only systems, so ABI=64 is the only
1225 # choice. In fact they need no special compiler flags, gcc -m64
1226 # is the default, but it doesn't hurt to add it. v9 CPUs always
1227 # use the sparc64 port, since the plain 32-bit sparc ports don't
1230 *-*-*bsd*) abilist="64" ;;
1232 # For all other systems, we try both 64 and 32.
1234 # GNU/Linux sparc64 has only recently gained a 64-bit user mode.
1235 # In the past sparc64 meant a v9 cpu, but there were no 64-bit
1236 # operations in user mode. We assume that if "gcc -m64" works
1237 # then the system is suitable. Hopefully even if someone attempts
1238 # to put a new gcc and/or glibc on an old system it won't run.
1240 *) abilist="64 32" ;;
1244 ultrasparc | ultrasparc2 | ultrasparc2i)
1245 path_64="sparc64/ultrasparc12 sparc64" ;;
1247 path_64="sparc64/ultrasparc34 sparc64/ultrasparc12 sparc64" ;;
1253 any_64_testlist="sizeof-long-8"
1255 # gcc -mptr64 is probably implied by -m64, but we're not sure if
1256 # this was always so. On Solaris in the past we always used both
1259 # gcc -Wa,-xarch=v9 is thought to be necessary in some cases on
1260 # solaris, but it would seem likely that if gcc is going to generate
1261 # 64-bit code it will have to add that option itself where needed.
1262 # An extra copy of this option should be harmless though, but leave
1263 # it until we're sure. (Might want -xarch=v9a or -xarch=v9b for the
1264 # higher cpu types instead.)
1266 gcc_64_cflags="$gcc_64_cflags -m64 -mptr64"
1267 gcc_64_ldflags="-Wc,-m64"
1268 gcc_64_cflags_optlist="cpu"
1274 # We used to have -fast and some fixup options here, but it
1275 # recurrently caused problems with miscompilation. Of course,
1276 # -fast is documented as miscompiling things for the sake of speed.
1278 cclist_64="$cclist_64 cc"
1279 cc_64_cflags="-xO3 -xarch=v9"
1280 cc_64_cflags_optlist="cpu"
1284 # using the v9 %tick register
1285 SPEED_CYCLECOUNTER_OBJ_32=sparcv9.lo
1286 SPEED_CYCLECOUNTER_OBJ_64=sparcv9.lo
1287 cyclecounter_size_32=2
1288 cyclecounter_size_64=2
1296 # Currently gcc (version 3.0) on vax always uses a frame pointer
1297 # (config/vax/vax.h FRAME_POINTER_REQUIRED=1), so -fomit-frame-pointer
1300 gcc_cflags="$gcc_cflags $fomit_frame_pointer"
1302 extra_functions="udiv_w_sdiv"
1306 # AMD and Intel x86 configurations, including AMD64
1308 # Rumour has it gcc -O2 used to give worse register allocation than just
1309 # -O, but lets assume that's no longer true.
1311 # -m32 forces 32-bit mode on a bi-arch 32/64 amd64 build of gcc. -m64 is
1312 # the default in such a build (we think), so -m32 is essential for ABI=32.
1313 # This is, of course, done for any $host_cpu, not just x86_64, so we can
1314 # get such a gcc into the right mode to cross-compile to say i486-*-*.
1316 # -m32 is not available in gcc 2.95 and earlier, hence cflags_maybe to use
1317 # it when it works. We check sizeof(long)==4 to ensure we get the right
1318 # mode, in case -m32 has failed not because it's an old gcc, but because
1319 # it's a dual 32/64-bit gcc without a 32-bit libc, or whatever.
1321 X86_PATTERN | X86_64_PATTERN)
1324 gcc_cflags="$gcc_cflags $fomit_frame_pointer"
1325 gcc_32_cflags_maybe="-m32"
1326 icc_cflags="-no-gcc"
1327 icc_cflags_optlist="opt"
1328 icc_cflags_opt="-O3 -O2 -O1"
1329 any_32_testlist="sizeof-long-4"
1330 CALLING_CONVENTIONS_OBJS='x86call.lo x86check$U.lo'
1332 # Availability of rdtsc is checked at run-time.
1333 SPEED_CYCLECOUNTER_OBJ=pentium.lo
1335 # gcc 2.7.2 only knows i386 and i486, using -m386 or -m486. These
1336 # represent -mcpu= since -m486 doesn't generate 486 specific insns.
1337 # gcc 2.95 adds k6, pentium and pentiumpro, and takes -march= and -mcpu=.
1338 # gcc 3.0 adds athlon.
1339 # gcc 3.1 adds k6-2, k6-3, pentium-mmx, pentium2, pentium3, pentium4,
1340 # athlon-tbird, athlon-4, athlon-xp, athlon-mp.
1341 # gcc 3.2 adds winchip2.
1342 # gcc 3.3 adds winchip-c6.
1343 # gcc 3.3.1 from mandrake adds k8 and knows -mtune.
1344 # gcc 3.4 adds c3, c3-2, k8, and deprecates -mcpu in favour of -mtune.
1346 # In gcc 2.95.[0123], -march=pentiumpro provoked a stack slot bug in an
1347 # old version of mpz/powm.c. Seems to be fine with the current code, so
1348 # no need for any restrictions on that option.
1350 # -march=pentiumpro can fail if the assembler doesn't know "cmov"
1351 # (eg. solaris 2.8 native "as"), so always have -march=pentium after
1352 # that as a fallback.
1354 # -march=pentium4 and -march=k8 enable SSE2 instructions, which may or
1355 # may not be supported by the assembler and/or the OS, and is bad in gcc
1356 # prior to 3.3. The tests will reject these if no good, so fallbacks
1357 # like "-march=pentium4 -mno-sse2" are given to try also without SSE2.
1358 # Note the relevant -march types are listed in the optflags handling
1359 # below, be sure to update there if adding new types emitting SSE2.
1361 # -mtune is used at the start of each cpu option list to give something
1362 # gcc 3.4 will use, thereby avoiding warnings from -mcpu. -mcpu forms
1363 # are retained for use by prior gcc. For example pentium has
1364 # "-mtune=pentium -mcpu=pentium ...", the -mtune is for 3.4 and the
1365 # -mcpu for prior. If there's a brand new choice in 3.4 for a chip,
1366 # like k8 for x86_64, then it can be the -mtune at the start, no need to
1367 # duplicate anything.
1369 gcc_cflags_optlist="cpu arch"
1372 gcc_cflags_cpu="-mtune=i386 -mcpu=i386 -m386"
1373 gcc_cflags_arch="-march=i386"
1376 gcc_cflags_cpu="-mtune=i486 -mcpu=i486 -m486"
1377 gcc_cflags_arch="-march=i486"
1380 gcc_cflags_cpu="-mtune=pentium -mcpu=pentium -m486"
1381 gcc_cflags_arch="-march=pentium"
1384 gcc_cflags_cpu="-mtune=pentium-mmx -mcpu=pentium-mmx -mcpu=pentium -m486"
1385 gcc_cflags_arch="-march=pentium-mmx -march=pentium"
1388 gcc_cflags_cpu="-mtune=pentiumpro -mcpu=pentiumpro -mcpu=i486 -m486"
1389 gcc_cflags_arch="-march=pentiumpro -march=pentium"
1392 gcc_cflags_cpu="-mtune=pentium2 -mcpu=pentium2 -mcpu=pentiumpro -mcpu=i486 -m486"
1393 gcc_cflags_arch="-march=pentium2 -march=pentiumpro -march=pentium"
1395 pentium3 | pentiumm)
1396 gcc_cflags_cpu="-mtune=pentium3 -mcpu=pentium3 -mcpu=pentiumpro -mcpu=i486 -m486"
1397 gcc_cflags_arch="-march=pentium3 -march=pentiumpro -march=pentium"
1400 gcc_cflags_cpu="-mtune=k6 -mcpu=k6 -mcpu=i486 -m486"
1401 gcc_cflags_arch="-march=k6"
1404 gcc_cflags_cpu="-mtune=k6-2 -mcpu=k6-2 -mcpu=k6 -mcpu=i486 -m486"
1405 gcc_cflags_arch="-march=k6-2 -march=k6"
1408 gcc_cflags_cpu="-mtune=k6-3 -mcpu=k6-3 -mcpu=k6 -mcpu=i486 -m486"
1409 gcc_cflags_arch="-march=k6-3 -march=k6"
1412 gcc_cflags_cpu="-mtune=k6-3 -mcpu=k6-3 -mcpu=k6 -mcpu=i486 -m486"
1413 gcc_cflags_arch="-march=k6-3 -march=k6"
1416 # Athlon instruction costs are close to P6 (3 cycle load latency,
1417 # 4-6 cycle mul, 40 cycle div, pairable adc, etc) so if gcc doesn't
1418 # know athlon (eg. 2.95.2 doesn't) then fall back on pentiumpro.
1419 gcc_cflags_cpu="-mtune=athlon -mcpu=athlon -mcpu=pentiumpro -mcpu=i486 -m486"
1420 gcc_cflags_arch="-march=athlon -march=pentiumpro -march=pentium"
1423 # pentiumpro is the primary fallback when gcc doesn't know pentium4.
1424 # This gets us cmov to eliminate branches. Maybe "athlon" would be
1425 # a possibility on gcc 3.0.
1427 gcc_cflags_cpu="-mtune=pentium4 -mcpu=pentium4 -mcpu=pentiumpro -mcpu=i486 -m486"
1428 gcc_cflags_arch="-march=pentium4 -march=pentium4~-mno-sse2 -march=pentiumpro -march=pentium"
1429 gcc_64_cflags_cpu="-mtune=nocona"
1432 # Not sure of the best fallbacks here for -mcpu.
1433 # c3-2 has sse and mmx, so pentium3 is good for -march.
1434 gcc_cflags_cpu="-mtune=c3-2 -mcpu=c3-2 -mcpu=i486 -m486"
1435 gcc_cflags_arch="-march=c3-2 -march=pentium3 -march=pentiumpro -march=pentium"
1438 # Not sure of the best fallbacks here.
1439 gcc_cflags_cpu="-mtune=c3 -mcpu=c3 -mcpu=i486 -m486"
1440 gcc_cflags_arch="-march=c3 -march=pentium-mmx -march=pentium"
1443 gcc_cflags_cpu="-mtune=k8 -mcpu=athlon -mcpu=pentiumpro -mcpu=i486 -m486"
1444 gcc_cflags_arch="-march=k8 -march=k8~-mno-sse2 -march=athlon -march=pentiumpro -march=pentium"
1447 gcc_cflags_cpu="-mtune=core2 -mtune=k8"
1448 gcc_cflags_arch="-march=core2 -march=core2~-mno-sse2 -march=k8 -march=k8~-mno-sse2"
1451 gcc_cflags_cpu="-mtune=atom -mtune=pentium3"
1452 gcc_cflags_arch="-march=atom -march=pentium3"
1455 gcc_cflags_cpu="-mtune=i486 -mcpu=i486 -m486"
1456 gcc_cflags_arch="-march=i486"
1461 i386*) path="x86" ;;
1462 i486*) path="x86/i486 x86" ;;
1463 i586 | pentium) path="x86/pentium x86" ;;
1464 pentiummmx) path="x86/pentium/mmx x86/pentium x86" ;;
1465 i686 | pentiumpro) path="x86/p6 x86" ;;
1466 pentium2) path="x86/p6/mmx x86/p6 x86" ;;
1467 pentium3) path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86";;
1468 pentiumm | core2 | corei)
1469 path="x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86";;
1470 [k6[23]]) path="x86/k6/k62mmx x86/k6/mmx x86/k6 x86" ;;
1471 k6) path="x86/k6/mmx x86/k6 x86" ;;
1472 geode) path="x86/k6/k62mmx x86/k6/mmx x86/k6 x86" ;;
1473 # we don't have any specific 32-bit code for athlon64/opteron, the
1474 # athlon code should be reasonable
1475 athlon | athlon64) path="x86/k7/mmx x86/k7 x86" ;;
1476 i786 | pentium4) path="x86/pentium4/sse2 x86/pentium4/mmx x86/pentium4 x86" ;;
1477 # VIA/Centaur processors, sold as CyrixIII and C3.
1478 viac32) path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86";;
1479 viac3*) path="x86/pentium/mmx x86/pentium x86";;
1480 atom) path="x86/atom x86" ;;
1487 gcc_64_cflags="$gcc_64_cflags -m64"
1488 gcc_64_cflags_optlist="cpu arch"
1489 CALLING_CONVENTIONS_OBJS_64='amd64call.lo amd64check$U.lo'
1490 SPEED_CYCLECOUNTER_OBJ_64=x86_64.lo
1491 cyclecounter_size_64=2
1499 path_64="x86_64/k8 $path_64"
1502 path_64="x86_64/pentium4 $path_64"
1505 path_64="x86_64/core2 $path_64"
1508 path_64="x86_64/corei x86_64/core2 $path_64"
1511 path_64="x86_64/atom $path_64"
1514 path_64="x86_64/nano $path_64"
1521 cclist_64="$cclist_64 cc"
1522 cc_64_cflags="-xO3 -m64"
1526 path_64="" # Windows amd64 calling conventions are *different*
1527 # Silence many pedantic warnings for w64. FIXME.
1528 gcc_64_cflags="$gcc_64_cflags -std=gnu99"
1536 # FIXME: z8kx won't get through config.sub. Could make 16 versus 32 bit
1537 # limb an ABI option perhaps.
1540 extra_functions="udiv_w_sdiv"
1544 extra_functions="udiv_w_sdiv"
1548 # Special CPU "none" selects generic C. -DNO_ASM is used to disable gcc
1549 # asm blocks in longlong.h (since they're driven by cpp pre-defined
1550 # symbols like __alpha rather than the configured $host_cpu).
1553 abilist="long longlong"
1555 gcc_long_cflags=$gcc_cflags
1556 gcc_long_cppflags="-DNO_ASM"
1557 cc_long_cflags=$cc_cflags
1558 cclist_longlong=$cclist
1559 gcc_longlong_cflags=$gcc_cflags
1560 gcc_longlong_cppflags="-DNO_ASM"
1561 cc_longlong_cflags=$cc_cflags
1562 limb_longlong=longlong
1567 # mingw can be built by the cygwin gcc if -mno-cygwin is added. For
1568 # convenience add this automatically if it works. Actual mingw gcc accepts
1569 # -mno-cygwin too, but of course is the default. mingw only runs on the
1570 # x86s, but allow any CPU here so as to catch "none" too.
1574 gcc_cflags_optlist="$gcc_cflags_optlist nocygwin"
1575 gcc_cflags_nocygwin="-mno-cygwin"
1580 CFLAGS_or_unset=${CFLAGS-'(unset)'}
1581 CPPFLAGS_or_unset=${CPPFLAGS-'(unset)'}
1583 cat >&AC_FD_CC <<EOF
1587 CFLAGS=$CFLAGS_or_unset
1588 CPPFLAGS=$CPPFLAGS_or_unset
1596 test_CFLAGS=${CFLAGS+set}
1597 test_CPPFLAGS=${CPPFLAGS+set}
1599 for abi in $abilist; do
1603 # If the user specifies an ABI then it must be in $abilist, after that
1604 # $abilist is restricted to just that choice.
1606 if test -n "$ABI"; then
1608 for abi in $abilist; do
1609 if test $abi = "$ABI"; then found=yes; break; fi
1611 if test $found = no; then
1612 AC_MSG_ERROR([ABI=$ABI is not among the following valid choices: $abilist])
1619 for abi in $abilist; do
1621 echo "checking ABI=$abi"
1623 # Suppose abilist="64 32", then for abi=64, will have abi1="_64" and
1624 # abi2="_64". For abi=32, will have abi1="_32" and abi2="". This is how
1625 # $gcc_cflags becomes a fallback for $gcc_32_cflags (the last in the
1626 # abilist), but there's no fallback for $gcc_64_cflags.
1628 abi1=[`echo _$abi | sed 's/[.]//g'`]
1629 if test $abi = $abi_last; then abi2=; else abi2="$abi1"; fi
1631 # Compiler choices under this ABI
1632 eval cclist_chosen=\"\$cclist$abi1\"
1633 test -n "$cclist_chosen" || eval cclist_chosen=\"\$cclist$abi2\"
1635 # If there's a user specified $CC then don't use a list for
1636 # $cclist_chosen, just a single value for $ccbase.
1638 if test -n "$CC"; then
1640 # The first word of $CC, stripped of any directory. For instance
1641 # CC="/usr/local/bin/gcc -pipe" will give "gcc".
1643 for ccbase in $CC; do break; done
1644 ccbase=`echo $ccbase | sed 's:.*/::'`
1646 # If this $ccbase is in $cclist_chosen then it's a compiler we know and
1647 # we can do flags defaulting with it. If not, then $cclist_chosen is
1648 # set to "unrecognised" so no default flags are used.
1650 # "unrecognised" is used to avoid bad effects with eval if $ccbase has
1651 # non-symbol characters. For instance ccbase=my+cc would end up with
1652 # something like cflags="$my+cc_cflags" which would give
1653 # cflags="+cc_cflags" rather than the intended empty string for an
1657 for i in $cclist_chosen; do
1658 if test "$ccbase" = $i; then
1663 cclist_chosen=$found
1666 for ccbase in $cclist_chosen; do
1668 # When cross compiling, look for a compiler with the $host_alias as a
1669 # prefix, the same way that AC_CHECK_TOOL does. But don't do this to a
1670 # user-selected $CC.
1672 # $cross_compiling will be yes/no/maybe at this point. Do the host
1673 # prefixing for "maybe" as well as "yes".
1675 if test "$cross_compiling" != no && test -z "$CC"; then
1676 cross_compiling_prefix="${host_alias}-"
1679 for ccprefix in $cross_compiling_prefix ""; do
1682 test -n "$cc" || cc="$ccprefix$ccbase"
1684 # If the compiler is gcc but installed under another name, then change
1685 # $ccbase so as to use the flags we know for gcc. This helps for
1686 # instance when specifying CC=gcc272 on Debian GNU/Linux, or the
1687 # native cc which is really gcc on NeXT or MacOS-X.
1689 # FIXME: There's a slight misfeature here. If cc is actually gcc but
1690 # gcc is not a known compiler under this $abi then we'll end up
1691 # testing it with no flags and it'll work, but chances are it won't be
1692 # in the right mode for the ABI we desire. Let's quietly hope this
1695 if test $ccbase != gcc; then
1696 GMP_PROG_CC_IS_GNU($cc,ccbase=gcc)
1699 # Similarly if the compiler is IBM xlc but invoked as cc or whatever
1700 # then change $ccbase and make the default xlc flags available.
1701 if test $ccbase != xlc; then
1702 GMP_PROG_CC_IS_XLC($cc,ccbase=xlc)
1705 # acc was Sun's first unbundled compiler back in the SunOS days, or
1706 # something like that, but today its man page says it's not meant to
1707 # be used directly (instead via /usr/ucb/cc). The options are pretty
1708 # much the same as the main SunPRO cc, so share those configs.
1711 *sparc*-*-solaris* | *sparc*-*-sunos*)
1712 if test "$ccbase" = acc; then ccbase=cc; fi ;;
1715 for tmp_cflags_maybe in yes no; do
1716 eval cflags=\"\$${ccbase}${abi1}_cflags\"
1717 test -n "$cflags" || eval cflags=\"\$${ccbase}${abi2}_cflags\"
1719 if test "$tmp_cflags_maybe" = yes; then
1720 # don't try cflags_maybe when the user set CFLAGS
1721 if test "$test_CFLAGS" = set; then continue; fi
1722 eval cflags_maybe=\"\$${ccbase}${abi1}_cflags_maybe\"
1723 test -n "$cflags_maybe" || eval cflags_maybe=\"\$${ccbase}${abi2}_cflags_maybe\"
1724 # don't try cflags_maybe if there's nothing set
1725 if test -z "$cflags_maybe"; then continue; fi
1726 cflags="$cflags_maybe $cflags"
1729 # Any user CFLAGS, even an empty string, takes precedence
1730 if test "$test_CFLAGS" = set; then cflags=$CFLAGS; fi
1732 # Any user CPPFLAGS, even an empty string, takes precedence
1733 eval cppflags=\"\$${ccbase}${abi1}_cppflags\"
1734 test -n "$cppflags" || eval cppflags=\"\$${ccbase}${abi2}_cppflags\"
1735 if test "$test_CPPFLAGS" = set; then cppflags=$CPPFLAGS; fi
1737 # --enable-profiling adds -p/-pg even to user-specified CFLAGS.
1738 # This is convenient, but it's perhaps a bit naughty to modify user
1740 case "$enable_profiling" in
1741 prof) cflags="$cflags -p" ;;
1742 gprof) cflags="$cflags -pg" ;;
1743 instrument) cflags="$cflags -finstrument-functions" ;;
1746 GMP_PROG_CC_WORKS($cc $cflags $cppflags,,continue)
1748 # If we're supposed to be using a "long long" for a limb, check that
1750 eval limb_chosen=\"\$limb$abi1\"
1751 test -n "$limb_chosen" || eval limb_chosen=\"\$limb$abi2\"
1752 if test "$limb_chosen" = longlong; then
1753 GMP_PROG_CC_WORKS_LONGLONG($cc $cflags $cppflags,,continue)
1756 # The tests to perform on this $cc, if any
1757 eval testlist=\"\$${ccbase}${abi1}_testlist\"
1758 test -n "$testlist" || eval testlist=\"\$${ccbase}${abi2}_testlist\"
1759 test -n "$testlist" || eval testlist=\"\$any${abi1}_testlist\"
1760 test -n "$testlist" || eval testlist=\"\$any${abi2}_testlist\"
1763 for tst in $testlist; do
1765 hpc-hppa-2-0) GMP_HPC_HPPA_2_0($cc,,testlist_pass=no) ;;
1766 gcc-arm-umodsi) GMP_GCC_ARM_UMODSI($cc,,testlist_pass=no) ;;
1767 gcc-mips-o32) GMP_GCC_MIPS_O32($cc,,testlist_pass=no) ;;
1768 hppa-level-2.0) GMP_HPPA_LEVEL_20($cc $cflags,,testlist_pass=no) ;;
1769 sizeof*) GMP_C_TEST_SIZEOF($cc $cflags,$tst,,testlist_pass=no) ;;
1771 if test $testlist_pass = no; then break; fi
1774 if test $testlist_pass = yes; then
1780 if test $found_compiler = yes; then break; fi
1783 if test $found_compiler = yes; then break; fi
1786 if test $found_compiler = yes; then break; fi
1790 # If we recognised the CPU, as indicated by $path being set, then insist
1791 # that we have a working compiler, either from our $cclist choices or from
1792 # $CC. We can't let AC_PROG_CC look around for a compiler because it might
1793 # find one that we've rejected (for not supporting the modes our asm code
1796 # If we didn't recognise the CPU (and this includes host_cpu=none), then
1797 # fall through and let AC_PROG_CC look around for a compiler too. This is
1798 # mostly in the interests of following a standard autoconf setup, after all
1799 # we've already tested cc and gcc adequately (hopefully). As of autoconf
1800 # 2.50 the only thing AC_PROG_CC really adds is a check for "cl" (Microsoft
1801 # C on MS-DOS systems).
1803 if test $found_compiler = no && test -n "$path"; then
1804 AC_MSG_ERROR([could not find a working compiler, see config.log for details])
1808 X86_PATTERN | X86_64_PATTERN)
1809 # If the user asked for a fat build, override the path and flags set above
1810 if test $enable_fat = yes; then
1814 if test "$abi" = 32; then
1815 extra_functions="$extra_functions fat fat_entry"
1817 fat_path="x86 x86/fat x86/i486
1818 x86/k6 x86/k6/mmx x86/k6/k62mmx
1820 x86/pentium x86/pentium/mmx
1821 x86/p6 x86/p6/mmx x86/p6/p3mmx x86/p6/sse2
1822 x86/pentium4 x86/pentium4/mmx x86/pentium4/sse2"
1825 if test "$abi" = 64; then
1827 extra_functions_64="$extra_functions_64 fat fat_entry"
1828 path_64="x86_64/fat x86_64"
1829 fat_path="x86_64 x86_64/fat x86_64/pentium4 x86_64/core2 x86_64/corei x86_64/atom x86_64/nano"
1832 fat_functions="add_n addmul_1 copyd copyi
1833 dive_1 diveby3 divrem_1 gcd_1 lshift
1834 mod_1 mod_34lsub1 mode1o mul_1 mul_basecase
1835 pre_divrem_1 pre_mod_1 rshift
1836 sqr_basecase sub_n submul_1"
1837 fat_thresholds="MUL_TOOM22_THRESHOLD MUL_TOOM33_THRESHOLD
1838 SQR_TOOM2_THRESHOLD SQR_TOOM3_THRESHOLD"
1844 if test $found_compiler = yes; then
1846 # If we're creating CFLAGS, then look for optional additions. If the user
1847 # set CFLAGS then leave it alone.
1849 if test "$test_CFLAGS" != set; then
1850 eval optlist=\"\$${ccbase}${abi1}_cflags_optlist\"
1851 test -n "$optlist" || eval optlist=\"\$${ccbase}${abi2}_cflags_optlist\"
1853 for opt in $optlist; do
1854 eval optflags=\"\$${ccbase}${abi1}_cflags_${opt}\"
1855 test -n "$optflags" || eval optflags=\"\$${ccbase}${abi2}_cflags_${opt}\"
1856 test -n "$optflags" || eval optflags=\"\$${ccbase}_cflags_${opt}\"
1858 for flag in $optflags; do
1860 # ~ represents a space in an option spec
1861 flag=`echo "$flag" | tr '~' ' '`
1864 -march=pentium4 | -march=k8)
1865 # For -march settings which enable SSE2 we exclude certain bad
1866 # gcc versions and we need an OS knowing how to save xmm regs.
1868 # This is only for ABI=32, any 64-bit gcc is good and any OS
1869 # knowing x86_64 will know xmm.
1871 # -march=k8 was only introduced in gcc 3.3, so we shouldn't need
1872 # the GMP_GCC_PENTIUM4_SSE2 check (for gcc 3.2 and prior). But
1873 # it doesn't hurt to run it anyway, sharing code with the
1876 if test "$abi" = 32; then
1877 GMP_GCC_PENTIUM4_SSE2($cc $cflags $cppflags,, continue)
1878 GMP_OS_X86_XMM($cc $cflags $cppflags,, continue)
1882 # special check, avoiding a warning
1883 GMP_GCC_NO_CPP_PRECOMP($ccbase,$cc,$cflags,
1884 [cflags="$cflags $flag"
1891 GMP_GCC_WA_MCPU($cc $cflags, $flag, , [continue])
1896 GMP_GCC_WA_OLDAS($cc $cflags $cppflags,
1897 [cflags="$cflags $flag"
1903 GMP_PROG_CC_WORKS($cc $cflags $cppflags $flag,
1904 [cflags="$cflags $flag"
1913 CPPFLAGS="$cppflags"
1916 # Could easily have this in config.h too, if desired.
1917 ABI_nodots=`echo $ABI | sed 's/\./_/'`
1918 GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_ABI_$ABI_nodots')", POST)
1921 # GMP_LDFLAGS substitution, selected according to ABI.
1922 # These are needed on libgmp.la and libmp.la, but currently not on
1923 # convenience libraries like tune/libspeed.la or mpz/libmpz.la.
1925 eval GMP_LDFLAGS=\"\$${ccbase}${abi1}_ldflags\"
1926 test -n "$GMP_LDFLAGS" || eval GMP_LDFLAGS=\"\$${ccbase}${abi1}_ldflags\"
1927 AC_SUBST(GMP_LDFLAGS)
1928 AC_SUBST(LIBGMP_LDFLAGS)
1929 AC_SUBST(LIBGMPXX_LDFLAGS)
1931 # extra_functions, selected according to ABI
1932 eval tmp=\"\$extra_functions$abi1\"
1933 test -n "$tmp" || eval tmp=\"\$extra_functions$abi2\"
1934 extra_functions="$tmp"
1937 # Cycle counter, selected according to ABI.
1939 eval tmp=\"\$SPEED_CYCLECOUNTER_OBJ$abi1\"
1940 test -n "$tmp" || eval tmp=\"\$SPEED_CYCLECOUNTER_OBJ$abi2\"
1941 SPEED_CYCLECOUNTER_OBJ="$tmp"
1942 eval tmp=\"\$cyclecounter_size$abi1\"
1943 test -n "$tmp" || eval tmp=\"\$cyclecounter_size$abi2\"
1944 cyclecounter_size="$tmp"
1946 if test -n "$SPEED_CYCLECOUNTER_OBJ"; then
1947 AC_DEFINE_UNQUOTED(HAVE_SPEED_CYCLECOUNTER, $cyclecounter_size,
1948 [Tune directory speed_cyclecounter, undef=none, 1=32bits, 2=64bits)])
1950 AC_SUBST(SPEED_CYCLECOUNTER_OBJ)
1953 # Calling conventions checking, selected according to ABI.
1955 eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi1\"
1956 test -n "$tmp" || eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi2\"
1957 CALLING_CONVENTIONS_OBJS="$tmp"
1959 if test -n "$CALLING_CONVENTIONS_OBJS"; then
1960 AC_DEFINE(HAVE_CALLING_CONVENTIONS,1,
1961 [Define to 1 if tests/libtests has calling conventions checking for the CPU])
1963 AC_SUBST(CALLING_CONVENTIONS_OBJS)
1968 # If the user gave an MPN_PATH, use that verbatim, otherwise choose
1969 # according to the ABI and add "generic".
1971 if test -n "$MPN_PATH"; then
1974 eval tmp=\"\$path$abi1\"
1975 test -n "$tmp" || eval tmp=\"\$path$abi2\"
1980 # Long long limb setup for gmp.h.
1981 case $limb_chosen in
1982 longlong) DEFN_LONG_LONG_LIMB="#define _LONG_LONG_LIMB 1" ;;
1983 *) DEFN_LONG_LONG_LIMB="/* #undef _LONG_LONG_LIMB */" ;;
1985 AC_SUBST(DEFN_LONG_LONG_LIMB)
1988 # The C compiler and preprocessor, put into ANSI mode if possible.
1995 # The C compiler on the build system, and associated tests.
1996 GMP_PROG_CC_FOR_BUILD
1997 GMP_PROG_CPP_FOR_BUILD
1998 GMP_PROG_EXEEXT_FOR_BUILD
1999 GMP_C_FOR_BUILD_ANSI
2000 GMP_CHECK_LIBM_FOR_BUILD
2003 # How to assemble, used with CFLAGS etc, see mpn/Makeasm.am.
2004 # Using the compiler is a lot easier than figuring out how to invoke the
2005 # assembler directly.
2007 test -n "$CCAS" || CCAS="$CC -c"
2011 # The C++ compiler, if desired.
2013 if test $enable_cxx != no; then
2014 test_CXXFLAGS=${CXXFLAGS+set}
2017 echo "CXXFLAGS chosen by autoconf: $CXXFLAGS" >&AC_FD_CC
2018 cxxflags_ac_prog_cxx=$CXXFLAGS
2019 cxxflags_list=ac_prog_cxx
2021 # If the user didn't specify $CXXFLAGS, then try $CFLAGS, with -g removed
2022 # if AC_PROG_CXX thinks that doesn't work. $CFLAGS stands a good chance
2023 # of working, eg. on a GNU system where CC=gcc and CXX=g++.
2025 if test "$test_CXXFLAGS" != set; then
2026 cxxflags_cflags=$CFLAGS
2027 cxxflags_list="cflags $cxxflags_list"
2028 if test "$ac_prog_cxx_g" = no; then
2029 cxxflags_cflags=`echo "$cxxflags_cflags" | sed -e 's/ -g //' -e 's/^-g //' -e 's/ -g$//'`
2033 # See if the C++ compiler works. If the user specified CXXFLAGS then all
2034 # we're doing is checking whether AC_PROG_CXX succeeded, since it doesn't
2035 # give a fatal error, just leaves CXX set to a default g++. If on the
2036 # other hand the user didn't specify CXXFLAGS then we get to try here our
2037 # $cxxflags_list alternatives.
2039 # Automake includes $CPPFLAGS in a C++ compile, so we do the same here.
2041 for cxxflags_choice in $cxxflags_list; do
2042 eval CXXFLAGS=\"\$cxxflags_$cxxflags_choice\"
2043 GMP_PROG_CXX_WORKS($CXX $CPPFLAGS $CXXFLAGS,
2048 # If --enable-cxx=yes but a C++ compiler can't be found, then abort.
2049 if test $want_cxx = no && test $enable_cxx = yes; then
2050 AC_MSG_ERROR([C++ compiler not available, see config.log for details])
2054 AM_CONDITIONAL(WANT_CXX, test $want_cxx = yes)
2056 # FIXME: We're not interested in CXXCPP for ourselves, but if we don't do it
2057 # here then AC_PROG_LIBTOOL will AC_REQUIRE it (via _LT_AC_TAGCONFIG) and
2058 # hence execute it unconditionally, and that will fail if there's no C++
2059 # compiler (and no generic /lib/cpp).
2061 if test $want_cxx = yes; then
2066 # Path setups for Cray, according to IEEE or CFP. These must come after
2067 # deciding the compiler.
2070 [add_path="cray/ieee"],
2071 [add_path="cray/cfp"; extra_functions="mulwwc90"],
2072 [add_path="cray/cfp"; extra_functions="mulwwj90"])
2075 if test -z "$MPN_PATH"; then
2076 path="$add_path $path"
2079 # For a nail build, also look in "nails" subdirectories.
2081 if test $GMP_NAIL_BITS != 0 && test -z "$MPN_PATH"; then
2085 generic) new_path="$new_path $i" ;;
2086 *) new_path="$new_path $i/nails $i" ;;
2093 # Put all directories into CPUVEC_list so as to get a full set of
2094 # CPUVEC_SETUP_$tmp_suffix defines into config.h, even if some of them are
2095 # empty because mmx and/or sse2 had to be dropped.
2097 for i in $fat_path; do
2098 GMP_FAT_SUFFIX(tmp_suffix, $i)
2099 CPUVEC_list="$CPUVEC_list CPUVEC_SETUP_$tmp_suffix"
2103 # If there's any sse2 or mmx in the path, check whether the assembler
2104 # supports it, and remove if not.
2106 # We only need this in ABI=32, for ABI=64 on x86_64 we can assume a new
2110 X86_PATTERN | X86_64_PATTERN)
2111 if test "$ABI" = 32; then
2112 case "$path $fat_path" in
2113 *mmx*) GMP_ASM_X86_MMX( , [GMP_STRIP_PATH(*mmx*)]) ;;
2115 case "$path $fat_path" in
2116 *sse2*) GMP_ASM_X86_SSE2( , [GMP_STRIP_PATH(sse2)]) ;;
2123 cat >&AC_FD_CC <<EOF
2129 GMP_LDFLAGS=$GMP_LDFLAGS
2134 echo "using ABI=\"$ABI\""
2136 echo " CFLAGS=\"$CFLAGS\""
2137 echo " CPPFLAGS=\"$CPPFLAGS\""
2138 if test $want_cxx = yes; then
2139 echo " CXX=\"$CXX\""
2140 echo " CXXFLAGS=\"$CXXFLAGS\""
2142 echo " MPN_PATH=\"$path\""
2145 # Automake ansi2knr support.
2154 # FIXME: On AIX 3 and 4, $libname.a is included in libtool
2155 # $library_names_spec, so libgmp.a becomes a symlink to libgmp.so, making
2156 # it impossible to build shared and static libraries simultaneously.
2157 # Disable shared libraries by default, but let the user override with
2158 # --enable-shared --disable-static.
2160 # FIXME: This $libname.a problem looks like it might apply to *-*-amigaos*
2161 # and *-*-os2* too, but wait for someone to test this before worrying
2162 # about it. If there is a problem then of course libtool is the right
2166 if test -z "$enable_shared"; then enable_shared=no; fi ;;
2170 # Configs for Windows DLLs.
2172 AC_LIBTOOL_WIN32_DLL
2174 AC_SUBST(LIBGMP_DLL,0)
2176 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
2177 # By default, build only static.
2178 if test -z "$enable_shared"; then
2181 # Don't allow both static and DLL.
2182 if test "$enable_shared" != no && test "$enable_static" != no; then
2183 AC_MSG_ERROR([cannot build both static and DLL, since gmp.h is different for each.
2184 Use "--disable-static --enable-shared" to build just a DLL.])
2187 # "-no-undefined" is required when building a DLL, see documentation on
2188 # AC_LIBTOOL_WIN32_DLL.
2190 # "-Wl,--export-all-symbols" is a bit of a hack, it gets all libgmp and
2191 # libgmpxx functions and variables exported. This is what libtool did
2192 # in the past, and it's convenient for us in the test programs.
2194 # Maybe it'd be prudent to check for --export-all-symbols before using
2195 # it, but it seems to have been in ld since at least 2000, and there's
2196 # not really any alternative we want to take up at the moment.
2198 # "-Wl,output-def" is used to get a .def file for use by MS lib to make
2199 # a .lib import library, described in the manual. libgmp-3.dll.def
2200 # corresponds to the libmp-3.dll.def generated by libtool (as a result
2201 # of -export-symbols on that library).
2203 # Incidentally, libtool does generate an import library libgmp.dll.a,
2204 # but it's "ar" format and cannot be used by the MS linker. There
2205 # doesn't seem to be any GNU tool for generating or converting to .lib.
2207 # FIXME: The .def files produced by -Wl,output-def include isascii,
2208 # iscsym, iscsymf and toascii, apparently because mingw ctype.h doesn't
2209 # inline isascii (used in gmp). It gives an extern inline for
2210 # __isascii, but for some reason not the plain isascii.
2212 if test "$enable_shared" = yes; then
2213 GMP_LDFLAGS="$GMP_LDFLAGS -no-undefined -Wl,--export-all-symbols"
2214 LIBGMP_LDFLAGS="$LIBGMP_LDFLAGS -Wl,--output-def,.libs/libgmp-3.dll.def"
2215 LIBGMPXX_LDFLAGS="$LIBGMP_LDFLAGS -Wl,--output-def,.libs/libgmpxx-3.dll.def"
2222 # Ensure that $CONFIG_SHELL is available for AC_LIBTOOL_SYS_MAX_CMD_LEN.
2223 # It's often set already by _LT_AC_PROG_ECHO_BACKSLASH or
2224 # _AS_LINENO_PREPARE, but not always.
2226 # The symptom of CONFIG_SHELL unset is some "expr" errors during the test,
2227 # and an empty result. This only happens when invoked as "sh configure",
2228 # ie. no path, and can be seen for instance on ia64-*-hpux*.
2230 # FIXME: Newer libtool should have it's own fix for this.
2232 if test -z "$CONFIG_SHELL"; then
2236 # Enable CXX in libtool only if we want it, and never enable GCJ, nor RC on
2237 # mingw and cygwin. Under --disable-cxx this avoids some error messages
2238 # from libtool arising from the fact we didn't actually run AC_PROG_CXX.
2239 # Notice that any user-supplied --with-tags setting takes precedence.
2241 # FIXME: Is this the right way to get this effect? Very possibly not, but
2242 # the current _LT_AC_TAGCONFIG doesn't really suggest an alternative.
2244 if test "${with_tags+set}" != set; then
2245 if test $want_cxx = yes; then
2252 # The dead hand of AC_REQUIRE makes AC_PROG_LIBTOOL expand and execute
2253 # AC_PROG_F77, even when F77 is not in the selected with_tags. This is
2254 # probably harmless, but it's unsightly and bloats our configure, so pretend
2255 # AC_PROG_F77 has been expanded already.
2257 # FIXME: Rumour has it libtool will one day provide a way for a configure.in
2258 # to say what it wants from among supported languages etc.
2260 AC_PROVIDE([AC_PROG_F77])
2264 # Generate an error here if attempting to build both shared and static when
2265 # $libname.a is in $library_names_spec (as mentioned above), rather than
2266 # wait for ar or ld to fail.
2268 if test "$enable_shared" = yes && test "$enable_static" = yes; then
2269 case $library_names_spec in
2271 AC_MSG_ERROR([cannot create both shared and static libraries on this system, --disable one of the two])
2276 AM_CONDITIONAL(ENABLE_STATIC, test "$enable_static" = yes)
2279 # Many of these library and header checks are for the benefit of
2280 # supplementary programs. libgmp doesn't use anything too weird.
2285 # Reasons for testing:
2286 # float.h - not in SunOS bundled cc
2287 # invent.h - IRIX specific
2288 # langinfo.h - X/Open standard only, not in djgpp for instance
2289 # locale.h - old systems won't have this
2290 # nl_types.h - X/Open standard only, not in djgpp for instance
2291 # (usually langinfo.h gives nl_item etc, but not on netbsd 1.4.1)
2292 # sys/attributes.h - IRIX specific
2293 # sys/iograph.h - IRIX specific
2294 # sys/mman.h - not in Cray Unicos
2295 # sys/param.h - not in mingw
2296 # sys/processor.h - solaris specific, though also present in macos
2297 # sys/pstat.h - HPUX specific
2298 # sys/resource.h - not in mingw
2299 # sys/sysctl.h - not in mingw
2300 # sys/sysinfo.h - OSF specific
2301 # sys/syssgi.h - IRIX specific
2302 # sys/systemcfg.h - AIX specific
2303 # sys/time.h - autoconf suggests testing, don't know anywhere without it
2304 # sys/times.h - not in mingw
2305 # machine/hal_sysinfo.h - OSF specific
2307 # inttypes.h, stdint.h, unistd.h and sys/types.h are already in the autoconf
2310 AC_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)
2312 # On SunOS, sys/resource.h needs sys/time.h (for struct timeval)
2313 AC_CHECK_HEADERS(sys/resource.h,,,
2314 [#if TIME_WITH_SYS_TIME
2315 # include <sys/time.h>
2318 # if HAVE_SYS_TIME_H
2319 # include <sys/time.h>
2325 # On NetBSD and OpenBSD, sys/sysctl.h needs sys/param.h for various constants
2326 AC_CHECK_HEADERS(sys/sysctl.h,,,
2327 [#if HAVE_SYS_PARAM_H
2328 # include <sys/param.h>
2331 # On OSF 4.0, <machine/hal_sysinfo.h> must have <sys/sysinfo.h> for ulong_t
2332 AC_CHECK_HEADERS(machine/hal_sysinfo.h,,,
2333 [#if HAVE_SYS_SYSINFO_H
2334 # include <sys/sysinfo.h>
2337 # Reasons for testing:
2338 # optarg - not declared in mingw
2339 # fgetc, fscanf, ungetc, vfprintf - not declared in SunOS 4
2340 # sys_errlist, sys_nerr - not declared in SunOS 4
2342 # optarg should be in unistd.h and the rest in stdio.h, both of which are
2343 # in the autoconf default includes.
2345 # sys_errlist and sys_nerr are supposed to be in <errno.h> on SunOS according
2346 # to the man page (but aren't), in glibc they're in stdio.h.
2348 AC_CHECK_DECLS([fgetc, fscanf, optarg, ungetc, vfprintf])
2349 AC_CHECK_DECLS([sys_errlist, sys_nerr], , ,
2351 #include <errno.h>])
2355 # Reasons for testing:
2357 # long double - not in the HP bundled K&R cc
2358 # long long - only in reasonably recent compilers
2359 # ptrdiff_t - seems to be everywhere, maybe don't need to check this
2360 # quad_t - BSD specific
2361 # uint_least32_t - C99
2363 # the default includes are sufficient for all these types
2365 AC_CHECK_TYPES([intmax_t, long double, long long, ptrdiff_t, quad_t,
2366 uint_least32_t, intptr_t])
2370 # FIXME: Really want #ifndef __cplusplus around the #define volatile
2371 # replacement autoconf gives, since volatile is always available in C++.
2372 # But we don't use it in C++ currently.
2378 GMP_C_ATTRIBUTE_CONST
2379 GMP_C_ATTRIBUTE_MALLOC
2380 GMP_C_ATTRIBUTE_MODE
2381 GMP_C_ATTRIBUTE_NORETURN
2395 [AC_DEFINE(HAVE_LIMB_BIG_ENDIAN, 1)
2396 GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_LIMB_BIG_ENDIAN')", POST)],
2397 [AC_DEFINE(HAVE_LIMB_LITTLE_ENDIAN, 1)
2398 GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_LIMB_LITTLE_ENDIAN')", POST)
2400 AH_VERBATIM([HAVE_LIMB],
2401 [/* Define one of these to 1 for the endianness of `mp_limb_t'.
2402 If the endianness is not a simple big or little, or you don't know what
2403 it is, then leave both undefined. */
2404 #undef HAVE_LIMB_BIG_ENDIAN
2405 #undef HAVE_LIMB_LITTLE_ENDIAN])
2410 # Reasons for testing:
2411 # alarm - not in mingw
2412 # attr_get - IRIX specific
2413 # clock_gettime - not in glibc 2.2.4, only very recent systems
2414 # cputime - not in glibc
2415 # getsysinfo - OSF specific
2416 # getrusage - not in mingw
2417 # gettimeofday - not in mingw
2418 # mmap - not in mingw, djgpp
2419 # nl_langinfo - X/Open standard only, not in djgpp for instance
2420 # obstack_vprintf - glibc specific
2421 # processor_info - solaris specific
2422 # pstat_getprocessor - HPUX specific (10.x and up)
2423 # raise - an ANSI-ism, though probably almost universal by now
2424 # read_real_time - AIX specific
2425 # sigaction - not in mingw
2426 # sigaltstack - not in mingw, or old AIX (reputedly)
2427 # sigstack - not in mingw
2428 # strerror - not in SunOS
2429 # strnlen - glibc extension (some other systems too)
2430 # syssgi - IRIX specific
2431 # times - not in mingw
2433 # clock_gettime is in librt on *-*-osf5.1. We could look for it
2434 # there, but that's not worth bothering with unless it has a decent
2435 # resolution (in a quick test clock_getres said only 1 millisecond).
2437 # AC_FUNC_STRNLEN is not used because we don't want the AC_LIBOBJ
2438 # replacement setups it gives. It detects a faulty strnlen on AIX, but
2439 # missing out on that test is ok since our only use of strnlen is in
2440 # __gmp_replacement_vsnprintf which is not required on AIX since it has a
2443 AC_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)
2446 GMP_FUNC_SSCANF_WRITABLE_INPUT
2448 # Reasons for checking:
2449 # pst_processor psp_iticksperclktick - not in hpux 9
2451 AC_CHECK_MEMBER(struct pst_processor.psp_iticksperclktick,
2452 [AC_DEFINE(HAVE_PSP_ITICKSPERCLKTICK, 1,
2453 [Define to 1 if <sys/pstat.h> `struct pst_processor' exists
2454 and contains `psp_iticksperclktick'.])],,
2455 [#include <sys/pstat.h>])
2457 # C++ tests, when required
2459 if test $enable_cxx = yes; then
2462 # Reasons for testing:
2463 # <sstream> - not in g++ 2.95.2
2464 # std::locale - not in g++ 2.95.4
2466 AC_CHECK_HEADERS([sstream])
2467 AC_CHECK_TYPES([std::locale],,,[#include <locale>])
2473 # Pick the correct source files in $path and link them to mpn/.
2474 # $gmp_mpn_functions lists all functions we need.
2476 # The rule is to find a file with the function name and a .asm, .S,
2477 # .s, or .c extension. Certain multi-function files with special names
2478 # can provide some functions too. (mpn/Makefile.am passes
2479 # -DOPERATION_<func> to get them to generate the right code.)
2481 # Note: $gmp_mpn_functions must have mod_1 before pre_mod_1 so the former
2482 # can optionally provide the latter as an extra entrypoint. Likewise
2483 # divrem_1 and pre_divrem_1.
2485 gmp_mpn_functions_optional="umul udiv \
2486 invert_limb sqr_diagonal \
2488 addmul_2 addmul_3 addmul_4 addmul_5 addmul_6 addmul_7 addmul_8 \
2489 addlsh1_n sublsh1_n rsblsh1_n rsh1add_n rsh1sub_n \
2490 addlsh2_n sublsh2_n rsblsh2_n \
2491 addlsh_n sublsh_n rsblsh_n \
2492 add_n_sub_n addaddmul_1msb0"
2494 gmp_mpn_functions="$extra_functions \
2495 add add_1 add_n sub sub_1 sub_n neg com mul_1 addmul_1 \
2496 submul_1 lshift rshift dive_1 diveby3 divis divrem divrem_1 divrem_2 \
2497 fib2_ui mod_1 mod_34lsub1 mode1o pre_divrem_1 pre_mod_1 dump \
2498 mod_1_1 mod_1_2 mod_1_3 mod_1_4 lshiftc \
2499 mul mul_fft mul_n sqr mul_basecase sqr_basecase nussbaumer_mul \
2500 random random2 pow_1 \
2501 rootrem sqrtrem get_str set_str scan0 scan1 popcount hamdist cmp \
2503 gcd_1 gcd gcdext_1 gcdext gcd_lehmer gcd_subdiv_step \
2504 gcdext_lehmer gcdext_subdiv_step \
2505 div_q tdiv_qr jacbase get_d \
2506 matrix22_mul hgcd2 hgcd mullo_n mullo_basecase \
2507 toom22_mul toom32_mul toom42_mul toom52_mul toom62_mul \
2508 toom33_mul toom43_mul toom53_mul toom63_mul \
2510 toom6h_mul toom6_sqr toom8h_mul toom8_sqr \
2511 toom_couple_handling \
2512 toom2_sqr toom3_sqr toom4_sqr \
2513 toom_eval_dgr3_pm1 toom_eval_dgr3_pm2 \
2514 toom_eval_pm1 toom_eval_pm2 toom_eval_pm2exp toom_eval_pm2rexp \
2515 toom_interpolate_5pts toom_interpolate_6pts toom_interpolate_7pts \
2516 toom_interpolate_8pts toom_interpolate_12pts toom_interpolate_16pts \
2517 invertappr invert binvert mulmod_bnm1 sqrmod_bnm1 \
2518 sbpi1_div_q sbpi1_div_qr sbpi1_divappr_q \
2519 dcpi1_div_q dcpi1_div_qr dcpi1_divappr_q \
2520 mu_div_qr mu_divappr_q mu_div_q \
2522 sbpi1_bdiv_q sbpi1_bdiv_qr \
2523 dcpi1_bdiv_q dcpi1_bdiv_qr \
2524 mu_bdiv_q mu_bdiv_qr \
2526 divexact bdiv_dbm1c redc_1 redc_2 redc_n powm powlo powm_sec subcnd_n \
2527 redc_1_sec trialdiv remove \
2528 and_n andn_n nand_n ior_n iorn_n nior_n xor_n xnor_n \
2530 $gmp_mpn_functions_optional"
2532 define(GMP_MULFUNC_CHOICES,
2533 [# functions that can be provided by multi-function files
2536 add_n|sub_n) tmp_mulfunc="aors_n" ;;
2537 addmul_1|submul_1) tmp_mulfunc="aorsmul_1" ;;
2538 popcount|hamdist) tmp_mulfunc="popham" ;;
2539 and_n|andn_n|nand_n | ior_n|iorn_n|nior_n | xor_n|xnor_n)
2540 tmp_mulfunc="logops_n" ;;
2541 lshift|rshift) tmp_mulfunc="lorrshift";;
2543 tmp_mulfunc="aorslsh1_n aorrlsh1_n";;
2545 tmp_mulfunc="aorslsh1_n sorrlsh1_n";;
2547 tmp_mulfunc="aorrlsh1_n sorrlsh1_n";;
2549 tmp_mulfunc="aorslsh2_n aorrlsh2_n";;
2551 tmp_mulfunc="aorslsh2_n sorrlsh2_n";;
2553 tmp_mulfunc="aorrlsh2_n sorrlsh2_n";;
2555 tmp_mulfunc="aorslsh_n aorrlsh_n";;
2557 tmp_mulfunc="aorslsh_n sorrlsh_n";;
2559 tmp_mulfunc="aorrlsh_n sorrlsh_n";;
2560 rsh1add_n|rsh1sub_n)
2561 tmp_mulfunc="rsh1aors_n";;
2565 # the list of all object files used by mpn/Makefile.in and the
2566 # top-level Makefile.in, respectively
2570 # links from the sources, to be removed by "make distclean"
2574 # mpn_relative_top_srcdir is $top_srcdir, but for use from within the mpn
2575 # build directory. If $srcdir is relative then we use a relative path too,
2576 # so the two trees can be moved together.
2578 [[\\/]* | ?:[\\/]*]) # absolute, as per autoconf
2579 mpn_relative_top_srcdir=$srcdir ;;
2581 mpn_relative_top_srcdir=../$srcdir ;;
2585 define(MPN_SUFFIXES,[asm S s c])
2587 dnl Usage: GMP_FILE_TO_FUNCTION_BASE(func,file)
2589 dnl Set $func to the function base name for $file, eg. dive_1 gives
2592 define(GMP_FILE_TO_FUNCTION,
2594 dive_1) $1=divexact_1 ;;
2595 diveby3) $1=divexact_by3c ;;
2596 pre_divrem_1) $1=preinv_divrem_1 ;;
2597 mode1o) $1=modexact_1c_odd ;;
2598 pre_mod_1) $1=preinv_mod_1 ;;
2603 # Fat binary setups.
2605 # We proceed through each $fat_path directory, and look for $fat_function
2606 # routines there. Those found are incorporated in the build by generating a
2607 # little mpn/<foo>.asm or mpn/<foo>.c file in the build directory, with
2608 # suitable function renaming, and adding that to $mpn_objects (the same as a
2611 # fat.h is generated with macros to let internal calls to each $fat_function
2612 # go directly through __gmpn_cpuvec, plus macros and declarations helping to
2613 # setup that structure, on a per-directory basis ready for
2614 # mpn/<cpu>/fat/fat.c.
2616 # fat.h includes thresholds listed in $fat_thresholds, extracted from
2617 # gmp-mparam.h in each directory. An overall maximum for each threshold is
2618 # established, for use in making fixed size arrays of temporary space.
2619 # (Eg. MUL_TOOM33_THRESHOLD_LIMIT used by mpn/generic/mul.c.)
2621 # It'd be possible to do some of this manually, but when there's more than a
2622 # few functions and a few directories it becomes very tedious, and very
2623 # prone to having some routine accidentally omitted. On that basis it seems
2624 # best to automate as much as possible, even if the code to do so is a bit
2628 if test -n "$fat_path"; then
2629 # Usually the mpn build directory is created with mpn/Makefile
2630 # instantiation, but we want to write to it sooner.
2631 mkdir mpn 2>/dev/null
2633 echo "/* fat.h - setups for fat binaries." >fat.h
2634 echo " Generated by configure - DO NOT EDIT. */" >>fat.h
2636 AC_DEFINE(WANT_FAT_BINARY, 1, [Define to 1 when building a fat binary.])
2637 GMP_DEFINE(WANT_FAT_BINARY, yes)
2639 # Don't want normal copies of fat functions
2640 for tmp_fn in $fat_functions; do
2641 GMP_REMOVE_FROM_LIST(gmp_mpn_functions, $tmp_fn)
2642 GMP_REMOVE_FROM_LIST(gmp_mpn_functions_optional, $tmp_fn)
2645 for tmp_fn in $fat_functions; do
2646 GMP_FILE_TO_FUNCTION(tmp_fbase,tmp_fn)
2648 #ifndef OPERATION_$tmp_fn
2649 #undef mpn_$tmp_fbase
2650 #define mpn_$tmp_fbase (*__gmpn_cpuvec.$tmp_fbase)
2652 DECL_$tmp_fbase (__MPN(${tmp_fbase}_init));" >>fat.h
2653 # encourage various macros to use fat functions
2654 AC_DEFINE_UNQUOTED(HAVE_NATIVE_$tmp_fbase)
2658 echo "/* variable thresholds */" >>fat.h
2659 for tmp_tn in $fat_thresholds; do
2660 echo "#undef $tmp_tn" >>fat.h
2661 echo "#define $tmp_tn CPUVEC_THRESHOLD (`echo $tmp_tn | tr A-Z a-z`)" >>fat.h
2665 /* Copy all fields into __gmpn_cpuvec.
2666 memcpy is not used because it might operate byte-wise (depending on its
2667 implementation), and we need the function pointer writes to be atomic.
2668 "volatile" discourages the compiler from trying to optimize this. */
2669 #define CPUVEC_INSTALL(vec) \\
2671 volatile struct cpuvec_t *p = &__gmpn_cpuvec; \\" >>fat.h
2672 for tmp_fn in $fat_functions; do
2673 GMP_FILE_TO_FUNCTION(tmp_fbase,tmp_fn)
2674 echo " p->$tmp_fbase = vec.$tmp_fbase; \\" >>fat.h
2676 for tmp_tn in $fat_thresholds; do
2677 tmp_field_name=`echo $tmp_tn | tr A-Z a-z`
2678 echo " p->$tmp_field_name = vec.$tmp_field_name; \\" >>fat.h
2680 echo " } while (0)" >>fat.h
2683 /* A helper to check all fields are filled. */
2684 #define ASSERT_CPUVEC(vec) \\
2686 for tmp_fn in $fat_functions; do
2687 GMP_FILE_TO_FUNCTION(tmp_fbase,tmp_fn)
2688 echo " ASSERT (vec.$tmp_fbase != NULL); \\" >>fat.h
2690 for tmp_tn in $fat_thresholds; do
2691 tmp_field_name=`echo $tmp_tn | tr A-Z a-z`
2692 echo " ASSERT (vec.$tmp_field_name != 0); \\" >>fat.h
2694 echo " } while (0)" >>fat.h
2697 /* Call ITERATE(field) for each fat threshold field. */
2698 #define ITERATE_FAT_THRESHOLDS() \\
2700 for tmp_tn in $fat_thresholds; do
2701 tmp_field_name=`echo $tmp_tn | tr A-Z a-z`
2702 echo " ITERATE ($tmp_tn, $tmp_field_name); \\" >>fat.h
2704 echo " } while (0)" >>fat.h
2706 for tmp_dir in $fat_path; do
2710 GMP_FAT_SUFFIX(tmp_suffix, $tmp_dir)
2712 # In order to keep names unique on a DOS 8.3 filesystem, use a prefix
2713 # (rather than a suffix) for the generated file names, and abbreviate.
2715 pentium) tmp_prefix=p ;;
2716 pentium_mmx) tmp_prefix=pm ;;
2717 p6_mmx) tmp_prefix=p2 ;;
2718 p6_p3mmx) tmp_prefix=p3 ;;
2719 pentium4) tmp_prefix=p4 ;;
2720 pentium4_mmx) tmp_prefix=p4m ;;
2721 pentium4_sse2) tmp_prefix=p4s ;;
2722 k6_mmx) tmp_prefix=k6m ;;
2723 k6_k62mmx) tmp_prefix=k62 ;;
2724 k7_mmx) tmp_prefix=k7m ;;
2725 *) tmp_prefix=$tmp_suffix ;;
2728 # Extract desired thresholds from gmp-mparam.h file in this directory,
2730 tmp_mparam=$srcdir/mpn/$tmp_dir/gmp-mparam.h
2731 if test -f $tmp_mparam; then
2732 for tmp_tn in $fat_thresholds; do
2733 tmp_thresh=`sed -n "s/^#define $tmp_tn[ ]*\\([0-9][0-9]*\\).*$/\\1/p" $tmp_mparam`
2734 if test -n "$tmp_thresh"; then
2735 THRESH_ASM_SETUP=["${THRESH_ASM_SETUP}define($tmp_tn,$tmp_thresh)
2737 CPUVEC_SETUP="$CPUVEC_SETUP decided_cpuvec.`echo $tmp_tn | tr A-Z a-z` = $tmp_thresh; \\
2739 eval tmp_limit=\$${tmp_tn}_LIMIT
2740 if test -z "$tmp_limit"; then
2743 if test $tmp_thresh -gt $tmp_limit; then
2744 eval ${tmp_tn}_LIMIT=$tmp_thresh
2750 for tmp_fn in $fat_functions; do
2753 for tmp_base in $tmp_fn $tmp_mulfunc; do
2754 for tmp_ext in MPN_SUFFIXES; do
2755 tmp_file=$srcdir/mpn/$tmp_dir/$tmp_base.$tmp_ext
2756 if test -f $tmp_file; then
2758 mpn_objects="$mpn_objects ${tmp_prefix}_$tmp_fn.lo"
2759 mpn_objs_in_libgmp="$mpn_objs_in_libgmp mpn/${tmp_prefix}_$tmp_fn.lo"
2761 GMP_FILE_TO_FUNCTION(tmp_fbase,tmp_fn)
2763 # carry-in variant, eg. divrem_1c or modexact_1c_odd
2765 *_1*) tmp_fbasec=`echo $tmp_fbase | sed 's/_1/_1c/'` ;;
2766 *) tmp_fbasec=${tmp_fbase}c ;;
2769 # Create a little file doing an include from srcdir. The
2770 # OPERATION and renamings aren't all needed all the time, but
2771 # they don't hurt if unused.
2773 # FIXME: Should generate these via config.status commands.
2774 # Would need them all in one AC_CONFIG_COMMANDS though, since
2775 # that macro doesn't accept a set of separate commands generated
2780 # hide the d-n-l from autoconf's error checking
2782 echo ["$tmp_d_n_l mpn_$tmp_fbase - from $tmp_dir directory for fat binary.
2783 $tmp_d_n_l Generated by configure - DO NOT EDIT.
2785 define(OPERATION_$tmp_fn)
2786 define(__gmpn_$tmp_fbase, __gmpn_${tmp_fbase}_$tmp_suffix)
2787 define(__gmpn_$tmp_fbasec,__gmpn_${tmp_fbasec}_${tmp_suffix})
2788 define(__gmpn_preinv_${tmp_fbase},__gmpn_preinv_${tmp_fbase}_${tmp_suffix})
2790 $tmp_d_n_l For k6 and k7 gcd_1 calling their corresponding mpn_modexact_1_odd
2791 ifdef(\`__gmpn_modexact_1_odd',,
2792 \`define(__gmpn_modexact_1_odd,__gmpn_modexact_1_odd_${tmp_suffix})')
2795 include][($mpn_relative_top_srcdir/mpn/$tmp_dir/$tmp_base.asm)
2796 "] >mpn/${tmp_prefix}_$tmp_fn.asm
2799 echo ["/* mpn_$tmp_fbase - from $tmp_dir directory for fat binary.
2800 Generated by configure - DO NOT EDIT. */
2802 #define OPERATION_$tmp_fn 1
2803 #define __gmpn_$tmp_fbase __gmpn_${tmp_fbase}_$tmp_suffix
2804 #define __gmpn_$tmp_fbasec __gmpn_${tmp_fbasec}_${tmp_suffix}
2805 #define __gmpn_preinv_${tmp_fbase} __gmpn_preinv_${tmp_fbase}_${tmp_suffix}
2807 #include \"$mpn_relative_top_srcdir/mpn/$tmp_dir/$tmp_base.c\"
2808 "] >mpn/${tmp_prefix}_$tmp_fn.c
2812 # Prototype, and append to CPUVEC_SETUP for this directory.
2813 echo "DECL_$tmp_fbase (__gmpn_${tmp_fbase}_$tmp_suffix);" >>fat.h
2814 CPUVEC_SETUP="$CPUVEC_SETUP decided_cpuvec.$tmp_fbase = __gmpn_${tmp_fbase}_${tmp_suffix}; \\
2816 # Ditto for any preinv variant (preinv_divrem_1, preinv_mod_1).
2817 if grep "^PROLOGUE(mpn_preinv_$tmp_fn)" $tmp_file >/dev/null; then
2818 echo "DECL_preinv_$tmp_fbase (__gmpn_preinv_${tmp_fbase}_$tmp_suffix);" >>fat.h
2819 CPUVEC_SETUP="$CPUVEC_SETUP decided_cpuvec.preinv_$tmp_fbase = __gmpn_preinv_${tmp_fbase}_${tmp_suffix}; \\
2827 # Emit CPUVEC_SETUP for this directory
2829 echo "#define CPUVEC_SETUP_$tmp_suffix \\" >>fat.h
2830 echo " do { \\" >>fat.h
2831 echo "$CPUVEC_SETUP } while (0)" >>fat.h
2834 # Emit threshold limits
2836 for tmp_tn in $fat_thresholds; do
2837 eval tmp_limit=\$${tmp_tn}_LIMIT
2838 echo "#define ${tmp_tn}_LIMIT $tmp_limit" >>fat.h
2843 # Normal binary setups.
2846 for tmp_ext in MPN_SUFFIXES; do
2847 eval found_$tmp_ext=no
2850 for tmp_fn in $gmp_mpn_functions; do
2851 for tmp_ext in MPN_SUFFIXES; do
2852 test "$no_create" = yes || rm -f mpn/$tmp_fn.$tmp_ext
2855 # mpn_preinv_divrem_1 might have been provided by divrem_1.asm, likewise
2856 # mpn_preinv_mod_1 by mod_1.asm.
2859 if test "$HAVE_NATIVE_mpn_preinv_divrem_1" = yes; then continue; fi ;;
2861 if test "$HAVE_NATIVE_mpn_preinv_mod_1" = yes; then continue; fi ;;
2867 for tmp_dir in $path; do
2868 for tmp_base in $tmp_fn $tmp_mulfunc; do
2869 for tmp_ext in MPN_SUFFIXES; do
2870 tmp_file=$srcdir/mpn/$tmp_dir/$tmp_base.$tmp_ext
2871 if test -f $tmp_file; then
2873 # For a nails build, check if the file supports our nail bits.
2874 # Generic code always supports all nails.
2876 # FIXME: When a multi-function file is selected to provide one of
2877 # the nails-neutral routines, like logops_n for and_n, the
2878 # PROLOGUE grepping will create HAVE_NATIVE_mpn_<foo> defines for
2879 # all functions in that file, even if they haven't all been
2880 # nailified. Not sure what to do about this, it's only really a
2881 # problem for logops_n, and it's not too terrible to insist those
2882 # get nailified always.
2884 if test $GMP_NAIL_BITS != 0 && test $tmp_dir != generic; then
2886 and_n | ior_n | xor_n | andn_n | \
2888 popcount | hamdist | \
2889 udiv | udiv_w_sdiv | umul | \
2890 cntlz | invert_limb)
2891 # these operations are either unaffected by nails or defined
2892 # to operate on full limbs
2895 nails=[`sed -n 's/^[ ]*NAILS_SUPPORT(\(.*\))/\1/p' $tmp_file `]
2899 n_start=`echo "$n" | sed -n 's/\(.*\)-.*/\1/p'`
2900 n_end=`echo "$n" | sed -n 's/.*-\(.*\)/\1/p'`
2907 if test $GMP_NAIL_BITS -ge $n_start && test $GMP_NAIL_BITS -le $n_end; then
2912 if test $found != yes; then
2920 eval found_$tmp_ext=yes
2922 if test $tmp_ext = c; then
2928 mpn_objects="$mpn_objects $tmp_fn$tmp_u.lo"
2929 mpn_objs_in_libgmp="$mpn_objs_in_libgmp mpn/$tmp_fn$tmp_u.lo"
2930 AC_CONFIG_LINKS(mpn/$tmp_fn.$tmp_ext:mpn/$tmp_dir/$tmp_base.$tmp_ext)
2931 gmp_srclinks="$gmp_srclinks mpn/$tmp_fn.$tmp_ext"
2933 # Duplicate AC_DEFINEs are harmless, so it doesn't matter
2934 # that multi-function files get grepped here repeatedly.
2935 # The PROLOGUE pattern excludes the optional second parameter.
2937 sed -n 's/^[ ]*MULFUNC_PROLOGUE(\(.*\))/\1/p' $tmp_file ;
2938 sed -n 's/^[ ]*PROLOGUE(\([^,]*\).*)/\1/p' $tmp_file
2940 for gmp_tmp in $gmp_ep; do
2941 AC_DEFINE_UNQUOTED(HAVE_NATIVE_$gmp_tmp)
2942 eval HAVE_NATIVE_$gmp_tmp=yes
2946 sqr_basecase) sqr_basecase_source=$tmp_file ;;
2952 if test $found = yes; then break ; fi
2954 if test $found = yes; then break ; fi
2957 if test $found = no; then
2958 for tmp_optional in $gmp_mpn_functions_optional; do
2959 if test $tmp_optional = $tmp_fn; then
2963 if test $found = no; then
2964 AC_MSG_ERROR([no version of $tmp_fn found in path: $path])
2969 # All cycle counters are .asm files currently
2970 if test -n "$SPEED_CYCLECOUNTER_OBJ"; then
2974 dnl The following list only needs to have templates for those defines which
2975 dnl are going to be tested by the code, there's no need to have every
2976 dnl possible mpn routine.
2978 AH_VERBATIM([HAVE_NATIVE],
2979 [/* Define to 1 each of the following for which a native (ie. CPU specific)
2980 implementation of the corresponding routine exists. */
2981 #undef HAVE_NATIVE_mpn_add_n
2982 #undef HAVE_NATIVE_mpn_add_n_sub_n
2983 #undef HAVE_NATIVE_mpn_add_nc
2984 #undef HAVE_NATIVE_mpn_addaddmul_1msb0
2985 #undef HAVE_NATIVE_mpn_addlsh1_n
2986 #undef HAVE_NATIVE_mpn_addlsh2_n
2987 #undef HAVE_NATIVE_mpn_addlsh_n
2988 #undef HAVE_NATIVE_mpn_addmul_1c
2989 #undef HAVE_NATIVE_mpn_addmul_2
2990 #undef HAVE_NATIVE_mpn_addmul_3
2991 #undef HAVE_NATIVE_mpn_addmul_4
2992 #undef HAVE_NATIVE_mpn_addmul_5
2993 #undef HAVE_NATIVE_mpn_addmul_6
2994 #undef HAVE_NATIVE_mpn_addmul_7
2995 #undef HAVE_NATIVE_mpn_addmul_8
2996 #undef HAVE_NATIVE_mpn_and_n
2997 #undef HAVE_NATIVE_mpn_andn_n
2998 #undef HAVE_NATIVE_mpn_bdiv_dbm1c
2999 #undef HAVE_NATIVE_mpn_bdiv_q_1
3000 #undef HAVE_NATIVE_mpn_pi1_bdiv_q_1
3001 #undef HAVE_NATIVE_mpn_com
3002 #undef HAVE_NATIVE_mpn_copyd
3003 #undef HAVE_NATIVE_mpn_copyi
3004 #undef HAVE_NATIVE_mpn_divexact_1
3005 #undef HAVE_NATIVE_mpn_divexact_by3c
3006 #undef HAVE_NATIVE_mpn_divrem_1
3007 #undef HAVE_NATIVE_mpn_divrem_1c
3008 #undef HAVE_NATIVE_mpn_divrem_2
3009 #undef HAVE_NATIVE_mpn_gcd_1
3010 #undef HAVE_NATIVE_mpn_hamdist
3011 #undef HAVE_NATIVE_mpn_invert_limb
3012 #undef HAVE_NATIVE_mpn_ior_n
3013 #undef HAVE_NATIVE_mpn_iorn_n
3014 #undef HAVE_NATIVE_mpn_lshift
3015 #undef HAVE_NATIVE_mpn_lshiftc
3016 #undef HAVE_NATIVE_mpn_lshsub_n
3017 #undef HAVE_NATIVE_mpn_mod_1
3018 #undef HAVE_NATIVE_mpn_mod_1_1p
3019 #undef HAVE_NATIVE_mpn_mod_1c
3020 #undef HAVE_NATIVE_mpn_mod_1s_2p
3021 #undef HAVE_NATIVE_mpn_mod_1s_4p
3022 #undef HAVE_NATIVE_mpn_mod_34lsub1
3023 #undef HAVE_NATIVE_mpn_modexact_1_odd
3024 #undef HAVE_NATIVE_mpn_modexact_1c_odd
3025 #undef HAVE_NATIVE_mpn_mul_1
3026 #undef HAVE_NATIVE_mpn_mul_1c
3027 #undef HAVE_NATIVE_mpn_mul_2
3028 #undef HAVE_NATIVE_mpn_mul_3
3029 #undef HAVE_NATIVE_mpn_mul_4
3030 #undef HAVE_NATIVE_mpn_mul_basecase
3031 #undef HAVE_NATIVE_mpn_nand_n
3032 #undef HAVE_NATIVE_mpn_nior_n
3033 #undef HAVE_NATIVE_mpn_popcount
3034 #undef HAVE_NATIVE_mpn_preinv_divrem_1
3035 #undef HAVE_NATIVE_mpn_preinv_mod_1
3036 #undef HAVE_NATIVE_mpn_redc_1
3037 #undef HAVE_NATIVE_mpn_redc_2
3038 #undef HAVE_NATIVE_mpn_rsblsh1_n
3039 #undef HAVE_NATIVE_mpn_rsblsh2_n
3040 #undef HAVE_NATIVE_mpn_rsblsh_n
3041 #undef HAVE_NATIVE_mpn_rsh1add_n
3042 #undef HAVE_NATIVE_mpn_rsh1add_nc
3043 #undef HAVE_NATIVE_mpn_rsh1sub_n
3044 #undef HAVE_NATIVE_mpn_rsh1sub_nc
3045 #undef HAVE_NATIVE_mpn_rshift
3046 #undef HAVE_NATIVE_mpn_sqr_basecase
3047 #undef HAVE_NATIVE_mpn_sqr_diagonal
3048 #undef HAVE_NATIVE_mpn_sub_n
3049 #undef HAVE_NATIVE_mpn_sub_nc
3050 #undef HAVE_NATIVE_mpn_sublsh1_n
3051 #undef HAVE_NATIVE_mpn_sublsh2_n
3052 #undef HAVE_NATIVE_mpn_sublsh_n
3053 #undef HAVE_NATIVE_mpn_submul_1c
3054 #undef HAVE_NATIVE_mpn_udiv_qrnnd
3055 #undef HAVE_NATIVE_mpn_udiv_qrnnd_r
3056 #undef HAVE_NATIVE_mpn_umul_ppmm
3057 #undef HAVE_NATIVE_mpn_umul_ppmm_r
3058 #undef HAVE_NATIVE_mpn_xor_n
3059 #undef HAVE_NATIVE_mpn_xnor_n])
3062 # Don't demand an m4 unless it's actually needed.
3063 if test $found_asm = yes; then
3065 GMP_M4_M4WRAP_SPURIOUS
3070 # Only do the GMP_ASM checks if there's a .S or .asm wanting them.
3071 if test $found_asm = no && test $found_S = no; then
3072 gmp_asm_syntax_testing=no
3075 if test "$gmp_asm_syntax_testing" != no; then
3078 GMP_ASM_LABEL_SUFFIX
3091 # for both pa32 and pa64
3092 GMP_INCLUDE_MPN(pa32/pa-defs.m4)
3095 GMP_ASM_IA64_ALIGN_OK
3098 GMP_ASM_M68K_INSTRUCTION
3099 GMP_ASM_M68K_ADDRESSING
3100 GMP_ASM_M68K_BRANCHES
3102 [powerpc*-*-* | power[3-9]-*-*])
3103 GMP_ASM_POWERPC_PIC_ALWAYS
3104 GMP_ASM_POWERPC_R_REGISTERS
3105 GMP_INCLUDE_MPN(powerpc32/powerpc-defs.m4)
3109 64 | aix64) GMP_INCLUDE_MPN(powerpc64/aix.m4) ;;
3110 *) GMP_INCLUDE_MPN(powerpc32/aix.m4) ;;
3113 *-*-linux* | *-*-*bsd*)
3115 mode64) GMP_INCLUDE_MPN(powerpc64/elf.m4) ;;
3116 mode32 | 32) GMP_INCLUDE_MPN(powerpc32/elf.m4) ;;
3121 mode64) GMP_INCLUDE_MPN(powerpc64/darwin.m4) ;;
3122 mode32 | 32) GMP_INCLUDE_MPN(powerpc32/darwin.m4) ;;
3126 # Assume unrecognized operating system is the powerpc eABI
3127 GMP_INCLUDE_MPN(powerpc32/eabi.m4)
3132 GMP_INCLUDE_MPN(powerpc32/aix.m4)
3134 sparcv9*-*-* | ultrasparc*-*-* | sparc64-*-*)
3137 GMP_ASM_SPARC_REGISTER
3141 X86_PATTERN | X86_64_PATTERN)
3142 GMP_ASM_ALIGN_FILL_0x90
3145 GMP_INCLUDE_MPN(x86/x86-defs.m4)
3146 AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86)
3148 GMP_ASM_X86_GOT_UNDERSCORE
3149 GMP_ASM_X86_SHLDL_CL
3150 case $enable_profiling in
3151 prof | gprof) GMP_ASM_X86_MCOUNT ;;
3155 GMP_INCLUDE_MPN(x86/darwin.m4) ;;
3159 GMP_INCLUDE_MPN(x86_64/x86_64-defs.m4)
3160 AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86_64)
3163 GMP_INCLUDE_MPN(x86_64/darwin.m4) ;;
3171 # For --enable-minithres, prepend "minithres" to path so that its special
3172 # gmp-mparam.h will be used.
3173 if test $enable_minithres = yes; then
3174 path="minithres $path"
3177 # Create link for gmp-mparam.h.
3179 for gmp_mparam_dir in $path; do
3180 test "$no_create" = yes || rm -f gmp-mparam.h
3181 tmp_file=$srcdir/mpn/$gmp_mparam_dir/gmp-mparam.h
3182 if test -f $tmp_file; then
3183 AC_CONFIG_LINKS(gmp-mparam.h:mpn/$gmp_mparam_dir/gmp-mparam.h)
3184 gmp_srclinks="$gmp_srclinks gmp-mparam.h"
3185 gmp_mparam_source=$tmp_file
3189 if test -z "$gmp_mparam_source"; then
3190 AC_MSG_ERROR([no version of gmp-mparam.h found in path: $path])
3193 # For a helpful message from tune/tuneup.c
3194 gmp_mparam_suggest=$gmp_mparam_source
3195 if test "$gmp_mparam_dir" = generic; then
3196 for i in $path; do break; done
3197 if test "$i" != generic; then
3198 gmp_mparam_suggest="new file $srcdir/mpn/$i/gmp-mparam.h"
3201 AC_DEFINE_UNQUOTED(GMP_MPARAM_H_SUGGEST, "$gmp_mparam_source",
3202 [The gmp-mparam.h file (a string) the tune program should suggest updating.])
3205 # Copy any SQR_TOOM2_THRESHOLD from gmp-mparam.h to config.m4.
3206 # Some versions of sqr_basecase.asm use this.
3207 # Fat binaries do this on a per-file basis, so skip in that case.
3209 if test -z "$fat_path"; then
3210 tmp_gmp_karatsuba_sqr_threshold=`sed -n 's/^#define SQR_TOOM2_THRESHOLD[ ]*\([0-9][0-9]*\).*$/\1/p' $gmp_mparam_source`
3211 if test -n "$tmp_gmp_karatsuba_sqr_threshold"; then
3212 GMP_DEFINE_RAW(["define(<SQR_TOOM2_THRESHOLD>,<$tmp_gmp_karatsuba_sqr_threshold>)"])
3217 # Sizes of some types, needed at preprocessing time.
3219 # FIXME: The assumption that GMP_LIMB_BITS is 8*sizeof(mp_limb_t) might
3220 # be slightly rash, but it's true everywhere we know of and ought to be true
3221 # of any sensible system. In a generic C build, grepping LONG_BIT out of
3222 # <limits.h> might be an alternative, for maximum portability.
3224 AC_CHECK_SIZEOF(void *)
3225 AC_CHECK_SIZEOF(unsigned short)
3226 AC_CHECK_SIZEOF(unsigned)
3227 AC_CHECK_SIZEOF(unsigned long)
3228 AC_CHECK_SIZEOF(mp_limb_t, , GMP_INCLUDE_GMP_H)
3229 if test "$ac_cv_sizeof_mp_limb_t" = 0; then
3230 AC_MSG_ERROR([Oops, mp_limb_t doesn't seem to work])
3232 AC_SUBST(GMP_LIMB_BITS, `expr 8 \* $ac_cv_sizeof_mp_limb_t`)
3233 GMP_DEFINE_RAW(["define(<SIZEOF_UNSIGNED>,<$ac_cv_sizeof_unsigned>)"])
3235 # Check compiler limb size matches gmp-mparam.h
3237 # FIXME: Some of the cycle counter objects in the tune directory depend on
3238 # the size of ulong, it'd be possible to check that here, though a mismatch
3239 # probably wouldn't want to be fatal, none of the libgmp assembler code
3242 mparam_bits=[`sed -n 's/^#define GMP_LIMB_BITS[ ][ ]*\([0-9]*\).*$/\1/p' $gmp_mparam_source`]
3243 if test -n "$mparam_bits" && test "$mparam_bits" -ne $GMP_LIMB_BITS; then
3244 if test "$test_CFLAGS" = set; then
3245 AC_MSG_ERROR([Oops, mp_limb_t is $GMP_LIMB_BITS bits, but the assembler code
3246 in this configuration expects $mparam_bits bits.
3247 You appear to have set \$CFLAGS, perhaps you also need to tell GMP the
3248 intended ABI, see "ABI and ISA" in the manual.])
3250 AC_MSG_ERROR([Oops, mp_limb_t is $GMP_LIMB_BITS bits, but the assembler code
3251 in this configuration expects $mparam_bits bits.])
3255 GMP_DEFINE_RAW(["define(<GMP_LIMB_BITS>,$GMP_LIMB_BITS)"])
3256 GMP_DEFINE_RAW(["define(<GMP_NAIL_BITS>,$GMP_NAIL_BITS)"])
3257 GMP_DEFINE_RAW(["define(<GMP_NUMB_BITS>,eval(GMP_LIMB_BITS-GMP_NAIL_BITS))"])
3260 # Exclude the mpn random functions from mpbsd since that would drag in the
3261 # top-level rand things, all of which are unnecessary for libmp. There's
3262 # other unnecessary objects too actually, if we could be bothered figuring
3263 # out exactly which they are.
3266 for i in $mpn_objs_in_libgmp; do
3269 *) mpn_objs_in_libmp="$mpn_objs_in_libmp $i" ;;
3272 AC_SUBST(mpn_objs_in_libmp)
3274 AC_SUBST(mpn_objects)
3275 AC_SUBST(mpn_objs_in_libgmp)
3276 AC_SUBST(gmp_srclinks)
3279 # A recompiled sqr_basecase for use in the tune program, if necessary.
3281 test -d tune || mkdir tune
3282 case $sqr_basecase_source in
3284 sqr_max=[`sed -n 's/^def...(SQR_TOOM2_THRESHOLD_MAX, *\([0-9]*\))/\1/p' $sqr_basecase_source`]
3285 if test -n "$sqr_max"; then
3286 TUNE_SQR_OBJ=sqr_asm.o
3287 AC_DEFINE_UNQUOTED(TUNE_SQR_TOOM2_MAX,$sqr_max,
3288 [Maximum size the tune program can test for SQR_TOOM2_THRESHOLD])
3290 cat >tune/sqr_basecase.c <<EOF
3291 /* not sure that an empty file can compile, so put in a dummy */
3292 int sqr_basecase_dummy;
3297 AC_DEFINE(TUNE_SQR_TOOM2_MAX,SQR_TOOM2_MAX_GENERIC)
3298 cat >tune/sqr_basecase.c <<EOF
3299 #define TUNE_PROGRAM_BUILD 1
3300 #define TUNE_PROGRAM_BUILD_SQR 1
3301 #include "mpn/sqr_basecase.c"
3305 AC_SUBST(TUNE_SQR_OBJ)
3308 # Configs for demos/pexpr.c.
3310 AC_CONFIG_FILES(demos/pexpr-config.h:demos/pexpr-config-h.in)
3311 GMP_SUBST_CHECK_FUNCS(clock, cputime, getrusage, gettimeofday, sigaction, sigaltstack, sigstack)
3312 GMP_SUBST_CHECK_HEADERS(sys/resource.h)
3313 AC_CHECK_TYPES([stack_t], HAVE_STACK_T_01=1, HAVE_STACK_T_01=0,
3314 [#include <signal.h>])
3315 AC_SUBST(HAVE_STACK_T_01)
3317 # Configs for demos/calc directory
3319 # AC_SUBST+AC_CONFIG_FILES is used for calc-config.h, rather than AC_DEFINE+
3320 # AC_CONFIG_HEADERS, since with the latter automake (1.8) will then put the
3321 # directory (ie. demos/calc) into $(DEFAULT_INCLUDES) for every Makefile.in,
3322 # which would look very strange.
3324 # -lcurses is required by libreadline. On a typical SVR4 style system this
3325 # normally doesn't have to be given explicitly, since libreadline.so will
3326 # have a NEEDED record for it. But if someone for some reason is using only
3327 # a static libreadline.a then we must give -lcurses. Readline (as of
3328 # version 4.3) doesn't use libtool, so we can't rely on a .la to cover
3329 # necessary dependencies.
3331 # On a couple of systems we've seen libreadline available, but the headers
3332 # not in the default include path, so check for readline/readline.h. We've
3333 # also seen readline/history.h missing, not sure if that's just a broken
3334 # install or a very old version, but check that too.
3336 AC_CONFIG_FILES(demos/calc/calc-config.h:demos/calc/calc-config-h.in)
3338 if test $with_readline != no; then
3339 AC_CHECK_LIB(ncurses, tputs, [LIBCURSES=-lncurses],
3340 [AC_CHECK_LIB(curses, tputs, [LIBCURSES=-lcurses])])
3343 use_readline=$with_readline
3344 if test $with_readline = detect; then
3346 AC_CHECK_LIB(readline, readline,
3347 [AC_CHECK_HEADER(readline/readline.h,
3348 [AC_CHECK_HEADER(readline/history.h, use_readline=yes)])],
3350 AC_MSG_CHECKING(readline detected)
3351 AC_MSG_RESULT($use_readline)
3353 if test $use_readline = yes; then
3354 AC_SUBST(WITH_READLINE_01, 1)
3355 AC_SUBST(LIBREADLINE, -lreadline)
3362 # Configs for demos/expr directory
3364 # Libtool already runs an AC_CHECK_TOOL for ranlib, but we give
3365 # AC_PROG_RANLIB anyway since automake is supposed to complain if it's not
3366 # called. (Automake 1.8.4 doesn't, at least not when the only library is in
3367 # an EXTRA_LIBRARIES.)
3376 # FIXME: Upcoming version of autoconf/automake may not like broken lines.
3377 # Right now automake isn't accepting the new AC_CONFIG_FILES scheme.
3379 AC_OUTPUT(Makefile \
3380 mpbsd/Makefile mpf/Makefile mpn/Makefile mpq/Makefile \
3381 mpz/Makefile printf/Makefile scanf/Makefile cxx/Makefile \
3382 tests/Makefile tests/devel/Makefile tests/mpbsd/Makefile \
3383 tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile \
3384 tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile \
3385 tests/cxx/Makefile \
3386 doc/Makefile tune/Makefile \
3387 demos/Makefile demos/calc/Makefile demos/expr/Makefile \
3388 gmp.h:gmp-h.in mp.h:mp-h.in)