~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to gmp3/configure.in

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl  Process this file with autoconf to produce a configure script.
 
2
 
 
3
 
 
4
# Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
 
5
#
 
6
# This file is part of the GNU MP Library.
 
7
#
 
8
# The GNU MP Library is free software; you can redistribute it and/or modify
 
9
# it under the terms of the GNU Lesser General Public License as published
 
10
# by the Free Software Foundation; either version 2.1 of the License, or (at
 
11
# your option) any later version.
 
12
#
 
13
# The GNU MP Library is distributed in the hope that it will be useful, but
 
14
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
15
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 
16
# License for more details.
 
17
#
 
18
# You should have received a copy of the GNU Lesser General Public License
 
19
# along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
 
20
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 
21
# MA 02111-1307, USA.
 
22
 
 
23
 
 
24
AC_REVISION($Revision: 1.2 $)
 
25
AC_PREREQ(2.52)
 
26
AC_INIT(gmp-impl.h)
 
27
m4_pattern_forbid([^[ \t]*GMP_])
 
28
m4_pattern_allow(GMP_LDFLAGS)
 
29
 
 
30
# If --target is not used then $target_alias is empty, but if say
 
31
# "./configure athlon-pc-freebsd3.5" is used, then all three of
 
32
# $build_alias, $host_alias and $target_alias are set to
 
33
# "athlon-pc-freebsd3.5".
 
34
#
 
35
if test -n "$target_alias" && test "$target_alias" != "$host_alias"; then
 
36
  AC_MSG_ERROR([--target is not appropriate for GMP
 
37
Use --build=CPU-VENDOR-OS if you need to specify your CPU and/or system
 
38
explicitly.  Use --host if cross-compiling (see "Installing GMP" in the
 
39
manual for more on this).])
 
40
fi
 
41
 
 
42
GMP_INIT(config.m4)
 
43
 
 
44
AC_CANONICAL_HOST
 
45
tmp_host=`echo $host_cpu | sed 's/\./_/'`
 
46
AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_$tmp_host)
 
47
GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_HOST_CPU_$tmp_host')", POST)
 
48
 
 
49
AM_INIT_AUTOMAKE(gmp, GMP_VERSION)
 
50
AM_CONFIG_HEADER(config.h:config.in)
 
51
AM_MAINTAINER_MODE
 
52
 
 
53
 
 
54
AC_ARG_ENABLE(assert,
 
55
AC_HELP_STRING([--enable-assert],[enable ASSERT checking [default=no]]),
 
56
[case $enableval in
 
57
yes|no) ;;
 
58
*) AC_MSG_ERROR([bad value $enableval for --enable-assert, need yes or no]) ;;
 
59
esac],
 
60
[enable_assert=no])
 
61
 
 
62
if test "$enable_assert" = "yes"; then
 
63
  AC_DEFINE(WANT_ASSERT,1,
 
64
  [./configure --enable-assert option, to enable some ASSERT()s])
 
65
fi
 
66
 
 
67
 
 
68
AC_ARG_ENABLE(alloca,
 
69
AC_HELP_STRING([--enable-alloca],[how to get temp memory [default=reentrant]]),
 
70
[case $enableval in
 
71
alloca|malloc-reentrant|malloc-notreentrant) ;;
 
72
yes|no|reentrant|notreentrant) ;;
 
73
debug) ;;
 
74
*)
 
75
  AC_MSG_ERROR([bad value $enableval for --enable-alloca, need one of:
 
76
yes no reentrant notreentrant alloca malloc-reentrant malloc-notreentrant debug]) ;;
 
77
esac],
 
78
[enable_alloca=reentrant])
 
79
 
 
80
 
 
81
# IMPROVE ME: The default for C++ is disabled.  The tests currently
 
82
# performed below for a working C++ compiler are not particularly strong,
 
83
# and in general can't be expected to get the right setup on their own.  The
 
84
# most significant problem is getting the ABI the same.  Defaulting CXXFLAGS
 
85
# to CFLAGS takes only a small step towards this.  It's also probably worth
 
86
# worrying whether the C and C++ runtimes from say gcc and a vendor C++ can
 
87
# work together.  Some rather broken C++ installations were encountered
 
88
# during testing, and though such things clearly aren't GMP's problem, if
 
89
# --enable-cxx=detect were to be the default then some careful checks of
 
90
# which, if any, C++ compiler on the system is up to scratch would be
 
91
# wanted.
 
92
#
 
93
AC_ARG_ENABLE(cxx,
 
94
AC_HELP_STRING([--enable-cxx],[enable C++ support [default=detect]]),
 
95
[case $enableval in
 
96
yes|no|detect) ;;
 
97
*) AC_MSG_ERROR([bad value $enableval for --enable-cxx, need yes/no/detect]) ;;
 
98
esac],
 
99
[enable_cxx=no])
 
100
 
 
101
 
 
102
AC_ARG_ENABLE(fft,
 
103
AC_HELP_STRING([--enable-fft],[enable FFTs for multiplication [default=yes]]),
 
104
[case $enableval in
 
105
yes|no) ;;
 
106
*) AC_MSG_ERROR([bad value $enableval for --enable-fft, need yes or no]) ;;
 
107
esac],
 
108
[enable_fft=yes])
 
109
 
 
110
if test "$enable_fft" = "yes"; then
 
111
  AC_DEFINE(WANT_FFT,1,
 
112
  [./configure --enable-fft option, to enable FFTs for multiplication])
 
113
fi
 
114
 
 
115
 
 
116
AC_ARG_ENABLE(mpbsd,
 
117
AC_HELP_STRING([--enable-mpbsd],
 
118
               [build Berkley MP compatibility library [default=no]]),
 
119
[case $enableval in
 
120
yes|no) ;;
 
121
*) AC_MSG_ERROR([bad value $enableval for --enable-mpbsd, need yes or no]) ;;
 
122
esac],
 
123
[enable_mpbsd=no])
 
124
AM_CONDITIONAL(WANT_MPBSD, test "$enable_mpbsd" = "yes")
 
125
 
 
126
 
 
127
AC_ARG_ENABLE(mpfr,
 
128
AC_HELP_STRING([--enable-mpfr],[build MPFR [default=no]]),
 
129
[case $enableval in
 
130
yes|no) ;;
 
131
*) AC_MSG_ERROR([bad value $enableval for --enable-mpfr, need yes or no]) ;;
 
132
esac],
 
133
[enable_mpfr=no])
 
134
AM_CONDITIONAL(WANT_MPFR, test "$enable_mpfr" = "yes")
 
135
 
 
136
 
 
137
AC_ARG_ENABLE(profiling,
 
138
AC_HELP_STRING([--enable-profiling],
 
139
               [build with profiler support [default=no]]),
 
140
[case $enableval in
 
141
no|prof|gprof) ;;
 
142
*) AC_MSG_ERROR([bad value $enableval for --enable-profiling, need no/prof/gprof]) ;;
 
143
esac],
 
144
[enable_profiling=no])
 
145
 
 
146
GMP_DEFINE_RAW(["define(<WANT_PROFILING>,<\`$enable_profiling'>)"])
 
147
 
 
148
# -fomit-frame-pointer is incompatible with -pg, on x86s at least
 
149
if test "$enable_profiling" = gprof; then
 
150
  fomit_frame_pointer=
 
151
else
 
152
  fomit_frame_pointer="-fomit-frame-pointer"
 
153
fi
 
154
 
 
155
 
 
156
 
 
157
# Table of compilers, options, and mpn paths.  This code has a couple of
 
158
# related purposes
 
159
#
 
160
#   - better default CC/CFLAGS selections than autoconf otherwise gives
 
161
#   - default CC/CFLAGS selections for extra CPU types specific to GMP
 
162
#   - a few tests for known bad compilers
 
163
#   - choice of ABIs on suitable systems
 
164
#   - selection of corresponding mpn search path
 
165
#
 
166
# After GMP specific searches and tests, the standard autoconf AC_PROG_CC is
 
167
# called.  User selections of CC etc are respected.
 
168
#
 
169
# Care is taken not to use macros like AC_TRY_COMPILE during the GMP
 
170
# pre-testing, since they of course depend on AC_PROG_CC, and also some of
 
171
# them cache their results, which is not wanted.
 
172
#
 
173
# The ABI selection mechanism is unique to GMP.  All that reaches autoconf
 
174
# is a different selection of CC/CFLAGS according to the best ABI the system
 
175
# supports, and/or what the user selects.  Naturally the mpn assembler code
 
176
# selected is very dependent on the ABI.
 
177
#
 
178
# The closest the standard tools come to a notion of ABI is something like
 
179
# "sparc64" which encodes a CPU and an ABI together.  This doesn't seem to
 
180
# scale well for GMP, where exact CPU types like "ultrasparc2" are wanted,
 
181
# separate from the ABI used on them.
 
182
#
 
183
#
 
184
# The variables set here are
 
185
#
 
186
#   cclist              the compiler choices
 
187
#   xx_cflags           flags for compiler xx
 
188
#   xx_cppflags         cpp flags for compiler xx
 
189
#   xx_cflags_optlist   list of sets of optional flags
 
190
#   xx_cflags_yyy       set yyy of optional flags for compiler xx
 
191
#   xx_ldflags          -Wc,-foo flags for libtool linking with compiler xx
 
192
#   ar_flags            extra flags for $AR
 
193
#   nm_flags            extra flags for $NM
 
194
#   limb                limb size, can be "longlong"
 
195
#   path                mpn search path
 
196
#   extra_functions     extra mpn functions
 
197
#
 
198
# Suppose xx_cflags_optlist="arch", then flags from $xx_cflags_arch are
 
199
# tried, and the first flag that works will be used.  An optlist like "arch
 
200
# cpu optimize" can be used to get multiple independent sets of flags tried.
 
201
# The first that works from each will be used.  If no flag in a set works
 
202
# then nothing from that set is added.
 
203
#
 
204
# For multiple ABIs, the scheme extends as follows.
 
205
#
 
206
#   abilist               set of ABI choices
 
207
#   cclist_aa             compiler choices in ABI aa
 
208
#   xx_aa_cflags          flags for xx in ABI aa
 
209
#   xx_aa_cppflags        cpp flags for xx in ABI aa
 
210
#   xx_aa_cflags_optlist  list of sets of optional flags in ABI aa
 
211
#   xx_aa_cflags_yyy      set yyy of optional flags for compiler xx in ABI aa
 
212
#   xx_aa_ldflags         -Wc,-foo flags for libtool linking
 
213
#   ar_aa_flags           extra flags for $AR in ABI aa
 
214
#   nm_aa_flags           extra flags for $NM in ABI aa
 
215
#   limb_aa               limb size in ABI aa, can be "longlong"
 
216
#   path_aa               mpn search path in ABI aa
 
217
#   extra_functions_aa    extra mpn functions in ABI aa
 
