Blame configure.ac

Packit 5c3484
dnl  Process this file with autoconf to produce a configure script.
Packit 5c3484
Packit 5c3484
Packit 5c3484
define(GMP_COPYRIGHT,[[
Packit 5c3484
Packit 5c3484
Copyright 1996-2016 Free Software Foundation, Inc.
Packit 5c3484
Packit 5c3484
This file is part of the GNU MP Library.
Packit 5c3484
Packit 5c3484
The GNU MP Library is free software; you can redistribute it and/or modify
Packit 5c3484
it under the terms of either:
Packit 5c3484
Packit 5c3484
  * the GNU Lesser General Public License as published by the Free
Packit 5c3484
    Software Foundation; either version 3 of the License, or (at your
Packit 5c3484
    option) any later version.
Packit 5c3484
Packit 5c3484
or
Packit 5c3484
Packit 5c3484
  * the GNU General Public License as published by the Free Software
Packit 5c3484
    Foundation; either version 2 of the License, or (at your option) any
Packit 5c3484
    later version.
Packit 5c3484
Packit 5c3484
or both in parallel, as here.
Packit 5c3484
Packit 5c3484
The GNU MP Library is distributed in the hope that it will be useful, but
Packit 5c3484
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 5c3484
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
Packit 5c3484
for more details.
Packit 5c3484
Packit 5c3484
You should have received copies of the GNU General Public License and the
Packit 5c3484
GNU Lesser General Public License along with the GNU MP Library.  If not,
Packit 5c3484
see https://www.gnu.org/licenses/.
Packit 5c3484
]])
Packit 5c3484
Packit 5c3484
AC_COPYRIGHT(GMP_COPYRIGHT)
Packit 5c3484
AH_TOP(/*GMP_COPYRIGHT*/)
Packit 5c3484
Packit 5c3484
AC_REVISION($Revision$)
Packit 5c3484
AC_PREREQ(2.59)
Packit 5c3484
AC_INIT(GNU MP, GMP_VERSION, [gmp-bugs@gmplib.org, see https://gmplib.org/manual/Reporting-Bugs.html], gmp)
Packit 5c3484
AC_CONFIG_SRCDIR(gmp-impl.h)
Packit 5c3484
m4_pattern_forbid([^[ \t]*GMP_])
Packit 5c3484
m4_pattern_allow(GMP_LDFLAGS)
Packit 5c3484
m4_pattern_allow(GMP_LIMB_BITS)
Packit 5c3484
m4_pattern_allow(GMP_MPARAM_H_SUGGEST)
Packit 5c3484
m4_pattern_allow(GMP_NAIL_BITS)
Packit 5c3484
m4_pattern_allow(GMP_NUMB_BITS)
Packit 5c3484
m4_pattern_allow(GMP_NONSTD_ABI)
Packit 5c3484
m4_pattern_allow(GMP_CPU_TYPE)
Packit 5c3484
Packit 5c3484
# If --target is not used then $target_alias is empty, but if say
Packit 5c3484
# "./configure athlon-pc-freebsd3.5" is used, then all three of
Packit 5c3484
# $build_alias, $host_alias and $target_alias are set to
Packit 5c3484
# "athlon-pc-freebsd3.5".
Packit 5c3484
#
Packit 5c3484
if test -n "$target_alias" && test "$target_alias" != "$host_alias"; then
Packit 5c3484
  AC_MSG_ERROR([--target is not appropriate for GMP
Packit 5c3484
Use --build=CPU-VENDOR-OS if you need to specify your CPU and/or system
Packit 5c3484
explicitly.  Use --host if cross-compiling (see "Installing GMP" in the
Packit 5c3484
manual for more on this).])
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
GMP_INIT(config.m4)
Packit 5c3484
Packit 5c3484
AC_CANONICAL_HOST
Packit 5c3484
Packit 5c3484
dnl  Automake "no-dependencies" is used because include file dependencies
Packit 5c3484
dnl  are not useful to us.  Pretty much everything depends just on gmp.h,
Packit 5c3484
dnl  gmp-impl.h and longlong.h, and yet only rarely does everything need to
Packit 5c3484
dnl  be rebuilt for changes to those files.
Packit 5c3484
dnl
Packit 5c3484
dnl  "no-dependencies" also helps with the way we're setup to run
Packit 5c3484
dnl  AC_PROG_CXX only conditionally.  If dependencies are used then recent
Packit 5c3484
dnl  automake (eg 1.7.2) appends an AM_CONDITIONAL to AC_PROG_CXX, and then
Packit 5c3484
dnl  gets upset if it's not actually executed.
Packit 5c3484
dnl
Packit 5c3484
dnl  Note that there's a copy of these options in the top-level Makefile.am,
Packit 5c3484
dnl  so update there too if changing anything.
Packit 5c3484
dnl
Packit 5c3484
AM_INIT_AUTOMAKE([1.8 gnu no-dependencies])
Packit 5c3484
AC_CONFIG_HEADERS(config.h:config.in)
Packit 5c3484
AM_MAINTAINER_MODE
Packit 5c3484
Packit 5c3484
Packit 5c3484
AC_ARG_ENABLE(assert,
Packit 5c3484
AC_HELP_STRING([--enable-assert],[enable ASSERT checking [default=no]]),
Packit 5c3484
[case $enableval in
Packit 5c3484
yes|no) ;;
Packit 5c3484
*) AC_MSG_ERROR([bad value $enableval for --enable-assert, need yes or no]) ;;
Packit 5c3484
esac],
Packit 5c3484
[enable_assert=no])
Packit 5c3484
Packit 5c3484
if test "$enable_assert" = "yes"; then
Packit 5c3484
  AC_DEFINE(WANT_ASSERT,1,
Packit 5c3484
  [Define to 1 to enable ASSERT checking, per --enable-assert])
Packit 5c3484
  want_assert_01=1
Packit 5c3484
else
Packit 5c3484
  want_assert_01=0
Packit 5c3484
fi
Packit 5c3484
GMP_DEFINE_RAW(["define(<WANT_ASSERT>,$want_assert_01)"])
Packit 5c3484
Packit 5c3484
Packit 5c3484
AC_ARG_ENABLE(alloca,
Packit 5c3484
AC_HELP_STRING([--enable-alloca],[how to get temp memory [default=reentrant]]),
Packit 5c3484
[case $enableval in
Packit 5c3484
alloca|malloc-reentrant|malloc-notreentrant) ;;
Packit 5c3484
yes|no|reentrant|notreentrant) ;;
Packit 5c3484
debug) ;;
Packit 5c3484
*)
Packit 5c3484
  AC_MSG_ERROR([bad value $enableval for --enable-alloca, need one of:
Packit 5c3484
yes no reentrant notreentrant alloca malloc-reentrant malloc-notreentrant debug]) ;;
Packit 5c3484
esac],
Packit 5c3484
[enable_alloca=reentrant])
Packit 5c3484
Packit 5c3484
Packit 5c3484
# IMPROVE ME: The default for C++ is disabled.  The tests currently
Packit 5c3484
# performed below for a working C++ compiler are not particularly strong,
Packit 5c3484
# and in general can't be expected to get the right setup on their own.  The
Packit 5c3484
# most significant problem is getting the ABI the same.  Defaulting CXXFLAGS
Packit 5c3484
# to CFLAGS takes only a small step towards this.  It's also probably worth
Packit 5c3484
# worrying whether the C and C++ runtimes from say gcc and a vendor C++ can
Packit 5c3484
# work together.  Some rather broken C++ installations were encountered
Packit 5c3484
# during testing, and though such things clearly aren't GMP's problem, if
Packit 5c3484
# --enable-cxx=detect were to be the default then some careful checks of
Packit 5c3484
# which, if any, C++ compiler on the system is up to scratch would be
Packit 5c3484
# wanted.
Packit 5c3484
#
Packit 5c3484
AC_ARG_ENABLE(cxx,
Packit 5c3484
AC_HELP_STRING([--enable-cxx],[enable C++ support [default=no]]),
Packit 5c3484
[case $enableval in
Packit 5c3484
yes|no|detect) ;;
Packit 5c3484
*) AC_MSG_ERROR([bad value $enableval for --enable-cxx, need yes/no/detect]) ;;
Packit 5c3484
esac],
Packit 5c3484
[enable_cxx=no])
Packit 5c3484
Packit 5c3484
Packit 5c3484
AC_ARG_ENABLE(assembly,
Packit 5c3484
AC_HELP_STRING([--enable-assembly],[enable the use of assembly loops [default=yes]]),
Packit 5c3484
[case $enableval in
Packit 5c3484
yes|no) ;;
Packit 5c3484
*) AC_MSG_ERROR([bad value $enableval for --enable-assembly, need yes or no]) ;;
Packit 5c3484
esac],
Packit 5c3484
[enable_assembly=yes])
Packit 5c3484
Packit 5c3484
Packit 5c3484
AC_ARG_ENABLE(fft,
Packit 5c3484
AC_HELP_STRING([--enable-fft],[enable FFTs for multiplication [default=yes]]),
Packit 5c3484
[case $enableval in
Packit 5c3484
yes|no) ;;
Packit 5c3484
*) AC_MSG_ERROR([bad value $enableval for --enable-fft, need yes or no]) ;;
Packit 5c3484
esac],
Packit 5c3484
[enable_fft=yes])
Packit 5c3484
Packit 5c3484
if test "$enable_fft" = "yes"; then
Packit 5c3484
  AC_DEFINE(WANT_FFT,1,
Packit 5c3484
  [Define to 1 to enable FFTs for multiplication, per --enable-fft])
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
Packit 5c3484
AC_ARG_ENABLE(old-fft-full,
Packit 5c3484
AC_HELP_STRING([--enable-old-fft-full],[enable old mpn_mul_fft_full for multiplication [default=no]]),
Packit 5c3484
[case $enableval in
Packit 5c3484
yes|no) ;;
Packit 5c3484
*) AC_MSG_ERROR([bad value $enableval for --enable-old-fft-full, need yes or no]) ;;
Packit 5c3484
esac],
Packit 5c3484
[enable_old_fft_full=no])
Packit 5c3484
Packit 5c3484
if test "$enable_old_fft_full" = "yes"; then
Packit 5c3484
  AC_DEFINE(WANT_OLD_FFT_FULL,1,
Packit 5c3484
  [Define to 1 to enable old mpn_mul_fft_full for multiplication, per --enable-old-fft-full])
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
Packit 5c3484
AC_ARG_ENABLE(nails,
Packit 5c3484
AC_HELP_STRING([--enable-nails],[use nails on limbs [default=no]]),
Packit 5c3484
[case $enableval in
Packit 5c3484
[yes|no|[02468]|[0-9][02468]]) ;;
Packit 5c3484
[*[13579]])
Packit 5c3484
  AC_MSG_ERROR([bad value $enableval for --enable-nails, only even nail sizes supported]) ;;
Packit 5c3484
*)
Packit 5c3484
  AC_MSG_ERROR([bad value $enableval for --enable-nails, need yes/no/number]) ;;
Packit 5c3484
esac],
Packit 5c3484
[enable_nails=no])
Packit 5c3484
Packit 5c3484
case $enable_nails in
Packit 5c3484
yes) GMP_NAIL_BITS=2 ;;
Packit 5c3484
no)  GMP_NAIL_BITS=0 ;;
Packit 5c3484
*)   GMP_NAIL_BITS=$enable_nails ;;
Packit 5c3484
esac
Packit 5c3484
AC_SUBST(GMP_NAIL_BITS)
Packit 5c3484
Packit 5c3484
Packit 5c3484
AC_ARG_ENABLE(profiling,
Packit 5c3484
AC_HELP_STRING([--enable-profiling],
Packit 5c3484
               [build with profiler support [default=no]]),
Packit 5c3484
[case $enableval in
Packit 5c3484
no|prof|gprof|instrument) ;;
Packit 5c3484
*) AC_MSG_ERROR([bad value $enableval for --enable-profiling, need no/prof/gprof/instrument]) ;;
Packit 5c3484
esac],
Packit 5c3484
[enable_profiling=no])
Packit 5c3484
Packit 5c3484
case $enable_profiling in
Packit 5c3484
  prof)
Packit 5c3484
    AC_DEFINE(WANT_PROFILING_PROF, 1,
Packit 5c3484
              [Define to 1 if --enable-profiling=prof])
Packit 5c3484
    ;;
Packit 5c3484
  gprof)
Packit 5c3484
    AC_DEFINE(WANT_PROFILING_GPROF, 1,
Packit 5c3484
              [Define to 1 if --enable-profiling=gprof])
Packit 5c3484
    ;;
Packit 5c3484
  instrument)
Packit 5c3484
    AC_DEFINE(WANT_PROFILING_INSTRUMENT, 1,
Packit 5c3484
              [Define to 1 if --enable-profiling=instrument])
Packit 5c3484
    ;;
Packit 5c3484
esac
Packit 5c3484
Packit 5c3484
GMP_DEFINE_RAW(["define(<WANT_PROFILING>,<\`$enable_profiling'>)"])
Packit 5c3484
Packit 5c3484
# -fomit-frame-pointer is incompatible with -pg on some chips
Packit 5c3484
if test "$enable_profiling" = gprof; then
Packit 5c3484
  fomit_frame_pointer=
Packit 5c3484
else
Packit 5c3484
  fomit_frame_pointer="-fomit-frame-pointer"
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
Packit 5c3484
AC_ARG_WITH(readline,
Packit 5c3484
AC_HELP_STRING([--with-readline],
Packit 5c3484
               [readline support in demo programs [default=detect]]),
Packit 5c3484
[case $withval in
Packit 5c3484
yes|no|detect) ;;
Packit 5c3484
*) AC_MSG_ERROR([bad value $withval for --with-readline, need yes/no/detect]) ;;
Packit 5c3484
esac],
Packit 5c3484
[with_readline=detect])
Packit 5c3484
Packit 5c3484
Packit 5c3484
AC_ARG_ENABLE(fat,
Packit 5c3484
AC_HELP_STRING([--enable-fat],
Packit 5c3484
               [build fat libraries on systems that support it [default=no]]),
Packit 5c3484
[case $enableval in
Packit 5c3484
yes|no) ;;
Packit 5c3484
*) AC_MSG_ERROR([bad value $enableval for --enable-fat, need yes or no]) ;;
Packit 5c3484
esac],
Packit 5c3484
[enable_fat=no])
Packit 5c3484
Packit 5c3484
Packit 5c3484
AC_ARG_ENABLE(minithres,
Packit 5c3484
AC_HELP_STRING([--enable-minithres],
Packit 5c3484
               [choose minimal thresholds for testing [default=no]]),
Packit 5c3484
[case $enableval in
Packit 5c3484
yes|no) ;;
Packit 5c3484
*) AC_MSG_ERROR([bad value $enableval for --enable-minithres, need yes or no]) ;;
Packit 5c3484
esac],
Packit 5c3484
[enable_minithres=no])
Packit 5c3484
Packit 5c3484
Packit 5c3484
AC_ARG_ENABLE(fake-cpuid,
Packit 5c3484
AC_HELP_STRING([--enable-fake-cpuid],[enable GMP_CPU_TYPE faking cpuid [default=no]]),
Packit 5c3484
[case $enableval in
Packit 5c3484
yes|no) ;;
Packit 5c3484
*) AC_MSG_ERROR([bad value $enableval for --enable-fake-cpuid, need yes or no]) ;;
Packit 5c3484
esac],
Packit 5c3484
[enable_fake_cpuid=no])
Packit 5c3484
Packit 5c3484
if test "$enable_fake_cpuid" = "yes"; then
Packit 5c3484
  AC_DEFINE(WANT_FAKE_CPUID,1,
Packit 5c3484
  [Define to 1 to enable GMP_CPU_TYPE faking cpuid, per --enable-fake-cpuid])
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
Packit 5c3484
if test $enable_fat = yes && test $enable_assembly = no ; then
Packit 5c3484
  AC_MSG_ERROR([when doing a fat build, disabling assembly will not work])
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
if test $enable_fake_cpuid = yes && test $enable_fat = no ; then
Packit 5c3484
  AC_MSG_ERROR([--enable-fake-cpuid requires --enable-fat])
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
Packit 5c3484
tmp_host=`echo $host_cpu | sed 's/\./_/'`
Packit 5c3484
AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_$tmp_host)
Packit 5c3484
GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_HOST_CPU_$tmp_host')", POST)
Packit 5c3484
Packit 5c3484
dnl  The HAVE_HOST_CPU_ list here only needs to have entries for those which
Packit 5c3484
dnl  are going to be tested, not everything that can possibly be selected.
Packit 5c3484
dnl
Packit 5c3484
dnl  The HAVE_HOST_CPU_FAMILY_ list similarly, and note that the AC_DEFINEs
Packit 5c3484
dnl  for these are under the cpu specific setups below.
Packit 5c3484
Packit 5c3484
AH_VERBATIM([HAVE_HOST_CPU_1],
Packit 5c3484
[/* Define one of these to 1 for the host CPU family.
Packit 5c3484
   If your CPU is not in any of these families, leave all undefined.
Packit 5c3484
   For an AMD64 chip, define "x86" in ABI=32, but not in ABI=64. */
Packit 5c3484
#undef HAVE_HOST_CPU_FAMILY_alpha
Packit 5c3484
#undef HAVE_HOST_CPU_FAMILY_m68k
Packit 5c3484
#undef HAVE_HOST_CPU_FAMILY_power
Packit 5c3484
#undef HAVE_HOST_CPU_FAMILY_powerpc
Packit 5c3484
#undef HAVE_HOST_CPU_FAMILY_x86
Packit 5c3484
#undef HAVE_HOST_CPU_FAMILY_x86_64
Packit 5c3484
Packit 5c3484
/* Define one of the following to 1 for the host CPU, as per the output of
Packit 5c3484
   ./config.guess.  If your CPU is not listed here, leave all undefined.  */
Packit 5c3484
#undef HAVE_HOST_CPU_alphaev67
Packit 5c3484
#undef HAVE_HOST_CPU_alphaev68
Packit 5c3484
#undef HAVE_HOST_CPU_alphaev7
Packit 5c3484
#undef HAVE_HOST_CPU_m68020
Packit 5c3484
#undef HAVE_HOST_CPU_m68030
Packit 5c3484
#undef HAVE_HOST_CPU_m68040
Packit 5c3484
#undef HAVE_HOST_CPU_m68060
Packit 5c3484
#undef HAVE_HOST_CPU_m68360
Packit 5c3484
#undef HAVE_HOST_CPU_powerpc604
Packit 5c3484
#undef HAVE_HOST_CPU_powerpc604e
Packit 5c3484
#undef HAVE_HOST_CPU_powerpc750
Packit 5c3484
#undef HAVE_HOST_CPU_powerpc7400
Packit 5c3484
#undef HAVE_HOST_CPU_supersparc
Packit 5c3484
#undef HAVE_HOST_CPU_i386
Packit 5c3484
#undef HAVE_HOST_CPU_i586
Packit 5c3484
#undef HAVE_HOST_CPU_i686
Packit 5c3484
#undef HAVE_HOST_CPU_pentium
Packit 5c3484
#undef HAVE_HOST_CPU_pentiummmx
Packit 5c3484
#undef HAVE_HOST_CPU_pentiumpro
Packit 5c3484
#undef HAVE_HOST_CPU_pentium2
Packit 5c3484
#undef HAVE_HOST_CPU_pentium3
Packit 5c3484
#undef HAVE_HOST_CPU_s390_z900
Packit 5c3484
#undef HAVE_HOST_CPU_s390_z990
Packit 5c3484
#undef HAVE_HOST_CPU_s390_z9
Packit 5c3484
#undef HAVE_HOST_CPU_s390_z10
Packit 5c3484
#undef HAVE_HOST_CPU_s390_z196
Packit 5c3484
Packit 5c3484
/* Define to 1 iff we have a s390 with 64-bit registers.  */
Packit 5c3484
#undef HAVE_HOST_CPU_s390_zarch])
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Table of compilers, options, and mpn paths.  This code has various related
Packit 5c3484
# purposes
Packit 5c3484
#
Packit 5c3484
#   - better default CC/CFLAGS selections than autoconf otherwise gives
Packit 5c3484
#   - default CC/CFLAGS selections for extra CPU types specific to GMP
Packit 5c3484
#   - a few tests for known bad compilers
Packit 5c3484
#   - choice of ABIs on suitable systems
Packit 5c3484
#   - selection of corresponding mpn search path
Packit 5c3484
#
Packit 5c3484
# After GMP specific searches and tests, the standard autoconf AC_PROG_CC is
Packit 5c3484
# called.  User selections of CC etc are respected.
Packit 5c3484
#
Packit 5c3484
# Care is taken not to use macros like AC_TRY_COMPILE during the GMP
Packit 5c3484
# pre-testing, since they of course depend on AC_PROG_CC, and also some of
Packit 5c3484
# them cache their results, which is not wanted.
Packit 5c3484
#
Packit 5c3484
# The ABI selection mechanism is unique to GMP.  All that reaches autoconf
Packit 5c3484
# is a different selection of CC/CFLAGS according to the best ABI the system
Packit 5c3484
# supports, and/or what the user selects.  Naturally the mpn assembler code
Packit 5c3484
# selected is very dependent on the ABI.
Packit 5c3484
#
Packit 5c3484
# The closest the standard tools come to a notion of ABI is something like
Packit 5c3484
# "sparc64" which encodes a CPU and an ABI together.  This doesn't seem to
Packit 5c3484
# scale well for GMP, where exact CPU types like "ultrasparc2" are wanted,
Packit 5c3484
# separate from the ABI used on them.
Packit 5c3484
#
Packit 5c3484
#
Packit 5c3484
# The variables set here are
Packit 5c3484
#
Packit 5c3484
#   cclist              the compiler choices
Packit 5c3484
#   xx_cflags           flags for compiler xx
Packit 5c3484
#   xx_cflags_maybe     flags for compiler xx, if they work
Packit 5c3484
#   xx_cppflags         cpp flags for compiler xx
Packit 5c3484
#   xx_cflags_optlist   list of sets of optional flags
Packit 5c3484
#   xx_cflags_yyy       set yyy of optional flags for compiler xx
Packit 5c3484
#   xx_ldflags          -Wc,-foo flags for libtool linking with compiler xx
Packit 5c3484
#   ar_flags            extra flags for $AR
Packit 5c3484
#   nm_flags            extra flags for $NM
Packit 5c3484
#   limb                limb size, can be "longlong"
Packit 5c3484
#   path                mpn search path
Packit 5c3484
#   extra_functions     extra mpn functions
Packit 5c3484
#   fat_path            fat binary mpn search path [if fat binary desired]
Packit 5c3484
#   fat_functions       fat functions
Packit 5c3484
#   fat_thresholds      fat thresholds
Packit 5c3484
#
Packit 5c3484
# Suppose xx_cflags_optlist="arch", then flags from $xx_cflags_arch are
Packit 5c3484
# tried, and the first flag that works will be used.  An optlist like "arch
Packit 5c3484
# cpu optimize" can be used to get multiple independent sets of flags tried.
Packit 5c3484
# The first that works from each will be used.  If no flag in a set works
Packit 5c3484
# then nothing from that set is added.
Packit 5c3484
#
Packit 5c3484
# For multiple ABIs, the scheme extends as follows.
Packit 5c3484
#
Packit 5c3484
#   abilist               set of ABI choices
Packit 5c3484
#   cclist_aa             compiler choices in ABI aa
Packit 5c3484
#   xx_aa_cflags          flags for xx in ABI aa
Packit 5c3484
#   xx_aa_cflags_maybe    flags for xx in ABI aa, if they work
Packit 5c3484
#   xx_aa_cppflags        cpp flags for xx in ABI aa
Packit 5c3484
#   xx_aa_cflags_optlist  list of sets of optional flags in ABI aa
Packit 5c3484
#   xx_aa_cflags_yyy      set yyy of optional flags for compiler xx in ABI aa
Packit 5c3484
#   xx_aa_ldflags         -Wc,-foo flags for libtool linking
Packit 5c3484
#   ar_aa_flags           extra flags for $AR in ABI aa
Packit 5c3484
#   nm_aa_flags           extra flags for $NM in ABI aa
Packit 5c3484
#   limb_aa               limb size in ABI aa, can be "longlong"
Packit 5c3484
#   path_aa               mpn search path in ABI aa
Packit 5c3484
#   extra_functions_aa    extra mpn functions in ABI aa
Packit 5c3484
#
Packit 5c3484
# As a convenience, the unadorned xx_cflags (etc) are used for the last ABI
Packit 5c3484
# in ablist, if an xx_aa_cflags for that ABI isn't given.  For example if
Packit 5c3484
# abilist="64 32" then $cc_64_cflags will be used for the 64-bit ABI, but
Packit 5c3484
# for the 32-bit either $cc_32_cflags or $cc_cflags is used, whichever is
Packit 5c3484
# defined.  This makes it easy to add some 64-bit compilers and flags to an
Packit 5c3484
# unadorned 32-bit set.
Packit 5c3484
#
Packit 5c3484
# limb=longlong (or limb_aa=longlong) applies to all compilers within that
Packit 5c3484
# ABI.  It won't work to have some needing long long and some not, since a
Packit 5c3484
# single instantiated gmp.h will be used by both.
Packit 5c3484
#
Packit 5c3484
# SPEED_CYCLECOUNTER, cyclecounter_size and CALLING_CONVENTIONS_OBJS are
Packit 5c3484
# also set here, with an ABI suffix.
Packit 5c3484
#
Packit 5c3484
#
Packit 5c3484
#
Packit 5c3484
# A table-driven approach like this to mapping cpu type to good compiler
Packit 5c3484
# options is a bit of a maintenance burden, but there's not much uniformity
Packit 5c3484
# between options specifications on different compilers.  Some sort of
Packit 5c3484
# separately updatable tool might be cute.
Packit 5c3484
#
Packit 5c3484
# The use of lots of variables like this, direct and indirect, tends to
Packit 5c3484
# obscure when and how various things are done, but unfortunately it's
Packit 5c3484
# pretty much the only way.  If shell subroutines were portable then actual
Packit 5c3484
# code like "if this .. do that" could be written, but attempting the same
Packit 5c3484
# with full copies of GMP_PROG_CC_WORKS etc expanded at every point would
Packit 5c3484
# hugely bloat the output.
Packit 5c3484
Packit 5c3484
Packit 5c3484
AC_ARG_VAR(ABI, [desired ABI (for processors supporting more than one ABI)])
Packit 5c3484
Packit 5c3484
# abilist needs to be non-empty, "standard" is just a generic name here
Packit 5c3484
abilist="standard"
Packit 5c3484
Packit 5c3484
# FIXME: We'd like to prefer an ANSI compiler, perhaps by preferring
Packit 5c3484
# c89 over cc here.  But note that on HP-UX c89 provides a castrated
Packit 5c3484
# environment, and would want to be excluded somehow.  Maybe
Packit 5c3484
# AC_PROG_CC_STDC already does enough to stick cc into ANSI mode and
Packit 5c3484
# we don't need to worry.
Packit 5c3484
#
Packit 5c3484
cclist="gcc cc"
Packit 5c3484
Packit 5c3484
gcc_cflags="-O2 -pedantic"
Packit 5c3484
gcc_64_cflags="-O2 -pedantic"
Packit 5c3484
cc_cflags="-O"
Packit 5c3484
cc_64_cflags="-O"
Packit 5c3484
Packit 5c3484
SPEED_CYCLECOUNTER_OBJ=
Packit 5c3484
cyclecounter_size=2
Packit 5c3484
Packit 5c3484
AC_SUBST(HAVE_HOST_CPU_FAMILY_power,  0)
Packit 5c3484
AC_SUBST(HAVE_HOST_CPU_FAMILY_powerpc,0)
Packit 5c3484
Packit 5c3484
case $host in
Packit 5c3484
Packit 5c3484
  alpha*-*-*)
Packit 5c3484
    AC_DEFINE(HAVE_HOST_CPU_FAMILY_alpha)
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      alphaev5* | alphapca5*)
Packit 5c3484
	path="alpha/ev5 alpha" ;;
Packit 5c3484
      alphaev67 | alphaev68 | alphaev7*)
Packit 5c3484
        path="alpha/ev67 alpha/ev6 alpha" ;;
Packit 5c3484
      alphaev6)
Packit 5c3484
	path="alpha/ev6 alpha" ;;
Packit 5c3484
      *)
Packit 5c3484
        path="alpha" ;;
Packit 5c3484
    esac
Packit 5c3484
    if test "$enable_assembly" = "yes" ; then
Packit 5c3484
       extra_functions="cntlz"
Packit 5c3484
    fi
Packit 5c3484
    gcc_cflags_optlist="asm cpu oldas" # need asm ahead of cpu, see below
Packit 5c3484
    gcc_cflags_maybe="-mieee"
Packit 5c3484
    gcc_cflags_oldas="-Wa,-oldas"     # see GMP_GCC_WA_OLDAS.
Packit 5c3484
Packit 5c3484
    # gcc 2.7.2.3 doesn't know any -mcpu= for alpha, apparently.
Packit 5c3484
    # gcc 2.95 knows -mcpu= ev4, ev5, ev56, pca56, ev6.
Packit 5c3484
    # gcc 3.0 adds nothing.
Packit 5c3484
    # gcc 3.1 adds ev45, ev67 (but ev45 is the same as ev4).
Packit 5c3484
    # gcc 3.2 adds nothing.
Packit 5c3484
    #
Packit 5c3484
    # gcc version "2.9-gnupro-99r1" under "-O2 -mcpu=ev6" strikes internal
Packit 5c3484
    # compiler errors too easily and is rejected by GMP_PROG_CC_WORKS.  Each
Packit 5c3484
    # -mcpu=ev6 below has a fallback to -mcpu=ev56 for this reason.
Packit 5c3484
    #
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      alpha)        gcc_cflags_cpu="-mcpu=ev4" ;;
Packit 5c3484
      alphaev5)     gcc_cflags_cpu="-mcpu=ev5" ;;
Packit 5c3484
      alphaev56)    gcc_cflags_cpu="-mcpu=ev56" ;;
Packit 5c3484
      alphapca56 | alphapca57)
Packit 5c3484
                    gcc_cflags_cpu="-mcpu=pca56" ;;
Packit 5c3484
      alphaev6)     gcc_cflags_cpu="-mcpu=ev6 -mcpu=ev56" ;;
Packit 5c3484
      alphaev67 | alphaev68 | alphaev7*)
Packit 5c3484
                    gcc_cflags_cpu="-mcpu=ev67 -mcpu=ev6 -mcpu=ev56" ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    # gcc version "2.9-gnupro-99r1" on alphaev68-dec-osf5.1 has been seen
Packit 5c3484
    # accepting -mcpu=ev6, but not putting the assembler in the right mode
Packit 5c3484
    # for what it produces.  We need to do this for it, and need to do it
Packit 5c3484
    # before testing the -mcpu options.
Packit 5c3484
    #
Packit 5c3484
    # On old versions of gcc, which don't know -mcpu=, we believe an
Packit 5c3484
    # explicit -Wa,-mev5 etc will be necessary to put the assembler in
Packit 5c3484
    # the right mode for our .asm files and longlong.h asm blocks.
Packit 5c3484
    #
Packit 5c3484
    # On newer versions of gcc, when -mcpu= is known, we must give a -Wa
Packit 5c3484
    # which is at least as high as the code gcc will generate.  gcc
