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