218
#
 
219
# As a convenience, the unadorned xx_cflags (etc) are used for the last ABI
 
220
# in ablist, if an xx_aa_cflags for that ABI isn't given.  For example if
 
221
# abilist="64 32" then $cc_64_cflags will be used for the 64-bit ABI, but
 
222
# for the 32-bit either $cc_32_cflags or $cc_cflags is used, whichever is
 
223
# defined.  This makes it easy to add some 64-bit compilers and flags to an
 
224
# unadorned 32-bit set.
 
225
#
 
226
# limb=longlong (or limb_aa=longlong) applies to all compilers within that
 
227
# ABI.  It won't work to have some needing long long and some not, since a
 
228
# single instantiated gmp.h will be used by both.
 
229
#
 
230
# SPEED_CYCLECOUNTER, cyclecounter_size and CALLING_CONVENTIONS_OBJS are
 
231
# also set here, with an ABI suffix.
 
232
 
 
233
 
 
234
AC_ARG_VAR(ABI,[intended ABI (for processors supporting more than one ABI)])
 
235
 
 
236
# abilist needs to be non-empty, "standard" is just a generic name here
 
237
abilist="standard"
 
238
 
 
239
# FIXME: Prefer c89 to cc.
 
240
cclist="gcc cc"
 
241
 
 
242
gcc_cflags="-g -O2"
 
243
gcc_64_cflags="-g -O2"
 
244
cc_cflags="-O"
 
245
cc_64_cflags="-O"
 
246
 
 
247
SPEED_CYCLECOUNTER_OBJ=
 
248
cyclecounter_size=2
 
249
 
 
250
AC_SUBST(__GMP_HAVE_HOST_CPU_FAMILY_power,  0)
 
251
AC_SUBST(__GMP_HAVE_HOST_CPU_FAMILY_powerpc,0)
 
252
 
 
253
case $host in
 
254
 
 
255
  a29k*-*-*)
 
256
    path="a29k"
 
257
    ;;
 
258
 
 
259
 
 
260
  alpha*-*-*)
 
261
    path="alpha"
 
262
    extra_functions="cntlz"
 
263
    case $host in
 
264
      alphaev5*-*-* | alphapca56*-*-*) path="alpha/ev5 alpha" ;;
 
265
      alphaev6*-*-*)                   path="alpha/ev6 alpha/ev5 alpha" ;;
 
266
    esac
 
267
 
 
268
    SPEED_CYCLECOUNTER_OBJ=alpha.lo
 
269
    cyclecounter_size=1
 
270
 
 
271
    flavour=`echo $host_cpu | sed 's/^alpha//g'`
 
272
    case "$flavour" in
 
273
      # compilers don't seem to understand `ev67' and such.
 
274
      ev6? | ev7*)  flavour=ev6 ;;
 
275
      ev* | pca*) ;;
 
276
      *) flavour=ev4 ;;
 
277
    esac
 
278
 
 
279
    # FIXME: Maybe a feature test should find out whether -Wa,arch is
 
280
    # necessary.
 
281
    if test -n "$flavour"; then
 
282
      gcc_cflags_optlist="cpu arch"
 
283
      gcc_cflags_cpu="-march=$flavour"
 
284
      gcc_cflags_arch="-Wa,-arch,$flavour -Wa,-m$flavour"
 
285
    fi
 
286
 
 
287
    case $host in
 
288
      *-cray-unicos*)
 
289
        # FIXME: Is GCC available for these systems? Hopefully it doesn't
 
290
        # hurt to check for it anyway.
 
291
        cc_cflags="-O"          # no -g, it silently disables all optimizations
 
292
        GMP_INCLUDE_MPN(alpha/unicos.m4)
 
293
        # Don't perform any assembly syntax tests on this beast.
 
294
        gmp_asm_syntax_testing=no
 
295
        # tune/alpha.asm assumes int==4bytes but unicos uses int=8bytes
 
296
        SPEED_CYCLECOUNTER_OBJ=
 
297
        ;;
 
298
      *-*-osf*)
 
299
        cc_cflags_optlist="cpu"
 
300
        cc_cflags="-arch $flavour -tune $flavour"
 
301
        GMP_INCLUDE_MPN(alpha/default.m4)
 
302
        ;;
 
303
      *)
 
304
        GMP_INCLUDE_MPN(alpha/default.m4)
 
305
        ;;
 
306
    esac
 
307
    ;;
 
308
 
 
309
 
 
310
  # Cray vector machines.
 
311
  # This must come after alpha* so that we can recognize present and future
 
312
  # vector processors with a wildcard.
 
313
  *-cray-unicos*)
 
314
    gmp_asm_syntax_testing=no
 
315
    cclist="cc"
 
316
    cc_cflags="-O3 -htask0 -Wa,-B"
 
317
    path="cray"
 
318
    ;;
 
319
 
 
320
 
 
321
  arm*-*-*)
 
322
    path="arm"
 
323
    gcc_cflags="$gcc_cflags $fomit_frame_pointer"
 
324
    gcc_testlist="gcc-arm-umodsi"
 
325
    extra_functions="udiv"
 
326
    GMP_INCLUDE_MPN(arm/arm-defs.m4)
 
327
    ;;
 
328
 
 
329
 
 
330
  clipper*-*-*)
 
331
    path="clipper"
 
332
    ;;
 
333
 
 
334
 
 
335
  # Fujitsu
 
336
  [f30[01]-fujitsu-sysv*])
 
337
    cclist="gcc vcc"
 
338
    # FIXME: flags for vcc?
 
339
    vcc_cflags="-g"
 
340
    path="fujitsu"
 
341
    ;;
 
342
 
 
343
 
 
344
  hppa*-*-*)
 
345
    # HP cc is K&R by default, but AM_C_PROTOTYPES will add "-Ae", or "-Aa
 
346
    # -D_HPUX_SOURCE", to put it into ansi mode, if possible.
 
347
 
 
348
    # default to pa7100
 
349
    gcc_cflags="-g -O2"
 
350
    gcc_cflags_optlist="arch"
 
351
    gcc_cflags_arch="-mpa-risc-1-1"
 
352
    cc_cflags="+DA1.1 +O2"
 
353
    path="hppa/hppa1_1/pa7100 hppa/hppa1_1 hppa"
 
354
    extra_functions="udiv_qrnnd"
 
355
 
 
356
    SPEED_CYCLECOUNTER_OBJ=hppa.lo
 
357
    cyclecounter_size=1
 
358
 
 
359
    case $host in
 
360
      hppa1.0*-*-*)
 
361
        # override back to plain 1.0
 
362
        gcc_cflags_optlist=
 
363
        cc_cflags="+O2"
 
364
        path="hppa"
 
365
        ;;
 
366
      hppa7000*-*-*)
 
367
        path="hppa/hppa1_1 hppa"
 
368
        ;;
 
369
 
 
370
      hppa2.0*-*-*)
 
371
        abilist="2.0n 1.0"
 
372
 
 
373
        # FIXME: It's suspected that an assembler feature test might be
 
374
        # necessary before -mpa-risc-2-0 can be enabled, since it's not
 
375
        # clear (as of gcc 2.95.2) whether that option always gives an
 
376
        # explicit ".level 2.0" or whatever to the assembler.  In any case,
 
377
        # under gcc 2.95.2 it only enables a few extra floating point insns,
 
378
        # so it's not very important.
 
379
        #
 
380
        # gmp_cflags_arch="-mpa-risc-2-0 -mpa-risc-1-1"
 
381
 
 
382
        # FIXME: path should be "hppa/hppa2_0 hppa/hppa1_1 hppa"
 
383
        path="hppa/hppa2_0 hppa/hppa1_1/pa7100 hppa/hppa1_1 hppa"
 
384
 
 
385
        # no gcc support for long long in 2.0n
 
386
        cclist_20n="cc"
 
387
        # +O2 to cc triggers bug in mpz/powm.c (cvs version 1.4)
 
388
        cc_20n_cflags="+DA2.0 +e +O3"
 
389
        cc_20n_testlist="hpc-hppa-2-0"
 
390
        path_20n="pa64"
 
391
        limb_20n=longlong
 
392
        extra_functions_20n="umul_ppmm udiv_qrnnd"
 
393
        SPEED_CYCLECOUNTER_OBJ_20n=hppa2.lo
 
394
        cyclecounter_size_20n=2
 
395
 
 
396
        # ABI=2.0w is available for hppa2.0w and hppa2.0, but not for hppa2.0n.
 
397
        case $host in
 
398
        hppa2.0n-*-*) ;;
 
399
        *)
 
400
          # HPUX 11 or up is required to run 2.0w.  Not sure about other
 
401
          # systems (GNU/Linux for instance), but lets assume they're ok.
 
402
          case $host in
 
403
          [*-*-hpux1[1-9]*]) abilist="2.0w $abilist" ;;
 
404
          *-*-hpux*)                                 ;;
 
405
          *)                 abilist="2.0w $abilist" ;;
 
406
          esac
 
407
 
 
408
          # gcc support for 2.0w is in progress
 
409
          cclist_20w="cc"
 
410
          cc_20w_cflags="+DD64 +O3"
 
411
          cc_20w_testlist="hpc-hppa-2-0"
 
412
          path_20w="pa64w"
 
413
          extra_functions_20w="umul_ppmm udiv_qrnnd"
 
414
          SPEED_CYCLECOUNTER_OBJ_20w=hppa2w.lo
 
415
          cyclecounter_size_20w=2
 
416
          ;;
 
417
        esac
 
418
        ;;
 
419
    esac
 
420
    ;;
 
421
 
 
422
 
 
423
  i960*-*-*)
 
424
    path="i960"
 
425
    ;;
 
426
 
 
427
 
 
428
  ia64*-*-*)
 
429
    path="ia64"
 
430
    GMP_INCLUDE_MPN(ia64/default.m4)
 
431
    SPEED_CYCLECOUNTER_OBJ=ia64.lo
 
432
    ;;
 
433
 
 
434
 
 
435
  # Motorola 68k
 
436
  #
 
437
  m68*-*-*)
 
438
    GMP_INCLUDE_MPN(m68k/m68k-defs.m4)
 
439
    gcc_cflags="-g $fomit_frame_pointer"
 
440
    gcc_cflags_optlist="optimize arch"
 
441
    gcc_cflags_optimize="-O2"   # munged below on gcc 2.95.x
 
442
 
 
443
    # gcc 2.7.2 doesn't know -m68060 or -mcpu32, so let them fall back
 
444
    # appropriately.
 
445
    # FIXME: Maybe "-m68020 -mnobitfield" would suit cpu32 on 2.7.2.
 
446
    #
 
447
    case $host in
 
448
    m68020-*-*)  gcc_cflags_arch="-m68020" ;;
 
449
    m68030-*-*)  gcc_cflags_arch="-m68030" ;;
 