Packit 5c3484
    # establishes what it needs with a ".arch" directive, our command line
Packit 5c3484
    # option seems to override that.
Packit 5c3484
    #
Packit 5c3484
    # gas prior to 2.14 doesn't accept -mev67, but -mev6 seems enough for
Packit 5c3484
    # ctlz and cttz (in 2.10.0 at least).
Packit 5c3484
    #
Packit 5c3484
    # OSF `as' accepts ev68 but stupidly treats it as ev4.  -arch only seems
Packit 5c3484
    # to affect insns like ldbu which are expanded as macros when necessary.
Packit 5c3484
    # Insns like ctlz which were never available as macros are always
Packit 5c3484
    # accepted and always generate their plain code.
Packit 5c3484
    #
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      alpha)        gcc_cflags_asm="-Wa,-arch,ev4 -Wa,-mev4" ;;
Packit 5c3484
      alphaev5)     gcc_cflags_asm="-Wa,-arch,ev5 -Wa,-mev5" ;;
Packit 5c3484
      alphaev56)    gcc_cflags_asm="-Wa,-arch,ev56 -Wa,-mev56" ;;
Packit 5c3484
      alphapca56 | alphapca57)
Packit 5c3484
                    gcc_cflags_asm="-Wa,-arch,pca56 -Wa,-mpca56" ;;
Packit 5c3484
      alphaev6)     gcc_cflags_asm="-Wa,-arch,ev6 -Wa,-mev6" ;;
Packit 5c3484
      alphaev67 | alphaev68 | alphaev7*)
Packit 5c3484
                    gcc_cflags_asm="-Wa,-arch,ev67 -Wa,-mev67 -Wa,-arch,ev6 -Wa,-mev6" ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    # It might be better to ask "cc" whether it's Cray C or DEC C,
Packit 5c3484
    # instead of relying on the OS part of $host.  But it's hard to
Packit 5c3484
    # imagine either of those compilers anywhere except their native
Packit 5c3484
    # systems.
Packit 5c3484
    #
Packit 5c3484
    GMP_INCLUDE_MPN(alpha/alpha-defs.m4)
Packit 5c3484
    case $host in
Packit 5c3484
      *-cray-unicos*)
Packit 5c3484
        cc_cflags="-O"		# no -g, it silently disables all optimizations
Packit 5c3484
        GMP_INCLUDE_MPN(alpha/unicos.m4)
Packit 5c3484
        # Don't perform any assembly syntax tests on this beast.
Packit 5c3484
        gmp_asm_syntax_testing=no
Packit 5c3484
        ;;
Packit 5c3484
      *-*-osf*)
Packit 5c3484
        GMP_INCLUDE_MPN(alpha/default.m4)
Packit 5c3484
        cc_cflags=""
Packit 5c3484
        cc_cflags_optlist="opt cpu"
Packit 5c3484
Packit 5c3484
        # not sure if -fast works on old versions, so make it optional
Packit 5c3484
	cc_cflags_opt="-fast -O2"
Packit 5c3484
Packit 5c3484
	# DEC C V5.9-005 knows ev4, ev5, ev56, pca56, ev6.
Packit 5c3484
	# Compaq C V6.3-029 adds ev67.
Packit 5c3484
	#
Packit 5c3484
	case $host_cpu in
Packit 5c3484
	  alpha)       cc_cflags_cpu="-arch~ev4~-tune~ev4" ;;
Packit 5c3484
	  alphaev5)    cc_cflags_cpu="-arch~ev5~-tune~ev5" ;;
Packit 5c3484
	  alphaev56)   cc_cflags_cpu="-arch~ev56~-tune~ev56" ;;
Packit 5c3484
	  alphapca56 | alphapca57)
Packit 5c3484
            cc_cflags_cpu="-arch~pca56~-tune~pca56" ;;
Packit 5c3484
	  alphaev6)    cc_cflags_cpu="-arch~ev6~-tune~ev6" ;;
Packit 5c3484
	  alphaev67 | alphaev68 | alphaev7*)
Packit 5c3484
            cc_cflags_cpu="-arch~ev67~-tune~ev67 -arch~ev6~-tune~ev6" ;;
Packit 5c3484
	esac
Packit 5c3484
        ;;
Packit 5c3484
      *)
Packit 5c3484
        GMP_INCLUDE_MPN(alpha/default.m4)
Packit 5c3484
        ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    case $host in
Packit 5c3484
      *-*-unicos*)
Packit 5c3484
        # tune/alpha.asm assumes int==4bytes but unicos uses int==8bytes
Packit 5c3484
        ;;
Packit 5c3484
      *)
Packit 5c3484
        SPEED_CYCLECOUNTER_OBJ=alpha.lo
Packit 5c3484
        cyclecounter_size=1 ;;
Packit 5c3484
    esac
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # Cray vector machines.
Packit 5c3484
  # This must come after alpha* so that we can recognize present and future
Packit 5c3484
  # vector processors with a wildcard.
Packit 5c3484
  *-cray-unicos*)
Packit 5c3484
    gmp_asm_syntax_testing=no
Packit 5c3484
    cclist="cc"
Packit 5c3484
    # We used to have -hscalar0 here as a workaround for miscompilation of
Packit 5c3484
    # mpz/import.c, but let's hope Cray fixes their bugs instead, since
Packit 5c3484
    # -hscalar0 causes disastrously poor code to be generated.
Packit 5c3484
    cc_cflags="-O3 -hnofastmd -htask0 -Wa,-B"
Packit 5c3484
    path="cray"
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  arm*-*-* | aarch64*-*-*)
Packit 5c3484
    abilist="32"
Packit 5c3484
    gcc_cflags="$gcc_cflags $fomit_frame_pointer"
Packit 5c3484
    gcc_cflags_optlist="arch fpmode neon tune"
Packit 5c3484
    gcc_64_cflags_optlist="arch tune"
Packit 5c3484
    gcc_testlist="gcc-arm-umodsi"
Packit 5c3484
    gcc_64_testlist=""
Packit 5c3484
    CALLING_CONVENTIONS_OBJS='arm32call.lo arm32check.lo'
Packit 5c3484
    CALLING_CONVENTIONS_OBJS_64=""
Packit 5c3484
    cclist_64="gcc cc"
Packit 5c3484
    any_32_testlist="sizeof-long-4"
Packit 5c3484
    any_64_testlist="sizeof-long-8"
Packit 5c3484
Packit 5c3484
    # This is needed for clang, which is not content with flags like -mfpu=neon
Packit 5c3484
    # alone.
Packit 5c3484
    case $host in
Packit 5c3484
      *-*-*eabi)
Packit 5c3484
        gcc_cflags_fpmode="-mfloat-abi=softfp" ;;
Packit 5c3484
      *-*-*eabihf)
Packit 5c3484
        gcc_cflags_fpmode="-mfloat-abi=hard" ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    # FIXME: We make mandatory compiler options optional here.  We should
Packit 5c3484
    # either enforce them, or organise to strip paths as the corresponding
Packit 5c3484
    # options fail.
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      armxscale | arm7ej | arm9te | arm9e* | arm10* | armv5*)
Packit 5c3484
	path="arm/v5 arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv5"
Packit 5c3484
	;;
Packit 5c3484
      armsa1 | arm7t* | arm9t* | armv4t*)
Packit 5c3484
	path="arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv4"
Packit 5c3484
	;;
Packit 5c3484
      arm1156 | armv6t2*)
Packit 5c3484
	path="arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv6t2"
Packit 5c3484
	;;
Packit 5c3484
      arm11* | armv6*)
Packit 5c3484
	path="arm/v6 arm/v5 arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv6"
Packit 5c3484
	;;
Packit 5c3484
      armcortexa5 | armv7*)
Packit 5c3484
	path="arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv7-a"
Packit 5c3484
	gcc_cflags_tune="-mtune=cortex-a5"
Packit 5c3484
	;;
Packit 5c3484
      armcortexa5neon)
Packit 5c3484
	path="arm/neon arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	gcc_cflags_neon="-mfpu=neon"
Packit 5c3484
	gcc_cflags_arch="-march=armv7-a"
Packit 5c3484
	gcc_cflags_tune="-mtune=cortex-a5"
Packit 5c3484
	;;
Packit 5c3484
      armcortexa7)
Packit 5c3484
	path="arm/v7a/cora7 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv7-a"
Packit 5c3484
	gcc_cflags_tune="-mtune=cortex-a7"
Packit 5c3484
	;;
Packit 5c3484
      armcortexa7neon)
Packit 5c3484
	path="arm/neon arm/v7a/cora7 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv7-a"
Packit 5c3484
	gcc_cflags_neon="-mfpu=neon"
Packit 5c3484
	gcc_cflags_tune="-mtune=cortex-a7"
Packit 5c3484
	;;
Packit 5c3484
      armcortexa8)
Packit 5c3484
	path="arm/v7a/cora8 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv7-a"
Packit 5c3484
	gcc_cflags_tune="-mtune=cortex-a8"
Packit 5c3484
	;;
Packit 5c3484
      armcortexa8neon)
Packit 5c3484
	path="arm/neon arm/v7a/cora8 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv7-a"
Packit 5c3484
	gcc_cflags_neon="-mfpu=neon"
Packit 5c3484
	gcc_cflags_tune="-mtune=cortex-a8"
Packit 5c3484
	;;
Packit 5c3484
      armcortexa9)
Packit 5c3484
	path="arm/v7a/cora9 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv7-a"
Packit 5c3484
	gcc_cflags_tune="-mtune=cortex-a9"
Packit 5c3484
	;;
Packit 5c3484
      armcortexa9neon)
Packit 5c3484
	path="arm/neon arm/v7a/cora9 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv7-a"
Packit 5c3484
	gcc_cflags_neon="-mfpu=neon"
Packit 5c3484
	gcc_cflags_tune="-mtune=cortex-a9"
Packit 5c3484
	;;
Packit 5c3484
      armcortexa15)
Packit 5c3484
	path="arm/v7a/cora15 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv7-a"
Packit 5c3484
	gcc_cflags_tune="-mtune=cortex-a15 -mtune=cortex-a9"
Packit 5c3484
	;;
Packit 5c3484
      armcortexa15neon)
Packit 5c3484
	path="arm/v7a/cora15/neon arm/neon arm/v7a/cora15 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv7-a"
Packit 5c3484
	gcc_cflags_neon="-mfpu=neon"
Packit 5c3484
	gcc_cflags_tune="-mtune=cortex-a15 -mtune=cortex-a9"
Packit 5c3484
	;;
Packit 5c3484
      armcortexa53 | armcortexa53neon)
Packit 5c3484
        abilist="64 32"
Packit 5c3484
	path="arm/neon arm/v7a/cora9 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	path_64="arm64/cora53 arm64"
Packit 5c3484
	gcc_cflags_arch="-march=armv8-a"
Packit 5c3484
	gcc_cflags_neon="-mfpu=neon"
Packit 5c3484
	gcc_cflags_tune="-mtune=cortex-a53"
Packit 5c3484
	;;
Packit 5c3484
      armcortexa57 | armcortexa57neon)
Packit 5c3484
        abilist="64 32"
Packit 5c3484
	path="arm/v7a/cora15/neon arm/neon arm/v7a/cora15 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	path_64="arm64/cora57 arm64"
Packit 5c3484
	gcc_cflags_arch="-march=armv8-a"
Packit 5c3484
	gcc_cflags_neon="-mfpu=neon"
Packit 5c3484
	gcc_cflags_tune="-mtune=cortex-a57"
Packit 5c3484
	;;
Packit 5c3484
      armcortexa72 | armcortexa72neon)
Packit 5c3484
        abilist="64 32"
Packit 5c3484
	path="arm/v7a/cora15/neon arm/neon arm/v7a/cora15 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	path_64="arm64/cora72 arm64"
Packit 5c3484
	gcc_cflags_arch="-march=armv8-a"
Packit 5c3484
	gcc_cflags_neon="-mfpu=neon"
Packit 5c3484
	gcc_cflags_tune="-mtune=cortex-a72"
Packit 5c3484
	;;
Packit 5c3484
      armexynosm1)
Packit 5c3484
        abilist="64 32"
Packit 5c3484
	path="arm/v7a/cora15/neon arm/neon arm/v7a/cora15 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	path_64="arm64"
Packit 5c3484
	gcc_cflags_arch="-march=armv8-a"
Packit 5c3484
	gcc_cflags_neon="-mfpu=neon"
Packit 5c3484
	gcc_cflags_tune="-mtune=exynosm1"
Packit 5c3484
	;;
Packit 5c3484
      armthunderx)
Packit 5c3484
        abilist="64 32"
Packit 5c3484
	path="arm/v7a/cora15/neon arm/neon arm/v7a/cora15 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	path_64="arm64"
Packit 5c3484
	gcc_cflags_arch="-march=armv8-a"
Packit 5c3484
	gcc_cflags_neon="-mfpu=neon"
Packit 5c3484
	gcc_cflags_tune="-mtune=thunderx"
Packit 5c3484
	;;
Packit 5c3484
      armxgene1)
Packit 5c3484
        abilist="64 32"
Packit 5c3484
	path="arm/v7a/cora15/neon arm/neon arm/v7a/cora15 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	path_64="arm64/xgene1 arm64"
Packit 5c3484
	gcc_cflags_arch="-march=armv8-a"
Packit 5c3484
	gcc_cflags_neon="-mfpu=neon"
Packit 5c3484
	gcc_cflags_tune="-mtune=xgene1"
Packit 5c3484
	;;
Packit 5c3484
      aarch64*)
Packit 5c3484
        abilist="64 32"
Packit 5c3484
	path="arm/v7a/cora15/neon arm/neon arm/v7a/cora15 arm/v6t2 arm/v6 arm/v5 arm"
Packit 5c3484
	path_64="arm64"
Packit 5c3484
	gcc_cflags_arch="-march=armv8-a"
Packit 5c3484
	gcc_cflags_neon="-mfpu=neon"
Packit 5c3484
	gcc_cflags_tune=""
Packit 5c3484
	;;
Packit 5c3484
      *)
Packit 5c3484
	path="arm"
Packit 5c3484
	gcc_cflags_arch="-march=armv4"
Packit 5c3484
	GMP_DEFINE_RAW(["define(<NOTHUMB>,1)"])
Packit 5c3484
	;;
Packit 5c3484
    esac
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # Fujitsu
Packit 5c3484
  [f30[01]-fujitsu-sysv*])
Packit 5c3484
    cclist="gcc vcc"
Packit 5c3484
    # FIXME: flags for vcc?
Packit 5c3484
    vcc_cflags="-g"
Packit 5c3484
    path="fujitsu"
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  hppa*-*-*)
Packit 5c3484
    # HP cc (the one sold separately) is K&R by default, but AM_C_PROTOTYPES
Packit 5c3484
    # will add "-Ae", or "-Aa -D_HPUX_SOURCE", to put it into ansi mode, if
Packit 5c3484
    # possible.
Packit 5c3484
    #
Packit 5c3484
    # gcc for hppa 2.0 can be built either for 2.0n (32-bit) or 2.0w
Packit 5c3484
    # (64-bit), but not both, so there's no option to choose the desired
Packit 5c3484
    # mode, we must instead detect which of the two it is.  This is done by
Packit 5c3484
    # checking sizeof(long), either 4 or 8 bytes respectively.  Do this in
Packit 5c3484
    # ABI=1.0 too, in case someone tries to build that with a 2.0w gcc.
Packit 5c3484
    #
Packit 5c3484
    gcc_cflags_optlist="arch"
Packit 5c3484
    gcc_testlist="sizeof-long-4"
Packit 5c3484
    SPEED_CYCLECOUNTER_OBJ=hppa.lo
Packit 5c3484
    cyclecounter_size=1
Packit 5c3484
Packit 5c3484
    # FIXME: For hppa2.0*, path should be "pa32/hppa2_0 pa32/hppa1_1 pa32".
Packit 5c3484
    # (Can't remember why this isn't done already, have to check what .asm
Packit 5c3484
    # files are available in each and how they run on a typical 2.0 cpu.)
Packit 5c3484
    #
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      hppa1.0*)    path="pa32" ;;
Packit 5c3484
      hppa7000*)   path="pa32/hppa1_1 pa32" ;;
Packit 5c3484
      hppa2.0* | hppa64)
Packit 5c3484
                   path="pa32/hppa2_0 pa32/hppa1_1/pa7100 pa32/hppa1_1 pa32" ;;
Packit 5c3484
      *)           # default to 7100
Packit 5c3484
                   path="pa32/hppa1_1/pa7100 pa32/hppa1_1 pa32" ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    # gcc 2.7.2.3 knows -mpa-risc-1-0 and -mpa-risc-1-1
Packit 5c3484
    # gcc 2.95 adds -mpa-risc-2-0, plus synonyms -march=1.0, 1.1 and 2.0
Packit 5c3484
    #
Packit 5c3484
    # We don't use -mpa-risc-2-0 in ABI=1.0 because 64-bit registers may not
Packit 5c3484
    # be saved by the kernel on an old system.  Actually gcc (as of 3.2)
Packit 5c3484
    # only adds a few float instructions with -mpa-risc-2-0, so it would
Packit 5c3484
    # probably be safe, but let's not take the chance.  In any case, a
Packit 5c3484
    # configuration like --host=hppa2.0 ABI=1.0 is far from optimal.
Packit 5c3484
    #
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      hppa1.0*)           gcc_cflags_arch="-mpa-risc-1-0" ;;
Packit 5c3484
      *)                  # default to 7100
Packit 5c3484
                          gcc_cflags_arch="-mpa-risc-1-1" ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      hppa1.0*)    cc_cflags="+O2" ;;
Packit 5c3484
      *)           # default to 7100
Packit 5c3484
                   cc_cflags="+DA1.1 +O2" ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    case $host in
Packit 5c3484
      hppa2.0*-*-* | hppa64-*-*)
Packit 5c3484
	cclist_20n="gcc cc"
Packit 5c3484
        abilist="2.0n 1.0"
Packit 5c3484
        path_20n="pa64"
Packit 5c3484
	limb_20n=longlong
Packit 5c3484
        any_20n_testlist="sizeof-long-4"
Packit 5c3484
        SPEED_CYCLECOUNTER_OBJ_20n=hppa2.lo
Packit 5c3484
        cyclecounter_size_20n=2
Packit 5c3484
Packit 5c3484
        # -mpa-risc-2-0 is only an optional flag, in case an old gcc is
Packit 5c3484
        # used.  Assembler support for 2.0 is essential though, for our asm
Packit 5c3484
        # files.
Packit 5c3484
	gcc_20n_cflags="$gcc_cflags"
Packit 5c3484
	gcc_20n_cflags_optlist="arch"
Packit 5c3484
        gcc_20n_cflags_arch="-mpa-risc-2-0 -mpa-risc-1-1"
Packit 5c3484
        gcc_20n_testlist="sizeof-long-4 hppa-level-2.0"
Packit 5c3484
Packit 5c3484
        cc_20n_cflags="+DA2.0 +e +O2 -Wl,+vnocompatwarnings"
Packit 5c3484
        cc_20n_testlist="hpc-hppa-2-0"
Packit 5c3484
Packit 5c3484
	# ABI=2.0w is available for hppa2.0w and hppa2.0, but not for
Packit 5c3484
	# hppa2.0n, on the assumption that that the latter indicates a
Packit 5c3484
	# desire for ABI=2.0n.
Packit 5c3484
	case $host in
Packit 5c3484
        hppa2.0n-*-*) ;;
Packit 5c3484
        *)
Packit 5c3484
          # HPUX 10 and earlier cannot run 2.0w.  Not sure about other
Packit 5c3484
          # systems (GNU/Linux for instance), but lets assume they're ok.
Packit 5c3484
          case $host in
Packit 5c3484
            [*-*-hpux[1-9] | *-*-hpux[1-9].* | *-*-hpux10 | *-*-hpux10.*]) ;;
Packit 5c3484
	    [*-*-linux*])  abilist="1.0" ;; # due to linux permanent kernel bug
Packit 5c3484
            *)    abilist="2.0w $abilist" ;;
Packit 5c3484
          esac
Packit 5c3484
Packit 5c3484
          cclist_20w="gcc cc"
Packit 5c3484
	  gcc_20w_cflags="$gcc_cflags -mpa-risc-2-0"
Packit 5c3484
          cc_20w_cflags="+DD64 +O2"
Packit 5c3484
          cc_20w_testlist="hpc-hppa-2-0"
Packit 5c3484
          path_20w="pa64"
Packit 5c3484
	  any_20w_testlist="sizeof-long-8"
Packit 5c3484
          SPEED_CYCLECOUNTER_OBJ_20w=hppa2w.lo
Packit 5c3484
          cyclecounter_size_20w=2
Packit 5c3484
	  ;;
Packit 5c3484
        esac
Packit 5c3484
        ;;
Packit 5c3484
    esac
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  IA64_PATTERN)
Packit 5c3484
    abilist="64"
Packit 5c3484
    GMP_INCLUDE_MPN(ia64/ia64-defs.m4)
Packit 5c3484
    SPEED_CYCLECOUNTER_OBJ=ia64.lo
Packit 5c3484
    any_32_testlist="sizeof-long-4"
Packit 5c3484
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      itanium)   path="ia64/itanium  ia64" ;;
Packit 5c3484
      itanium2)  path="ia64/itanium2 ia64" ;;
Packit 5c3484
      *)         path="ia64" ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    gcc_64_cflags_optlist="tune"
Packit 5c3484
    gcc_32_cflags_optlist=$gcc_64_cflags_optlist
Packit 5c3484
Packit 5c3484
    # gcc pre-release 3.4 adds -mtune itanium and itanium2
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      itanium)   gcc_cflags_tune="-mtune=itanium" ;;
Packit 5c3484
      itanium2)  gcc_cflags_tune="-mtune=itanium2" ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    case $host in
Packit 5c3484
      *-*-linux*)
Packit 5c3484
	cclist="gcc icc"
Packit 5c3484
	icc_cflags="-no-gcc"
Packit 5c3484
	icc_cflags_optlist="opt"
Packit 5c3484
	# Don't use -O3, it is for "large data sets" and also miscompiles GMP.
Packit 5c3484
	# But icc miscompiles GMP at any optimization level, at higher levels
Packit 5c3484
	# it miscompiles more files...
Packit 5c3484
	icc_cflags_opt="-O2 -O1"
Packit 5c3484
	icc_cflags_opt_maybe="-fp-model~precise"
Packit 5c3484
	;;
Packit 5c3484
Packit 5c3484
      *-*-hpux*)
Packit 5c3484
        # HP cc sometimes gets internal errors if the optimization level is
Packit 5c3484
        # too high.  GMP_PROG_CC_WORKS detects this, the "_opt" fallbacks
Packit 5c3484
        # let us use whatever seems to work.
Packit 5c3484
        #
Packit 5c3484
        abilist="32 64"
Packit 5c3484
        any_64_testlist="sizeof-long-8"
Packit 5c3484
Packit 5c3484
        cclist_32="gcc cc"
Packit 5c3484
        path_32="ia64"
Packit 5c3484
        cc_32_cflags=""
Packit 5c3484
        cc_32_cflags_optlist="opt"
Packit 5c3484
        cc_32_cflags_opt="+O2 +O1"
Packit 5c3484
        gcc_32_cflags="$gcc_cflags -milp32"
Packit 5c3484
        limb_32=longlong
Packit 5c3484
        SPEED_CYCLECOUNTER_OBJ_32=ia64.lo
Packit 5c3484
        cyclecounter_size_32=2
Packit 5c3484
Packit 5c3484
        # Must have +DD64 in CPPFLAGS to get the right __LP64__ for headers,
Packit 5c3484
        # but also need it in CFLAGS for linking programs, since automake
Packit 5c3484
        # only uses CFLAGS when linking, not CPPFLAGS.
Packit 5c3484
        # FIXME: Maybe should use cc_64_ldflags for this, but that would
Packit 5c3484
        # need GMP_LDFLAGS used consistently by all the programs.
Packit 5c3484
        #
Packit 5c3484
        cc_64_cflags="+DD64"
Packit 5c3484
        cc_64_cppflags="+DD64"
Packit 5c3484
        cc_64_cflags_optlist="opt"
Packit 5c3484
        cc_64_cflags_opt="+O2 +O1"
Packit 5c3484
        gcc_64_cflags="$gcc_cflags -mlp64"
Packit 5c3484
        ;;
Packit 5c3484
    esac
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # Motorola 68k
Packit 5c3484
  #
Packit 5c3484
  M68K_PATTERN)
Packit 5c3484
    AC_DEFINE(HAVE_HOST_CPU_FAMILY_m68k)
Packit 5c3484
    GMP_INCLUDE_MPN(m68k/m68k-defs.m4)
Packit 5c3484
    gcc_cflags="$gcc_cflags $fomit_frame_pointer"
Packit 5c3484
    gcc_cflags_optlist="arch"
Packit 5c3484
Packit 5c3484
    # gcc 2.7.2 knows -m68000, -m68020, -m68030, -m68040.
Packit 5c3484
    # gcc 2.95 adds -mcpu32, -m68060.
Packit 5c3484
    # FIXME: Maybe "-m68020 -mnobitfield" would suit cpu32 on 2.7.2.
Packit 5c3484
    #
Packit 5c3484
    case $host_cpu in
Packit 5c3484
    m68020)  gcc_cflags_arch="-m68020" ;;
Packit 5c3484
    m68030)  gcc_cflags_arch="-m68030" ;;
Packit 5c3484
    m68040)  gcc_cflags_arch="-m68040" ;;
Packit 5c3484
    m68060)  gcc_cflags_arch="-m68060 -m68000" ;;
Packit 5c3484
    m68360)  gcc_cflags_arch="-mcpu32 -m68000" ;;
Packit 5c3484
    *)       gcc_cflags_arch="-m68000" ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    # FIXME: m68k/mc68020 looks like it's ok for cpu32, but this wants to be
Packit 5c3484
    # tested.  Will need to introduce an m68k/cpu32 if m68k/mc68020 ever uses
Packit 5c3484
    # the bitfield instructions.
Packit 5c3484
    case $host_cpu in
Packit 5c3484
    [m680[234]0 | m68360])  path="m68k/mc68020 m68k" ;;
Packit 5c3484
    *)                      path="m68k" ;;
Packit 5c3484
    esac
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # Motorola 88k
Packit 5c3484
  m88k*-*-*)
Packit 5c3484
    path="m88k"
Packit 5c3484
    ;;
Packit 5c3484
  m88110*-*-*)
Packit 5c3484
    gcc_cflags="$gcc_cflags -m88110"
Packit 5c3484
    path="m88k/mc88110 m88k"
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # IRIX 5 and earlier can only run 32-bit o32.
Packit 5c3484
  #
Packit 5c3484
  # IRIX 6 and up always has a 64-bit mips CPU can run n32 or 64.  n32 is
Packit 5c3484
  # preferred over 64, but only because that's been the default in past
Packit 5c3484
  # versions of GMP.  The two are equally efficient.
Packit 5c3484
  #
Packit 5c3484
  # Linux kernel 2.2.13 arch/mips/kernel/irixelf.c has a comment about not
Packit 5c3484
  # supporting n32 or 64.
Packit 5c3484
  #
Packit 5c3484
  # For reference, libtool (eg. 1.5.6) recognises the n32 ABI and knows the
Packit 5c3484
  # right options to use when linking (both cc and gcc), so no need for
Packit 5c3484
  # anything special from us.
Packit 5c3484
  #
Packit 5c3484
  mips*-*-*)
Packit 5c3484
    abilist="o32"
Packit 5c3484
    gcc_cflags_optlist="abi"
Packit 5c3484
    gcc_cflags_abi="-mabi=32 -m32"
Packit 5c3484
    gcc_testlist="gcc-mips-o32"
Packit 5c3484
    path="mips32"
Packit 5c3484
    cc_cflags="-O2 -o32"   # no -g, it disables all optimizations
Packit 5c3484
    # this suits both mips32 and mips64
Packit 5c3484
    GMP_INCLUDE_MPN(mips32/mips-defs.m4)
Packit 5c3484
Packit 5c3484
    case $host in
Packit 5c3484
      [mips64*-*-* | mips*-*-irix[6789]*])
Packit 5c3484
        abilist="n32 64 o32"
Packit 5c3484
Packit 5c3484
        cclist_n32="gcc cc"
Packit 5c3484
        gcc_n32_cflags_optlist="abi"
Packit 5c3484
        gcc_n32_cflags="$gcc_cflags"
Packit 5c3484
        gcc_n32_cflags_abi="-mabi=n32 -mn32"
Packit 5c3484
        cc_n32_cflags="-O2 -n32"	# no -g, it disables all optimizations
Packit 5c3484
        limb_n32=longlong
Packit 5c3484
        path_n32="mips64"
Packit 5c3484
Packit 5c3484
        cclist_64="gcc cc"
Packit 5c3484
        gcc_64_cflags_optlist="abi"
Packit 5c3484
        gcc_64_cflags="$gcc_cflags"
Packit 5c3484
        gcc_64_cflags_abi="-mabi=64 -m64"
Packit 5c3484
        gcc_64_ldflags="-Wc,-mabi=64"
Packit 5c3484
        cc_64_cflags="-O2 -64"		# no -g, it disables all optimizations
Packit 5c3484
        cc_64_ldflags="-Wc,-64"
Packit 5c3484
        path_64="mips64"
Packit 5c3484
        ;;
Packit 5c3484
    esac
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # Darwin (powerpc-apple-darwin1.3) has it's hacked gcc installed as cc.
Packit 5c3484
  # Our usual "gcc in disguise" detection means gcc_cflags etc here gets
Packit 5c3484
  # used.
Packit 5c3484
  #
Packit 5c3484
  # The darwin pre-compiling preprocessor is disabled with -no-cpp-precomp
Packit 5c3484
  # since it doesn't like "__attribute__ ((mode (SI)))" etc in gmp-impl.h,
Packit 5c3484
  # and so always ends up running the plain preprocessor anyway.  This could
Packit 5c3484
  # be done in CPPFLAGS rather than CFLAGS, but there's not many places
Packit 5c3484
  # preprocessing is done separately, and this is only a speedup, the normal
Packit 5c3484
  # preprocessor gets run if there's any problems.
Packit 5c3484
  #
Packit 5c3484
  # We used to use -Wa,-mppc with gcc, but can't remember exactly why.
Packit 5c3484
  # Presumably it was for old versions of gcc where -mpowerpc doesn't put
Packit 5c3484
  # the assembler in the right mode.  In any case -Wa,-mppc is not good, for
Packit 5c3484
  # instance -mcpu=604 makes recent gcc use -m604 to get access to the
Packit 5c3484
  # "fsel" instruction, but a -Wa,-mppc overrides that, making code that
Packit 5c3484
  # comes out with fsel fail.
Packit 5c3484
  #
Packit 5c3484
  # (Note also that the darwin assembler doesn't accept "-mppc", so any
Packit 5c3484
  # -Wa,-mppc was used only if it worked.  The right flag on darwin would be
Packit 5c3484
  # "-arch ppc" or some such, but that's already the default.)
Packit 5c3484
  #
Packit 5c3484
  [powerpc*-*-* | power[3-9]-*-*])
Packit 5c3484
    AC_DEFINE(HAVE_HOST_CPU_FAMILY_powerpc)
Packit 5c3484
    HAVE_HOST_CPU_FAMILY_powerpc=1
