1 dnl Process this file with autoconf to produce a configure script.
4 dnl Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
6 dnl This file is part of the GNU MP Library.
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.
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.
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.
24 AC_REVISION($Revision: 1.7 $)dnl
32 AM_INIT_AUTOMAKE(gmp, GMP_VERSION)
33 AM_CONFIG_HEADER(config.h:config.in)
41 AC_HELP_STRING([--enable-assert],[enable ASSERT checking [default=no]]),
42 [case "${enableval}" in
44 *) AC_MSG_ERROR([bad value ${enableval} for --enable-assert, need yes or no]) ;;
48 if test "$enable_assert" = "yes"; then
49 AC_DEFINE(WANT_ASSERT,1,
50 [./configure --enable-assert option, to enable some ASSERT()s])
55 AC_HELP_STRING([--enable-alloca],[use alloca for temp space [default=yes]]),
56 [case "${enableval}" in
58 *) AC_MSG_ERROR([bad value ${enableval} for --enable-alloca, need yes or no]) ;;
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])
69 AC_HELP_STRING([--enable-fft],[enable FFTs for multiplication [default=no]]),
70 [case "${enableval}" in
72 *) AC_MSG_ERROR([bad value ${enableval} for --enable-fft, need yes or no]) ;;
76 if test "$enable_fft" = "yes"; then
78 [./configure --enable-fft option, to enable FFTs for multiplication])
83 AC_HELP_STRING([--enable-mpbsd],[build Berkley MP compatibility library [default=no]]),
84 [case "${enableval}" in
86 *) AC_MSG_ERROR([bad value ${enableval} for --enable-mpbsd, need yes or no]) ;;
89 AM_CONDITIONAL(WANT_MPBSD, test "$enable_mpbsd" = "yes")
93 AC_HELP_STRING([--enable-mpfr],[build MPFR [default=no]]),
94 [case "${enableval}" in
96 *) AC_MSG_ERROR([bad value ${enableval} for --enable-mpfr, need yes or no]) ;;
99 AM_CONDITIONAL(WANT_MPFR, test "$enable_mpfr" = "yes")
102 dnl Switch on OS and determine what compiler to use.
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.
113 cclist="gcc cc" # FIXME: Prefer c89 to cc.
114 gmp_cflags_gcc="-g -O2"
115 gmp_cflags64_gcc="-g -O2"
122 # Don't perform any assembly syntax tests on this beast.
123 gmp_no_asm_syntax_testing=yes
125 gmp_cflags_cc="$gmp_cflags_cc -O"
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;;
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"
143 flavour=`echo $target_cpu | sed 's/^alpha//g'`
144 if test -n "$flavour"; then
146 ev6? | ev7*) flavour=ev6;;
148 gmp_optcflags_gcc="-mcpu=$flavour"
151 # Cray vector machines. This must come after alpha* so that we can
152 # recognize present and future vector processors with a wildcard.
154 # Don't perform any assembly syntax tests on this beast.
155 gmp_no_asm_syntax_testing=yes
157 # Don't inherit default gmp_cflags_cc value; it comes with -g which
158 # disables all optimization on Cray vector systems
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"
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";;
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";;
178 k6*-*-*) gmp_optcflags_gcc="-mcpu=k6 -march=k6";;
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";;
189 [ultrasparc*-*-solaris2.[7-9] | sparcv9-*-solaris2.[7-9]])
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"
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.
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"
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"
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"
216 sparcv8*-*-* | microsparc*-*-*) # SunOS, Linux, *BSD
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?
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"
228 supersparc*-*-*) # SunOS, Linux, *BSD
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?
237 gmp_cflags_acc="-g -O2"
238 gmp_cflags_cc="-g -O2"
244 gmp_cflags_gcc="$gmp_cflags_gcc -maix64 -mpowerpc64"
245 gmp_cflags_xlc="-g -O2 -q64 -qtune=pwr3"
249 gmp_cflags_gcc="$gmp_cflags_gcc -mpowerpc"
250 gmp_cflags_xlc="$gmp_cflags_cc -qarch=ppc -O2"
254 gmp_cflags_gcc="$gmp_cflags_gcc -mpower"
255 gmp_cflags_xlc="$gmp_cflags_cc -qarch=pwr -O2"
258 gmp_cflags_gcc="$gmp_cflags_gcc -mpowerpc64"
259 AC_DEFINE(_LONG_LONG_LIMB) dnl FIXME: Remove.
262 gmp_cflags_gcc="$gmp_cflags_gcc -mpowerpc"
268 gmp_cflags64_gcc="-g -O2 -mabi=n32"
269 gmp_cflags64_cc="$gmp_cflags64_cc -O2 -n32"
272 # Motorola 68k family
274 gmp_cflags_gcc="-g -O -m88110" dnl FIXME: Use `-O2'?
277 gmp_cflags_gcc="$gmp_cflags_gcc -fomit-frame-pointer"
283 gmp_cflags_c89="$gmp_cflags_cc +O2"
284 gmp_cflags_cc="$gmp_cflags_cc +O2"
288 gmp_cflags_c89="+DD64 +O3"
289 gmp_cflags_cc="+DD64 +O3"
294 gmp_cflags64_gcc="$gmp_cflags64_gcc -mWHAT -D_LONG_LONG_LIMB"
295 # +O2 to cc triggers bug in mpz/powm.c (1.4)
296 gmp_cflags64_c89="+DA2.0 +e +O3 -D_LONG_LONG_LIMB"
297 gmp_cflags64_cc="+DA2.0 +e +O3 -D_LONG_LONG_LIMB"
298 gmp_cflags_c89="$gmp_cflags_cc +O2"
299 gmp_cflags_cc="$gmp_cflags_cc +O2"
304 gmp_cflags_gcc="$gmp_cflags_gcc -fomit-frame-pointer"
308 [f30[01]-fujitsu-sysv*])
310 gmp_cflags_vcc="-g" # FIXME: flags for vcc?
315 *-*-mingw32) gmp_cflags_gcc="$gmp_cflags_gcc -mno-cygwin";;
318 dnl Check for programs needed by macros for finding compiler.
319 dnl More programs are checked for below, when a compiler is found.
320 AC_PROG_NM dnl Macro from Libtool.
321 # nm on 64-bit AIX needs to know the object file format
328 # Save CFLAGS given on command line.
329 gmp_user_CFLAGS="$CFLAGS"
331 if test -z "$CC"; then
333 GMP_PROG_CC_FIND($cclist, $os_64bit)
335 # If 64-bit OS and we have a 64-bit compiler, use it.
336 if test -n "$os_64bit" && test -n "$CC64"; then
340 eval CFLAGS=\$gmp_cflags_$CC
343 # Try compiler flags that may work with only some compiler versions.
344 # gmp_optcflags: All or nothing.
345 eval optcflags=\$gmp_optcflags_$CC
346 if test -n "$optcflags"; then
347 CFLAGS_save="$CFLAGS"
348 CFLAGS="$CFLAGS $optcflags"
349 AC_MSG_CHECKING([whether $CC accepts $optcflags])
351 AC_TRY_COMPILER([int main(){return(0);}], optok, cross)
352 if test "$optok" = "yes"; then
356 CFLAGS="$CFLAGS_save"
359 # gmp_xoptcflags: First is best, one has to work.
360 eval xoptcflags=\$gmp_xoptcflags_$CC
361 if test -n "$xoptcflags"; then
363 for xopt in $xoptcflags; do
364 CFLAGS_save="$CFLAGS"
365 CFLAGS="$CFLAGS $xopt"
366 AC_MSG_CHECKING([whether $CC accepts $xopt])
368 AC_TRY_COMPILER([int main(){return(0);}], optok, cross)
369 if test "$optok" = "yes"; then
375 CFLAGS="$CFLAGS_save"
378 if test "$gmp_found" = "no"; then
379 echo ["$0: fatal: need a compiler that understands one of $xoptcflags"]
385 # Restore CFLAGS given on command line.
386 # FIXME: We've run through quite some unnecessary code looking for a
387 # nice compiler and working flags for it, just to spoil that with user
389 test -n "$gmp_user_CFLAGS" && CFLAGS="$gmp_user_CFLAGS"
391 # Select chosen compiler.
398 dnl Checks for programs.
399 dnl --------------------
404 AC_CHECK_PROG(AR, ar, ar)
405 # ar on AIX needs to know the object file format
411 dnl FIXME: Find good ld? /usr/ucb/ld on Solaris won't work.
413 dnl Checks for assembly syntax.
414 if test "$gmp_no_asm_syntax_testing" != "yes"; then
418 GMP_CHECK_ASM_LABEL_SUFFIX
421 GMP_CHECK_ASM_LSYM_PREFIX
423 GMP_CHECK_ASM_UNDERSCORE(underscore=yes, underscore=no)
424 GMP_CHECK_ASM_ALIGN_LOG(asm_align=log, asm_align=nolog)
427 dnl FIXME: Check for FPU and set `floating_point' appropriately.
429 dnl ========================================
431 dnl ----------------------------------------
432 dnl Set the following target specific variables:
433 dnl path where to search for source files
434 dnl family processor family (Needed for building
435 dnl asm-syntax.h for now. FIXME: Remove.)
436 dnl extra_functions extra functions
444 [sparcv9*-*-solaris2.[789]* | sparc64*-*-solaris2.[789]* | ultrasparc*-*-solaris2.[789]*])
447 else path="sparc32/v9 sparc32/v8 sparc32"
453 else path="sparc32/v9 sparc32/v8 sparc32"
456 sparcv8*-*-* | microsparc*-*-*)
457 path="sparc32/v8 sparc32"
458 if test x${floating_point} = xno
459 then extra_functions="udiv_nfp"
460 else extra_functions="udiv_fp"
463 sparcv9*-*-* | ultrasparc*-*-*)
464 path="sparc32/v9 sparc32/v8 sparc32"
465 extra_functions="udiv_fp"
468 path="sparc32/v8/supersparc sparc32/v8 sparc32"
469 extra_functions="udiv"
471 sparc*-*-*) path="sparc32"
472 if test x${floating_point} = xno
473 then extra_functions="udiv_nfp"
474 else extra_functions="udiv_fp"
478 path="hppa/hppa1_1 hppa"
479 extra_functions="udiv_qrnnd"
483 extra_functions="udiv_qrnnd"
487 extra_functions="umul_ppmm udiv_qrnnd"
490 if test -n "$CC64"; then
492 extra_functions="umul_ppmm udiv_qrnnd"
493 # We need to use the system compiler, or actually the system assembler,
494 # since GAS has not been ported to understand the 2.0 instructions.
497 # FIXME: path should be "hppa/hppa2_0 hppa/hppa1_1 hppa"
498 path="hppa/hppa1_1 hppa"
499 extra_functions="udiv_qrnnd"
502 hppa*-*-*) #assume pa7100
503 path="hppa/hppa1_1/pa7100 hppa/hppa1_1 hppa"
504 extra_functions="udiv_qrnnd";;
505 [f30[01]-fujitsu-sysv*])
507 alphaev6*-*-*) path="alpha/ev6 alpha"; extra_functions="invert_limb cntlz";;
508 alphaev5*-*-*) path="alpha/ev5 alpha"; extra_functions="invert_limb cntlz";;
509 alpha*-*-*) path="alpha"; extra_functions="invert_limb cntlz";;
510 # Cray vector machines. This must come after alpha* so that we can
511 # recognize present and future vector processors with a wildcard.
514 extra_functions="mulww";;
515 am29000*-*-*) path="a29k";;
516 a29k*-*-*) path="a29k";;
518 # AMD and Intel x86 configurations
520 [i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*])
521 gmp_m4postinc="x86/x86-defs.m4"
522 extra_functions="udiv umul"
523 CALLING_CONVENTIONS_OBJS="x86call.o x86check.o"
525 GMP_CHECK_ASM_SHLDL_CL(
526 [GMP_DEFINE(WANT_SHLDL_CL,1)],
527 [GMP_DEFINE(WANT_SHLDL_CL,0)])
528 GMP_CHECK_ASM_ALIGN_FILL_0x90
530 # the CPUs below wanting to know about mmx
532 [pentiummmx-*-* | pentium[23]-*-* | k6*-*-* | athlon-*-*])
533 GMP_CHECK_ASM_MMX(tmp_mmx=yes, tmp_mmx=no)
537 # default for anything not otherwise mentioned
545 # don't know what best suits k5
548 i586*-*-* | pentium-*-*)
549 path="x86/pentium x86"
552 path="x86/pentium x86"
553 if test "$tmp_mmx" = yes; then
554 path="x86/pentium/mmx $path"
557 i686*-*-* | pentiumpro-*-*)
562 # The pentium/mmx lshift and rshift are good on p6 and can be used
563 # until there's something specific for p6.
564 if test "$tmp_mmx" = yes; then
565 path="x86/p6/mmx x86/pentium/mmx $path"
570 # The pentium/mmx lshift and rshift are good on p6 and can be used
571 # until there's something specific for p6.
572 if test "$tmp_mmx" = yes; then
573 path="x86/p6/p3mmx x86/p6/mmx x86/pentium/mmx $path"
578 if test "$tmp_mmx" = yes; then
579 path="x86/k6/k62mmx x86/k6/mmx $path"
584 if test "$tmp_mmx" = yes; then
585 path="x86/k6/mmx $path"
590 if test "$tmp_mmx" = yes; then
591 path="x86/k7/mmx $path"
598 i960*-*-*) path="i960";;
600 ia64*-*-*) path="ia64";;
602 # Motorola 68k configurations. Let m68k mean 68020-68040.
603 [m680[234]0*-*-* | m68k*-*-* | \
604 m68*-next-nextstep*]) # Nexts are at least '020
605 path="m68k/mc68020 m68k"
613 m88k*-*-* | m88k*-*-*) path="m88k";;
614 m88110*-*-*) path="m88k/mc88110 m88k";;
615 ns32k*-*-*) path="ns32k";;
617 pyramid-*-*) path="pyr";;
619 ppc601-*-*) path="power powerpc32";;
620 powerpc64*-*-*) path="powerpc64";;
621 powerpc*-*-*) path="powerpc32";;
622 rs6000-*-* | power-*-* | power2-*-*)
624 extra_functions="udiv_w_sdiv"
628 sh2-*-*) path="sh/sh2 sh";;
630 [mips[34]*-*-*]) path="mips3";;
631 mips*-*-irix6*) path="mips3";;
632 mips*-*-*) path="mips2";;
634 vax*-*-*) path="vax"; extra_functions="udiv_w_sdiv";;
636 z8000x*-*-*) path="z8000x"; extra_functions="udiv_w_sdiv";;
637 z8000*-*-*) path="z8000"; extra_functions="udiv_w_sdiv";;
639 clipper*-*-*) path="clipper";;
642 AC_SUBST(CALLING_CONVENTIONS_OBJS)
643 if test -n "$CALLING_CONVENTIONS_OBJS"; then
644 AC_DEFINE(HAVE_CALLING_CONVENTIONS,1,
645 [Define if mpn/tests has calling conventions checking for the CPU])
650 [i[5-8]86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*])
651 # rdtsc is in pentium and up, not in i386 and i486
652 SPEED_CYCLECOUNTER_OBJS=pentium.lo
655 SPEED_CYCLECOUNTER_OBJS=alpha.lo
657 sparcv9*-*-* | ultrasparc*-*-* | sparc64*-*-*)
658 SPEED_CYCLECOUNTER_OBJS=sparcv9.lo
661 SPEED_CYCLECOUNTER_OBJS=hppa2.lo
664 SPEED_CYCLECOUNTER_OBJS=hppa.lo
668 AC_SUBST(SPEED_CYCLECOUNTER_OBJS)
670 if test -n "$SPEED_CYCLECOUNTER_OBJS"
672 AC_DEFINE(HAVE_SPEED_CYCLECOUNTER, 1,
673 [Define if a speed_cyclecounter exists (for the tune programs)])
677 dnl Extensions for executable and object files.
678 dnl -------------------------------------------
684 dnl FIXME: Shared libs seem to fail on aix4.3.
685 dnl FIXME: Should invoke [AC_DISABLE_SHARED], but m4 recurses to death.
687 [*-*-aix4.[3-9]*]) enable_shared=no ;;
691 dnl Checks for libraries.
692 dnl ---------------------
693 AC_CHECK_DECLS((optarg))
695 dnl Checks for header files.
696 dnl ------------------------
698 AC_CHECK_HEADERS(getopt.h unistd.h sys/sysctl.h sys/time.h)
700 dnl Checks for typedefs, structures, and compiler characteristics.
701 dnl --------------------------------------------------------------
702 AC_CHECK_TYPES((void))
705 dnl Checks for library functions.
706 dnl -----------------------------
707 dnl Most of these are only for the benefit of supplementary programs. The
708 dnl library itself doesn't use anything weird.
711 dnl AC_CHECK_FUNCS(strtol)
712 AC_CHECK_FUNCS(getopt_long getpagesize popen processor_info strtoul sysconf sysctlbyname)
714 dnl Trick automake into thinking we've run AM_C_PROTOTYPES which it wants
715 dnl for ansi2knr, and instead use our own test. (It's only a warning
716 dnl automake prints, but it's good to suppress it.)
723 dnl Set `syntax' to one of <blank>, "mit", "elf", "aix", "macho".
725 # For now, we use the old switch for setting syntax.
726 # FIXME: Remove when conversion to .asm is completed.
729 m680[234]0*-*-linuxaout* | m68k*-*-linuxaout* | \
730 m68k-next-nextstep* | \
734 m680[234]0*-*-linux* | m68k*-*-linux*)
737 m680[234]0*-*-* | m68k*-*-*)
743 dnl ----------------------------------------
744 # Now build an asm-syntax.h file for targets that include that from the
746 # FIXME: Remove when conversion to .asm is completed.
747 case "${family}-${underscore}-${asm_align}-${syntax}" in
749 echo '#define MIT_SYNTAX' >asm-syntax.h
750 cat $srcdir/mpn/underscore.h >>asm-syntax.h
751 echo '#include "'$srcdir'/mpn/m68k/syntax.h"' >>asm-syntax.h;;
753 echo '#define ELF_SYNTAX' >asm-syntax.h
754 echo '#define C_SYMBOL_NAME(name) name' >>asm-syntax.h
755 echo '#include "'$srcdir'/mpn/m68k/syntax.h"' >>asm-syntax.h;;
759 # The pattern here tests for an absolute path the same way as
760 # _AC_OUTPUT_FILES in autoconf acgeneral.m4.
761 GMP_DEFINE_RAW(["dnl CONFIG_TOP_SRCDIR is a path from the mpn builddir to the top srcdir"])
763 [[\\/]]* | ?:[[\\/]]* )
764 GMP_DEFINE_RAW(["define(<CONFIG_TOP_SRCDIR>,<\`$srcdir'>)"]) ;;
765 *) GMP_DEFINE_RAW(["define(<CONFIG_TOP_SRCDIR>,<\`../$srcdir'>)"]) ;;
768 GMP_DEFINE_RAW(["include(CONFIG_TOP_SRCDIR\`/mpn/asm-defs.m4')"], POST)
770 # Must be after asm-defs.m4
771 GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_TARGET_CPU_$target_cpu')", POST)
774 dnl config.m4 post-includes
775 dnl -----------------------
776 dnl (Note x86 post include set with $path above.)
780 gmp_m4postinc="alpha/unicos.m4"
783 gmp_m4postinc="alpha/default.m4"
787 *-*-mach* | *-*-rhapsody* | *-*-nextstep*)
788 ;; # these use non-conventional assembly syntax.
790 gmp_m4postinc="powerpc32/regmap.m4 powerpc64/aix.m4"
793 gmp_m4postinc="powerpc32/regmap.m4 powerpc32/aix.m4"
796 gmp_m4postinc="powerpc32/regmap.m4"
803 for tmp_f in $gmp_m4postinc; do
804 GMP_DEFINE_RAW(["include_mpn(\`$tmp_f')"], POST)
808 # Set up `gmp_links'. It's a list of link:file pairs that configure will
809 # process to create link -> file.
812 # If the user specified `MPN_PATH', use that instead of the path we've
814 if test -z "$MPN_PATH"; then
820 # Pick the correct source files in $path and link them to mpn/.
821 # $gmp_mpn_functions lists all functions we need.
823 # The rule is to find a file with the function name and a .asm, .S,
824 # .s, or .c extension. Certain multi-function files with special names
825 # can provide some functions too. (mpn/Makefile.am passes
826 # -DOPERATION_<func> to get them to generate the right code.)
828 # FIXME: udiv and umul aren't in $gmp_mpn_functions_optional yet since
829 # there's some versions of those files which should be checked for bit
830 # rot first. Put them in $extra_functions for each target for now,
831 # change to standard optionals when all are ready.
833 # Note: The following lines defining $gmp_mpn_functions_optional
834 # and $gmp_mpn_functions are parsed by the "macos/configure"
835 # Perl script. So if you change the lines in a major way
836 # make sure to run and examine the output from
838 # % (cd macos; perl configure)
840 gmp_mpn_functions_optional="copyi copyd com_n \
841 and_n andn_n nand_n ior_n iorn_n nior_n xor_n xnor_n"
843 gmp_mpn_functions="${extra_functions} inlines add_n sub_n mul_1 addmul_1 \
844 submul_1 lshift rshift diveby3 divrem divrem_1 divrem_2 \
845 mod_1 mod_1_rs pre_mod_1 dump \
846 mul mul_fft mul_n mul_basecase sqr_basecase random \
847 random2 sqrtrem get_str set_str scan0 scan1 popcount hamdist cmp perfsqr \
848 bdivmod gcd_1 gcd gcdext tdiv_qr bz_divrem_n sb_divrem_mn jacbase \
849 $gmp_mpn_functions_optional"
851 # the list of all object files used by mpn/Makefile.in and the
852 # top-level Makefile.in, respectively
854 mpn_objs_in_libgmp="mpn/mp_bases.lo"
856 for tmp_fn in ${gmp_mpn_functions} ; do
857 [rm -f mpn/${tmp_fn}.[Ssc] mpn/${tmp_fn}.asm]
859 # functions that can be provided by multi-function files
862 add_n|sub_n) tmp_mulfunc="aors_n" ;;
863 addmul_1|submul_1) tmp_mulfunc="aorsmul_1" ;;
864 popcount|hamdist) tmp_mulfunc="popham" ;;
865 and_n|andn_n|nand_n | ior_n|iorn_n|nior_n | xor_n|xnor_n)
866 tmp_mulfunc="logops_n" ;;
870 for tmp_dir in $path; do
871 for tmp_base in $tmp_fn $tmp_mulfunc; do
872 for tmp_ext in asm S s c; do
873 tmp_file=$srcdir/mpn/$tmp_dir/$tmp_base.$tmp_ext
874 if test -f $tmp_file; then
877 mpn_objects="$mpn_objects ${tmp_fn}.lo"
878 mpn_objs_in_libgmp="$mpn_objs_in_libgmp mpn/${tmp_fn}.lo"
879 gmp_links="$gmp_links mpn/$tmp_fn.$tmp_ext:mpn/$tmp_dir/$tmp_base.$tmp_ext"
881 # duplicate AC_DEFINEs are harmless, so it doesn't matter
882 # that multi-function files get grepped here repeatedly
884 sed -n 's/^[ ]*MULFUNC_PROLOGUE(\(.*\))/\1/p' $tmp_file ;
885 sed -n 's/^[ ]*PROLOGUE.*(\(.*\))/\1/p' $tmp_file
887 for gmp_tmp in $gmp_ep; do
888 AC_DEFINE_UNQUOTED(HAVE_NATIVE_${gmp_tmp})
894 if test $found = yes; then break ; fi
896 if test $found = yes; then break ; fi
899 if test $found = no; then
900 for tmp_optional in $gmp_mpn_functions_optional; do
901 if test $tmp_optional = $tmp_fn; then
905 if test $found = no; then
906 AC_MSG_ERROR([no version of $tmp_fn found in path: $path])
911 # Create link for gmp-mparam.h.
912 for tmp_dir in $path ; do
914 if test -f $srcdir/mpn/${tmp_dir}/gmp-mparam.h ; then
915 gmp_links="$gmp_links gmp-mparam.h:mpn/${tmp_dir}/gmp-mparam.h"
917 # Copy any KARATSUBA_SQR_THRESHOLD in gmp-mparam.h to config.m4.
918 # Some versions of sqr_basecase.asm use this.
919 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`"
920 if test -n "$tmp_gmp_karatsuba_sqr_threshold"; then
921 GMP_DEFINE_RAW(["define(<KARATSUBA_SQR_THRESHOLD>,<$tmp_gmp_karatsuba_sqr_threshold>)"])
928 # Dig out the links from `gmp_links' for inclusion in DISTCLEANFILES.
930 for f in $gmp_links; do
931 gmp_srclinks="$gmp_srclinks `echo $f | sed 's/\(.*\):.*/\1/'`"
934 AC_SUBST(mpn_objects)
935 AC_SUBST(mpn_objs_in_libgmp)
936 AC_SUBST(gmp_srclinks)
938 dnl ----------------------------------------
940 AC_CONFIG_LINKS($gmp_links)
942 dnl Create config.m4.
946 dnl FIXME: Upcoming version of autoconf/automake may not like broken lines.
947 AC_OUTPUT(Makefile mpz/Makefile mpn/Makefile)