450
    m68040-*-*)  gcc_cflags_arch="-m68040" ;;
 
451
    m68060-*-*)  gcc_cflags_arch="-m68060 -m68040" ;;
 
452
    m68360-*-*)  gcc_cflags_arch="-mcpu32 -m68000" ;;
 
453
    *)           gcc_cflags_arch="-m68000" ;;
 
454
    esac
 
455
 
 
456
    # FIXME: m68k/mc68020 looks like it's ok for cpu32, but this wants to be
 
457
    # tested.  Will need to introduce an m68k/cpu32 if m68k/mc62020 ever uses
 
458
    # the bitfield instructions.
 
459
    case $host in
 
460
    [m680[2346]0-*-* | m68360-*-*])  path="m68k/mc68020 m68k"
 
461
                                     extra_functions="udiv umul" ;;
 
462
    *)                               path="m68k" ;; 
 
463
    esac
 
464
    ;;
 
465
 
 
466
 
 
467
  # Motorola 88k
 
468
  m88k*-*-*)
 
469
    path="m88k"
 
470
    ;;
 
471
  m88110*-*-*)
 
472
    # FIXME: Use `-O2'?
 
473
    gcc_cflags="-g -O -m88110"
 
474
    path="m88k/mc88110 m88k"
 
475
    ;;
 
476
 
 
477
 
 
478
  # National Semiconductor 32k
 
479
  ns32k*-*-*)
 
480
    path="ns32k"
 
481
    ;;
 
482
 
 
483
 
 
484
  # IRIX 5 and earlier can only run 32-bit o32.
 
485
  #
 
486
  # IRIX 6 and up can run n32 or 64, and GMP uses a 64-bit limb on both.  It
 
487
  # could run the mips2 code in n32 with a 32-bit limb, which we could
 
488
  # perhaps call 32, but since that would just create a slower library, we
 
489
  # don't give that option.
 
490
  #
 
491
  # Linux kernel 2.2.13 arch/mips/kernel/irixelf.c has a comment about not
 
492
  # supporting n32 or 64.
 
493
  #
 
494
  # We here use ldflags for passing options with libtool to the compiler
 
495
  # when generating the shared library.
 
496
 
 
497
  [mips*-*-irix[6789]*])
 
498
    abilist="n32 64"
 
499
 
 
500
    # let the $found_compiler test below know that the cpu is recognised
 
501
    path=dummy
 
502
 
 
503
    cclist_n32="gcc cc"
 
504
    gcc_n32_cflags="-g -O2 -mabi=n32"
 
505
    gcc_n32_ldflags="-Wc,-mabi=n32"
 
506
    cc_n32_cflags="-O2 -n32"            # no -g, it disables all optimizations
 
507
    cc_n32_ldflags="-Wc,-n32"
 
508
    limb_n32=longlong
 
509
    path_n32="mips3"
 
510
 
 
511
    cclist_64="gcc cc"
 
512
    gcc_64_cflags="-g -O2 -mabi=64"
 
513
    gcc_64_ldflags="-Wc,-mabi=64"
 
514
    cc_64_cflags="-O2 -64"              # no -g, it disables all optimizations
 
515
    cc_64_ldflags="-Wc,-64"
 
516
    path_64="mips3"
 
517
 
 
518
    GMP_INCLUDE_MPN(mips3/mips.m4)
 
519
    ;;
 
520
 
 
521
  mips*-*-*)
 
522
    path="mips2"
 
523
    ;;
 
524
 
 
525
 
 
526
  # Darwin (powerpc-apple-darwin1.3) has gcc installed as cc.
 
527
  #
 
528
  # The darwin assembler doesn't accept "-mppc", so gcc_cflags_asm is
 
529
  # optional.  The right flag would be "-arch ppc" or some such, but that's
 
530
  # already the default.
 
531
  #
 
532
  # The darwin pre-compiling preprocessor is disabled with -no-cpp-precomp
 
533
  # since it doesn't like "__attribute__ ((mode (SI)))" etc in gmp-impl.h,
 
534
  # and so always ends up running the plain preprocessor anyway.  This could
 
535
  # be done in CPPFLAGS rather than CFLAGS, but there's not many places
 
536
  # preprocessing is done separately, and this is only a speedup, the normal
 
537
  # preprocessor gets run if there's any problems.
 
538
  #
 
539
  powerpc*-*-*)
 
540
    AC_DEFINE(HAVE_HOST_CPU_FAMILY_powerpc)
 
541
    __GMP_HAVE_HOST_CPU_FAMILY_powerpc=1
 
542
    cclist="gcc cc"
 
543
    cc_cflags="-g -O2"
 
544
    gcc_cflags="-g -O2 -mpowerpc"
 
545
    gcc_cflags_optlist="asm precomp"
 
546
    gcc_cflags_asm="-Wa,-mppc"
 
547
    gcc_cflags_precomp="-no-cpp-precomp"
 
548
    path="powerpc32"
 
549
    extra_functions="umul"
 
550
    case $host in
 
551
      *-*-aix*) cclist="gcc xlc cc"
 
552
                xlc_cflags="-g -O2 -qarch=ppc -qmaxmem=20000" ;;
 
553
    esac
 
554
 
 
555
    case $host in
 
556
      powerpc64*-*-*)
 
557
        # CPU type powerpc64 forces to a 64-bit limb
 
558
        case $host in
 
559
          powerpc64-*-*) abilist="32L" ;;
 
560
          *)             abilist="32L 32" ;;
 
561
        esac
 
562
        cclist_32L="gcc"
 
563
        gcc_32L_cflags="-g -O2 -mpowerpc64"
 
564
        limb_32L=longlong
 
565
        path_32L="powerpc64"
 
566
 
 
567
        # On AIX a true 64-bit ABI is available.
 
568
        case $host in
 
569
          *-*-aix*)
 
570
            # Need -Wc to pass object type flags through to the linker.
 
571
            abilist="aix64 $abilist"
 
572
            cclist_aix64="gcc xlc"
 
573
            gcc_aix64_cflags="-g -O2 -maix64 -mpowerpc64"
 
574
            gcc_aix64_ldflags="-Wc,-maix64"
 
575
            xlc_aix64_cflags="-g -O2 -q64 -qtune=pwr3 -qmaxmem=20000"
 
576
            xlc_aix64_ldflags="-Wc,-q64"
 
577
            # Must indicate object type to ar and nm
 
578
            ar_aix64_flags="-X64"
 
579
            nm_aix64_flags="-X64"
 
580
            path_aix64="powerpc64"
 
581
            ;;
 
582
        esac
 
583
        ;;
 
584
    esac
 
585
    ;;
 
586
 
 
587
 
 
588
  # POWER
 
589
  [power-*-* | power[12]-*-* | power2sc-*-*])
 
590
    AC_DEFINE(HAVE_HOST_CPU_FAMILY_power)
 
591
    __GMP_HAVE_HOST_CPU_FAMILY_power=1
 
592
    cclist="gcc"
 
593
    extra_functions="udiv_w_sdiv"
 
594
    path="power"
 
595
 
 
596
    gcc_cflags_optlist="cpu"
 
597
    case $host in
 
598
      power-*-*)    gcc_cflags_cpu="-march=power -mpower" ;;
 
599
      power1-*-*)   gcc_cflags_cpu="-march=rios1 -mpower" ;;
 
600
      power2-*-*)   gcc_cflags_cpu="-march=rios2 -mpower" ;;
 
601
      power2sc-*-*) gcc_cflags_cpu="-march=rsc   -mpower" ;;
 
602
    esac
 
603
    case $host in
 
604
    *-*-aix*)
 
605
      cclist="gcc xlc"
 
606
      xlc_cflags="-g -O2 -qarch=pwr -qmaxmem=20000"
 
607
      ;;
 
608
    esac
 
609
    ;;
 
610
 
 
611
 
 
612
  # FIXME: ppc601 isn't accepted by config.sub.
 
613
  ppc601-*-*)
 
614
    path="power powerpc32"
 
615
    ;;
 
616
 
 
617
 
 
618
  pyramid-*-*)
 
619
    path="pyr"
 
620
    ;;
 
621
 
 
622
 
 
623
  # IBM s/370 and similar
 
624
  [s3[6-9]0*-*-*])
 
625
    gcc_cflags="-g -O2 $fomit_frame_pointer"
 
626
    path="s390"
 
627
    extra_functions="udiv_w_sdiv"
 
628
    ;;
 
629
 
 
630
 
 
631
  sh-*-*)   path="sh" ;;
 
632
  sh2-*-*)  path="sh/sh2 sh" ;;
 
633
 
 
634
 
 
635
  *sparc*-*-*)
 
636
    # For cc and acc, -g disables -O, so it's not used
 
637
    cclist="gcc acc cc"
 
638
    path="sparc32"
 
639
    gcc_cflags="-g -O2"
 
640
    gcc_cflags_optlist="cpu"
 
641
    gcc_cflags_cpu=
 
642
    acc_cflags="-O2"
 
643
    cc_cflags="-O2"
 
644
 
 
645
    # FIXME: This should be selected according to the CPU
 
646
    if test x${floating_point} = xno
 
647
    then extra_functions="udiv_nfp"
 
648
    else extra_functions="udiv_fp"
 
649
    fi
 
650
 
 
651
    case $host in
 
652
      sparcv8*-*-* | supersparc*-*-* | microsparc*-*-*)
 
653
        gcc_cflags_cpu="-march=v8 -mv8"
 
654
        acc_cflags="-O2 -cg92"
 
655
        path="sparc32/v8 sparc32"
 
656
 
 
657
        case $host in
 
658
          *-*-solaris2.*)  cc_cflags="-xtarget=native -xarch=v8 -xO4" ;;
 
659
        esac
 
660
        case $host in
 
661
          supersparc*-*-*) path="sparc32/v8/supersparc sparc32/v8 sparc32"
 
662
                           extra_functions="udiv" ;;
 
663
        esac
 
664
        ;;
 
665
 
 
666
      # sparc64-*-linux-gnu is a misnomer, since there's no support for any
 
667
      # 64-bit operations in user mode.  We assume that a future release
 
668
      # will have some 64-bit support and that the gcc options will be the
 
669
      # same as on solaris.
 
670
      #
 
671
      # cc -xarch actually controls the ABI, hence it must be v8 for 32-bit,
 
672
      # even though the chip is v9.
 
673
      #
 
674
      sparcv9*-*-* | ultrasparc*-*-* | sparc64-*-*)
 
675
        path="sparc32/v9 sparc32/v8 sparc32"
 
676
        extra_functions="udiv_fp"
 
677
 
 
678
        SPEED_CYCLECOUNTER_OBJ=sparcv9.lo
 
679
 
 
680
        gcc_cflags="-g -O2 -Wa,-xarch=v8plus"
 
681
        gcc_cflags_cpu="-march=ultrasparc -march=v9 -march=v8 -mv8"
 