Packit 5c3484
    abilist="32"
Packit 5c3484
    cclist="gcc cc"
Packit 5c3484
    cc_cflags="-O2"
Packit 5c3484
    gcc_32_cflags_maybe="-m32"
Packit 5c3484
    gcc_cflags_optlist="precomp subtype asm cpu"
Packit 5c3484
    gcc_cflags_precomp="-no-cpp-precomp"
Packit 5c3484
    gcc_cflags_subtype="-force_cpusubtype_ALL"	# for vmx on darwin
Packit 5c3484
    gcc_cflags_asm=""
Packit 5c3484
    gcc_cflags_cpu=""
Packit 5c3484
    vmx_path=""
Packit 5c3484
Packit 5c3484
    # grab this object, though it's not a true cycle counter routine
Packit 5c3484
    SPEED_CYCLECOUNTER_OBJ=powerpc.lo
Packit 5c3484
    cyclecounter_size=0
Packit 5c3484
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      powerpc740 | powerpc750)
Packit 5c3484
        path="powerpc32/750 powerpc32" ;;
Packit 5c3484
      powerpc7400 | powerpc7410)
Packit 5c3484
        path="powerpc32/vmx powerpc32/750 powerpc32" ;;
Packit 5c3484
      [powerpc74[45]?])
Packit 5c3484
        path="powerpc32/vmx powerpc32" ;;
Packit 5c3484
      *)
Packit 5c3484
        path="powerpc32" ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      powerpc401)   gcc_cflags_cpu="-mcpu=401" ;;
Packit 5c3484
      powerpc403)   gcc_cflags_cpu="-mcpu=403"
Packit 5c3484
		    xlc_cflags_arch="-qarch=403 -qarch=ppc" ;;
Packit 5c3484
      powerpc405)   gcc_cflags_cpu="-mcpu=405" ;;
Packit 5c3484
      powerpc505)   gcc_cflags_cpu="-mcpu=505" ;;
Packit 5c3484
      powerpc601)   gcc_cflags_cpu="-mcpu=601"
Packit 5c3484
		    xlc_cflags_arch="-qarch=601 -qarch=ppc" ;;
Packit 5c3484
      powerpc602)   gcc_cflags_cpu="-mcpu=602"
Packit 5c3484
		    xlc_cflags_arch="-qarch=602 -qarch=ppc" ;;
Packit 5c3484
      powerpc603)   gcc_cflags_cpu="-mcpu=603"
Packit 5c3484
		    xlc_cflags_arch="-qarch=603 -qarch=ppc" ;;
Packit 5c3484
      powerpc603e)  gcc_cflags_cpu="-mcpu=603e -mcpu=603"
Packit 5c3484
		    xlc_cflags_arch="-qarch=603 -qarch=ppc" ;;
Packit 5c3484
      powerpc604)   gcc_cflags_cpu="-mcpu=604"
Packit 5c3484
		    xlc_cflags_arch="-qarch=604 -qarch=ppc" ;;
Packit 5c3484
      powerpc604e)  gcc_cflags_cpu="-mcpu=604e -mcpu=604"
Packit 5c3484
		    xlc_cflags_arch="-qarch=604 -qarch=ppc" ;;
Packit 5c3484
      powerpc620)   gcc_cflags_cpu="-mcpu=620" ;;
Packit 5c3484
      powerpc630)   gcc_cflags_cpu="-mcpu=630"
Packit 5c3484
		    xlc_cflags_arch="-qarch=pwr3"
Packit 5c3484
		    cpu_path="p3 p3-p7" ;;
Packit 5c3484
      powerpc740)   gcc_cflags_cpu="-mcpu=740" ;;
Packit 5c3484
      powerpc7400 | powerpc7410)
Packit 5c3484
		    gcc_cflags_asm="-Wa,-maltivec"
Packit 5c3484
		    gcc_cflags_cpu="-mcpu=7400 -mcpu=750" ;;
Packit 5c3484
      [powerpc74[45]?])
Packit 5c3484
		    gcc_cflags_asm="-Wa,-maltivec"
Packit 5c3484
		    gcc_cflags_cpu="-mcpu=7450" ;;
Packit 5c3484
      powerpc750)   gcc_cflags_cpu="-mcpu=750" ;;
Packit 5c3484
      powerpc801)   gcc_cflags_cpu="-mcpu=801" ;;
Packit 5c3484
      powerpc821)   gcc_cflags_cpu="-mcpu=821" ;;
Packit 5c3484
      powerpc823)   gcc_cflags_cpu="-mcpu=823" ;;
Packit 5c3484
      powerpc860)   gcc_cflags_cpu="-mcpu=860" ;;
Packit 5c3484
      powerpc970)   gcc_cflags_cpu="-mtune=970"
Packit 5c3484
		    xlc_cflags_arch="-qarch=970 -qarch=pwr3"
Packit 5c3484
		    vmx_path="powerpc64/vmx"
Packit 5c3484
		    cpu_path="p4 p3-p7" ;;
Packit 5c3484
      power4)	    gcc_cflags_cpu="-mtune=power4"
Packit 5c3484
		    xlc_cflags_arch="-qarch=pwr4"
Packit 5c3484
		    cpu_path="p4 p3-p7" ;;
Packit 5c3484
      power5)	    gcc_cflags_cpu="-mtune=power5 -mtune=power4"
Packit 5c3484
		    xlc_cflags_arch="-qarch=pwr5"
Packit 5c3484
		    cpu_path="p5 p4 p3-p7" ;;
Packit 5c3484
      power6)	    gcc_cflags_cpu="-mtune=power6"
Packit 5c3484
		    xlc_cflags_arch="-qarch=pwr6"
Packit 5c3484
		    cpu_path="p6 p3-p7" ;;
Packit 5c3484
      power7)	    gcc_cflags_cpu="-mtune=power7 -mtune=power5"
Packit 5c3484
		    xlc_cflags_arch="-qarch=pwr7 -qarch=pwr5"
Packit 5c3484
		    cpu_path="p7 p5 p4 p3-p7" ;;
Packit 5c3484
      [power[89]])  gcc_cflags_cpu="-mtune=power8 -mtune=power7 -mtune=power5"
Packit 5c3484
		    xlc_cflags_arch="-qarch=pwr8 -qarch=pwr7 -qarch=pwr5"
Packit 5c3484
		    cpu_path="p8 p7 p5 p4 p3-p7" ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    case $host in
Packit 5c3484
      *-*-aix*)
Packit 5c3484
	cclist="gcc xlc cc"
Packit 5c3484
	gcc_32_cflags_maybe="-maix32"
Packit 5c3484
	xlc_cflags="-O2 -qmaxmem=20000"
Packit 5c3484
	xlc_cflags_optlist="arch"
Packit 5c3484
	xlc_32_cflags_maybe="-q32"
Packit 5c3484
	ar_32_flags="-X32"
Packit 5c3484
	nm_32_flags="-X32"
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    case $host in
Packit 5c3484
      POWERPC64_PATTERN)
Packit 5c3484
	case $host in
Packit 5c3484
	  *-*-aix*)
Packit 5c3484
	    # On AIX a true 64-bit ABI is available.
Packit 5c3484
	    # Need -Wc to pass object type flags through to the linker.
Packit 5c3484
	    abilist="mode64 $abilist"
Packit 5c3484
	    cclist_mode64="gcc xlc"
Packit 5c3484
	    gcc_mode64_cflags="$gcc_cflags -maix64 -mpowerpc64"
Packit 5c3484
	    gcc_mode64_cflags_optlist="cpu"
Packit 5c3484
	    gcc_mode64_ldflags="-Wc,-maix64"
Packit 5c3484
	    xlc_mode64_cflags="-O2 -q64 -qmaxmem=20000"
Packit 5c3484
	    xlc_mode64_cflags_optlist="arch"
Packit 5c3484
	    xlc_mode64_ldflags="-Wc,-q64"
Packit 5c3484
	    # Must indicate object type to ar and nm
Packit 5c3484
	    ar_mode64_flags="-X64"
Packit 5c3484
	    nm_mode64_flags="-X64"
Packit 5c3484
	    path_mode64=""
Packit 5c3484
	    p=""
Packit 5c3484
	    for i in $cpu_path
Packit 5c3484
	      do path_mode64="${path_mode64}powerpc64/mode64/$i "
Packit 5c3484
		 path_mode64="${path_mode64}powerpc64/$i "
Packit 5c3484
		 p="${p} powerpc32/$i "
Packit 5c3484
	      done
Packit 5c3484
	    path_mode64="${path_mode64}powerpc64/mode64 $vmx_path powerpc64"
Packit 5c3484
	    path="$p $path"
Packit 5c3484
	    # grab this object, though it's not a true cycle counter routine
Packit 5c3484
	    SPEED_CYCLECOUNTER_OBJ_mode64=powerpc64.lo
Packit 5c3484
	    cyclecounter_size_mode64=0
Packit 5c3484
	    ;;
Packit 5c3484
	  *-*-darwin*)
Packit 5c3484
	    # On Darwin we can use 64-bit instructions with a longlong limb,
Packit 5c3484
	    # but the chip still in 32-bit mode.
Packit 5c3484
	    # In theory this can be used on any OS which knows how to save
Packit 5c3484
	    # 64-bit registers in a context switch.
Packit 5c3484
	    #
Packit 5c3484
	    # Note that we must use -mpowerpc64 with gcc, since the
Packit 5c3484
	    # longlong.h macros expect limb operands in a single 64-bit
Packit 5c3484
	    # register, not two 32-bit registers as would be given for a
Packit 5c3484
	    # long long without -mpowerpc64.  In theory we could detect and
Packit 5c3484
	    # accommodate both styles, but the proper 64-bit registers will
Packit 5c3484
	    # be fastest and are what we really want to use.
Packit 5c3484
	    #
Packit 5c3484
	    # One would think -mpowerpc64 would set the assembler in the right
Packit 5c3484
	    # mode to handle 64-bit instructions.  But for that, also
Packit 5c3484
	    # -force_cpusubtype_ALL is needed.
Packit 5c3484
	    #
Packit 5c3484
	    # Do not use -fast for Darwin, it actually adds options
Packit 5c3484
	    # incompatible with a shared library.
Packit 5c3484
	    #
Packit 5c3484
	    abilist="mode64 mode32 $abilist"
Packit 5c3484
	    gcc_cflags_opt="-O3 -O2 -O1"	# will this become used?
Packit 5c3484
	    cclist_mode32="gcc"
Packit 5c3484
	    gcc_mode32_cflags_maybe="-m32"
Packit 5c3484
	    gcc_mode32_cflags="-mpowerpc64"
Packit 5c3484
	    gcc_mode32_cflags_optlist="subtype cpu opt"
Packit 5c3484
	    gcc_mode32_cflags_subtype="-force_cpusubtype_ALL"
Packit 5c3484
	    gcc_mode32_cflags_opt="-O3 -O2 -O1"
Packit 5c3484
	    limb_mode32=longlong
Packit 5c3484
	    cclist_mode64="gcc"
Packit 5c3484
	    gcc_mode64_cflags="-m64"
Packit 5c3484
	    gcc_mode64_cflags_optlist="cpu opt"
Packit 5c3484
	    gcc_mode64_cflags_opt="-O3 -O2 -O1"
Packit 5c3484
	    path_mode64=""
Packit 5c3484
	    path_mode32=""
Packit 5c3484
	    p=""
Packit 5c3484
	    for i in $cpu_path
Packit 5c3484
	      do path_mode64="${path_mode64}powerpc64/mode64/$i "
Packit 5c3484
		 path_mode64="${path_mode64}powerpc64/$i "
Packit 5c3484
		 path_mode32="${path_mode32}powerpc64/mode32/$i "
Packit 5c3484
		 path_mode32="${path_mode32}powerpc64/$i "
Packit 5c3484
		 p="${p} powerpc32/$i "
Packit 5c3484
	      done
Packit 5c3484
	    path_mode64="${path_mode64}powerpc64/mode64 $vmx_path powerpc64"
Packit 5c3484
	    path_mode32="${path_mode32}powerpc64/mode32 $vmx_path powerpc64"
Packit 5c3484
	    path="$p $path"
Packit 5c3484
	    SPEED_CYCLECOUNTER_OBJ_mode64=powerpc64.lo
Packit 5c3484
	    cyclecounter_size_mode64=0
Packit 5c3484
	    any_mode64_testlist="sizeof-long-8"
Packit 5c3484
	    ;;
Packit 5c3484
	  *-*-linux* | *-*-*bsd*)
Packit 5c3484
	    # On GNU/Linux, assume the processor is in 64-bit mode.  Some
Packit 5c3484
	    # environments have a gcc that is always in 64-bit mode, while
Packit 5c3484
	    # others require -m64, hence the use of cflags_maybe.  The
Packit 5c3484
	    # sizeof-long-8 test checks the mode is right (for the no option
Packit 5c3484
	    # case).
Packit 5c3484
	    #
Packit 5c3484
	    # -mpowerpc64 is not used, since it should be the default in
Packit 5c3484
	    # 64-bit mode.  (We need its effect for the various longlong.h
Packit 5c3484
	    # asm macros to be right of course.)
Packit 5c3484
	    #
Packit 5c3484
	    # gcc64 was an early port of gcc to 64-bit mode, but should be
Packit 5c3484
	    # obsolete before too long.  We prefer plain gcc when it knows
Packit 5c3484
	    # 64-bits.
Packit 5c3484
	    #
Packit 5c3484
	    abilist="mode64 mode32 $abilist"
Packit 5c3484
	    cclist_mode32="gcc"
Packit 5c3484
	    gcc_mode32_cflags_maybe="-m32"
Packit 5c3484
	    gcc_mode32_cflags="-mpowerpc64"
Packit 5c3484
	    gcc_mode32_cflags_optlist="cpu opt"
Packit 5c3484
	    gcc_mode32_cflags_opt="-O3 -O2 -O1"
Packit 5c3484
	    limb_mode32=longlong
Packit 5c3484
	    cclist_mode64="gcc gcc64"
Packit 5c3484
	    gcc_mode64_cflags_maybe="-m64"
Packit 5c3484
	    gcc_mode64_cflags_optlist="cpu opt"
Packit 5c3484
	    gcc_mode64_cflags_opt="-O3 -O2 -O1"
Packit 5c3484
	    path_mode64=""
Packit 5c3484
	    path_mode32=""
Packit 5c3484
	    p=""
Packit 5c3484
	    for i in $cpu_path
Packit 5c3484
	      do path_mode64="${path_mode64}powerpc64/mode64/$i "
Packit 5c3484
		 path_mode64="${path_mode64}powerpc64/$i "
Packit 5c3484
		 path_mode32="${path_mode32}powerpc64/mode32/$i "
Packit 5c3484
		 path_mode32="${path_mode32}powerpc64/$i "
Packit 5c3484
		 p="${p} powerpc32/$i "
Packit 5c3484
	      done
Packit 5c3484
	    path_mode64="${path_mode64}powerpc64/mode64 $vmx_path powerpc64"
Packit 5c3484
	    path_mode32="${path_mode32}powerpc64/mode32 $vmx_path powerpc64"
Packit 5c3484
	    path="$p $path"
Packit 5c3484
	    SPEED_CYCLECOUNTER_OBJ_mode64=powerpc64.lo
Packit 5c3484
	    cyclecounter_size_mode64=0
Packit 5c3484
	    any_mode64_testlist="sizeof-long-8"
Packit 5c3484
	    ;;
Packit 5c3484
	esac
Packit 5c3484
	;;
Packit 5c3484
    esac
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # POWER 32-bit
Packit 5c3484
  [power-*-* | power[12]-*-* | power2sc-*-*])
Packit 5c3484
    AC_DEFINE(HAVE_HOST_CPU_FAMILY_power)
Packit 5c3484
    HAVE_HOST_CPU_FAMILY_power=1
Packit 5c3484
    cclist="gcc"
Packit 5c3484
    if test "$enable_assembly" = "yes" ; then
Packit 5c3484
      extra_functions="udiv_w_sdiv"
Packit 5c3484
    fi
Packit 5c3484
    path="power"
Packit 5c3484
Packit 5c3484
    # gcc 2.7.2 knows rios1, rios2, rsc
Packit 5c3484
    #
Packit 5c3484
    # -mcpu=rios2 can tickle an AIX assembler bug (see GMP_PROG_CC_WORKS) so
Packit 5c3484
    # there needs to be a fallback to just -mpower.
Packit 5c3484
    #
Packit 5c3484
    gcc_cflags_optlist="cpu"
Packit 5c3484
    case $host in
Packit 5c3484
      power-*-*)    gcc_cflags_cpu="-mcpu=power -mpower" ;;
Packit 5c3484
      power1-*-*)   gcc_cflags_cpu="-mcpu=rios1 -mpower" ;;
Packit 5c3484
      power2-*-*)   gcc_cflags_cpu="-mcpu=rios2 -mpower" ;;
Packit 5c3484
      power2sc-*-*) gcc_cflags_cpu="-mcpu=rsc   -mpower" ;;
Packit 5c3484
    esac
Packit 5c3484
    case $host in
Packit 5c3484
    *-*-aix*)
Packit 5c3484
      cclist="gcc xlc"
Packit 5c3484
      xlc_cflags="-O2 -qarch=pwr -qmaxmem=20000"
Packit 5c3484
      ;;
Packit 5c3484
    esac
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # IBM System/390 and z/Architecture
Packit 5c3484
  S390_PATTERN | S390X_PATTERN)
Packit 5c3484
    abilist="32"
Packit 5c3484
    gcc_cflags="$gcc_cflags $fomit_frame_pointer"
Packit 5c3484
    gcc_cflags_optlist="arch"
Packit 5c3484
    path="s390_32"
Packit 5c3484
    if test "$enable_assembly" = "yes" ; then
Packit 5c3484
       extra_functions="udiv_w_sdiv"
Packit 5c3484
    fi
Packit 5c3484
    gcc_32_cflags_maybe="-m31"
Packit 5c3484
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      s390)
Packit 5c3484
	;;
Packit 5c3484
      z900 | z900esa)
Packit 5c3484
        cpu="z900"
Packit 5c3484
        gccarch="$cpu"
Packit 5c3484
	path="s390_32/esame/$cpu s390_32/esame s390_32"
Packit 5c3484
	gcc_cflags_arch="-march=$gccarch"
Packit 5c3484
	AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu)
Packit 5c3484
	AC_DEFINE(HAVE_HOST_CPU_s390_zarch)
Packit 5c3484
	extra_functions=""
Packit 5c3484
        ;;
Packit 5c3484
      z990 | z990esa)
Packit 5c3484
        cpu="z990"
Packit 5c3484
        gccarch="$cpu"
Packit 5c3484
	path="s390_32/esame/$cpu s390_32/esame s390_32"
Packit 5c3484
	gcc_cflags_arch="-march=$gccarch"
Packit 5c3484
	AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu)
Packit 5c3484
	AC_DEFINE(HAVE_HOST_CPU_s390_zarch)
Packit 5c3484
	extra_functions=""
Packit 5c3484
        ;;
Packit 5c3484
      z9 | z9esa)
Packit 5c3484
        cpu="z9"
Packit 5c3484
	gccarch="z9-109"
Packit 5c3484
	path="s390_32/esame/$cpu s390_32/esame s390_32"
Packit 5c3484
	gcc_cflags_arch="-march=$gccarch"
Packit 5c3484
	AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu)
Packit 5c3484
	AC_DEFINE(HAVE_HOST_CPU_s390_zarch)
Packit 5c3484
	extra_functions=""
Packit 5c3484
        ;;
Packit 5c3484
      z10 | z10esa)
Packit 5c3484
        cpu="z10"
Packit 5c3484
	gccarch="z10"
Packit 5c3484
	path="s390_32/esame/$cpu s390_32/esame s390_32"
Packit 5c3484
	gcc_cflags_arch="-march=$gccarch"
Packit 5c3484
	AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu)
Packit 5c3484
	AC_DEFINE(HAVE_HOST_CPU_s390_zarch)
Packit 5c3484
	extra_functions=""
Packit 5c3484
        ;;
Packit 5c3484
      z196 | z196esa)
Packit 5c3484
        cpu="z196"
Packit 5c3484
	gccarch="z196"
Packit 5c3484
	path="s390_32/esame/$cpu s390_32/esame s390_32"
Packit 5c3484
	gcc_cflags_arch="-march=$gccarch"
Packit 5c3484
	AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu)
Packit 5c3484
	AC_DEFINE(HAVE_HOST_CPU_s390_zarch)
Packit 5c3484
	extra_functions=""
Packit 5c3484
        ;;
Packit 5c3484
      esac
Packit 5c3484
Packit 5c3484
    case $host in
Packit 5c3484
      S390X_PATTERN)
Packit 5c3484
	abilist="64 32"
Packit 5c3484
	cclist_64="gcc"
Packit 5c3484
	gcc_64_cflags_optlist="arch"
Packit 5c3484
	gcc_64_cflags="$gcc_cflags -m64"
Packit 5c3484
	path_64="s390_64/$host_cpu s390_64"
Packit 5c3484
	extra_functions=""
Packit 5c3484
	;;
Packit 5c3484
      esac
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  sh-*-*)   path="sh" ;;
Packit 5c3484
  [sh[2-4]-*-*])  path="sh/sh2 sh" ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  *sparc*-*-*)
Packit 5c3484
    # sizeof(long)==4 or 8 is tested, to ensure we get the right ABI.  We've
Packit 5c3484
    # had various bug reports where users have set CFLAGS for their desired
Packit 5c3484
    # mode, but not set our ABI.  For some reason it's sparc where this
Packit 5c3484
    # keeps coming up, presumably users there are accustomed to driving the
Packit 5c3484
    # compiler mode that way.  The effect of our testlist setting is to
Packit 5c3484
    # reject ABI=64 in favour of ABI=32 if the user has forced the flags to
Packit 5c3484
    # 32-bit mode.
Packit 5c3484
    #
Packit 5c3484
    abilist="32"
Packit 5c3484
    cclist="gcc acc cc"
Packit 5c3484
    any_testlist="sizeof-long-4"
Packit 5c3484
    GMP_INCLUDE_MPN(sparc32/sparc-defs.m4)
Packit 5c3484
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      sparcv8 | microsparc | turbosparc)
Packit 5c3484
        path="sparc32/v8 sparc32" ;;
Packit 5c3484
      supersparc)
Packit 5c3484
        path="sparc32/v8/supersparc sparc32/v8 sparc32" ;;
Packit 5c3484
      [sparc64 | sparcv9* | ultrasparc | ultrasparc[234]*])
Packit 5c3484
        path="sparc32/v9 sparc32/v8 sparc32" ;;
Packit 5c3484
      [ultrasparct[12345]])
Packit 5c3484
        path="sparc32/ultrasparct1 sparc32/v8 sparc32" ;;
Packit 5c3484
      *)
Packit 5c3484
        path="sparc32" ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    # gcc 2.7.2 doesn't know about v9 and doesn't pass -xarch=v8plus to the
Packit 5c3484
    # assembler.  Add it explicitly since the solaris assembler won't accept
Packit 5c3484
    # our sparc32/v9 asm code without it.  gas accepts -xarch=v8plus too, so
Packit 5c3484
    # it can be in the cflags unconditionally (though gas doesn't need it).
Packit 5c3484
    #
Packit 5c3484
    # gcc -m32 is needed to force 32-bit mode on a dual-ABI system, but past
Packit 5c3484
    # gcc doesn't know that flag, hence cflags_maybe.  Note that -m32 cannot
Packit 5c3484
    # be done through the optlist since the plain cflags would be run first
Packit 5c3484
    # and we don't want to require the default mode (whatever it is) works.
Packit 5c3484
    #
Packit 5c3484
    # Note it's gcc_32_cflags_maybe and not gcc_cflags_maybe because the
Packit 5c3484
    # latter would be used in the 64-bit ABI on systems like "*bsd" where
Packit 5c3484
    # abilist="64" only.
Packit 5c3484
    #
Packit 5c3484
    gcc_32_cflags_maybe="-m32"
Packit 5c3484
    gcc_cflags_optlist="cpu asm"
Packit 5c3484
Packit 5c3484
    # gcc 2.7.2 knows -mcypress, -msupersparc, -mv8, -msparclite.
Packit 5c3484
    # gcc 2.95 knows -mcpu= v7, hypersparc, sparclite86x, f930, f934,
Packit 5c3484
    #   sparclet, tsc701, v9, ultrasparc.  A warning is given that the
Packit 5c3484
    #   plain -m forms will disappear.
Packit 5c3484
    # gcc 3.3 adds ultrasparc3.
Packit 5c3484
    #
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      supersparc*)
Packit 5c3484
			gcc_cflags_cpu="-mcpu=supersparc -msupersparc"
Packit 5c3484
			gcc_cflags_asm="-Wa,-Av8 -Wa,-xarch=v8";;
Packit 5c3484
      sparcv8 | microsparc* | turbosparc | hypersparc*)
Packit 5c3484
			gcc_cflags_cpu="-mcpu=v8 -mv8"
Packit 5c3484
			gcc_cflags_asm="-Wa,-Av8 -Wa,-xarch=v8";;
Packit 5c3484
      sparc64 | sparcv9*)
Packit 5c3484
			gcc_cflags_cpu="-mcpu=v9"
Packit 5c3484
			gcc_32_cflags_asm="-Wa,-Av8 -Wa,-xarch=v8plus"
Packit 5c3484
			gcc_64_cflags_asm="-Wa,-Av9 -Wa,-xarch=v9";;
Packit 5c3484
      ultrasparc1 | ultrasparc2*)
Packit 5c3484
			gcc_cflags_cpu="-mcpu=ultrasparc -mcpu=v9"
Packit 5c3484
			gcc_32_cflags_asm="-Wa,-Av8plusa -Wa,-xarch=v8plusa"
Packit 5c3484
			gcc_64_cflags_asm="-Wa,-Av9a -Wa,-xarch=v9a";;
Packit 5c3484
      [ultrasparc[34]])
Packit 5c3484
			gcc_cflags_cpu="-mcpu=ultrasparc3 -mcpu=ultrasparc -mcpu=v9"
Packit 5c3484
			gcc_32_cflags_asm="-Wa,-Av8plusb -Wa,-xarch=v8plusb"
Packit 5c3484
			gcc_64_cflags_asm="-Wa,-Av9b -Wa,-xarch=v9b";;
Packit 5c3484
      [ultrasparct[12]])
Packit 5c3484
			gcc_cflags_cpu="-mcpu=niagara -mcpu=v9"
Packit 5c3484
			gcc_32_cflags_asm="-Wa,-Av8plusc -Wa,-xarch=v8plusc"
Packit 5c3484
			gcc_64_cflags_asm="-Wa,-Av9c -Wa,-xarch=v9c";;
Packit 5c3484
      ultrasparct3)
Packit 5c3484
			gcc_cflags_cpu="-mcpu=niagara3 -mcpu=niagara -mcpu=v9"
Packit 5c3484
			gcc_32_cflags_asm="-Wa,-Av8plusd -Wa,-xarch=v8plusd"
Packit 5c3484
			gcc_64_cflags_asm="-Wa,-Av9d -Wa,-xarch=v9d";;
Packit 5c3484
      [ultrasparct[45]])
Packit 5c3484
			gcc_cflags_cpu="-mcpu=niagara4 -mcpu=niagara3 -mcpu=niagara -mcpu=v9"
Packit 5c3484
			gcc_32_cflags_asm="-Wa,-Av8plusd -Wa,-xarch=v8plusd"
Packit 5c3484
			gcc_64_cflags_asm="-Wa,-Av9d -Wa,-xarch=v9d";;
Packit 5c3484
      *)
Packit 5c3484
			gcc_cflags_cpu="-mcpu=v7 -mcypress"
Packit 5c3484
			gcc_cflags_asm="";;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    # SunPRO cc and acc, and SunOS bundled cc
Packit 5c3484
    case $host in
Packit 5c3484
      *-*-solaris* | *-*-sunos*)
Packit 5c3484
	# Note no -g, it disables all optimizations.
Packit 5c3484
	cc_cflags=
Packit 5c3484
	cc_cflags_optlist="opt arch cpu"
Packit 5c3484
Packit 5c3484
        # SunOS <= 4 cc doesn't know -xO3, fallback to -O2.
Packit 5c3484
	cc_cflags_opt="-xO3 -O2"
Packit 5c3484
Packit 5c3484
        # SunOS cc doesn't know -xarch, apparently always generating v7
Packit 5c3484
        # code, so make this optional
Packit 5c3484
	case $host_cpu in
Packit 5c3484
	  sparcv8 | microsparc* | supersparc* | turbosparc | hypersparc*)
Packit 5c3484
			cc_cflags_arch="-xarch=v8";;
Packit 5c3484
          [ultrasparct[345]])
Packit 5c3484
			cc_cflags_arch="-xarch=v8plusd" ;;
Packit 5c3484
	  sparc64 | sparcv9* | ultrasparc*)
Packit 5c3484
			cc_cflags_arch="-xarch=v8plus" ;;
Packit 5c3484
	  *)
Packit 5c3484
			cc_cflags_arch="-xarch=v7" ;;
Packit 5c3484
	esac
Packit 5c3484
Packit 5c3484
        # SunOS cc doesn't know -xchip and doesn't seem to have an equivalent.
Packit 5c3484
	# SunPRO cc 5 recognises -xchip=generic, old, super, super2, micro,
Packit 5c3484
	#   micro2, hyper, hyper2, powerup, ultra, ultra2, ultra2i.
Packit 5c3484
	# SunPRO cc 6 adds -xchip=ultra2e, ultra3cu.
Packit 5c3484
        #
Packit 5c3484
	case $host_cpu in
Packit 5c3484
	  supersparc*)  cc_cflags_cpu="-xchip=super" ;;
Packit 5c3484
	  microsparc*)  cc_cflags_cpu="-xchip=micro" ;;
Packit 5c3484
	  turbosparc)   cc_cflags_cpu="-xchip=micro2" ;;
Packit 5c3484
	  hypersparc*)  cc_cflags_cpu="-xchip=hyper" ;;
Packit 5c3484
	  ultrasparc)   cc_cflags_cpu="-xchip=ultra" ;;
Packit 5c3484
	  ultrasparc2)  cc_cflags_cpu="-xchip=ultra2 -xchip=ultra" ;;
Packit 5c3484
	  ultrasparc2i) cc_cflags_cpu="-xchip=ultra2i -xchip=ultra2 -xchip=ultra" ;;
Packit 5c3484
	  ultrasparc3)  cc_cflags_cpu="-xchip=ultra3 -xchip=ultra" ;;
Packit 5c3484
	  ultrasparc4)  cc_cflags_cpu="-xchip=ultra4 -xchip=ultra3 -xchip=ultra" ;;
Packit 5c3484
	  ultrasparct1) cc_cflags_cpu="-xchip=ultraT1" ;;
Packit 5c3484
	  ultrasparct2) cc_cflags_cpu="-xchip=ultraT2 -xchip=ultraT1" ;;
Packit 5c3484
	  ultrasparct3) cc_cflags_cpu="-xchip=ultraT3 -xchip=ultraT2" ;;
Packit 5c3484
	  ultrasparct4) cc_cflags_cpu="-xchip=T4" ;;
Packit 5c3484
	  ultrasparct5) cc_cflags_cpu="-xchip=T5 -xchip=T4" ;;
