6204367e847b427359ca3d75e1638bfd16b3d689
[ghc-hetmet.git] / ghc / rts / gmp / configure.in
1 dnl  Process this file with autoconf to produce a configure script.
2
3
4 dnl  Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
5 dnl
6 dnl  This file is part of the GNU MP Library.
7 dnl
8 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9 dnl  it under the terms of the GNU Lesser General Public License as published
10 dnl  by the Free Software Foundation; either version 2.1 of the License, or (at
11 dnl  your option) any later version.
12 dnl
13 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
14 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 dnl  License for more details.
17 dnl
18 dnl  You should have received a copy of the GNU Lesser General Public License
19 dnl  along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
20 dnl  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 dnl  MA 02111-1307, USA.
22
23
24 AC_REVISION($Revision: 1.4 $)dnl
25 AC_PREREQ(2.14)dnl
26 AC_INIT(gmp-impl.h)
27
28 dnl Check system.
29 AC_CANONICAL_SYSTEM
30
31 dnl  Automake
32 AM_INIT_AUTOMAKE(gmp, GMP_VERSION)
33 AM_CONFIG_HEADER(config.h:config.in)
34 AM_MAINTAINER_MODE
35
36 dnl  GMP specific
37 GMP_INIT(config.m4)
38
39
40 AC_ARG_ENABLE(assert,
41 AC_HELP_STRING([--enable-assert],[enable ASSERT checking [default=no]]),
42 [case "${enableval}" in
43 yes|no) ;;
44 *) AC_MSG_ERROR([bad value ${enableval} for --enable-assert, need yes or no]) ;;
45 esac],
46 [enable_assert=no])
47
48 if test "$enable_assert" = "yes"; then
49   AC_DEFINE(WANT_ASSERT,1,
50   [./configure --enable-assert option, to enable some ASSERT()s])
51 fi
52
53
54 AC_ARG_ENABLE(alloca,
55 AC_HELP_STRING([--enable-alloca],[use alloca for temp space [default=yes]]),
56 [case "${enableval}" in
57 yes|no) ;;
58 *) AC_MSG_ERROR([bad value ${enableval} for --enable-alloca, need yes or no]) ;;
59 esac],
60 [enable_alloca=yes])
61
62 if test "$enable_alloca" = "no"; then
63   AC_DEFINE(USE_STACK_ALLOC,1,
64   [./configure --disable-alloca option, to use stack-alloc.c, not alloca])
65 fi
66
67
68 AC_ARG_ENABLE(fft,
69 AC_HELP_STRING([--enable-fft],[enable FFTs for multiplication [default=no]]),
70 [case "${enableval}" in
71 yes|no) ;;
72 *) AC_MSG_ERROR([bad value ${enableval} for --enable-fft, need yes or no]) ;;
73 esac],
74 [enable_fft=no])
75
76 if test "$enable_fft" = "yes"; then
77   AC_DEFINE(WANT_FFT,1,
78   [./configure --enable-fft option, to enable FFTs for multiplication])
79 fi
80
81
82 AC_ARG_ENABLE(mpbsd,
83 AC_HELP_STRING([--enable-mpbsd],[build Berkley MP compatibility library [default=no]]),
84 [case "${enableval}" in
85 yes|no) ;;
86 *) AC_MSG_ERROR([bad value ${enableval} for --enable-mpbsd, need yes or no]) ;;
87 esac],
88 [enable_mpbsd=no])
89 AM_CONDITIONAL(WANT_MPBSD, test "$enable_mpbsd" = "yes")
90
91
92 AC_ARG_ENABLE(mpfr,
93 AC_HELP_STRING([--enable-mpfr],[build MPFR [default=no]]),
94 [case "${enableval}" in
95 yes|no) ;;
96 *) AC_MSG_ERROR([bad value ${enableval} for --enable-mpfr, need yes or no]) ;;
97 esac],
98 [enable_mpfr=no])
99 AM_CONDITIONAL(WANT_MPFR, test "$enable_mpfr" = "yes")
100
101
102 dnl Switch on OS and determine what compiler to use.
103 dnl
104 dnl  os_64bit              Set to "yes" if OS is 64-bit capable.
105 dnl                        FIXME: Rename to `check_64bit_compiler'!
106 dnl  cclist                List of compilers, best first.
107 dnl  gmp_cflags_{cc}       Flags for compiler named {cc}.
108 dnl  gmp_cflags64_{cc}     Flags for compiler named {cc} for 64-bit code.
109 dnl  gmp_optcflags_{cc}    Optional compiler flags.
110 dnl  gmp_xoptcflags_{cc}   Exclusive optional compiler flags.
111 dnl
112 os_64bit="no"
113 cclist="gcc cc"         # FIXME: Prefer c89 to cc.
114 gmp_cflags_gcc="-g -O2"
115 gmp_cflags64_gcc="-g -O2"
116 gmp_cflags_cc="-g"
117 gmp_cflags64_cc="-g"
118
119 case "$target" in
120   # Alpha
121   alpha*-cray-unicos*)
122     # Don't perform any assembly syntax tests on this beast.
123     gmp_no_asm_syntax_testing=yes
124     cclist=cc
125     gmp_cflags_cc="$gmp_cflags_cc -O"
126     ;;
127   alpha*-*-osf*)
128     flavour=`echo $target_cpu | sed 's/^alpha//g'`
129     if test -n "$flavour"; then
130       case $flavour in     # compilers don't seem to understand `ev67' and such.
131         ev6? | ev7*) flavour=ev6;;
132       esac
133       gmp_optcflags_gcc="-mcpu=$flavour"
134       # FIXME: We shouldn't fail fatally if none of these work, but that's
135       # how xoptcflags work and we don't have any other mechanism right now.
136       # Why do we need this here and not for alpha*-*-* below?
137       gmp_xoptcflags_gcc="-Wa,-arch,${flavour} -Wa,-m${flavour}"
138       gmp_optcflags_cc="-arch $flavour -tune $flavour"
139     fi
140     ;;
141   alpha*-*-*)
142     cclist="gcc"
143     flavour=`echo $target_cpu | sed 's/^alpha//g'`
144     if test -n "$flavour"; then
145       case $flavour in
146         ev6? | ev7*) flavour=ev6;;
147       esac
148       gmp_optcflags_gcc="-mcpu=$flavour"
149     fi
150     ;;
151   # Cray vector machines.  This must come after alpha* so that we can
152   # recognize present and future vector processors with a wildcard.
153   *-cray-unicos*)
154     # Don't perform any assembly syntax tests on this beast.
155     gmp_no_asm_syntax_testing=yes
156     cclist=cc
157     # Don't inherit default gmp_cflags_cc value; it comes with -g which
158     # disables all optimization on Cray vector systems
159     gmp_cflags_cc="-O"
160     ;;
161
162   # AMD and Intel x86 configurations
163   [i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*])
164     # Rumour has it -O2 used to give worse register allocation than just -O.
165     gmp_cflags_gcc="-g -O -fomit-frame-pointer"
166
167     case "${target}" in
168       i386*-*-*)    gmp_optcflags_gcc="-mcpu=i386 -march=i386";;
169       i486*-*-*)    gmp_optcflags_gcc="-mcpu=i486 -march=i486";;
170       i586*-*-* | pentium-*-* | pentiummmx-*-*)
171                     gmp_optcflags_gcc="-mcpu=pentium -march=pentium";;
172
173       # -march=pentiumpro not used because mpz/powm.c (swox cvs rev 1.4)
174       # tickles a bug in gcc 2.95.2 (believed fixed in 2.96).
175       [i686*-*-* | pentiumpro-*-* | pentium[23]-*-*])
176                     gmp_optcflags_gcc="-mcpu=pentiumpro";;
177
178       k6*-*-*)      gmp_optcflags_gcc="-mcpu=k6 -march=k6";;
179
180       # Athlon instruction costs are close to p6: 3 cycle load latency, 4-6
181       # cycle mul, 40 cycle div, pairable adc, ...
182       # FIXME: Change this when gcc gets something specific for Athlon.
183       # -march=pentiumpro not used, per i686 above.
184       athlon-*-*)   gmp_optcflags_gcc="-mcpu=pentiumpro";;
185     esac
186     ;;
187
188   # Sparc
189   [ultrasparc*-*-solaris2.[7-9] | sparcv9-*-solaris2.[7-9]])
190     os_64bit=yes
191     gmp_cflags_gcc="$gmp_cflags_gcc -Wa,-xarch=v8plus"
192     gmp_xoptcflags_gcc="-mcpu=v9 -mcpu=v8 -mv8"
193     gmp_cflags64_gcc="$gmp_cflags64_gcc -m64 -mptr64 -Wa,-xarch=v9 -mcpu=v9"
194     gmp_cflags_cc="-xtarget=native -xarch=v8 -xO4"
195     gmp_cflags64_cc="-xtarget=native -xarch=v9 -xO4"
196     ;;
197   sparc64-*-linux*)
198     os_64bit=yes
199     gmp_cflags64_gcc="$gmp_cflags64_gcc -m64 -mptr64 -Wa,-xarch=v9 -mcpu=v9"
200     gmp_cflags_gcc="$gmp_cflags_gcc -m32"
201     gmp_xoptflags_gcc="-mcpu=ultrasparc -mvis"
202     ;;
203   ultrasparc*-*-* | sparcv9-*-*)
204     gmp_cflags_gcc="$gmp_cflags_gcc -Wa,-xarch=v8plus"
205     gmp_xoptcflags_gcc="-mcpu=v9 -mcpu=v8 -mv8"
206     gmp_cflags_cc="-xtarget=native -xarch=v8 -xO4"
207     ;;
208   sparcv8*-*-solaris2.* | microsparc*-*-solaris2.*)
209     gmp_cflags_gcc="$gmp_cflags_gcc"
210     gmp_xoptcflags_gcc="-mcpu=v8 -mv8"
211     gmp_cflags_cc="-xtarget=native -xarch=v8 -xO4"
212     ;;
213   sparcv8*-*-* | microsparc*-*-*)               # SunOS, Linux, *BSD
214     cclist="gcc acc cc"
215     gmp_cflags_gcc="$gmp_cflags_gcc"
216     gmp_xoptcflags_gcc="-mcpu=v8 -mv8"
217     gmp_cflags_acc="-g -O2 -cg92"
218     gmp_cflags_cc="-O2"         # FIXME: Flag for v8?
219     ;;
220   supersparc*-*-solaris2.*)
221     gmp_cflags_gcc="$gmp_cflags_gcc -DSUPERSPARC"
222     gmp_xoptcflags_gcc="-mcpu=v8 -mv8"
223     gmp_cflags_cc="-xtarget=native -xarch=v8 -xO4 -DSUPERSPARC"
224     ;;
225   supersparc*-*-*)              # SunOS, Linux, *BSD
226     cclist="gcc acc cc"
227     gmp_cflags_gcc="$gmp_cflags_gcc -DSUPERSPARC"
228     gmp_xoptcflags_gcc="-mcpu=v8 -mv8"
229     gmp_cflags_acc="-g -O2 -cg92 -DSUPERSPARC"
230     gmp_cflags_cc="-O2 -DSUPERSPARC"    # FIXME: Flag for v8?
231     ;;
232   *sparc*-*-*)
233     cclist="gcc acc cc"
234     gmp_cflags_acc="-g -O2"
235     gmp_cflags_cc="-g -O2"
236     ;;
237
238   # POWER/PowerPC
239   powerpc64-*-aix*)
240     cclist="gcc xlc"
241     gmp_cflags_gcc="$gmp_cflags_gcc -maix64 -mpowerpc64"
242     gmp_cflags_xlc="-g -O2 -q64 -qtune=pwr3"
243     ;;
244   powerpc*-*-aix*)
245     cclist="gcc xlc"
246     gmp_cflags_gcc="$gmp_cflags_gcc -mpowerpc"
247     gmp_cflags_xlc="$gmp_cflags_cc -qarch=ppc -O2"
248     ;;
249   power-*-aix*)
250     cclist="gcc xlc"
251     gmp_cflags_gcc="$gmp_cflags_gcc -mpower"
252     gmp_cflags_xlc="$gmp_cflags_cc -qarch=pwr -O2"
253     ;;
254   powerpc64*-*-*)
255     gmp_cflags_gcc="$gmp_cflags_gcc -mpowerpc64"
256     AC_DEFINE(_LONG_LONG_LIMB)  dnl FIXME: Remove.
257     ;;
258   powerpc*-*-*)
259     gmp_cflags_gcc="$gmp_cflags_gcc -mpowerpc"
260     ;;
261
262   # MIPS
263   mips-sgi-irix6.*)
264     os_64bit=yes
265     gmp_cflags64_gcc="-g -O2 -mabi=n32"
266     gmp_cflags64_cc="$gmp_cflags64_cc -O2 -n32"
267     ;;
268
269   # Motorola 68k family
270   m88110*-*-*)
271     gmp_cflags_gcc="-g -O -m88110"      dnl  FIXME: Use `-O2'?
272     ;;
273   m68*-*-*)
274     gmp_cflags_gcc="$gmp_cflags_gcc -fomit-frame-pointer"
275     ;;
276
277   # HP
278   hppa1.0*-*-*)
279     cclist="gcc c89 cc"
280     gmp_cflags_c89="$gmp_cflags_cc +O2"
281     gmp_cflags_cc="$gmp_cflags_cc +O2"
282     ;;
283   hppa2.0w*-*-*)
284     cclist="c89 cc"
285     gmp_cflags_c89="+DD64 +O3"
286     gmp_cflags_cc="+DD64 +O3"
287     ;;
288   hppa2.0*-*-*)
289     os_64bit=yes
290     cclist="gcc c89 cc"
291     gmp_cflags64_gcc="$gmp_cflags64_gcc -mWHAT -D_LONG_LONG_LIMB"
292     # +O2 to cc triggers bug in mpz/powm.c (1.4)
293     gmp_cflags64_c89="+DA2.0 +e +O3 -D_LONG_LONG_LIMB"
294     gmp_cflags64_cc="+DA2.0 +e +O3 -D_LONG_LONG_LIMB"
295     gmp_cflags_c89="$gmp_cflags_cc +O2"
296     gmp_cflags_cc="$gmp_cflags_cc +O2"
297     ;;
298
299   # VAX
300   vax*-*-*)
301     gmp_cflags_gcc="$gmp_cflags_gcc -fomit-frame-pointer"
302     ;;
303
304   # Fujitsu
305   [f30[01]-fujitsu-sysv*])
306     cclist="gcc vcc"
307     gmp_cflags_vcc="-g"         # FIXME: flags for vcc?
308     ;;
309 esac
310
311 dnl  Check for programs needed by macros for finding compiler.
312 dnl  More programs are checked for below, when a compiler is found.
313 AC_PROG_NM      dnl  Macro from Libtool.
314 # nm on 64-bit AIX needs to know the object file format 
315 case "$target" in
316   powerpc64*-*-aix*)
317     NM="$NM -X 64"
318     ;;
319 esac   
320
321 # Save CFLAGS given on command line.
322 gmp_user_CFLAGS="$CFLAGS"
323
324 if test -z "$CC"; then
325   # Find compiler.
326   GMP_PROG_CC_FIND($cclist, $os_64bit)
327
328   # If 64-bit OS and we have a 64-bit compiler, use it.
329   if test -n "$os_64bit" && test -n "$CC64"; then
330     CC=$CC64
331     CFLAGS=$CFLAGS64
332   else
333     eval CFLAGS=\$gmp_cflags_$CC  
334   fi
335
336   # Try compiler flags that may work with only some compiler versions.
337   # gmp_optcflags: All or nothing.
338   eval optcflags=\$gmp_optcflags_$CC
339   if test -n "$optcflags"; then
340     CFLAGS_save="$CFLAGS"
341     CFLAGS="$CFLAGS $optcflags"
342     AC_MSG_CHECKING([whether $CC accepts $optcflags])
343     AC_LANG_C
344     AC_TRY_COMPILER([int main(){return(0);}], optok, cross)
345     if test "$optok" = "yes"; then
346       AC_MSG_RESULT([yes])
347     else
348       AC_MSG_RESULT([no])
349       CFLAGS="$CFLAGS_save"
350     fi
351   fi
352   # gmp_xoptcflags: First is best, one has to work.
353   eval xoptcflags=\$gmp_xoptcflags_$CC
354   if test -n "$xoptcflags"; then
355     gmp_found="no"
356     for xopt in $xoptcflags; do
357       CFLAGS_save="$CFLAGS"
358       CFLAGS="$CFLAGS $xopt"
359       AC_MSG_CHECKING([whether $CC accepts $xopt])
360       AC_LANG_C
361       AC_TRY_COMPILER([int main(){return(0);}], optok, cross)
362       if test "$optok" = "yes"; then
363         AC_MSG_RESULT([yes])
364         gmp_found="yes"
365         break
366       else
367         AC_MSG_RESULT([no])
368         CFLAGS="$CFLAGS_save"
369       fi
370     done
371     if test "$gmp_found" = "no"; then
372       echo ["$0: fatal: need a compiler that understands one of $xoptcflags"]
373       exit 1
374     fi
375   fi
376 fi
377
378 # Restore CFLAGS given on command line.
379 # FIXME: We've run through quite some unnecessary code looking for a
380 # nice compiler and working flags for it, just to spoil that with user
381 # supplied flags.
382 test -n "$gmp_user_CFLAGS" && CFLAGS="$gmp_user_CFLAGS"
383
384 # Select chosen compiler.
385 GMP_PROG_CC_SELECT
386
387 # How to assemble.
388 CCAS="$CC -c"
389 AC_SUBST(CCAS)
390
391 dnl Checks for programs.
392 dnl --------------------
393 AC_PROG_CPP
394 AC_PROG_INSTALL
395 AC_PROG_LN_S
396 GMP_PROG_M4
397 AC_CHECK_PROG(AR, ar, ar)
398 # ar on AIX needs to know the object file format 
399 case "$target" in
400   powerpc64*-*-aix*)
401     AR="$AR -X 64"
402     ;;
403 esac   
404 dnl  FIXME: Find good ld?  /usr/ucb/ld on Solaris won't work.
405
406 dnl Checks for assembly syntax.
407 if test "$gmp_no_asm_syntax_testing" != "yes"; then
408   GMP_CHECK_ASM_TEXT
409   GMP_CHECK_ASM_DATA
410   GMP_CHECK_ASM_GLOBL
411   GMP_CHECK_ASM_LABEL_SUFFIX
412   GMP_CHECK_ASM_TYPE
413   GMP_CHECK_ASM_SIZE
414   GMP_CHECK_ASM_LSYM_PREFIX
415   GMP_CHECK_ASM_W32
416   GMP_CHECK_ASM_UNDERSCORE(underscore=yes, underscore=no)
417   GMP_CHECK_ASM_ALIGN_LOG(asm_align=log, asm_align=nolog)
418 fi
419
420 dnl  FIXME: Check for FPU and set `floating_point' appropriately.
421
422 dnl  ========================================
423 dnl  Configuring mpn.
424 dnl  ----------------------------------------
425 dnl  Set the following target specific variables:
426 dnl  path               where to search for source files
427 dnl  family             processor family (Needed for building 
428 dnl                     asm-syntax.h for now.  FIXME: Remove.)
429 dnl  extra_functions    extra functions
430
431 family=generic
432
433 case ${target} in
434   arm*-*-*)
435     path="arm"
436     ;;
437   [sparcv9*-*-solaris2.[789]* | sparc64*-*-solaris2.[789]* | ultrasparc*-*-solaris2.[789]*])
438     if test -n "$CC64"; then
439       path="sparc64"
440     else
441       path="sparc32/v9 sparc32/v8 sparc32"
442     fi
443     ;;
444   sparc64-*-linux*)
445     path="sparc64"
446     ;;
447   sparcv8*-*-* | microsparc*-*-*)
448         path="sparc32/v8 sparc32"
449         if test x${floating_point} = xno
450           then extra_functions="udiv_nfp"
451           else extra_functions="udiv_fp"
452         fi
453         ;;
454   sparcv9*-*-* | ultrasparc*-*-*)
455         path="sparc32/v9 sparc32/v8 sparc32"
456         extra_functions="udiv_fp"
457         ;;
458   supersparc*-*-*)
459         path="sparc32/v8/supersparc sparc32/v8 sparc32"
460         extra_functions="udiv"
461         ;;
462   sparc*-*-*) path="sparc32"
463         if test x${floating_point} = xno
464           then extra_functions="udiv_nfp"
465           else extra_functions="udiv_fp"
466         fi
467         ;;
468   hppa7000*-*-*)
469     path="hppa/hppa1_1 hppa"
470     extra_functions="udiv_qrnnd"
471     ;;
472   hppa1.0*-*-*)
473     path="hppa"
474     extra_functions="udiv_qrnnd"
475     ;;
476   hppa2.0w-*-*)
477     path="pa64w"
478     extra_functions="umul_ppmm udiv_qrnnd"
479     ;;
480   hppa2.0*-*-*)
481     if test -n "$CC64"; then
482       path="pa64"
483       extra_functions="umul_ppmm udiv_qrnnd"
484       # We need to use the system compiler, or actually the system assembler,
485       # since GAS has not been ported to understand the 2.0 instructions.
486       CCAS="$CC64 -c"
487     else
488       # FIXME: path should be "hppa/hppa2_0 hppa/hppa1_1 hppa"
489       path="hppa/hppa1_1 hppa"
490       extra_functions="udiv_qrnnd"
491     fi
492     ;;
493   hppa*-*-*)                                    #assume pa7100
494     path="hppa/hppa1_1/pa7100 hppa/hppa1_1 hppa"
495     extra_functions="udiv_qrnnd";;
496   [f30[01]-fujitsu-sysv*])
497     path=fujitsu;;
498   alphaev6*-*-*) path="alpha/ev6 alpha"; extra_functions="invert_limb cntlz";;
499   alphaev5*-*-*) path="alpha/ev5 alpha"; extra_functions="invert_limb cntlz";;
500   alpha*-*-*) path="alpha"; extra_functions="invert_limb cntlz";;
501   # Cray vector machines.  This must come after alpha* so that we can
502   # recognize present and future vector processors with a wildcard.
503   *-cray-unicos*)
504     path="cray"
505     extra_functions="mulww";;
506   am29000*-*-*) path="a29k";;
507   a29k*-*-*) path="a29k";;
508
509   # AMD and Intel x86 configurations
510
511   [i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*])
512     gmp_m4postinc="x86/x86-defs.m4"
513     extra_functions="udiv umul"
514     CALLING_CONVENTIONS_OBJS="x86call.o x86check.o"
515
516     GMP_CHECK_ASM_SHLDL_CL(
517       [GMP_DEFINE(WANT_SHLDL_CL,1)],
518       [GMP_DEFINE(WANT_SHLDL_CL,0)])
519     GMP_CHECK_ASM_ALIGN_FILL_0x90
520
521     # the CPUs below wanting to know about mmx
522     case ${target} in
523       [pentiummmx-*-* | pentium[23]-*-* | k6*-*-* | athlon-*-*])
524         GMP_CHECK_ASM_MMX(tmp_mmx=yes, tmp_mmx=no)
525         ;;
526     esac
527
528     # default for anything not otherwise mentioned
529     path="x86"
530  
531     case ${target} in
532       [i[34]86*-*-*])
533         path="x86"
534         ;;
535       k5*-*-*)
536         # don't know what best suits k5
537         path="x86"
538         ;;
539       i586*-*-* | pentium-*-*)
540         path="x86/pentium x86"
541         ;;
542       pentiummmx-*-*)
543         path="x86/pentium x86"
544         if test "$tmp_mmx" = yes; then
545           path="x86/pentium/mmx $path"
546         fi
547         ;;
548       i686*-*-* | pentiumpro-*-*)
549         path="x86/p6 x86"
550         ;;
551       pentium2-*-*)
552         path="x86/p6 x86"
553         # The pentium/mmx lshift and rshift are good on p6 and can be used
554         # until there's something specific for p6.
555         if test "$tmp_mmx" = yes; then
556           path="x86/p6/mmx x86/pentium/mmx $path"
557         fi
558         ;;
559       pentium3-*-*)
560         path="x86/p6 x86"
561         # The pentium/mmx lshift and rshift are good on p6 and can be used
562         # until there's something specific for p6.
563         if test "$tmp_mmx" = yes; then
564           path="x86/p6/p3mmx x86/p6/mmx x86/pentium/mmx $path"
565         fi
566         ;;
567       [k6[23]*-*-*])
568         path="x86/k6 x86"
569         if test "$tmp_mmx" = yes; then
570           path="x86/k6/k62mmx x86/k6/mmx $path"
571         fi
572         ;;
573       k6*-*-*)
574         path="x86/k6 x86"
575         if test "$tmp_mmx" = yes; then
576           path="x86/k6/mmx $path"
577         fi
578         ;;
579       athlon-*-*)
580         path="x86/k7 x86"
581         if test "$tmp_mmx" = yes; then
582           path="x86/k7/mmx $path"
583         fi
584         ;;
585     esac
586     ;;
587
588
589   i960*-*-*) path="i960";;
590
591   ia64*-*-*) path="ia64";;
592
593 # Motorola 68k configurations.  Let m68k mean 68020-68040.
594   [m680[234]0*-*-* | m68k*-*-* | \
595   m68*-next-nextstep*])         # Nexts are at least '020
596     path="m68k/mc68020 m68k"
597     family=m68k
598     ;;
599   m68000*-*-*)
600     path="m68k"
601     family=m68k
602     ;;
603
604   m88k*-*-* | m88k*-*-*) path="m88k";;
605   m88110*-*-*) path="m88k/mc88110 m88k";;
606   ns32k*-*-*) path="ns32k";;
607
608   pyramid-*-*) path="pyr";;
609
610   ppc601-*-*) path="power powerpc32";;
611   powerpc64*-*-*) path="powerpc64";;
612   powerpc*-*-*) path="powerpc32";;
613   rs6000-*-* | power-*-* | power2-*-*)
614     path="power"
615     extra_functions="udiv_w_sdiv"
616     ;;
617
618   sh-*-*) path="sh";;
619   sh2-*-*) path="sh/sh2 sh";;
620
621   [mips[34]*-*-*]) path="mips3";;
622   mips*-*-irix6*) path="mips3";;
623   mips*-*-*) path="mips2";;
624
625   vax*-*-*) path="vax"; extra_functions="udiv_w_sdiv";;
626
627   z8000x*-*-*) path="z8000x"; extra_functions="udiv_w_sdiv";;
628   z8000*-*-*) path="z8000"; extra_functions="udiv_w_sdiv";;
629
630   clipper*-*-*) path="clipper";;
631 esac
632
633 AC_SUBST(CALLING_CONVENTIONS_OBJS)
634 if test -n "$CALLING_CONVENTIONS_OBJS"; then
635   AC_DEFINE(HAVE_CALLING_CONVENTIONS,1,
636   [Define if mpn/tests has calling conventions checking for the CPU])
637 fi
638
639
640 case ${target} in
641   [i[5-8]86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*])
642     # rdtsc is in pentium and up, not in i386 and i486
643     SPEED_CYCLECOUNTER_OBJS=pentium.lo
644     ;;
645   alpha*-*-*)
646     SPEED_CYCLECOUNTER_OBJS=alpha.lo
647     ;;
648   sparcv9*-*-* | ultrasparc*-*-* | sparc64*-*-*)
649     SPEED_CYCLECOUNTER_OBJS=sparcv9.lo
650     ;;
651   hppa2*-*-*)
652     SPEED_CYCLECOUNTER_OBJS=hppa2.lo
653     ;;
654   hppa*-*-*)
655     SPEED_CYCLECOUNTER_OBJS=hppa.lo
656     ;;
657 esac
658
659 AC_SUBST(SPEED_CYCLECOUNTER_OBJS)
660
661 if test -n "$SPEED_CYCLECOUNTER_OBJS"
662 then
663   AC_DEFINE(HAVE_SPEED_CYCLECOUNTER, 1,
664   [Define if a speed_cyclecounter exists (for the tune programs)])
665 fi
666
667
668 dnl Extensions for executable and object files.
669 dnl -------------------------------------------
670 AC_EXEEXT
671 AC_OBJEXT
672
673 dnl Use Libtool.
674 dnl ------------
675 dnl  FIXME: Shared libs seem to fail on aix4.3.
676 dnl  FIXME: Should invoke [AC_DISABLE_SHARED], but m4 recurses to death.
677 case "$target" in
678   [*-*-aix4.[3-9]*]) enable_shared=no ;;
679 esac
680 AC_PROG_LIBTOOL
681
682 dnl Checks for libraries.
683 dnl ---------------------
684 AC_CHECK_DECLS((optarg))
685
686 dnl Checks for header files.
687 dnl ------------------------
688 AC_HEADER_STDC
689 AC_CHECK_HEADERS(getopt.h unistd.h sys/sysctl.h sys/time.h)
690
691 dnl Checks for typedefs, structures, and compiler characteristics.
692 dnl --------------------------------------------------------------
693 AC_CHECK_TYPES((void))
694 AC_C_STRINGIZE
695
696 dnl Checks for library functions.
697 dnl -----------------------------
698 dnl Most of these are only for the benefit of supplementary programs.  The
699 dnl library itself doesn't use anything weird.
700 dnl AC_FUNC_MEMCMP
701 dnl AC_TYPE_SIGNAL
702 dnl AC_CHECK_FUNCS(strtol)
703 AC_CHECK_FUNCS(getopt_long getpagesize popen processor_info strtoul sysconf sysctlbyname)
704
705 dnl Trick automake into thinking we've run AM_C_PROTOTYPES which it wants
706 dnl for ansi2knr, and instead use our own test.  (It's only a warning
707 dnl automake prints, but it's good to suppress it.)
708 ifelse(0,1,[
709 AM_C_PROTOTYPES
710 ])
711 GMP_C_ANSI2KNR
712
713
714 dnl  Set `syntax' to one of <blank>, "mit", "elf", "aix", "macho".
715 syntax=
716 # For now, we use the old switch for setting syntax.  
717 # FIXME: Remove when conversion to .asm is completed.
718 changequote(,)dnl
719 case "${target}" in
720   m680[234]0*-*-linuxaout* | m68k*-*-linuxaout* | \
721   m68k-next-nextstep* | \
722   m68000*-*-*)
723     syntax=mit
724     ;;
725   m680[234]0*-*-linux* | m68k*-*-linux*)
726     syntax=elf
727     ;;
728   m680[234]0*-*-* | m68k*-*-*)
729     syntax=mit
730     ;;
731 esac
732 changequote([,])dnl
733
734 dnl  ----------------------------------------
735 # Now build an asm-syntax.h file for targets that include that from the
736 # assembly files.
737 # FIXME: Remove when conversion to .asm is completed.
738 case "${family}-${underscore}-${asm_align}-${syntax}" in
739   m68k-yes-log-mit)
740     echo '#define MIT_SYNTAX' >asm-syntax.h
741     cat $srcdir/mpn/underscore.h >>asm-syntax.h
742     echo '#include "'$srcdir'/mpn/m68k/syntax.h"' >>asm-syntax.h;;
743   m68k-no-nolog-elf)
744     echo '#define ELF_SYNTAX' >asm-syntax.h
745     echo '#define C_SYMBOL_NAME(name) name' >>asm-syntax.h
746     echo '#include "'$srcdir'/mpn/m68k/syntax.h"' >>asm-syntax.h;;
747 esac
748
749
750 # The pattern here tests for an absolute path the same way as
751 # _AC_OUTPUT_FILES in autoconf acgeneral.m4.
752 GMP_DEFINE_RAW(["dnl  CONFIG_TOP_SRCDIR is a path from the mpn builddir to the top srcdir"])
753 case "$srcdir" in
754 [[\\/]]* | ?:[[\\/]]* )
755      GMP_DEFINE_RAW(["define(<CONFIG_TOP_SRCDIR>,<\`$srcdir'>)"])    ;;
756 *)   GMP_DEFINE_RAW(["define(<CONFIG_TOP_SRCDIR>,<\`../$srcdir'>)"]) ;;
757 esac
758  
759 GMP_DEFINE_RAW(["include(CONFIG_TOP_SRCDIR\`/mpn/asm-defs.m4')"], POST)
760
761 # Must be after asm-defs.m4
762 GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_TARGET_CPU_$target_cpu')", POST)
763
764
765 dnl  config.m4 post-includes
766 dnl  -----------------------
767 dnl  (Note x86 post include set with $path above.)
768 changequote(,)dnl
769 case "$target" in
770   alpha*-cray-unicos*)
771     gmp_m4postinc="alpha/unicos.m4"
772     ;;
773   alpha*-*-*)
774     gmp_m4postinc="alpha/default.m4"
775     ;;
776   power*-*-*)
777     case "$target" in
778       *-*-mach* | *-*-rhapsody* | *-*-nextstep*)
779         ;;      # these use non-conventional assembly syntax.
780       powerpc64-*-aix*)
781         gmp_m4postinc="powerpc32/regmap.m4 powerpc64/aix.m4"
782         ;;
783       *-*-aix*)
784         gmp_m4postinc="powerpc32/regmap.m4 powerpc32/aix.m4"
785         ;;
786       *)
787         gmp_m4postinc="powerpc32/regmap.m4"
788         ;;
789     esac
790     ;;
791 esac
792 changequote([, ])dnl
793
794 for tmp_f in $gmp_m4postinc; do
795   GMP_DEFINE_RAW(["include_mpn(\`$tmp_f')"], POST)
796 done
797
798
799 # Set up `gmp_links'.  It's a list of link:file pairs that configure will
800 # process to create link -> file.
801 gmp_links=
802
803 # If the user specified `MPN_PATH', use that instead of the path we've
804 # come up with.
805 if test -z "$MPN_PATH"; then
806   path="$path generic"
807 else
808   path="$MPN_PATH"
809 fi
810
811 # Pick the correct source files in $path and link them to mpn/.
812 # $gmp_mpn_functions lists all functions we need.
813 #
814 # The rule is to find a file with the function name and a .asm, .S,
815 # .s, or .c extension.  Certain multi-function files with special names
816 # can provide some functions too.  (mpn/Makefile.am passes
817 # -DOPERATION_<func> to get them to generate the right code.)
818
819 # FIXME: udiv and umul aren't in $gmp_mpn_functions_optional yet since
820 # there's some versions of those files which should be checked for bit
821 # rot first.  Put them in $extra_functions for each target for now,
822 # change to standard optionals when all are ready.
823
824 # Note: The following lines defining $gmp_mpn_functions_optional
825 #       and $gmp_mpn_functions are parsed by the "macos/configure"
826 #       Perl script. So if you change the lines in a major way
827 #       make sure to run and examine the output from
828 #       
829 #           % (cd macos; perl configure)
830
831 gmp_mpn_functions_optional="copyi copyd com_n           \
832   and_n andn_n nand_n ior_n iorn_n nior_n xor_n xnor_n"
833
834 gmp_mpn_functions="${extra_functions} inlines add_n sub_n mul_1 addmul_1   \
835   submul_1 lshift rshift diveby3 divrem divrem_1 divrem_2                  \
836   mod_1 mod_1_rs pre_mod_1 dump                                            \
837   mul mul_fft mul_n mul_basecase sqr_basecase random                       \
838   random2 sqrtrem get_str set_str scan0 scan1 popcount hamdist cmp perfsqr \
839   bdivmod gcd_1 gcd gcdext tdiv_qr bz_divrem_n sb_divrem_mn jacbase        \
840   $gmp_mpn_functions_optional"
841
842 # the list of all object files used by mpn/Makefile.in and the
843 # top-level Makefile.in, respectively
844 mpn_objects=
845 mpn_objs_in_libgmp="mpn/mp_bases.lo"
846
847 for tmp_fn in ${gmp_mpn_functions} ; do
848   [rm -f mpn/${tmp_fn}.[Ssc] mpn/${tmp_fn}.asm]
849
850   # functions that can be provided by multi-function files
851   tmp_mulfunc=
852   case $tmp_fn in
853   add_n|sub_n)       tmp_mulfunc="aors_n"    ;;
854   addmul_1|submul_1) tmp_mulfunc="aorsmul_1" ;;
855   popcount|hamdist)  tmp_mulfunc="popham"    ;;
856   and_n|andn_n|nand_n | ior_n|iorn_n|nior_n | xor_n|xnor_n)
857                      tmp_mulfunc="logops_n"  ;;
858   esac
859
860   found=no
861   for tmp_dir in $path; do
862     for tmp_base in $tmp_fn $tmp_mulfunc; do
863       for tmp_ext in asm S s c; do
864         tmp_file=$srcdir/mpn/$tmp_dir/$tmp_base.$tmp_ext
865         if test -f $tmp_file; then
866           found=yes
867
868           mpn_objects="$mpn_objects ${tmp_fn}.lo"
869           mpn_objs_in_libgmp="$mpn_objs_in_libgmp mpn/${tmp_fn}.lo"
870           gmp_links="$gmp_links mpn/$tmp_fn.$tmp_ext:mpn/$tmp_dir/$tmp_base.$tmp_ext"
871
872           # duplicate AC_DEFINEs are harmless, so it doesn't matter
873           # that multi-function files get grepped here repeatedly
874           gmp_ep=["`
875             sed -n 's/^[        ]*MULFUNC_PROLOGUE(\(.*\))/\1/p' $tmp_file ;
876             sed -n 's/^[        ]*PROLOGUE(\(.*\))/\1/p' $tmp_file
877           `"]
878           for gmp_tmp in $gmp_ep; do
879             AC_DEFINE_UNQUOTED(HAVE_NATIVE_${gmp_tmp})
880           done
881
882           break
883         fi
884       done
885       if test $found = yes; then break ; fi
886     done
887     if test $found = yes; then break ; fi
888   done
889
890   if test $found = no; then
891     for tmp_optional in $gmp_mpn_functions_optional; do
892       if test $tmp_optional = $tmp_fn; then
893         found=yes
894       fi
895     done
896     if test $found = no; then
897       AC_MSG_ERROR([no version of $tmp_fn found in path: $path])
898     fi
899   fi
900 done
901
902 # Create link for gmp-mparam.h.
903 for tmp_dir in $path ; do
904   rm -f gmp-mparam.h
905   if test -f $srcdir/mpn/${tmp_dir}/gmp-mparam.h ; then
906     gmp_links="$gmp_links gmp-mparam.h:mpn/${tmp_dir}/gmp-mparam.h"
907
908     # Copy any KARATSUBA_SQR_THRESHOLD in gmp-mparam.h to config.m4.
909     # Some versions of sqr_basecase.asm use this.
910     tmp_gmp_karatsuba_sqr_threshold="`sed -n 's/^#define KARATSUBA_SQR_THRESHOLD[       ]*\([0-9][0-9]*\).*$/\1/p' $srcdir/mpn/${tmp_dir}/gmp-mparam.h`"
911     if test -n "$tmp_gmp_karatsuba_sqr_threshold"; then
912       GMP_DEFINE_RAW(["define(<KARATSUBA_SQR_THRESHOLD>,<$tmp_gmp_karatsuba_sqr_threshold>)"])
913     fi
914
915     break
916   fi
917 done
918
919 # Dig out the links from `gmp_links' for inclusion in DISTCLEANFILES.
920 gmp_srclinks=
921 for f in $gmp_links; do
922   gmp_srclinks="$gmp_srclinks `echo $f | sed 's/\(.*\):.*/\1/'`"
923 done
924
925 AC_SUBST(mpn_objects)
926 AC_SUBST(mpn_objs_in_libgmp)
927 AC_SUBST(gmp_srclinks)
928
929 dnl  ----------------------------------------
930 dnl  Make links.
931 AC_CONFIG_LINKS($gmp_links)
932
933 dnl  Create config.m4.
934 GMP_FINISH
935
936 dnl  Create Makefiles
937 dnl  FIXME: Upcoming version of autoconf/automake may not like broken lines.
938 AC_OUTPUT(Makefile mpf/Makefile mpz/Makefile mpn/Makefile mpq/Makefile \
939   mpf/tests/Makefile mpz/tests/Makefile mpq/tests/Makefile mpn/tests/Makefile \
940   tests/Makefile tests/rand/Makefile demos/Makefile tune/Makefile \
941   mpbsd/Makefile mpbsd/tests/Makefile mpfr/Makefile mpfr/tests/Makefile)