682
 
 
683
        cc_cflags="-xtarget=native -xarch=v8 -xO4"
 
684
 
 
685
        case $host in
 
686
          [*-*-solaris2.[7-9]])
 
687
            # solaris prior to 2.6 doesn't save registers properly, so the
 
688
            # 64-bit ABI is only available for 2.7 up
 
689
            abilist="64 32"
 
690
            path_64="sparc64"
 
691
            cclist_64="gcc cc"
 
692
            gcc_64_cflags="-g -O2 -m64 -mptr64 -Wa,-xarch=v9 -march=v9"
 
693
            cc_64_cflags="-xtarget=native -xarch=v9 -xO4"
 
694
            ;;
 
695
        esac
 
696
      ;;
 
697
    esac
 
698
    ;;
 
699
 
 
700
 
 
701
  # VAX
 
702
  vax*-*-*)
 
703
    # Currently (version 3.0) gcc on vax always uses a frame pointer
 
704
    # (config/vax/vax.h FRAME_POINTER_REQUIRED=1), so -fomit-frame-pointer
 
705
    # will be ignored.
 
706
    #
 
707
    gcc_cflags="-g -O2 $fomit_frame_pointer"
 
708
    path="vax"
 
709
    extra_functions="udiv_w_sdiv"
 
710
    ;;
 
711
 
 
712
 
 
713
  # AMD and Intel x86 configurations
 
714
  X86_PATTERN)
 
715
    AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86)
 
716
    # Rumour has it gcc -O2 used to give worse register allocation than just
 
717
    # -O, but lets assume that's no longer true.
 
718
    gcc_cflags="-g -O2 $fomit_frame_pointer"
 
719
    GMP_INCLUDE_MPN(x86/x86-defs.m4)
 
720
    extra_functions="udiv umul"
 
721
    CALLING_CONVENTIONS_OBJS='x86call.lo x86check$U.lo'
 
722
 
 
723
    # Availability of rdtsc is checked at run-time.
 
724
    SPEED_CYCLECOUNTER_OBJ=pentium.lo
 
725
 
 
726
    # gcc 2.7.2 only knows i386 and i486, using -m386 or -m486.  These
 
727
    # represent -march= since -m486 doesn't generate 486 specific insns.  The
 
728
    # -march= and -march= options will fail, leaving just -m486.
 
729
    #
 
730
    # gcc 2.95.2 adds k6, pentium and pentiumpro, and allows -march= and
 
731
    # -march=.
 
732
    #
 
733
    # gcc 3.0 adds athlon.
 
734
    #
 
735
    # gcc 3.1 adds pentium4.
 
736
 
 
737
    # Defaults for anything not otherwise mentioned.
 
738
    path="x86"
 
739
    gcc_cflags_optlist="cpu arch"
 
740
    gcc_cflags_cpu="-march=i486 -m486"
 
741
    gcc_cflags_arch="-march=i486"
 
742
 
 
743
    case $host in
 
744
      i386*-*-*)
 
745
        # Because i386 means generic x86, -march=i486 is used since that
 
746
        # should better suit newer processors.
 
747
        # FIXME: How would a user ask for an actual 80386? Currently only by
 
748
        # using CFLAGS="-march=386" or whatever.
 
749
        gcc_cflags_cpu="-march=i486 -m486"
 
750
        gcc_cflags_arch="-march=i386"
 
751
        ;;
 
752
      i586*-*-* | pentium-*-* | pentiummmx-*-*)
 
753
        gcc_cflags_cpu="-march=pentium -m486"
 
754
        gcc_cflags_arch="-march=pentium"
 
755
        ;;
 
756
      [i686*-*-* | pentiumpro-*-* | pentium[23]-*-*])
 
757
        gcc_cflags_cpu="-march=pentiumpro -march=i486 -m486"
 
758
        gcc_cflags_arch="-march=pentiumpro -march=i486"
 
759
        ;;
 
760
      k6*-*-*)
 
761
        gcc_cflags_cpu="-march=k6 -march=i486 -m486"
 
762
        gcc_cflags_arch="-march=k6 -march=i486"
 
763
        ;;
 
764
      athlon-*-*)
 
765
        # Athlon instruction costs are close to P6 (3 cycle load latency,
 
766
        # 4-6 cycle mul, 40 cycle div, pairable adc, etc) so if gcc doesn't
 
767
        # know athlon (eg. 2.95.2 doesn't) then fall back on pentiumpro.
 
768
        gcc_cflags_cpu="-march=athlon -march=pentiumpro -march=i486 -m486"
 
769
        gcc_cflags_arch="-march=athlon -march=pentiumpro -march=i486"
 
770
        ;;
 
771
      pentium4-*-*)
 
772
        # pentium4 is known to gcc 3.1 and up, not sure what cpu choice
 
773
        # would best suit previous versions, pentiumpro will get us cmov
 
774
        # from gcc 2.95.4 up, otherwise let's just try i486.
 
775
        gcc_cflags_cpu="-march=pentium4 -march=pentiumpro -march=i486 -m486"
 
776
        gcc_cflags_arch="-march=pentium4 -march=pentiumpro -march=i486"
 
777
        ;;
 
778
    esac
 
779
 
 
780
    case $host in
 
781
      i486*-*-*)                  path="x86/i486 x86" ;;
 
782
      i586*-*-* | pentium-*-*)    path="x86/pentium x86" ;;
 
783
      pentiummmx-*-*)             path="x86/pentium/mmx x86/pentium x86" ;;
 
784
      i686*-*-* | pentiumpro-*-*) path="x86/p6 x86" ;;
 
785
      pentium2-*-*)   path="x86/p6/mmx x86/p6 x86" ;;
 
786
      pentium3-*-*)   path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86";;
 
787
      [k6[23]*-*-*])  path="x86/k6/k62mmx x86/k6/mmx x86/k6 x86" ;;
 
788
      k6*-*-*)        path="x86/k6/mmx x86/k6 x86" ;;
 
789
      athlon-*-*)     path="x86/k7/mmx x86/k7 x86" ;;
 
790
      pentium4-*-*)   path="x86/pentium4/sse2 x86/pentium4/mmx x86/pentium4 x86" ;;
 
791
    esac
 
792
    ;;
 
793
 
 
794
 
 
795
  # FIXME: z8kx won't get through config.sub.  Could make 16 versus 32 bit
 
796
  # limb an ABI option perhaps.
 
797
  z8kx*-*-*)
 
798
    path="z8000x"
 
799
    extra_functions="udiv_w_sdiv"
 
800
    ;;
 
801
  z8k*-*-*)
 
802
    path="z8000"
 
803
    extra_functions="udiv_w_sdiv"
 
804
    ;;
 
805
 
 
806
 
 
807
  # Special CPU "none" selects generic C.  -DNO_ASM is used to disable gcc
 
808
  # asm blocks in longlong.h (since they're driven by cpp pre-defined
 
809
  # symbols like __alpha rather than the configured $host_cpu).
 
810
  #
 
811
  none-*-*)
 
812
    abilist="long longlong"
 
813
    cclist_long=$cclist
 
814
    gcc_long_cflags=$gcc_cflags
 
815
    gcc_long_cppflags="-DNO_ASM"
 
816
    cc_long_cflags=$cc_cflags
 
817
    cclist_longlong=$cclist
 
818
    gcc_longlong_cflags=$gcc_cflags
 
819
    gcc_longlong_cppflags="-DNO_ASM"
 
820
    cc_longlong_cflags=$cc_cflags
 
821
    limb_longlong=longlong
 
822
    ;;
 
823
 
 
824
esac
 
825
 
 
826
 
 
827
CFLAGS_or_unset=${CFLAGS-'(unset)'}
 
828
CPPFLAGS_or_unset=${CPPFLAGS-'(unset)'}
 
829
 
 
830
cat >&AC_FD_CC <<EOF
 
831
configure:__line__: User:
 
832
ABI=$ABI
 
833
CC=$CC
 
834
CFLAGS=$CFLAGS_or_unset
 
835
CPPFLAGS=$CPPFLAGS_or_unset
 
836
MPN_PATH=$MPN_PATH
 
837
configure:__line__: GMP:
 
838
abilist=$abilist
 
839
cclist=$cclist
 
840
EOF
 
841
 
 
842
 
 
843
test_CFLAGS=${CFLAGS+set}
 
844
test_CPPFLAGS=${CPPFLAGS+set}
 
845
 
 
846
for abi in $abilist; do
 
847
  abi_last="$abi"
 
848
done
 
849
 
 
850
# If the user specifies an ABI then it must be in $abilist, after that
 
851
# $abilist is restricted to just that choice.
 
852
#
 
853
if test -n "$ABI"; then
 
854
  found=no
 
855
  for abi in $abilist; do
 
856
    if test $abi = "$ABI"; then found=yes; break; fi
 
857
  done
 
858
  if test $found = no; then
 
859
    AC_MSG_ERROR([ABI=$ABI is not among the following valid choices: $abilist])
 
860
  fi
 
861
  abilist="$ABI"
 
862
fi
 
863
 
 
864
found_compiler=no
 
865
 
 
866
for abi in $abilist; do
 
867
 
 
868
  # Suppose abilist="64 32", then for abi=64, will have abi1="_64" and
 
869
  # abi2="_64".  For abi=32, will have abi1="_32" and abi2="".  This is how
 
870
  # $gcc_cflags becomes a fallback for $gcc_32_cflags (the last in the
 
871
  # abilist), but there's no fallback for $gcc_64_cflags.
 
872
  #
 
873
  abi1=[`echo _$abi | sed 's/[.]//g'`]
 
874
  if test $abi = $abi_last; then abi2=; else abi2="$abi1"; fi
 
875
 
 
876
  # Compiler choices under this ABI
 
877
                              eval cclist_chosen=\"\$cclist$abi1\"
 
878
  test -n "$cclist_chosen" || eval cclist_chosen=\"\$cclist$abi2\"
 
879
 
 
880
  # If there's a user specified $CC then don't use a list for
 
881
  # $cclist_chosen, just a single value for $ccbase.
 
882
  #
 
883
  if test -n "$CC"; then
 
884
 
 
885
    # The first word of $CC, stripped of any directory.  For instance
 
886
    # CC="/usr/local/bin/gcc -pipe" will give "gcc".
 
887
    #
 
888
    for ccbase in $CC; do break; done
 
889
    ccbase=`echo $ccbase | sed 's:.*/::'`
 
890
 
 
891
    # If this $ccbase is in $cclist_chosen then it's a compiler we know and
 
892
    # we can do flags defaulting with it.  If not, then $cclist_chosen is
 
893
    # set to "unrecognised" so no default flags are used.
 
894
    #
 
895
    # "unrecognised" is used to avoid bad effects with eval if $ccbase has
 
896
    # non-symbol characters.  For instance ccbase=my+cc would end up with
 