Packit 5c3484
	  *)            cc_cflags_cpu="-xchip=generic" ;;
Packit 5c3484
	esac
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      sparc64 | sparcv9* | ultrasparc*)
Packit 5c3484
        case $host in
Packit 5c3484
          # Solaris 6 and earlier cannot run ABI=64 since it doesn't save
Packit 5c3484
          # registers properly, so ABI=32 is left as the only choice.
Packit 5c3484
          #
Packit 5c3484
          [*-*-solaris2.[0-6] | *-*-solaris2.[0-6].*]) ;;
Packit 5c3484
Packit 5c3484
          # BSD sparc64 ports are 64-bit-only systems, so ABI=64 is the only
Packit 5c3484
          # choice.  In fact they need no special compiler flags, gcc -m64
Packit 5c3484
          # is the default, but it doesn't hurt to add it.  v9 CPUs always
Packit 5c3484
          # use the sparc64 port, since the plain 32-bit sparc ports don't
Packit 5c3484
          # run on a v9.
Packit 5c3484
          #
Packit 5c3484
          *-*-*bsd*) abilist="64" ;;
Packit 5c3484
Packit 5c3484
          # For all other systems, we try both 64 and 32.
Packit 5c3484
          #
Packit 5c3484
          # GNU/Linux sparc64 has only recently gained a 64-bit user mode.
Packit 5c3484
          # In the past sparc64 meant a v9 cpu, but there were no 64-bit
Packit 5c3484
          # operations in user mode.  We assume that if "gcc -m64" works
Packit 5c3484
          # then the system is suitable.  Hopefully even if someone attempts
Packit 5c3484
          # to put a new gcc and/or glibc on an old system it won't run.
Packit 5c3484
          #
Packit 5c3484
          *) abilist="64 32" ;;
Packit 5c3484
        esac
Packit 5c3484
Packit 5c3484
	case $host_cpu in
Packit 5c3484
	  ultrasparc | ultrasparc2 | ultrasparc2i)
Packit 5c3484
	    path_64="sparc64/ultrasparc1234 sparc64" ;;
Packit 5c3484
	  [ultrasparc[34]])
Packit 5c3484
	    path_64="sparc64/ultrasparc34 sparc64/ultrasparc1234 sparc64" ;;
Packit 5c3484
	  [ultrasparct[12]])
Packit 5c3484
	    path_64="sparc64/ultrasparct1 sparc64" ;;
Packit 5c3484
	  [ultrasparct[345]])
Packit 5c3484
	    path_64="sparc64/ultrasparct3 sparc64" ;;
Packit 5c3484
	  *)
Packit 5c3484
	    path_64="sparc64"
Packit 5c3484
	esac
Packit 5c3484
Packit 5c3484
        cclist_64="gcc"
Packit 5c3484
        any_64_testlist="sizeof-long-8"
Packit 5c3484
Packit 5c3484
        # gcc -mptr64 is probably implied by -m64, but we're not sure if
Packit 5c3484
        # this was always so.  On Solaris in the past we always used both
Packit 5c3484
        # "-m64 -mptr64".
Packit 5c3484
        #
Packit 5c3484
        # gcc -Wa,-xarch=v9 is thought to be necessary in some cases on
Packit 5c3484
        # solaris, but it would seem likely that if gcc is going to generate
Packit 5c3484
        # 64-bit code it will have to add that option itself where needed.
Packit 5c3484
        # An extra copy of this option should be harmless though, but leave
Packit 5c3484
        # it until we're sure.  (Might want -xarch=v9a or -xarch=v9b for the
Packit 5c3484
        # higher cpu types instead.)
Packit 5c3484
        #
Packit 5c3484
        gcc_64_cflags="$gcc_cflags -m64 -mptr64"
Packit 5c3484
        gcc_64_ldflags="-Wc,-m64"
Packit 5c3484
        gcc_64_cflags_optlist="cpu asm"
Packit 5c3484
Packit 5c3484
        case $host in
Packit 5c3484
          *-*-solaris*)
Packit 5c3484
            # Sun cc.
Packit 5c3484
            #
Packit 5c3484
            # We used to have -fast and some fixup options here, but it
Packit 5c3484
            # recurrently caused problems with miscompilation.  Of course,
Packit 5c3484
            # -fast is documented as miscompiling things for the sake of speed.
Packit 5c3484
            #
Packit 5c3484
            cclist_64="$cclist_64 cc"
Packit 5c3484
            cc_64_cflags_optlist="cpu"
Packit 5c3484
            case $host_cpu in
Packit 5c3484
              [ultrasparct[345]])
Packit 5c3484
                cc_64_cflags="$cc_64_cflags -xO3 -xarch=v9d" ;;
Packit 5c3484
              *)
Packit 5c3484
                cc_64_cflags="-xO3 -xarch=v9" ;;
Packit 5c3484
            esac
Packit 5c3484
            ;;
Packit 5c3484
        esac
Packit 5c3484
Packit 5c3484
        # using the v9 %tick register
Packit 5c3484
        SPEED_CYCLECOUNTER_OBJ_32=sparcv9.lo
Packit 5c3484
        SPEED_CYCLECOUNTER_OBJ_64=sparcv9.lo
Packit 5c3484
        cyclecounter_size_32=2
Packit 5c3484
        cyclecounter_size_64=2
Packit 5c3484
        ;;
Packit 5c3484
    esac
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # VAX
Packit 5c3484
  vax*-*-*elf*)
Packit 5c3484
    # Use elf conventions (i.e., '%' register prefix, no global prefix)
Packit 5c3484
    #
Packit 5c3484
    GMP_INCLUDE_MPN(vax/elf.m4)
Packit 5c3484
    gcc_cflags="$gcc_cflags $fomit_frame_pointer"
Packit 5c3484
    path="vax"
Packit 5c3484
    if test "$enable_assembly" = "yes" ; then
Packit 5c3484
      extra_functions="udiv_w_sdiv"
Packit 5c3484
    fi
Packit 5c3484
    ;;
Packit 5c3484
  vax*-*-*)
Packit 5c3484
    # Default to aout conventions (i.e., no register prefix, '_' global prefix)
Packit 5c3484
    #
Packit 5c3484
    gcc_cflags="$gcc_cflags $fomit_frame_pointer"
Packit 5c3484
    path="vax"
Packit 5c3484
    if test "$enable_assembly" = "yes" ; then
Packit 5c3484
      extra_functions="udiv_w_sdiv"
Packit 5c3484
    fi
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # AMD and Intel x86 configurations, including AMD64
Packit 5c3484
  #
Packit 5c3484
  # Rumour has it gcc -O2 used to give worse register allocation than just
Packit 5c3484
  # -O, but lets assume that's no longer true.
Packit 5c3484
  #
Packit 5c3484
  # -m32 forces 32-bit mode on a bi-arch 32/64 amd64 build of gcc.  -m64 is
Packit 5c3484
  # the default in such a build (we think), so -m32 is essential for ABI=32.
Packit 5c3484
  # This is, of course, done for any $host_cpu, not just x86_64, so we can
Packit 5c3484
  # get such a gcc into the right mode to cross-compile to say i486-*-*.
Packit 5c3484
  #
Packit 5c3484
  # -m32 is not available in gcc 2.95 and earlier, hence cflags_maybe to use
Packit 5c3484
  # it when it works.  We check sizeof(long)==4 to ensure we get the right
Packit 5c3484
  # mode, in case -m32 has failed not because it's an old gcc, but because
Packit 5c3484
  # it's a dual 32/64-bit gcc without a 32-bit libc, or whatever.
Packit 5c3484
  #
Packit 5c3484
  X86_PATTERN | X86_64_PATTERN)
Packit 5c3484
    abilist="32"
Packit 5c3484
    cclist="gcc icc cc"
Packit 5c3484
    gcc_cflags="$gcc_cflags $fomit_frame_pointer"
Packit 5c3484
    gcc_32_cflags_maybe="-m32"
Packit 5c3484
    icc_cflags="-no-gcc"
Packit 5c3484
    icc_cflags_optlist="opt"
Packit 5c3484
    icc_cflags_opt="-O3 -O2 -O1"
Packit 5c3484
    icc_cflags_opt_maybe="-fp-model~precise"
Packit 5c3484
    any_32_testlist="sizeof-long-4"
Packit 5c3484
    gcc_cflags_optlist="cpu arch noavx"
Packit 5c3484
    CALLING_CONVENTIONS_OBJS='x86call.lo x86check$U.lo'
Packit 5c3484
Packit 5c3484
    # Availability of rdtsc is checked at run-time.
Packit 5c3484
    SPEED_CYCLECOUNTER_OBJ=pentium.lo
Packit 5c3484
Packit 5c3484
    # gcc 2.7.2 only knows i386 and i486, using -m386 or -m486.  These
Packit 5c3484
    #     represent -mcpu= since -m486 doesn't generate 486 specific insns.
Packit 5c3484
    # gcc 2.95 adds k6, pentium and pentiumpro, and takes -march= and -mcpu=.
Packit 5c3484
    # gcc 3.0 adds athlon.
Packit 5c3484
    # gcc 3.1 adds k6-2, k6-3, pentium-mmx, pentium2, pentium3, pentium4,
Packit 5c3484
    #     athlon-tbird, athlon-4, athlon-xp, athlon-mp.
Packit 5c3484
    # gcc 3.2 adds winchip2.
Packit 5c3484
    # gcc 3.3 adds winchip-c6.
Packit 5c3484
    # gcc 3.3.1 from mandrake adds k8 and knows -mtune.
Packit 5c3484
    # gcc 3.4 adds c3, c3-2, k8, and deprecates -mcpu in favour of -mtune.
Packit 5c3484
    #
Packit 5c3484
    # In gcc 2.95.[0123], -march=pentiumpro provoked a stack slot bug in an
Packit 5c3484
    # old version of mpz/powm.c.  Seems to be fine with the current code, so
Packit 5c3484
    # no need for any restrictions on that option.
Packit 5c3484
    #
Packit 5c3484
    # -march=pentiumpro can fail if the assembler doesn't know "cmov"
Packit 5c3484
    # (eg. solaris 2.8 native "as"), so always have -march=pentium after
Packit 5c3484
    # that as a fallback.
Packit 5c3484
    #
Packit 5c3484
    # -march=pentium4 and -march=k8 enable SSE2 instructions, which may or
Packit 5c3484
    # may not be supported by the assembler and/or the OS, and is bad in gcc
Packit 5c3484
    # prior to 3.3.  The tests will reject these if no good, so fallbacks
Packit 5c3484
    # like "-march=pentium4 -mno-sse2" are given to try also without SSE2.
Packit 5c3484
    # Note the relevant -march types are listed in the optflags handling
Packit 5c3484
    # below, be sure to update there if adding new types emitting SSE2.
Packit 5c3484
    #
Packit 5c3484
    # -mtune is used at the start of each cpu option list to give something
Packit 5c3484
    # gcc 3.4 will use, thereby avoiding warnings from -mcpu.  -mcpu forms
Packit 5c3484
    # are retained for use by prior gcc.  For example pentium has
Packit 5c3484
    # "-mtune=pentium -mcpu=pentium ...", the -mtune is for 3.4 and the
Packit 5c3484
    # -mcpu for prior.  If there's a brand new choice in 3.4 for a chip,
Packit 5c3484
    # like k8 for x86_64, then it can be the -mtune at the start, no need to
Packit 5c3484
    # duplicate anything.
Packit 5c3484
    #
Packit 5c3484
    case $host_cpu in
Packit 5c3484
      i386*)
Packit 5c3484
	gcc_cflags_cpu="-mtune=i386 -mcpu=i386 -m386"
Packit 5c3484
	gcc_cflags_arch="-march=i386"
Packit 5c3484
	path="x86"
Packit 5c3484
	;;
Packit 5c3484
      i486*)
Packit 5c3484
	gcc_cflags_cpu="-mtune=i486 -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=i486"
Packit 5c3484
	path="x86/i486 x86"
Packit 5c3484
	;;
Packit 5c3484
      i586 | pentium)
Packit 5c3484
	gcc_cflags_cpu="-mtune=pentium -mcpu=pentium -m486"
Packit 5c3484
	gcc_cflags_arch="-march=pentium"
Packit 5c3484
	path="x86/pentium x86"
Packit 5c3484
	;;
Packit 5c3484
      pentiummmx)
Packit 5c3484
	gcc_cflags_cpu="-mtune=pentium-mmx -mcpu=pentium-mmx -mcpu=pentium -m486"
Packit 5c3484
	gcc_cflags_arch="-march=pentium-mmx -march=pentium"
Packit 5c3484
	path="x86/pentium/mmx x86/pentium x86/mmx x86"
Packit 5c3484
	;;
Packit 5c3484
      i686 | pentiumpro)
Packit 5c3484
	gcc_cflags_cpu="-mtune=pentiumpro -mcpu=pentiumpro -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=pentiumpro -march=pentium"
Packit 5c3484
	path="x86/p6 x86"
Packit 5c3484
	;;
Packit 5c3484
      pentium2)
Packit 5c3484
	gcc_cflags_cpu="-mtune=pentium2 -mcpu=pentium2 -mcpu=pentiumpro -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=pentium2 -march=pentiumpro -march=pentium"
Packit 5c3484
	path="x86/p6/mmx x86/p6 x86/mmx x86"
Packit 5c3484
	;;
Packit 5c3484
      pentium3)
Packit 5c3484
	gcc_cflags_cpu="-mtune=pentium3 -mcpu=pentium3 -mcpu=pentiumpro -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=pentium3 -march=pentiumpro -march=pentium"
Packit 5c3484
	path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86/mmx x86"
Packit 5c3484
	;;
Packit 5c3484
      pentiumm)
Packit 5c3484
	gcc_cflags_cpu="-mtune=pentium3 -mcpu=pentium3 -mcpu=pentiumpro -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=pentium3 -march=pentiumpro -march=pentium"
Packit 5c3484
	path="x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86/mmx x86"
Packit 5c3484
	;;
Packit 5c3484
      k6)
Packit 5c3484
	gcc_cflags_cpu="-mtune=k6 -mcpu=k6 -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=k6"
Packit 5c3484
	path="x86/k6/mmx x86/k6 x86/mmx x86"
Packit 5c3484
	;;
Packit 5c3484
      k62)
Packit 5c3484
	gcc_cflags_cpu="-mtune=k6-2 -mcpu=k6-2 -mcpu=k6 -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=k6-2 -march=k6"
Packit 5c3484
	path="x86/k6/k62mmx x86/k6/mmx x86/k6 x86/mmx x86"
Packit 5c3484
	;;
Packit 5c3484
      k63)
Packit 5c3484
	gcc_cflags_cpu="-mtune=k6-3 -mcpu=k6-3 -mcpu=k6 -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=k6-3 -march=k6"
Packit 5c3484
	path="x86/k6/k62mmx x86/k6/mmx x86/k6 x86/mmx x86"
Packit 5c3484
	;;
Packit 5c3484
      geode)
Packit 5c3484
	gcc_cflags_cpu="-mtune=k6-3 -mcpu=k6-3 -mcpu=k6 -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=k6-3 -march=k6"
Packit 5c3484
	path="x86/geode x86/k6/k62mmx x86/k6/mmx x86/k6 x86/mmx x86"
Packit 5c3484
	;;
Packit 5c3484
      athlon)
Packit 5c3484
	# Athlon instruction costs are close to P6 (3 cycle load latency,
Packit 5c3484
	# 4-6 cycle mul, 40 cycle div, pairable adc, etc) so if gcc doesn't
Packit 5c3484
	# know athlon (eg. 2.95.2 doesn't) then fall back on pentiumpro.
Packit 5c3484
	gcc_cflags_cpu="-mtune=athlon -mcpu=athlon -mcpu=pentiumpro -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=athlon -march=pentiumpro -march=pentium"
Packit 5c3484
	path="x86/k7/mmx x86/k7 x86/mmx x86"
Packit 5c3484
	;;
Packit 5c3484
      i786 | pentium4)
Packit 5c3484
	# pentiumpro is the primary fallback when gcc doesn't know pentium4.
Packit 5c3484
	# This gets us cmov to eliminate branches.  Maybe "athlon" would be
Packit 5c3484
	# a possibility on gcc 3.0.
Packit 5c3484
	#
Packit 5c3484
	gcc_cflags_cpu="-mtune=pentium4 -mcpu=pentium4 -mcpu=pentiumpro -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=pentium4 -march=pentium4~-mno-sse2 -march=pentiumpro -march=pentium"
Packit 5c3484
	gcc_64_cflags_cpu="-mtune=nocona"
Packit 5c3484
	path="x86/pentium4/sse2 x86/pentium4/mmx x86/pentium4 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/pentium4 x86_64"
Packit 5c3484
	;;
Packit 5c3484
      viac32)
Packit 5c3484
	# Not sure of the best fallbacks here for -mcpu.
Packit 5c3484
	# c3-2 has sse and mmx, so pentium3 is good for -march.
Packit 5c3484
	gcc_cflags_cpu="-mtune=c3-2 -mcpu=c3-2 -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=c3-2 -march=pentium3 -march=pentiumpro -march=pentium"
Packit 5c3484
	path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86/mmx x86"
Packit 5c3484
	;;
Packit 5c3484
      viac3*)
Packit 5c3484
	# Not sure of the best fallbacks here.
Packit 5c3484
	gcc_cflags_cpu="-mtune=c3 -mcpu=c3 -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=c3 -march=pentium-mmx -march=pentium"
Packit 5c3484
	path="x86/pentium/mmx x86/pentium x86/mmx x86"
Packit 5c3484
	;;
Packit 5c3484
      athlon64 | k8 | x86_64)
Packit 5c3484
	gcc_cflags_cpu="-mtune=k8 -mcpu=athlon -mcpu=pentiumpro -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=k8 -march=k8~-mno-sse2 -march=athlon -march=pentiumpro -march=pentium"
Packit 5c3484
	path="x86/k8 x86/k7/mmx x86/k7 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/k8 x86_64"
Packit 5c3484
	;;
Packit 5c3484
      k10)
Packit 5c3484
	gcc_cflags_cpu="-mtune=amdfam10 -mtune=k8"
Packit 5c3484
	gcc_cflags_arch="-march=amdfam10 -march=k8 -march=k8~-mno-sse2"
Packit 5c3484
	path="x86/k10 x86/k8 x86/k7/mmx x86/k7 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/k10 x86_64/k8 x86_64"
Packit 5c3484
	;;
Packit 5c3484
      bobcat)
Packit 5c3484
	gcc_cflags_cpu="-mtune=btver1 -mtune=amdfam10 -mtune=k8"
Packit 5c3484
	gcc_cflags_arch="-march=btver1 -march=amdfam10 -march=k8 -march=k8~-mno-sse2"
Packit 5c3484
	path="x86/bobcat x86/k7/mmx x86/k7 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/bobcat x86_64/k10 x86_64/k8 x86_64"
Packit 5c3484
	;;
Packit 5c3484
      jaguar | jaguarnoavx)
Packit 5c3484
	gcc_cflags_cpu="-mtune=btver2 -mtune=btver1 -mtune=amdfam10 -mtune=k8"
Packit 5c3484
	gcc_cflags_arch="-march=btver2 -march=btver1 -march=amdfam10 -march=k8 -march=k8~-mno-sse2"
Packit 5c3484
	path="x86/jaguar x86/bobcat x86/k7/mmx x86/k7 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/jaguar x86_64/bobcat x86_64/k10 x86_64/k8 x86_64"
Packit 5c3484
	;;
Packit 5c3484
      bulldozer | bd1 | bulldozernoavx | bd1noavx)
Packit 5c3484
	gcc_cflags_cpu="-mtune=bdver1 -mtune=amdfam10 -mtune=k8"
Packit 5c3484
	gcc_cflags_arch="-march=bdver1 -march=amdfam10 -march=k8 -march=k8~-mno-sse2"
Packit 5c3484
	path="x86/bd1 x86/k7/mmx x86/k7 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/bd1 x86_64/k10 x86_64/k8 x86_64"
Packit 5c3484
	;;
Packit 5c3484
      piledriver | bd2 | piledrivernoavx | bd2noavx)
Packit 5c3484
	gcc_cflags_cpu="-mtune=bdver2 -mtune=bdver1 -mtune=amdfam10 -mtune=k8"
Packit 5c3484
	gcc_cflags_arch="-march=bdver2 -march=bdver1 -march=amdfam10 -march=k8 -march=k8~-mno-sse2"
Packit 5c3484
	path="x86/bd2 x86/bd1 x86/k7/mmx x86/k7 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/bd2 x86_64/bd1 x86_64/k10 x86_64/k8 x86_64"
Packit 5c3484
	;;
Packit 5c3484
      steamroller | bd3 | steamrollernoavx | bd3noavx)
Packit 5c3484
	gcc_cflags_cpu="-mtune=bdver3 -mtune=bdver2 -mtune=bdver1 -mtune=amdfam10 -mtune=k8"
Packit 5c3484
	gcc_cflags_arch="-march=bdver3 -march=bdver2 -march=bdver1 -march=amdfam10 -march=k8 -march=k8~-mno-sse2"
Packit 5c3484
	path="x86/bd3 x86/bd2 x86/bd1 x86/k7/mmx x86/k7 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/bd3 x86_64/bd2 x86_64/bd1 x86_64/k10 x86_64/k8 x86_64"
Packit 5c3484
	;;
Packit 5c3484
      excavator | bd4 | excavatornoavx | bd4noavx)
Packit 5c3484
	gcc_cflags_cpu="-mtune=bdver4 -mtune=bdver3 -mtune=bdver2 -mtune=bdver1 -mtune=amdfam10 -mtune=k8"
Packit 5c3484
	gcc_cflags_arch="-march=bdver4 -march=bdver3 -march=bdver2 -march=bdver1 -march=amdfam10 -march=k8 -march=k8~-mno-sse2"
Packit 5c3484
	path="x86/bd4 x86/bd3 x86/bd2 x86/bd1 x86/k7/mmx x86/k7 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/bd4 x86_64/bd3 x86_64/bd2 x86_64/bd1 x86_64/k10 x86_64/k8 x86_64"
Packit 5c3484
	;;
Packit 5c3484
      core2)
Packit 5c3484
	gcc_cflags_cpu="-mtune=core2 -mtune=k8"
Packit 5c3484
	gcc_cflags_arch="-march=core2 -march=core2~-mno-sse2 -march=k8 -march=k8~-mno-sse2"
Packit 5c3484
	path="x86/core2 x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/core2 x86_64"
Packit 5c3484
	;;
Packit 5c3484
      corei | coreinhm | coreiwsm | nehalem | westmere)
Packit 5c3484
	gcc_cflags_cpu="-mtune=corei7 -mtune=core2 -mtune=k8"
Packit 5c3484
	gcc_cflags_arch="-march=corei7 -march=core2 -march=core2~-mno-sse2 -march=k8 -march=k8~-mno-sse2"
Packit 5c3484
	path="x86/coreinhm x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/coreinhm x86_64/core2 x86_64"
Packit 5c3484
	;;
Packit 5c3484
      coreisbr | coreisbrnoavx | coreiibr | coreiibrnoavx | \
Packit 5c3484
      sandybridge | sandybridgenoavx | ivybridge | ivybridgenoavx)
Packit 5c3484
	gcc_cflags_cpu="-mtune=sandybridge -mtune=corei7 -mtune=core2 -mtune=k8"
Packit 5c3484
	gcc_cflags_arch="-march=sandybridge -march=corei7 -march=core2 -march=core2~-mno-sse2 -march=k8 -march=k8~-mno-sse2"
Packit 5c3484
	path="x86/coreisbr x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/coreisbr x86_64/coreinhm x86_64/core2 x86_64"
Packit 5c3484
	;;
Packit 5c3484
      coreihwl | coreihwlnoavx | haswell | haswellnoavx)
Packit 5c3484
	gcc_cflags_cpu="-mtune=haswell -mtune=corei7 -mtune=core2 -mtune=k8"
Packit 5c3484
	gcc_cflags_arch="-march=haswell -march=corei7 -march=core2 -march=core2~-mno-sse2 -march=k8 -march=k8~-mno-sse2"
Packit 5c3484
	path="x86/coreisbr x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/coreihwl x86_64/coreisbr x86_64/coreinhm x86_64/core2 x86_64"
Packit 5c3484
	;;
Packit 5c3484
      coreibwl | coreibwlnoavx | broadwell | broadwellnoavx)
Packit 5c3484
	gcc_cflags_cpu="-mtune=broadwell -mtune=corei7 -mtune=core2 -mtune=k8"
Packit 5c3484
	gcc_cflags_arch="-march=broadwell -march=corei7 -march=core2 -march=core2~-mno-sse2 -march=k8 -march=k8~-mno-sse2"
Packit 5c3484
	path="x86/coreisbr x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/coreibwl x86_64/coreihwl x86_64/coreisbr x86_64/coreinhm x86_64/core2 x86_64"
Packit 5c3484
	# extra_functions_64="missing"	 # enable for bmi2/adx simulation
Packit 5c3484
	;;
Packit 5c3484
      skylake | skylakenoavx | kabylake | kabylakenoavx)
Packit 5c3484
	gcc_cflags_cpu="-mtune=skylake -mtune=broadwell -mtune=corei7 -mtune=core2 -mtune=k8"
Packit 5c3484
	# Don't pass -march=skylake for now as then some compilers emit AVX512.
Packit 5c3484
	gcc_cflags_arch="-march=broadwell -march=corei7 -march=core2 -march=core2~-mno-sse2 -march=k8 -march=k8~-mno-sse2"
Packit 5c3484
	path="x86/coreisbr x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86/mmx x86"
Packit 5c3484
	path_64="x86_64/skylake x86_64/coreibwl x86_64/coreihwl x86_64/coreisbr x86_64/coreinhm x86_64/core2 x86_64"
Packit 5c3484
	# extra_functions_64="missing"	 # enable for bmi2/adx simulation
Packit 5c3484
	;;
Packit 5c3484
      atom)			# in-order pipeline atom
Packit 5c3484
	gcc_cflags_cpu="-mtune=atom -mtune=pentium3"
Packit 5c3484
	gcc_cflags_arch="-march=atom -march=pentium3"
Packit 5c3484
	path="x86/atom/sse2 x86/atom/mmx x86/atom x86/mmx x86"
Packit 5c3484
	path_64="x86_64/atom x86_64"
Packit 5c3484
	;;
Packit 5c3484
      silvermont | goldmont)	# out-of-order pipeline atom
Packit 5c3484
	gcc_cflags_cpu="-mtune=slm -mtune=atom -mtune=pentium3"
Packit 5c3484
	gcc_cflags_arch="-march=slm -march=atom -march=pentium3"
Packit 5c3484
	path="x86/atom/sse2 x86/atom/mmx x86/atom x86/mmx x86"
Packit 5c3484
	path_64="x86_64/silvermont x86_64/atom x86_64"
Packit 5c3484
	;;
Packit 5c3484
      nano)
Packit 5c3484
	gcc_cflags_cpu="-mtune=nano"
Packit 5c3484
	gcc_cflags_arch="-march=nano"
Packit 5c3484
	path="x86/nano x86/mmx x86"
Packit 5c3484
	path_64="x86_64/nano x86_64"
Packit 5c3484
	;;
Packit 5c3484
      *)
Packit 5c3484
	gcc_cflags_cpu="-mtune=i486 -mcpu=i486 -m486"
Packit 5c3484
	gcc_cflags_arch="-march=i486"
Packit 5c3484
	path="x86"
Packit 5c3484
	path_64="x86_64"
Packit 5c3484
	;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    case $host in
Packit 5c3484
      # Disable AVX if the CPU part tells us AVX is unavailable, but also
Packit 5c3484
      # unconditionally for NetBSD where they don't work but OSXSAVE is set
Packit 5c3484
      # to claim the contrary.
Packit 5c3484
      *noavx-*-* | *-*-netbsd*)
Packit 5c3484
	gcc_cflags_noavx="-mno-avx";;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    case $host in
Packit 5c3484
      X86_64_PATTERN)
Packit 5c3484
	cclist_64="gcc cc"
Packit 5c3484
	gcc_64_cflags="$gcc_cflags -m64"
Packit 5c3484
	gcc_64_cflags_optlist="cpu arch noavx"
Packit 5c3484
	CALLING_CONVENTIONS_OBJS_64='amd64call.lo amd64check$U.lo'
Packit 5c3484
	SPEED_CYCLECOUNTER_OBJ_64=x86_64.lo
Packit 5c3484
	cyclecounter_size_64=2
Packit 5c3484
Packit 5c3484
	cclist_x32="gcc cc"
Packit 5c3484
	gcc_x32_cflags="$gcc_cflags -mx32"
Packit 5c3484
	gcc_x32_cflags_optlist="$gcc_64_cflags_optlist"
Packit 5c3484
	CALLING_CONVENTIONS_OBJS_x32="$CALLING_CONVENTIONS_OBJS_64"
Packit 5c3484
	SPEED_CYCLECOUNTER_OBJ_x32="$SPEED_CYCLECOUNTER_OBJ_64"
Packit 5c3484
	cyclecounter_size_x32="$cyclecounter_size_64"
Packit 5c3484
	path_x32="$path_64"
Packit 5c3484
	limb_x32=longlong
Packit 5c3484
	any_x32_testlist="sizeof-long-4"
Packit 5c3484
Packit 5c3484
	abilist="64 x32 32"
Packit 5c3484
	if test "$enable_assembly" = "yes" ; then
Packit 5c3484
	    extra_functions_64="$extra_functions_64 invert_limb_table"
Packit 5c3484
	    extra_functions_x32=$extra_functions_64
Packit 5c3484
	fi
Packit 5c3484
Packit 5c3484
	case $host in
Packit 5c3484
	  *-*-solaris*)
Packit 5c3484
	    # Sun cc.
Packit 5c3484
	    cc_64_cflags="-xO3 -m64"
Packit 5c3484
	    ;;
Packit 5c3484
	  *-*-mingw* | *-*-cygwin)
Packit 5c3484
	    limb_64=longlong
Packit 5c3484
	    CALLING_CONVENTIONS_OBJS_64=""
Packit 5c3484
	    AC_DEFINE(HOST_DOS64,1,[Define to 1 for Windos/64])
Packit 5c3484
	    GMP_NONSTD_ABI_64=DOS64
Packit 5c3484
	    ;;
Packit 5c3484
	esac
Packit 5c3484
	;;
Packit 5c3484
    esac
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # Special CPU "none" used to select generic C, now this is obsolete.
Packit 5c3484
  none-*-*)
Packit 5c3484
    enable_assembly=no
