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