897
    # something like cflags="$my+cc_cflags" which would give
 
898
    # cflags="+cc_cflags" rather than the intended empty string for an
 
899
    # unknown compiler.
 
900
    #
 
901
    found=unrecognised
 
902
    for i in $cclist_chosen; do
 
903
      if test "$ccbase" = $i; then
 
904
        found=$ccbase
 
905
        break
 
906
      fi
 
907
    done
 
908
    cclist_chosen=$found
 
909
  fi  
 
910
 
 
911
  for ccbase in $cclist_chosen; do
 
912
 
 
913
    # When cross compiling, look for a compiler with the $host_alias as a
 
914
    # prefix, the same way that AC_CHECK_TOOL does.  But don't do this to a
 
915
    # user-selected $CC.
 
916
    #
 
917
    # $cross_compiling will be yes/no/maybe at this point.  Do the host
 
918
    # prefixing for "maybe" as well as "yes".
 
919
    #
 
920
    if test "$cross_compiling" != no && test -z "$CC"; then
 
921
      cross_compiling_prefix="${host_alias}-"
 
922
    fi
 
923
 
 
924
    for ccprefix in $cross_compiling_prefix ""; do
 
925
 
 
926
      cc="$CC"
 
927
      test -n "$cc" || cc="$ccprefix$ccbase"
 
928
 
 
929
      # If the compiler is gcc but installed under another name, then change
 
930
      # $ccbase so as to use the flags we know for gcc.  This helps for
 
931
      # instance when specifying CC=gcc272 on Debian GNU/Linux, or the
 
932
      # native cc which is really gcc on NeXT or MacOS-X.
 
933
      #
 
934
      # FIXME: There's a slight misfeature here.  If cc is actually gcc but
 
935
      # gcc is not a known compiler under this $abi then we'll end up
 
936
      # testing it with no flags and it'll work, but chances are it won't be
 
937
      # in the right mode for the ABI we desire.  Let's quietly hope this
 
938
      # doesn't happen.
 
939
      #
 
940
      if test $ccbase != gcc; then
 
941
        GMP_PROG_CC_IS_GNU($cc,ccbase=gcc)
 
942
      fi
 
943
 
 
944
      # Similarly if the compiler is IBM xlc but invoked as cc or whatever
 
945
      # then change $ccbase and make the default xlc flags available.
 
946
      if test $ccbase != xlc; then
 
947
        GMP_PROG_CC_IS_XLC($cc,ccbase=xlc)
 
948
      fi
 
949
 
 
950
      # Any user CFLAGS, even an empty string, takes precendence
 
951
                           eval cflags=\"\$${ccbase}${abi1}_cflags\"
 
952
      test -n "$cflags" || eval cflags=\"\$${ccbase}${abi2}_cflags\"
 
953
      if test "$test_CFLAGS" = set; then cflags=$CFLAGS; fi
 
954
 
 
955
      # Any user CPPFLAGS, even an empty string, takes precendence
 
956
                             eval cppflags=\"\$${ccbase}${abi1}_cppflags\"
 
957
      test -n "$cppflags" || eval cppflags=\"\$${ccbase}${abi2}_cppflags\"
 
958
      if test "$test_CPPFLAGS" = set; then cppflags=$CPPFLAGS; fi
 
959
 
 
960
      # --enable-profiling adds -p/-pg even to user-specified CFLAGS.
 
961
      # This is convenient, but it's perhaps a bit naughty to modify user
 
962
      # CFLAGS.
 
963
      case "$enable_profiling" in
 
964
      prof)  cflags="$cflags -p" ;;
 
965
      gprof) cflags="$cflags -pg" ;;
 
966
      esac
 
967
 
 
968
      GMP_PROG_CC_WORKS($cc $cflags $cppflags,,continue)
 
969
 
 
970
      # The tests to perform on this $cc, if any
 
971
                             eval testlist=\"\$${ccbase}${abi1}_testlist\"
 
972
      test -n "$testlist" || eval testlist=\"\$${ccbase}${abi2}_testlist\"
 
973
 
 
974
      testlist_pass=yes
 
975
      for tst in $testlist; do
 
976
        case $tst in
 
977
        hpc-hppa-2-0)   GMP_HPC_HPPA_2_0($cc,,testlist_pass=no) ;;
 
978
        gcc-arm-umodsi) GMP_GCC_ARM_UMODSI($cc,,testlist_pass=no) ;;
 
979
        esac
 
980
        if test $testlist_pass = no; then break; fi
 
981
      done
 
982
 
 
983
      if test $testlist_pass = yes; then
 
984
        found_compiler=yes
 
985
        break
 
986
      fi
 
987
    done
 
988
 
 
989
    if test $found_compiler = yes; then break; fi
 
990
  done
 
991
 
 
992
  if test $found_compiler = yes; then break; fi
 
993
done
 
994
 
 
995
 
 
996
# If we recognised the CPU, as indicated by $path being set, then insist
 
997
# that we have a working compiler, either from our $cclist choices or from
 
998
# $CC.  We can't let AC_PROG_CC look around for a compiler because it might
 
999
# find one that we've rejected (for not supporting the modes our asm code
 
1000
# demands, etc).
 
1001
#
 
1002
# If we didn't recognise the CPU (and this includes host_cpu=none), then
 
1003
# fall through and let AC_PROG_CC look around for a compiler too.  This is
 
1004
# mostly in the interests of following a standard autoconf setup, after all
 
1005
# we've already tested cc and gcc adequately (hopefully).  As of autoconf
 
1006
# 2.50 the only thing AC_PROG_CC really adds is a check for "cl" (Microsoft
 
1007
# C on MS-DOS systems).
 
1008
#
 
1009
if test $found_compiler = no && test -n "$path"; then
 
1010
  AC_MSG_ERROR([could not find a working compiler])
 
1011
fi
 
1012
 
 
1013
 
 
1014
if test $found_compiler = yes; then
 
1015
 
 
1016
  # If we're creating CFLAGS, then look for optional additions.  If the user
 
1017
  # set CFLAGS then leave it alone.
 
1018
  #
 
1019
  if test "$test_CFLAGS" != set; then
 
1020
                          eval optlist=\"\$${ccbase}${abi1}_cflags_optlist\"
 
1021
    test -n "$optlist" || eval optlist=\"\$${ccbase}${abi2}_cflags_optlist\"
 
1022
 
 
1023
    for opt in $optlist; do
 
1024
                             eval optflags=\"\$${ccbase}${abi1}_cflags_${opt}\"
 
1025
      test -n "$optflags" || eval optflags=\"\$${ccbase}${abi2}_cflags_${opt}\"
 
1026
 
 
1027
      for flag in $optflags; do
 
1028
 
 
1029
        case $flag in
 
1030
          -march=pentiumpro)
 
1031
            # tickles stack slot bugs on some gcc, exclude as necessary
 
1032
            GMP_GCC_MARCH_PENTIUMPRO($cc,,continue)
 
1033
            ;;
 
1034
          -O*)
 
1035
            # ease back to just -O on m68k gcc 2.95.x
 
1036
            GMP_GCC_M68K_OPTIMIZE($ccbase,$cc,flag)
 
1037
            ;;
 
1038
          -no-cpp-precomp)
 
1039
            # special check, avoiding a warning
 
1040
            GMP_GCC_NO_CPP_PRECOMP($ccbase,$cc,$cflags,
 
1041
                                   [cflags="$cflags $flag"
 
1042
                                   break],
 
1043
                                   [continue])
 
1044
            ;;
 
1045
        esac
 
1046
 
 
1047
        GMP_PROG_CC_WORKS($cc $cflags $cppflags $flag,
 
1048
          [cflags="$cflags $flag"
 
1049
          break])
 
1050
      done
 
1051
    done
 
1052
  fi
 
1053
 
 
1054
  ABI="$abi"
 
1055
  CC="$cc"
 
1056
  CFLAGS="$cflags"
 
1057
  CPPFLAGS="$cppflags"
 
1058
 
 
1059
 
 
1060
  # Could easily have this in config.h too, if desired.
 
1061
  ABI_nodots=`echo $ABI | sed 's/\./_/'`
 
1062
  GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_ABI_$ABI_nodots')", POST)
 
1063
 
 
1064
 
 
1065
  # GMP_LDFLAGS substitution, selected according to ABI.
 
1066
  # These are needed on libgmp.la and libmp.la, but currently not on
 
1067
  # convenience libraries like tune/libspeed.la or mpz/libmpz.la.
 
1068
  #
 
1069
                            eval GMP_LDFLAGS=\"\$${ccbase}${abi1}_ldflags\"
 
1070
  test -n "$GMP_LDFLAGS" || eval GMP_LDFLAGS=\"\$${ccbase}${abi1}_ldflags\"
 
1071
  AC_SUBST(GMP_LDFLAGS)
 
1072
 
 
1073
  # extra_functions, selected according to ABI
 
1074
                    eval tmp=\"\$extra_functions$abi1\"
 
1075
  test -n "$tmp" || eval tmp=\"\$extra_functions$abi2\"
 
1076
  extra_functions="$tmp"
 
1077
 
 
1078
 
 
1079
  # Cycle counter, selected according to ABI.
 
1080
  #
 
1081
                    eval tmp=\"\$SPEED_CYCLECOUNTER_OBJ$abi1\"
 
1082
  test -n "$tmp" || eval tmp=\"\$SPEED_CYCLECOUNTER_OBJ$abi2\"
 
1083
  SPEED_CYCLECOUNTER_OBJ="$tmp"
 
1084
                    eval tmp=\"\$cyclecounter_size$abi1\"
 
1085
  test -n "$tmp" || eval tmp=\"\$cyclecounter_size$abi2\"
 
1086
  cyclecounter_size="$tmp"
 
1087
 
 
1088
  if test -n "$SPEED_CYCLECOUNTER_OBJ"; then
 
1089
    AC_DEFINE_UNQUOTED(HAVE_SPEED_CYCLECOUNTER, $cyclecounter_size,
 
1090
    [Tune directory speed_cyclecounter, undef=none, 1=32bits, 2=64bits)])
 
1091
  fi
 
1092
  AC_SUBST(SPEED_CYCLECOUNTER_OBJ)
 
1093
 
 
1094
 
 
1095
  # Calling conventions checking, selected according to ABI.
 
1096
  #
 
1097
                    eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi1\"
 
1098
  test -n "$tmp" || eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi2\"
 
1099
  CALLING_CONVENTIONS_OBJS="$tmp"
 
1100
 
 
1101
  if test -n "$CALLING_CONVENTIONS_OBJS"; then
 
1102
    AC_DEFINE(HAVE_CALLING_CONVENTIONS,1,
 
1103
    [Define if tests/libtests has calling conventions checking for the CPU])
 
1104
  fi
 
1105
  AC_SUBST(CALLING_CONVENTIONS_OBJS)
 