Packit 5c3484
    AC_MSG_WARN([the \"none\" host is obsolete, use --disable-assembly])
Packit 5c3484
    ;;
Packit 5c3484
Packit 5c3484
esac
Packit 5c3484
Packit 5c3484
# mingw can be built by the cygwin gcc if -mno-cygwin is added.  For
Packit 5c3484
# convenience add this automatically if it works.  Actual mingw gcc accepts
Packit 5c3484
# -mno-cygwin too, but of course is the default.  mingw only runs on the
Packit 5c3484
# x86s, but allow any CPU here so as to catch "none" too.
Packit 5c3484
#
Packit 5c3484
case $host in
Packit 5c3484
  *-*-mingw*)
Packit 5c3484
    gcc_cflags_optlist="$gcc_cflags_optlist nocygwin"
Packit 5c3484
    gcc_cflags_nocygwin="-mno-cygwin"
Packit 5c3484
    ;;
Packit 5c3484
esac
Packit 5c3484
Packit 5c3484
Packit 5c3484
CFLAGS_or_unset=${CFLAGS-'(unset)'}
Packit 5c3484
CPPFLAGS_or_unset=${CPPFLAGS-'(unset)'}
Packit 5c3484
Packit 5c3484
cat >&AC_FD_CC <
Packit 5c3484
User:
Packit 5c3484
ABI=$ABI
Packit 5c3484
CC=$CC
Packit 5c3484
CFLAGS=$CFLAGS_or_unset
Packit 5c3484
CPPFLAGS=$CPPFLAGS_or_unset
Packit 5c3484
MPN_PATH=$MPN_PATH
Packit 5c3484
GMP:
Packit 5c3484
abilist=$abilist
Packit 5c3484
cclist=$cclist
Packit 5c3484
EOF
Packit 5c3484
Packit 5c3484
Packit 5c3484
test_CFLAGS=${CFLAGS+set}
Packit 5c3484
test_CPPFLAGS=${CPPFLAGS+set}
Packit 5c3484
Packit 5c3484
for abi in $abilist; do
Packit 5c3484
  abi_last="$abi"
Packit 5c3484
done
Packit 5c3484
Packit 5c3484
# If the user specifies an ABI then it must be in $abilist, after that
Packit 5c3484
# $abilist is restricted to just that choice.
Packit 5c3484
#
Packit 5c3484
if test -n "$ABI"; then
Packit 5c3484
  found=no
Packit 5c3484
  for abi in $abilist; do
Packit 5c3484
    if test $abi = "$ABI"; then found=yes; break; fi
Packit 5c3484
  done
Packit 5c3484
  if test $found = no; then
Packit 5c3484
    AC_MSG_ERROR([ABI=$ABI is not among the following valid choices: $abilist])
Packit 5c3484
  fi
Packit 5c3484
  abilist="$ABI"
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
found_compiler=no
Packit 5c3484
Packit 5c3484
for abi in $abilist; do
Packit 5c3484
Packit 5c3484
  echo "checking ABI=$abi"
Packit 5c3484
Packit 5c3484
  # Suppose abilist="64 32", then for abi=64, will have abi1="_64" and
Packit 5c3484
  # abi2="_64".  For abi=32, will have abi1="_32" and abi2="".  This is how
Packit 5c3484
  # $gcc_cflags becomes a fallback for $gcc_32_cflags (the last in the
Packit 5c3484
  # abilist), but there's no fallback for $gcc_64_cflags.
Packit 5c3484
  #
Packit 5c3484
  abi1=[`echo _$abi | sed 's/[.]//g'`]
Packit 5c3484
  if test $abi = $abi_last; then abi2=; else abi2="$abi1"; fi
Packit 5c3484
Packit 5c3484
  # Compiler choices under this ABI
Packit 5c3484
                              eval cclist_chosen=\"\$cclist$abi1\"
Packit 5c3484
  test -n "$cclist_chosen" || eval cclist_chosen=\"\$cclist$abi2\"
Packit 5c3484
Packit 5c3484
  # If there's a user specified $CC then don't use a list for
Packit 5c3484
  # $cclist_chosen, just a single value for $ccbase.
Packit 5c3484
  #
Packit 5c3484
  if test -n "$CC"; then
Packit 5c3484
Packit 5c3484
    # The first word of $CC, stripped of any directory.  For instance
Packit 5c3484
    # CC="/usr/local/bin/gcc -pipe" will give "gcc".
Packit 5c3484
    #
Packit 5c3484
    for ccbase in $CC; do break; done
Packit 5c3484
    ccbase=`echo $ccbase | sed 's:.*/::'`
Packit 5c3484
Packit 5c3484
    # If this $ccbase is in $cclist_chosen then it's a compiler we know and
Packit 5c3484
    # we can do flags defaulting with it.  If not, then $cclist_chosen is
Packit 5c3484
    # set to "unrecognised" so no default flags are used.
Packit 5c3484
    #
Packit 5c3484
    # "unrecognised" is used to avoid bad effects with eval if $ccbase has
Packit 5c3484
    # non-symbol characters.  For instance ccbase=my+cc would end up with
Packit 5c3484
    # something like cflags="$my+cc_cflags" which would give
Packit 5c3484
    # cflags="+cc_cflags" rather than the intended empty string for an
Packit 5c3484
    # unknown compiler.
Packit 5c3484
    #
Packit 5c3484
    found=unrecognised
Packit 5c3484
    for i in $cclist_chosen; do
Packit 5c3484
      if test "$ccbase" = $i; then
Packit 5c3484
        found=$ccbase
Packit 5c3484
        break
Packit 5c3484
      fi
Packit 5c3484
    done
Packit 5c3484
    cclist_chosen=$found
Packit 5c3484
  fi
Packit 5c3484
Packit 5c3484
  for ccbase in $cclist_chosen; do
Packit 5c3484
Packit 5c3484
    # When cross compiling, look for a compiler with the $host_alias as a
Packit 5c3484
    # prefix, the same way that AC_CHECK_TOOL does.  But don't do this to a
Packit 5c3484
    # user-selected $CC.
Packit 5c3484
    #
Packit 5c3484
    # $cross_compiling will be yes/no/maybe at this point.  Do the host
Packit 5c3484
    # prefixing for "maybe" as well as "yes".
Packit 5c3484
    #
Packit 5c3484
    if test "$cross_compiling" != no && test -z "$CC"; then
Packit 5c3484
      cross_compiling_prefix="${host_alias}-"
Packit 5c3484
    fi
Packit 5c3484
Packit 5c3484
    for ccprefix in $cross_compiling_prefix ""; do
Packit 5c3484
Packit 5c3484
      cc="$CC"
Packit 5c3484
      test -n "$cc" || cc="$ccprefix$ccbase"
Packit 5c3484
Packit 5c3484
      # If the compiler is gcc but installed under another name, then change
Packit 5c3484
      # $ccbase so as to use the flags we know for gcc.  This helps for
Packit 5c3484
      # instance when specifying CC=gcc272 on Debian GNU/Linux, or the
Packit 5c3484
      # native cc which is really gcc on NeXT or MacOS-X.
Packit 5c3484
      #
Packit 5c3484
      # FIXME: There's a slight misfeature here.  If cc is actually gcc but
Packit 5c3484
      # gcc is not a known compiler under this $abi then we'll end up
Packit 5c3484
      # testing it with no flags and it'll work, but chances are it won't be
Packit 5c3484
      # in the right mode for the ABI we desire.  Let's quietly hope this
Packit 5c3484
      # doesn't happen.
Packit 5c3484
      #
Packit 5c3484
      if test $ccbase != gcc; then
Packit 5c3484
        GMP_PROG_CC_IS_GNU($cc,ccbase=gcc)
Packit 5c3484
      fi
Packit 5c3484
Packit 5c3484
      # Similarly if the compiler is IBM xlc but invoked as cc or whatever
Packit 5c3484
      # then change $ccbase and make the default xlc flags available.
Packit 5c3484
      if test $ccbase != xlc; then
Packit 5c3484
        GMP_PROG_CC_IS_XLC($cc,ccbase=xlc)
Packit 5c3484
      fi
Packit 5c3484
Packit 5c3484
      # acc was Sun's first unbundled compiler back in the SunOS days, or
Packit 5c3484
      # something like that, but today its man page says it's not meant to
Packit 5c3484
      # be used directly (instead via /usr/ucb/cc).  The options are pretty
Packit 5c3484
      # much the same as the main SunPRO cc, so share those configs.
Packit 5c3484
      #
Packit 5c3484
      case $host in
Packit 5c3484
        *sparc*-*-solaris* | *sparc*-*-sunos*)
Packit 5c3484
          if test "$ccbase" = acc; then ccbase=cc; fi ;;
Packit 5c3484
      esac
Packit 5c3484
Packit 5c3484
      for tmp_cflags_maybe in yes no; do
Packit 5c3484
                             eval cflags=\"\$${ccbase}${abi1}_cflags\"
Packit 5c3484
        test -n "$cflags" || eval cflags=\"\$${ccbase}${abi2}_cflags\"
Packit 5c3484
Packit 5c3484
	if test "$tmp_cflags_maybe" = yes; then
Packit 5c3484
          # don't try cflags_maybe when the user set CFLAGS
Packit 5c3484
          if test "$test_CFLAGS" = set; then continue; fi
Packit 5c3484
                                     eval cflags_maybe=\"\$${ccbase}${abi1}_cflags_maybe\"
Packit 5c3484
          test -n "$cflags_maybe" || eval cflags_maybe=\"\$${ccbase}${abi2}_cflags_maybe\"
Packit 5c3484
          # don't try cflags_maybe if there's nothing set
Packit 5c3484
          if test -z "$cflags_maybe"; then continue; fi
Packit 5c3484
          cflags="$cflags_maybe $cflags"
Packit 5c3484
        fi
Packit 5c3484
Packit 5c3484
        # Any user CFLAGS, even an empty string, takes precedence
Packit 5c3484
        if test "$test_CFLAGS" = set; then cflags=$CFLAGS; fi
Packit 5c3484
Packit 5c3484
        # Any user CPPFLAGS, even an empty string, takes precedence
Packit 5c3484
                               eval cppflags=\"\$${ccbase}${abi1}_cppflags\"
Packit 5c3484
        test -n "$cppflags" || eval cppflags=\"\$${ccbase}${abi2}_cppflags\"
Packit 5c3484
        if test "$test_CPPFLAGS" = set; then cppflags=$CPPFLAGS; fi
Packit 5c3484
Packit 5c3484
        # --enable-profiling adds -p/-pg even to user-specified CFLAGS.
Packit 5c3484
        # This is convenient, but it's perhaps a bit naughty to modify user
Packit 5c3484
        # CFLAGS.
Packit 5c3484
        case "$enable_profiling" in
Packit 5c3484
          prof)       cflags="$cflags -p" ;;
Packit 5c3484
          gprof)      cflags="$cflags -pg" ;;
Packit 5c3484
          instrument) cflags="$cflags -finstrument-functions" ;;
Packit 5c3484
        esac
Packit 5c3484
Packit 5c3484
        GMP_PROG_CC_WORKS($cc $cflags $cppflags,,continue)
Packit 5c3484
Packit 5c3484
        # If we're supposed to be using a "long long" for a limb, check that
Packit 5c3484
        # it works.
Packit 5c3484
                                  eval limb_chosen=\"\$limb$abi1\"
Packit 5c3484
        test -n "$limb_chosen" || eval limb_chosen=\"\$limb$abi2\"
Packit 5c3484
        if test "$limb_chosen" = longlong; then
Packit 5c3484
          GMP_PROG_CC_WORKS_LONGLONG($cc $cflags $cppflags,,continue)
Packit 5c3484
        fi
Packit 5c3484
Packit 5c3484
        # The tests to perform on this $cc, if any
Packit 5c3484
                               eval testlist=\"\$${ccbase}${abi1}_testlist\"
Packit 5c3484
        test -n "$testlist" || eval testlist=\"\$${ccbase}${abi2}_testlist\"
Packit 5c3484
        test -n "$testlist" || eval testlist=\"\$any${abi1}_testlist\"
Packit 5c3484
        test -n "$testlist" || eval testlist=\"\$any${abi2}_testlist\"
Packit 5c3484
Packit 5c3484
        testlist_pass=yes
Packit 5c3484
        for tst in $testlist; do
Packit 5c3484
          case $tst in
Packit 5c3484
          hpc-hppa-2-0)   GMP_HPC_HPPA_2_0($cc,,testlist_pass=no) ;;
Packit 5c3484
          gcc-arm-umodsi) GMP_GCC_ARM_UMODSI($cc,,testlist_pass=no) ;;
Packit 5c3484
          gcc-mips-o32)   GMP_GCC_MIPS_O32($cc,,testlist_pass=no) ;;
Packit 5c3484
          hppa-level-2.0) GMP_HPPA_LEVEL_20($cc $cflags,,testlist_pass=no) ;;
Packit 5c3484
          sizeof*)       GMP_C_TEST_SIZEOF($cc $cflags,$tst,,testlist_pass=no) ;;
Packit 5c3484
          esac
Packit 5c3484
          if test $testlist_pass = no; then break; fi
Packit 5c3484
        done
Packit 5c3484
Packit 5c3484
        if test $testlist_pass = yes; then
Packit 5c3484
          found_compiler=yes
Packit 5c3484
          break
Packit 5c3484
        fi
Packit 5c3484
      done
Packit 5c3484
Packit 5c3484
      if test $found_compiler = yes; then break; fi
Packit 5c3484
    done
Packit 5c3484
Packit 5c3484
    if test $found_compiler = yes; then break; fi
Packit 5c3484
  done
Packit 5c3484
Packit 5c3484
  if test $found_compiler = yes; then break; fi
Packit 5c3484
done
Packit 5c3484
Packit 5c3484
Packit 5c3484
# If we recognised the CPU, as indicated by $path being set, then insist
Packit 5c3484
# that we have a working compiler, either from our $cclist choices or from
Packit 5c3484
# $CC.  We can't let AC_PROG_CC look around for a compiler because it might
Packit 5c3484
# find one that we've rejected (for not supporting the modes our asm code
Packit 5c3484
# demands, etc).
Packit 5c3484
#
Packit 5c3484
# If we didn't recognise the CPU (and this includes host_cpu=none), then
Packit 5c3484
# fall through and let AC_PROG_CC look around for a compiler too.  This is
Packit 5c3484
# mostly in the interests of following a standard autoconf setup, after all
Packit 5c3484
# we've already tested cc and gcc adequately (hopefully).  As of autoconf
Packit 5c3484
# 2.50 the only thing AC_PROG_CC really adds is a check for "cl" (Microsoft
Packit 5c3484
# C on MS-DOS systems).
Packit 5c3484
#
Packit 5c3484
if test $found_compiler = no && test -n "$path"; then
Packit 5c3484
  AC_MSG_ERROR([could not find a working compiler, see config.log for details])
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
case $host in
Packit 5c3484
  X86_PATTERN | X86_64_PATTERN)
Packit 5c3484
    # If the user asked for a fat build, override the path and flags set above
Packit 5c3484
    if test $enable_fat = yes; then
Packit 5c3484
      gcc_cflags_cpu=""
Packit 5c3484
      gcc_cflags_arch=""
Packit 5c3484
Packit 5c3484
      fat_functions="add_n addmul_1 bdiv_dbm1c com cnd_add_n cnd_sub_n
Packit 5c3484
		     copyd copyi dive_1 divrem_1
Packit 5c3484
		     gcd_1 lshift lshiftc mod_1 mod_1_1 mod_1_1_cps mod_1_2
Packit 5c3484
		     mod_1_2_cps mod_1_4 mod_1_4_cps mod_34lsub1 mode1o mul_1
Packit 5c3484
		     mul_basecase mullo_basecase pre_divrem_1 pre_mod_1 redc_1
Packit 5c3484
		     redc_2 rshift sqr_basecase sub_n submul_1"
Packit 5c3484
Packit 5c3484
      if test "$abi" = 32; then
Packit 5c3484
	extra_functions="$extra_functions fat fat_entry"
Packit 5c3484
	path="x86/fat x86"
Packit 5c3484
	fat_path="x86 x86/fat x86/i486
Packit 5c3484
		  x86/k6 x86/k6/mmx x86/k6/k62mmx
Packit 5c3484
		  x86/k7 x86/k7/mmx
Packit 5c3484
		  x86/k8 x86/k10 x86/bobcat
Packit 5c3484
		  x86/pentium x86/pentium/mmx
Packit 5c3484
		  x86/p6 x86/p6/mmx x86/p6/p3mmx x86/p6/sse2
Packit 5c3484
		  x86/pentium4 x86/pentium4/mmx x86/pentium4/sse2
Packit 5c3484
		  x86/core2 x86/coreinhm x86/coreisbr
Packit 5c3484
		  x86/atom x86/atom/mmx x86/atom/sse2 x86/nano"
Packit 5c3484
      fi
Packit 5c3484
Packit 5c3484
      if test "$abi" = 64; then
Packit 5c3484
	gcc_64_cflags=""
Packit 5c3484
	extra_functions_64="$extra_functions_64 fat fat_entry"
Packit 5c3484
	path_64="x86_64/fat x86_64"
Packit 5c3484
	fat_path="x86_64 x86_64/fat
Packit 5c3484
		  x86_64/k8 x86_64/k10 x86_64/bd1 x86_64/bobcat x86_64/pentium4
Packit 5c3484
		  x86_64/core2 x86_64/coreinhm x86_64/coreisbr x86_64/coreihwl
Packit 5c3484
		  x86_64/coreibwl x86_64/skylake x86_64/atom x86_64/silvermont
Packit 5c3484
		  x86_64/nano"
Packit 5c3484
	fat_functions="$fat_functions addmul_2 addlsh1_n addlsh2_n sublsh1_n"
Packit 5c3484
      fi
Packit 5c3484
Packit 5c3484
      fat_thresholds="MUL_TOOM22_THRESHOLD MUL_TOOM33_THRESHOLD
Packit 5c3484
		      SQR_TOOM2_THRESHOLD SQR_TOOM3_THRESHOLD
Packit 5c3484
		      BMOD_1_TO_MOD_1_THRESHOLD"
Packit 5c3484
    fi
Packit 5c3484
    ;;
Packit 5c3484
esac
Packit 5c3484
Packit 5c3484
Packit 5c3484
if test $found_compiler = yes; then
Packit 5c3484
Packit 5c3484
  # If we're creating CFLAGS, then look for optional additions.  If the user
Packit 5c3484
  # set CFLAGS then leave it alone.
Packit 5c3484
  #
Packit 5c3484
  if test "$test_CFLAGS" != set; then
Packit 5c3484
                          eval optlist=\"\$${ccbase}${abi1}_cflags_optlist\"
Packit 5c3484
    test -n "$optlist" || eval optlist=\"\$${ccbase}${abi2}_cflags_optlist\"
Packit 5c3484
Packit 5c3484
    for opt in $optlist; do
Packit 5c3484
                             eval optflags=\"\$${ccbase}${abi1}_cflags_${opt}\"
Packit 5c3484
      test -n "$optflags" || eval optflags=\"\$${ccbase}${abi2}_cflags_${opt}\"
Packit 5c3484
      test -n "$optflags" || eval optflags=\"\$${ccbase}_cflags_${opt}\"
Packit 5c3484
Packit 5c3484
      for flag in $optflags; do
Packit 5c3484
Packit 5c3484
	# ~ represents a space in an option spec
Packit 5c3484
        flag=`echo "$flag" | tr '~' ' '`
Packit 5c3484
Packit 5c3484
        case $flag in
Packit 5c3484
          -march=pentium4 | -march=k8)
Packit 5c3484
            # For -march settings which enable SSE2 we exclude certain bad
Packit 5c3484
            # gcc versions and we need an OS knowing how to save xmm regs.
Packit 5c3484
            #
Packit 5c3484
            # This is only for ABI=32, any 64-bit gcc is good and any OS
Packit 5c3484
            # knowing x86_64 will know xmm.
Packit 5c3484
            #
Packit 5c3484
            # -march=k8 was only introduced in gcc 3.3, so we shouldn't need
Packit 5c3484
            # the GMP_GCC_PENTIUM4_SSE2 check (for gcc 3.2 and prior).  But
Packit 5c3484
            # it doesn't hurt to run it anyway, sharing code with the
Packit 5c3484
            # pentium4 case.
Packit 5c3484
            #
Packit 5c3484
            if test "$abi" = 32; then
Packit 5c3484
              GMP_GCC_PENTIUM4_SSE2($cc $cflags $cppflags,, continue)
Packit 5c3484
              GMP_OS_X86_XMM($cc $cflags $cppflags,, continue)
Packit 5c3484
            fi
Packit 5c3484
            ;;
Packit 5c3484
          -no-cpp-precomp)
Packit 5c3484
            # special check, avoiding a warning
Packit 5c3484
            GMP_GCC_NO_CPP_PRECOMP($ccbase,$cc,$cflags,
Packit 5c3484
                                   [cflags="$cflags $flag"
Packit 5c3484
                                   break],
Packit 5c3484
                                   [continue])
Packit 5c3484
            ;;
Packit 5c3484
          -Wa,-m*)
Packit 5c3484
            case $host in
Packit 5c3484
              alpha*-*-*)
Packit 5c3484
                GMP_GCC_WA_MCPU($cc $cflags, $flag, , [continue])
Packit 5c3484
              ;;
Packit 5c3484
            esac
Packit 5c3484
            ;;
Packit 5c3484
          -Wa,-oldas)
Packit 5c3484
            GMP_GCC_WA_OLDAS($cc $cflags $cppflags,
Packit 5c3484
                             [cflags="$cflags $flag"
Packit 5c3484
                             break],
Packit 5c3484
                             [continue])
Packit 5c3484
            ;;
Packit 5c3484
        esac
Packit 5c3484
Packit 5c3484
        GMP_PROG_CC_WORKS($cc $cflags $cppflags $flag,
Packit 5c3484
          [cflags="$cflags $flag"
Packit 5c3484
          break])
Packit 5c3484
      done
Packit 5c3484
    done
Packit 5c3484
  fi
Packit 5c3484
Packit 5c3484
  ABI="$abi"
Packit 5c3484
  CC="$cc"
Packit 5c3484
  CFLAGS="$cflags"
Packit 5c3484
  CPPFLAGS="$cppflags"
Packit 5c3484
  eval GMP_NONSTD_ABI=\"\$GMP_NONSTD_ABI_$ABI\"
Packit 5c3484
Packit 5c3484
  # Could easily have this in config.h too, if desired.
Packit 5c3484
  ABI_nodots=`echo $ABI | sed 's/\./_/'`
Packit 5c3484
  GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_ABI_$ABI_nodots')", POST)
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # GMP_LDFLAGS substitution, selected according to ABI.
Packit 5c3484
  # These are needed on libgmp.la and libmp.la, but currently not on
Packit 5c3484
  # convenience libraries like tune/libspeed.la or mpz/libmpz.la.
Packit 5c3484
  #
Packit 5c3484
                            eval GMP_LDFLAGS=\"\$${ccbase}${abi1}_ldflags\"
Packit 5c3484
  test -n "$GMP_LDFLAGS" || eval GMP_LDFLAGS=\"\$${ccbase}${abi1}_ldflags\"
Packit 5c3484
  AC_SUBST(GMP_LDFLAGS)
Packit 5c3484
  AC_SUBST(LIBGMP_LDFLAGS)
Packit 5c3484
  AC_SUBST(LIBGMPXX_LDFLAGS)
Packit 5c3484
Packit 5c3484
  # extra_functions, selected according to ABI
Packit 5c3484
                    eval tmp=\"\$extra_functions$abi1\"
Packit 5c3484
  test -n "$tmp" || eval tmp=\"\$extra_functions$abi2\"
Packit 5c3484
  extra_functions="$tmp"
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # Cycle counter, selected according to ABI.
Packit 5c3484
  #
Packit 5c3484
                    eval tmp=\"\$SPEED_CYCLECOUNTER_OBJ$abi1\"
Packit 5c3484
  test -n "$tmp" || eval tmp=\"\$SPEED_CYCLECOUNTER_OBJ$abi2\"
Packit 5c3484
  SPEED_CYCLECOUNTER_OBJ="$tmp"
Packit 5c3484
                    eval tmp=\"\$cyclecounter_size$abi1\"
Packit 5c3484
  test -n "$tmp" || eval tmp=\"\$cyclecounter_size$abi2\"
Packit 5c3484
  cyclecounter_size="$tmp"
Packit 5c3484
Packit 5c3484
  if test -n "$SPEED_CYCLECOUNTER_OBJ"; then
Packit 5c3484
    AC_DEFINE_UNQUOTED(HAVE_SPEED_CYCLECOUNTER, $cyclecounter_size,
Packit 5c3484
    [Tune directory speed_cyclecounter, undef=none, 1=32bits, 2=64bits)])
Packit 5c3484
  fi
Packit 5c3484
  AC_SUBST(SPEED_CYCLECOUNTER_OBJ)
Packit 5c3484
Packit 5c3484
Packit 5c3484
  # Calling conventions checking, selected according to ABI.
Packit 5c3484
  #
Packit 5c3484
                    eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi1\"
Packit 5c3484
  test -n "$tmp" || eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi2\"
Packit 5c3484
  if test "$enable_assembly" = "yes"; then
Packit 5c3484
     CALLING_CONVENTIONS_OBJS="$tmp"
Packit 5c3484
  else
Packit 5c3484
     CALLING_CONVENTIONS_OBJS=""
Packit 5c3484
  fi
Packit 5c3484
Packit 5c3484
  if test -n "$CALLING_CONVENTIONS_OBJS"; then
Packit 5c3484
    AC_DEFINE(HAVE_CALLING_CONVENTIONS,1,
Packit 5c3484
    [Define to 1 if tests/libtests has calling conventions checking for the CPU])
Packit 5c3484
  fi
Packit 5c3484
  AC_SUBST(CALLING_CONVENTIONS_OBJS)
Packit 5c3484
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
Packit 5c3484
# If the user gave an MPN_PATH, use that verbatim, otherwise choose
Packit 5c3484
# according to the ABI and add "generic".
Packit 5c3484
#
Packit 5c3484
if test -n "$MPN_PATH"; then
Packit 5c3484
  path="$MPN_PATH"
Packit 5c3484
else
Packit 5c3484
                    eval tmp=\"\$path$abi1\"
Packit 5c3484
  test -n "$tmp" || eval tmp=\"\$path$abi2\"
Packit 5c3484
  path="$tmp generic"
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Long long limb setup for gmp.h.
Packit 5c3484
case $limb_chosen in
Packit 5c3484
longlong) DEFN_LONG_LONG_LIMB="#define _LONG_LONG_LIMB 1"    ;;
Packit 5c3484
*)        DEFN_LONG_LONG_LIMB="/* #undef _LONG_LONG_LIMB */" ;;
Packit 5c3484
esac
Packit 5c3484
AC_SUBST(DEFN_LONG_LONG_LIMB)
Packit 5c3484
Packit 5c3484
Packit 5c3484
# The C compiler and preprocessor, put into ANSI mode if possible.
Packit 5c3484
AC_PROG_CC
Packit 5c3484
AC_PROG_CC_STDC
Packit 5c3484
AC_PROG_CPP
Packit 5c3484
Packit 5c3484
Packit 5c3484
# The C compiler on the build system, and associated tests.
Packit 5c3484
GMP_PROG_CC_FOR_BUILD
Packit 5c3484
GMP_PROG_CPP_FOR_BUILD
Packit 5c3484
GMP_PROG_EXEEXT_FOR_BUILD
Packit 5c3484
GMP_C_FOR_BUILD_ANSI
Packit 5c3484
GMP_CHECK_LIBM_FOR_BUILD
Packit 5c3484
Packit 5c3484
Packit 5c3484
# How to assemble, used with CFLAGS etc, see mpn/Makeasm.am.
Packit 5c3484
# Using the compiler is a lot easier than figuring out how to invoke the
Packit 5c3484
# assembler directly.
Packit 5c3484
#
Packit 5c3484
test -n "$CCAS" || CCAS="$CC -c"
Packit 5c3484
AC_SUBST(CCAS)
Packit 5c3484
Packit 5c3484
Packit 5c3484
# The C++ compiler, if desired.
Packit 5c3484
want_cxx=no
Packit 5c3484
if test $enable_cxx != no; then
Packit 5c3484
  test_CXXFLAGS=${CXXFLAGS+set}
Packit 5c3484
  AC_PROG_CXX
Packit 5c3484
Packit 5c3484
  echo "CXXFLAGS chosen by autoconf: $CXXFLAGS" >&AC_FD_CC
Packit 5c3484
  cxxflags_ac_prog_cxx=$CXXFLAGS
Packit 5c3484
  cxxflags_list=ac_prog_cxx
Packit 5c3484
Packit 5c3484
  # If the user didn't specify $CXXFLAGS, then try $CFLAGS, with -g removed
Packit 5c3484
  # if AC_PROG_CXX thinks that doesn't work.  $CFLAGS stands a good chance
Packit 5c3484
  # of working, eg. on a GNU system where CC=gcc and CXX=g++.
Packit 5c3484
  #
Packit 5c3484
  if test "$test_CXXFLAGS" != set; then
Packit 5c3484
    cxxflags_cflags=$CFLAGS
Packit 5c3484
    cxxflags_list="cflags $cxxflags_list"
Packit 5c3484
    if test "$ac_prog_cxx_g" = no; then
Packit 5c3484
      cxxflags_cflags=`echo "$cxxflags_cflags" | sed -e 's/ -g //' -e 's/^-g //' -e 's/ -g$//'`
Packit 5c3484
    fi
Packit 5c3484
  fi
Packit 5c3484
Packit 5c3484
  # See if the C++ compiler works.  If the user specified CXXFLAGS then all
Packit 5c3484
  # we're doing is checking whether AC_PROG_CXX succeeded, since it doesn't
Packit 5c3484
  # give a fatal error, just leaves CXX set to a default g++.  If on the
Packit 5c3484
  # other hand the user didn't specify CXXFLAGS then we get to try here our
Packit 5c3484
  # $cxxflags_list alternatives.
Packit 5c3484
  #
Packit 5c3484
  # Automake includes $CPPFLAGS in a C++ compile, so we do the same here.
Packit 5c3484
  #
Packit 5c3484
  for cxxflags_choice in $cxxflags_list; do
Packit 5c3484
    eval CXXFLAGS=\"\$cxxflags_$cxxflags_choice\"
Packit 5c3484
    GMP_PROG_CXX_WORKS($CXX $CPPFLAGS $CXXFLAGS,
Packit 5c3484
      [want_cxx=yes
Packit 5c3484
      break])
Packit 5c3484
  done
Packit 5c3484
Packit 5c3484
  # If --enable-cxx=yes but a C++ compiler can't be found, then abort.
Packit 5c3484
  if test $want_cxx = no && test $enable_cxx = yes; then
Packit 5c3484
    AC_MSG_ERROR([C++ compiler not available, see config.log for details])
Packit 5c3484
  fi
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
AM_CONDITIONAL(WANT_CXX, test $want_cxx = yes)
Packit 5c3484
Packit 5c3484
# FIXME: We're not interested in CXXCPP for ourselves, but if we don't do it
Packit 5c3484
# here then AC_PROG_LIBTOOL will AC_REQUIRE it (via _LT_AC_TAGCONFIG) and
Packit 5c3484
# hence execute it unconditionally, and that will fail if there's no C++
Packit 5c3484
# compiler (and no generic /lib/cpp).
Packit 5c3484
#
Packit 5c3484
if test $want_cxx = yes; then
Packit 5c3484
  AC_PROG_CXXCPP
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Path setups for Cray, according to IEEE or CFP.  These must come after
Packit 5c3484
# deciding the compiler.
Packit 5c3484
#
Packit 5c3484
GMP_CRAY_OPTIONS(
Packit 5c3484
  [add_path="cray/ieee"],
Packit 5c3484
  [add_path="cray/cfp"; extra_functions="mulwwc90"],
Packit 5c3484
  [add_path="cray/cfp"; extra_functions="mulwwj90"])
