source: trunk/third/gmp/configure.in @ 22254

Revision 22254, 70.6 KB checked in by ghudson, 19 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r22253, which included commits to RCS files with non-trunk default branches.
Line 
1dnl  Process this file with autoconf to produce a configure script.
2
3
4AC_COPYRIGHT([
5
6Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
7Foundation, Inc.
8
9This file is part of the GNU MP Library.
10
11The GNU MP Library is free software; you can redistribute it and/or modify
12it under the terms of the GNU Lesser General Public License as published
13by the Free Software Foundation; either version 2.1 of the License, or (at
14your option) any later version.
15
16The GNU MP Library is distributed in the hope that it will be useful, but
17WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
19License for more details.
20
21You should have received a copy of the GNU Lesser General Public License
22along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
23the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24MA 02111-1307, USA.
25])
26
27
28AC_REVISION($Revision: 1.1.1.3 $)
29AC_PREREQ(2.52)
30AC_INIT(gmp-impl.h)
31m4_pattern_forbid([^[ \t]*GMP_])
32m4_pattern_forbid([^[ \t]*MPFR_CONFIGS])
33m4_pattern_allow(GMP_LDFLAGS)
34m4_pattern_allow(GMP_LIMB_BITS)
35m4_pattern_allow(GMP_MPARAM_H_SUGGEST)
36m4_pattern_allow(GMP_NAIL_BITS)
37m4_pattern_allow(GMP_NUMB_BITS)
38
39# If --target is not used then $target_alias is empty, but if say
40# "./configure athlon-pc-freebsd3.5" is used, then all three of
41# $build_alias, $host_alias and $target_alias are set to
42# "athlon-pc-freebsd3.5".
43#
44if test -n "$target_alias" && test "$target_alias" != "$host_alias"; then
45  AC_MSG_ERROR([--target is not appropriate for GMP
46Use --build=CPU-VENDOR-OS if you need to specify your CPU and/or system
47explicitly.  Use --host if cross-compiling (see "Installing GMP" in the
48manual for more on this).])
49fi
50
51GMP_INIT(config.m4)
52
53AC_CANONICAL_HOST
54tmp_host=`echo $host_cpu | sed 's/\./_/'`
55AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_$tmp_host)
56GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_HOST_CPU_$tmp_host')", POST)
57
58AM_INIT_AUTOMAKE(gmp, GMP_VERSION)
59AM_CONFIG_HEADER(config.h:config.in)
60AM_MAINTAINER_MODE
61
62
63AC_ARG_ENABLE(assert,
64AC_HELP_STRING([--enable-assert],[enable ASSERT checking [[default=no]]]),
65[case $enableval in
66yes|no) ;;
67*) AC_MSG_ERROR([bad value $enableval for --enable-assert, need yes or no]) ;;
68esac],
69[enable_assert=no])
70
71if test "$enable_assert" = "yes"; then
72  AC_DEFINE(WANT_ASSERT,1,
73  [./configure --enable-assert option, to enable some ASSERT()s])
74fi
75
76
77AC_ARG_ENABLE(alloca,
78AC_HELP_STRING([--enable-alloca],[how to get temp memory [[default=reentrant]]]),
79[case $enableval in
80alloca|malloc-reentrant|malloc-notreentrant) ;;
81yes|no|reentrant|notreentrant) ;;
82debug) ;;
83*)
84  AC_MSG_ERROR([bad value $enableval for --enable-alloca, need one of:
85yes no reentrant notreentrant alloca malloc-reentrant malloc-notreentrant debug]) ;;
86esac],
87[enable_alloca=reentrant])
88
89
90# IMPROVE ME: The default for C++ is disabled.  The tests currently
91# performed below for a working C++ compiler are not particularly strong,
92# and in general can't be expected to get the right setup on their own.  The
93# most significant problem is getting the ABI the same.  Defaulting CXXFLAGS
94# to CFLAGS takes only a small step towards this.  It's also probably worth
95# worrying whether the C and C++ runtimes from say gcc and a vendor C++ can
96# work together.  Some rather broken C++ installations were encountered
97# during testing, and though such things clearly aren't GMP's problem, if
98# --enable-cxx=detect were to be the default then some careful checks of
99# which, if any, C++ compiler on the system is up to scratch would be
100# wanted.
101#
102AC_ARG_ENABLE(cxx,
103AC_HELP_STRING([--enable-cxx],[enable C++ support [[default=no]]]),
104[case $enableval in
105yes|no|detect) ;;
106*) AC_MSG_ERROR([bad value $enableval for --enable-cxx, need yes/no/detect]) ;;
107esac],
108[enable_cxx=no])
109
110
111AC_ARG_ENABLE(fft,
112AC_HELP_STRING([--enable-fft],[enable FFTs for multiplication [[default=yes]]]),
113[case $enableval in
114yes|no) ;;
115*) AC_MSG_ERROR([bad value $enableval for --enable-fft, need yes or no]) ;;
116esac],
117[enable_fft=yes])
118
119if test "$enable_fft" = "yes"; then
120  AC_DEFINE(WANT_FFT,1,
121  [./configure --enable-fft option, to enable FFTs for multiplication])
122fi
123
124
125AC_ARG_ENABLE(mpbsd,
126AC_HELP_STRING([--enable-mpbsd],
127               [build Berkeley MP compatibility library [[default=no]]]),
128[case $enableval in
129yes|no) ;;
130*) AC_MSG_ERROR([bad value $enableval for --enable-mpbsd, need yes or no]) ;;
131esac],
132[enable_mpbsd=no])
133AM_CONDITIONAL(WANT_MPBSD, test "$enable_mpbsd" = "yes")
134
135
136AC_ARG_ENABLE(mpfr,
137AC_HELP_STRING([--enable-mpfr],[build MPFR [[default=no]]]),
138[case $enableval in
139yes|no) ;;
140*) AC_MSG_ERROR([bad value $enableval for --enable-mpfr, need yes or no]) ;;
141esac],
142[enable_mpfr=no])
143AM_CONDITIONAL(WANT_MPFR, test "$enable_mpfr" = "yes")
144
145
146AC_ARG_ENABLE(nails,
147AC_HELP_STRING([--enable-nails],[use nails on limbs [[default=no]]]),
148[case $enableval in
149[yes|no|[0-9]|[0-9][0-9]]) ;;
150*) AC_MSG_ERROR([bad value $enableval for --enable-nails, need yes/no/number]) ;;
151esac],
152[enable_nails=no])
153
154case $enable_nails in
155yes) GMP_NAIL_BITS=2 ;;
156no)  GMP_NAIL_BITS=0 ;;
157*)   GMP_NAIL_BITS=$enable_nails ;;
158esac
159AC_SUBST(GMP_NAIL_BITS)
160
161
162AC_ARG_ENABLE(profiling,
163AC_HELP_STRING([--enable-profiling],
164               [build with profiler support [[default=no]]]),
165[case $enableval in
166no|prof|gprof) ;;
167*) AC_MSG_ERROR([bad value $enableval for --enable-profiling, need no/prof/gprof]) ;;
168esac],
169[enable_profiling=no])
170
171case $enable_profiling in
172  prof)
173    AC_DEFINE(WANT_PROFILING_PROF, 1,
174              [Define to 1 if --enable-profiling=prof])
175    ;;
176  gprof)
177    AC_DEFINE(WANT_PROFILING_GPROF, 1,
178              [Define to 1 if --enable-profiling=gprof])
179    ;;
180esac
181
182GMP_DEFINE_RAW(["define(<WANT_PROFILING>,<\`$enable_profiling'>)"])
183
184# -fomit-frame-pointer is incompatible with -pg, on x86s at least
185if test "$enable_profiling" = gprof; then
186  fomit_frame_pointer=
187else
188  fomit_frame_pointer="-fomit-frame-pointer"
189fi
190
191
192AC_ARG_WITH(readline,
193AC_HELP_STRING([--with-readline],
194               [readline support in calc demo program [[default=detect]]]),
195[case $withval in
196yes|no|detect) ;;
197*) AC_MSG_ERROR([bad value $withval for --with-readline, need yes/no/detect]) ;;
198esac],
199[with_readline=detect])
200
201
202
203# Table of compilers, options, and mpn paths.  This code has various related
204# purposes
205#
206#   - better default CC/CFLAGS selections than autoconf otherwise gives
207#   - default CC/CFLAGS selections for extra CPU types specific to GMP
208#   - a few tests for known bad compilers
209#   - choice of ABIs on suitable systems
210#   - selection of corresponding mpn search path
211#
212# After GMP specific searches and tests, the standard autoconf AC_PROG_CC is
213# called.  User selections of CC etc are respected.
214#
215# Care is taken not to use macros like AC_TRY_COMPILE during the GMP
216# pre-testing, since they of course depend on AC_PROG_CC, and also some of
217# them cache their results, which is not wanted.
218#
219# The ABI selection mechanism is unique to GMP.  All that reaches autoconf
220# is a different selection of CC/CFLAGS according to the best ABI the system
221# supports, and/or what the user selects.  Naturally the mpn assembler code
222# selected is very dependent on the ABI.
223#
224# The closest the standard tools come to a notion of ABI is something like
225# "sparc64" which encodes a CPU and an ABI together.  This doesn't seem to
226# scale well for GMP, where exact CPU types like "ultrasparc2" are wanted,
227# separate from the ABI used on them.
228#
229#
230# The variables set here are
231#
232#   cclist              the compiler choices
233#   xx_cflags           flags for compiler xx
234#   xx_cppflags         cpp flags for compiler xx
235#   xx_cflags_optlist   list of sets of optional flags
236#   xx_cflags_yyy       set yyy of optional flags for compiler xx
237#   xx_ldflags          -Wc,-foo flags for libtool linking with compiler xx
238#   ar_flags            extra flags for $AR
239#   nm_flags            extra flags for $NM
240#   limb                limb size, can be "longlong"
241#   path                mpn search path
242#   extra_functions     extra mpn functions
243#
244# Suppose xx_cflags_optlist="arch", then flags from $xx_cflags_arch are
245# tried, and the first flag that works will be used.  An optlist like "arch
246# cpu optimize" can be used to get multiple independent sets of flags tried.
247# The first that works from each will be used.  If no flag in a set works
248# then nothing from that set is added.
249#
250# For multiple ABIs, the scheme extends as follows.
251#
252#   abilist               set of ABI choices
253#   cclist_aa             compiler choices in ABI aa
254#   xx_aa_cflags          flags for xx in ABI aa
255#   xx_aa_cppflags        cpp flags for xx in ABI aa
256#   xx_aa_cflags_optlist  list of sets of optional flags in ABI aa
257#   xx_aa_cflags_yyy      set yyy of optional flags for compiler xx in ABI aa
258#   xx_aa_ldflags         -Wc,-foo flags for libtool linking
259#   ar_aa_flags           extra flags for $AR in ABI aa
260#   nm_aa_flags           extra flags for $NM in ABI aa
261#   limb_aa               limb size in ABI aa, can be "longlong"
262#   path_aa               mpn search path in ABI aa
263#   extra_functions_aa    extra mpn functions in ABI aa
264#
265# As a convenience, the unadorned xx_cflags (etc) are used for the last ABI
266# in ablist, if an xx_aa_cflags for that ABI isn't given.  For example if
267# abilist="64 32" then $cc_64_cflags will be used for the 64-bit ABI, but
268# for the 32-bit either $cc_32_cflags or $cc_cflags is used, whichever is
269# defined.  This makes it easy to add some 64-bit compilers and flags to an
270# unadorned 32-bit set.
271#
272# limb=longlong (or limb_aa=longlong) applies to all compilers within that
273# ABI.  It won't work to have some needing long long and some not, since a
274# single instantiated gmp.h will be used by both.
275#
276# SPEED_CYCLECOUNTER, cyclecounter_size and CALLING_CONVENTIONS_OBJS are
277# also set here, with an ABI suffix.
278#
279#
280#
281# A table-driven approach like this to mapping cpu type to good compiler
282# options is a bit of a maintenance burden, but there's not much uniformity
283# between options specifications on different compilers.  Some sort of
284# separately updatable tool might be cute.
285#
286# The use of lots of variables like this, direct and indirect, tends to
287# obscure when and how various things are done, but unfortunately it's
288# pretty much the only way.  If shell subroutines were portable then actual
289# code like "if this .. do that" could be written, but attempting the same
290# with full copies of GMP_PROG_CC_WORKS etc expanded at every point would
291# hugely bloat the output.
292
293
294AC_ARG_VAR(ABI, [desired ABI (for processors supporting more than one ABI)])
295
296# abilist needs to be non-empty, "standard" is just a generic name here
297abilist="standard"
298
299# FIXME: We'd like to prefer an ANSI compiler, perhaps by preferring
300# c89 over cc here.  But note that on HP-UX c89 provides a castrated
301# environment, and would want to be excluded somehow.  Maybe
302# AC_PROG_CC_STDC already does enough to stick cc into ANSI mode and
303# we don't need to worry.
304#
305cclist="gcc cc"
306
307gcc_cflags="-g -O2"
308gcc_64_cflags="-g -O2"
309cc_cflags="-O"
310cc_64_cflags="-O"
311
312SPEED_CYCLECOUNTER_OBJ=
313cyclecounter_size=2
314
315AC_SUBST(HAVE_HOST_CPU_FAMILY_power,  0)
316AC_SUBST(HAVE_HOST_CPU_FAMILY_powerpc,0)
317
318case $host in
319
320  a29k*-*-*)
321    path="a29k"
322    ;;
323
324
325  alpha*-*-*)
326    case $host_cpu in
327      alphaev5* | alphapca5*) path="alpha/ev5 alpha" ;;
328      alphaev6*)             path="alpha/ev6 alpha/ev5 alpha" ;;
329      *)                     path="alpha" ;;
330    esac
331    extra_functions="cntlz"
332    gcc_cflags_optlist="cpu asm"
333
334    # gcc 2.7.2.3 doesn't know any -mcpu= for alpha, apparently.
335    # gcc 2.95 and 3.0 know ev4, ev5, ev56, pca56, ev6.
336    # gcc 3.1 pre-releases add ev67.
337    #
338    case $host_cpu in
339      alpha)        gcc_cflags_cpu="-mcpu=ev4" ;;
340      alphaev5)     gcc_cflags_cpu="-mcpu=ev5" ;;
341      alphaev56)    gcc_cflags_cpu="-mcpu=ev56" ;;
342      alphapca56 | alphapca57)
343                    gcc_cflags_cpu="-mcpu=pca56" ;;
344      alphaev6)     gcc_cflags_cpu="-mcpu=ev6" ;;
345      alphaev67 | alphaev68)
346                    gcc_cflags_cpu="-mcpu=ev67 -mcpu=ev6" ;;
347    esac
348
349    # On old versions of gcc, which don't know -mcpu=, we believe an
350    # explicit -Wa,-mev5 etc will be necessary to put the assembler in
351    # the right mode for our .asm files and longlong.h asm blocks.
352    #
353    # On newer versions of gcc, when -mcpu= is known, we must give a
354    # -Wa which is at least as high as the code gcc will generate,
355    # since the options ordering seems to make our setting override
356    # that passed by gcc.
357    #
358    # gas prior to 2.14 doesn't accept -mev67, but -mev6 seems enough for
359    # ctlz and cttz (in 2.10.0 at least).
360    #
361    # OSF `as' accepts ev68 but stupidly treats it as ev4.  -arch only seems
362    # to affect insns like ldbu which are expanded as macros when necessary.
363    # Insns like ctlz which were never available as macros are always
364    # accepted and always generate their plain code.
365    #
366    case $host_cpu in
367      alpha)        gcc_cflags_asm="-Wa,-arch,ev4 -Wa,-mev4" ;;
368      alphaev5)     gcc_cflags_asm="-Wa,-arch,ev5 -Wa,-mev5" ;;
369      alphaev56)    gcc_cflags_asm="-Wa,-arch,ev56 -Wa,-mev56" ;;
370      alphapca56 | alphapca57)
371                    gcc_cflags_asm="-Wa,-arch,pca56 -Wa,-mpca56" ;;
372      alphaev6)     gcc_cflags_asm="-Wa,-arch,ev6 -Wa,-mev6" ;;
373      alphaev67 | alphaev68)
374                    gcc_cflags_asm="-Wa,-arch,ev67 -Wa,-mev67 -Wa,-arch,ev6 -Wa,-mev6" ;;
375    esac
376
377    # It might be better to ask "cc" whether it's Cray C or DEC C,
378    # instead of relying on the OS part of $host.  But it's hard to
379    # imagine either of those compilers anywhere except their native
380    # systems.
381    #
382    case $host in
383      *-cray-unicos*)
384        cc_cflags="-O"          # no -g, it silently disables all optimizations
385        GMP_INCLUDE_MPN(alpha/unicos.m4)
386        # Don't perform any assembly syntax tests on this beast.
387        gmp_asm_syntax_testing=no
388        ;;
389      *-*-osf*)
390        GMP_INCLUDE_MPN(alpha/default.m4)
391        cc_cflags=""
392        cc_cflags_optlist="opt cpu"
393
394        # not sure if -fast works on old versions, so make it optional
395        cc_cflags_opt="-fast -O2"
396
397        # DEC C V5.9-005 knows ev4, ev5, ev56, pca56, ev6.
398        # Compaq C V6.3-029 adds ev67.
399        #
400        case $host_cpu in
401          alpha)       cc_cflags_cpu="-arch~ev4~-tune~ev4" ;;
402          alphaev5)    cc_cflags_cpu="-arch~ev5~-tune~ev5" ;;
403          alphaev56)   cc_cflags_cpu="-arch~ev56~-tune~ev56" ;;
404          alphapca56 | alphapca57)
405                       cc_cflags_cpu="-arch~pca56~-tune~pca56" ;;
406          alphaev6)    cc_cflags_cpu="-arch~ev6~-tune~ev6" ;;
407          alphaev67 | alphaev68)
408                       cc_cflags_cpu="-arch~ev67~-tune~ev67 -arch~ev6~-tune~ev6" ;;
409        esac
410        ;;
411      *)
412        GMP_INCLUDE_MPN(alpha/default.m4)
413        ;;
414    esac
415
416    case $host in
417      *-*-unicos*)
418        # tune/alpha.asm assumes int==4bytes but unicos uses int==8bytes
419        ;;
420      *)
421        SPEED_CYCLECOUNTER_OBJ=alpha.lo
422        cyclecounter_size=1 ;;
423    esac
424    ;;
425
426
427  # Cray vector machines.
428  # This must come after alpha* so that we can recognize present and future
429  # vector processors with a wildcard.
430  *-cray-unicos*)
431    gmp_asm_syntax_testing=no
432    cclist="cc"
433    # We used to have -hscalar0 here as a workaround for miscompilation of
434    # mpz/import.c, but let's hope Cray fixes their bugs instead, since
435    # -hscalar0 causes disastrously poor code to be generated.
436    cc_cflags="-O3 -hnofastmd -htask0 -Wa,-B"
437    path="cray"
438    ;;
439
440
441  arm*-*-*)
442    path="arm"
443    gcc_cflags="$gcc_cflags $fomit_frame_pointer"
444    gcc_testlist="gcc-arm-umodsi"
445    extra_functions="udiv"
446    GMP_INCLUDE_MPN(arm/arm-defs.m4)
447    ;;
448
449
450  clipper*-*-*)
451    path="clipper"
452    ;;
453
454
455  # Fujitsu
456  [f30[01]-fujitsu-sysv*])
457    cclist="gcc vcc"
458    # FIXME: flags for vcc?
459    vcc_cflags="-g"
460    path="fujitsu"
461    ;;
462
463
464  hppa*-*-*)
465    # HP cc is K&R by default, but AM_C_PROTOTYPES will add "-Ae", or "-Aa
466    # -D_HPUX_SOURCE", to put it into ansi mode, if possible.
467
468    # default to pa7100
469    gcc_cflags="-g -O2"
470    gcc_cflags_optlist="arch"
471    gcc_cflags_arch="-mpa-risc-1-1"
472    cc_cflags="+DA1.1 +O2"
473    path="pa32/hppa1_1/pa7100 pa32/hppa1_1 pa32"
474    extra_functions="udiv_qrnnd"
475
476    SPEED_CYCLECOUNTER_OBJ=hppa.lo
477    cyclecounter_size=1
478
479    case $host in
480      hppa1.0*-*-*)
481        # override back to plain 1.0
482        gcc_cflags_optlist=
483        cc_cflags="+O2"
484        path="pa32"
485        ;;
486      hppa7000*-*-*)
487        path="pa32/hppa1_1 pa32"
488        ;;
489
490      hppa2.0*-*-*)
491        abilist="2.0n 1.0"
492
493        # FIXME: It's suspected that an assembler feature test might be
494        # necessary before -mpa-risc-2-0 can be enabled, since it's not
495        # clear (as of gcc 2.95.2) whether that option always gives an
496        # explicit ".level 2.0" or whatever to the assembler.  In any case,
497        # under gcc 2.95.2 it only enables a few extra floating point insns,
498        # so it's not very important.
499        #
500        # gmp_cflags_arch="-mpa-risc-2-0 -mpa-risc-1-1"
501
502        # FIXME: path should be "pa32/hppa2_0 pa32/hppa1_1 pa32"
503        path="pa32/hppa2_0 pa32/hppa1_1/pa7100 pa32/hppa1_1 pa32"
504
505        # no gcc support for long long in 2.0n
506        cclist_20n="cc"
507        # +O3 causes problems with fp rounding in mpfr/tests/tdiv.
508        cc_20n_cflags="+DA2.0 +e +O2"
509        cc_20n_testlist="hpc-hppa-2-0"
510        path_20n="pa64"
511        limb_20n=longlong
512        extra_functions_20n="umul_ppmm udiv_qrnnd"
513        SPEED_CYCLECOUNTER_OBJ_20n=hppa2.lo
514        cyclecounter_size_20n=2
515
516        # ABI=2.0w is available for hppa2.0w and hppa2.0, but not for hppa2.0n.
517        case $host in
518        hppa2.0n-*-*) ;;
519        *)
520          # HPUX 11 or up is required to run 2.0w.  Not sure about other
521          # systems (GNU/Linux for instance), but lets assume they're ok.
522          case $host in
523          [*-*-hpux1[1-9]*]) abilist="2.0w $abilist" ;;
524          *-*-hpux*)                                 ;;
525          *)                 abilist="2.0w $abilist" ;;
526          esac
527
528          # gcc support for 2.0w is in progress
529          cclist_20w="cc"
530          cc_20w_cflags="+DD64 +O2" # +O3 causes problems with fp rounding in mpfr/tests/tdiv.
531          cc_20w_testlist="hpc-hppa-2-0"
532          path_20w="pa64"
533          extra_functions_20w="umul_ppmm udiv_qrnnd"
534          SPEED_CYCLECOUNTER_OBJ_20w=hppa2w.lo
535          cyclecounter_size_20w=2
536          ;;
537        esac
538        ;;
539    esac
540    ;;
541
542
543  i960*-*-*)
544    path="i960"
545    ;;
546
547
548  ia64*-*-*)
549    path="ia64"
550    GMP_INCLUDE_MPN(ia64/default.m4)
551    SPEED_CYCLECOUNTER_OBJ=ia64.lo
552    ;;
553
554
555  # Motorola 68k
556  #
557  m68*-*-*)
558    GMP_INCLUDE_MPN(m68k/m68k-defs.m4)
559    gcc_cflags="-g $fomit_frame_pointer"
560    gcc_cflags_optlist="optimize arch"
561    gcc_cflags_optimize="-O2"   # munged below on gcc 2.95.x
562
563    # gcc 2.7.2 doesn't know -m68060 or -mcpu32, so let them fall back
564    # appropriately.
565    # FIXME: Maybe "-m68020 -mnobitfield" would suit cpu32 on 2.7.2.
566    #
567    case $host in
568    m68020-*-*)  gcc_cflags_arch="-m68020" ;;
569    m68030-*-*)  gcc_cflags_arch="-m68030" ;;
570    m68040-*-*)  gcc_cflags_arch="-m68040" ;;
571    m68060-*-*)  gcc_cflags_arch="-m68060 -m68000" ;;
572    m68360-*-*)  gcc_cflags_arch="-mcpu32 -m68000" ;;
573    *)           gcc_cflags_arch="-m68000" ;;
574    esac
575
576    # FIXME: m68k/mc68020 looks like it's ok for cpu32, but this wants to be
577    # tested.  Will need to introduce an m68k/cpu32 if m68k/mc62020 ever uses
578    # the bitfield instructions.
579    case $host in
580    [m680[234]0-*-* | m68360-*-*])  path="m68k/mc68020 m68k"
581                                    extra_functions="udiv umul" ;;
582    *)                              path="m68k" ;;
583    esac
584    ;;
585
586
587  # Motorola 88k
588  m88k*-*-*)
589    path="m88k"
590    ;;
591  m88110*-*-*)
592    # FIXME: Use `-O2'?
593    gcc_cflags="-g -O -m88110"
594    path="m88k/mc88110 m88k"
595    ;;
596
597
598  # National Semiconductor 32k
599  ns32k*-*-*)
600    path="ns32k"
601    ;;
602
603
604  # IRIX 5 and earlier can only run 32-bit o32.
605  #
606  # IRIX 6 and up always has a 64-bit mips CPU can run n32 or 64.  n32 is
607  # preferred over 64, but only because that's been the default in past
608  # versions of GMP.  The two are equally efficient.
609  #
610  # Linux kernel 2.2.13 arch/mips/kernel/irixelf.c has a comment about not
611  # supporting n32 or 64.
612  #
613  # FIXME: It's necessary to pass -mabi or -n32 to the compiler when
614  # linking.  Libtool used to strip them, hence the ldflags here.  It
615  # looks like it has something equivalent itself now, so perhaps
616  # these can be removed.
617  #
618  mips*-*-*)
619    abilist="o32"
620    gcc_cflags_optlist="abi"
621    gcc_cflags_abi="-mabi=32"
622    gcc_testlist="gcc-mips-o32"
623    path="mips32"
624    cc_cflags="-O2 -o32"   # no -g, it disables all optimizations
625    extra_functions="umul"
626    # this suits both mips32 and mips64
627    GMP_INCLUDE_MPN(mips32/mips-defs.m4)
628
629    case $host in
630      mips64*-*-* | mips*-*-irix[6789]*)
631        abilist="n32 64 o32"
632
633        cclist_n32="gcc cc"
634        gcc_n32_cflags="-g -O2 -mabi=n32"
635        gcc_n32_ldflags="-Wc,-mabi=n32"
636        # Pass just -O1, MIPSpro 7.2.1 miscompiles mpn/generic/divrem_1.c
637        # cvs version 1.20, for -O2 and -O3
638        cc_n32_cflags="-O1 -n32"        # no -g, it disables all optimizations
639        cc_n32_ldflags="-Wc,-n32"
640        limb_n32=longlong
641        path_n32="mips64"
642        extra_functions_n32="umul"
643
644        cclist_64="gcc cc"
645        gcc_64_cflags="-g -O2 -mabi=64"
646        gcc_64_ldflags="-Wc,-mabi=64"
647        cc_64_cflags="-O2 -64"          # no -g, it disables all optimizations
648        cc_64_ldflags="-Wc,-64"
649        path_64="mips64"
650        extra_functions_64="umul"
651        ;;
652    esac
653    ;;
654
655
656  # Darwin (powerpc-apple-darwin1.3) has gcc installed as cc.
657  #
658  # The darwin assembler doesn't accept "-mppc", so gcc_cflags_asm is
659  # optional.  The right flag would be "-arch ppc" or some such, but that's
660  # already the default.
661  #
662  # The darwin pre-compiling preprocessor is disabled with -no-cpp-precomp
663  # since it doesn't like "__attribute__ ((mode (SI)))" etc in gmp-impl.h,
664  # and so always ends up running the plain preprocessor anyway.  This could
665  # be done in CPPFLAGS rather than CFLAGS, but there's not many places
666  # preprocessing is done separately, and this is only a speedup, the normal
667  # preprocessor gets run if there's any problems.
668  #
669  powerpc*-*-*)
670    AC_DEFINE(HAVE_HOST_CPU_FAMILY_powerpc)
671    HAVE_HOST_CPU_FAMILY_powerpc=1
672    cclist="gcc cc"
673    cc_cflags="-g -O2"
674    gcc_cflags="-g -O2 -mpowerpc"
675    gcc_cflags_optlist="asm precomp cpu"
676    gcc_cflags_asm="-Wa,-mppc"
677    gcc_cflags_precomp="-no-cpp-precomp"
678    extra_functions="umul"
679
680    case $host_cpu in
681      powerpc740 | powerpc750 | powerpc7400)
682        path="powerpc32/750 powerpc32" ;;
683      *)
684        path="powerpc32" ;;
685    esac
686
687    # gcc 2.7.2 knows -mcpu=403, 603, 604.
688    # gcc 2.95 adds 401, 505, 602, 603e, ec603e, 604e, 620, 740, 750,
689    #   801, 821, 823, 860.
690    # gcc 3.0 adds 630, rs64a.
691    # gcc 3.1 pre-releases add 405, 7400, 7450.
692    #
693    # FIXME: The way 603e falls back to 603 for gcc 2.7.2 should be
694    # done for all the others too.  But what would be the correct
695    # arrangements?
696    #
697    case $host_cpu in
698      powerpc401)   gcc_cflags_cpu="-mcpu=401" ;;
699      powerpc403)   gcc_cflags_cpu="-mcpu=403" ;;
700      powerpc405)   gcc_cflags_cpu="-mcpu=405" ;;
701      powerpc505)   gcc_cflags_cpu="-mcpu=505" ;;
702      powerpc602)   gcc_cflags_cpu="-mcpu=602" ;;
703      powerpc603)   gcc_cflags_cpu="-mcpu=603" ;;
704      powerpc603e)  gcc_cflags_cpu="-mcpu=603e -mcpu=603" ;;
705      powerpc604)   gcc_cflags_cpu="-mcpu=604" ;;
706      powerpc604e)  gcc_cflags_cpu="-mcpu=604e -mcpu=604" ;;
707      powerpc620)   gcc_cflags_cpu="-mcpu=620" ;;
708      powerpc630)   gcc_cflags_cpu="-mcpu=630" ;;
709      powerpc740)   gcc_cflags_cpu="-mcpu=740" ;;
710      powerpc7400)  gcc_cflags_cpu="-mcpu=7400" ;;
711      powerpc7450)  gcc_cflags_cpu="-mcpu=7450" ;;
712      powerpc750)   gcc_cflags_cpu="-mcpu=750" ;;
713      powerpc801)   gcc_cflags_cpu="-mcpu=801" ;;
714      powerpc821)   gcc_cflags_cpu="-mcpu=821" ;;
715      powerpc823)   gcc_cflags_cpu="-mcpu=823" ;;
716      powerpc860)   gcc_cflags_cpu="-mcpu=860" ;;
717    esac
718
719    case $host in
720      *-*-aix*)
721        cclist="gcc xlc cc"
722        xlc_cflags="-g -O2 -qmaxmem=20000"
723        xlc_cflags_optlist="arch"
724
725        # xlc (what version?) knows -qarch=ppc, ppcgr, 601, 602, 603, 604,
726        # 403, rs64a
727        # -qarch=ppc is needed, so ensure everything falls back to that.
728        # FIXME: Perhaps newer versions know more flavours.
729        #
730        case $host_cpu in
731          powerpc403)   xlc_cflags_arch="-qarch=403 -qarch=ppc" ;;
732          powerpc602)   xlc_cflags_arch="-qarch=602 -qarch=ppc" ;;
733          powerpc603)   xlc_cflags_arch="-qarch=603 -qarch=ppc" ;;
734          powerpc603e)  xlc_cflags_arch="-qarch=603 -qarch=ppc" ;;
735          powerpc604)   xlc_cflags_arch="-qarch=604 -qarch=ppc" ;;
736          powerpc604e)  xlc_cflags_arch="-qarch=604 -qarch=ppc" ;;
737          *)            xlc_cflags_arch="-qarch=ppc" ;;
738        esac
739        ;;
740    esac
741
742    case $host in
743      POWERPC64_PATTERN)
744        # On AIX a true 64-bit ABI is available.
745        case $host in
746          *-*-aix*)
747            # Need -Wc to pass object type flags through to the linker.
748            abilist="aix64 32"
749            cclist_aix64="gcc xlc"
750            gcc_aix64_cflags="-g -O2 -maix64 -mpowerpc64"
751            gcc_aix64_cflags_optlist="cpu"
752            gcc_aix64_ldflags="-Wc,-maix64"
753            xlc_aix64_cflags="-g -O2 -q64 -qtune=pwr3 -qmaxmem=20000"
754            xlc_aix64_ldflags="-Wc,-q64"
755            # Must indicate object type to ar and nm
756            ar_aix64_flags="-X64"
757            nm_aix64_flags="-X64"
758            path_aix64="powerpc64"
759            extra_functions_aix64="umul"
760            ;;
761          *-*-linux*)
762            # On GNU/Linux, assume the processor is in 64-bit mode.  Some
763            # environments have a gcc that is always in 64-bit mode, while
764            # others require -m64, hence the use of cflags_maybe.  The
765            # sizeof-long-8 test checks the mode is right (for the no option
766            # case).
767            #
768            # -mpowerpc64 is not used, since it should be the default in
769            # 64-bit mode.  (We need its effect for the various longlong.h
770            # asm macros to be right of course.)
771            #
772            # gcc64 was an early port of gcc to 64-bit mode, but should be
773            # obsolete before too long.  We prefer plain gcc when it knows
774            # 64-bits.
775            #
776            abilist="64 $abilist"
777            cclist_64="gcc gcc64"
778            gcc_64_cflags_maybe="-m64"
779            gcc_64_cflags="-O3"
780            gcc_64_cflags_optlist="cpu"
781            path_64="powerpc64"
782            any_64_testlist="sizeof-long-8"
783            gmp_cv_asm_underscore=no            # Kludge
784            ;;
785        esac
786        ;;
787    esac
788    ;;
789
790
791  # POWER
792  [power-*-* | power[12]-*-* | power2sc-*-*])
793    AC_DEFINE(HAVE_HOST_CPU_FAMILY_power)
794    HAVE_HOST_CPU_FAMILY_power=1
795    cclist="gcc"
796    extra_functions="udiv_w_sdiv"
797    path="power"
798
799    gcc_cflags_optlist="cpu"
800    case $host in
801      power-*-*)    gcc_cflags_cpu="-mcpu=power -mpower" ;;
802      power1-*-*)   gcc_cflags_cpu="-mcpu=rios1 -mpower" ;;
803      power2-*-*)   gcc_cflags_cpu="-mcpu=rios2 -mpower" ;;
804      power2sc-*-*) gcc_cflags_cpu="-mcpu=rsc   -mpower" ;;
805    esac
806    case $host in
807    *-*-aix*)
808      cclist="gcc xlc"
809      xlc_cflags="-g -O2 -qarch=pwr -qmaxmem=20000"
810      ;;
811    esac
812    ;;
813
814
815  # FIXME: ppc601 isn't accepted by config.sub.
816  ppc601-*-*)
817    path="power powerpc32"
818    ;;
819
820
821  pyramid-*-*)
822    path="pyr"
823    ;;
824
825
826  # IBM s/370 and similar
827  [s3[6-9]0*-*-*])
828    gcc_cflags="-g -O2 $fomit_frame_pointer"
829    path="s390"
830    extra_functions="udiv_w_sdiv"
831    ;;
832
833
834  sh-*-*)   path="sh" ;;
835  sh2-*-*)  path="sh/sh2 sh" ;;
836
837
838  *sparc*-*-*)
839    # For cc and acc, -g disables -O, so it's not used
840    cclist="gcc acc cc"
841    path="sparc32"
842    gcc_cflags="-g -O2"
843    gcc_cflags_optlist="cpu"
844    gcc_cflags_cpu=
845    acc_cflags="-O2"
846    cc_cflags="-O2"
847    GMP_INCLUDE_MPN(sparc32/sparc-defs.m4)
848
849    # FIXME: This should be selected according to the CPU
850    if test x${floating_point} = xno
851    then extra_functions="udiv_nfp"
852    else extra_functions="udiv_fp"
853    fi
854
855    case $host in
856      sparcv8*-*-* | supersparc*-*-* | microsparc*-*-*)
857        gcc_cflags_cpu="-mcpu=v8 -mv8"
858        acc_cflags="-O2 -cg92"
859        path="sparc32/v8 sparc32"
860        extra_functions="udiv"
861
862        case $host in
863          *-*-solaris2.*)  cc_cflags="-xtarget=native -xarch=v8 -xO4" ;;
864        esac
865        case $host in
866          supersparc*-*-*) path="sparc32/v8/supersparc sparc32/v8 sparc32" ;;
867        esac
868        ;;
869
870      # sparc64-*-linux-gnu is a misnomer, since there's no support for any
871      # 64-bit operations in user mode.  We assume that a future release
872      # will have some 64-bit support and that the gcc options will be the
873      # same as on solaris.
874      #
875      # cc -xarch actually controls the ABI, hence it must be v8 for 32-bit,
876      # even though the chip is v9.
877      #
878      sparcv9*-*-* | ultrasparc*-*-* | sparc64-*-*)
879        path="sparc32/v9 sparc32/v8 sparc32"
880        extra_functions="udiv_fp"
881
882        SPEED_CYCLECOUNTER_OBJ=sparcv9.lo
883
884        gcc_cflags="-g -O2 -Wa,-xarch=v8plus"
885        gcc_cflags_cpu="-mcpu=ultrasparc -mcpu=v9 -mcpu=v8 -mv8"
886
887        # must have -xarch=v8plus here, to get the right assembler options
888        # for our mpn/sparc32/v9 code
889        cc_cflags="-xtarget=native -xarch=v8plus -xO4"
890
891        case $host in
892          [*-*-solaris2.[7-9]])
893            # solaris prior to 2.6 doesn't save registers properly, so the
894            # 64-bit ABI is only available for 2.7 up
895            abilist="64 32"
896            path_64="sparc64"
897            cclist_64="gcc cc"
898            gcc_64_cflags="-g -O2 -m64 -mptr64 -Wa,-xarch=v9 -mcpu=v9"
899            gcc_64_ldflags="-Wc,-m64"
900            # -fast enables different optimizations depending compiler version
901            # -fns=no and -fsimple=1 disables some transformations that
902            # conflict with IEEE 754, which some compiler versions perform.
903            cc_64_cflags="-fast -fns=no -fsimple=1 -xarch=v9"
904            SPEED_CYCLECOUNTER_OBJ_64=sparcv9.lo
905            cyclecounter_size_64=2
906            ;;
907          *-*-*bsd*)
908            # NetBSD and OpenBSD sparc64
909            abilist="64"
910            extra_functions=
911            path="sparc64"
912            gcc_cflags="-g -O2"
913            cyclecounter_size=2
914            ;;
915        esac
916      ;;
917    esac
918    ;;
919
920
921  # VAX
922  vax*-*-*)
923    # Currently (version 3.0) gcc on vax always uses a frame pointer
924    # (config/vax/vax.h FRAME_POINTER_REQUIRED=1), so -fomit-frame-pointer
925    # will be ignored.
926    #
927    gcc_cflags="-g -O2 $fomit_frame_pointer"
928    path="vax"
929    extra_functions="udiv_w_sdiv"
930    ;;
931
932
933  # AMD and Intel x86 configurations
934  X86_PATTERN | x86_64-*-*)
935    AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86)
936    # Rumour has it gcc -O2 used to give worse register allocation than just
937    # -O, but lets assume that's no longer true.
938    gcc_cflags="-g -O2 $fomit_frame_pointer"
939    GMP_INCLUDE_MPN(x86/x86-defs.m4)
940    extra_functions="udiv umul"
941    CALLING_CONVENTIONS_OBJS='x86call.lo x86check$U.lo'
942
943    # Availability of rdtsc is checked at run-time.
944    SPEED_CYCLECOUNTER_OBJ=pentium.lo
945
946    # gcc 2.7.2 only knows i386 and i486, using -m386 or -m486.  These
947    # represent -mcpu= since -m486 doesn't generate 486 specific insns.  The
948    # -mcpu= and -march= options will fail, leaving just -m486.
949    #
950    # gcc 2.95.2 adds k6, pentium and pentiumpro, and allows -march= and
951    # -mcpu=.
952    #
953    # gcc 3.0 adds athlon.
954    #
955    # gcc 3.1 adds pentium4.
956
957    # Defaults for anything not otherwise mentioned.
958    path="x86"
959    gcc_cflags_optlist="cpu arch"
960    gcc_cflags_cpu="-mcpu=i486 -m486"
961    gcc_cflags_arch="-march=i486"
962
963    case $host in
964      i386*-*-*)
965        # Because i386 means generic x86, -mcpu=i486 is used since that
966        # should better suit newer processors.
967        # FIXME: How would a user ask for an actual 80386? Currently only by
968        # using CFLAGS="-mcpu=386" or whatever.
969        gcc_cflags_cpu="-mcpu=i486 -m486"
970        gcc_cflags_arch="-march=i386"
971        ;;
972      i586*-*-* | pentium-*-* | pentiummmx-*-*)
973        gcc_cflags_cpu="-mcpu=pentium -m486"
974        gcc_cflags_arch="-march=pentium"
975        ;;
976      [i686*-*-* | pentiumpro-*-* | pentium[23]-*-*])
977        gcc_cflags_cpu="-mcpu=pentiumpro -mcpu=i486 -m486"
978        gcc_cflags_arch="-march=pentiumpro -march=pentium -march=i486"
979        ;;
980      k6*-*-*)
981        gcc_cflags_cpu="-mcpu=k6 -mcpu=i486 -m486"
982        gcc_cflags_arch="-march=k6 -march=i486"
983        ;;
984      athlon-*-*)
985        # Athlon instruction costs are close to P6 (3 cycle load latency,
986        # 4-6 cycle mul, 40 cycle div, pairable adc, etc) so if gcc doesn't
987        # know athlon (eg. 2.95.2 doesn't) then fall back on pentiumpro.
988        gcc_cflags_cpu="-mcpu=athlon -mcpu=pentiumpro -mcpu=i486 -m486"
989        gcc_cflags_arch="-march=athlon -march=pentiumpro -march=pentium -march=i486"
990        ;;
991      pentium4-*-* | i786-*-*)
992        # pentium4 is known to gcc 3.1 and up, not sure what cpu choice
993        # would best suit previous versions, pentiumpro will get us cmov
994        # from gcc 2.95.4 up, otherwise let's just try i486.
995        gcc_cflags_cpu="-mcpu=pentium4 -mcpu=pentiumpro -mcpu=i486 -m486"
996        gcc_cflags_arch="-march=pentium4~-mno-sse2 -march=pentiumpro -march=pentium -march=i486"
997        ;;
998      viac32-*-*)
999        # Not sure of the best fallbacks here for -mcpu.
1000        # c3-2 has sse and mmx, so pentium3 is good for -march.
1001        gcc_cflags_cpu="-mtune=c3-2 -mcpu=c3-2 -mcpu=i486 -m486"
1002        gcc_cflags_arch="-march=c3-2 -march=pentium3 -march=pentiumpro -march=pentium"
1003        ;;
1004      viac3*-*-*)
1005        # Not sure of the best fallbacks here.
1006        gcc_cflags_cpu="-mtune=c3 -mcpu=c3 -mcpu=i486 -m486"
1007        gcc_cflags_arch="-march=c3 -march=pentium-mmx -march=pentium"
1008        ;;
1009      x86_64-*-*)
1010        gcc_cflags_cpu="-mtune=k8 -mcpu=athlon -mcpu=pentiumpro -mcpu=i486 -m486"
1011        gcc_cflags_arch="-march=k8 -march=k8~-mno-sse2 -march=athlon -march=pentiumpro -march=pentium"
1012        ;;
1013    esac
1014
1015    case $host in
1016      i486*-*-*)                  path="x86/i486 x86" ;;
1017      i586*-*-* | pentium-*-*)    path="x86/pentium x86" ;;
1018      pentiummmx-*-*)             path="x86/pentium/mmx x86/pentium x86" ;;
1019      i686*-*-* | pentiumpro-*-*) path="x86/p6 x86" ;;
1020      pentium2-*-*)   path="x86/p6/mmx x86/p6 x86" ;;
1021      pentium3-*-*)   path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86";;
1022      [k6[23]*-*-*])  path="x86/k6/k62mmx x86/k6/mmx x86/k6 x86" ;;
1023      k6*-*-*)        path="x86/k6/mmx x86/k6 x86" ;;
1024      # we don't have any specific 32-bit code for opteron (x86_64), the
1025      # athlon code should be reasonable
1026      athlon-*-* | x86_64-*-*)    path="x86/k7/mmx x86/k7 x86" ;;
1027      i786-*-* | pentium4-*-*)
1028        path="x86/pentium4/sse2 x86/pentium4/mmx x86/pentium4 x86" ;;
1029      # VIA/Centaur processors, sold as CyrixIII and C3.
1030      viac32-*-*)   path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86";;
1031      viac3*-*-*)   path="x86/pentium/mmx x86/pentium x86";;
1032      *)              path="x86" ;;
1033    esac
1034
1035    case $host in
1036      x86_64-*-*)
1037        abilist="64 32"
1038        path_64="x86-64"
1039        cclist_64="gcc"
1040        gcc_64_cflags="-O2 -m64"
1041        gcc_64_cflags_optlist="cpu"
1042        ;;
1043    esac
1044    ;;
1045
1046
1047  # FIXME: z8kx won't get through config.sub.  Could make 16 versus 32 bit
1048  # limb an ABI option perhaps.
1049  z8kx*-*-*)
1050    path="z8000x"
1051    extra_functions="udiv_w_sdiv"
1052    ;;
1053  z8k*-*-*)
1054    path="z8000"
1055    extra_functions="udiv_w_sdiv"
1056    ;;
1057
1058
1059  # Special CPU "none" selects generic C.  -DNO_ASM is used to disable gcc
1060  # asm blocks in longlong.h (since they're driven by cpp pre-defined
1061  # symbols like __alpha rather than the configured $host_cpu).
1062  #
1063  none-*-*)
1064    abilist="long longlong"
1065    cclist_long=$cclist
1066    gcc_long_cflags=$gcc_cflags
1067    gcc_long_cppflags="-DNO_ASM"
1068    cc_long_cflags=$cc_cflags
1069    cclist_longlong=$cclist
1070    gcc_longlong_cflags=$gcc_cflags
1071    gcc_longlong_cppflags="-DNO_ASM"
1072    cc_longlong_cflags=$cc_cflags
1073    limb_longlong=longlong
1074    ;;
1075
1076esac
1077
1078
1079CFLAGS_or_unset=${CFLAGS-'(unset)'}
1080CPPFLAGS_or_unset=${CPPFLAGS-'(unset)'}
1081
1082cat >&AC_FD_CC <<EOF
1083configure:__line__: User:
1084ABI=$ABI
1085CC=$CC
1086CFLAGS=$CFLAGS_or_unset
1087CPPFLAGS=$CPPFLAGS_or_unset
1088MPN_PATH=$MPN_PATH
1089configure:__line__: GMP:
1090abilist=$abilist
1091cclist=$cclist
1092EOF
1093
1094
1095test_CFLAGS=${CFLAGS+set}
1096test_CPPFLAGS=${CPPFLAGS+set}
1097
1098for abi in $abilist; do
1099  abi_last="$abi"
1100done
1101
1102# If the user specifies an ABI then it must be in $abilist, after that
1103# $abilist is restricted to just that choice.
1104#
1105if test -n "$ABI"; then
1106  found=no
1107  for abi in $abilist; do
1108    if test $abi = "$ABI"; then found=yes; break; fi
1109  done
1110  if test $found = no; then
1111    AC_MSG_ERROR([ABI=$ABI is not among the following valid choices: $abilist])
1112  fi
1113  abilist="$ABI"
1114fi
1115
1116found_compiler=no
1117
1118for abi in $abilist; do
1119
1120  # Suppose abilist="64 32", then for abi=64, will have abi1="_64" and
1121  # abi2="_64".  For abi=32, will have abi1="_32" and abi2="".  This is how
1122  # $gcc_cflags becomes a fallback for $gcc_32_cflags (the last in the
1123  # abilist), but there's no fallback for $gcc_64_cflags.
1124  #
1125  abi1=[`echo _$abi | sed 's/[.]//g'`]
1126  if test $abi = $abi_last; then abi2=; else abi2="$abi1"; fi
1127
1128  # Compiler choices under this ABI
1129                              eval cclist_chosen=\"\$cclist$abi1\"
1130  test -n "$cclist_chosen" || eval cclist_chosen=\"\$cclist$abi2\"
1131
1132  # If there's a user specified $CC then don't use a list for
1133  # $cclist_chosen, just a single value for $ccbase.
1134  #
1135  if test -n "$CC"; then
1136
1137    # The first word of $CC, stripped of any directory.  For instance
1138    # CC="/usr/local/bin/gcc -pipe" will give "gcc".
1139    #
1140    for ccbase in $CC; do break; done
1141    ccbase=`echo $ccbase | sed 's:.*/::'`
1142
1143    # If this $ccbase is in $cclist_chosen then it's a compiler we know and
1144    # we can do flags defaulting with it.  If not, then $cclist_chosen is
1145    # set to "unrecognised" so no default flags are used.
1146    #
1147    # "unrecognised" is used to avoid bad effects with eval if $ccbase has
1148    # non-symbol characters.  For instance ccbase=my+cc would end up with
1149    # something like cflags="$my+cc_cflags" which would give
1150    # cflags="+cc_cflags" rather than the intended empty string for an
1151    # unknown compiler.
1152    #
1153    found=unrecognised
1154    for i in $cclist_chosen; do
1155      if test "$ccbase" = $i; then
1156        found=$ccbase
1157        break
1158      fi
1159    done
1160    cclist_chosen=$found
1161  fi 
1162
1163  for ccbase in $cclist_chosen; do
1164
1165    # When cross compiling, look for a compiler with the $host_alias as a
1166    # prefix, the same way that AC_CHECK_TOOL does.  But don't do this to a
1167    # user-selected $CC.
1168    #
1169    # $cross_compiling will be yes/no/maybe at this point.  Do the host
1170    # prefixing for "maybe" as well as "yes".
1171    #
1172    if test "$cross_compiling" != no && test -z "$CC"; then
1173      cross_compiling_prefix="${host_alias}-"
1174    fi
1175
1176    for ccprefix in $cross_compiling_prefix ""; do
1177
1178      cc="$CC"
1179      test -n "$cc" || cc="$ccprefix$ccbase"
1180
1181      # If the compiler is gcc but installed under another name, then change
1182      # $ccbase so as to use the flags we know for gcc.  This helps for
1183      # instance when specifying CC=gcc272 on Debian GNU/Linux, or the
1184      # native cc which is really gcc on NeXT or MacOS-X.
1185      #
1186      # FIXME: There's a slight misfeature here.  If cc is actually gcc but
1187      # gcc is not a known compiler under this $abi then we'll end up
1188      # testing it with no flags and it'll work, but chances are it won't be
1189      # in the right mode for the ABI we desire.  Let's quietly hope this
1190      # doesn't happen.
1191      #
1192      if test $ccbase != gcc; then
1193        GMP_PROG_CC_IS_GNU($cc,ccbase=gcc)
1194      fi
1195
1196      # Similarly if the compiler is IBM xlc but invoked as cc or whatever
1197      # then change $ccbase and make the default xlc flags available.
1198      if test $ccbase != xlc; then
1199        GMP_PROG_CC_IS_XLC($cc,ccbase=xlc)
1200      fi
1201
1202      # Any user CFLAGS, even an empty string, takes precendence
1203                           eval cflags=\"\$${ccbase}${abi1}_cflags\"
1204      test -n "$cflags" || eval cflags=\"\$${ccbase}${abi2}_cflags\"
1205      if test "$test_CFLAGS" = set; then cflags=$CFLAGS; fi
1206
1207      # Any user CPPFLAGS, even an empty string, takes precendence
1208                             eval cppflags=\"\$${ccbase}${abi1}_cppflags\"
1209      test -n "$cppflags" || eval cppflags=\"\$${ccbase}${abi2}_cppflags\"
1210      if test "$test_CPPFLAGS" = set; then cppflags=$CPPFLAGS; fi
1211
1212      # --enable-profiling adds -p/-pg even to user-specified CFLAGS.
1213      # This is convenient, but it's perhaps a bit naughty to modify user
1214      # CFLAGS.
1215      case "$enable_profiling" in
1216      prof)  cflags="$cflags -p" ;;
1217      gprof) cflags="$cflags -pg" ;;
1218      esac
1219
1220      GMP_PROG_CC_WORKS($cc $cflags $cppflags,,continue)
1221
1222      # The tests to perform on this $cc, if any
1223                             eval testlist=\"\$${ccbase}${abi1}_testlist\"
1224      test -n "$testlist" || eval testlist=\"\$${ccbase}${abi2}_testlist\"
1225
1226      testlist_pass=yes
1227      for tst in $testlist; do
1228        case $tst in
1229        hpc-hppa-2-0)   GMP_HPC_HPPA_2_0($cc,,testlist_pass=no) ;;
1230        gcc-arm-umodsi) GMP_GCC_ARM_UMODSI($cc,,testlist_pass=no) ;;
1231        gcc-mips-o32)   GMP_GCC_MIPS_O32($cc,,testlist_pass=no) ;;
1232        esac
1233        if test $testlist_pass = no; then break; fi
1234      done
1235
1236      if test $testlist_pass = yes; then
1237        found_compiler=yes
1238        break
1239      fi
1240    done
1241
1242    if test $found_compiler = yes; then break; fi
1243  done
1244
1245  if test $found_compiler = yes; then break; fi
1246done
1247
1248
1249# If we recognised the CPU, as indicated by $path being set, then insist
1250# that we have a working compiler, either from our $cclist choices or from
1251# $CC.  We can't let AC_PROG_CC look around for a compiler because it might
1252# find one that we've rejected (for not supporting the modes our asm code
1253# demands, etc).
1254#
1255# If we didn't recognise the CPU (and this includes host_cpu=none), then
1256# fall through and let AC_PROG_CC look around for a compiler too.  This is
1257# mostly in the interests of following a standard autoconf setup, after all
1258# we've already tested cc and gcc adequately (hopefully).  As of autoconf
1259# 2.50 the only thing AC_PROG_CC really adds is a check for "cl" (Microsoft
1260# C on MS-DOS systems).
1261#
1262if test $found_compiler = no && test -n "$path"; then
1263  AC_MSG_ERROR([could not find a working compiler])
1264fi
1265
1266
1267if test $found_compiler = yes; then
1268
1269  # If we're creating CFLAGS, then look for optional additions.  If the user
1270  # set CFLAGS then leave it alone.
1271  #
1272  if test "$test_CFLAGS" != set; then
1273                          eval optlist=\"\$${ccbase}${abi1}_cflags_optlist\"
1274    test -n "$optlist" || eval optlist=\"\$${ccbase}${abi2}_cflags_optlist\"
1275
1276    for opt in $optlist; do
1277                             eval optflags=\"\$${ccbase}${abi1}_cflags_${opt}\"
1278      test -n "$optflags" || eval optflags=\"\$${ccbase}${abi2}_cflags_${opt}\"
1279      test -n "$optflags" || eval optflags=\"\$${ccbase}_cflags_${opt}\"
1280
1281      for flag in $optflags; do
1282
1283        # ~ respresents a space in an option spec
1284        flag=`echo "$flag" | tr '~' ' '`
1285
1286        case $flag in
1287          -O*)
1288            # ease back to just -O on m68k gcc 2.95.x
1289            GMP_GCC_M68K_OPTIMIZE($ccbase,$cc,flag)
1290            ;;
1291          -no-cpp-precomp)
1292            # special check, avoiding a warning
1293            GMP_GCC_NO_CPP_PRECOMP($ccbase,$cc,$cflags,
1294                                   [cflags="$cflags $flag"
1295                                   break],
1296                                   [continue])
1297            ;;
1298          -Wa,-m*)
1299            case $host in
1300              alpha*-*-*)
1301                GMP_GCC_WA_MCPU($cc $cflags, $flag, , [continue])
1302              ;;
1303            esac
1304            ;;
1305        esac
1306
1307        GMP_PROG_CC_WORKS($cc $cflags $cppflags $flag,
1308          [cflags="$cflags $flag"
1309          break])
1310      done
1311    done
1312  fi
1313
1314  ABI="$abi"
1315  CC="$cc"
1316  CFLAGS="$cflags"
1317  CPPFLAGS="$cppflags"
1318
1319
1320  # Could easily have this in config.h too, if desired.
1321  ABI_nodots=`echo $ABI | sed 's/\./_/'`
1322  GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_ABI_$ABI_nodots')", POST)
1323
1324
1325  # GMP_LDFLAGS substitution, selected according to ABI.
1326  # These are needed on libgmp.la and libmp.la, but currently not on
1327  # convenience libraries like tune/libspeed.la or mpz/libmpz.la.
1328  #
1329                            eval GMP_LDFLAGS=\"\$${ccbase}${abi1}_ldflags\"
1330  test -n "$GMP_LDFLAGS" || eval GMP_LDFLAGS=\"\$${ccbase}${abi1}_ldflags\"
1331  AC_SUBST(GMP_LDFLAGS)
1332
1333  # extra_functions, selected according to ABI
1334                    eval tmp=\"\$extra_functions$abi1\"
1335  test -n "$tmp" || eval tmp=\"\$extra_functions$abi2\"
1336  extra_functions="$tmp"
1337
1338
1339  # Cycle counter, selected according to ABI.
1340  #
1341                    eval tmp=\"\$SPEED_CYCLECOUNTER_OBJ$abi1\"
1342  test -n "$tmp" || eval tmp=\"\$SPEED_CYCLECOUNTER_OBJ$abi2\"
1343  SPEED_CYCLECOUNTER_OBJ="$tmp"
1344                    eval tmp=\"\$cyclecounter_size$abi1\"
1345  test -n "$tmp" || eval tmp=\"\$cyclecounter_size$abi2\"
1346  cyclecounter_size="$tmp"
1347
1348  if test -n "$SPEED_CYCLECOUNTER_OBJ"; then
1349    AC_DEFINE_UNQUOTED(HAVE_SPEED_CYCLECOUNTER, $cyclecounter_size,
1350    [Tune directory speed_cyclecounter, undef=none, 1=32bits, 2=64bits)])
1351  fi
1352  AC_SUBST(SPEED_CYCLECOUNTER_OBJ)
1353
1354
1355  # Calling conventions checking, selected according to ABI.
1356  #
1357                    eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi1\"
1358  test -n "$tmp" || eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi2\"
1359  CALLING_CONVENTIONS_OBJS="$tmp"
1360
1361  if test -n "$CALLING_CONVENTIONS_OBJS"; then
1362    AC_DEFINE(HAVE_CALLING_CONVENTIONS,1,
1363    [Define if tests/libtests has calling conventions checking for the CPU])
1364  fi
1365  AC_SUBST(CALLING_CONVENTIONS_OBJS)
1366
1367fi
1368
1369
1370# If the user gave an MPN_PATH, use that verbatim, otherwise choose
1371# according to the ABI and add "generic".
1372#
1373if test -n "$MPN_PATH"; then
1374  path="$MPN_PATH"
1375else
1376                    eval tmp=\"\$path$abi1\"
1377  test -n "$tmp" || eval tmp=\"\$path$abi2\"
1378  path="$tmp generic"
1379fi
1380
1381
1382# Whether using a long long limb in this ABI.
1383                          eval limb_chosen=\"\$limb$abi1\"
1384test -n "$limb_chosen" || eval limb_chosen=\"\$limb$abi2\"
1385case $limb_chosen in
1386longlong) DEFN_LONG_LONG_LIMB="#define _LONG_LONG_LIMB 1"    ;;
1387*)        DEFN_LONG_LONG_LIMB="/* #undef _LONG_LONG_LIMB */" ;;
1388esac
1389AC_SUBST(DEFN_LONG_LONG_LIMB)
1390
1391
1392# The C compiler and preprocessor, put into ANSI mode if possible.
1393AC_PROG_CC
1394AC_PROG_CC_STDC
1395AC_PROG_CPP
1396GMP_H_ANSI
1397
1398
1399# The C++ compiler, if desired.
1400want_cxx=no
1401if test $enable_cxx != no; then
1402  test_CXXFLAGS=${CXXFLAGS+set}
1403  AC_PROG_CXX
1404
1405  echo "CXXFLAGS chosen by autoconf: $CXXFLAGS" >&AC_FD_CC
1406  cxxflags_ac_prog_cxx=$CXXFLAGS
1407  cxxflags_list=ac_prog_cxx
1408
1409  # If the user didn't specify $CXXFLAGS, then try $CFLAGS, with -g removed
1410  # if AC_PROG_CXX thinks that doesn't work.  $CFLAGS stands a good chance
1411  # of working, eg. on a GNU system where CC=gcc and CXX=g++.
1412  #
1413  if test "$test_CXXFLAGS" != set; then
1414    cxxflags_cflags=$CFLAGS
1415    cxxflags_list="cflags $cxxflags_list"
1416    if test "$ac_prog_cxx_g" = no; then
1417      cxxflags_cflags=`echo "$cxxflags_cflags" | sed -e 's/ -g //' -e 's/^-g //' -e 's/ -g$//'`
1418    fi
1419  fi
1420
1421  # See if the C++ compiler works.  If the user specified CXXFLAGS then all
1422  # we're doing is checking whether AC_PROG_CXX succeeded, since it doesn't
1423  # give a fatal error, just leaves CXX set to a default g++.  If on the
1424  # other hand the user didn't specify CXXFLAGS then we get to try here our
1425  # $cxxflags_list alternatives.
1426  #
1427  for cxxflags_choice in $cxxflags_list; do
1428    eval CXXFLAGS=\"\$cxxflags_$cxxflags_choice\"
1429    GMP_PROG_CXX_WORKS($CXX $CXXFLAGS,
1430      [want_cxx=yes
1431      break])
1432  done
1433
1434  # If --enable-cxx=yes but a C++ compiler can't be found, then abort.
1435  if test $want_cxx = no && test $enable_cxx = yes; then
1436    AC_MSG_ERROR([C++ compiler not available])
1437  fi
1438fi
1439
1440AM_CONDITIONAL(WANT_CXX, test $want_cxx = yes)
1441
1442# FIXME: We're not interested in CXXCPP for ourselves, but if we don't call
1443# it here then AC_PROG_LIBTOOL (via _LT_AC_TAGCONFIG) will do so
1444# unconditionally, and that will fail if there's no C++ compiler (and no
1445# generic /lib/cpp).
1446#
1447if test $want_cxx = yes; then
1448  AC_PROG_CXXCPP
1449fi
1450
1451case $host_cpu in
1452  c90 | t90)
1453    AC_EGREP_CPP(yes,
1454[#ifdef _CRAYIEEE
1455yes
1456#endif],
1457    [add_path="cray/ieee"],
1458    [add_path="cray/cfp"; extra_functions="mulwwc90"]) ;;
1459  j90 | sv1)
1460    extra_functions="mulwwj90"
1461    add_path="cray/cfp" ;;
1462esac
1463
1464if test -z "$MPN_PATH"; then
1465  path="$add_path $path"
1466fi
1467
1468# for a nail build, also look in "nails" subdirectories
1469if test $GMP_NAIL_BITS != 0 && test -z "$MPN_PATH"; then
1470  new_path=
1471  for i in $path; do
1472    case $i in
1473    generic) new_path="$new_path $i" ;;
1474    *)       new_path="$new_path $i/nails $i" ;;
1475    esac
1476  done
1477  path=$new_path
1478fi
1479
1480
1481cat >&AC_FD_CC <<EOF
1482configure:__line__: Decided:
1483ABI=$ABI
1484CC=$CC
1485CFLAGS=$CFLAGS
1486CPPFLAGS=$CPPFLAGS
1487GMP_LDFLAGS=$GMP_LDFLAGS
1488CXX=$CXX
1489CXXFLAGS=$CXXFLAGS
1490path=$path
1491EOF
1492echo "using ABI=\"$ABI\""
1493echo "      CC=\"$CC\""
1494echo "      CFLAGS=\"$CFLAGS\""
1495echo "      CPPFLAGS=\"$CPPFLAGS\""
1496if test $want_cxx = yes; then
1497  echo "      CXX=\"$CXX\""
1498  echo "      CXXFLAGS=\"$CXXFLAGS\""
1499fi
1500echo "      MPN_PATH=\"$path\""
1501
1502
1503# Automake ansi2knr support.
1504AM_C_PROTOTYPES
1505
1506GMP_PROG_AR
1507GMP_PROG_NM
1508
1509case $host in
1510  # FIXME: On AIX 3 and 4, $libname.a is included in libtool
1511  # $library_names_spec, so libgmp.a becomes a symlink to libgmp.so, making
1512  # it impossible to build shared and static libraries simultaneously.
1513  # Disable shared libraries by default, but let the user override with
1514  # --enable-shared --disable-static.
1515  #
1516  # FIXME: This $libname.a problem looks like it might apply to *-*-amigaos*
1517  # and *-*-os2* too, but wait for someone to test this before worrying
1518  # about it.  If there is a problem then of course libtool is the right
1519  # place to fix it.
1520  #
1521  [*-*-aix[34]*])
1522    if test -z "$enable_shared"; then enable_shared=no; fi ;;
1523
1524  # FIXME: Libtool recognises djgpp can't build shared libraries, but still
1525  # makes tests/.libs/libtests.al out of PIC objects, which then fail to
1526  # link into the test programs.  Forcibly disable shared stuff until
1527  # libtool gets it right,
1528  #
1529  *-*-msdosdjgpp*)
1530    enable_shared=no ;;
1531
1532  # FIXME: On SCO 5, an explicit -lc is not wanted when making shared
1533  # libraries.  Giving it makes strange things happen, like ctype.h macros
1534  # not working and profiler mcount calls segfaulting.  Libtool ought to
1535  # know about this, but as of Dec 2000 it doesn't, so forcibly disable -lc
1536  # on relevant systems.
1537  #
1538  *-*-sco3.2v5*)
1539    lt_cv_archive_cmds_need_lc=no ;;
1540
1541  # FIXME: Shared libraries aren't supported on unicos, but as of Dec 2000
1542  # libtool doesn't seem to detect this correctly, so forcibly disable them.
1543  #
1544  *-*-unicos*)
1545    enable_shared=no ;;
1546
1547  # It seems there are no shared libs on ultrix, and it is not very important
1548  # to work on this.  Just disable for now.
1549  *-*-ultrix*)
1550    enable_shared=no ;;
1551esac
1552
1553# FIXME: AC_LIBTOOL_SYS_MAX_CMD_LEN has been reported to blow up in some
1554# fashion on windows 9x (but not 2k), taking a very long time and
1555# temporarily locking the whole PC.  Clearly this is a libtool problem, but
1556# for now force a sensible value to avoid the test.
1557#
1558case $build in
1559  *-*-cygwin*)
1560    if test -z "$lt_cv_sys_max_cmd_len"; then
1561      lt_cv_sys_max_cmd_len=20000
1562    fi
1563    ;;
1564esac
1565
1566
1567# Configs for Windows DLLs.
1568
1569AC_LIBTOOL_WIN32_DLL
1570
1571AC_SUBST(LIBGMP_DLL,0)
1572case $host in
1573  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1574    # By default, build only static.
1575    if test -z "$enable_shared"; then
1576      enable_shared=no
1577    fi
1578    # Don't allow both static and DLL.
1579    if test "$enable_shared" != no && test "$enable_static" != no; then
1580      AC_MSG_ERROR([cannot build both static and DLL, since gmp.h is different for each.
1581Use "--disable-static --enable-shared" to build just a DLL.])
1582    fi
1583    if test "$enable_shared" = yes; then
1584      # libtool requires "-no-undefined", see AC_LIBTOOL_WIN32_DLL doco.
1585      GMP_LDFLAGS="$GMP_LDFLAGS -no-undefined"
1586      LIBGMP_DLL=1
1587    fi
1588    ;;
1589esac
1590
1591# When cross compiling a DLL, libtool requires $HOST_CC, to compile impgen.c
1592# on the build system.  It's a well-known misfeature that libtool doesn't
1593# hunt around for a useful HOST_CC on its own.
1594# FIXME: Newer libtool looks like it'll need this only for "*-*-mingw* |
1595# *-*-pw32*", not *-*-cygwin*.
1596#
1597case $host in
1598  *-*-cygwin* | *-*-mingw* | *-*-pw32*)
1599    if test "$cross_compiling" != no && test "$enable_shared" != no; then
1600      GMP_PROG_HOST_CC
1601    fi
1602    ;;
1603esac
1604
1605
1606# Ensure that $CONFIG_SHELL is available for AC_LIBTOOL_SYS_MAX_CMD_LEN.
1607# It's often set already by _LT_AC_PROG_ECHO_BACKSLASH or
1608# _AS_LINENO_PREPARE, but not always.
1609#
1610# The symptom of CONFIG_SHELL unset is some "expr" errors during the test,
1611# and an empty result.  This only happens when invoked as "sh configure",
1612# ie. no path, and can be seen for instance on ia64-*-hpux*.
1613#
1614# FIXME: Newer libtool should have it's own fix for this.
1615#
1616if test -z "$CONFIG_SHELL"; then
1617  CONFIG_SHELL=$SHELL
1618fi
1619
1620# Enable CXX in libtool only if we want it, and never enable GCJ, nor RC on
1621# mingw and cygwin.  Under --disable-cxx this avoids some error messages
1622# from libtool arising from the fact we didn't actually run AC_PROG_CXX.
1623# Notice that any user-supplied --with-tags setting takes precedence.
1624#
1625# FIXME: Is this the right way to get this effect?  Very possibly not, but
1626# the current _LT_AC_TAGCONFIG doesn't really suggest an alternative.
1627#
1628if test "${with_tags+set}" != set; then
1629  if test $want_cxx = yes; then
1630    with_tags=CXX
1631  else
1632    with_tags=
1633  fi
1634fi
1635
1636AC_PROG_LIBTOOL
1637
1638# Generate an error here if attempting to build both shared and static when
1639# $libname.a is in $library_names_spec (as mentioned above), rather than
1640# wait for ar or ld to fail.
1641#
1642if test "$enable_shared" = yes && test "$enable_static" = yes; then
1643  case $library_names_spec in
1644    *libname.a*)
1645      AC_MSG_ERROR([cannot create both shared and static libraries on this system, --disable one of the two])
1646      ;;
1647  esac
1648fi
1649
1650
1651# How to assemble, used with CFLAGS etc, see mpn/Makeasm.am.
1652# Using the compiler is a lot easier than figuring out how to invoke the
1653# assembler directly.
1654#
1655test -n "$CCAS" || CCAS="$CC -c"
1656AC_SUBST(CCAS)
1657
1658case $host in
1659  X86_PATTERN | x86_64-*-*)
1660    # If there's any sse2 or mmx in the path, check whether the assembler
1661    # supports it, and remove if not.
1662    case "$path" in
1663      *mmx*)   GMP_ASM_X86_MMX( , [GMP_STRIP_PATH(*mmx*)]) ;;
1664    esac
1665    case "$path" in
1666      *sse2*)  GMP_ASM_X86_SSE2( , [GMP_STRIP_PATH(sse2)]) ;;
1667    esac
1668  ;;
1669esac
1670
1671
1672# The library and header checks are mostly for the benefit of supplementary
1673# programs.  libgmp doesn't use anything too weird.
1674
1675AC_HEADER_STDC
1676AC_HEADER_TIME
1677
1678# Reasons for testing:
1679#   sys/param.h - not in mingw
1680#   sys/processor.h - solaris specific, though also present in macos
1681#   sys/resource.h - not in mingw
1682#   sys/sysctl.h - not in mingw
1683#   sys/syssgi.h - IRIX specific
1684#   sys/systemcfg.h - AIX specific
1685#   sys/times.h - not in mingw
1686#
1687# inttypes.h, stdint.h, unistd.h and sys/types.h are already in the autoconf
1688# default tests
1689#
1690AC_CHECK_HEADERS(fcntl.h locale.h sys/mman.h sys/param.h sys/processor.h sys/resource.h sys/sysctl.h sys/syssgi.h sys/systemcfg.h sys/time.h sys/times.h)
1691
1692# optarg should be in unistd.h, which is already in the default includes
1693AC_CHECK_DECLS([fgetc, fscanf, optarg, ungetc, vfprintf])
1694
1695AC_TYPE_SIGNAL
1696
1697# the default includes are sufficient for all these types
1698AC_CHECK_TYPES([intmax_t, long double, long long, ptrdiff_t, quad_t])
1699
1700AC_C_STRINGIZE
1701AC_C_VOLATILE
1702GMP_C_STDARG
1703GMP_C_ATTRIBUTE_CONST
1704GMP_C_ATTRIBUTE_MALLOC
1705GMP_C_ATTRIBUTE_MODE
1706GMP_C_ATTRIBUTE_NORETURN
1707
1708GMP_C_INLINE
1709GMP_H_EXTERN_INLINE
1710
1711# from libtool
1712AC_CHECK_LIBM
1713AC_SUBST(LIBM)
1714
1715GMP_FUNC_ALLOCA
1716GMP_OPTION_ALLOCA
1717
1718GMP_H_HAVE_FILE
1719GMP_IMPL_H_IEEE_FLOATS
1720
1721# FIXME: Autoconf 2.52 AC_C_BIGENDIAN bombs when cross compiling, but in the
1722# future the probes will be better and this override can be removed.
1723if test "$cross_compiling" = yes; then
1724  ac_cv_c_bigendian=unknown
1725fi
1726AC_C_BIGENDIAN
1727# Enhancement: In the future AC_C_BIGENDIAN will accept these actions as
1728# parameters.
1729case $ac_cv_c_bigendian in
1730  yes)     AC_DEFINE(HAVE_LIMB_BIG_ENDIAN, 1) ;;
1731  no)      AC_DEFINE(HAVE_LIMB_LITTLE_ENDIAN, 1) ;;
1732  unknown) ;;
1733  *)       AC_MSG_ERROR([Oops, unrecognised ac_cv_c_bigendian]) ;;
1734esac
1735AH_VERBATIM([HAVE_LIMB],
1736[/* Define one (just one) of the following for the endiannes of `mp_limb_t'.
1737   If the endianness is not a simple big or little, or you don't know what
1738   it is, then leave both of these undefined. */
1739#undef HAVE_LIMB_BIG_ENDIAN
1740#undef HAVE_LIMB_LITTLE_ENDIAN])
1741
1742GMP_C_DOUBLE_FORMAT
1743
1744
1745# On m68k NetBSD 1.4.1 getrusage() is doubtful.  ru_utime looks microsecond
1746# accurate but has been seen remaining unchanged after many microseconds
1747# have elapsed.  This upsets the tune and speed programs, so pretend it
1748# doesn't exist.
1749#
1750# FIXME: Would prefer tune/time.c to do a run-time test for this rather than
1751# driving it from the system name.
1752#
1753case $host in
1754  m68*-*-netbsd1.4*) ac_cv_func_getrusage=no ;;
1755esac
1756
1757# Reasons for testing:
1758#   alarm - not in mingw
1759#   clock_gettime - not in glibc 2.2.4, only very recent systems
1760#   cputime - not in glibc
1761#   gettimeofday - not in mingw
1762#   mmap - not in mingw, djgpp
1763#   obstack_vprintf - glibc specific
1764#   processor_info - solaris specific
1765#   read_real_time - AIX specific
1766#   sigaction - not in mingw
1767#   sigaltstack - not in mingw, old AIX (reputedly)
1768#   sigstack - not in mingw
1769#   strnlen - glibc extension
1770#   syssgi - IRIX specific
1771#   times - not in mingw
1772#
1773# clock_gettime is in librt on *-*-osf5.1.  We could look for it
1774# there, but that's not worth bothering with unless it has a decent
1775# resolution (in a quick test clock_getres said only 1 millisecond).
1776#
1777AC_CHECK_FUNCS(alarm clock clock_gettime cputime getpagesize getrusage gettimeofday localeconv memset mmap mprotect obstack_vprintf popen processor_info read_real_time sigaction sigaltstack sigstack syssgi strchr strnlen strtoul sysconf sysctl sysctlbyname times)
1778
1779# FIXME: Would have done this with an AM_CONDITIONAL, but automake 1.5
1780# doesn't like that under libgmp_la_DEPENDENCIES.
1781GMP_FUNC_VSNPRINTF
1782if test "$gmp_cv_func_vsnprintf" = no; then
1783  AC_SUBST(REPL_VSNPRINTF_PRINTF_OBJ, 'printf/repl-vsnprintf$U.lo')
1784  AC_SUBST(REPL_VSNPRINTF_OBJ,        'repl-vsnprintf$U.lo')
1785fi
1786
1787GMP_FUNC_SSCANF_WRITABLE_INPUT
1788
1789
1790# Pick the correct source files in $path and link them to mpn/.
1791# $gmp_mpn_functions lists all functions we need.
1792#
1793# The rule is to find a file with the function name and a .asm, .S,
1794# .s, or .c extension.  Certain multi-function files with special names
1795# can provide some functions too.  (mpn/Makefile.am passes
1796# -DOPERATION_<func> to get them to generate the right code.)
1797
1798# FIXME: udiv and umul aren't in $gmp_mpn_functions_optional yet since
1799# there's some versions of those files which should be checked for bit
1800# rot first.  Put them in $extra_functions for each host for now,
1801# change to standard optionals when all are ready.
1802
1803# Note: The following lines defining $gmp_mpn_functions_optional
1804#       and $gmp_mpn_functions are parsed by the "macos/configure"
1805#       Perl script. So if you change the lines in a major way
1806#       make sure to run and examine the output from
1807#       
1808#           % (cd macos; perl configure)
1809#
1810# Note: $gmp_mpn_functions must have mod_1 before pre_mod_1 so the former
1811#       can optionally provide the latter as an extra entrypoint.  Likewise
1812#       divrem_1 and pre_divrem_1.
1813
1814gmp_mpn_functions_optional="copyi copyd com_n
1815  and_n andn_n nand_n ior_n iorn_n nior_n xor_n xnor_n                  \
1816  gcd_finda invert_limb sqr_diagonal                                    \
1817  mul_2 mul_3 mul_4 addmul_2 addmul_3 addmul_4"
1818
1819gmp_mpn_functions="$extra_functions                                        \
1820  add add_1 add_n sub sub_1 sub_n mul_1 addmul_1                           \
1821  submul_1 lshift rshift dive_1 diveby3 divis divrem divrem_1 divrem_2     \
1822  fib2_ui mod_1 mod_34lsub1 mode1o pre_divrem_1 pre_mod_1 dump             \
1823  mul mul_fft mul_n mul_basecase sqr_basecase random random2 pow_1         \
1824  rootrem sqrtrem get_str set_str scan0 scan1 popcount hamdist cmp perfsqr \
1825  bdivmod gcd_1 gcd gcdext tdiv_qr dc_divrem_n sb_divrem_mn jacbase        \
1826  $gmp_mpn_functions_optional"
1827
1828# the list of all object files used by mpn/Makefile.in and the
1829# top-level Makefile.in, respectively
1830mpn_objects=
1831mpn_objs_in_libgmp="mpn/mp_bases.lo"
1832
1833# links from the sources, to be removed by "make distclean"
1834gmp_srclinks=
1835
1836define(MPN_SUFFIXES,[asm S s c])
1837
1838for tmp_ext in MPN_SUFFIXES; do
1839  eval found_$tmp_ext=no
1840done
1841
1842for tmp_fn in $gmp_mpn_functions; do
1843  for tmp_ext in MPN_SUFFIXES; do
1844    test "$no_create" = yes || rm -f mpn/$tmp_fn.$tmp_ext
1845  done
1846
1847  # mpn_preinv_divrem_1 might have been provided by divrem_1.asm, likewise
1848  # mpn_preinv_mod_1 by mod_1.asm.
1849  case $tmp_fn in
1850  pre_divrem_1)
1851    if test "$HAVE_NATIVE_mpn_preinv_divrem_1" = yes; then continue; fi ;;
1852  pre_mod_1)
1853    if test "$HAVE_NATIVE_mpn_preinv_mod_1" = yes; then continue; fi ;;
1854  esac
1855
1856  # functions that can be provided by multi-function files
1857  tmp_mulfunc=
1858  case $tmp_fn in
1859  add_n|sub_n)       tmp_mulfunc="aors_n"    ;;
1860  addmul_1|submul_1) tmp_mulfunc="aorsmul_1" ;;
1861  popcount|hamdist)  tmp_mulfunc="popham"    ;;
1862  and_n|andn_n|nand_n | ior_n|iorn_n|nior_n | xor_n|xnor_n)
1863                     tmp_mulfunc="logops_n"  ;;
1864  lshift|rshift)     tmp_mulfunc="lorrshift";;
1865  esac
1866
1867  found=no
1868  for tmp_dir in $path; do
1869    for tmp_base in $tmp_fn $tmp_mulfunc; do
1870      for tmp_ext in MPN_SUFFIXES; do
1871        tmp_file=$srcdir/mpn/$tmp_dir/$tmp_base.$tmp_ext
1872        if test -f $tmp_file; then
1873
1874          # For a nails build, check if the file supports our nail bits.
1875          # Generic code always supports all nails.
1876          #
1877          # FIXME: When a multi-function file is selected to provide one of
1878          # the nails-neutral routines, like logops_n for and_n, the
1879          # PROLOGUE grepping will create HAVE_NATIVE_mpn_<foo> defines for
1880          # all functions in that file, even if they haven't all been
1881          # nailified.  Not sure what to do about this, it's only really a
1882          # problem for logops_n, and it's not too terrible to insist those
1883          # get nailified alwasy.
1884          #
1885          if test $GMP_NAIL_BITS != 0 && test $tmp_dir != generic; then
1886            case $tmp_fn in
1887              and_n | ior_n | xor_n | \
1888              copyi | copyd | \
1889              popcount | hamdist | \
1890              udiv | udiv_qrnnd | udiv_w_sdiv | udiv_fp | udiv_nfp | \
1891              umul | umul_ppmm | \
1892              cntlz | invert_limb)
1893                # these operations are either unaffected by nails or defined
1894                # to operate on full limbs
1895                ;;
1896              *)
1897                nails=[`sed -n 's/^[    ]*NAILS_SUPPORT(\(.*\))/\1/p' $tmp_file `]
1898                for n in $nails; do
1899                  case $n in
1900                  *-*)
1901                    n_start=`echo "$n" | sed -n 's/\(.*\)-.*/\1/p'`
1902                    n_end=`echo "$n" | sed -n 's/.*-\(.*\)/\1/p'`
1903                    ;;
1904                  *)
1905                    n_start=$n
1906                    n_end=$n
1907                    ;;
1908                  esac
1909                  if test $GMP_NAIL_BITS -ge $n_start && test $GMP_NAIL_BITS -le $n_end; then
1910                    found=yes
1911                    break
1912                  fi
1913                done
1914                if test $found != yes; then
1915                  continue
1916                fi
1917                ;;
1918            esac
1919          fi
1920
1921          found=yes
1922          eval found_$tmp_ext=yes
1923
1924          if test $tmp_ext = c; then
1925            tmp_u='$U'
1926          else
1927            tmp_u=
1928          fi
1929
1930          mpn_objects="$mpn_objects $tmp_fn$tmp_u.lo"
1931          mpn_objs_in_libgmp="$mpn_objs_in_libgmp mpn/$tmp_fn$tmp_u.lo"
1932          AC_CONFIG_LINKS(mpn/$tmp_fn.$tmp_ext:mpn/$tmp_dir/$tmp_base.$tmp_ext)
1933          gmp_srclinks="$gmp_srclinks mpn/$tmp_fn.$tmp_ext"
1934
1935          # Duplicate AC_DEFINEs are harmless, so it doesn't matter
1936          # that multi-function files get grepped here repeatedly.
1937          # The PROLOGUE pattern excludes the optional second parameter.
1938          gmp_ep=[`
1939            sed -n 's/^[        ]*MULFUNC_PROLOGUE(\(.*\))/\1/p' $tmp_file ;
1940            sed -n 's/^[        ]*PROLOGUE(\([^,]*\).*)/\1/p' $tmp_file
1941          `]
1942          for gmp_tmp in $gmp_ep; do
1943            AC_DEFINE_UNQUOTED(HAVE_NATIVE_$gmp_tmp)
1944            eval HAVE_NATIVE_$gmp_tmp=yes
1945          done
1946
1947          case $tmp_fn in
1948          sqr_basecase) sqr_basecase_source=$tmp_file ;;
1949          esac
1950
1951          break
1952        fi
1953      done
1954      if test $found = yes; then break ; fi
1955    done
1956    if test $found = yes; then break ; fi
1957  done
1958
1959  if test $found = no; then
1960    for tmp_optional in $gmp_mpn_functions_optional; do
1961      if test $tmp_optional = $tmp_fn; then
1962        found=yes
1963      fi
1964    done
1965    if test $found = no; then
1966      AC_MSG_ERROR([no version of $tmp_fn found in path: $path])
1967    fi
1968  fi
1969done
1970
1971# All cycle counters are .asm files currently
1972if test -n "$SPEED_CYCLECOUNTER_OBJ"; then
1973  found_asm=yes
1974fi
1975
1976
1977# Don't demand an m4 unless it's actually needed.
1978if test $found_asm = yes; then
1979  GMP_PROG_M4
1980  GMP_M4_M4WRAP_SPURIOUS
1981else
1982  M4=m4-not-needed
1983fi
1984
1985# Only do the GMP_ASM checks if there's a .S or .asm wanting them.
1986if test $found_asm = no && test $found_S = no; then
1987  gmp_asm_syntax_testing=no
1988fi
1989
1990if test "$gmp_asm_syntax_testing" != no; then
1991  GMP_ASM_TEXT
1992  GMP_ASM_DATA
1993  GMP_ASM_LABEL_SUFFIX
1994  GMP_ASM_GLOBL
1995  GMP_ASM_UNDERSCORE
1996  GMP_ASM_RODATA
1997  GMP_ASM_GLOBL_ATTR
1998  GMP_ASM_TYPE
1999  GMP_ASM_SIZE
2000  GMP_ASM_LSYM_PREFIX
2001  GMP_ASM_W32
2002  GMP_ASM_ALIGN_LOG
2003
2004  case $host in
2005    m68*-*-*)
2006      GMP_ASM_M68K_INSTRUCTION
2007      GMP_ASM_M68K_ADDRESSING
2008      GMP_ASM_M68K_BRANCHES
2009      ;;
2010    powerpc*-*-*)
2011      GMP_ASM_POWERPC_R_REGISTERS
2012      GMP_INCLUDE_MPN(powerpc32/powerpc-defs.m4)
2013      case $host in
2014        powerpc*-*-aix*)
2015          case $ABI in
2016            64 | aix64) GMP_INCLUDE_MPN(powerpc64/aix.m4) ;;
2017            *)          GMP_INCLUDE_MPN(powerpc32/aix.m4) ;;
2018          esac
2019          ;;
2020        powerpc*-*-linux*)
2021          case $ABI in
2022            64) GMP_INCLUDE_MPN(powerpc64/linux64.m4) ;;
2023          esac
2024          ;;
2025      esac
2026      ;;
2027    power*-*-aix*)
2028      GMP_INCLUDE_MPN(powerpc32/aix.m4)
2029      ;;
2030    sparcv9*-*-* | ultrasparc*-*-* | sparc64-*-*)
2031      case $ABI in
2032        64)
2033          GMP_ASM_SPARC_REGISTER
2034          ;;
2035      esac
2036      ;;
2037    X86_PATTERN | x86_64-*-*)
2038      GMP_ASM_ALIGN_FILL_0x90
2039      GMP_ASM_X86_SHLDL_CL
2040      if test "$enable_profiling" != no; then
2041        GMP_ASM_X86_MCOUNT
2042      fi
2043      case $host in
2044        *-*-openbsd*)
2045          GMP_DEFINE(_GLOBAL_OFFSET_TABLE_,__GLOBAL_OFFSET_TABLE_)
2046          ;;
2047      esac
2048      ;;
2049  esac
2050fi
2051
2052
2053# Create link for gmp-mparam.h.
2054gmp_mparam_source=
2055for gmp_mparam_dir in $path; do
2056  test "$no_create" = yes || rm -f gmp-mparam.h
2057  tmp_file=$srcdir/mpn/$gmp_mparam_dir/gmp-mparam.h
2058  if test -f $tmp_file; then
2059    AC_CONFIG_LINKS(gmp-mparam.h:mpn/$gmp_mparam_dir/gmp-mparam.h)
2060    gmp_srclinks="$gmp_srclinks gmp-mparam.h"
2061    gmp_mparam_source=$tmp_file
2062    break
2063  fi
2064done
2065if test -z "$gmp_mparam_source"; then
2066  AC_MSG_ERROR([no version of gmp-mparam.h found in path: $path])
2067fi
2068
2069# For a helpful message from tune/tuneup.c
2070gmp_mparam_suggest=$gmp_mparam_source
2071if test "$gmp_mparam_dir" = generic; then
2072  for i in $path; do break; done
2073  if test "$i" != generic; then
2074    gmp_mparam_suggest="new file $srcdir/mpn/$i/gmp-mparam.h"
2075  fi
2076fi
2077AC_DEFINE_UNQUOTED(GMP_MPARAM_H_SUGGEST, "$gmp_mparam_source",
2078                   [The gmp-mparam.h to update when tuning.])
2079
2080
2081# Copy any SQR_KARATSUBA_THRESHOLD from gmp-mparam.h to config.m4.
2082# Some versions of sqr_basecase.asm use this.
2083tmp_gmp_karatsuba_sqr_threshold=`sed -n 's/^#define SQR_KARATSUBA_THRESHOLD[    ]*\([0-9][0-9]*\).*$/\1/p' $gmp_mparam_source`
2084if test -n "$tmp_gmp_karatsuba_sqr_threshold"; then
2085  GMP_DEFINE_RAW(["define(<SQR_KARATSUBA_THRESHOLD>,<$tmp_gmp_karatsuba_sqr_threshold>)"])
2086fi
2087
2088# This must come after gmp-mparam.h has been chosen.
2089GMP_C_SIZES
2090
2091GMP_DEFINE_RAW(["define(<GMP_LIMB_BITS>,$BITS_PER_MP_LIMB)"])
2092GMP_DEFINE_RAW(["define(<GMP_NAIL_BITS>,$GMP_NAIL_BITS)"])
2093GMP_DEFINE_RAW(["define(<GMP_NUMB_BITS>,eval(GMP_LIMB_BITS-GMP_NAIL_BITS))"])
2094
2095
2096# Exclude the mpn random functions from mpbsd since that would drag in the
2097# top-level rand things, all of which are unnecessary for libmp.  There's
2098# other unnecessary objects too actually, if we could be bothered figuring
2099# out exactly which they are.
2100#
2101mpn_objs_in_libmp=
2102for i in $mpn_objs_in_libgmp; do
2103  case $i in
2104  *random*) ;;
2105  *) mpn_objs_in_libmp="$mpn_objs_in_libmp $i" ;;
2106  esac
2107done
2108AC_SUBST(mpn_objs_in_libmp)
2109
2110AC_SUBST(mpn_objects)
2111AC_SUBST(mpn_objs_in_libgmp)
2112AC_SUBST(gmp_srclinks)
2113
2114
2115# Configs for mpfr.
2116#
2117if test $enable_mpfr = yes; then
2118  gmp_CFLAGS=$CFLAGS
2119  gmp_LIBS=$LIBS
2120  LIBS="$LIBS $LIBM"
2121
2122  MPFR_CONFIGS
2123
2124  AC_SUBST(MPFR_CFLAGS,$CFLAGS)
2125  AC_SUBST(MPFR_LIBS,  $LIBS)
2126  CFLAGS=$gmp_CFLAGS
2127  LIBS=$gmp_LIBS
2128fi
2129
2130
2131# A recompiled sqr_basecase for use in the tune program, if necessary.
2132TUNE_SQR_OBJ=
2133test -d tune || mkdir tune
2134case $sqr_basecase_source in
2135  *.asm)
2136    sqr_max=[`sed -n 's/^def...(SQR_KARATSUBA_THRESHOLD_MAX, *\([0-9]*\))/\1/p' $sqr_basecase_source`]
2137    if test -n "$sqr_max"; then
2138      TUNE_SQR_OBJ=sqr_asm.o
2139      AC_DEFINE_UNQUOTED(TUNE_SQR_KARATSUBA_MAX,$sqr_max,
2140      [Maximum size the tune program can test for SQR_KARATSUBA_THRESHOLD])
2141    fi
2142    cat >tune/sqr_basecase.c <<EOF
2143/* not sure that an empty file can compile, so put in a dummy */
2144int sqr_basecase_dummy;
2145EOF
2146    ;;
2147  *.c)
2148    TUNE_SQR_OBJ=
2149    AC_DEFINE(TUNE_SQR_KARATSUBA_MAX,SQR_KARATSUBA_MAX_GENERIC)
2150    cat >tune/sqr_basecase.c <<EOF
2151#define TUNE_PROGRAM_BUILD 1
2152#define TUNE_PROGRAM_BUILD_SQR 1
2153#include "mpn/sqr_basecase.c"
2154EOF
2155    ;;
2156esac
2157AC_SUBST(TUNE_SQR_OBJ)
2158
2159
2160# Configs for demos/pexpr.c.
2161#
2162AC_CONFIG_FILES(demos/pexpr-config.h:demos/pexpr-config-h.in)
2163GMP_SUBST_CHECK_FUNCS(clock, cputime, getrusage, gettimeofday, sigaction, sigaltstack, sigstack)
2164GMP_SUBST_CHECK_HEADERS(sys/resource.h)
2165AC_CHECK_TYPES([stack_t], HAVE_STACK_T_01=1, HAVE_STACK_T_01=0,
2166               [#include <signal.h>])
2167AC_SUBST(HAVE_STACK_T_01)
2168
2169# Configs for demos/calc directory
2170#
2171# AC_SUBST is used here since with AM_CONFIG_HEADER automake would put
2172# demos/calc in the default $(DEFAULT_INCLUDES) for every directory,
2173# which would look very strange.  Likewise demos/expr below.
2174#
2175AC_CONFIG_FILES(demos/calc/calc-config.h:demos/calc/calc-config-h.in)
2176use_readline=$with_readline
2177if test $with_readline = detect; then
2178  AC_CHECK_LIB(readline, readline, use_readline=yes)
2179fi
2180if test $use_readline = yes; then
2181  AC_SUBST(WITH_READLINE_01, 1)
2182  AC_SUBST(LIBREADLINE, -lreadline)
2183else
2184  WITH_READLINE_01=0
2185fi
2186AC_PROG_YACC
2187GMP_PROG_LEX
2188
2189# Configs for demos/expr directory
2190AC_CONFIG_FILES(demos/expr/expr-config.h:demos/expr/expr-config-h.in)
2191if test $enable_mpfr = yes; then
2192  AC_SUBST(HAVE_MPFR_01, 1)
2193else
2194  HAVE_MPFR_01=0
2195fi
2196if test $ac_cv_have_decl_optarg = yes; then
2197  AC_SUBST(HAVE_DECL_OPTARG, 1)
2198else
2199  HAVE_DECL_OPTARG=0
2200fi
2201
2202
2203# Create config.m4.
2204GMP_FINISH
2205
2206# Create Makefiles
2207# FIXME: Upcoming version of autoconf/automake may not like broken lines.
2208#        Right now automake isn't accepting the new AC_CONFIG_FILES scheme.
2209
2210AC_OUTPUT(Makefile                                                      \
2211  mpbsd/Makefile mpf/Makefile mpn/Makefile mpq/Makefile                 \
2212  mpz/Makefile printf/Makefile scanf/Makefile cxx/Makefile              \
2213  tests/Makefile tests/devel/Makefile tests/mpbsd/Makefile              \
2214  tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile              \
2215  tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile            \
2216  tests/cxx/Makefile                                                    \
2217  mpfr/Makefile mpfr/tests/Makefile                                     \
2218  tune/Makefile                                                         \
2219  demos/Makefile demos/calc/Makefile demos/expr/Makefile                \
2220  gmp.h:gmp-h.in mp.h:mp-h.in)
Note: See TracBrowser for help on using the repository browser.