1106
 
 
1107
fi
 
1108
 
 
1109
 
 
1110
# If the user gave an MPN_PATH, use that verbatim, otherwise choose
 
1111
# according to the ABI and add "generic".
 
1112
#
 
1113
if test -n "$MPN_PATH"; then
 
1114
  path="$MPN_PATH"
 
1115
else
 
1116
                    eval tmp=\"\$path$abi1\"
 
1117
  test -n "$tmp" || eval tmp=\"\$path$abi2\"
 
1118
  path="$tmp generic"
 
1119
fi
 
1120
 
 
1121
 
 
1122
# Whether using a long long limb in this ABI.
 
1123
                          eval limb_chosen=\"\$limb$abi1\"
 
1124
test -n "$limb_chosen" || eval limb_chosen=\"\$limb$abi2\"
 
1125
case $limb_chosen in
 
1126
longlong) DEFN_LONG_LONG_LIMB="#define _LONG_LONG_LIMB 1"    ;;
 
1127
*)        DEFN_LONG_LONG_LIMB="/* #undef _LONG_LONG_LIMB */" ;;
 
1128
esac
 
1129
AC_SUBST(DEFN_LONG_LONG_LIMB)
 
1130
 
 
1131
 
 
1132
# The C compiler and preprocessor, put into ANSI mode if possible.
 
1133
AC_PROG_CC
 
1134
AC_PROG_CC_STDC
 
1135
AC_PROG_CPP
 
1136
GMP_H_ANSI
 
1137
 
 
1138
 
 
1139
# The C++ compiler, if desired.
 
1140
want_cxx=no
 
1141
if test $enable_cxx != no; then
 
1142
  test_CXXFLAGS=${CXXFLAGS+set}
 
1143
  AC_PROG_CXX
 
1144
 
 
1145
  echo "CXXFLAGS chosen by autoconf: $CXXFLAGS" >&AC_FD_CC
 
1146
  cxxflags_ac_prog_cxx=$CXXFLAGS
 
1147
  cxxflags_list=ac_prog_cxx
 
1148
 
 
1149
  # If the user didn't specify $CXXFLAGS, then try $CFLAGS, with -g removed
 
1150
  # if AC_PROG_CXX thinks that doesn't work.  $CFLAGS stands a good chance
 
1151
  # of working, eg. on a GNU system where CC=gcc and CXX=g++.
 
1152
  #
 
1153
  if test "$test_CXXFLAGS" != set; then
 
1154
    cxxflags_cflags=$CFLAGS
 
1155
    cxxflags_list="cflags $cxxflags_list"
 
1156
    if test "$ac_prog_cxx_g" = no; then
 
1157
      cxxflags_cflags=`echo "$cxxflags_cflags" | sed -e 's/ -g //' -e 's/^-g //' -e 's/ -g$//'`
 
1158
    fi
 
1159
  fi
 
1160
 
 
1161
  # See if the C++ compiler works.  If the user specified CXXFLAGS then all
 
1162
  # we're doing is checking whether AC_PROG_CXX succeeded, since it doesn't
 
1163
  # give a fatal error, just leaves CXX set to a default g++.  If on the
 
1164
  # other hand the user didn't specify CXXFLAGS then we get to try here our
 
1165
  # $cxxflags_list alternatives.
 
1166
  #
 
1167
  for cxxflags_choice in $cxxflags_list; do
 
1168
    eval CXXFLAGS=\"\$cxxflags_$cxxflags_choice\"
 
1169
    GMP_PROG_CXX_WORKS($CXX $CXXFLAGS,
 
1170
      [want_cxx=yes
 
1171
      break])
 
1172
  done
 
1173
 
 
1174
  # If --enable-cxx=yes but a C++ compiler can't be found, then abort.
 
1175
  if test $want_cxx = no && test $enable_cxx = yes; then
 
1176
    AC_MSG_ERROR([C++ compiler not available])
 
1177
  fi
 
1178
fi
 
1179
 
 
1180
AM_CONDITIONAL(WANT_CXX, test $want_cxx = yes)
 
1181
 
 
1182
# FIXME: We're not interested in CXXCPP for ourselves, but if we don't call
 
1183
# it here then AC_PROG_LIBTOOL (via _LT_AC_TAGCONFIG) will do so
 
1184
# unconditionally, and that will fail if there's no C++ compiler (and no
 
1185
# generic /lib/cpp).
 
1186
#
 
1187
if test $want_cxx = yes; then
 
1188
  AC_PROG_CXXCPP
 
1189
fi
 
1190
 
 
1191
cat >&AC_FD_CC <<EOF
 
1192
configure:__line__: Decided:
 
1193
ABI=$ABI
 
1194
CC=$CC
 
1195
CFLAGS=$CFLAGS
 
1196
CPPFLAGS=$CPPFLAGS
 
1197
GMP_LDFLAGS=$GMP_LDFLAGS
 
1198
CXX=$CXX
 
1199
CXXFLAGS=$CXXFLAGS
 
1200
path=$path
 
1201
EOF
 
1202
echo "using ABI=\"$ABI\""
 
1203
echo "      CC=\"$CC\""
 
1204
echo "      CFLAGS=\"$CFLAGS\""
 
1205
echo "      CPPFLAGS=\"$CPPFLAGS\""
 
1206
if test $want_cxx = yes; then
 
1207
  echo "      CXX=\"$CXX\""
 
1208
  echo "      CXXFLAGS=\"$CXXFLAGS\""
 
1209
fi
 
1210
 
 
1211
case $host_cpu in
 
1212
  c90 | t90)
 
1213
    AC_EGREP_CPP(yes,
 
1214
[#ifdef _CRAYIEEE
 
1215
yes
 
1216
#endif],
 
1217
    [add_path="cray/ieee"],
 
1218
    [add_path="cray/cfp"; extra_functions="mulwwc90"]) ;;
 
1219
  j90 | sv1)
 
1220
    extra_functions="mulwwj90"
 
1221
    add_path="cray/cfp" ;;
 
1222
esac
 
1223
 
 
1224
if test -z "$MPN_PATH"; then
 
1225
  path="$add_path $path"
 
1226
fi
 
1227
 
 
1228
 
 
1229
# Automake ansi2knr support.
 
1230
AM_C_PROTOTYPES
 
1231
 
 
1232
GMP_PROG_AR
 
1233
GMP_PROG_NM
 
1234
 
 
1235
case $host in
 
1236
  # FIXME: On AIX 3 and 4, $libname.a is included in libtool
 
1237
  # $library_names_spec, so libgmp.a becomes a symlink to libgmp.so, making
 
1238
  # it impossible to build shared and static libraries simultaneously.
 
1239
  # Disable shared libraries by default, but let the user override with
 
1240
  # --enable-shared --disable-static.
 
1241
  #
 
1242
  # FIXME: This $libname.a problem looks like it might apply to *-*-amigaos*
 
1243
  # and *-*-os2* too, but wait for someone to test this before worrying
 
1244
  # about it.  If there is a problem then of course libtool is the right
 
1245
  # place to fix it.
 
1246
  #
 
1247
  [*-*-aix[34]*])
 
1248
    if test -z "$enable_shared"; then enable_shared=no; fi ;;
 
1249
 
 
1250
  # On Windows, build only static by default, and don't allow both static
 
1251
  # and DLL.  libtool -no-undefined is needed for a DLL, as per the
 
1252
  # AC_LIBTOOL_WIN32_DLL doco.
 
1253
  #
 
1254
  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
 
1255
    if test -z "$enable_shared"; then
 
1256
      enable_shared=no
 
1257
    fi
 
1258
    if test "$enable_shared" != no && test "$enable_static" != no; then
 
1259
      AC_MSG_ERROR([cannot build both static and DLL, since gmp.h is different for each.
 
1260
Use "--disable-static --enable-shared" to build just a DLL.])
 
1261
    fi
 
1262
    if test "$enable_shared" = yes; then
 
1263
      GMP_LDFLAGS="$GMP_LDFLAGS -no-undefined"
 
1264
    fi
 
1265
    ;;
 
1266
 
 
1267
  # FIXME: Libtool recognises djgpp can't build shared libraries, but still
 
1268
  # makes tests/.libs/libtests.al out of PIC objects, which then fail to
 
1269
  # link into the test programs.  Forcibly disable shared stuff until
 
1270
  # libtool gets it right,
 
1271
  #
 
1272
  *-*-msdosdjgpp*)
 
1273
    enable_shared=no ;;
 
1274
 
 
1275
  # FIXME: On SCO 5, an explicit -lc is not wanted when making shared
 
1276
  # libraries.  Giving it makes strange things happen, like ctype.h macros
 
1277
  # not working and profiler mcount calls segfaulting.  Libtool ought to
 
1278
  # know about this, but as of Dec 2000 it doesn't, so forcibly disable -lc
 
1279
  # on relevant systems.
 
1280
  #
 
1281
  *-*-sco3.2v5*)
 
1282
    lt_cv_archive_cmds_need_lc=no ;;
 
1283
 
 
1284
  # FIXME: Shared libraries aren't supported on unicos, but as of Dec 2000
 
1285
  # libtool doesn't seem to detect this correctly, so forcibly disable them.
 
1286
  #
 
1287
  *-*-unicos*)
 
1288
    enable_shared=no ;;
 
1289
 
 
1290
  # It seems there are no shared libs on ultrix, and it is not very important
 
1291
  # to work on this.  Just disable for now.
 
1292
  *-*-ultrix*)
 
1293
    enable_shared=no ;;
 
1294
esac
 
1295
 
 
1296
# Libtool runs an impgen.c program on the build system when making windows
 
1297
# DLLs.  If we're cross compiling then look for a suitable build system
 
1298
# compiler, since $CC can't be expected to work.
 
1299
# FIXME: Libtool ought to do this itself.
 
1300
#
 
1301
if test "$cross_compiling" != no && test "$enable_shared" != no; then
 
1302
  case $host in
 
1303
    *-*-cygwin* | *-*-mingw* | *-*-pw32*)
 
1304
      GMP_PROG_HOST_CC
 
1305
      ;;
 
1306
  esac
 
1307
fi
 
1308
 
 
1309
# Enable CXX in libtool only if we want it, and never enable GCJ, nor RC on
 
1310
# mingw and cygwin.  Under --disable-cxx this avoids some error messages
 
1311
# from libtool arising from the fact we didn't actually run AC_PROG_CXX.
 
1312
# Notice that any user-supplied --with-tags setting takes precedence.
 
1313
#
 
1314
# FIXME: Is this the right way to get this effect?  Very possibly not, but
 
1315
# the current _LT_AC_TAGCONFIG doesn't really suggest an alternative.
 
1316
#
 
1317
if test "${with_tags+set}" != set; then
 
1318
  if test $want_cxx = yes; then
 
1319
    with_tags=CXX
 
1320
  else
 
1321
    with_tags=
 