Packit 5c3484
Packit 5c3484
Packit 5c3484
if test -z "$MPN_PATH"; then
Packit 5c3484
  path="$add_path $path"
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
# For a nail build, also look in "nails" subdirectories.
Packit 5c3484
#
Packit 5c3484
if test $GMP_NAIL_BITS != 0 && test -z "$MPN_PATH"; then
Packit 5c3484
  new_path=
Packit 5c3484
  for i in $path; do
Packit 5c3484
    case $i in
Packit 5c3484
    generic) new_path="$new_path $i" ;;
Packit 5c3484
    *)       new_path="$new_path $i/nails $i" ;;
Packit 5c3484
    esac
Packit 5c3484
  done
Packit 5c3484
  path=$new_path
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Put all directories into CPUVEC_list so as to get a full set of
Packit 5c3484
# CPUVEC_SETUP_$tmp_suffix defines into config.h, even if some of them are
Packit 5c3484
# empty because mmx and/or sse2 had to be dropped.
Packit 5c3484
#
Packit 5c3484
for i in $fat_path; do
Packit 5c3484
  GMP_FAT_SUFFIX(tmp_suffix, $i)
Packit 5c3484
  CPUVEC_list="$CPUVEC_list CPUVEC_SETUP_$tmp_suffix"
Packit 5c3484
done
Packit 5c3484
Packit 5c3484
Packit 5c3484
# If there's any sse2 or mmx in the path, check whether the assembler
Packit 5c3484
# supports it, and remove if not.
Packit 5c3484
#
Packit 5c3484
# We only need this in ABI=32, for ABI=64 on x86_64 we can assume a new
Packit 5c3484
# enough assembler.
Packit 5c3484
#
Packit 5c3484
case $host in
Packit 5c3484
  X86_PATTERN | X86_64_PATTERN)
Packit 5c3484
    if test "$ABI" = 32; then
Packit 5c3484
      case "$path $fat_path" in
Packit 5c3484
        *mmx*)   GMP_ASM_X86_MMX( , [GMP_STRIP_PATH(*mmx*)]) ;;
Packit 5c3484
      esac
Packit 5c3484
      case "$path $fat_path" in
Packit 5c3484
        *sse2*)  GMP_ASM_X86_SSE2( , [GMP_STRIP_PATH(sse2)]) ;;
Packit 5c3484
      esac
Packit 5c3484
    fi
Packit 5c3484
    case "$path $fat_path" in
Packit 5c3484
      *mulx*)  GMP_ASM_X86_MULX( , [GMP_STRIP_PATH(mulx)]) ;;
Packit 5c3484
    esac
Packit 5c3484
    case "$path $fat_path" in
Packit 5c3484
      *adx*)   GMP_ASM_X86_ADX( , [GMP_STRIP_PATH(adx)]) ;;
Packit 5c3484
    esac
Packit 5c3484
    ;;
Packit 5c3484
esac
Packit 5c3484
Packit 5c3484
Packit 5c3484
if test "$enable_assembly" = "no"; then
Packit 5c3484
  path="generic"
Packit 5c3484
  AC_DEFINE([NO_ASM],1,[Define to 1 to disable the use of inline assembly])
Packit 5c3484
#  for abi in $abilist; do
Packit 5c3484
#    eval unset "path_\$abi"
Packit 5c3484
#    eval gcc_${abi}_cflags=\"\$gcc_${abi}_cflags -DNO_ASM\"
Packit 5c3484
#  done
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
Packit 5c3484
cat >&AC_FD_CC <
Packit 5c3484
Decided:
Packit 5c3484
ABI=$ABI
Packit 5c3484
CC=$CC
Packit 5c3484
CFLAGS=$CFLAGS
Packit 5c3484
CPPFLAGS=$CPPFLAGS
Packit 5c3484
GMP_LDFLAGS=$GMP_LDFLAGS
Packit 5c3484
CXX=$CXX
Packit 5c3484
CXXFLAGS=$CXXFLAGS
Packit 5c3484
path=$path
Packit 5c3484
EOF
Packit 5c3484
echo "using ABI=\"$ABI\""
Packit 5c3484
echo "      CC=\"$CC\""
Packit 5c3484
echo "      CFLAGS=\"$CFLAGS\""
Packit 5c3484
echo "      CPPFLAGS=\"$CPPFLAGS\""
Packit 5c3484
if test $want_cxx = yes; then
Packit 5c3484
  echo "      CXX=\"$CXX\""
Packit 5c3484
  echo "      CXXFLAGS=\"$CXXFLAGS\""
Packit 5c3484
fi
Packit 5c3484
echo "      MPN_PATH=\"$path\""
Packit 5c3484
Packit 5c3484
Packit 5c3484
CL_AS_NOEXECSTACK
Packit 5c3484
Packit 5c3484
GMP_PROG_AR
Packit 5c3484
GMP_PROG_NM
Packit 5c3484
Packit 5c3484
case $host in
Packit 5c3484
  # FIXME: On AIX 3 and 4, $libname.a is included in libtool
Packit 5c3484
  # $library_names_spec, so libgmp.a becomes a symlink to libgmp.so, making
Packit 5c3484
  # it impossible to build shared and static libraries simultaneously.
Packit 5c3484
  # Disable shared libraries by default, but let the user override with
Packit 5c3484
  # --enable-shared --disable-static.
Packit 5c3484
  #
Packit 5c3484
  # FIXME: This $libname.a problem looks like it might apply to *-*-amigaos*
Packit 5c3484
  # and *-*-os2* too, but wait for someone to test this before worrying
Packit 5c3484
  # about it.  If there is a problem then of course libtool is the right
Packit 5c3484
  # place to fix it.
Packit 5c3484
  #
Packit 5c3484
  [*-*-aix[34]*])
Packit 5c3484
    if test -z "$enable_shared"; then enable_shared=no; fi ;;
Packit 5c3484
esac
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Configs for Windows DLLs.
Packit 5c3484
Packit 5c3484
AC_LIBTOOL_WIN32_DLL
Packit 5c3484
Packit 5c3484
AC_SUBST(LIBGMP_DLL,0)
Packit 5c3484
case $host in
Packit 5c3484
  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
Packit 5c3484
    # By default, build only static.
Packit 5c3484
    if test -z "$enable_shared"; then
Packit 5c3484
      enable_shared=no
Packit 5c3484
    fi
Packit 5c3484
    # Don't allow both static and DLL.
Packit 5c3484
    if test "$enable_shared" != no && test "$enable_static" != no; then
Packit 5c3484
      AC_MSG_ERROR([cannot build both static and DLL, since gmp.h is different for each.
Packit 5c3484
Use "--disable-static --enable-shared" to build just a DLL.])
Packit 5c3484
    fi
Packit 5c3484
Packit 5c3484
    # "-no-undefined" is required when building a DLL, see documentation on
Packit 5c3484
    # AC_LIBTOOL_WIN32_DLL.
Packit 5c3484
    #
Packit 5c3484
    # "-Wl,--export-all-symbols" is a bit of a hack, it gets all libgmp and
Packit 5c3484
    # libgmpxx functions and variables exported.  This is what libtool did
Packit 5c3484
    # in the past, and it's convenient for us in the test programs.
Packit 5c3484
    #
Packit 5c3484
    # Maybe it'd be prudent to check for --export-all-symbols before using
Packit 5c3484
    # it, but it seems to have been in ld since at least 2000, and there's
Packit 5c3484
    # not really any alternative we want to take up at the moment.
Packit 5c3484
    #
Packit 5c3484
    # "-Wl,output-def" is used to get a .def file for use by MS lib to make
Packit 5c3484
    # a .lib import library, described in the manual.  libgmp-3.dll.def
Packit 5c3484
    # corresponds to the libmp-3.dll.def generated by libtool (as a result
Packit 5c3484
    # of -export-symbols on that library).
Packit 5c3484
    #
Packit 5c3484
    # Incidentally, libtool does generate an import library libgmp.dll.a,
Packit 5c3484
    # but it's "ar" format and cannot be used by the MS linker.  There
Packit 5c3484
    # doesn't seem to be any GNU tool for generating or converting to .lib.
Packit 5c3484
    #
Packit 5c3484
    # FIXME: The .def files produced by -Wl,output-def include isascii,
Packit 5c3484
    # iscsym, iscsymf and toascii, apparently because mingw ctype.h doesn't
Packit 5c3484
    # inline isascii (used in gmp).  It gives an extern inline for
Packit 5c3484
    # __isascii, but for some reason not the plain isascii.
Packit 5c3484
    #
Packit 5c3484
    if test "$enable_shared" = yes; then
Packit 5c3484
      GMP_LDFLAGS="$GMP_LDFLAGS -no-undefined -Wl,--export-all-symbols"
Packit 5c3484
      LIBGMP_LDFLAGS="$LIBGMP_LDFLAGS -Wl,--output-def,.libs/libgmp-3.dll.def"
Packit 5c3484
      LIBGMPXX_LDFLAGS="$LIBGMP_LDFLAGS -Wl,--output-def,.libs/libgmpxx-3.dll.def"
Packit 5c3484
      LIBGMP_DLL=1
Packit 5c3484
    fi
Packit 5c3484
    ;;
Packit 5c3484
esac
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Ensure that $CONFIG_SHELL is available for AC_LIBTOOL_SYS_MAX_CMD_LEN.
Packit 5c3484
# It's often set already by _LT_AC_PROG_ECHO_BACKSLASH or
Packit 5c3484
# _AS_LINENO_PREPARE, but not always.
Packit 5c3484
#
Packit 5c3484
# The symptom of CONFIG_SHELL unset is some "expr" errors during the test,
Packit 5c3484
# and an empty result.  This only happens when invoked as "sh configure",
Packit 5c3484
# ie. no path, and can be seen for instance on ia64-*-hpux*.
Packit 5c3484
#
Packit 5c3484
# FIXME: Newer libtool should have it's own fix for this.
Packit 5c3484
#
Packit 5c3484
if test -z "$CONFIG_SHELL"; then
Packit 5c3484
  CONFIG_SHELL=$SHELL
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
# Enable CXX in libtool only if we want it, and never enable GCJ, nor RC on
Packit 5c3484
# mingw and cygwin.  Under --disable-cxx this avoids some error messages
Packit 5c3484
# from libtool arising from the fact we didn't actually run AC_PROG_CXX.
Packit 5c3484
# Notice that any user-supplied --with-tags setting takes precedence.
Packit 5c3484
#
Packit 5c3484
# FIXME: Is this the right way to get this effect?  Very possibly not, but
Packit 5c3484
# the current _LT_AC_TAGCONFIG doesn't really suggest an alternative.
Packit 5c3484
#
Packit 5c3484
if test "${with_tags+set}" != set; then
Packit 5c3484
  if test $want_cxx = yes; then
Packit 5c3484
    with_tags=CXX
Packit 5c3484
  else
Packit 5c3484
    with_tags=
Packit 5c3484
  fi
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
# The dead hand of AC_REQUIRE makes AC_PROG_LIBTOOL expand and execute
Packit 5c3484
# AC_PROG_F77, even when F77 is not in the selected with_tags.  This is
Packit 5c3484
# probably harmless, but it's unsightly and bloats our configure, so pretend
Packit 5c3484
# AC_PROG_F77 has been expanded already.
Packit 5c3484
#
Packit 5c3484
# FIXME: Rumour has it libtool will one day provide a way for a configure.in
Packit 5c3484
# to say what it wants from among supported languages etc.
Packit 5c3484
#
Packit 5c3484
#AC_PROVIDE([AC_PROG_F77])
Packit 5c3484
Packit 5c3484
AC_PROG_LIBTOOL
Packit 5c3484
Packit 5c3484
# Generate an error here if attempting to build both shared and static when
Packit 5c3484
# $libname.a is in $library_names_spec (as mentioned above), rather than
Packit 5c3484
# wait for ar or ld to fail.
Packit 5c3484
#
Packit 5c3484
if test "$enable_shared" = yes && test "$enable_static" = yes; then
Packit 5c3484
  case $library_names_spec in
Packit 5c3484
    *libname.a*)
Packit 5c3484
      AC_MSG_ERROR([cannot create both shared and static libraries on this system, --disable one of the two])
Packit 5c3484
      ;;
