remove empty dir
[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.8 $)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     # Need to think more about the options passed here.  This isn't good for
199     # some sparc64 linux distros, since we end up not optimizing when all the
200     # options below fail.
201     os_64bit=yes
202     gmp_cflags64_gcc="$gmp_cflags64_gcc -m64 -mptr64 -Wa,-xarch=v9 -mcpu=v9"
203     gmp_cflags_gcc="$gmp_cflags_gcc -m32"
204     gmp_xoptflags_gcc="-mcpu=ultrasparc -mvis"
205     ;;
206   ultrasparc*-*-* | sparcv9-*-*)
207     gmp_cflags_gcc="$gmp_cflags_gcc -Wa,-xarch=v8plus"
208     gmp_xoptcflags_gcc="-mcpu=v9 -mcpu=v8 -mv8"
209     gmp_cflags_cc="-xtarget=native -xarch=v8 -xO4"
210     ;;
211   sparcv8*-*-solaris2.* | microsparc*-*-solaris2.*)
212     gmp_cflags_gcc="$gmp_cflags_gcc"
213     gmp_xoptcflags_gcc="-mcpu=v8 -mv8"
214     gmp_cflags_cc="-xtarget=native -xarch=v8 -xO4"
215     ;;
216   sparcv8*-*-* | microsparc*-*-*)               # SunOS, Linux, *BSD
217     cclist="gcc acc cc"
218     gmp_cflags_gcc="$gmp_cflags_gcc"
219     gmp_xoptcflags_gcc="-mcpu=v8 -mv8"
220     gmp_cflags_acc="-g -O2 -cg92"
221     gmp_cflags_cc="-O2"         # FIXME: Flag for v8?
222     ;;
223   supersparc*-*-solaris2.*)
224     gmp_cflags_gcc="$gmp_cflags_gcc -DSUPERSPARC"
225     gmp_xoptcflags_gcc="-mcpu=v8 -mv8"
226     gmp_cflags_cc="-xtarget=native -xarch=v8 -xO4 -DSUPERSPARC"
227     ;;
228   supersparc*-*-*)              # SunOS, Linux, *BSD
229     cclist="gcc acc cc"
230     gmp_cflags_gcc="$gmp_cflags_gcc -DSUPERSPARC"
231     gmp_xoptcflags_gcc="-mcpu=v8 -mv8"
232     gmp_cflags_acc="-g -O2 -cg92 -DSUPERSPARC"
233     gmp_cflags_cc="-O2 -DSUPERSPARC"    # FIXME: Flag for v8?
234     ;;
235   *sparc*-*-*)
236     cclist="gcc acc cc"
237     gmp_cflags_acc="-g -O2"
238     gmp_cflags_cc="-g -O2"
239     ;;
240
241   # POWER/PowerPC
242   powerpc64-*-aix*)
243     cclist="gcc xlc"
244     gmp_cflags_gcc="$gmp_cflags_gcc -maix64 -mpowerpc64"
245     gmp_cflags_xlc="-g -O2 -q64 -qtune=pwr3"
246     ;;
247   powerpc*-*-aix*)
248     cclist="gcc xlc"
249     gmp_cflags_gcc="$gmp_cflags_gcc -mpowerpc"
250     gmp_cflags_xlc="$gmp_cflags_cc -qarch=ppc -O2"
251     ;;
252   power-*-aix*)
253     cclist="gcc xlc"
254     gmp_cflags_gcc="$gmp_cflags_gcc -mpower"
255     gmp_cflags_xlc="$gmp_cflags_cc -qarch=pwr -O2"
256     ;;
257   powerpc64*-*-*)
258     gmp_cflags_gcc="$gmp_cflags_gcc -mpowerpc64"
259     AC_DEFINE(_LONG_LONG_LIMB)  dnl FIXME: Remove.
260     ;;
261   powerpc-apple-darwin* | powerpc-apple-macosx*)
262     gmp_cflags_gcc="$gmp_cflags_gcc -mpowerpc -traditional-cpp"
263     ;;
264   powerpc*-*-*)
265     gmp_cflags_gcc="$gmp_cflags_gcc -mpowerpc"
266     ;;
267
268   # MIPS
269   mips-sgi-irix6.*)
270     os_64bit=yes
271     gmp_cflags64_gcc="-g -O2 -mabi=n32"
272     gmp_cflags64_cc="$gmp_cflags64_cc -O2 -n32"
273     ;;
274
275   # Motorola 68k family
276   m88110*-*-*)
277     gmp_cflags_gcc="-g -O -m88110"      dnl  FIXME: Use `-O2'?
278     ;;
279   m68*-*-*)
280     gmp_cflags_gcc="$gmp_cflags_gcc -fomit-frame-pointer"
281     ;;
282
283   # HP
284   hppa1.0*-*-*)
285     cclist="gcc c89 cc"
286     gmp_cflags_c89="$gmp_cflags_cc +O2"
287     gmp_cflags_cc="$gmp_cflags_cc +O2"
288     ;;
289   hppa2.0w*-*-*)
290     cclist="c89 cc"
291     gmp_cflags_c89="+DD64 +O3"
292     gmp_cflags_cc="+DD64 +O3"
293     ;;
294   hppa2.0*-*-*)
295     os_64bit=yes
296     cclist="gcc c89 cc"
297     gmp_cflags64_gcc="$gmp_cflags64_gcc -mWHAT -D_LONG_LONG_LIMB"
298     # +O2 to cc triggers bug in mpz/powm.c (1.4)
299     gmp_cflags64_c89="+DA2.0 +e +O3 -D_LONG_LONG_LIMB"
300     gmp_cflags64_cc="+DA2.0 +e +O3 -D_LONG_LONG_LIMB"
301     gmp_cflags_c89="$gmp_cflags_cc +O2"
302     gmp_cflags_cc="$gmp_cflags_cc +O2"
303     ;;
304
305   # VAX
306   vax*-*-*)
307     gmp_cflags_gcc="$gmp_cflags_gcc -fomit-frame-pointer"
308     ;;
309
310   # Fujitsu
311   [f30[01]-fujitsu-sysv*])
312     cclist="gcc vcc"
313     gmp_cflags_vcc="-g"         # FIXME: flags for vcc?
314     ;;
315 esac
316
317 case "${target}" in
318   *-*-mingw32) gmp_cflags_gcc="$gmp_cflags_gcc -mno-cygwin";;
319 esac
320
321 dnl  Check for programs needed by macros for finding compiler.
322 dnl  More programs are checked for below, when a compiler is found.
323 AC_PROG_NM      dnl  Macro from Libtool.
324 # nm on 64-bit AIX needs to know the object file format 
325 case "$target" in
326   powerpc64*-*-aix*)
327     NM="$NM -X 64"
328     ;;
329 esac   
330
331 # Save CFLAGS given on command line.
332 gmp_user_CFLAGS="$CFLAGS"
333
334 if test -z "$CC"; then
335   # Find compiler.
336   GMP_PROG_CC_FIND($cclist, $os_64bit)
337
338   # If 64-bit OS and we have a 64-bit compiler, use it.
339   if test -n "$os_64bit" && test -n "$CC64"; then
340     CC=$CC64
341     CFLAGS=$CFLAGS64
342   else
343     eval CFLAGS=\$gmp_cflags_$CC  
344   fi
345
346   # Try compiler flags that may work with only some compiler versions.
347   # gmp_optcflags: All or nothing.
348   eval optcflags=\$gmp_optcflags_$CC
349   if test -n "$optcflags"; then
350     CFLAGS_save="$CFLAGS"
351     CFLAGS="$CFLAGS $optcflags"
352     AC_MSG_CHECKING([whether $CC accepts $optcflags])
353     AC_LANG_C
354     AC_TRY_COMPILER([int main(){return(0);}], optok, cross)
355     if test "$optok" = "yes"; then
356       AC_MSG_RESULT([yes])
357     else
358       AC_MSG_RESULT([no])
359       CFLAGS="$CFLAGS_save"
360     fi
361   fi
362   # gmp_xoptcflags: First is best, one has to work.
363   eval xoptcflags=\$gmp_xoptcflags_$CC
364   if test -n "$xoptcflags"; then
365     gmp_found="no"
366     for xopt in $xoptcflags; do
367       CFLAGS_save="$CFLAGS"
368       CFLAGS="$CFLAGS $xopt"
369       AC_MSG_CHECKING([whether $CC accepts $xopt])
370       AC_LANG_C
371       AC_TRY_COMPILER([int main(){return(0);}], optok, cross)
372       if test "$optok" = "yes"; then
373         AC_MSG_RESULT([yes])
374         gmp_found="yes"
375         break
376       else
377         AC_MSG_RESULT([no])
378         CFLAGS="$CFLAGS_save"
379       fi
380     done
381     if test "$gmp_found" = "no"; then
382       echo ["$0: fatal: need a compiler that understands one of $xoptcflags"]
383       exit 1
384     fi
385   fi
386 fi
387
388 # Restore CFLAGS given on command line.
389 # FIXME: We've run through quite some unnecessary code looking for a
390 # nice compiler and working flags for it, just to spoil that with user
391 # supplied flags.
392 test -n "$gmp_user_CFLAGS" && CFLAGS="$gmp_user_CFLAGS"
393
394 # Select chosen compiler.
395 GMP_PROG_CC_SELECT
396
397 # How to assemble.
398 CCAS="$CC -c"
399 AC_SUBST(CCAS)
400
401 dnl Checks for programs.
402 dnl --------------------
403 AC_PROG_CPP
404 AC_PROG_INSTALL
405 AC_PROG_LN_S
406 GMP_PROG_M4
407 AC_CHECK_PROG(AR, ar, ar)
408 # ar on AIX needs to know the object file format 
409 case "$target" in
410   powerpc64*-*-aix*)
411     AR="$AR -X 64"
412     ;;
413 esac   
414 dnl  FIXME: Find good ld?  /usr/ucb/ld on Solaris won't work.
415
416 dnl Checks for assembly syntax.
417 if test "$gmp_no_asm_syntax_testing" != "yes"; then
418   GMP_CHECK_ASM_TEXT
419   GMP_CHECK_ASM_DATA
420   GMP_CHECK_ASM_GLOBL
421   GMP_CHECK_ASM_LABEL_SUFFIX
422   GMP_CHECK_ASM_TYPE
423   GMP_CHECK_ASM_SIZE
424   GMP_CHECK_ASM_LSYM_PREFIX
425   GMP_CHECK_ASM_W32
426   GMP_CHECK_ASM_UNDERSCORE(underscore=yes, underscore=no)
427   GMP_CHECK_ASM_ALIGN_LOG(asm_align=log, asm_align=nolog)
428 fi
429
430 dnl  FIXME: Check for FPU and set `floating_point' appropriately.
431
432 dnl  ========================================
433 dnl  Configuring mpn.
434 dnl  ----------------------------------------
435 dnl  Set the following target specific variables:
436 dnl  path               where to search for source files
437 dnl  family             processor family (Needed for building 
438 dnl                     asm-syntax.h for now.  FIXME: Remove.)
439 dnl  extra_functions    extra functions
440
441 family=generic
442
443 case ${target} in
444   arm*-*-*)
445     path="arm"
446     ;;
447   [sparcv9*-*-solaris2.[789]* | sparc64*-*-solaris2.[789]* | ultrasparc*-*-solaris2.[789]*])
448     if test -n "$CC64"
449       then path="sparc64"
450       else path="sparc32/v9 sparc32/v8 sparc32"
451     fi
452     ;;
453   sparc64-*-linux*)
454     if test -n "$CC64"
455       then path="sparc64"
456       else path="sparc32/v9 sparc32/v8 sparc32"
457     fi
458     ;;
459   sparcv8*-*-* | microsparc*-*-*)
460         path="sparc32/v8 sparc32"
461         if test x${floating_point} = xno
462           then extra_functions="udiv_nfp"
463           else extra_functions="udiv_fp"
464         fi
465         ;;
466   sparcv9*-*-* | ultrasparc*-*-*)
467         path="sparc32/v9 sparc32/v8 sparc32"
468         extra_functions="udiv_fp"
469         ;;
470   supersparc*-*-*)
471         path="sparc32/v8/supersparc sparc32/v8 sparc32"
472         extra_functions="udiv"
473         ;;
474   sparc*-*-*) path="sparc32"
475         if test x${floating_point} = xno
476           then extra_functions="udiv_nfp"
477           else extra_functions="udiv_fp"
478         fi
479         ;;
480   hppa7000*-*-*)
481     path="hppa/hppa1_1 hppa"
482     extra_functions="udiv_qrnnd"
483     ;;
484   hppa1.0*-*-*)
485     path="hppa"
486     extra_functions="udiv_qrnnd"
487     ;;
488   hppa2.0w-*-*)
489     path="pa64w"
490     extra_functions="umul_ppmm udiv_qrnnd"
491     ;;
492   hppa2.0*-*-*)
493     if test -n "$CC64"; then
494       path="pa64"
495       extra_functions="umul_ppmm udiv_qrnnd"
496       # We need to use the system compiler, or actually the system assembler,
497       # since GAS has not been ported to understand the 2.0 instructions.
498       CCAS="$CC64 -c"
499     else
500       # FIXME: path should be "hppa/hppa2_0 hppa/hppa1_1 hppa"
501       path="hppa/hppa1_1 hppa"
502       extra_functions="udiv_qrnnd"
503     fi
504     ;;
505   hppa*-*-*)                                    #assume pa7100
506     path="hppa/hppa1_1/pa7100 hppa/hppa1_1 hppa"
507     extra_functions="udiv_qrnnd";;
508   [f30[01]-fujitsu-sysv*])
509     path=fujitsu;;
510   alphaev6*-*-*) path="alpha/ev6 alpha"; extra_functions="invert_limb cntlz";;
511   alphaev5*-*-*) path="alpha/ev5 alpha"; extra_functions="invert_limb cntlz";;
512   alpha*-*-*) path="alpha"; extra_functions="invert_limb cntlz";;
513   # Cray vector machines.  This must come after alpha* so that we can
514   # recognize present and future vector processors with a wildcard.
515   *-cray-unicos*)
516     path="cray"
517     extra_functions="mulww";;
518   am29000*-*-*) path="a29k";;
519   a29k*-*-*) path="a29k";;
520
521   # AMD and Intel x86 configurations
522
523   [i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*])
524     gmp_m4postinc="x86/x86-defs.m4"
525     extra_functions="udiv umul"
526     CALLING_CONVENTIONS_OBJS="x86call.o x86check.o"
527
528     GMP_CHECK_ASM_SHLDL_CL(
529       [GMP_DEFINE(WANT_SHLDL_CL,1)],
530       [GMP_DEFINE(WANT_SHLDL_CL,0)])
531     GMP_CHECK_ASM_ALIGN_FILL_0x90
532
533     # the CPUs below wanting to know about mmx
534     case ${target} in
535       [pentiummmx-*-* | pentium[23]-*-* | k6*-*-* | athlon-*-*])
536         GMP_CHECK_ASM_MMX(tmp_mmx=yes, tmp_mmx=no)
537         ;;
538     esac
539
540     # default for anything not otherwise mentioned
541     path="x86"
542  
543     case ${target} in
544       [i[34]86*-*-*])
545         path="x86"
546         ;;
547       k5*-*-*)
548         # don't know what best suits k5
549         path="x86"
550         ;;
551       i586*-*-* | pentium-*-*)
552         path="x86/pentium x86"
553         ;;
554       pentiummmx-*-*)
555         path="x86/pentium x86"
556         if test "$tmp_mmx" = yes; then
557           path="x86/pentium/mmx $path"
558         fi
559         ;;
560       i686*-*-* | pentiumpro-*-*)
561         path="x86/p6 x86"
562         ;;
563       pentium2-*-*)
564         path="x86/p6 x86"
565         # The pentium/mmx lshift and rshift are good on p6 and can be used
566         # until there's something specific for p6.
567         if test "$tmp_mmx" = yes; then
568           path="x86/p6/mmx x86/pentium/mmx $path"
569         fi
570         ;;
571       pentium3-*-*)
572         path="x86/p6 x86"
573         # The pentium/mmx lshift and rshift are good on p6 and can be used
574         # until there's something specific for p6.
575         if test "$tmp_mmx" = yes; then
576           path="x86/p6/p3mmx x86/p6/mmx x86/pentium/mmx $path"
577         fi
578         ;;
579       [k6[23]*-*-*])
580         path="x86/k6 x86"
581         if test "$tmp_mmx" = yes; then
582           path="x86/k6/k62mmx x86/k6/mmx $path"
583         fi
584         ;;
585       k6*-*-*)
586         path="x86/k6 x86"
587         if test "$tmp_mmx" = yes; then
588           path="x86/k6/mmx $path"
589         fi
590         ;;
591       athlon-*-*)
592         path="x86/k7 x86"
593         if test "$tmp_mmx" = yes; then
594           path="x86/k7/mmx $path"
595         fi
596         ;;
597     esac
598     ;;
599
600
601   i960*-*-*) path="i960";;
602
603   ia64*-*-*) path="ia64";;
604
605 # Motorola 68k configurations.  Let m68k mean 68020-68040.
606   [m680[234]0*-*-* | m68k*-*-* | \
607   m68*-next-nextstep*])         # Nexts are at least '020
608     path="m68k/mc68020 m68k"
609     family=m68k
610     ;;
611   m68000*-*-*)
612     path="m68k"
613     family=m68k
614     ;;
615
616   m88k*-*-* | m88k*-*-*) path="m88k";;
617   m88110*-*-*) path="m88k/mc88110 m88k";;
618   ns32k*-*-*) path="ns32k";;
619
620   pyramid-*-*) path="pyr";;
621
622   ppc601-*-*) path="power powerpc32";;
623   powerpc64*-*-*) path="powerpc64";;
624   powerpc*-*-*) path="powerpc32";;
625   rs6000-*-* | power-*-* | power2-*-*)
626     path="power"
627     extra_functions="udiv_w_sdiv"
628     ;;
629
630   sh-*-*) path="sh";;
631   sh2-*-*) path="sh/sh2 sh";;
632
633   [mips[34]*-*-*]) path="mips3";;
634   mips*-*-irix6*) path="mips3";;
635   mips*-*-*) path="mips2";;
636
637   vax*-*-*) path="vax"; extra_functions="udiv_w_sdiv";;
638
639   z8000x*-*-*) path="z8000x"; extra_functions="udiv_w_sdiv";;
640   z8000*-*-*) path="z8000"; extra_functions="udiv_w_sdiv";;
641
642   clipper*-*-*) path="clipper";;
643 esac
644
645 AC_SUBST(CALLING_CONVENTIONS_OBJS)
646 if test -n "$CALLING_CONVENTIONS_OBJS"; then
647   AC_DEFINE(HAVE_CALLING_CONVENTIONS,1,
648   [Define if mpn/tests has calling conventions checking for the CPU])
649 fi
650
651
652 case ${target} in
653   [i[5-8]86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*])
654     # rdtsc is in pentium and up, not in i386 and i486
655     SPEED_CYCLECOUNTER_OBJS=pentium.lo
656     ;;
657   alpha*-*-*)
658     SPEED_CYCLECOUNTER_OBJS=alpha.lo
659     ;;
660   sparcv9*-*-* | ultrasparc*-*-* | sparc64*-*-*)
661     SPEED_CYCLECOUNTER_OBJS=sparcv9.lo
662     ;;
663   hppa2*-*-*)
664     SPEED_CYCLECOUNTER_OBJS=hppa2.lo
665     ;;
666   hppa*-*-*)
667     SPEED_CYCLECOUNTER_OBJS=hppa.lo
668     ;;
669 esac
670
671 AC_SUBST(SPEED_CYCLECOUNTER_OBJS)
672
673 if test -n "$SPEED_CYCLECOUNTER_OBJS"
674 then
675   AC_DEFINE(HAVE_SPEED_CYCLECOUNTER, 1,
676   [Define if a speed_cyclecounter exists (for the tune programs)])
677 fi
678
679
680 dnl Extensions for executable and object files.
681 dnl -------------------------------------------
682 AC_EXEEXT
683 AC_OBJEXT
684
685 dnl Use Libtool.
686 dnl ------------
687 dnl  FIXME: Shared libs seem to fail on aix4.3.
688 dnl  FIXME: Should invoke [AC_DISABLE_SHARED], but m4 recurses to death.
689 case "$target" in
690   [*-*-aix4.[3-9]*]) enable_shared=no ;;
691 esac
692 AC_PROG_LIBTOOL
693
694 dnl Checks for libraries.
695 dnl ---------------------
696 AC_CHECK_DECLS((optarg))
697
698 dnl Checks for header files.
699 dnl ------------------------
700 AC_HEADER_STDC
701 AC_CHECK_HEADERS(getopt.h unistd.h sys/sysctl.h sys/time.h)
702
703 dnl Checks for typedefs, structures, and compiler characteristics.
704 dnl --------------------------------------------------------------
705 AC_CHECK_TYPES((void))
706 AC_C_STRINGIZE
707
708 dnl Checks for library functions.
709 dnl -----------------------------
710 dnl Most of these are only for the benefit of supplementary programs.  The
711 dnl library itself doesn't use anything weird.
712 dnl AC_FUNC_MEMCMP
713 dnl AC_TYPE_SIGNAL
714 dnl AC_CHECK_FUNCS(strtol)
715 AC_CHECK_FUNCS(getopt_long getpagesize popen processor_info strtoul sysconf sysctlbyname)
716
717 dnl Trick automake into thinking we've run AM_C_PROTOTYPES which it wants
718 dnl for ansi2knr, and instead use our own test.  (It's only a warning
719 dnl automake prints, but it's good to suppress it.)
720 ifelse(0,1,[
721 AM_C_PROTOTYPES
722 ])
723 GMP_C_ANSI2KNR
724
725
726 dnl  Set `syntax' to one of <blank>, "mit", "elf", "aix", "macho".
727 syntax=
728 # For now, we use the old switch for setting syntax.  
729 # FIXME: Remove when conversion to .asm is completed.
730 changequote(,)dnl
731 case "${target}" in
732   m680[234]0*-*-linuxaout* | m68k*-*-linuxaout* | \
733   m68k-next-nextstep* | \
734   m68000*-*-*)
735     syntax=mit
736     ;;
737   m680[234]0*-*-linux* | m68k*-*-linux*)
738     syntax=elf
739     ;;
740   m680[234]0*-*-* | m68k*-*-*)
741     syntax=mit
742     ;;
743 esac
744 changequote([,])dnl
745
746 dnl  ----------------------------------------
747 # Now build an asm-syntax.h file for targets that include that from the
748 # assembly files.
749 # FIXME: Remove when conversion to .asm is completed.
750 case "${family}-${underscore}-${asm_align}-${syntax}" in
751   m68k-yes-log-mit)
752     echo '#define MIT_SYNTAX' >asm-syntax.h
753     cat $srcdir/mpn/underscore.h >>asm-syntax.h
754     echo '#include "'$srcdir'/mpn/m68k/syntax.h"' >>asm-syntax.h;;
755   m68k-no-nolog-elf)
756     echo '#define ELF_SYNTAX' >asm-syntax.h
757     echo '#define C_SYMBOL_NAME(name) name' >>asm-syntax.h
758     echo '#include "'$srcdir'/mpn/m68k/syntax.h"' >>asm-syntax.h;;
759 esac
760
761
762 # The pattern here tests for an absolute path the same way as
763 # _AC_OUTPUT_FILES in autoconf acgeneral.m4.
764 GMP_DEFINE_RAW(["dnl  CONFIG_TOP_SRCDIR is a path from the mpn builddir to the top srcdir"])
765 case "$srcdir" in
766 [[\\/]]* | ?:[[\\/]]* )
767      GMP_DEFINE_RAW(["define(<CONFIG_TOP_SRCDIR>,<\`$srcdir'>)"])    ;;
768 *)   GMP_DEFINE_RAW(["define(<CONFIG_TOP_SRCDIR>,<\`../$srcdir'>)"]) ;;
769 esac
770  
771 GMP_DEFINE_RAW(["include(CONFIG_TOP_SRCDIR\`/mpn/asm-defs.m4')"], POST)
772
773 # Must be after asm-defs.m4
774 GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_TARGET_CPU_$target_cpu')", POST)
775
776
777 dnl  config.m4 post-includes
778 dnl  -----------------------
779 dnl  (Note x86 post include set with $path above.)
780 changequote(,)dnl
781 case "$target" in
782   alpha*-cray-unicos*)
783     gmp_m4postinc="alpha/unicos.m4"
784     ;;
785   alpha*-*-*)
786     gmp_m4postinc="alpha/default.m4"
787     ;;
788   power*-*-*)
789     case "$target" in
790       *-*-mach* | *-*-rhapsody* | *-*-nextstep* | *-*-darwin* | *-*-macosx*)
791         ;;      # these use non-conventional assembly syntax.
792       powerpc64-*-aix*)
793         gmp_m4postinc="powerpc32/regmap.m4 powerpc64/aix.m4"
794         ;;
795       *-*-aix*)
796         gmp_m4postinc="powerpc32/regmap.m4 powerpc32/aix.m4"
797         ;;
798       *)
799         gmp_m4postinc="powerpc32/regmap.m4"
800         ;;
801     esac
802     ;;
803 esac
804 changequote([, ])dnl
805
806 for tmp_f in $gmp_m4postinc; do
807   GMP_DEFINE_RAW(["include_mpn(\`$tmp_f')"], POST)
808 done
809
810
811 # Set up `gmp_links'.  It's a list of link:file pairs that configure will
812 # process to create link -> file.
813 gmp_links=
814
815 # If the user specified `MPN_PATH', use that instead of the path we've
816 # come up with.
817 if test -z "$MPN_PATH"; then
818   path="$path generic"
819 else
820   path="$MPN_PATH"
821 fi
822
823 # Pick the correct source files in $path and link them to mpn/.
824 # $gmp_mpn_functions lists all functions we need.
825 #
826 # The rule is to find a file with the function name and a .asm, .S,
827 # .s, or .c extension.  Certain multi-function files with special names
828 # can provide some functions too.  (mpn/Makefile.am passes
829 # -DOPERATION_<func> to get them to generate the right code.)
830
831 # FIXME: udiv and umul aren't in $gmp_mpn_functions_optional yet since
832 # there's some versions of those files which should be checked for bit
833 # rot first.  Put them in $extra_functions for each target for now,
834 # change to standard optionals when all are ready.
835
836 # Note: The following lines defining $gmp_mpn_functions_optional
837 #       and $gmp_mpn_functions are parsed by the "macos/configure"
838 #       Perl script. So if you change the lines in a major way
839 #       make sure to run and examine the output from
840 #       
841 #           % (cd macos; perl configure)
842
843 gmp_mpn_functions_optional="copyi copyd com_n           \
844   and_n andn_n nand_n ior_n iorn_n nior_n xor_n xnor_n"
845
846 gmp_mpn_functions="${extra_functions} inlines add_n sub_n mul_1 addmul_1   \
847   submul_1 lshift rshift diveby3 divrem divrem_1 divrem_2                  \
848   mod_1 mod_1_rs pre_mod_1 dump                                            \
849   mul mul_fft mul_n mul_basecase sqr_basecase random                       \
850   random2 sqrtrem get_str set_str scan0 scan1 popcount hamdist cmp perfsqr \
851   bdivmod gcd_1 gcd gcdext tdiv_qr bz_divrem_n sb_divrem_mn jacbase        \
852   $gmp_mpn_functions_optional"
853
854 # the list of all object files used by mpn/Makefile.in and the
855 # top-level Makefile.in, respectively
856 mpn_objects=
857 mpn_objs_in_libgmp="mpn/mp_bases.lo"
858
859 for tmp_fn in ${gmp_mpn_functions} ; do
860   [rm -f mpn/${tmp_fn}.[Ssc] mpn/${tmp_fn}.asm]
861
862   # functions that can be provided by multi-function files
863   tmp_mulfunc=
864   case $tmp_fn in
865   add_n|sub_n)       tmp_mulfunc="aors_n"    ;;
866   addmul_1|submul_1) tmp_mulfunc="aorsmul_1" ;;
867   popcount|hamdist)  tmp_mulfunc="popham"    ;;
868   and_n|andn_n|nand_n | ior_n|iorn_n|nior_n | xor_n|xnor_n)
869                      tmp_mulfunc="logops_n"  ;;
870   esac
871
872   found=no
873   for tmp_dir in $path; do
874     for tmp_base in $tmp_fn $tmp_mulfunc; do
875       for tmp_ext in asm S s c; do
876         tmp_file=$srcdir/mpn/$tmp_dir/$tmp_base.$tmp_ext
877         if test -f $tmp_file; then
878           found=yes
879
880           mpn_objects="$mpn_objects ${tmp_fn}.lo"
881           mpn_objs_in_libgmp="$mpn_objs_in_libgmp mpn/${tmp_fn}.lo"
882           gmp_links="$gmp_links mpn/$tmp_fn.$tmp_ext:mpn/$tmp_dir/$tmp_base.$tmp_ext"
883
884           # duplicate AC_DEFINEs are harmless, so it doesn't matter
885           # that multi-function files get grepped here repeatedly
886           gmp_ep=["`
887             sed -n 's/^[        ]*MULFUNC_PROLOGUE(\(.*\))/\1/p' $tmp_file ;
888             sed -n 's/^[        ]*PROLOGUE.*(\(.*\))/\1/p' $tmp_file
889           `"]
890           for gmp_tmp in $gmp_ep; do
891             AC_DEFINE_UNQUOTED(HAVE_NATIVE_${gmp_tmp})
892           done
893
894           break
895         fi
896       done
897       if test $found = yes; then break ; fi
898     done
899     if test $found = yes; then break ; fi
900   done
901
902   if test $found = no; then
903     for tmp_optional in $gmp_mpn_functions_optional; do
904       if test $tmp_optional = $tmp_fn; then
905         found=yes
906       fi
907     done
908     if test $found = no; then
909       AC_MSG_ERROR([no version of $tmp_fn found in path: $path])
910     fi
911   fi
912 done
913
914 # Create link for gmp-mparam.h.
915 for tmp_dir in $path ; do
916   rm -f gmp-mparam.h
917   if test -f $srcdir/mpn/${tmp_dir}/gmp-mparam.h ; then
918     gmp_links="$gmp_links gmp-mparam.h:mpn/${tmp_dir}/gmp-mparam.h"
919
920     # Copy any KARATSUBA_SQR_THRESHOLD in gmp-mparam.h to config.m4.
921     # Some versions of sqr_basecase.asm use this.
922     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`"
923     if test -n "$tmp_gmp_karatsuba_sqr_threshold"; then
924       GMP_DEFINE_RAW(["define(<KARATSUBA_SQR_THRESHOLD>,<$tmp_gmp_karatsuba_sqr_threshold>)"])
925     fi
926
927     break
928   fi
929 done
930
931 # Dig out the links from `gmp_links' for inclusion in DISTCLEANFILES.
932 gmp_srclinks=
933 for f in $gmp_links; do
934   gmp_srclinks="$gmp_srclinks `echo $f | sed 's/\(.*\):.*/\1/'`"
935 done
936
937 AC_SUBST(mpn_objects)
938 AC_SUBST(mpn_objs_in_libgmp)
939 AC_SUBST(gmp_srclinks)
940
941 dnl  ----------------------------------------
942 dnl  Make links.
943 AC_CONFIG_LINKS($gmp_links)
944
945 dnl  Create config.m4.
946 GMP_FINISH
947
948 dnl  Create Makefiles
949 dnl  FIXME: Upcoming version of autoconf/automake may not like broken lines.
950 AC_OUTPUT(Makefile mpz/Makefile mpn/Makefile)