1322
  fi
 
1323
fi
 
1324
 
 
1325
AC_LIBTOOL_WIN32_DLL
 
1326
AC_PROG_LIBTOOL
 
1327
 
 
1328
# Generate an error here if attempting to build both shared and static when
 
1329
# $libname.a is in $library_names_spec (as mentioned above), rather than
 
1330
# wait for ar or ld to fail.
 
1331
#
 
1332
if test "$enable_shared" = yes && test "$enable_static" = yes; then
 
1333
  case $library_names_spec in
 
1334
    *libname.a*)
 
1335
      AC_MSG_ERROR([cannot create both shared and static libraries on this system, --disable one of the two])
 
1336
      ;;
 
1337
  esac
 
1338
fi
 
1339
 
 
1340
# Encode in gmp.h whether a shared or static library is available.
 
1341
# Currently only used for the windows DLL stuff.
 
1342
#
 
1343
case $enable_shared in
 
1344
yes) __GMP_LIBGMP_SHARED=1 ;;
 
1345
no)  __GMP_LIBGMP_SHARED=0 ;;
 
1346
esac
 
1347
AC_SUBST(__GMP_LIBGMP_SHARED)
 
1348
 
 
1349
case $enable_static in
 
1350
yes) __GMP_LIBGMP_STATIC=1 ;;
 
1351
no)  __GMP_LIBGMP_STATIC=0 ;;
 
1352
esac
 
1353
AC_SUBST(__GMP_LIBGMP_STATIC)
 
1354
 
 
1355
 
 
1356
# How to assemble, used with CFLAGS etc, see mpn/Makeasm.am.
 
1357
# Using the compiler is a lot easier than figuring out how to invoke the
 
1358
# assembler directly.
 
1359
#
 
1360
test -n "$CCAS" || CCAS="$CC -c"
 
1361
AC_SUBST(CCAS)
 
1362
 
 
1363
case $host in
 
1364
  X86_PATTERN)
 
1365
    # If there's any sse2 or mmx in the path, check whether the assembler
 
1366
    # supports it, and remove if not.
 
1367
    case "$path" in
 
1368
      *mmx*)   GMP_ASM_X86_MMX( , [GMP_STRIP_PATH(*mmx*)]) ;;
 
1369
    esac
 
1370
    case "$path" in
 
1371
      *sse2*)  GMP_ASM_X86_SSE2( , [GMP_STRIP_PATH(sse2)]) ;;
 
1372
    esac
 
1373
  ;;
 
1374
esac
 
1375
 
 
1376
 
 
1377
# The library and header checks are mostly for the benefit of supplementary
 
1378
# programs.  libgmp doesn't use anything too weird.
 
1379
 
 
1380
AC_HEADER_STDC
 
1381
AC_HEADER_TIME
 
1382
 
 
1383
# stdint.h, unistd.h and sys/types.h are already in the autoconf default
 
1384
# tests
 
1385
AC_CHECK_HEADERS(locale.h sys/mman.h sys/param.h sys/processor.h sys/resource.h sys/sysctl.h sys/systemcfg.h sys/time.h sys/times.h)
 
1386
 
 
1387
# optarg should be in unistd.h, which is already in the default includes
 
1388
AC_CHECK_DECLS([fgetc, fscanf, optarg, ungetc, vfprintf])
 
1389
 
 
1390
AC_TYPE_SIGNAL
 
1391
 
 
1392
# the default includes are sufficient for all these types
 
1393
AC_CHECK_TYPES([intmax_t, long double, long long, ptrdiff_t, quad_t])
 
1394
 
 
1395
AC_C_STRINGIZE
 
1396
GMP_C_STDARG
 
1397
GMP_C_ATTRIBUTE_CONST
 
1398
GMP_C_ATTRIBUTE_MALLOC
 
1399
GMP_C_ATTRIBUTE_MODE
 
1400
GMP_C_ATTRIBUTE_NORETURN
 
1401
 
 
1402
AC_C_INLINE
 
1403
GMP_H_EXTERN_INLINE
 
1404
 
 
1405
# from libtool
 
1406
AC_CHECK_LIBM
 
1407
AC_SUBST(LIBM)
 
1408
 
 
1409
GMP_FUNC_ALLOCA
 
1410
GMP_OPTION_ALLOCA
 
1411
 
 
1412
GMP_H_HAVE_FILE
 
1413
GMP_IMPL_H_IEEE_FLOATS
 
1414
 
 
1415
 
 
1416
# On m68k NetBSD 1.4.1 getrusage() is doubtful.  ru_utime looks microsecond
 
1417
# accurate but has been seen remaining unchanged after many microseconds
 
1418
# have elapsed.  This upsets the tune and speed programs, so pretend it
 
1419
# doesn't exist.
 
1420
#
 
1421
# FIXME: Would prefer tune/time.c to do a run-time test for this rather than
 
1422
# driving it from the system name.
 
1423
#
 
1424
case $host in
 
1425
  m68*-*-netbsd1.4*) ac_cv_func_getrusage=no ;;
 
1426
esac
 
1427
 
 
1428
AC_CHECK_FUNCS(alarm getpagesize getrusage gettimeofday localeconv memset mmap mprotect obstack_vprintf popen processor_info read_real_time strchr strnlen strtoul sysconf sysctl sysctlbyname times)
 
1429
 
 
1430
# FIXME: Would have done this with an AM_CONDITIONAL, but automake 1.5
 
1431
# doesn't like that under libgmp_la_DEPENDENCIES.
 
1432
GMP_FUNC_VSNPRINTF
 
1433
if test "$gmp_cv_func_vsnprintf" = no; then
 
1434
  AC_SUBST(REPL_VSNPRINTF_PRINTF_OBJ, 'printf/repl-vsnprintf$U.lo')
 
1435
  AC_SUBST(REPL_VSNPRINTF_OBJ,        'repl-vsnprintf$U.lo')
 
1436
fi
 
1437
 
 
1438
GMP_FUNC_SSCANF_WRITABLE_INPUT
 
1439
 
 
1440
 
 
1441
# Pick the correct source files in $path and link them to mpn/.
 
1442
# $gmp_mpn_functions lists all functions we need.
 
1443
#
 
1444
# The rule is to find a file with the function name and a .asm, .S,
 
1445
# .s, or .c extension.  Certain multi-function files with special names
 
1446
# can provide some functions too.  (mpn/Makefile.am passes
 
1447
# -DOPERATION_<func> to get them to generate the right code.)
 
1448
 
 
1449
# FIXME: udiv and umul aren't in $gmp_mpn_functions_optional yet since
 
1450
# there's some versions of those files which should be checked for bit
 
1451
# rot first.  Put them in $extra_functions for each host for now,
 
1452
# change to standard optionals when all are ready.
 
1453
 
 
1454
# Note: The following lines defining $gmp_mpn_functions_optional
 
1455
#       and $gmp_mpn_functions are parsed by the "macos/configure"
 
1456
#       Perl script. So if you change the lines in a major way
 
1457
#       make sure to run and examine the output from
 
1458
#       
 
1459
#           % (cd macos; perl configure)
 
1460
#
 
1461
# Note: $gmp_mpn_functions must have mod_1 before pre_mod_1 so the former
 
1462
#       can optionally provide the latter as an extra entrypoint.
 
1463
 
 
1464
gmp_mpn_functions_optional="copyi copyd com_n           \
 
1465
  and_n andn_n nand_n ior_n iorn_n nior_n xor_n xnor_n  \
 
1466
  gcd_finda invert_limb sqr_diagonal"
 
1467
 
 
1468
gmp_mpn_functions="$extra_functions                                        \
 
1469
  add add_1 add_n sub sub_1 sub_n mul_1 addmul_1                           \
 
1470
  submul_1 lshift rshift dive_1 diveby3 divis divrem divrem_1 divrem_2     \
 
1471
  fib2_ui mod_1 mod_34lsub1 mode1o pre_mod_1 dump                          \
 
1472
  mul mul_fft mul_n mul_basecase sqr_basecase random                       \
 
1473
  random2 sqrtrem get_str set_str scan0 scan1 popcount hamdist cmp perfsqr \
 
1474
  bdivmod gcd_1 gcd gcdext tdiv_qr dc_divrem_n sb_divrem_mn jacbase        \
 
1475
  $gmp_mpn_functions_optional"
 
1476
 
 
1477
# the list of all object files used by mpn/Makefile.in and the
 
1478
# top-level Makefile.in, respectively
 
1479
mpn_objects=
 
1480
mpn_objs_in_libgmp="mpn/mp_bases.lo"
 
1481
 
 
1482
# links from the sources, to be removed by "make distclean"
 
1483
gmp_srclinks=
 
1484
 
 
1485
define(MPN_SUFFIXES,[asm S s c])
 
1486
 
 
1487
for tmp_ext in MPN_SUFFIXES; do
 
1488
  eval found_$tmp_ext=no
 
1489
done
 
1490
 
 
1491
for tmp_fn in $gmp_mpn_functions; do
 
1492
  for tmp_ext in MPN_SUFFIXES; do
 
1493
    test "$no_create" = yes || rm -f mpn/$tmp_fn.$tmp_ext
 
1494
  done
 
1495
 
 
1496
  # Don't need pre_mod_1 if it's already been provided (by an asm mod_1).
 
1497
  case $tmp_fn in
 
1498
  pre_mod_1)
 
1499
    if test "$HAVE_NATIVE_mpn_preinv_mod_1" = yes; then continue; fi ;;
 
1500
  esac
 
1501
 
 
1502
  # functions that can be provided by multi-function files
 
1503
  tmp_mulfunc=
 
1504
  case $tmp_fn in
 
1505
  add_n|sub_n)       tmp_mulfunc="aors_n"    ;;
 
1506
  addmul_1|submul_1) tmp_mulfunc="aorsmul_1" ;;
 
1507
  popcount|hamdist)  tmp_mulfunc="popham"    ;;
 
1508
  and_n|andn_n|nand_n | ior_n|iorn_n|nior_n | xor_n|xnor_n)
 
1509
                     tmp_mulfunc="logops_n"  ;;
 
1510
  lshift|rshift)     tmp_mulfunc="lorrshift";;
 
1511
  esac
 
1512
 
 
1513
  found=no
 
1514
  for tmp_dir in $path; do
 
1515
    for tmp_base in $tmp_fn $tmp_mulfunc; do
 
1516
      for tmp_ext in MPN_SUFFIXES; do
 
1517
        tmp_file=$srcdir/mpn/$tmp_dir/$tmp_base.$tmp_ext
 
1518
        if test -f $tmp_file; then
 
1519
          found=yes
 
1520
          eval found_$tmp_ext=yes
 
1521
 
 
1522
          if test $tmp_ext = c; then
 
1523
            tmp_u='$U'
 
1524
          else
 
1525
            tmp_u=
 
1526
          fi
 