Packit 5c3484
  esac
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
AM_CONDITIONAL(ENABLE_STATIC, test "$enable_static" = yes)
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Many of these library and header checks are for the benefit of
Packit 5c3484
# supplementary programs.  libgmp doesn't use anything too weird.
Packit 5c3484
Packit 5c3484
AC_HEADER_STDC
Packit 5c3484
AC_HEADER_TIME
Packit 5c3484
Packit 5c3484
# Reasons for testing:
Packit 5c3484
#   float.h - not in SunOS bundled cc
Packit 5c3484
#   invent.h - IRIX specific
Packit 5c3484
#   langinfo.h - X/Open standard only, not in djgpp for instance
Packit 5c3484
#   locale.h - old systems won't have this
Packit 5c3484
#   nl_types.h - X/Open standard only, not in djgpp for instance
Packit 5c3484
#       (usually langinfo.h gives nl_item etc, but not on netbsd 1.4.1)
Packit 5c3484
#   sys/attributes.h - IRIX specific
Packit 5c3484
#   sys/iograph.h - IRIX specific
Packit 5c3484
#   sys/mman.h - not in Cray Unicos
Packit 5c3484
#   sys/param.h - not in mingw
Packit 5c3484
#   sys/processor.h - solaris specific, though also present in macos
Packit 5c3484
#   sys/pstat.h - HPUX specific
Packit 5c3484
#   sys/resource.h - not in mingw
Packit 5c3484
#   sys/sysctl.h - not in mingw
Packit 5c3484
#   sys/sysinfo.h - OSF specific
Packit 5c3484
#   sys/syssgi.h - IRIX specific
Packit 5c3484
#   sys/systemcfg.h - AIX specific
Packit 5c3484
#   sys/time.h - autoconf suggests testing, don't know anywhere without it
Packit 5c3484
#   sys/times.h - not in mingw
Packit 5c3484
#   machine/hal_sysinfo.h - OSF specific
Packit 5c3484
#
Packit 5c3484
# inttypes.h, stdint.h, unistd.h and sys/types.h are already in the autoconf
Packit 5c3484
# default tests
Packit 5c3484
#
Packit 5c3484
AC_CHECK_HEADERS(fcntl.h float.h invent.h langinfo.h locale.h nl_types.h sys/attributes.h sys/iograph.h sys/mman.h sys/param.h sys/processor.h sys/pstat.h sys/sysinfo.h sys/syssgi.h sys/systemcfg.h sys/time.h sys/times.h)
Packit 5c3484
Packit 5c3484
# On SunOS, sys/resource.h needs sys/time.h (for struct timeval)
Packit 5c3484
AC_CHECK_HEADERS(sys/resource.h,,,
Packit 5c3484
[#if TIME_WITH_SYS_TIME
Packit 5c3484
# include <sys/time.h>
Packit 5c3484
# include <time.h>
Packit 5c3484
#else
Packit 5c3484
# if HAVE_SYS_TIME_H
Packit 5c3484
#  include <sys/time.h>
Packit 5c3484
# else
Packit 5c3484
#  include <time.h>
Packit 5c3484
# endif
Packit 5c3484
#endif])
Packit 5c3484
Packit 5c3484
# On NetBSD and OpenBSD, sys/sysctl.h needs sys/param.h for various constants
Packit 5c3484
AC_CHECK_HEADERS(sys/sysctl.h,,,
Packit 5c3484
[#if HAVE_SYS_PARAM_H
Packit 5c3484
# include <sys/param.h>
Packit 5c3484
#endif])
Packit 5c3484
Packit 5c3484
# On OSF 4.0, <machine/hal_sysinfo.h> must have <sys/sysinfo.h> for ulong_t
Packit 5c3484
AC_CHECK_HEADERS(machine/hal_sysinfo.h,,,
Packit 5c3484
[#if HAVE_SYS_SYSINFO_H
Packit 5c3484
# include <sys/sysinfo.h>
Packit 5c3484
#endif])
Packit 5c3484
Packit 5c3484
# Reasons for testing:
Packit 5c3484
#   optarg - not declared in mingw
Packit 5c3484
#   fgetc, fscanf, ungetc, vfprintf - not declared in SunOS 4
Packit 5c3484
#   sys_errlist, sys_nerr - not declared in SunOS 4
Packit 5c3484
#
Packit 5c3484
# optarg should be in unistd.h and the rest in stdio.h, both of which are
Packit 5c3484
# in the autoconf default includes.
Packit 5c3484
#
Packit 5c3484
# sys_errlist and sys_nerr are supposed to be in <errno.h> on SunOS according
Packit 5c3484
# to the man page (but aren't), in glibc they're in stdio.h.
Packit 5c3484
#
Packit 5c3484
AC_CHECK_DECLS([fgetc, fscanf, optarg, ungetc, vfprintf])
Packit 5c3484
AC_CHECK_DECLS([sys_errlist, sys_nerr], , ,
Packit 5c3484
[#include <stdio.h>
Packit 5c3484
#include <errno.h>])
Packit 5c3484
Packit 5c3484
AC_TYPE_SIGNAL
Packit 5c3484
Packit 5c3484
# Reasons for testing:
Packit 5c3484
#   intmax_t       - C99
Packit 5c3484
#   long double    - not in the HP bundled K&R cc
Packit 5c3484
#   long long      - only in reasonably recent compilers
Packit 5c3484
#   ptrdiff_t      - seems to be everywhere, maybe don't need to check this
Packit 5c3484
#   quad_t         - BSD specific
Packit 5c3484
#   uint_least32_t - C99
Packit 5c3484
#
Packit 5c3484
# the default includes are sufficient for all these types
Packit 5c3484
#
Packit 5c3484
AC_CHECK_TYPES([intmax_t, long double, long long, ptrdiff_t, quad_t,
Packit 5c3484
		uint_least32_t, intptr_t])
Packit 5c3484
Packit 5c3484
# FIXME: Really want #ifndef __cplusplus around the #define volatile
Packit 5c3484
# replacement autoconf gives, since volatile is always available in C++.
Packit 5c3484
# But we don't use it in C++ currently.
Packit 5c3484
AC_C_VOLATILE
Packit 5c3484
Packit 5c3484
AC_C_RESTRICT
Packit 5c3484
Packit 5c3484
# GMP_C_STDARG
Packit 5c3484
GMP_C_ATTRIBUTE_CONST
Packit 5c3484
GMP_C_ATTRIBUTE_MALLOC
Packit 5c3484
GMP_C_ATTRIBUTE_MODE
Packit 5c3484
GMP_C_ATTRIBUTE_NORETURN
Packit 5c3484
GMP_C_HIDDEN_ALIAS
Packit 5c3484
Packit 5c3484
GMP_H_EXTERN_INLINE
Packit 5c3484
Packit 5c3484
# from libtool
Packit 5c3484
AC_CHECK_LIBM
Packit 5c3484
AC_SUBST(LIBM)
Packit 5c3484
Packit 5c3484
GMP_FUNC_ALLOCA
Packit 5c3484
GMP_OPTION_ALLOCA
Packit 5c3484
Packit 5c3484
GMP_H_HAVE_FILE
Packit 5c3484
Packit 5c3484
AC_C_BIGENDIAN(
Packit 5c3484
  [AC_DEFINE(HAVE_LIMB_BIG_ENDIAN, 1)
Packit 5c3484
   GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_LIMB_BIG_ENDIAN')", POST)],
Packit 5c3484
  [AC_DEFINE(HAVE_LIMB_LITTLE_ENDIAN, 1)
Packit 5c3484
   GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_LIMB_LITTLE_ENDIAN')", POST)
Packit 5c3484
  ], [:])
Packit 5c3484
AH_VERBATIM([HAVE_LIMB],
Packit 5c3484
[/* Define one of these to 1 for the endianness of `mp_limb_t'.
Packit 5c3484
   If the endianness is not a simple big or little, or you don't know what
Packit 5c3484
   it is, then leave both undefined. */
Packit 5c3484
#undef HAVE_LIMB_BIG_ENDIAN
Packit 5c3484
#undef HAVE_LIMB_LITTLE_ENDIAN])
Packit 5c3484
Packit 5c3484
GMP_C_DOUBLE_FORMAT
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Reasons for testing:
Packit 5c3484
#   alarm - not in mingw
Packit 5c3484
#   attr_get - IRIX specific
Packit 5c3484
#   clock_gettime - not in glibc 2.2.4, only very recent systems
Packit 5c3484
#   cputime - not in glibc
Packit 5c3484
#   getsysinfo - OSF specific
Packit 5c3484
#   getrusage - not in mingw
Packit 5c3484
#   gettimeofday - not in mingw
Packit 5c3484
#   mmap - not in mingw, djgpp
Packit 5c3484
#   nl_langinfo - X/Open standard only, not in djgpp for instance
Packit 5c3484
#   obstack_vprintf - glibc specific
Packit 5c3484
#   processor_info - solaris specific
Packit 5c3484
#   pstat_getprocessor - HPUX specific (10.x and up)
Packit 5c3484
#   raise - an ANSI-ism, though probably almost universal by now
Packit 5c3484
#   read_real_time - AIX specific
Packit 5c3484
#   sigaction - not in mingw
Packit 5c3484
#   sigaltstack - not in mingw, or old AIX (reputedly)
Packit 5c3484
#   sigstack - not in mingw
Packit 5c3484
#   strerror - not in SunOS
Packit 5c3484
#   strnlen - glibc extension (some other systems too)
Packit 5c3484
#   syssgi - IRIX specific
Packit 5c3484
#   times - not in mingw
Packit 5c3484
#
Packit 5c3484
# AC_FUNC_STRNLEN is not used because we don't want the AC_LIBOBJ
Packit 5c3484
# replacement setups it gives.  It detects a faulty strnlen on AIX, but
Packit 5c3484
# missing out on that test is ok since our only use of strnlen is in
Packit 5c3484
# __gmp_replacement_vsnprintf which is not required on AIX since it has a
Packit 5c3484
# vsnprintf.
Packit 5c3484
#
Packit 5c3484
AC_CHECK_FUNCS(alarm attr_get clock cputime getpagesize getrusage gettimeofday getsysinfo localeconv memset mmap mprotect nl_langinfo obstack_vprintf popen processor_info pstat_getprocessor raise read_real_time sigaction sigaltstack sigstack syssgi strchr strerror strnlen strtol strtoul sysconf sysctl sysctlbyname times)
Packit 5c3484
Packit 5c3484
# clock_gettime is in librt on *-*-osf5.1 and on glibc, so att -lrt to
Packit 5c3484
# TUNE_LIBS if needed. On linux (tested on x86_32, 2.6.26),
Packit 5c3484
# clock_getres reports ns accuracy, while in a quick test on osf
Packit 5c3484
# clock_getres said only 1 millisecond.
Packit 5c3484
Packit 5c3484
old_LIBS="$LIBS"
Packit 5c3484
AC_SEARCH_LIBS(clock_gettime, rt, [
Packit 5c3484
  AC_DEFINE([HAVE_CLOCK_GETTIME],1,[Define to 1 if you have the `clock_gettime' function])])
Packit 5c3484
TUNE_LIBS="$LIBS"
Packit 5c3484
LIBS="$old_LIBS"
Packit 5c3484
Packit 5c3484
AC_SUBST(TUNE_LIBS)
Packit 5c3484
Packit 5c3484
GMP_FUNC_VSNPRINTF
Packit 5c3484
GMP_FUNC_SSCANF_WRITABLE_INPUT
Packit 5c3484
Packit 5c3484
# Reasons for checking:
Packit 5c3484
#   pst_processor psp_iticksperclktick - not in hpux 9
Packit 5c3484
#
Packit 5c3484
AC_CHECK_MEMBER(struct pst_processor.psp_iticksperclktick,
Packit 5c3484
                [AC_DEFINE(HAVE_PSP_ITICKSPERCLKTICK, 1,
Packit 5c3484
[Define to 1 if <sys/pstat.h> `struct pst_processor' exists
Packit 5c3484
and contains `psp_iticksperclktick'.])],,
Packit 5c3484
                [#include <sys/pstat.h>])
Packit 5c3484
Packit 5c3484
# C++ tests, when required
Packit 5c3484
#
Packit 5c3484
if test $enable_cxx = yes; then
Packit 5c3484
  AC_LANG_PUSH(C++)
Packit 5c3484
Packit 5c3484
  # Reasons for testing:
Packit 5c3484
  #   <sstream> - not in g++ 2.95.2
Packit 5c3484
  #   std::locale - not in g++ 2.95.4
Packit 5c3484
  #
Packit 5c3484
  AC_CHECK_HEADERS([sstream])
Packit 5c3484
  AC_CHECK_TYPES([std::locale],,,[#include <locale>])
Packit 5c3484
Packit 5c3484
  AC_LANG_POP(C++)
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Pick the correct source files in $path and link them to mpn/.
Packit 5c3484
# $gmp_mpn_functions lists all functions we need.
Packit 5c3484
#
Packit 5c3484
# The rule is to find a file with the function name and a .asm, .S,
Packit 5c3484
# .s, or .c extension.  Certain multi-function files with special names
Packit 5c3484
# can provide some functions too.  (mpn/Makefile.am passes
Packit 5c3484
# -DOPERATION_<func> to get them to generate the right code.)
Packit 5c3484
Packit 5c3484
# Note: $gmp_mpn_functions must have mod_1 before pre_mod_1 so the former
Packit 5c3484
#       can optionally provide the latter as an extra entrypoint.  Likewise
Packit 5c3484
#       divrem_1 and pre_divrem_1.
Packit 5c3484
Packit 5c3484
gmp_mpn_functions_optional="umul udiv					\
Packit 5c3484
  invert_limb sqr_diagonal sqr_diag_addlsh1				\
Packit 5c3484
  mul_2 mul_3 mul_4 mul_5 mul_6						\
Packit 5c3484
  addmul_2 addmul_3 addmul_4 addmul_5 addmul_6 addmul_7 addmul_8	\
Packit 5c3484
  addlsh1_n sublsh1_n rsblsh1_n rsh1add_n rsh1sub_n			\
Packit 5c3484
  addlsh2_n sublsh2_n rsblsh2_n						\
Packit 5c3484
  addlsh_n sublsh_n rsblsh_n						\
Packit 5c3484
  add_n_sub_n addaddmul_1msb0"
Packit 5c3484
Packit 5c3484
gmp_mpn_functions="$extra_functions					   \
Packit 5c3484
  add add_1 add_n sub sub_1 sub_n cnd_add_n cnd_sub_n cnd_swap neg com	   \
Packit 5c3484
  mul_1 addmul_1 submul_1						   \
Packit 5c3484
  add_err1_n add_err2_n add_err3_n sub_err1_n sub_err2_n sub_err3_n	   \
Packit 5c3484
  lshift rshift dive_1 diveby3 divis divrem divrem_1 divrem_2		   \
Packit 5c3484
  fib2_ui mod_1 mod_34lsub1 mode1o pre_divrem_1 pre_mod_1 dump		   \
Packit 5c3484
  mod_1_1 mod_1_2 mod_1_3 mod_1_4 lshiftc				   \
Packit 5c3484
  mul mul_fft mul_n sqr mul_basecase sqr_basecase nussbaumer_mul	   \
Packit 5c3484
  mulmid_basecase toom42_mulmid mulmid_n mulmid				   \
Packit 5c3484
  random random2 pow_1							   \
Packit 5c3484
  rootrem sqrtrem sizeinbase get_str set_str				   \
Packit 5c3484
  scan0 scan1 popcount hamdist cmp zero_p				   \
Packit 5c3484
  perfsqr perfpow							   \
Packit 5c3484
  gcd_1 gcd gcdext_1 gcdext gcd_subdiv_step				   \
Packit 5c3484
  gcdext_lehmer								   \
Packit 5c3484
  div_q tdiv_qr jacbase jacobi_2 jacobi get_d				   \
Packit 5c3484
  matrix22_mul matrix22_mul1_inverse_vector				   \
Packit 5c3484
  hgcd_matrix hgcd2 hgcd_step hgcd_reduce hgcd hgcd_appr		   \
Packit 5c3484
  hgcd2_jacobi hgcd_jacobi						   \
Packit 5c3484
  mullo_n mullo_basecase sqrlo sqrlo_basecase				   \
Packit 5c3484
  toom22_mul toom32_mul toom42_mul toom52_mul toom62_mul		   \
Packit 5c3484
  toom33_mul toom43_mul toom53_mul toom54_mul toom63_mul		   \
Packit 5c3484
  toom44_mul								   \
Packit 5c3484
  toom6h_mul toom6_sqr toom8h_mul toom8_sqr				   \
Packit 5c3484
  toom_couple_handling							   \
Packit 5c3484
  toom2_sqr toom3_sqr toom4_sqr						   \
Packit 5c3484
  toom_eval_dgr3_pm1 toom_eval_dgr3_pm2					   \
Packit 5c3484
  toom_eval_pm1 toom_eval_pm2 toom_eval_pm2exp toom_eval_pm2rexp	   \
Packit 5c3484
  toom_interpolate_5pts toom_interpolate_6pts toom_interpolate_7pts	   \
Packit 5c3484
  toom_interpolate_8pts toom_interpolate_12pts toom_interpolate_16pts	   \
Packit 5c3484
  invertappr invert binvert mulmod_bnm1 sqrmod_bnm1			   \
Packit 5c3484
  div_qr_1 div_qr_1n_pi1						   \
Packit 5c3484
  div_qr_2 div_qr_2n_pi1 div_qr_2u_pi1					   \
Packit 5c3484
  sbpi1_div_q sbpi1_div_qr sbpi1_divappr_q				   \
Packit 5c3484
  dcpi1_div_q dcpi1_div_qr dcpi1_divappr_q				   \
Packit 5c3484
  mu_div_qr mu_divappr_q mu_div_q					   \
Packit 5c3484
  bdiv_q_1								   \
Packit 5c3484
  sbpi1_bdiv_q sbpi1_bdiv_qr						   \
Packit 5c3484
  dcpi1_bdiv_q dcpi1_bdiv_qr						   \
Packit 5c3484
  mu_bdiv_q mu_bdiv_qr							   \
Packit 5c3484
  bdiv_q bdiv_qr broot brootinv bsqrt bsqrtinv				   \
Packit 5c3484
  divexact bdiv_dbm1c redc_1 redc_2 redc_n powm powlo sec_powm		   \
Packit 5c3484
  sec_mul sec_sqr sec_div_qr sec_div_r sec_pi1_div_qr sec_pi1_div_r	   \
Packit 5c3484
  sec_add_1 sec_sub_1 sec_invert					   \
Packit 5c3484
  trialdiv remove							   \
Packit 5c3484
  and_n andn_n nand_n ior_n iorn_n nior_n xor_n xnor_n			   \
Packit 5c3484
  copyi copyd zero sec_tabselect					   \
Packit 5c3484
  comb_tables								   \
Packit 5c3484
  $gmp_mpn_functions_optional"
Packit 5c3484
Packit 5c3484
define(GMP_MULFUNC_CHOICES,
Packit 5c3484
[# functions that can be provided by multi-function files
Packit 5c3484
tmp_mulfunc=
Packit 5c3484
case $tmp_fn in
Packit 5c3484
  add_n|sub_n)       tmp_mulfunc="aors_n"    ;;
Packit 5c3484
  add_err1_n|sub_err1_n)
Packit 5c3484
		     tmp_mulfunc="aors_err1_n" ;;
Packit 5c3484
  add_err2_n|sub_err2_n)
Packit 5c3484
		     tmp_mulfunc="aors_err2_n" ;;
Packit 5c3484
  add_err3_n|sub_err3_n)
Packit 5c3484
		     tmp_mulfunc="aors_err3_n" ;;
Packit 5c3484
  cnd_add_n|cnd_sub_n) tmp_mulfunc="cnd_aors_n"   ;;
Packit 5c3484
  sec_add_1|sec_sub_1) tmp_mulfunc="sec_aors_1"   ;;
Packit 5c3484
  addmul_1|submul_1) tmp_mulfunc="aorsmul_1" ;;
Packit 5c3484
  mul_2|addmul_2)    tmp_mulfunc="aormul_2" ;;
Packit 5c3484
  mul_3|addmul_3)    tmp_mulfunc="aormul_3" ;;
Packit 5c3484
  mul_4|addmul_4)    tmp_mulfunc="aormul_4" ;;
Packit 5c3484
  popcount|hamdist)  tmp_mulfunc="popham"    ;;
Packit 5c3484
  and_n|andn_n|nand_n | ior_n|iorn_n|nior_n | xor_n|xnor_n)
Packit 5c3484
                     tmp_mulfunc="logops_n"  ;;
Packit 5c3484
  lshift|rshift)     tmp_mulfunc="lorrshift";;
Packit 5c3484
  addlsh1_n)
Packit 5c3484
		     tmp_mulfunc="aorslsh1_n aorrlsh1_n aorsorrlsh1_n";;
Packit 5c3484
  sublsh1_n)
Packit 5c3484
		     tmp_mulfunc="aorslsh1_n sorrlsh1_n aorsorrlsh1_n";;
Packit 5c3484
  rsblsh1_n)
Packit 5c3484
		     tmp_mulfunc="aorrlsh1_n sorrlsh1_n aorsorrlsh1_n";;
Packit 5c3484
  addlsh2_n)
Packit 5c3484
		     tmp_mulfunc="aorslsh2_n aorrlsh2_n aorsorrlsh2_n";;
Packit 5c3484
  sublsh2_n)
Packit 5c3484
		     tmp_mulfunc="aorslsh2_n sorrlsh2_n aorsorrlsh2_n";;
Packit 5c3484
  rsblsh2_n)
Packit 5c3484
		     tmp_mulfunc="aorrlsh2_n sorrlsh2_n aorsorrlsh2_n";;
Packit 5c3484
  addlsh_n)
Packit 5c3484
		     tmp_mulfunc="aorslsh_n aorrlsh_n aorsorrlsh_n";;
Packit 5c3484
  sublsh_n)
Packit 5c3484
		     tmp_mulfunc="aorslsh_n sorrlsh_n aorsorrlsh_n";;
Packit 5c3484
  rsblsh_n)
Packit 5c3484
		     tmp_mulfunc="aorrlsh_n sorrlsh_n aorsorrlsh_n";;
Packit 5c3484
  rsh1add_n|rsh1sub_n)
Packit 5c3484
		     tmp_mulfunc="rsh1aors_n";;
Packit 5c3484
  sec_div_qr|sec_div_r)
Packit 5c3484
		     tmp_mulfunc="sec_div";;
Packit 5c3484
  sec_pi1_div_qr|sec_pi1_div_r)
Packit 5c3484
		     tmp_mulfunc="sec_pi1_div";;
Packit 5c3484
esac
Packit 5c3484
])
Packit 5c3484
Packit 5c3484
# the list of all object files used by mpn/Makefile.in and the
Packit 5c3484
# top-level Makefile.in, respectively
Packit 5c3484
mpn_objects=
Packit 5c3484
mpn_objs_in_libgmp=
Packit 5c3484
Packit 5c3484
# links from the sources, to be removed by "make distclean"
Packit 5c3484
gmp_srclinks=
Packit 5c3484
Packit 5c3484
Packit 5c3484
# mpn_relative_top_srcdir is $top_srcdir, but for use from within the mpn
Packit 5c3484
# build directory.  If $srcdir is relative then we use a relative path too,
Packit 5c3484
# so the two trees can be moved together.
Packit 5c3484
case $srcdir in
Packit 5c3484
  [[\\/]* | ?:[\\/]*])  # absolute, as per autoconf
Packit 5c3484
    mpn_relative_top_srcdir=$srcdir ;;
Packit 5c3484
  *)                    # relative
Packit 5c3484
    mpn_relative_top_srcdir=../$srcdir ;;
Packit 5c3484
esac
Packit 5c3484
Packit 5c3484
Packit 5c3484
define(MPN_SUFFIXES,[asm S s c])
Packit 5c3484
Packit 5c3484
dnl  Usage: GMP_FILE_TO_FUNCTION_BASE(func,file)
Packit 5c3484
dnl
Packit 5c3484
dnl  Set $func to the function base name for $file, eg. dive_1 gives
Packit 5c3484
dnl  divexact_1.
Packit 5c3484
dnl
Packit 5c3484
define(GMP_FILE_TO_FUNCTION,
Packit 5c3484
[case $$2 in
Packit 5c3484
  dive_1)	$1=divexact_1 ;;
Packit 5c3484
  diveby3)	$1=divexact_by3c ;;
Packit 5c3484
  pre_divrem_1) $1=preinv_divrem_1 ;;
Packit 5c3484
  mode1o)	$1=modexact_1c_odd ;;
Packit 5c3484
  pre_mod_1)	$1=preinv_mod_1 ;;
Packit 5c3484
  mod_1_1)	$1=mod_1_1p ;;
Packit 5c3484
  mod_1_1_cps)	$1=mod_1_1p_cps ;;
Packit 5c3484
  mod_1_2)	$1=mod_1s_2p ;;
Packit 5c3484
  mod_1_2_cps)	$1=mod_1s_2p_cps ;;
Packit 5c3484
  mod_1_3)	$1=mod_1s_3p ;;
Packit 5c3484
  mod_1_3_cps)	$1=mod_1s_3p_cps ;;
Packit 5c3484
  mod_1_4)	$1=mod_1s_4p ;;
Packit 5c3484
  mod_1_4_cps)	$1=mod_1s_4p_cps ;;
Packit 5c3484
  *)		$1=$$2 ;;
Packit 5c3484
esac
Packit 5c3484
])
Packit 5c3484
Packit 5c3484
# Fat binary setups.
Packit 5c3484
#
Packit 5c3484
# We proceed through each $fat_path directory, and look for $fat_function
Packit 5c3484
# routines there.  Those found are incorporated in the build by generating a
Packit 5c3484
# little mpn/<foo>.asm or mpn/<foo>.c file in the build directory, with
Packit 5c3484
# suitable function renaming, and adding that to $mpn_objects (the same as a
Packit 5c3484
# normal mpn file).
Packit 5c3484
#
Packit 5c3484
# fat.h is generated with macros to let internal calls to each $fat_function
Packit 5c3484
# go directly through __gmpn_cpuvec, plus macros and declarations helping to
Packit 5c3484
# setup that structure, on a per-directory basis ready for
Packit 5c3484
# mpn/<cpu>/fat/fat.c.
Packit 5c3484
#
Packit 5c3484
# fat.h includes thresholds listed in $fat_thresholds, extracted from
Packit 5c3484
# gmp-mparam.h in each directory.  An overall maximum for each threshold is
Packit 5c3484
# established, for use in making fixed size arrays of temporary space.
Packit 5c3484
# (Eg. MUL_TOOM33_THRESHOLD_LIMIT used by mpn/generic/mul.c.)
Packit 5c3484
#
Packit 5c3484
# It'd be possible to do some of this manually, but when there's more than a
Packit 5c3484
# few functions and a few directories it becomes very tedious, and very
Packit 5c3484
# prone to having some routine accidentally omitted.  On that basis it seems
Packit 5c3484
# best to automate as much as possible, even if the code to do so is a bit
Packit 5c3484
# ugly.
Packit 5c3484
#
Packit 5c3484
Packit 5c3484
if test -n "$fat_path"; then
Packit 5c3484
  # Usually the mpn build directory is created with mpn/Makefile
Packit 5c3484
  # instantiation, but we want to write to it sooner.
Packit 5c3484
  mkdir mpn 2>/dev/null
Packit 5c3484
Packit 5c3484
  echo "/* fat.h - setups for fat binaries." >fat.h
Packit 5c3484
  echo "   Generated by configure - DO NOT EDIT.  */" >>fat.h
Packit 5c3484
Packit 5c3484
  AC_DEFINE(WANT_FAT_BINARY, 1, [Define to 1 when building a fat binary.])
Packit 5c3484
  GMP_DEFINE(WANT_FAT_BINARY, yes)
Packit 5c3484
Packit 5c3484
  # Don't want normal copies of fat functions
Packit 5c3484
  for tmp_fn in $fat_functions; do
Packit 5c3484
    GMP_REMOVE_FROM_LIST(gmp_mpn_functions, $tmp_fn)
Packit 5c3484
    GMP_REMOVE_FROM_LIST(gmp_mpn_functions_optional, $tmp_fn)
Packit 5c3484
  done
Packit 5c3484
Packit 5c3484
  for tmp_fn in $fat_functions; do
Packit 5c3484
    GMP_FILE_TO_FUNCTION(tmp_fbase,tmp_fn)
Packit 5c3484
    echo "
Packit 5c3484
#ifndef OPERATION_$tmp_fn
Packit 5c3484
#undef  mpn_$tmp_fbase
Packit 5c3484
#define mpn_$tmp_fbase  (*__gmpn_cpuvec.$tmp_fbase)
Packit 5c3484
#endif
Packit 5c3484
DECL_$tmp_fbase (__MPN(${tmp_fbase}_init));" >>fat.h
Packit 5c3484
    # encourage various macros to use fat functions
Packit 5c3484
    AC_DEFINE_UNQUOTED(HAVE_NATIVE_mpn_$tmp_fbase)
Packit 5c3484
  done
Packit 5c3484
Packit 5c3484
  echo "" >>fat.h
Packit 5c3484
  echo "/* variable thresholds */" >>fat.h
Packit 5c3484
  for tmp_tn in $fat_thresholds; do
Packit 5c3484
    echo "#undef  $tmp_tn" >>fat.h
Packit 5c3484
    echo "#define $tmp_tn  CPUVEC_THRESHOLD (`echo $tmp_tn | tr [A-Z] [a-z]`)" >>fat.h
Packit 5c3484
  done
Packit 5c3484
Packit 5c3484
  echo "
Packit 5c3484
/* Copy all fields into __gmpn_cpuvec.
Packit 5c3484
   memcpy is not used because it might operate byte-wise (depending on its
Packit 5c3484
   implementation), and we need the function pointer writes to be atomic.
Packit 5c3484
   "volatile" discourages the compiler from trying to optimize this.  */
Packit 5c3484
#define CPUVEC_INSTALL(vec) \\
Packit 5c3484
  do { \\
Packit 5c3484
    volatile struct cpuvec_t *p = &__gmpn_cpuvec; \\" >>fat.h
Packit 5c3484
  for tmp_fn in $fat_functions; do
Packit 5c3484
    GMP_FILE_TO_FUNCTION(tmp_fbase,tmp_fn)
Packit 5c3484
    echo "    p->$tmp_fbase = vec.$tmp_fbase; \\" >>fat.h
Packit 5c3484
  done
Packit 5c3484
  for tmp_tn in $fat_thresholds; do
Packit 5c3484
    tmp_field_name=`echo $tmp_tn | tr [[A-Z]] [[a-z]]`
Packit 5c3484
    echo "    p->$tmp_field_name = vec.$tmp_field_name; \\" >>fat.h
Packit 5c3484
  done
Packit 5c3484
  echo "  } while (0)" >>fat.h
Packit 5c3484
Packit 5c3484
  echo "
Packit 5c3484
/* A helper to check all fields are filled. */
Packit 5c3484
#define ASSERT_CPUVEC(vec) \\
Packit 5c3484
  do { \\" >>fat.h
Packit 5c3484
  for tmp_fn in $fat_functions; do
Packit 5c3484
    GMP_FILE_TO_FUNCTION(tmp_fbase,tmp_fn)
Packit 5c3484
    echo "    ASSERT (vec.$tmp_fbase != NULL); \\" >>fat.h
Packit 5c3484
  done
Packit 5c3484
  for tmp_tn in $fat_thresholds; do
Packit 5c3484
    tmp_field_name=`echo $tmp_tn | tr [[A-Z]] [[a-z]]`
Packit 5c3484
    echo "    ASSERT (vec.$tmp_field_name != 0); \\" >>fat.h
Packit 5c3484
  done
Packit 5c3484
  echo "  } while (0)" >>fat.h
Packit 5c3484
Packit 5c3484
  echo "
Packit 5c3484
/* Call ITERATE(field) for each fat threshold field. */
Packit 5c3484
#define ITERATE_FAT_THRESHOLDS() \\
Packit 5c3484
  do { \\" >>fat.h
Packit 5c3484
  for tmp_tn in $fat_thresholds; do
Packit 5c3484
    tmp_field_name=`echo $tmp_tn | tr [[A-Z]] [[a-z]]`
Packit 5c3484
    echo "    ITERATE ($tmp_tn, $tmp_field_name); \\" >>fat.h
Packit 5c3484
  done
Packit 5c3484
  echo "  } while (0)" >>fat.h
Packit 5c3484
Packit 5c3484
  for tmp_dir in $fat_path; do
Packit 5c3484
    CPUVEC_SETUP=
Packit 5c3484
    THRESH_ASM_SETUP=
Packit 5c3484
    echo "" >>fat.h
Packit 5c3484
    GMP_FAT_SUFFIX(tmp_suffix, $tmp_dir)
Packit 5c3484
Packit 5c3484
    # In order to keep names unique on a DOS 8.3 filesystem, use a prefix
Packit 5c3484
    # (rather than a suffix) for the generated file names, and abbreviate.
Packit 5c3484
    case $tmp_suffix in
Packit 5c3484
      pentium)       tmp_prefix=p   ;;
Packit 5c3484
      pentium_mmx)   tmp_prefix=pm  ;;
Packit 5c3484
      p6_mmx)        tmp_prefix=p2  ;;
Packit 5c3484
      p6_p3mmx)      tmp_prefix=p3  ;;
Packit 5c3484
      pentium4)      tmp_prefix=p4  ;;
Packit 5c3484
      pentium4_mmx)  tmp_prefix=p4m ;;
Packit 5c3484
      pentium4_sse2) tmp_prefix=p4s ;;
Packit 5c3484
      k6_mmx)        tmp_prefix=k6m ;;
Packit 5c3484
      k6_k62mmx)     tmp_prefix=k62 ;;
Packit 5c3484
      k7_mmx)        tmp_prefix=k7m ;;
Packit 5c3484
      *)             tmp_prefix=$tmp_suffix ;;
Packit 5c3484
    esac
Packit 5c3484
Packit 5c3484
    # Extract desired thresholds from gmp-mparam.h file in this directory,
Packit 5c3484
    # if present.
Packit 5c3484
    tmp_mparam=$srcdir/mpn/$tmp_dir/gmp-mparam.h
Packit 5c3484
    if test -f $tmp_mparam; then
Packit 5c3484
      for tmp_tn in $fat_thresholds; do
Packit 5c3484
        tmp_thresh=`sed -n "s/^#define $tmp_tn[ 	]*\\([0-9][0-9]*\\).*$/\\1/p" $tmp_mparam`
Packit 5c3484
        if test -n "$tmp_thresh"; then
Packit 5c3484
          THRESH_ASM_SETUP=["${THRESH_ASM_SETUP}define($tmp_tn,$tmp_thresh)
Packit 5c3484
"]
Packit 5c3484
          CPUVEC_SETUP="$CPUVEC_SETUP    decided_cpuvec.`echo $tmp_tn | tr [[A-Z]] [[a-z]]` = $tmp_thresh; \\
Packit 5c3484
"
Packit 5c3484
          eval tmp_limit=\$${tmp_tn}_LIMIT
Packit 5c3484
          if test -z "$tmp_limit"; then
Packit 5c3484
            tmp_limit=0
Packit 5c3484
          fi
Packit 5c3484
          if test $tmp_thresh -gt $tmp_limit; then
Packit 5c3484
            eval ${tmp_tn}_LIMIT=$tmp_thresh
Packit 5c3484
          fi
Packit 5c3484
        fi
Packit 5c3484
      done
Packit 5c3484
    fi
Packit 5c3484
Packit 5c3484
    for tmp_fn in $fat_functions; do
Packit 5c3484
      GMP_MULFUNC_CHOICES
Packit 5c3484
Packit 5c3484
      for tmp_base in $tmp_fn $tmp_mulfunc; do
Packit 5c3484
        for tmp_ext in MPN_SUFFIXES; do
Packit 5c3484
          tmp_file=$srcdir/mpn/$tmp_dir/$tmp_base.$tmp_ext
Packit 5c3484
          if test -f $tmp_file; then
Packit 5c3484
Packit 5c3484
	    # If the host uses a non-standard ABI, check if tmp_file supports it
Packit 5c3484
	    #
Packit 5c3484
	    if test -n "$GMP_NONSTD_ABI" && test $tmp_ext != "c"; then
Packit 5c3484
	      abi=[`sed -n 's/^[ 	]*ABI_SUPPORT(\(.*\))/\1/p' $tmp_file `]
Packit 5c3484
	      if echo "$abi" | grep -q "\\b${GMP_NONSTD_ABI}\\b"; then
Packit 5c3484
		true
Packit 5c3484
	      else
Packit 5c3484
		continue
Packit 5c3484
	      fi
Packit 5c3484
	    fi
Packit 5c3484
Packit 5c3484
            mpn_objects="$mpn_objects ${tmp_prefix}_$tmp_fn.lo"
Packit 5c3484
            mpn_objs_in_libgmp="$mpn_objs_in_libgmp mpn/${tmp_prefix}_$tmp_fn.lo"
Packit 5c3484
Packit 5c3484
            GMP_FILE_TO_FUNCTION(tmp_fbase,tmp_fn)
Packit 5c3484
Packit 5c3484
            # carry-in variant, eg. divrem_1c or modexact_1c_odd
Packit 5c3484
            case $tmp_fbase in
Packit 5c3484
              *_1*) tmp_fbasec=`echo $tmp_fbase | sed 's/_1/_1c/'` ;;
Packit 5c3484
              *)    tmp_fbasec=${tmp_fbase}c ;;
Packit 5c3484
            esac
Packit 5c3484
Packit 5c3484
            # Create a little file doing an include from srcdir.  The
Packit 5c3484
            # OPERATION and renamings aren't all needed all the time, but
Packit 5c3484
            # they don't hurt if unused.
Packit 5c3484
            #
Packit 5c3484
            # FIXME: Should generate these via config.status commands.
Packit 5c3484
            # Would need them all in one AC_CONFIG_COMMANDS though, since
Packit 5c3484
            # that macro doesn't accept a set of separate commands generated
Packit 5c3484
            # by shell code.
Packit 5c3484
            #
Packit 5c3484
            case $tmp_ext in
Packit 5c3484
              asm)
Packit 5c3484
                # hide the d-n-l from autoconf's error checking
Packit 5c3484
                tmp_d_n_l=d""nl
Packit 5c3484
                echo ["$tmp_d_n_l  mpn_$tmp_fbase - from $tmp_dir directory for fat binary.
Packit 5c3484
$tmp_d_n_l  Generated by configure - DO NOT EDIT.
Packit 5c3484
Packit 5c3484
define(OPERATION_$tmp_fn)
Packit 5c3484
define(__gmpn_$tmp_fbase, __gmpn_${tmp_fbase}_$tmp_suffix)
Packit 5c3484
define(__gmpn_$tmp_fbasec,__gmpn_${tmp_fbasec}_${tmp_suffix})
Packit 5c3484
define(__gmpn_preinv_${tmp_fbase},__gmpn_preinv_${tmp_fbase}_${tmp_suffix})
Packit 5c3484
define(__gmpn_${tmp_fbase}_cps,__gmpn_${tmp_fbase}_cps_${tmp_suffix})
Packit 5c3484
Packit 5c3484
$tmp_d_n_l  For k6 and k7 gcd_1 calling their corresponding mpn_modexact_1_odd
Packit 5c3484
ifdef(\`__gmpn_modexact_1_odd',,
Packit 5c3484
\`define(__gmpn_modexact_1_odd,__gmpn_modexact_1_odd_${tmp_suffix})')
Packit 5c3484
Packit 5c3484
$THRESH_ASM_SETUP
Packit 5c3484
include][($mpn_relative_top_srcdir/mpn/$tmp_dir/$tmp_base.asm)
Packit 5c3484
"] >mpn/${tmp_prefix}_$tmp_fn.asm
Packit 5c3484
                ;;
Packit 5c3484
              c)
Packit 5c3484
                echo ["/* mpn_$tmp_fbase - from $tmp_dir directory for fat binary.
Packit 5c3484
   Generated by configure - DO NOT EDIT. */
Packit 5c3484
Packit 5c3484
#define OPERATION_$tmp_fn 1
Packit 5c3484
#define __gmpn_$tmp_fbase           __gmpn_${tmp_fbase}_$tmp_suffix
Packit 5c3484
#define __gmpn_$tmp_fbasec          __gmpn_${tmp_fbasec}_${tmp_suffix}
Packit 5c3484
#define __gmpn_preinv_${tmp_fbase}  __gmpn_preinv_${tmp_fbase}_${tmp_suffix}
Packit 5c3484
#define __gmpn_${tmp_fbase}_cps     __gmpn_${tmp_fbase}_cps_${tmp_suffix}
Packit 5c3484
Packit 5c3484
#include \"$mpn_relative_top_srcdir/mpn/$tmp_dir/$tmp_base.c\"
Packit 5c3484
"] >mpn/${tmp_prefix}_$tmp_fn.c
Packit 5c3484
                ;;
Packit 5c3484
            esac
Packit 5c3484
Packit 5c3484
            # Prototype, and append to CPUVEC_SETUP for this directory.
Packit 5c3484
            echo "DECL_$tmp_fbase (__gmpn_${tmp_fbase}_$tmp_suffix);" >>fat.h
Packit 5c3484
            CPUVEC_SETUP="$CPUVEC_SETUP    decided_cpuvec.$tmp_fbase = __gmpn_${tmp_fbase}_${tmp_suffix}; \\
Packit 5c3484
"
Packit 5c3484
            # Ditto for any preinv variant (preinv_divrem_1, preinv_mod_1).
Packit 5c3484
            if grep "^PROLOGUE(mpn_preinv_$tmp_fn)" $tmp_file >/dev/null; then
Packit 5c3484
              echo "DECL_preinv_$tmp_fbase (__gmpn_preinv_${tmp_fbase}_$tmp_suffix);" >>fat.h
Packit 5c3484
              CPUVEC_SETUP="$CPUVEC_SETUP    decided_cpuvec.preinv_$tmp_fbase = __gmpn_preinv_${tmp_fbase}_${tmp_suffix}; \\
Packit 5c3484
"
Packit 5c3484
            fi
Packit 5c3484
Packit 5c3484
            # Ditto for any mod_1...cps variant
Packit 5c3484
            if grep "^PROLOGUE(mpn_${tmp_fbase}_cps)" $tmp_file >/dev/null; then
Packit 5c3484
              echo "DECL_${tmp_fbase}_cps (__gmpn_${tmp_fbase}_cps_$tmp_suffix);" >>fat.h
Packit 5c3484
              CPUVEC_SETUP="$CPUVEC_SETUP    decided_cpuvec.${tmp_fbase}_cps = __gmpn_${tmp_fbase}_cps_${tmp_suffix}; \\
Packit 5c3484
"
Packit 5c3484
            fi
Packit 5c3484
          fi
Packit 5c3484
        done
Packit 5c3484
      done
Packit 5c3484
    done
Packit 5c3484
Packit 5c3484
    # Emit CPUVEC_SETUP for this directory
Packit 5c3484
    echo "" >>fat.h
Packit 5c3484
    echo "#define CPUVEC_SETUP_$tmp_suffix \\" >>fat.h
Packit 5c3484
    echo "  do { \\" >>fat.h
Packit 5c3484
    echo "$CPUVEC_SETUP  } while (0)" >>fat.h
Packit 5c3484
  done
Packit 5c3484
Packit 5c3484
  # Emit threshold limits
Packit 5c3484
  echo "" >>fat.h
Packit 5c3484
  for tmp_tn in $fat_thresholds; do
Packit 5c3484
    eval tmp_limit=\$${tmp_tn}_LIMIT
Packit 5c3484
    echo "#define ${tmp_tn}_LIMIT  $tmp_limit" >>fat.h
Packit 5c3484
  done
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Normal binary setups.
Packit 5c3484
#
Packit 5c3484
Packit 5c3484
for tmp_ext in MPN_SUFFIXES; do
Packit 5c3484
  eval found_$tmp_ext=no
Packit 5c3484
done
Packit 5c3484
Packit 5c3484
for tmp_fn in $gmp_mpn_functions; do
Packit 5c3484
  for tmp_ext in MPN_SUFFIXES; do
Packit 5c3484
    test "$no_create" = yes || rm -f mpn/$tmp_fn.$tmp_ext
Packit 5c3484
  done
Packit 5c3484
Packit 5c3484
  # mpn_preinv_divrem_1 might have been provided by divrem_1.asm, likewise
Packit 5c3484
  # mpn_preinv_mod_1 by mod_1.asm.
Packit 5c3484
  case $tmp_fn in
Packit 5c3484
  pre_divrem_1)
Packit 5c3484
    if test "$HAVE_NATIVE_mpn_preinv_divrem_1" = yes; then continue; fi ;;
Packit 5c3484
  pre_mod_1)
Packit 5c3484
    if test "$HAVE_NATIVE_mpn_preinv_mod_1" = yes; then continue; fi ;;
Packit 5c3484
  esac
Packit 5c3484
Packit 5c3484
  GMP_MULFUNC_CHOICES
Packit 5c3484
Packit 5c3484
  found=no
Packit 5c3484
  for tmp_dir in $path; do
Packit 5c3484
    for tmp_base in $tmp_fn $tmp_mulfunc; do
Packit 5c3484
      for tmp_ext in MPN_SUFFIXES; do
Packit 5c3484
        tmp_file=$srcdir/mpn/$tmp_dir/$tmp_base.$tmp_ext
Packit 5c3484
        if test -f $tmp_file; then
Packit 5c3484
Packit 5c3484
          # For a nails build, check if the file supports our nail bits.
Packit 5c3484
          # Generic code always supports all nails.
Packit 5c3484
          #
Packit 5c3484
          # FIXME: When a multi-function file is selected to provide one of
Packit 5c3484
          # the nails-neutral routines, like logops_n for and_n, the
Packit 5c3484
          # PROLOGUE grepping will create HAVE_NATIVE_mpn_<foo> defines for
Packit 5c3484
          # all functions in that file, even if they haven't all been
Packit 5c3484
          # nailified.  Not sure what to do about this, it's only really a
Packit 5c3484
          # problem for logops_n, and it's not too terrible to insist those
Packit 5c3484
          # get nailified always.
Packit 5c3484
          #
Packit 5c3484
          if test $GMP_NAIL_BITS != 0 && test $tmp_dir != generic; then
Packit 5c3484
            case $tmp_fn in
Packit 5c3484
              and_n | ior_n | xor_n | andn_n | \
Packit 5c3484
              copyi | copyd | \
Packit 5c3484
              popcount | hamdist | \
Packit 5c3484
              udiv | udiv_w_sdiv | umul | \
Packit 5c3484
              cntlz | invert_limb)
Packit 5c3484
                # these operations are either unaffected by nails or defined
Packit 5c3484
                # to operate on full limbs
Packit 5c3484
                ;;
Packit 5c3484
              *)
Packit 5c3484
                nails=[`sed -n 's/^[ 	]*NAILS_SUPPORT(\(.*\))/\1/p' $tmp_file `]
Packit 5c3484
                for n in $nails; do
Packit 5c3484
                  case $n in
Packit 5c3484
                  *-*)
Packit 5c3484
                    n_start=`echo "$n" | sed -n 's/\(.*\)-.*/\1/p'`
Packit 5c3484
                    n_end=`echo "$n" | sed -n 's/.*-\(.*\)/\1/p'`
Packit 5c3484
                    ;;
Packit 5c3484
                  *)
Packit 5c3484
                    n_start=$n
Packit 5c3484
                    n_end=$n
Packit 5c3484
                    ;;
Packit 5c3484
                  esac
Packit 5c3484
                  if test $GMP_NAIL_BITS -ge $n_start && test $GMP_NAIL_BITS -le $n_end; then
Packit 5c3484
                    found=yes
Packit 5c3484
                    break
Packit 5c3484
                  fi
Packit 5c3484
                done
Packit 5c3484
                if test $found != yes; then
Packit 5c3484
                  continue
Packit 5c3484
                fi
Packit 5c3484
                ;;
Packit 5c3484
            esac
Packit 5c3484
          fi
Packit 5c3484
Packit 5c3484
	  # If the host uses a non-standard ABI, check if tmp_file supports it
Packit 5c3484
	  #
Packit 5c3484
	  if test -n "$GMP_NONSTD_ABI" && test $tmp_ext != "c"; then
Packit 5c3484
	    abi=[`sed -n 's/^[ 	]*ABI_SUPPORT(\(.*\))/\1/p' $tmp_file `]
Packit 5c3484
	    if echo "$abi" | grep -q "\\b${GMP_NONSTD_ABI}\\b"; then
Packit 5c3484
	      true
Packit 5c3484
	    else
Packit 5c3484
	      continue
Packit 5c3484
	    fi
Packit 5c3484
	  fi
Packit 5c3484
Packit 5c3484
          found=yes
Packit 5c3484
          eval found_$tmp_ext=yes
Packit 5c3484
Packit 5c3484
          if test $tmp_ext = c; then
Packit 5c3484
            tmp_u='$U'
Packit 5c3484
          else
Packit 5c3484
            tmp_u=
Packit 5c3484
          fi
Packit 5c3484
Packit 5c3484
          mpn_objects="$mpn_objects $tmp_fn$tmp_u.lo"
Packit 5c3484
          mpn_objs_in_libgmp="$mpn_objs_in_libgmp mpn/$tmp_fn$tmp_u.lo"
Packit 5c3484
          AC_CONFIG_LINKS(mpn/$tmp_fn.$tmp_ext:mpn/$tmp_dir/$tmp_base.$tmp_ext)
Packit 5c3484
          gmp_srclinks="$gmp_srclinks mpn/$tmp_fn.$tmp_ext"
Packit 5c3484
Packit 5c3484
          # Duplicate AC_DEFINEs are harmless, so it doesn't matter
Packit 5c3484
          # that multi-function files get grepped here repeatedly.
Packit 5c3484
          # The PROLOGUE pattern excludes the optional second parameter.
Packit 5c3484
          gmp_ep=[`
Packit 5c3484
            sed -n 's/^[ 	]*MULFUNC_PROLOGUE(\(.*\))/\1/p' $tmp_file ;
Packit 5c3484
            sed -n 's/^[ 	]*PROLOGUE(\([^,]*\).*)/\1/p' $tmp_file
Packit 5c3484
          `]
Packit 5c3484
          for gmp_tmp in $gmp_ep; do
Packit 5c3484
            AC_DEFINE_UNQUOTED(HAVE_NATIVE_$gmp_tmp)
Packit 5c3484
            eval HAVE_NATIVE_$gmp_tmp=yes
Packit 5c3484
          done
Packit 5c3484
Packit 5c3484
          case $tmp_fn in
Packit 5c3484
          sqr_basecase) sqr_basecase_source=$tmp_file ;;
Packit 5c3484
          esac
Packit 5c3484
Packit 5c3484
          break
Packit 5c3484
        fi
Packit 5c3484
      done
Packit 5c3484
      if test $found = yes; then break ; fi
Packit 5c3484
    done
Packit 5c3484
    if test $found = yes; then break ; fi
Packit 5c3484
  done
Packit 5c3484
Packit 5c3484
  if test $found = no; then
Packit 5c3484
    for tmp_optional in $gmp_mpn_functions_optional; do
Packit 5c3484
      if test $tmp_optional = $tmp_fn; then
Packit 5c3484
        found=yes
Packit 5c3484
      fi
Packit 5c3484
    done
Packit 5c3484
    if test $found = no; then
Packit 5c3484
      AC_MSG_ERROR([no version of $tmp_fn found in path: $path])
Packit 5c3484
    fi
Packit 5c3484
  fi
Packit 5c3484
done
Packit 5c3484
Packit 5c3484
# All cycle counters are .asm files currently
Packit 5c3484
if test -n "$SPEED_CYCLECOUNTER_OBJ"; then
Packit 5c3484
  found_asm=yes
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
dnl  The following list only needs to have templates for those defines which
Packit 5c3484
dnl  are going to be tested by the code, there's no need to have every
Packit 5c3484
dnl  possible mpn routine.
Packit 5c3484
Packit 5c3484
AH_VERBATIM([HAVE_NATIVE],
Packit 5c3484
[/* Define to 1 each of the following for which a native (ie. CPU specific)
Packit 5c3484
    implementation of the corresponding routine exists.  */
Packit 5c3484
#undef HAVE_NATIVE_mpn_add_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_add_n_sub_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_add_nc
Packit 5c3484
#undef HAVE_NATIVE_mpn_addaddmul_1msb0
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh1_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh2_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh1_nc
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh2_nc
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh_nc
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh1_n_ip1
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh2_n_ip1
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh_n_ip1
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh1_nc_ip1
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh2_nc_ip1
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh_nc_ip1
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh1_n_ip2
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh2_n_ip2
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh_n_ip2
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh1_nc_ip2
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh2_nc_ip2
Packit 5c3484
#undef HAVE_NATIVE_mpn_addlsh_nc_ip2
Packit 5c3484
#undef HAVE_NATIVE_mpn_addmul_1c
Packit 5c3484
#undef HAVE_NATIVE_mpn_addmul_2
Packit 5c3484
#undef HAVE_NATIVE_mpn_addmul_3
Packit 5c3484
#undef HAVE_NATIVE_mpn_addmul_4
Packit 5c3484
#undef HAVE_NATIVE_mpn_addmul_5
Packit 5c3484
#undef HAVE_NATIVE_mpn_addmul_6
Packit 5c3484
#undef HAVE_NATIVE_mpn_addmul_7
Packit 5c3484
#undef HAVE_NATIVE_mpn_addmul_8
Packit 5c3484
#undef HAVE_NATIVE_mpn_addmul_2s
Packit 5c3484
#undef HAVE_NATIVE_mpn_and_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_andn_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_bdiv_dbm1c
Packit 5c3484
#undef HAVE_NATIVE_mpn_bdiv_q_1
Packit 5c3484
#undef HAVE_NATIVE_mpn_pi1_bdiv_q_1
Packit 5c3484
#undef HAVE_NATIVE_mpn_cnd_add_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_cnd_sub_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_com
Packit 5c3484
#undef HAVE_NATIVE_mpn_copyd
Packit 5c3484
#undef HAVE_NATIVE_mpn_copyi
Packit 5c3484
#undef HAVE_NATIVE_mpn_div_qr_1n_pi1
Packit 5c3484
#undef HAVE_NATIVE_mpn_div_qr_2
Packit 5c3484
#undef HAVE_NATIVE_mpn_divexact_1
Packit 5c3484
#undef HAVE_NATIVE_mpn_divexact_by3c
Packit 5c3484
#undef HAVE_NATIVE_mpn_divrem_1
Packit 5c3484
#undef HAVE_NATIVE_mpn_divrem_1c
Packit 5c3484
#undef HAVE_NATIVE_mpn_divrem_2
Packit 5c3484
#undef HAVE_NATIVE_mpn_gcd_1
Packit 5c3484
#undef HAVE_NATIVE_mpn_hamdist
Packit 5c3484
#undef HAVE_NATIVE_mpn_invert_limb
Packit 5c3484
#undef HAVE_NATIVE_mpn_ior_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_iorn_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_lshift
Packit 5c3484
#undef HAVE_NATIVE_mpn_lshiftc
Packit 5c3484
#undef HAVE_NATIVE_mpn_lshsub_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_mod_1
Packit 5c3484
#undef HAVE_NATIVE_mpn_mod_1_1p
Packit 5c3484
#undef HAVE_NATIVE_mpn_mod_1c
Packit 5c3484
#undef HAVE_NATIVE_mpn_mod_1s_2p
Packit 5c3484
#undef HAVE_NATIVE_mpn_mod_1s_4p
Packit 5c3484
#undef HAVE_NATIVE_mpn_mod_34lsub1
Packit 5c3484
#undef HAVE_NATIVE_mpn_modexact_1_odd
Packit 5c3484
#undef HAVE_NATIVE_mpn_modexact_1c_odd
Packit 5c3484
#undef HAVE_NATIVE_mpn_mul_1
Packit 5c3484
#undef HAVE_NATIVE_mpn_mul_1c
Packit 5c3484
#undef HAVE_NATIVE_mpn_mul_2
Packit 5c3484
#undef HAVE_NATIVE_mpn_mul_3
Packit 5c3484
#undef HAVE_NATIVE_mpn_mul_4
Packit 5c3484
#undef HAVE_NATIVE_mpn_mul_5
Packit 5c3484
#undef HAVE_NATIVE_mpn_mul_6
Packit 5c3484
#undef HAVE_NATIVE_mpn_mul_basecase
Packit 5c3484
#undef HAVE_NATIVE_mpn_mullo_basecase
Packit 5c3484
#undef HAVE_NATIVE_mpn_nand_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_nior_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_popcount
Packit 5c3484
#undef HAVE_NATIVE_mpn_preinv_divrem_1
Packit 5c3484
#undef HAVE_NATIVE_mpn_preinv_mod_1
Packit 5c3484
#undef HAVE_NATIVE_mpn_redc_1
Packit 5c3484
#undef HAVE_NATIVE_mpn_redc_2
Packit 5c3484
#undef HAVE_NATIVE_mpn_rsblsh1_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_rsblsh2_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_rsblsh_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_rsblsh1_nc
Packit 5c3484
#undef HAVE_NATIVE_mpn_rsblsh2_nc
Packit 5c3484
#undef HAVE_NATIVE_mpn_rsblsh_nc
Packit 5c3484
#undef HAVE_NATIVE_mpn_rsh1add_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_rsh1add_nc
Packit 5c3484
#undef HAVE_NATIVE_mpn_rsh1sub_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_rsh1sub_nc
Packit 5c3484
#undef HAVE_NATIVE_mpn_rshift
Packit 5c3484
#undef HAVE_NATIVE_mpn_sqr_basecase
Packit 5c3484
#undef HAVE_NATIVE_mpn_sqr_diagonal
Packit 5c3484
#undef HAVE_NATIVE_mpn_sqr_diag_addlsh1
Packit 5c3484
#undef HAVE_NATIVE_mpn_sub_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_sub_nc
Packit 5c3484
#undef HAVE_NATIVE_mpn_sublsh1_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_sublsh2_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_sublsh_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_sublsh1_nc
Packit 5c3484
#undef HAVE_NATIVE_mpn_sublsh2_nc
Packit 5c3484
#undef HAVE_NATIVE_mpn_sublsh_nc
Packit 5c3484
#undef HAVE_NATIVE_mpn_sublsh1_n_ip1
Packit 5c3484
#undef HAVE_NATIVE_mpn_sublsh2_n_ip1
Packit 5c3484
#undef HAVE_NATIVE_mpn_sublsh_n_ip1
Packit 5c3484
#undef HAVE_NATIVE_mpn_sublsh1_nc_ip1
Packit 5c3484
#undef HAVE_NATIVE_mpn_sublsh2_nc_ip1
Packit 5c3484
#undef HAVE_NATIVE_mpn_sublsh_nc_ip1
Packit 5c3484
#undef HAVE_NATIVE_mpn_submul_1c
Packit 5c3484
#undef HAVE_NATIVE_mpn_tabselect
Packit 5c3484
#undef HAVE_NATIVE_mpn_udiv_qrnnd
Packit 5c3484
#undef HAVE_NATIVE_mpn_udiv_qrnnd_r
Packit 5c3484
#undef HAVE_NATIVE_mpn_umul_ppmm
Packit 5c3484
#undef HAVE_NATIVE_mpn_umul_ppmm_r
Packit 5c3484
#undef HAVE_NATIVE_mpn_xor_n
Packit 5c3484
#undef HAVE_NATIVE_mpn_xnor_n])
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Don't demand an m4 unless it's actually needed.
Packit 5c3484
if test $found_asm = yes; then
Packit 5c3484
  GMP_PROG_M4
Packit 5c3484
  GMP_M4_M4WRAP_SPURIOUS
Packit 5c3484
# else
Packit 5c3484
# It's unclear why this m4-not-needed stuff was ever done.
Packit 5c3484
#  if test -z "$M4" ; then
Packit 5c3484
#    M4=m4-not-needed
Packit 5c3484
#  fi
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
# Only do the GMP_ASM checks if there's a .S or .asm wanting them.
Packit 5c3484
if test $found_asm = no && test $found_S = no; then
Packit 5c3484
  gmp_asm_syntax_testing=no
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
if test "$gmp_asm_syntax_testing" != no; then
Packit 5c3484
  GMP_ASM_TEXT
Packit 5c3484
  GMP_ASM_DATA
Packit 5c3484
  GMP_ASM_LABEL_SUFFIX
Packit 5c3484
  GMP_ASM_GLOBL
Packit 5c3484
  GMP_ASM_GLOBL_ATTR
Packit 5c3484
  GMP_ASM_UNDERSCORE
Packit 5c3484
  GMP_ASM_RODATA
Packit 5c3484
  GMP_ASM_TYPE
Packit 5c3484
  GMP_ASM_SIZE
Packit 5c3484
  GMP_ASM_LSYM_PREFIX
Packit 5c3484
  GMP_ASM_W32
Packit 5c3484
  GMP_ASM_ALIGN_LOG
Packit 5c3484
Packit 5c3484
  case $host in
Packit 5c3484
    arm*-*-* | aarch64*-*-*)
Packit 5c3484
      case $ABI in
Packit 5c3484
        32)
Packit 5c3484
	  GMP_INCLUDE_MPN(arm/arm-defs.m4) ;;
Packit 5c3484
      esac
Packit 5c3484
      ;;
Packit 5c3484
    hppa*-*-*)
Packit 5c3484
      # for both pa32 and pa64
Packit 5c3484
      GMP_INCLUDE_MPN(pa32/pa-defs.m4)
Packit 5c3484
      ;;
Packit 5c3484
    IA64_PATTERN)
Packit 5c3484
      GMP_ASM_IA64_ALIGN_OK
Packit 5c3484
      ;;
Packit 5c3484
    M68K_PATTERN)
Packit 5c3484
      GMP_ASM_M68K_INSTRUCTION
Packit 5c3484
      GMP_ASM_M68K_ADDRESSING
Packit 5c3484
      GMP_ASM_M68K_BRANCHES
Packit 5c3484
      ;;
Packit 5c3484
    [powerpc*-*-* | power[3-9]-*-*])
Packit 5c3484
      GMP_ASM_POWERPC_PIC_ALWAYS
Packit 5c3484
      GMP_ASM_POWERPC_R_REGISTERS
Packit 5c3484
      GMP_INCLUDE_MPN(powerpc32/powerpc-defs.m4)
Packit 5c3484
Packit 5c3484
      # Check for Linux ELFv2 ABI
Packit 5c3484
      AC_EGREP_CPP(yes,
Packit 5c3484
[#if _CALL_ELF == 2
Packit 5c3484
yes
Packit 5c3484
#endif],
Packit 5c3484
      [GMP_DEFINE_RAW(["define(<ELFv2_ABI>)"])])
Packit 5c3484
Packit 5c3484
      case $host in
Packit 5c3484
        *-*-aix*)
Packit 5c3484
	  case $ABI in
Packit 5c3484
	    mode64)      GMP_INCLUDE_MPN(powerpc64/aix.m4) ;;
Packit 5c3484
            *)           GMP_INCLUDE_MPN(powerpc32/aix.m4) ;;
Packit 5c3484
          esac
Packit 5c3484
          ;;
Packit 5c3484
        *-*-linux* | *-*-*bsd*)
Packit 5c3484
	  case $ABI in
Packit 5c3484
	    mode64)      GMP_INCLUDE_MPN(powerpc64/elf.m4) ;;
Packit 5c3484
	    mode32 | 32) GMP_INCLUDE_MPN(powerpc32/elf.m4) ;;
Packit 5c3484
          esac
Packit 5c3484
          ;;
Packit 5c3484
        *-*-darwin*)
Packit 5c3484
	  case $ABI in
Packit 5c3484
	    mode64)      GMP_INCLUDE_MPN(powerpc64/darwin.m4) ;;
Packit 5c3484
	    mode32 | 32) GMP_INCLUDE_MPN(powerpc32/darwin.m4) ;;
Packit 5c3484
          esac
Packit 5c3484
          ;;
Packit 5c3484
        *)
Packit 5c3484
	  # Assume unrecognized operating system is the powerpc eABI
Packit 5c3484
          GMP_INCLUDE_MPN(powerpc32/eabi.m4)
Packit 5c3484
	  ;;
Packit 5c3484
      esac
Packit 5c3484
      ;;
Packit 5c3484
    power*-*-aix*)
Packit 5c3484
      GMP_INCLUDE_MPN(powerpc32/aix.m4)
Packit 5c3484
      ;;
Packit 5c3484
    *sparc*-*-*)
Packit 5c3484
      case $ABI in
Packit 5c3484
        64)
Packit 5c3484
          GMP_ASM_SPARC_REGISTER
Packit 5c3484
          ;;
Packit 5c3484
      esac
Packit 5c3484
      GMP_ASM_SPARC_GOTDATA
Packit 5c3484
      GMP_ASM_SPARC_SHARED_THUNKS
Packit 5c3484
      ;;
Packit 5c3484
    X86_PATTERN | X86_64_PATTERN)
Packit 5c3484
      GMP_ASM_ALIGN_FILL_0x90
Packit 5c3484
      case $ABI in
Packit 5c3484
        32)
Packit 5c3484
          GMP_INCLUDE_MPN(x86/x86-defs.m4)
Packit 5c3484
          AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86)
Packit 5c3484
          GMP_ASM_COFF_TYPE
Packit 5c3484
          GMP_ASM_X86_GOT_UNDERSCORE
Packit 5c3484
          GMP_ASM_X86_SHLDL_CL
Packit 5c3484
	  case $enable_profiling in
Packit 5c3484
	    prof | gprof)  GMP_ASM_X86_MCOUNT ;;
Packit 5c3484
	  esac
Packit 5c3484
	  case $host in
Packit 5c3484
	    *-*-darwin*)
Packit 5c3484
	      GMP_INCLUDE_MPN(x86/darwin.m4) ;;
Packit 5c3484
	  esac
Packit 5c3484
          ;;
Packit 5c3484
        64|x32)
Packit 5c3484
          GMP_INCLUDE_MPN(x86_64/x86_64-defs.m4)
Packit 5c3484
          AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86_64)
Packit 5c3484
	  case $host in
Packit 5c3484
	    *-*-darwin*)
Packit 5c3484
	      GMP_INCLUDE_MPN(x86_64/darwin.m4) ;;
Packit 5c3484
	    *-*-mingw* | *-*-cygwin)
Packit 5c3484
	      GMP_INCLUDE_MPN(x86_64/dos64.m4) ;;
Packit 5c3484
	    *-openbsd*)
Packit 5c3484
	      GMP_DEFINE_RAW(["define(<OPENBSD>,1)"]) ;;
Packit 5c3484
	    *-linux*)
Packit 5c3484
	      GMP_DEFINE_RAW(["define(<LINUX>,1)"]) ;;
Packit 5c3484
	  esac
Packit 5c3484
          ;;
Packit 5c3484
      esac
Packit 5c3484
      ;;
Packit 5c3484
  esac
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
# For --enable-minithres, prepend "minithres" to path so that its special
Packit 5c3484
# gmp-mparam.h will be used.
Packit 5c3484
if test $enable_minithres = yes; then
Packit 5c3484
  path="minithres $path"
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
# Create link for gmp-mparam.h.
Packit 5c3484
gmp_mparam_source=
Packit 5c3484
for gmp_mparam_dir in $path; do
Packit 5c3484
  test "$no_create" = yes || rm -f gmp-mparam.h
Packit 5c3484
  tmp_file=$srcdir/mpn/$gmp_mparam_dir/gmp-mparam.h
Packit 5c3484
  if test -f $tmp_file; then
Packit 5c3484
    AC_CONFIG_LINKS(gmp-mparam.h:mpn/$gmp_mparam_dir/gmp-mparam.h)
Packit 5c3484
    gmp_srclinks="$gmp_srclinks gmp-mparam.h"
Packit 5c3484
    gmp_mparam_source=$tmp_file
Packit 5c3484
    break
Packit 5c3484
  fi
Packit 5c3484
done
Packit 5c3484
if test -z "$gmp_mparam_source"; then
Packit 5c3484
  AC_MSG_ERROR([no version of gmp-mparam.h found in path: $path])
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
# For a helpful message from tune/tuneup.c
Packit 5c3484
gmp_mparam_suggest=$gmp_mparam_source
Packit 5c3484
if test "$gmp_mparam_dir" = generic; then
Packit 5c3484
  for i in $path; do break; done
Packit 5c3484
  if test "$i" != generic; then
Packit 5c3484
    gmp_mparam_suggest="new file $srcdir/mpn/$i/gmp-mparam.h"
Packit 5c3484
  fi
Packit 5c3484
fi
Packit 5c3484
AC_DEFINE_UNQUOTED(GMP_MPARAM_H_SUGGEST, "$gmp_mparam_source",
Packit 5c3484
[The gmp-mparam.h file (a string) the tune program should suggest updating.])
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Copy relevant parameters from gmp-mparam.h to config.m4.
Packit 5c3484
# We only do this for parameters that are used by some assembly files.
Packit 5c3484
# Fat binaries do this on a per-file basis, so skip in that case.
Packit 5c3484
#
Packit 5c3484
if test -z "$fat_path"; then
Packit 5c3484
  for i in SQR_TOOM2_THRESHOLD BMOD_1_TO_MOD_1_THRESHOLD SHLD_SLOW SHRD_SLOW; do
Packit 5c3484
    value=`sed -n 's/^#define '$i'[ 	]*\([0-9][0-9]*\).*$/\1/p' $gmp_mparam_source`
Packit 5c3484
    if test -n "$value"; then
Packit 5c3484
      GMP_DEFINE_RAW(["define(<$i>,<$value>)"])
Packit 5c3484
    fi
Packit 5c3484
  done
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Sizes of some types, needed at preprocessing time.
Packit 5c3484
#
Packit 5c3484
# FIXME: The assumption that GMP_LIMB_BITS is 8*sizeof(mp_limb_t) might
Packit 5c3484
# be slightly rash, but it's true everywhere we know of and ought to be true
Packit 5c3484
# of any sensible system.  In a generic C build, grepping LONG_BIT out of
Packit 5c3484
# <limits.h> might be an alternative, for maximum portability.
Packit 5c3484
#
Packit 5c3484
AC_CHECK_SIZEOF(void *)
Packit 5c3484
AC_CHECK_SIZEOF(unsigned short)
Packit 5c3484
AC_CHECK_SIZEOF(unsigned)
Packit 5c3484
AC_CHECK_SIZEOF(unsigned long)
Packit 5c3484
AC_CHECK_SIZEOF(mp_limb_t, , GMP_INCLUDE_GMP_H)
Packit 5c3484
if test "$ac_cv_sizeof_mp_limb_t" = 0; then
Packit 5c3484
  AC_MSG_ERROR([Oops, mp_limb_t doesn't seem to work])
Packit 5c3484
fi
Packit 5c3484
AC_SUBST(GMP_LIMB_BITS, `expr 8 \* $ac_cv_sizeof_mp_limb_t`)
Packit 5c3484
GMP_DEFINE_RAW(["define(<SIZEOF_UNSIGNED>,<$ac_cv_sizeof_unsigned>)"])
Packit 5c3484
Packit 5c3484
# Check compiler limb size matches gmp-mparam.h
Packit 5c3484
#
Packit 5c3484
# FIXME: Some of the cycle counter objects in the tune directory depend on
Packit 5c3484
# the size of ulong, it'd be possible to check that here, though a mismatch
Packit 5c3484
# probably wouldn't want to be fatal, none of the libgmp assembler code
Packit 5c3484
# depends on ulong.
Packit 5c3484
#
Packit 5c3484
mparam_bits=[`sed -n 's/^#define GMP_LIMB_BITS[ 	][ 	]*\([0-9]*\).*$/\1/p' $gmp_mparam_source`]
Packit 5c3484
if test -n "$mparam_bits" && test "$mparam_bits" -ne $GMP_LIMB_BITS; then
Packit 5c3484
  if test "$test_CFLAGS" = set; then
Packit 5c3484
    AC_MSG_ERROR([Oops, mp_limb_t is $GMP_LIMB_BITS bits, but the assembler code
Packit 5c3484
in this configuration expects $mparam_bits bits.
Packit 5c3484
You appear to have set \$CFLAGS, perhaps you also need to tell GMP the
Packit 5c3484
intended ABI, see "ABI and ISA" in the manual.])
Packit 5c3484
  else
Packit 5c3484
    AC_MSG_ERROR([Oops, mp_limb_t is $GMP_LIMB_BITS bits, but the assembler code
Packit 5c3484
in this configuration expects $mparam_bits bits.])
Packit 5c3484
  fi
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
GMP_DEFINE_RAW(["define(<GMP_LIMB_BITS>,$GMP_LIMB_BITS)"])
Packit 5c3484
GMP_DEFINE_RAW(["define(<GMP_NAIL_BITS>,$GMP_NAIL_BITS)"])
Packit 5c3484
GMP_DEFINE_RAW(["define(<GMP_NUMB_BITS>,eval(GMP_LIMB_BITS-GMP_NAIL_BITS))"])
Packit 5c3484
Packit 5c3484
Packit 5c3484
AC_SUBST(mpn_objects)
Packit 5c3484
AC_SUBST(mpn_objs_in_libgmp)
Packit 5c3484
AC_SUBST(gmp_srclinks)
Packit 5c3484
Packit 5c3484
Packit 5c3484
# A recompiled sqr_basecase for use in the tune program, if necessary.
Packit 5c3484
TUNE_SQR_OBJ=
Packit 5c3484
test -d tune || mkdir tune
Packit 5c3484
case $sqr_basecase_source in
Packit 5c3484
  *.asm)
Packit 5c3484
    sqr_max=[`sed -n 's/^def...(SQR_TOOM2_THRESHOLD_MAX, *\([0-9]*\))/\1/p' $sqr_basecase_source`]
Packit 5c3484
    if test -n "$sqr_max"; then
Packit 5c3484
      TUNE_SQR_OBJ=sqr_asm.o
Packit 5c3484
      AC_DEFINE_UNQUOTED(TUNE_SQR_TOOM2_MAX,$sqr_max,
Packit 5c3484
      [Maximum size the tune program can test for SQR_TOOM2_THRESHOLD])
Packit 5c3484
    fi
Packit 5c3484
    cat >tune/sqr_basecase.c <
Packit 5c3484
/* not sure that an empty file can compile, so put in a dummy */
Packit 5c3484
int sqr_basecase_dummy;
Packit 5c3484
EOF
Packit 5c3484
    ;;
Packit 5c3484
  *.c)
Packit 5c3484
    TUNE_SQR_OBJ=
Packit 5c3484
    AC_DEFINE(TUNE_SQR_TOOM2_MAX,SQR_TOOM2_MAX_GENERIC)
Packit 5c3484
    cat >tune/sqr_basecase.c <
Packit 5c3484
#define TUNE_PROGRAM_BUILD 1
Packit 5c3484
#define TUNE_PROGRAM_BUILD_SQR 1
Packit 5c3484
#include "mpn/sqr_basecase.c"
Packit 5c3484
EOF
Packit 5c3484
    ;;
Packit 5c3484
esac
Packit 5c3484
AC_SUBST(TUNE_SQR_OBJ)
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Configs for demos/pexpr.c.
Packit 5c3484
#
Packit 5c3484
AC_CONFIG_FILES(demos/pexpr-config.h:demos/pexpr-config-h.in)
Packit 5c3484
GMP_SUBST_CHECK_FUNCS(clock, cputime, getrusage, gettimeofday, sigaction, sigaltstack, sigstack)
Packit 5c3484
GMP_SUBST_CHECK_HEADERS(sys/resource.h)
Packit 5c3484
AC_CHECK_TYPES([stack_t], HAVE_STACK_T_01=1, HAVE_STACK_T_01=0,
Packit 5c3484
               [#include <signal.h>])
Packit 5c3484
AC_SUBST(HAVE_STACK_T_01)
Packit 5c3484
Packit 5c3484
# Configs for demos/calc directory
Packit 5c3484
#
Packit 5c3484
# AC_SUBST+AC_CONFIG_FILES is used for calc-config.h, rather than AC_DEFINE+
Packit 5c3484
# AC_CONFIG_HEADERS, since with the latter automake (1.8) will then put the
Packit 5c3484
# directory (ie. demos/calc) into $(DEFAULT_INCLUDES) for every Makefile.in,
Packit 5c3484
# which would look very strange.
Packit 5c3484
#
Packit 5c3484
# -lcurses is required by libreadline.  On a typical SVR4 style system this
Packit 5c3484
# normally doesn't have to be given explicitly, since libreadline.so will
Packit 5c3484
# have a NEEDED record for it.  But if someone for some reason is using only
Packit 5c3484
# a static libreadline.a then we must give -lcurses.  Readline (as of
Packit 5c3484
# version 4.3) doesn't use libtool, so we can't rely on a .la to cover
Packit 5c3484
# necessary dependencies.
Packit 5c3484
#
Packit 5c3484
# On a couple of systems we've seen libreadline available, but the headers
Packit 5c3484
# not in the default include path, so check for readline/readline.h.  We've
Packit 5c3484
# also seen readline/history.h missing, not sure if that's just a broken
Packit 5c3484
# install or a very old version, but check that too.
Packit 5c3484
#
Packit 5c3484
AC_CONFIG_FILES(demos/calc/calc-config.h:demos/calc/calc-config-h.in)
Packit 5c3484
LIBCURSES=
Packit 5c3484
if test $with_readline != no; then
Packit 5c3484
  AC_CHECK_LIB(ncurses, tputs, [LIBCURSES=-lncurses],
Packit 5c3484
    [AC_CHECK_LIB(curses, tputs, [LIBCURSES=-lcurses])])
Packit 5c3484
fi
Packit 5c3484
AC_SUBST(LIBCURSES)
Packit 5c3484
use_readline=$with_readline
Packit 5c3484
if test $with_readline = detect; then
Packit 5c3484
  use_readline=no
Packit 5c3484
  AC_CHECK_LIB(readline, readline,
Packit 5c3484
    [AC_CHECK_HEADER(readline/readline.h,
Packit 5c3484
      [AC_CHECK_HEADER(readline/history.h, use_readline=yes)])],
Packit 5c3484
    , $LIBCURSES)
Packit 5c3484
  AC_MSG_CHECKING(readline detected)
Packit 5c3484
  AC_MSG_RESULT($use_readline)
Packit 5c3484
fi
Packit 5c3484
if test $use_readline = yes; then
Packit 5c3484
  AC_SUBST(WITH_READLINE_01, 1)
Packit 5c3484
  AC_SUBST(LIBREADLINE, -lreadline)
Packit 5c3484
else
Packit 5c3484
  WITH_READLINE_01=0
Packit 5c3484
fi
Packit 5c3484
AC_PROG_YACC
Packit 5c3484
AM_PROG_LEX
Packit 5c3484
Packit 5c3484
# Configs for demos/expr directory
Packit 5c3484
#
Packit 5c3484
# Libtool already runs an AC_CHECK_TOOL for ranlib, but we give
Packit 5c3484
# AC_PROG_RANLIB anyway since automake is supposed to complain if it's not
Packit 5c3484
# called.  (Automake 1.8.4 doesn't, at least not when the only library is in
Packit 5c3484
# an EXTRA_LIBRARIES.)
Packit 5c3484
#
Packit 5c3484
AC_PROG_RANLIB
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Create config.m4.
Packit 5c3484
GMP_FINISH
Packit 5c3484
Packit 5c3484
# Create Makefiles
Packit 5c3484
# FIXME: Upcoming version of autoconf/automake may not like broken lines.
Packit 5c3484
#        Right now automake isn't accepting the new AC_CONFIG_FILES scheme.
Packit 5c3484
Packit 5c3484
AC_OUTPUT(Makefile							\
Packit 5c3484
  mpf/Makefile mpn/Makefile mpq/Makefile				\
Packit 5c3484
  mpz/Makefile printf/Makefile scanf/Makefile rand/Makefile cxx/Makefile \
Packit 5c3484
  tests/Makefile tests/devel/Makefile					\
Packit 5c3484
  tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile		\
Packit 5c3484
  tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile		\
Packit 5c3484
  tests/cxx/Makefile							\
Packit 5c3484
  doc/Makefile tune/Makefile						\
Packit 5c3484
  demos/Makefile demos/calc/Makefile demos/expr/Makefile		\
Packit 5c3484
  gmp.h:gmp-h.in)
Packit 5c3484
Packit 5c3484
AC_MSG_NOTICE([summary of build options:
Packit 5c3484
Packit 5c3484
  Version:           ${PACKAGE_STRING}
Packit 5c3484
  Host type:         ${host}
Packit 5c3484
  ABI:               ${ABI}
Packit 5c3484
  Install prefix:    ${prefix}
Packit 5c3484
  Compiler:          ${CC}
Packit 5c3484
  Static libraries:  ${enable_static}
Packit 5c3484
  Shared libraries:  ${enable_shared}
Packit 5c3484
])
Packit 5c3484
Packit 5c3484
if test x$cross_compiling = xyes ; then
Packit 5c3484
   case "$host" in
Packit 5c3484
     *-*-mingw* | *-*-cygwin)
Packit 5c3484
     if test x$ABI = x64 ; then
Packit 5c3484
	AC_MSG_NOTICE([If wine64 is installed, use make check TESTS_ENVIRONMENT=wine64.])
Packit 5c3484
     else
Packit 5c3484
	AC_MSG_NOTICE([If wine is installed, use make check TESTS_ENVIRONMENT=wine.])
Packit 5c3484
     fi
Packit 5c3484
     ;;
Packit 5c3484
   esac
Packit 5c3484
fi