1527
 
 
1528
          mpn_objects="$mpn_objects $tmp_fn$tmp_u.lo"
 
1529
          mpn_objs_in_libgmp="$mpn_objs_in_libgmp mpn/$tmp_fn$tmp_u.lo"
 
1530
          AC_CONFIG_LINKS(mpn/$tmp_fn.$tmp_ext:mpn/$tmp_dir/$tmp_base.$tmp_ext)
 
1531
          gmp_srclinks="$gmp_srclinks mpn/$tmp_fn.$tmp_ext"
 
1532
 
 
1533
          # Duplicate AC_DEFINEs are harmless, so it doesn't matter
 
1534
          # that multi-function files get grepped here repeatedly.
 
1535
          # The PROLOGUE pattern has ".*" so that alpha PROLOGUE_GP matches.
 
1536
          gmp_ep=[`
 
1537
            sed -n 's/^[        ]*MULFUNC_PROLOGUE(\(.*\))/\1/p' $tmp_file ;
 
1538
            sed -n 's/^[        ]*PROLOGUE.*(\(.*\))/\1/p' $tmp_file
 
1539
          `]
 
1540
          for gmp_tmp in $gmp_ep; do
 
1541
            AC_DEFINE_UNQUOTED(HAVE_NATIVE_$gmp_tmp)
 
1542
            eval HAVE_NATIVE_$gmp_tmp=yes
 
1543
          done
 
1544
 
 
1545
          case $tmp_fn in
 
1546
          sqr_basecase) sqr_basecase_source=$tmp_file ;;
 
1547
          esac
 
1548
 
 
1549
          break
 
1550
        fi
 
1551
      done
 
1552
      if test $found = yes; then break ; fi
 
1553
    done
 
1554
    if test $found = yes; then break ; fi
 
1555
  done
 
1556
 
 
1557
  if test $found = no; then
 
1558
    for tmp_optional in $gmp_mpn_functions_optional; do
 
1559
      if test $tmp_optional = $tmp_fn; then
 
1560
        found=yes
 
1561
      fi
 
1562
    done
 
1563
    if test $found = no; then
 
1564
      AC_MSG_ERROR([no version of $tmp_fn found in path: $path])
 
1565
    fi
 
1566
  fi
 
1567
done
 
1568
 
 
1569
# All cycle counters are .asm files currently
 
1570
if test -n "$SPEED_CYCLECOUNTER_OBJ"; then
 
1571
  found_asm=yes
 
1572
fi
 
1573
 
 
1574
 
 
1575
# Don't demand an m4 unless it's actually needed.
 
1576
if test $found_asm = yes; then
 
1577
  GMP_PROG_M4
 
1578
  GMP_M4_M4WRAP_SPURIOUS
 
1579
else
 
1580
  M4=m4-not-needed
 
1581
fi
 
1582
 
 
1583
# Only do the GMP_ASM checks if there's a .S or .asm wanting them.
 
1584
if test $found_asm = no && test $found_S = no; then
 
1585
  gmp_asm_syntax_testing=no
 
1586
fi
 
1587
 
 
1588
if test "$gmp_asm_syntax_testing" != no; then
 
1589
  GMP_ASM_TEXT
 
1590
  GMP_ASM_DATA
 
1591
  GMP_ASM_LABEL_SUFFIX
 
1592
  GMP_ASM_GLOBL
 
1593
  GMP_ASM_UNDERSCORE
 
1594
  GMP_ASM_RODATA
 
1595
  GMP_ASM_GLOBL_ATTR
 
1596
  GMP_ASM_TYPE
 
1597
  GMP_ASM_SIZE
 
1598
  GMP_ASM_LSYM_PREFIX
 
1599
  GMP_ASM_W32
 
1600
  GMP_ASM_ALIGN_LOG
 
1601
 
 
1602
  case $host in
 
1603
    m68*-*-*)
 
1604
      GMP_ASM_M68K_INSTRUCTION
 
1605
      GMP_ASM_M68K_ADDRESSING
 
1606
      GMP_ASM_M68K_BRANCHES
 
1607
      ;;
 
1608
    power*-*-*)
 
1609
      GMP_ASM_POWERPC_R_REGISTERS
 
1610
      GMP_INCLUDE_MPN(powerpc32/powerpc-defs.m4)
 
1611
      case $host in
 
1612
      powerpc64*-*-aix*) GMP_INCLUDE_MPN(powerpc64/aix.m4) ;;
 
1613
      *-*-aix*)          GMP_INCLUDE_MPN(powerpc32/aix.m4) ;;
 
1614
      esac
 
1615
      ;;
 
1616
 
 
1617
    X86_PATTERN)
 
1618
      GMP_ASM_ALIGN_FILL_0x90
 
1619
      GMP_ASM_X86_SHLDL_CL
 
1620
      if test "$enable_profiling" != no; then
 
1621
        GMP_ASM_X86_MCOUNT
 
1622
      fi
 
1623
      ;;
 
1624
  esac
 
1625
fi
 
1626
 
 
1627
 
 
1628
# Create link for gmp-mparam.h.
 
1629
gmp_mparam_source=
 
1630
for tmp_dir in $path; do
 
1631
  test "$no_create" = yes || rm -f gmp-mparam.h
 
1632
  tmp_file=$srcdir/mpn/$tmp_dir/gmp-mparam.h
 
1633
  if test -f $tmp_file; then
 
1634
    AC_CONFIG_LINKS(gmp-mparam.h:mpn/$tmp_dir/gmp-mparam.h)
 
1635
    gmp_srclinks="$gmp_srclinks gmp-mparam.h"
 
1636
    gmp_mparam_source=$tmp_file
 
1637
    break
 
1638
  fi
 
1639
done
 
1640
if test -z "$gmp_mparam_source"; then
 
1641
  AC_MSG_ERROR([no version of gmp-mparam.h found in path: $path])
 
1642
fi
 
1643
 
 
1644
# Copy any KARATSUBA_SQR_THRESHOLD from gmp-mparam.h to config.m4.
 
1645
# Some versions of sqr_basecase.asm use this.
 
1646
tmp_gmp_karatsuba_sqr_threshold=`sed -n 's/^#define KARATSUBA_SQR_THRESHOLD[    ]*\([0-9][0-9]*\).*$/\1/p' $gmp_mparam_source`
 
1647
if test -n "$tmp_gmp_karatsuba_sqr_threshold"; then
 
1648
  GMP_DEFINE_RAW(["define(<KARATSUBA_SQR_THRESHOLD>,<$tmp_gmp_karatsuba_sqr_threshold>)"])
 
1649
fi
 
1650
 
 
1651
# This must come after gmp-mparam.h has been chosen.
 
1652
GMP_C_SIZES
 
1653
 
 
1654
 
 
1655
# Exclude the mpn random functions from mpbsd since that would drag in the
 
1656
# top-level rand things, all of which are unnecessary for libmp.  There's
 
1657
# other unnecessary objects too actually, if we could be bothered figuring
 
1658
# out exactly which they are.
 
1659
#
 
1660
mpn_objs_in_libmp=
 
1661
for i in $mpn_objs_in_libgmp; do
 
1662
  case $i in
 
1663
  *random*) ;;
 
1664
  *) mpn_objs_in_libmp="$mpn_objs_in_libmp $i" ;;
 
1665
  esac
 
1666
done
 
1667
AC_SUBST(mpn_objs_in_libmp)
 
1668
 
 
1669
AC_SUBST(mpn_objects)
 
1670
AC_SUBST(mpn_objs_in_libgmp)
 
1671
AC_SUBST(gmp_srclinks)
 
1672
 
 
1673
 
 
1674
# A recompiled sqr_basecase for use in the tune program, if necessary.
 
1675
TUNE_SQR_OBJ=
 
1676
test -d tune || mkdir tune
 
1677
case $sqr_basecase_source in
 
1678
  *.asm)
 
1679
    sqr_max=[`sed -n 's/^def...(KARATSUBA_SQR_THRESHOLD_MAX, *\([0-9]*\))/\1/p' $sqr_basecase_source`]
 
1680
    if test -n "$sqr_max"; then
 
1681
      TUNE_SQR_OBJ=sqr_asm.o
 
1682
      AC_DEFINE_UNQUOTED(TUNE_KARATSUBA_SQR_MAX,$sqr_max,
 
1683
      [Maximum size the tune program can test for KARATSUBA_SQR_THRESHOLD])
 
1684
    fi
 
1685
    cat >tune/sqr_basecase.c <<EOF
 
1686
/* not sure that an empty file can compile, so put in a dummy */
 
1687
int sqr_basecase_dummy;
 
1688
EOF
 
1689
    ;;
 
1690
  *.c)
 
1691
    TUNE_SQR_OBJ=
 
1692
    AC_DEFINE(TUNE_KARATSUBA_SQR_MAX,KARATSUBA_SQR_MAX_GENERIC)
 
1693
    cat >tune/sqr_basecase.c <<EOF
 
1694
#define TUNE_PROGRAM_BUILD 1
 
1695
#define TUNE_PROGRAM_BUILD_SQR 1
 
1696
#include "mpn/sqr_basecase.c"
 
1697
EOF
 
1698
    ;;
 
1699
esac
 
1700
AC_SUBST(TUNE_SQR_OBJ)
 
1701
 
 
1702
 
 
1703
# Configs for demos/expr directory
 
1704
if test $enable_mpfr = yes; then
 
1705
  HAVE_MPFR=1
 
1706
else
 
1707
  HAVE_MPFR=0
 
1708
fi
 
1709
AC_SUBST(HAVE_MPFR)
 
1710
 
 
1711
 
 
1712
# Create config.m4.
 
1713
GMP_FINISH
 
1714
 
 
1715
# Create Makefiles
 
1716
# FIXME: Upcoming version of autoconf/automake may not like broken lines.
 
1717
#        Right now automake isn't accepting the new AC_CONFIG_FILES scheme.
 
1718
 
 
1719
AC_OUTPUT(Makefile                                                      \
 
1720
  mpbsd/Makefile mpf/Makefile mpn/Makefile mpq/Makefile \
 
1721
  mpz/Makefile printf/Makefile scanf/Makefile cxx/Makefile              \
 
1722
  tests/Makefile tests/devel/Makefile tests/mpbsd/Makefile              \
 
1723
  tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile              \
 
1724
  tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile            \
 
1725
  tests/cxx/Makefile                                                    \
 
1726
  tune/Makefile                                                         \
 
1727
  demos/Makefile demos/calc/Makefile demos/expr/Makefile                \
 
1728
  gmp.h:gmp-h.in mp.h:mp-h.in                                           \
 
1729
  demos/expr/expr-impl.h:demos/expr/expr-impl-h.in)
 
1730
 
 
1731
dnl  mpfr temporarily removed from the distribution
 
1732
dnl  mpfr/Makefile mpfr/tests/Makefile