dnl GMP specific autoconf macrosdnl Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 Free Softwarednl Foundation, Inc.dnldnl This file is part of the GNU MP Library.dnldnl The GNU MP Library is free software; you can redistribute it and/or modifydnl it under the terms of the GNU Lesser General Public License as publisheddnl by the Free Software Foundation; either version 3 of the License, or (atdnl your option) any later version.dnldnl The GNU MP Library is distributed in the hope that it will be useful, butdnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITYdnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Publicdnl License for more details.dnldnl You should have received a copy of the GNU Lesser General Public Licensednl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.dnl Some tests use, or must delete, the default compiler output. Thednl possible filenames are based on what autoconf looks for, namelydnldnl a.out - normal unix stylednl b.out - i960 systems, including gcc therednl a.exe - djgppdnl a_out.exe - OpenVMS DEC C called via GNV wrapper (gnv.sourceforge.net)dnl conftest.exe - various DOS compilersdefine(IA64_PATTERN,[[ia64*-*-* | itanium-*-* | itanium2-*-*]])dnl Need to be careful not to match m6811, m6812, m68hc11 and m68hc12, alldnl of which config.sub accepts. (Though none of which are likely to workdnl with GMP.)dnldefine(M68K_PATTERN,[[m68k-*-* | m68[0-9][0-9][0-9]-*-*]])define(POWERPC64_PATTERN,[[powerpc64-*-* | powerpc64le-*-* | powerpc620-*-* | powerpc630-*-* | powerpc970-*-* | power[3-9]-*-*]])define(X86_PATTERN,[[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-* | geode*-*-* | atom-*-*]])define(X86_64_PATTERN,[[athlon64-*-* | pentium4-*-* | atom-*-* | core2-*-* | corei-*-* | x86_64-*-* | nano-*-*]])dnl GMP_FAT_SUFFIX(DSTVAR, DIRECTORY)dnl ---------------------------------dnl Emit code to set shell variable DSTVAR to the suffix for a fat binarydnl routine from DIRECTORY. DIRECTORY can be a shell expression like $foodnl etc.dnldnl The suffix is directory separators / or \ changed to underscores, anddnl if there's more than one directory part, then the first is dropped.dnldnl For instance,dnldnl x86 -> x86dnl x86/k6 -> k6dnl x86/k6/mmx -> k6_mmxdefine(GMP_FAT_SUFFIX,[[$1=`echo $2 | sed -e '/\//s:^[^/]*/::' -e 's:[\\/]:_:g'`]])dnl GMP_REMOVE_FROM_LIST(listvar,item)dnl ----------------------------------dnl Emit code to remove any occurrence of ITEM from $LISTVAR. ITEM can be adnl shell expression like $foo if desired.define(GMP_REMOVE_FROM_LIST,[remove_from_list_tmp=for remove_from_list_i in $[][$1]; doif test $remove_from_list_i = [$2]; then :;elseremove_from_list_tmp="$remove_from_list_tmp $remove_from_list_i"fidone[$1]=$remove_from_list_tmp])dnl GMP_STRIP_PATH(subdir)dnl ----------------------dnl Strip entries */subdir from $path and $fat_path.define(GMP_STRIP_PATH,[GMP_STRIP_PATH_VAR(path, [$1])GMP_STRIP_PATH_VAR(fat_path, [$1])])define(GMP_STRIP_PATH_VAR,[tmp_path=for i in $[][$1]; docase $i in*/[$2]) ;;*) tmp_path="$tmp_path $i" ;;esacdone[$1]="$tmp_path"])dnl GMP_INCLUDE_GMP_Hdnl -----------------dnl Expand to the right way to #include gmp-h.in. This must be useddnl instead of gmp.h, since that file isn't generated until the end of thednl configure.dnldnl Dummy value for GMP_LIMB_BITS is enoughdnl for all current configure-time uses of gmp.h.define(GMP_INCLUDE_GMP_H,[[#define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */#define GMP_NAIL_BITS $GMP_NAIL_BITS#define GMP_LIMB_BITS 123$DEFN_LONG_LONG_LIMB#include "$srcdir/gmp-h.in"]])dnl GMP_HEADER_GETVAL(NAME,FILE)dnl ----------------------------dnl Expand at autoconf time to the value of a "#define NAME" from the givendnl FILE. The regexps here aren't very rugged, but are enough for gmp.dnl /dev/null as a parameter prevents a hang if $2 is accidentally omitted.define(GMP_HEADER_GETVAL,[patsubst(patsubst(esyscmd([grep "^#define $1 " $2 /dev/null 2>/dev/null]),[^.*$1[ ]+],[]),[[]*$],[])])dnl GMP_VERSIONdnl -----------dnl The gmp version number, extracted from the #defines in gmp-h.in atdnl autoconf time. Two digits like 3.0 if patchlevel <= 0, or three digitsdnl like 3.0.1 if patchlevel > 0.define(GMP_VERSION,[GMP_HEADER_GETVAL(__GNU_MP_VERSION,gmp-h.in)[]dnl.GMP_HEADER_GETVAL(__GNU_MP_VERSION_MINOR,gmp-h.in)[]dnl.GMP_HEADER_GETVAL(__GNU_MP_VERSION_PATCHLEVEL,gmp-h.in)])dnl GMP_SUBST_CHECK_FUNCS(func,...)dnl ------------------------------dnl Setup an AC_SUBST of HAVE_FUNC_01 for each argument.AC_DEFUN([GMP_SUBST_CHECK_FUNCS],[m4_if([$1],,,[_GMP_SUBST_CHECK_FUNCS(ac_cv_func_[$1],HAVE_[]m4_translit([$1],[a-z],[A-Z])_01)GMP_SUBST_CHECK_FUNCS(m4_shift($@))])])dnl Called: _GMP_SUBST_CHECK_FUNCS(cachevar,substvar)AC_DEFUN([_GMP_SUBST_CHECK_FUNCS],[case $[$1] inyes) AC_SUBST([$2],1) ;;no) [$2]=0 ;;esac])dnl GMP_SUBST_CHECK_HEADERS(foo.h,...)dnl ----------------------------------dnl Setup an AC_SUBST of HAVE_FOO_H_01 for each argument.AC_DEFUN([GMP_SUBST_CHECK_HEADERS],[m4_if([$1],,,[_GMP_SUBST_CHECK_HEADERS(ac_cv_header_[]m4_translit([$1],[./],[__]),HAVE_[]m4_translit([$1],[a-z./],[A-Z__])_01)GMP_SUBST_CHECK_HEADERS(m4_shift($@))])])dnl Called: _GMP_SUBST_CHECK_HEADERS(cachevar,substvar)AC_DEFUN([_GMP_SUBST_CHECK_HEADERS],[case $[$1] inyes) AC_SUBST([$2],1) ;;no) [$2]=0 ;;esac])dnl GMP_COMPARE_GE(A1,B1, A2,B2, ...)dnl ---------------------------------dnl Compare two version numbers A1.A2.etc and B1.B2.etc. Setdnl $gmp_compare_ge to yes or no according to the result. The A partsdnl should be variables, the B parts fixed numbers. As many parts asdnl desired can be included. An empty string in an A part is taken to bednl zero, the B parts should be non-empty and non-zero.dnldnl For example,dnldnl GMP_COMPARE($major,10, $minor,3, $subminor,1)dnldnl would test whether $major.$minor.$subminor is greater than or equal todnl 10.3.1.AC_DEFUN([GMP_COMPARE_GE],[gmp_compare_ge=noGMP_COMPARE_GE_INTERNAL($@)])AC_DEFUN([GMP_COMPARE_GE_INTERNAL],[ifelse(len([$3]),0,[if test -n "$1" && test "$1" -ge $2; thengmp_compare_ge=yesfi],[if test -n "$1"; thenif test "$1" -gt $2; thengmp_compare_ge=yeselseif test "$1" -eq $2; thenGMP_COMPARE_GE_INTERNAL(m4_shift(m4_shift($@)))fififi])])dnl GMP_PROG_ARdnl -----------dnl GMP additions to $AR.dnldnl A cross-"ar" may be necessary when cross-compiling since the builddnl system "ar" might try to interpret the object files to build a symboldnl table index, hence the use of AC_CHECK_TOOL.dnldnl A user-selected $AR is always left unchanged. AC_CHECK_TOOL is stilldnl run to get the "checking" message printed though.dnldnl If extra flags are added to AR, then ac_cv_prog_AR anddnl ac_cv_prog_ac_ct_AR are set too, since libtool (cvs 2003-03-31 atdnl least) will do an AC_CHECK_TOOL and that will AR from one of those twodnl cached variables. (ac_cv_prog_AR is used if there's an ac_tool_prefix,dnl or ac_cv_prog_ac_ct_AR is used otherwise.) FIXME: This is highlydnl dependent on autoconf internals, perhaps it'd work to put our extradnl flags into AR_FLAGS instead.dnldnl $AR_FLAGS is set to "cq" rather than leaving it to libtool "cru". Thednl latter fails when libtool goes into piecewise mode and is unluckydnl enough to have two same-named objects in separate pieces, as happensdnl for instance to random.o (and others) on vax-dec-ultrix4.5. Naturallydnl a user-selected $AR_FLAGS is left unchanged.dnldnl For reference, $ARFLAGS is used by automake (1.8) for its ".a" archivednl file rules. This doesn't get used by the piecewise linking, so wednl leave it at the default "cru".dnldnl FIXME: Libtool 1.5.2 has its own arrangements for "cq", but that versiondnl is broken in other ways. When we can upgrade, remove the forciblednl AR_FLAGS=cq.AC_DEFUN([GMP_PROG_AR],[dnl Want to establish $AR before libtool initialization.AC_BEFORE([$0],[AC_PROG_LIBTOOL])gmp_user_AR=$ARAC_CHECK_TOOL(AR, ar, ar)if test -z "$gmp_user_AR"; theneval arflags=\"\$ar${abi1}_flags\"test -n "$arflags" || eval arflags=\"\$ar${abi2}_flags\"if test -n "$arflags"; thenAC_MSG_CHECKING([for extra ar flags])AR="$AR $arflags"ac_cv_prog_AR="$AR $arflags"ac_cv_prog_ac_ct_AR="$AR $arflags"AC_MSG_RESULT([$arflags])fifiif test -z "$AR_FLAGS"; thenAR_FLAGS=cqfi])dnl GMP_PROG_M4dnl -----------dnl Find a working m4, either in $PATH or likely locations, and setup $M4dnl and an AC_SUBST accordingly. If $M4 is already set then it's a userdnl choice and is accepted with no checks. GMP_PROG_M4 is likednl AC_PATH_PROG or AC_CHECK_PROG, but tests each m4 found to see if it'sdnl good enough.dnldnl See mpn/asm-defs.m4 for details on the known bad m4s.AC_DEFUN([GMP_PROG_M4],[AC_ARG_VAR(M4,[m4 macro processor])AC_CACHE_CHECK([for suitable m4],gmp_cv_prog_m4,[if test -n "$M4"; thengmp_cv_prog_m4="$M4"elsecat >conftest.m4 <<\EOFdnl Must protect this against being expanded during autoconf m4!dnl Dont put "dnl"s in this as autoconf will flag an error for unexpandeddnl macros.[define(dollarhash,``$][#'')ifelse(dollarhash(x),1,`define(t1,Y)',``bad: $][# not supported (SunOS /usr/bin/m4)'')ifelse(eval(89),89,`define(t2,Y)',`bad: eval() doesnt support 8 or 9 in a constant (OpenBSD 2.6 m4)')ifelse(t1`'t2,YY,`good')]EOFdnl ' <- balance the quotes for emacs sh-modeecho "trying m4" >&AC_FD_CCgmp_tmp_val=`(m4 conftest.m4) 2>&AC_FD_CC`echo "$gmp_tmp_val" >&AC_FD_CCif test "$gmp_tmp_val" = good; thengmp_cv_prog_m4="m4"elseIFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"dnl $ac_dummy forces splitting on constant user-supplied paths.dnl POSIX.2 word splitting is done only on the output of word expansions,dnl not every word. This closes a longstanding sh security hole.ac_dummy="$PATH:/usr/5bin"for ac_dir in $ac_dummy; dotest -z "$ac_dir" && ac_dir=.echo "trying $ac_dir/m4" >&AC_FD_CCgmp_tmp_val=`($ac_dir/m4 conftest.m4) 2>&AC_FD_CC`echo "$gmp_tmp_val" >&AC_FD_CCif test "$gmp_tmp_val" = good; thengmp_cv_prog_m4="$ac_dir/m4"breakfidoneIFS="$ac_save_ifs"if test -z "$gmp_cv_prog_m4"; thenAC_MSG_ERROR([No usable m4 in \$PATH or /usr/5bin (see config.log for reasons).])fifirm -f conftest.m4fi])M4="$gmp_cv_prog_m4"AC_SUBST(M4)])dnl GMP_M4_M4WRAP_SPURIOUSdnl ----------------------dnl Check for spurious output from m4wrap(), as described in mpn/asm-defs.m4.dnldnl The following systems have been seen with the problem.dnldnl - Unicos alpha, but its assembler doesn't seem to mind.dnl - MacOS X Darwin, its assembler fails.dnl - NetBSD 1.4.1 m68k, and gas 1.92.3 there gives a warning and ignoresdnl the bad last line since it doesn't have a newline.dnl - NetBSD 1.4.2 alpha, but its assembler doesn't seem to mind.dnl - HP-UX ia64.dnldnl Enhancement: Maybe this could be in GMP_PROG_M4, and attempt to preferdnl an m4 with a working m4wrap, if it can be found.AC_DEFUN([GMP_M4_M4WRAP_SPURIOUS],[AC_REQUIRE([GMP_PROG_M4])AC_CACHE_CHECK([if m4wrap produces spurious output],gmp_cv_m4_m4wrap_spurious,[# hide the d-n-l from autoconf's error checkingtmp_d_n_l=d""nlcat >conftest.m4 <<EOF[changequote({,})define(x,)m4wrap({x})$tmp_d_n_l]EOFecho test input is >&AC_FD_CCcat conftest.m4 >&AC_FD_CCtmp_chars=`$M4 conftest.m4 | wc -c`echo produces $tmp_chars chars output >&AC_FD_CCrm -f conftest.m4if test $tmp_chars = 0; thengmp_cv_m4_m4wrap_spurious=noelsegmp_cv_m4_m4wrap_spurious=yesfi])GMP_DEFINE_RAW(["define(<M4WRAP_SPURIOUS>,<$gmp_cv_m4_m4wrap_spurious>)"])])dnl GMP_PROG_NMdnl -----------dnl GMP additions to libtool AC_PROG_NM.dnldnl Note that if AC_PROG_NM can't find a working nm it still leavesdnl $NM set to "nm", so $NM can't be assumed to actually work.dnldnl A user-selected $NM is always left unchanged. AC_PROG_NM is still rundnl to get the "checking" message printed though.dnldnl Perhaps it'd be worthwhile checking that nm works, by running it on andnl actual object file. For instance on sparcv9 solaris old versions ofdnl GNU nm don't recognise 64-bit objects. Checking would give a betterdnl error message than just a failure in later tests like GMP_ASM_W32 etc.dnldnl On the other hand it's not really normal autoconf practice to take toodnl much trouble over detecting a broken set of tools. And libtool doesn'tdnl do anything at all for say ranlib or strip. So for now we're inclineddnl to just demand that the user provides a coherent environment.AC_DEFUN([GMP_PROG_NM],[dnl Make sure we're the first to call AC_PROG_NM, so our extra flags arednl used by everyone.AC_BEFORE([$0],[AC_PROG_NM])gmp_user_NM=$NMAC_PROG_NM# FIXME: When cross compiling (ie. $ac_tool_prefix not empty), libtool# defaults to plain "nm" if a "${ac_tool_prefix}nm" is not found. In this# case run it again to try the native "nm", firstly so that likely locations# are searched, secondly so that -B or -p are added if necessary for BSD# format. This is necessary for instance on OSF with "./configure# --build=alphaev5-dec-osf --host=alphaev6-dec-osf".#if test -z "$gmp_user_NM" && test -n "$ac_tool_prefix" && test "$NM" = nm; then$as_unset lt_cv_path_NMgmp_save_ac_tool_prefix=$ac_tool_prefixac_tool_prefix=NM=AC_PROG_NMac_tool_prefix=$gmp_save_ac_tool_prefixfiif test -z "$gmp_user_NM"; theneval nmflags=\"\$nm${abi1}_flags\"test -n "$nmflags" || eval nmflags=\"\$nm${abi2}_flags\"if test -n "$nmflags"; thenAC_MSG_CHECKING([for extra nm flags])NM="$NM $nmflags"AC_MSG_RESULT([$nmflags])fifi])dnl GMP_PROG_CC_WORKS(cc+cflags,[ACTION-IF-WORKS][,ACTION-IF-NOT-WORKS])dnl --------------------------------------------------------------------dnl Check if cc+cflags can compile and link.dnldnl This test is designed to be run repeatedly with different cc+cflagsdnl selections, so the result is not cached.dnldnl For a native build, meaning $cross_compiling == no, we require that thednl generated program will run. This is the same as AC_PROG_CC does indnl _AC_COMPILER_EXEEXT_WORKS, and checking here will ensure we don't passdnl a CC/CFLAGS combination that it rejects.dnldnl sparc-*-solaris2.7 can compile ABI=64 but won't run it if the kerneldnl was booted in 32-bit mode. The effect of requiring the compiler outputdnl will run is that a plain native "./configure" falls back on ABI=32, butdnl ABI=64 is still available as a cross-compile.dnldnl The various specific problems we try to detect are done in separatednl compiles. Although this is probably a bit slower than one testdnl program, it makes it easy to indicate the problem in AC_MSG_RESULT,dnl hence giving the user a clue about why we rejected the compiler.AC_DEFUN([GMP_PROG_CC_WORKS],[AC_MSG_CHECKING([compiler $1])gmp_prog_cc_works=yes# first see a simple "main()" works, then go on to other checksGMP_PROG_CC_WORKS_PART([$1], [])GMP_PROG_CC_WORKS_PART([$1], [function pointer return],[/* The following provokes an internal error from gcc 2.95.2 -mpowerpc64(without -maix64), hence detecting an unusable compiler */void *g() { return (void *) 0; }void *f() { return g(); }])GMP_PROG_CC_WORKS_PART([$1], [cmov instruction],[/* The following provokes an invalid instruction syntax from i386 gcc-march=pentiumpro on Solaris 2.8. The native sun assemblerrequires a non-standard syntax for cmov which gcc (as of 2.95.2 atleast) doesn't know. */int n;int cmov () { return (n >= 0 ? n : 0); }])GMP_PROG_CC_WORKS_PART([$1], [double -> ulong conversion],[/* The following provokes a linker invocation problem with gcc 3.0.3on AIX 4.3 under "-maix64 -mpowerpc64 -mcpu=630". The -mcpu=630option causes gcc to incorrectly select the 32-bit libgcc.a, notthe 64-bit one, and consequently it misses out on the __fixunsdfdihelper (double -> uint64 conversion). */double d;unsigned long gcc303 () { return (unsigned long) d; }])GMP_PROG_CC_WORKS_PART([$1], [double negation],[/* The following provokes an error from hppa gcc 2.95 under -mpa-risc-2-0 ifthe assembler doesn't know hppa 2.0 instructions. fneg is a 2.0instruction, and a negation like this comes out using it. */double fneg_data;unsigned long fneg () { return -fneg_data; }])GMP_PROG_CC_WORKS_PART([$1], [double -> float conversion],[/* The following makes gcc 3.3 -march=pentium4 generate an SSE2 xmm insn(cvtsd2ss) which will provoke an error if the assembler doesn't recognisethose instructions. Not sure how much of the gmp code will come outwanting sse2, but it's easiest to reject an option we know is bad. */double ftod_data;float ftod () { return (float) ftod_data; }])GMP_PROG_CC_WORKS_PART([$1], [gnupro alpha ev6 char spilling],[/* The following provokes an internal compiler error from gcc version"2.9-gnupro-99r1" under "-O2 -mcpu=ev6", apparently relating to charvalues being spilled into floating point registers. The problem doesn'tshow up all the time, but has occurred enough in GMP for us to rejectthis compiler+flags. */#include <string.h> /* for memcpy */struct try_t{char dst[2];char size;long d0, d1, d2, d3, d4, d5, d6;char overlap;};struct try_t param[6];intparam_init (){struct try_t *p;memcpy (p, ¶m[ 2 ], sizeof (*p));memcpy (p, ¶m[ 2 ], sizeof (*p));p->size = 2;memcpy (p, ¶m[ 1 ], sizeof (*p));p->dst[0] = 1;p->overlap = 2;memcpy (p, ¶m[ 3 ], sizeof (*p));p->dst[0] = 1;p->overlap = 8;memcpy (p, ¶m[ 4 ], sizeof (*p));memcpy (p, ¶m[ 4 ], sizeof (*p));p->overlap = 8;memcpy (p, ¶m[ 5 ], sizeof (*p));memcpy (p, ¶m[ 5 ], sizeof (*p));memcpy (p, ¶m[ 5 ], sizeof (*p));return 0;}])# __builtin_alloca is not available everywhere, check it exists before# seeing that it worksGMP_PROG_CC_WORKS_PART_TEST([$1],[__builtin_alloca availability],[int k; int foo () { __builtin_alloca (k); }],[GMP_PROG_CC_WORKS_PART([$1], [alloca array],[/* The following provokes an internal compiler error from Itanium HP-UX ccunder +O2 or higher. We use this sort of code in mpn/generic/mul_fft.c. */int k;int foo (){int i, **a;a = __builtin_alloca (k);for (i = 0; i <= k; i++)a[i] = __builtin_alloca (1 << i);}])])GMP_PROG_CC_WORKS_PART([$1], [abs int -> double conversion],[/* The following provokes an internal error from the assembler onpower2-ibm-aix4.3.1.0. gcc -mrios2 compiles to nabs+fcirz, and thisresults in "Internal error related to the source program domain".For reference it seems to be the combination of nabs+fcirz which is bad,not either alone. This sort of thing occurs in mpz/get_str.c with theway double chars_per_bit_exactly is applied in MPN_SIZEINBASE. Perhapsif that code changes to a scaled-integer style then we won't need thistest. */double fp[1];int x;int f (){int a;a = (x >= 0 ? x : -x);return a * fp[0];}])GMP_PROG_CC_WORKS_PART([$1], [long long reliability test 1],[/* The following provokes a segfault in the compiler on powerpc-apple-darwin.Extracted from tests/mpn/t-iord_u.c. Causes Apple's gcc 3.3 build 1640 and1666 to segfault with e.g., -O2 -mpowerpc64. */#if defined (__GNUC__) && ! defined (__cplusplus)typedef unsigned long long t1;typedef t1*t2;static __inline__ t1 e(t2 rp,t2 up,int n,t1 v0){t1 c,x,r;int i;if(v0){c=1;for(i=1;i<n;i++){x=up[i];r=x+1;rp[i]=r;}}return c;}f(){static const struct{t1 n;t1 src[9];t1 want[9];}d[]={{1,{0},{1}},};t1 got[9];int i;for(i=0;i<1;i++){if(e(got,got,9,d[i].n)==0)h();g(i,d[i].src,d[i].n,got,d[i].want,9);if(d[i].n)h();}}h(){}g(){}#elseint dummy;#endif])GMP_PROG_CC_WORKS_PART([$1], [long long reliability test 2],[/* The following provokes an internal compiler error on powerpc-apple-darwin.Extracted from mpz/cfdiv_q_2exp.c. Causes Apple's gcc 3.3 build 1640 and1666 to get an ICE with -O1 -mpowerpc64. */#if defined (__GNUC__) && ! defined (__cplusplus)f(int u){int i;long long x;x=u?~0:0;if(x)for(i=0;i<9;i++);x&=g();if(x)g();}g(){}#elseint dummy;#endif])GMP_PROG_CC_WORKS_PART_MAIN([$1], [mpn_lshift_com optimization],[/* The following is mis-compiled by HP ia-64 cc versioncc: HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]under "cc +O3", both in +DD32 and +DD64 modes. The mpn_lshift_com getsinlined and its return value somehow botched to be 0 instead of 1. Thisarises in the real mpn_lshift_com in mul_fft.c. A lower optimizationlevel, like +O2 seems ok. This code needs to be run to show the problem,but that's fine, the offending cc is a native-only compiler so we don'thave to worry about cross compiling. */#if ! defined (__cplusplus)unsigned longlshift_com (rp, up, n, cnt)unsigned long *rp;unsigned long *up;long n;unsigned cnt;{unsigned long retval, high_limb, low_limb;unsigned tnc;long i;tnc = 8 * sizeof (unsigned long) - cnt;low_limb = *up++;retval = low_limb >> tnc;high_limb = low_limb << cnt;for (i = n - 1; i != 0; i--){low_limb = *up++;*rp++ = ~(high_limb | (low_limb >> tnc));high_limb = low_limb << cnt;}return retval;}intmain (){unsigned long cy, rp[2], up[2];up[0] = ~ 0L;up[1] = 0;cy = lshift_com (rp, up, 2L, 1);if (cy != 1L)return 1;return 0;}#elseintmain (){return 0;}#endif])GMP_PROG_CC_WORKS_PART_MAIN([$1], [mpn_lshift_com optimization 2],[/* The following is mis-compiled by Intel ia-64 icc version 1.8 under"icc -O3", After several calls, the function writes parial garbage tothe result vector. Perhaps relates to the chk.a.nc insn. This code needsto be run to show the problem, but that's fine, the offending cc is anative-only compiler so we don't have to worry about cross compiling. */#if ! defined (__cplusplus)#include <stdlib.h>voidlshift_com (rp, up, n, cnt)unsigned long *rp;unsigned long *up;long n;unsigned cnt;{unsigned long high_limb, low_limb;unsigned tnc;long i;up += n;rp += n;tnc = 8 * sizeof (unsigned long) - cnt;low_limb = *--up;high_limb = low_limb << cnt;for (i = n - 1; i != 0; i--){low_limb = *--up;*--rp = ~(high_limb | (low_limb >> tnc));high_limb = low_limb << cnt;}*--rp = ~high_limb;}intmain (){unsigned long *r, *r2;unsigned long a[88 + 1];long i;for (i = 0; i < 88 + 1; i++)a[i] = ~0L;r = malloc (10000 * sizeof (unsigned long));r2 = r;for (i = 0; i < 528; i += 22){lshift_com (r2, a,i / (8 * sizeof (unsigned long)) + 1,i % (8 * sizeof (unsigned long)));r2 += 88 + 1;}if (r[2048] != 0 || r[2049] != 0 || r[2050] != 0 || r[2051] != 0 ||r[2052] != 0 || r[2053] != 0 || r[2054] != 0)abort ();return 0;}#elseintmain (){return 0;}#endif])# A certain _GLOBAL_OFFSET_TABLE_ problem in past versions of gas, tickled# by recent versions of gcc.#if test "$gmp_prog_cc_works" = yes; thencase $host inX86_PATTERN)# this problem only arises in PIC code, so don't need to test when# --disable-shared. We don't necessarily have $enable_shared set to# yes at this point, it will still be unset for the default (which is# yes); hence the use of "!= no".if test "$enable_shared" != no; thenGMP_PROG_CC_X86_GOT_EAX_EMITTED([$1],[GMP_ASM_X86_GOT_EAX_OK([$1],,[gmp_prog_cc_works="no, bad gas GOT with eax"])])fi;;esacfiAC_MSG_RESULT($gmp_prog_cc_works)case $gmp_prog_cc_works inyes)[$2];;*)[$3];;esac])dnl Called: GMP_PROG_CC_WORKS_PART(CC+CFLAGS,FAIL-MESSAGE [,CODE])dnl A dummy main() is appended to the CODE given.dnlAC_DEFUN([GMP_PROG_CC_WORKS_PART],[GMP_PROG_CC_WORKS_PART_MAIN([$1],[$2],[$3][int main () { return 0; }])])dnl Called: GMP_PROG_CC_WORKS_PART_MAIN(CC+CFLAGS,FAIL-MESSAGE,CODE)dnl CODE must include a main().dnlAC_DEFUN([GMP_PROG_CC_WORKS_PART_MAIN],[GMP_PROG_CC_WORKS_PART_TEST([$1],[$2],[$3],[],gmp_prog_cc_works="no[]m4_if([$2],,,[[, ]])[$2]",gmp_prog_cc_works="no[]m4_if([$2],,,[[, ]])[$2][[, program does not run]]")])dnl Called: GMP_PROG_CC_WORKS_PART_TEST(CC+CFLAGS,TITLE,[CODE],dnl [ACTION-GOOD],[ACTION-BAD][ACTION-NORUN])dnlAC_DEFUN([GMP_PROG_CC_WORKS_PART_TEST],[if test "$gmp_prog_cc_works" = yes; then# remove anything that might look like compiler output to our "||" expressionrm -f conftest* a.out b.out a.exe a_out.execat >conftest.c <<EOF[$3]EOFecho "Test compile: [$2]" >&AC_FD_CCgmp_compile="$1 conftest.c >&AC_FD_CC"if AC_TRY_EVAL(gmp_compile); thencc_works_part=yesif test "$cross_compiling" = no; thenif AC_TRY_COMMAND([./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest]); then :;elsecc_works_part=norunfifielsecc_works_part=nofiif test "$cc_works_part" != yes; thenecho "failed program was:" >&AC_FD_CCcat conftest.c >&AC_FD_CCfirm -f conftest* a.out b.out a.exe a_out.execase $cc_works_part inyes)$4;;no)$5;;norun)$6;;esacfi])dnl GMP_PROG_CC_WORKS_LONGLONG(cc+cflags,[ACTION-YES][,ACTION-NO])dnl --------------------------------------------------------------dnl Check that cc+cflags accepts "long long".dnldnl This test is designed to be run repeatedly with different cc+cflagsdnl selections, so the result is not cached.AC_DEFUN([GMP_PROG_CC_WORKS_LONGLONG],[AC_MSG_CHECKING([compiler $1 has long long])cat >conftest.c <<EOFlong long foo;long long bar () { return foo; }int main () { return 0; }EOFgmp_prog_cc_works=nogmp_compile="$1 -c conftest.c >&AC_FD_CC"if AC_TRY_EVAL(gmp_compile); thengmp_prog_cc_works=yeselseecho "failed program was:" >&AC_FD_CCcat conftest.c >&AC_FD_CCfirm -f conftest* a.out b.out a.exe a_out.exeAC_MSG_RESULT($gmp_prog_cc_works)if test $gmp_prog_cc_works = yes; thenifelse([$2],,:,[$2])elseifelse([$3],,:,[$3])fi])dnl GMP_C_TEST_SIZEOF(cc/cflags,test,[ACTION-GOOD][,ACTION-BAD])dnl ------------------------------------------------------------dnl The given cc/cflags compiler is run to check the size of a typednl specified by the "test" argument. "test" can either be a string, or adnl variable like $foo. The value should be for instance "sizeof-long-4",dnl to test that sizeof(long)==4.dnldnl This test is designed to be run for different compiler and/or flagsdnl combinations, so the result is not cached.dnldnl The idea for making an array that has a negative size if the desireddnl condition test is false comes from autoconf AC_CHECK_SIZEOF. The castdnl to "long" in the array dimension also follows autoconf, apparently it'sdnl a workaround for a HP compiler bug.AC_DEFUN([GMP_C_TEST_SIZEOF],[echo "configure: testlist $2" >&AC_FD_CC[gmp_sizeof_type=`echo "$2" | sed 's/sizeof-\([a-z]*\).*/\1/'`][gmp_sizeof_want=`echo "$2" | sed 's/sizeof-[a-z]*-\([0-9]*\).*/\1/'`]AC_MSG_CHECKING([compiler $1 has sizeof($gmp_sizeof_type)==$gmp_sizeof_want])cat >conftest.c <<EOF[intmain (){static int test_array [1 - 2 * (long) (sizeof ($gmp_sizeof_type) != $gmp_sizeof_want)];test_array[0] = 0;return 0;}]EOFgmp_c_testlist_sizeof=nogmp_compile="$1 -c conftest.c >&AC_FD_CC"if AC_TRY_EVAL(gmp_compile); thengmp_c_testlist_sizeof=yesfirm -f conftest*AC_MSG_RESULT($gmp_c_testlist_sizeof)if test $gmp_c_testlist_sizeof = yes; thenifelse([$3],,:,[$3])elseifelse([$4],,:,[$4])fi])dnl GMP_PROG_CC_IS_GNU(CC,[ACTIONS-IF-YES][,ACTIONS-IF-NO])dnl -------------------------------------------------------dnl Determine whether the given compiler is GNU C.dnldnl This test is the same as autoconf _AC_LANG_COMPILER_GNU, but doesn'tdnl cache the result. The same "ifndef" style test is used, to avoiddnl problems with syntax checking cpp's used on NeXT and Apple systems.AC_DEFUN([GMP_PROG_CC_IS_GNU],[cat >conftest.c <<EOF#if ! defined (__GNUC__) || defined (__INTEL_COMPILER)choke me#endifEOFgmp_compile="$1 -c conftest.c >&AC_FD_CC"if AC_TRY_EVAL(gmp_compile); thenrm -f conftest*AC_MSG_CHECKING([whether $1 is gcc])AC_MSG_RESULT(yes)ifelse([$2],,:,[$2])elserm -f conftest*ifelse([$3],,:,[$3])fi])dnl GMP_PROG_CC_IS_XLC(CC,[ACTIONS-IF-YES][,ACTIONS-IF-NO])dnl -------------------------------------------------------dnl Determine whether the given compiler is IBM xlc (on AIX).dnldnl There doesn't seem to be a preprocessor symbol to test for this, or ifdnl there is one then it's well hidden in xlc 3.1 on AIX 4.3, so just grepdnl the man page printed when xlc is invoked with no arguments.AC_DEFUN([GMP_PROG_CC_IS_XLC],[gmp_command="$1 2>&1 | grep xlc >/dev/null"if AC_TRY_EVAL(gmp_command); thenAC_MSG_CHECKING([whether $1 is xlc])AC_MSG_RESULT(yes)ifelse([$2],,:,[$2])elseifelse([$3],,:,[$3])fi])dnl GMP_PROG_CC_X86_GOT_EAX_EMITTED(CC+CFLAGS, [ACTION-YES] [, ACTION-NO])dnl ----------------------------------------------------------------------dnl Determine whether CC+CFLAGS emits instructions using %eax withdnl _GLOBAL_OFFSET_TABLE_. This test is for use on x86 systems.dnldnl Recent versions of gcc will use %eax for the GOT in leaf functions, fordnl instance gcc 3.3.3 with -O3. This avoids having to save and restorednl %ebx which otherwise usually holds the GOT, and is what gcc used in thednl past.dnldnl %ecx and %edx are also candidates for this sort of optimization, anddnl are used under lesser optimization levels, like -O2 in 3.3.3. FIXME:dnl It's not quite clear what the conditions for using %eax are, we mightdnl need more test code to provoke it.dnldnl The motivation for this test is that past versions of gas have bugsdnl affecting this usage, see GMP_ASM_X86_GOT_EAX_OK.dnldnl This test is not specific to gcc, other compilers might emit %eax GOTdnl insns like this, though we've not investigated that.dnldnl This is for use by compiler probing in GMP_PROG_CC_WORKS, so we doesn'tdnl cache the result.dnldnl -fPIC is hard coded here, because this test is for use before libtooldnl has established the pic options. It's right for gcc, but perhaps notdnl other compilers.AC_DEFUN([GMP_PROG_CC_X86_GOT_EAX_EMITTED],[echo "Testing gcc GOT with eax emitted" >&AC_FD_CCcat >conftest.c <<\EOF[int foo;int bar () { return foo; }]EOFtmp_got_emitted=nogmp_compile="$1 -fPIC -S conftest.c >&AC_FD_CC 2>&1"if AC_TRY_EVAL(gmp_compile); thenif grep "addl.*_GLOBAL_OFFSET_TABLE_.*eax" conftest.s >/dev/null; thentmp_got_emitted=yesfifirm -f conftest.*echo "Result: $tmp_got_emitted" >&AC_FD_CCif test "$tmp_got_emitted" = yes; thenifelse([$2],,:,[$2])elseifelse([$3],,:,[$3])fi])dnl GMP_HPC_HPPA_2_0(cc,[ACTION-IF-GOOD][,ACTION-IF-BAD])dnl ---------------------------------------------------------dnl Find out whether a HP compiler is good enough to generate hppa 2.0.dnldnl This test might be repeated for different compilers, so the result isdnl not cached.AC_DEFUN([GMP_HPC_HPPA_2_0],[AC_MSG_CHECKING([whether HP compiler $1 is good for 64-bits])# Bad compiler output:# ccom: HP92453-01 G.10.32.05 HP C Compiler# Good compiler output:# ccom: HP92453-01 A.10.32.30 HP C Compiler# Let A.10.32.30 or higher be ok.echo >conftest.cgmp_tmp_vs=`$1 $2 -V -c -o conftest.$OBJEXT conftest.c 2>&1 | grep "^ccom:"`echo "Version string: $gmp_tmp_vs" >&AC_FD_CCrm conftest*gmp_tmp_v1=`echo $gmp_tmp_vs | sed 's/.* .\.\([[0-9]]*\).*/\1/'`gmp_tmp_v2=`echo $gmp_tmp_vs | sed 's/.* .\..*\.\(.*\)\..* HP C.*/\1/'`gmp_tmp_v3=`echo $gmp_tmp_vs | sed 's/.* .\..*\..*\.\(.*\) HP C.*/\1/'`echo "Version number: $gmp_tmp_v1.$gmp_tmp_v2.$gmp_tmp_v3" >&AC_FD_CCif test -z "$gmp_tmp_v1"; thengmp_hpc_64bit=not-applicableelseGMP_COMPARE_GE($gmp_tmp_v1, 10, $gmp_tmp_v2, 32, $gmp_tmp_v3, 30)gmp_hpc_64bit=$gmp_compare_gefiAC_MSG_RESULT($gmp_hpc_64bit)if test $gmp_hpc_64bit = yes; thenifelse([$2],,:,[$2])elseifelse([$3],,:,[$3])fi])dnl GMP_GCC_ARM_UMODSI(CC,[ACTIONS-IF-GOOD][,ACTIONS-IF-BAD])dnl ---------------------------------------------------------dnl gcc 2.95.3 and earlier on arm has a bug in the libgcc __umodsi routinednl making "%" give wrong results for some operands, eg. "0x90000000 % 3".dnl We're hoping it'll be fixed in 2.95.4, and we know it'll be fixed indnl gcc 3.dnldnl There's only a couple of places gmp cares about this, one is thednl size==1 case in mpn/generic/mode1o.c, and this shows up indnl tests/mpz/t-jac.c as a wrong result from mpz_kronecker_ui.AC_DEFUN([GMP_GCC_ARM_UMODSI],[AC_MSG_CHECKING([whether ARM gcc unsigned division works])tmp_version=`$1 --version`echo "$tmp_version" >&AC_FD_CCcase $tmp_version in[2.95 | 2.95.[123]])ifelse([$3],,:,[$3])gmp_gcc_arm_umodsi_result=["no, gcc 2.95.[0123]"] ;;*)ifelse([$2],,:,[$2])gmp_gcc_arm_umodsi_result=yes ;;esacAC_MSG_RESULT([$gmp_gcc_arm_umodsi_result])])dnl GMP_GCC_MIPS_O32(gcc,[actions-yes][,[actions-no]])dnl -------------------------------------------------dnl Test whether gcc supports o32.dnldnl gcc 2.7.2.2 only does o32, and doesn't accept -mabi=32.dnldnl gcc 2.95 accepts -mabi=32 but it only works on irix5, on irix6 it givesdnl "cc1: The -mabi=32 support does not work yet".AC_DEFUN([GMP_GCC_MIPS_O32],[AC_MSG_CHECKING([whether gcc supports o32])echo 'int x;' >conftest.cecho "$1 -mabi=32 -c conftest.c" >&AC_FD_CCif $1 -mabi=32 -c conftest.c >conftest.out 2>&1; thenresult=yeselsecat conftest.out >&AC_FD_CCif grep "cc1: Invalid option \`abi=32'" conftest.out >/dev/null; thenresult=yeselseresult=nofifirm -f conftest.*AC_MSG_RESULT($result)if test $result = yes; thenifelse([$2],,:,[$2])elseifelse([$3],,:,[$3])fi])dnl GMP_GCC_NO_CPP_PRECOMP(CCBASE,CC,CFLAGS,[ACTIONS-YES][,ACTIONS-NO])dnl -------------------------------------------------------------------dnl Check whether -no-cpp-precomp should be used on this compiler, anddnl execute the corresponding ACTIONS-YES or ACTIONS-NO.dnldnl -no-cpp-precomp is only meant for Apple's hacked version of gcc founddnl on powerpc*-*-darwin*, but we can give it a try on any gcc. Normal gccdnl (as of 3.0 at least) only gives a warning, not an actual error, and wednl watch for that and decide against the option in that case, to avoiddnl confusing the user.AC_DEFUN([GMP_GCC_NO_CPP_PRECOMP],[if test "$ccbase" = gcc; thenAC_MSG_CHECKING([compiler $2 $3 -no-cpp-precomp])result=nocat >conftest.c <<EOFint main () { return 0; }EOFgmp_compile="$2 $3 -no-cpp-precomp conftest.c >conftest.out 2>&1"if AC_TRY_EVAL(gmp_compile); thenif grep "unrecognized option.*-no-cpp-precomp" conftest.out >/dev/null; then : ;elseresult=yesfificat conftest.out >&AC_FD_CCrm -f conftest* a.out b.out a.exe a_out.exeAC_MSG_RESULT($result)if test "$result" = yes; thenifelse([$4],,:,[$4])elseifelse([$5],,:,[$5])fifi])dnl GMP_GCC_PENTIUM4_SSE2(CC+CFLAGS,[ACTION-IF-YES][,ACTION-IF-NO])dnl ---------------------------------------------------------------dnl Determine whether gcc CC+CFLAGS is a good enough version fordnl -march=pentium4 with sse2.dnldnl Gcc 3.2.1 was seen generating incorrect code for raw double -> intdnl conversions through a union. We believe the problem is in all 3.1 anddnl 3.2 versions, but that it's fixed in 3.3.AC_DEFUN([GMP_GCC_PENTIUM4_SSE2],[AC_MSG_CHECKING([whether gcc is good for sse2])case `$1 -dumpversion` in[3.[012] | 3.[012].*]) result=no ;;*) result=yes ;;esacAC_MSG_RESULT($result)if test "$result" = yes; thenifelse([$2],,:,[$2])elseifelse([$3],,:,[$3])fi])dnl GMP_GCC_WA_MCPU(CC+CFLAGS, NEWFLAG [,ACTION-YES [,ACTION-NO]])dnl --------------------------------------------------------------dnl Check whether gcc (or gas rather) accepts a flag like "-Wa,-mev67".dnldnl Gas doesn't give an error for an unknown cpu, it only prints a warningdnl like "Warning: Unknown CPU identifier `ev78'".dnldnl This is intended for use on alpha, since only recent versions of gasdnl accept -mev67, but there's nothing here that's alpha specific.AC_DEFUN([GMP_GCC_WA_MCPU],[AC_MSG_CHECKING([assembler $1 $2])result=nocat >conftest.c <<EOFint main () {}EOFgmp_compile="$1 $2 -c conftest.c >conftest.out 2>&1"if AC_TRY_EVAL(gmp_compile); thenif grep "Unknown CPU identifier" conftest.out >/dev/null; then : ;elseresult=yesfificat conftest.out >&AC_FD_CCrm -f conftest*AC_MSG_RESULT($result)if test "$result" = yes; thenifelse([$3],,:,[$3])elseifelse([$4],,:,[$4])fi])dnl GMP_GCC_WA_OLDAS(CC+CFLAGS [,ACTION-YES [,ACTION-NO]])dnl ------------------------------------------------------dnl Check whether gcc should be run with "-Wa,-oldas".dnldnl On systems alpha*-*-osf* (or maybe just osf5), apparently there's adnl newish Compaq "as" which doesn't work with the gcc mips-tfile.dnl Compiling an empty file with "gcc -c foo.c" produces for instancednldnl mips-tfile, /tmp/ccaqUNnF.s:7 Segmentation faultdnldnl The fix is to pass "-oldas" to that assembler, as noted bydnldnl http://gcc.gnu.org/install/specific.html#alpha*-dec-osf*dnldnl The test here tries to compile an empty file, and if that fails butdnl adding -Wa,-oldas makes it succeed, then that flag is considereddnl necessary.dnldnl We look for the failing case specifically, since it may not be a gooddnl idea to use -Wa,-oldas in other circumstances. For instance gas takesdnl "-oldas" to mean the "-o" option and will write a file called "ldas" asdnl its output. Normally gcc puts its own "-o" after any -Wa options, sodnl -oldas ends up being harmless, but clearly that's only through gooddnl luck.dnldnl This macro is designed for use while probing for a good compiler, anddnl so doesn't cache it's result.AC_DEFUN([GMP_GCC_WA_OLDAS],[AC_MSG_CHECKING([for $1 -Wa,-oldas])result=nocat >conftest.c <<EOFEOFecho "with empty conftest.c" >&AC_FD_CCgmp_compile="$1 -c conftest.c >&AC_FD_CC 2>&1"if AC_TRY_EVAL(gmp_compile); then : ;else# empty failsgmp_compile="$1 -Wa,-oldas -c conftest.c >&AC_FD_CC 2>&1"if AC_TRY_EVAL(gmp_compile); then# but with -Wa,-oldas it worksresult=yesfifirm -f conftest*AC_MSG_RESULT($result)if test "$result" = yes; thenifelse([$2],,:,[$2])elseifelse([$3],,:,[$3])fi])dnl GMP_OS_X86_XMM(CC+CFLAGS,[ACTION-IF-YES][,ACTION-IF-NO])dnl --------------------------------------------------------dnl Determine whether the operating system supports XMM registers.dnldnl If build==host then a test program is run, executing an SSE2dnl instruction using an XMM register. This will give a SIGILL if thednl system hasn't set the OSFXSR bit in CR4 to say it knows it must usednl fxsave/fxrestor in a context switch (to save xmm registers).dnldnl If build!=host, we can fallback on:dnldnl - FreeBSD version 4 is the first supporting xmm.dnldnl - Linux kernel 2.4 might be the first stable series supporting xmmdnl (not sure). But there's no version number in the GNU/Linuxdnl config tuple to test anyway.dnldnl The default is to allow xmm. This might seem rash, but it's likelydnl most systems know xmm by now, so this will normally be what's wanted.dnl And cross compiling is a bit hairy anyway, so hopefully anyone doing itdnl will be smart enough to know what to do.dnldnl In the test program, .text and .globl are hard coded because this macrodnl is wanted before GMP_ASM_TEXT and GMP_ASM_GLOBL are run. A .bytednl sequence is used (for xorps %xmm0, %xmm0) to make us independent ofdnl tests for whether the assembler supports sse2/xmm. Obviously we needdnl both assembler and OS support, but this means we don't force the orderdnl in which we test.dnldnl FIXME: Maybe we should use $CCAS to assemble, if it's set. (Woulddnl still want $CC/$CFLAGS for the link.) But this test is used beforednl AC_PROG_CC sets $OBJEXT, so we'd need to check for various object filednl suffixes ourselves.AC_DEFUN([GMP_OS_X86_XMM],[AC_CACHE_CHECK([whether the operating system supports XMM registers],gmp_cv_os_x86_xmm,[if test "$build" = "$host"; then# remove anything that might look like compiler output to our "||" expressionrm -f conftest* a.out b.out a.exe a_out.execat >conftest.s <<EOF.textmain:_main:.globl main.globl _main.byte 0x0f, 0x57, 0xc0xorl %eax, %eaxretEOFgmp_compile="$1 conftest.s -o conftest >&AC_FD_CC"if AC_TRY_EVAL(gmp_compile); thenif AC_TRY_COMMAND([./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest]); thengmp_cv_os_x86_xmm=yeselsegmp_cv_os_x86_xmm=nofielseAC_MSG_WARN([Oops, cannot compile test program])firm -f conftest*fiif test -z "$gmp_cv_os_x86_xmm"; thencase $host_os in[freebsd[123] | freebsd[123].*])gmp_cv_os_x86_xmm=no ;;freebsd*)gmp_cv_os_x86_xmm=yes ;;*)gmp_cv_os_x86_xmm=probably ;;esacfi])if test "$gmp_cv_os_x86_xmm" = probably; thenAC_MSG_WARN([Not certain of OS support for xmm when cross compiling.])AC_MSG_WARN([Will assume it's ok, expect a SIGILL if this is wrong.])ficase $gmp_cv_os_x86_xmm inno)$3;;*)$2;;esac])dnl GMP_CRAY_HOST_TYPES(C90/T90-IEEE, C90/T90-CFP, J90/SV1)dnl -------------------------------------------------------dnl Execute the actions in the arguments on the respective Cray vectordnl systems. For other hosts, do nothing.dnldnl This macro should be used after the C compiler has been chosen, sincednl on c90 and t90 we ask the compiler whether we're in IEEE or CFP floatdnl mode.dnldnl This code is in a macro so that any AC_REQUIRE pre-requisites ofdnl AC_EGREP_CPP will be expanded at the top-level, ie. for all hosts notdnl merely c90 and t90. In autoconf 2.57 for instance this meansdnl AC_PROG_EGREP, which is needed by various other macros.AC_DEFUN([GMP_CRAY_OPTIONS],[case $host_cpu inc90 | t90)AC_EGREP_CPP(yes,[#ifdef _CRAYIEEEyes#endif],[$1],[$2]);;j90 | sv1)[$3];;esac])dnl GMP_HPPA_LEVEL_20(cc/cflags [, ACTION-GOOD [,ACTION-BAD]])dnl ----------------------------------------------------------dnl Check that the given cc/cflags accepts HPPA 2.0n assembler code.dnldnl Old versions of gas don't know 2.0 instructions. It rejects ".leveldnl 2.0" for a start, so just test that.dnldnl This test is designed to be run for various different compiler anddnl flags combinations, and hence doesn't cache its result.AC_DEFUN([GMP_HPPA_LEVEL_20],[AC_MSG_CHECKING([$1 assembler knows hppa 2.0])result=nocat >conftest.s <<EOF.level 2.0EOFgmp_compile="$1 -c conftest.s >&AC_FD_CC 2>&1"if AC_TRY_EVAL(gmp_compile); thenresult=yeselseecho "failed program was" >&AC_FD_CCcat conftest.s >&AC_FD_CCfirm -f conftest*AC_MSG_RESULT($result)if test "$result" = yes; thenifelse([$2],,:,[$2])elseifelse([$3],,:,[$3])fi])dnl GMP_PROG_CXX_WORKS(cxx/cxxflags [, ACTION-YES [,ACTION-NO]])dnl ------------------------------------------------------------dnl Check whether cxx/cxxflags can compile and link.dnldnl This test is designed to be run repeatedly with different cxx/cxxflagsdnl selections, so the result is not cached.dnldnl For a native build, we insist on being able to run the program, so asdnl to detect any problems with the standard C++ library. Duringdnl development various systems with broken or incomplete C++ installationsdnl were seen.dnldnl The various features and problems we try to detect are done in separatednl compiles. Although this is probably a bit slower than one testdnl program, it makes it easy to indicate the problem in AC_MSG_RESULT,dnl hence giving the user a clue about why we rejected the compiler.AC_DEFUN([GMP_PROG_CXX_WORKS],[AC_MSG_CHECKING([C++ compiler $1])gmp_prog_cxx_works=yes# start with a plain "main()", then go on to further checksGMP_PROG_CXX_WORKS_PART([$1], [])GMP_PROG_CXX_WORKS_PART([$1], [namespace],[namespace foo { }using namespace foo;])# GMP requires the standard C++ iostream classesGMP_PROG_CXX_WORKS_PART([$1], [std iostream],[/* This test rejects g++ 2.7.2 which doesn't have <iostream>, only apre-standard iostream.h. */#include <iostream>/* This test rejects OSF 5.1 Compaq C++ in its default pre-standard iostreammode, since that mode puts cout in the global namespace, not "std". */void someoutput (void) { std::cout << 123; }])AC_MSG_RESULT($gmp_prog_cxx_works)case $gmp_prog_cxx_works inyes)[$2];;*)[$3];;esac])dnl Called: GMP_PROG_CXX_WORKS_PART(CXX+CXXFLAGS, FAIL-MESSAGE [,CODE])dnlAC_DEFUN([GMP_PROG_CXX_WORKS_PART],[if test "$gmp_prog_cxx_works" = yes; then# remove anything that might look like compiler output to our "||" expressionrm -f conftest* a.out b.out a.exe a_out.execat >conftest.cc <<EOF[$3]int main (void) { return 0; }EOFecho "Test compile: [$2]" >&AC_FD_CCgmp_cxxcompile="$1 conftest.cc >&AC_FD_CC"if AC_TRY_EVAL(gmp_cxxcompile); thenif test "$cross_compiling" = no; thenif AC_TRY_COMMAND([./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest]); then :;elsegmp_prog_cxx_works="no[]m4_if([$2],,,[, ])[$2], program does not run"fifielsegmp_prog_cxx_works="no[]m4_if([$2],,,[, ])[$2]"ficase $gmp_prog_cxx_works inno*)echo "failed program was:" >&AC_FD_CCcat conftest.cc >&AC_FD_CC;;esacrm -f conftest* a.out b.out a.exe a_out.exefi])dnl GMP_INIT([M4-DEF-FILE])dnl -----------------------dnl Initializations for GMP config.m4 generation.dnldnl FIXME: The generated config.m4 doesn't get recreated by config.status.dnl Maybe the relevant "echo"s should go through AC_CONFIG_COMMANDS.AC_DEFUN([GMP_INIT],[ifelse([$1], , gmp_configm4=config.m4, gmp_configm4="[$1]")gmp_tmpconfigm4=cnfm4.tmpgmp_tmpconfigm4i=cnfm4i.tmpgmp_tmpconfigm4p=cnfm4p.tmprm -f $gmp_tmpconfigm4 $gmp_tmpconfigm4i $gmp_tmpconfigm4p# CONFIG_TOP_SRCDIR is a path from the mpn builddir to the top srcdir.# The pattern here tests for an absolute path the same way as# _AC_OUTPUT_FILES in autoconf acgeneral.m4.case $srcdir in[[\\/]]* | ?:[[\\/]]* ) tmp="$srcdir" ;;*) tmp="../$srcdir" ;;esacecho ["define(<CONFIG_TOP_SRCDIR>,<\`$tmp'>)"] >>$gmp_tmpconfigm4# All CPUs use asm-defs.m4echo ["include][(CONFIG_TOP_SRCDIR\`/mpn/asm-defs.m4')"] >>$gmp_tmpconfigm4i])dnl GMP_FINISHdnl ----------dnl Create config.m4 from its accumulated parts.dnldnl __CONFIG_M4_INCLUDED__ is used so that a second or subsequent includednl of config.m4 is harmless.dnldnl A separate ifdef on the angle bracket quoted part ensures the quotingdnl style there is respected. The basic defines from gmp_tmpconfigm4 arednl fully quoted but are still put under an ifdef in case any have beendnl redefined by one of the m4 include files.dnldnl Doing a big ifdef within asm-defs.m4 and/or other macro files wouldn'tdnl work, since it'd interpret parentheses and quotes in dnl comments, anddnl having a whole file as a macro argument would overflow the string spacednl on BSD m4.AC_DEFUN([GMP_FINISH],[AC_REQUIRE([GMP_INIT])echo "creating $gmp_configm4"echo ["d""nl $gmp_configm4. Generated automatically by configure."] > $gmp_configm4if test -f $gmp_tmpconfigm4; thenecho ["changequote(<,>)"] >> $gmp_configm4echo ["ifdef(<__CONFIG_M4_INCLUDED__>,,<"] >> $gmp_configm4cat $gmp_tmpconfigm4 >> $gmp_configm4echo [">)"] >> $gmp_configm4echo ["changequote(\`,')"] >> $gmp_configm4rm $gmp_tmpconfigm4fiecho ["ifdef(\`__CONFIG_M4_INCLUDED__',,\`"] >> $gmp_configm4if test -f $gmp_tmpconfigm4i; thencat $gmp_tmpconfigm4i >> $gmp_configm4rm $gmp_tmpconfigm4ifiif test -f $gmp_tmpconfigm4p; thencat $gmp_tmpconfigm4p >> $gmp_configm4rm $gmp_tmpconfigm4pfiecho ["')"] >> $gmp_configm4echo ["define(\`__CONFIG_M4_INCLUDED__')"] >> $gmp_configm4])dnl GMP_INCLUDE_MPN(FILE)dnl ---------------------dnl Add an include_mpn(`FILE') to config.m4. FILE should be a pathdnl relative to the mpn source directory, for examplednldnl GMP_INCLUDE_MPN(`x86/x86-defs.m4')dnlAC_DEFUN([GMP_INCLUDE_MPN],[AC_REQUIRE([GMP_INIT])echo ["include_mpn(\`$1')"] >> $gmp_tmpconfigm4i])dnl GMP_DEFINE(MACRO, DEFINITION [, LOCATION])dnl ------------------------------------------dnl Define M4 macro MACRO as DEFINITION in temporary file.dnldnl If LOCATION is `POST', the definition will appear after any include()dnl directives inserted by GMP_INCLUDE. Mind the quoting! No shelldnl variables will get expanded. Don't forget to invoke GMP_FINISH todnl create file config.m4. config.m4 uses `<' and '>' as quote charactersdnl for all defines.AC_DEFUN([GMP_DEFINE],[AC_REQUIRE([GMP_INIT])echo ['define(<$1>, <$2>)'] >>ifelse([$3], [POST],$gmp_tmpconfigm4p, $gmp_tmpconfigm4)])dnl GMP_DEFINE_RAW(STRING [, LOCATION])dnl ------------------------------------dnl Put STRING into config.m4 file.dnldnl If LOCATION is `POST', the definition will appear after any include()dnl directives inserted by GMP_INCLUDE. Don't forget to invoke GMP_FINISHdnl to create file config.m4.AC_DEFUN([GMP_DEFINE_RAW],[AC_REQUIRE([GMP_INIT])echo [$1] >> ifelse([$2], [POST], $gmp_tmpconfigm4p, $gmp_tmpconfigm4)])dnl GMP_TRY_ASSEMBLE(asm-code,[action-success][,action-fail])dnl ----------------------------------------------------------dnl Attempt to assemble the given code.dnl Do "action-success" if this succeeds, "action-fail" if not.dnldnl conftest.o and conftest.out are available for inspection indnl "action-success". If either action does a "break" out of a loop thendnl an explicit "rm -f conftest*" will be necessary.dnldnl This is not unlike AC_TRY_COMPILE, but there's no default includes ordnl anything in "asm-code", everything wanted must be given explicitly.AC_DEFUN([GMP_TRY_ASSEMBLE],[cat >conftest.s <<EOF[$1]EOFgmp_assemble="$CCAS $CFLAGS $CPPFLAGS conftest.s >conftest.out 2>&1"if AC_TRY_EVAL(gmp_assemble); thencat conftest.out >&AC_FD_CCifelse([$2],,:,[$2])elsecat conftest.out >&AC_FD_CCecho "configure: failed program was:" >&AC_FD_CCcat conftest.s >&AC_FD_CCifelse([$3],,:,[$3])firm -f conftest*])dnl Checks whether the stack can be marked nonexecutable by passing an optiondnl to the C-compiler when acting on .s files. Appends that option to ASFLAGS.dnl This macro is adapted from one found in GLIBC-2.3.5.AC_DEFUN([CL_AS_NOEXECSTACK],[dnl AC_REQUIRE([AC_PROG_CC]) GMP uses something elseAC_CACHE_CHECK([whether assembler supports --noexecstack option],cl_cv_as_noexecstack, [dnlcat > conftest.c <<EOFvoid foo() {}EOFif AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS-S -o conftest.s conftest.c >/dev/null]) \&& grep .note.GNU-stack conftest.s >/dev/null \&& AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -Wa,--noexecstack-c -o conftest.o conftest.s >/dev/null])thencl_cv_as_noexecstack=yeselsecl_cv_as_noexecstack=nofirm -f conftest*])if test "$cl_cv_as_noexecstack" = yes; thenASMFLAGS="$ASMFLAGS -Wa,--noexecstack"fiAC_SUBST(ASMFLAGS)])dnl GMP_ASM_LABEL_SUFFIXdnl --------------------dnl : - is usual.dnl empty - hppa on HP-UX doesn't use a :, just the label namednldnl Note that it's necessary to test the empty case first, since HP "as"dnl will accept "somelabel:", and take it to mean a label with a name thatdnl happens to end in a colon.AC_DEFUN([GMP_ASM_LABEL_SUFFIX],[AC_REQUIRE([GMP_ASM_TEXT])AC_CACHE_CHECK([for assembler label suffix],gmp_cv_asm_label_suffix,[gmp_cv_asm_label_suffix=unknownfor i in "" ":"; doecho "trying $i" >&AC_FD_CCGMP_TRY_ASSEMBLE([ $gmp_cv_asm_textsomelabel$i],[gmp_cv_asm_label_suffix=$irm -f conftest*break],[cat conftest.out >&AC_FD_CC])doneif test "$gmp_cv_asm_label_suffix" = "unknown"; thenAC_MSG_ERROR([Cannot determine label suffix])fi])echo ["define(<LABEL_SUFFIX>, <$gmp_cv_asm_label_suffix>)"] >> $gmp_tmpconfigm4])dnl GMP_ASM_UNDERSCOREdnl ------------------dnl Determine whether global symbols need to be prefixed with an underscore.dnl The output from "nm" is grepped to see what a typical symbol looks like.dnldnl This test used to grep the .o file directly, but that failed with grepsdnl that don't like binary files (eg. SunOS 4).dnldnl This test also used to construct an assembler file with and without andnl underscore and try to link that to a C file, to see which worked.dnl Although that's what will happen in the real build we don't really wantdnl to depend on creating asm files within configure for every possible CPUdnl (or at least we don't want to do that more than we have to).dnldnl The fallback on no underscore is based on the assumption that the worlddnl is moving towards non-underscore systems. There should actually be nodnl good reason for nm to fail though.AC_DEFUN([GMP_ASM_UNDERSCORE],[AC_REQUIRE([GMP_PROG_NM])AC_CACHE_CHECK([if globals are prefixed by underscore],gmp_cv_asm_underscore,[gmp_cv_asm_underscore="unknown"cat >conftest.c <<EOFint gurkmacka;EOFgmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >&AC_FD_CC"if AC_TRY_EVAL(gmp_compile); then$NM conftest.$OBJEXT >conftest.outif grep _gurkmacka conftest.out >/dev/null; thengmp_cv_asm_underscore=yeselif grep gurkmacka conftest.out >/dev/null; thengmp_cv_asm_underscore=noelseecho "configure: $NM doesn't have gurkmacka:" >&AC_FD_CCcat conftest.out >&AC_FD_CCfielseecho "configure: failed program was:" >&AC_FD_CCcat conftest.c >&AC_FD_CCfirm -f conftest*])case $gmp_cv_asm_underscore inyes)GMP_DEFINE(GSYM_PREFIX, [_]) ;;no)GMP_DEFINE(GSYM_PREFIX, []) ;;*)AC_MSG_WARN([+----------------------------------------------------------])AC_MSG_WARN([| Cannot determine global symbol prefix.])AC_MSG_WARN([| $NM output doesn't contain a global data symbol.])AC_MSG_WARN([| Will proceed with no underscore.])AC_MSG_WARN([| If this is wrong then you'll get link errors referring])AC_MSG_WARN([| to ___gmpn_add_n (note three underscores).])AC_MSG_WARN([| In this case do a fresh build with an override,])AC_MSG_WARN([| ./configure gmp_cv_asm_underscore=yes])AC_MSG_WARN([+----------------------------------------------------------])GMP_DEFINE(GSYM_PREFIX, []);;esac])dnl GMP_ASM_ALIGN_LOGdnl -----------------dnl Is parameter to `.align' logarithmic?AC_DEFUN([GMP_ASM_ALIGN_LOG],[AC_REQUIRE([GMP_ASM_GLOBL])AC_REQUIRE([GMP_ASM_BYTE])AC_REQUIRE([GMP_ASM_DATA])AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])AC_REQUIRE([GMP_PROG_NM])AC_CACHE_CHECK([if .align assembly directive is logarithmic],gmp_cv_asm_align_log,[GMP_TRY_ASSEMBLE([ $gmp_cv_asm_data.align 4$gmp_cv_asm_globl foo$gmp_cv_asm_byte 1.align 4foo$gmp_cv_asm_label_suffix$gmp_cv_asm_byte 2],[gmp_tmp_val=[`$NM conftest.$OBJEXT | grep foo | \sed -e 's;[[][0-9][]]\(.*\);\1;' -e 's;[^1-9]*\([0-9]*\).*;\1;'`]if test "$gmp_tmp_val" = "10" || test "$gmp_tmp_val" = "16"; thengmp_cv_asm_align_log=yeselsegmp_cv_asm_align_log=nofi],[AC_MSG_ERROR([cannot assemble alignment test])])])GMP_DEFINE_RAW(["define(<ALIGN_LOGARITHMIC>,<$gmp_cv_asm_align_log>)"])])dnl GMP_ASM_ALIGN_FILL_0x90dnl -----------------------dnl Determine whether a ",0x90" suffix works on a .align directive.dnl This is only meant for use on x86, 0x90 being a "nop".dnldnl Old gas, eg. 1.92.3dnl Needs ",0x90" or else the fill is 0x00, which can't be executeddnl across.dnldnl New gas, eg. 2.91dnl Generates multi-byte nop fills even when ",0x90" is given.dnldnl Solaris 2.6 asdnl ",0x90" is not allowed, causes a fatal error.dnldnl Solaris 2.8 asdnl ",0x90" does nothing, generates a warning that it's being ignored.dnldnl SCO OpenServer 5 asdnl Second parameter is max bytes to fill, not a fill pattern.dnl ",0x90" is an error due to being bigger than the first parameter.dnl Multi-byte nop fills are generated in text segments.dnldnl Note that both solaris "as"s only care about ",0x90" if they actuallydnl have to use it to fill something, hence the .byte in the test. It'sdnl the second .align which provokes the error or warning.dnldnl The warning from solaris 2.8 is suppressed to stop anyone worrying thatdnl something might be wrong.AC_DEFUN([GMP_ASM_ALIGN_FILL_0x90],[AC_REQUIRE([GMP_ASM_TEXT])AC_CACHE_CHECK([if the .align directive accepts an 0x90 fill in .text],gmp_cv_asm_align_fill_0x90,[GMP_TRY_ASSEMBLE([ $gmp_cv_asm_text.align 4, 0x90.byte 0.align 4, 0x90],[if grep "Warning: Fill parameter ignored for executable section" conftest.out >/dev/null; thenecho "Supressing this warning by omitting 0x90" 1>&AC_FD_CCgmp_cv_asm_align_fill_0x90=noelsegmp_cv_asm_align_fill_0x90=yesfi],[gmp_cv_asm_align_fill_0x90=no])])GMP_DEFINE_RAW(["define(<ALIGN_FILL_0x90>,<$gmp_cv_asm_align_fill_0x90>)"])])dnl GMP_ASM_BYTEdnl ------------dnl .byte - is usual.dnl data1 - required by ia64 (on hpux at least).dnldnl This macro is just to support other configure tests, not any actual asmdnl code.AC_DEFUN([GMP_ASM_BYTE],[AC_REQUIRE([GMP_ASM_TEXT])AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])AC_CACHE_CHECK([for assembler byte directive],gmp_cv_asm_byte,[for i in .byte data1; doecho "trying $i" >&AC_FD_CCGMP_TRY_ASSEMBLE([ $gmp_cv_asm_data$i 0],[gmp_cv_asm_byte=$irm -f conftest*break],[cat conftest.out >&AC_FD_CC])doneif test -z "$gmp_cv_asm_byte"; thenAC_MSG_ERROR([Cannot determine how to emit a data byte])fi])])dnl GMP_ASM_TEXTdnl ------------dnl .text - is usual.dnl .code - is needed by the hppa on HP-UX (but ia64 HP-UX uses .text)dnl .csect .text[PR] - is for AIX.AC_DEFUN([GMP_ASM_TEXT],[AC_CACHE_CHECK([how to switch to text section],gmp_cv_asm_text,[for i in ".text" ".code" [".csect .text[PR]"]; doecho "trying $i" >&AC_FD_CCGMP_TRY_ASSEMBLE([ $i],[gmp_cv_asm_text=$irm -f conftest*break])doneif test -z "$gmp_cv_asm_text"; thenAC_MSG_ERROR([Cannot determine text section directive])fi])echo ["define(<TEXT>, <$gmp_cv_asm_text>)"] >> $gmp_tmpconfigm4])dnl GMP_ASM_DATAdnl ------------dnl Can we say `.data'?AC_DEFUN([GMP_ASM_DATA],[AC_CACHE_CHECK([how to switch to data section],gmp_cv_asm_data,[case $host in*-*-aix*) gmp_cv_asm_data=[".csect .data[RW]"] ;;*) gmp_cv_asm_data=".data" ;;esac])echo ["define(<DATA>, <$gmp_cv_asm_data>)"] >> $gmp_tmpconfigm4])dnl GMP_ASM_RODATAdnl --------------dnl Find out how to switch to the read-only data section.dnldnl The compiler output is grepped for the right directive. It's notdnl considered wise to just probe for ".section .rodata" or whatever works,dnl since arbitrary section names might be accepted, but not necessarily dodnl the right thing when they get to the linker.dnldnl Only a few asm files use RODATA, so this code is perhaps a bitdnl excessive right now, but should find more uses in the future.dnldnl FIXME: gcc on aix generates something like ".csect _foo.ro_c[RO],3"dnl where foo is the object file. Might need to check for that if we usednl RODATA there.AC_DEFUN([GMP_ASM_RODATA],[AC_REQUIRE([GMP_ASM_TEXT])AC_REQUIRE([GMP_ASM_DATA])AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])AC_REQUIRE([GMP_ASM_UNDERSCORE])AC_CACHE_CHECK([how to switch to read-only data section],gmp_cv_asm_rodata,[dnl Default to DATA on CPUs with split code/data caching, and TEXTdnl elsewhere. i386 means generic x86, so use DATA on it.case $host inX86_PATTERN | x86_64-*-*)gmp_cv_asm_rodata="$gmp_cv_asm_data" ;;*)gmp_cv_asm_rodata="$gmp_cv_asm_text" ;;esaccat >conftest.c <<EOFconst int foo = 123;EOFecho "Test program:" >&AC_FD_CCcat conftest.c >&AC_FD_CCgmp_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c >&AC_FD_CC"if AC_TRY_EVAL(gmp_compile); thenecho "Compiler output:" >&AC_FD_CCcat conftest.s >&AC_FD_CCif test $gmp_cv_asm_underscore = yes; thentmp_gsym_prefix=_elsetmp_gsym_prefix=fi# must see our labelif grep "^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix" conftest.s >/dev/null 2>&AC_FD_CC; then# take the last directive before our label (hence skipping segments# getting debugging info etc)tmp_match=`sed -n ["/^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix/q/^[. ]*data/p/^[. ]*rdata/p/^[. ]*text/p/^[. ]*section/p/^[. ]*csect/p/^[. ]*CSECT/p"] conftest.s | sed -n '$p'`echo "Match: $tmp_match" >&AC_FD_CCif test -n "$tmp_match"; thengmp_cv_asm_rodata=$tmp_matchfielseecho "Couldn't find label: ^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix" >&AC_FD_CCfifirm -f conftest*])echo ["define(<RODATA>, <$gmp_cv_asm_rodata>)"] >> $gmp_tmpconfigm4])dnl GMP_ASM_GLOBLdnl -------------dnl The assembler directive to mark a label as a global symbol.dnldnl ia64 - .global is standard, according to the Intel documentation.dnldnl hppa - ".export foo,entry" is demanded by HP hppa "as". ".global" is adnl kind of import.dnldnl other - .globl is usual.dnldnl "gas" tends to accept .globl everywhere, in addition to .export ordnl .global or whatever the system assembler demands.AC_DEFUN([GMP_ASM_GLOBL],[AC_REQUIRE([GMP_ASM_TEXT])AC_CACHE_CHECK([for assembler global directive],gmp_cv_asm_globl,[case $host inhppa*-*-*) gmp_cv_asm_globl=.export ;;IA64_PATTERN) gmp_cv_asm_globl=.global ;;*) gmp_cv_asm_globl=.globl ;;esac])echo ["define(<GLOBL>, <$gmp_cv_asm_globl>)"] >> $gmp_tmpconfigm4])dnl GMP_ASM_GLOBL_ATTRdnl ------------------dnl Do we need something after `GLOBL symbol'?AC_DEFUN([GMP_ASM_GLOBL_ATTR],[AC_REQUIRE([GMP_ASM_GLOBL])AC_CACHE_CHECK([for assembler global directive attribute],gmp_cv_asm_globl_attr,[case $gmp_cv_asm_globl in.export) gmp_cv_asm_globl_attr=",entry" ;;*) gmp_cv_asm_globl_attr="" ;;esac])echo ["define(<GLOBL_ATTR>, <$gmp_cv_asm_globl_attr>)"] >> $gmp_tmpconfigm4])dnl GMP_ASM_TYPEdnl ------------dnl Can we say ".type", and how?dnldnl For i386 GNU/Linux ELF systems, and very likely other ELF systems,dnl .type and .size are important on functions in shared libraries. Ifdnl .type is omitted and the mainline program references that function thendnl the code will be copied down to the mainline at load time like a piecednl of data. If .size is wrong or missing (it defaults to 4 bytes or somednl such) then incorrect bytes will be copied and a segv is the most likelydnl result. In any case such copying is not what's wanted, a .typednl directive will ensure a PLT entry is used.dnldnl In GMP the assembler functions are normally only used from within thednl library (since most programs are not interested in the low leveldnl routines), and in those circumstances a missing .type isn't fatal,dnl letting the problem go unnoticed. tests/mpn/t-asmtype.c aims to checkdnl for it.AC_DEFUN([GMP_ASM_TYPE],[AC_CACHE_CHECK([for assembler .type directive],gmp_cv_asm_type,[gmp_cv_asm_type=for gmp_tmp_prefix in @ \# %; doGMP_TRY_ASSEMBLE([ .type sym,${gmp_tmp_prefix}function],[if grep "\.type pseudo-op used outside of \.def/\.endef ignored" conftest.out >/dev/null; then : ;elsegmp_cv_asm_type=".type \$][1,${gmp_tmp_prefix}\$][2"breakfi])donerm -f conftest*])echo ["define(<TYPE>, <$gmp_cv_asm_type>)"] >> $gmp_tmpconfigm4])dnl GMP_ASM_SIZEdnl ------------dnl Can we say `.size'?AC_DEFUN([GMP_ASM_SIZE],[AC_CACHE_CHECK([for assembler .size directive],gmp_cv_asm_size,[gmp_cv_asm_size=GMP_TRY_ASSEMBLE([ .size sym,1],[if grep "\.size pseudo-op used outside of \.def/\.endef ignored" conftest.out >/dev/null; then : ;elsegmp_cv_asm_size=".size \$][1,\$][2"fi])])echo ["define(<SIZE>, <$gmp_cv_asm_size>)"] >> $gmp_tmpconfigm4])dnl GMP_ASM_COFF_TYPEdnl -----------------dnl Determine whether the assembler supports COFF type information.dnldnl Currently this is only needed for mingw (and cygwin perhaps) and so isdnl run only on the x86s, but it ought to work anywhere.dnldnl On MINGW, recent versions of the linker have an automatic import schemednl for data in a DLL which is referenced by a mainline but withoutdnl __declspec (__dllimport__) on the prototype. It seems functionsdnl without type information are treated as data, or something, and callsdnl to them from the mainline will crash. gcc puts type information on thednl C functions it generates, we need to do the same for assemblerdnl functions.dnldnl This applies only to functions without __declspec(__dllimport__),dnl ie. without __GMP_DECLSPEC in the case of libgmp, so it also works justdnl to ensure all assembler functions used from outside libgmp havednl __GMP_DECLSPEC on their prototypes. But this isn't an ideal situation,dnl since we don't want perfectly valid calls going wrong just becausednl there wasn't a prototype in scope.dnldnl When an auto-import takes place, the following warning is given by thednl linker. This shouldn't be seen for any functions.dnldnl Info: resolving _foo by linking to __imp__foo (auto-import)dnldnldnl COFF type directives look like the followingdnldnl .def _foodnl .scl 2dnl .type 32dnl .endefdnldnl _foo is the symbol with GSYM_PREFIX (_). .scl is the storage class, 2dnl for external, 3 for static. .type is the object type, 32 for adnl function.dnldnl On an ELF system, this is (correctly) rejected due to .def, .endef anddnl .scl being invalid, and .type not having enough arguments.AC_DEFUN([GMP_ASM_COFF_TYPE],[AC_REQUIRE([GMP_ASM_TEXT])AC_REQUIRE([GMP_ASM_GLOBL])AC_REQUIRE([GMP_ASM_GLOBL_ATTR])AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])AC_REQUIRE([GMP_ASM_UNDERSCORE])AC_CACHE_CHECK([for assembler COFF type directives],gmp_cv_asm_x86_coff_type,[GMP_TRY_ASSEMBLE([ $gmp_cv_asm_text$gmp_cv_asm_globl ${tmp_gsym_prefix}foo$gmp_cv_asm_globl_attr.def ${tmp_gsym_prefix}foo.scl 2.type 32.endef${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix],[gmp_cv_asm_x86_coff_type=yes],[gmp_cv_asm_x86_coff_type=no])])echo ["define(<HAVE_COFF_TYPE>, <$gmp_cv_asm_x86_coff_type>)"] >> $gmp_tmpconfigm4])dnl GMP_ASM_LSYM_PREFIXdnl -------------------dnl What is the prefix for a local label?dnldnl The prefixes tested are,dnldnl L - usual for underscore systemsdnl .L - usual for non-underscore systemsdnl $ - alpha (gas and OSF system assembler)dnl L$ - hppa (gas and HP-UX system assembler)dnldnl The default is "L" if the tests fail for any reason. There's a gooddnl chance this will be adequate, since on most systems labels are localdnl anyway unless given a ".globl", and an "L" will avoid clashes withdnl other identifers.dnldnl For gas, ".L" is normally purely local to the assembler, it doesn't getdnl put into the object file at all. This style is preferred, to keep thednl object files nice and clean.dnldnl BSD format nm produces a line likednldnl 00000000 t Lgurkmackadnldnl The symbol code is normally "t" for text, but any lower case letterdnl indicates a local definition.dnldnl Code "n" is for a debugging symbol, OSF "nm -B" gives that as an upperdnl case "N" for a local.dnldnl HP-UX nm prints an error message (though seems to give a 0 exit) ifdnl there's no symbols at all in an object file, hence the use of "dummy".AC_DEFUN([GMP_ASM_LSYM_PREFIX],[AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])AC_REQUIRE([GMP_ASM_TEXT])AC_REQUIRE([GMP_PROG_NM])AC_CACHE_CHECK([for assembler local label prefix],gmp_cv_asm_lsym_prefix,[gmp_tmp_pre_appears=yesfor gmp_tmp_pre in L .L $L $ L$; doecho "Trying $gmp_tmp_pre" >&AC_FD_CCGMP_TRY_ASSEMBLE([ $gmp_cv_asm_textdummy${gmp_cv_asm_label_suffix}${gmp_tmp_pre}gurkmacka${gmp_cv_asm_label_suffix}],[if $NM conftest.$OBJEXT >conftest.nm 2>&AC_FD_CC; then : ; elsecat conftest.nm >&AC_FD_CCAC_MSG_WARN(["$NM" failure])breakficat conftest.nm >&AC_FD_CCif grep gurkmacka conftest.nm >/dev/null; then : ; else# no mention of the symbol, this is goodecho "$gmp_tmp_pre label doesn't appear in object file at all (good)" >&AC_FD_CCgmp_cv_asm_lsym_prefix="$gmp_tmp_pre"gmp_tmp_pre_appears=nobreakfiif grep [' [a-zN] .*gurkmacka'] conftest.nm >/dev/null; then# symbol mentioned as a local, use this if nothing betterecho "$gmp_tmp_pre label is local but still in object file" >&AC_FD_CCif test -z "$gmp_cv_asm_lsym_prefix"; thengmp_cv_asm_lsym_prefix="$gmp_tmp_pre"fielseecho "$gmp_tmp_pre label is something unknown" >&AC_FD_CCfi])donerm -f conftest*if test -z "$gmp_cv_asm_lsym_prefix"; thengmp_cv_asm_lsym_prefix=LAC_MSG_WARN([cannot determine local label, using default $gmp_cv_asm_lsym_prefix])fi# for development purposes, note whether we got a purely temporary local labelecho "Local label appears in object files: $gmp_tmp_pre_appears" >&AC_FD_CC])echo ["define(<LSYM_PREFIX>, <${gmp_cv_asm_lsym_prefix}>)"] >> $gmp_tmpconfigm4AC_DEFINE_UNQUOTED(LSYM_PREFIX, "$gmp_cv_asm_lsym_prefix",[Assembler local label prefix])])dnl GMP_ASM_W32dnl -----------dnl How to define a 32-bit word.dnldnl FIXME: This test is not right for ia64-*-hpux*. The directive shoulddnl be "data4", but the W32 macro is not currently used by the mpn/ia64 asmdnl files.AC_DEFUN([GMP_ASM_W32],[AC_REQUIRE([GMP_ASM_DATA])AC_REQUIRE([GMP_ASM_BYTE])AC_REQUIRE([GMP_ASM_GLOBL])AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])AC_REQUIRE([GMP_PROG_NM])AC_CACHE_CHECK([how to define a 32-bit word],gmp_cv_asm_w32,[case $host in*-*-hpux*)# FIXME: HPUX puts first symbol at 0x40000000, breaking our assumption# that it's at 0x0. We'll have to declare another symbol before the# .long/.word and look at the distance between the two symbols. The# only problem is that the sed expression(s) barfs (on Solaris, for# example) for the symbol with value 0. For now, HPUX uses .word.gmp_cv_asm_w32=".word";;*-*-*)gmp_tmp_val=for gmp_tmp_op in .long .word data4; doGMP_TRY_ASSEMBLE([ $gmp_cv_asm_data$gmp_cv_asm_globl foo$gmp_tmp_op 0foo$gmp_cv_asm_label_suffix$gmp_cv_asm_byte 0],[gmp_tmp_val=[`$NM conftest.$OBJEXT | grep foo | \sed -e 's;[[][0-9][]]\(.*\);\1;' -e 's;[^1-9]*\([0-9]*\).*;\1;'`]if test "$gmp_tmp_val" = 4; thengmp_cv_asm_w32="$gmp_tmp_op"breakfi])donerm -f conftest*;;esacif test -z "$gmp_cv_asm_w32"; thenAC_MSG_ERROR([cannot determine how to define a 32-bit word])fi])echo ["define(<W32>, <$gmp_cv_asm_w32>)"] >> $gmp_tmpconfigm4])dnl GMP_X86_ASM_GOT_UNDERSCOREdnl --------------------------dnl Determine whether i386 _GLOBAL_OFFSET_TABLE_ needs an additionaldnl underscore prefix.dnldnl SVR4 - the standard is _GLOBAL_OFFSET_TABLE_dnl GNU/Linux - follows SVR4dnl OpenBSD - an a.out underscore system, uses __GLOBAL_OFFSET_TABLE_dnl NetBSD - also an a.out underscore system, but _GLOBAL_OFFSET_TABLE_dnldnl The test attempts to link a program using _GLOBAL_OFFSET_TABLE_ ordnl __GLOBAL_OFFSET_TABLE_ to see which works.dnldnl $lt_prog_compiler_pic is included in the compile because old versionsdnl of gas wouldn't accept PIC idioms without the right option (-K). Thisdnl is the same as what libtool and mpn/Makeasm.am will do.dnldnl $lt_prog_compiler_pic is also included in the link because OpenBSD lddnl won't accept an R_386_GOTPC relocation without the right options. Thisdnl is not what's done by the Makefiles when building executables, butdnl let's hope it's ok (it works fine with gcc).dnldnl The fallback is no additional underscore, on the basis that this willdnl suit SVR4/ELF style systems, which should be much more common thandnl a.out systems with shared libraries.dnldnl Note that it's not an error for the tests to fail, since for instancednl cygwin, mingw and djgpp don't have a _GLOBAL_OFFSET_TABLE_ scheme atdnl all.dnldnl Perhaps $CCAS could be asked to do the linking as well as thednl assembling, but in the Makefiles it's only used for assembling, so letsdnl keep it that way.dnldnl The test here is run even under --disable-shared, so that PIC objectsdnl can be built and tested by the tune/many.pl development scheme. Thednl tests will be reasonably quick and won't give a fatal error, so thisdnl arrangement is ok. AC_LIBTOOL_PROG_COMPILER_PIC does itsdnl $lt_prog_compiler_pic setups even for --disable-shared too.AC_DEFUN([GMP_ASM_X86_GOT_UNDERSCORE],[AC_REQUIRE([GMP_ASM_TEXT])AC_REQUIRE([GMP_ASM_GLOBL])AC_REQUIRE([GMP_ASM_GLOBL_ATTR])AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])AC_REQUIRE([GMP_ASM_UNDERSCORE])AC_REQUIRE([AC_LIBTOOL_PROG_COMPILER_PIC])AC_CACHE_CHECK([if _GLOBAL_OFFSET_TABLE_ is prefixed by underscore],gmp_cv_asm_x86_got_underscore,[gmp_cv_asm_x86_got_underscore="not applicable"if test $gmp_cv_asm_underscore = yes; thentmp_gsym_prefix=_elsetmp_gsym_prefix=fifor tmp_underscore in "" "_"; docat >conftest.s <<EOF$gmp_cv_asm_text$gmp_cv_asm_globl ${tmp_gsym_prefix}main$gmp_cv_asm_globl_attr${tmp_gsym_prefix}main$gmp_cv_asm_label_suffixaddl $ ${tmp_underscore}_GLOBAL_OFFSET_TABLE_, %ebxEOFgmp_compile="$CCAS $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.s >&AC_FD_CC && $CC $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.$OBJEXT >&AC_FD_CC"if AC_TRY_EVAL(gmp_compile); thenif test "$tmp_underscore" = "_"; thengmp_cv_asm_x86_got_underscore=yeselsegmp_cv_asm_x86_got_underscore=nofibreakfidonerm -f conftest* a.out b.out a.exe a_out.exe])if test "$gmp_cv_asm_x86_got_underscore" = "yes"; thenGMP_DEFINE(GOT_GSYM_PREFIX, [_])elseGMP_DEFINE(GOT_GSYM_PREFIX, [])fi])dnl GMP_ASM_X86_GOT_EAX_OK(CC+CFLAGS, [ACTION-YES] [, ACTION-NO])dnl -------------------------------------------------------------dnl Determine whether _GLOBAL_OFFSET_TABLE_ used with %eax is ok.dnldnl An instructiondnldnl addl $_GLOBAL_OFFSET_TABLE_, %eaxdnldnl is incorrectly assembled by gas 2.12 (or thereabouts) and earlier. Itdnl puts an addend 2 into the R_386_GOTPC relocation, but it should be 1dnl for this %eax form being a 1 byte opcode (with other registers it's 2dnl opcode bytes). See note about this in mpn/x86/README too.dnldnl We assemble this, surrounded by some unlikely byte sequences asdnl delimiters, and check for the bad output.dnldnl This is for use by compiler probing in GMP_PROG_CC_WORKS, so the resultdnl is not cached.dnldnl This test is not specific to gas, but old gas is the only assembler wednl know of with this problem. The Solaris has been seen coming out ok.dnldnl ".text" is hard coded because this macro is wanted before GMP_ASM_TEXT.dnl This should be fine, ".text" is normal on x86 systems, and certainlydnl will be fine with the offending gas.dnldnl If an error occurs when assembling, we consider the assembler ok, sincednl the bad output does not occur. This happens for instance on mingw,dnl where _GLOBAL_OFFSET_TABLE_ results in a bfd error, since there's nodnl GOT etc in PE object files.dnldnl This test is used before the object file extension has been determined,dnl so we force output to conftest.o. Using -o with -c is not portable,dnl but we think all x86 compilers will accept -o with -c, certainly gccdnl does.dnldnl -fPIC is hard coded here, because this test is for use before libtooldnl has established the pic options. It's right for gcc, but perhaps notdnl other compilers.AC_DEFUN([GMP_ASM_X86_GOT_EAX_OK],[echo "Testing gas GOT with eax good" >&AC_FD_CCcat >conftest.awk <<\EOF[BEGIN {want[0] = "001"want[1] = "043"want[2] = "105"want[3] = "147"want[4] = "211"want[5] = "253"want[6] = "315"want[7] = "357"want[8] = "005"want[9] = "002"want[10] = "000"want[11] = "000"want[12] = "000"want[13] = "376"want[14] = "334"want[15] = "272"want[16] = "230"want[17] = "166"want[18] = "124"want[19] = "062"want[20] = "020"result = "yes"}{for (f = 2; f <= NF; f++){for (i = 0; i < 20; i++)got[i] = got[i+1];got[20] = $f;found = 1for (i = 0; i < 21; i++)if (got[i] != want[i]){found = 0break}if (found){result = "no"exit}}}END {print result}]EOFcat >conftest.s <<\EOF[ .text.byte 1, 35, 69, 103, 137, 171, 205, 239addl $_GLOBAL_OFFSET_TABLE_, %eax.byte 254, 220, 186, 152, 118, 84, 50, 16]EOFtmp_got_good=yesgmp_compile="$1 -fPIC -o conftest.o -c conftest.s >&AC_FD_CC 2>&1"if AC_TRY_EVAL(gmp_compile); thentmp_got_good=`od -b conftest.o | $AWK -f conftest.awk`firm -f conftest.*echo "Result: $tmp_got_good" >&AC_FD_CCif test "$tmp_got_good" = no; thenifelse([$3],,:,[$3])elseifelse([$2],,:,[$2])fi])dnl GMP_ASM_X86_MMX([ACTION-IF-YES][,ACTION-IF-NO])dnl -----------------------------------------------dnl Determine whether the assembler supports MMX instructions.dnldnl This macro is wanted before GMP_ASM_TEXT, so ".text" is hard codeddnl here. ".text" is believed to be correct on all x86 systems. Actuallydnl ".text" probably isn't needed at all, at least for just checkingdnl instruction syntax.dnldnl "movq %mm0, %mm1" should assemble to "0f 6f c8", but Solaris 2.6 anddnl 2.7 wrongly assemble it to "0f 6f c1" (that being the reverse "movqdnl %mm1, %mm0"). It seems more trouble than it's worth to work arounddnl this in the code, so just detect and reject.AC_DEFUN([GMP_ASM_X86_MMX],[AC_CACHE_CHECK([if the assembler knows about MMX instructions],gmp_cv_asm_x86_mmx,[GMP_TRY_ASSEMBLE([ .textmovq %mm0, %mm1],[gmp_cv_asm_x86_mmx=yescase $host in*-*-solaris*)if (dis conftest.$OBJEXT >conftest.out) 2>/dev/null; thenif grep "0f 6f c1" conftest.out >/dev/null; thengmp_cv_asm_x86_mmx=movq-bugfielseAC_MSG_WARN(["dis" not available to check for "as" movq bug])fiesac],[gmp_cv_asm_x86_mmx=no])])case $gmp_cv_asm_x86_mmx inmovq-bug)AC_MSG_WARN([+----------------------------------------------------------])AC_MSG_WARN([| WARNING WARNING WARNING])AC_MSG_WARN([| Host CPU has MMX code, but the assembler])AC_MSG_WARN([| $CCAS $CFLAGS $CPPFLAGS])AC_MSG_WARN([| has the Solaris 2.6 and 2.7 bug where register to register])AC_MSG_WARN([| movq operands are reversed.])AC_MSG_WARN([| Non-MMX replacements will be used.])AC_MSG_WARN([| This will be an inferior build.])AC_MSG_WARN([+----------------------------------------------------------]);;no)AC_MSG_WARN([+----------------------------------------------------------])AC_MSG_WARN([| WARNING WARNING WARNING])AC_MSG_WARN([| Host CPU has MMX code, but it can't be assembled by])AC_MSG_WARN([| $CCAS $CFLAGS $CPPFLAGS])AC_MSG_WARN([| Non-MMX replacements will be used.])AC_MSG_WARN([| This will be an inferior build.])AC_MSG_WARN([+----------------------------------------------------------]);;esacif test "$gmp_cv_asm_x86_mmx" = yes; thenifelse([$1],,:,[$1])elseifelse([$2],,:,[$2])fi])dnl GMP_ASM_X86_SHLDL_CLdnl --------------------AC_DEFUN([GMP_ASM_X86_SHLDL_CL],[AC_REQUIRE([GMP_ASM_TEXT])AC_CACHE_CHECK([if the assembler takes cl with shldl],gmp_cv_asm_x86_shldl_cl,[GMP_TRY_ASSEMBLE([ $gmp_cv_asm_textshldl %cl, %eax, %ebx],gmp_cv_asm_x86_shldl_cl=yes,gmp_cv_asm_x86_shldl_cl=no)])if test "$gmp_cv_asm_x86_shldl_cl" = "yes"; thenGMP_DEFINE(WANT_SHLDL_CL,1)elseGMP_DEFINE(WANT_SHLDL_CL,0)fi])dnl GMP_ASM_X86_SSE2([ACTION-IF-YES][,ACTION-IF-NO])dnl ------------------------------------------------dnl Determine whether the assembler supports SSE2 instructions.dnldnl This macro is wanted before GMP_ASM_TEXT, so ".text" is hard codeddnl here. ".text" is believed to be correct on all x86 systems, certainlydnl it's all GMP_ASM_TEXT gives currently. Actually ".text" probably isn'tdnl needed at all, at least for just checking instruction syntax.AC_DEFUN([GMP_ASM_X86_SSE2],[AC_CACHE_CHECK([if the assembler knows about SSE2 instructions],gmp_cv_asm_x86_sse2,[GMP_TRY_ASSEMBLE([ .textpaddq %mm0, %mm1],[gmp_cv_asm_x86_sse2=yes],[gmp_cv_asm_x86_sse2=no])])case $gmp_cv_asm_x86_sse2 inyes)ifelse([$1],,:,[$1]);;*)AC_MSG_WARN([+----------------------------------------------------------])AC_MSG_WARN([| WARNING WARNING WARNING])AC_MSG_WARN([| Host CPU has SSE2 code, but it can't be assembled by])AC_MSG_WARN([| $CCAS $CFLAGS $CPPFLAGS])AC_MSG_WARN([| Non-SSE2 replacements will be used.])AC_MSG_WARN([| This will be an inferior build.])AC_MSG_WARN([+----------------------------------------------------------])ifelse([$2],,:,[$2]);;esac])dnl GMP_ASM_X86_MCOUNTdnl ------------------dnl Find out how to call mcount for profiling on an x86 system.dnldnl A dummy function is compiled and the ".s" output examined. The patterndnl matching might be a bit fragile, but should work at least with gcc ondnl sensible systems. Certainly it's better than hard coding a table ofdnl conventions.dnldnl For non-PIC, any ".data" is taken to mean a counter might be passed.dnl It's assumed a movl will set it up, and the right register is takendnl from that movl. Any movl involving %esp is ignored (a frame pointerdnl setup normally).dnldnl For PIC, any ".data" is similarly interpreted, but a GOTOFF identifiesdnl the line setting up the right register.dnldnl In both cases a line with "mcount" identifies the call and that line isdnl used literally.dnldnl On some systems (eg. FreeBSD 3.5) gcc emits ".data" but doesn't use it,dnl so it's not an error to have .data but then not find a register.dnldnl Variations in mcount conventions on different x86 systems can be founddnl in gcc config/i386. mcount can have a "_" prefix or be .mcount ordnl _mcount_ptr, and for PIC it can be called through a GOT entry, or viadnl the PLT. If a pointer to a counter is required it's passed in %eax ordnl %edx.dnldnl Flags to specify PIC are taken from $lt_prog_compiler_pic set bydnl AC_PROG_LIBTOOL.dnldnl Enhancement: Cache the values determined here. But what's the right waydnl to get two variables (mcount_nonpic_reg and mcount_nonpic_call say) setdnl from one block of commands?AC_DEFUN([GMP_ASM_X86_MCOUNT],[AC_REQUIRE([AC_ENABLE_SHARED])AC_REQUIRE([AC_PROG_LIBTOOL])AC_MSG_CHECKING([how to call x86 mcount])cat >conftest.c <<EOFfoo(){bar();}EOFif test "$enable_static" = yes; thengmp_asmout_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c 1>&AC_FD_CC"if AC_TRY_EVAL(gmp_asmout_compile); thenif grep '\.data' conftest.s >/dev/null; thenmcount_nonpic_reg=`sed -n ['/esp/!s/.*movl.*,\(%[a-z]*\).*$/\1/p'] conftest.s`elsemcount_nonpic_reg=fimcount_nonpic_call=`grep 'call.*mcount' conftest.s`if test -z "$mcount_nonpic_call"; thenAC_MSG_ERROR([Cannot find mcount call for non-PIC])fielseAC_MSG_ERROR([Cannot compile test program for non-PIC])fifiif test "$enable_shared" = yes; thengmp_asmout_compile="$CC $CFLAGS $CPPFLAGS $lt_prog_compiler_pic -S conftest.c 1>&AC_FD_CC"if AC_TRY_EVAL(gmp_asmout_compile); thenif grep '\.data' conftest.s >/dev/null; thencase $lt_prog_compiler_pic in*-DDLL_EXPORT*)# Windows DLLs have non-PIC style mcountmcount_pic_reg=`sed -n ['/esp/!s/.*movl.*,\(%[a-z]*\).*$/\1/p'] conftest.s`;;*)mcount_pic_reg=`sed -n ['s/.*GOTOFF.*,\(%[a-z]*\).*$/\1/p'] conftest.s`;;esacelsemcount_pic_reg=fimcount_pic_call=`grep 'call.*mcount' conftest.s`if test -z "$mcount_pic_call"; thenAC_MSG_ERROR([Cannot find mcount call for PIC])fielseAC_MSG_ERROR([Cannot compile test program for PIC])fifiGMP_DEFINE_RAW(["define(<MCOUNT_NONPIC_REG>, <\`$mcount_nonpic_reg'>)"])GMP_DEFINE_RAW(["define(<MCOUNT_NONPIC_CALL>,<\`$mcount_nonpic_call'>)"])GMP_DEFINE_RAW(["define(<MCOUNT_PIC_REG>, <\`$mcount_pic_reg'>)"])GMP_DEFINE_RAW(["define(<MCOUNT_PIC_CALL>, <\`$mcount_pic_call'>)"])rm -f conftest.*AC_MSG_RESULT([determined])])dnl GMP_ASM_IA64_ALIGN_OKdnl ---------------------dnl Determine whether .align correctly pads with nop instructions in a textdnl segment.dnldnl gas 2.14 and earlier byte swaps its padding bundle on big endiandnl systems, which is incorrect (endianness only changes data). Whatdnl should be "nop.m / nop.f / nop.i" comes out as "break" instructions.dnldnl The test here detects the bad case, and assumes anything else is okdnl (there are many sensible nop bundles, so it'd be impractical to try todnl match everything good).AC_DEFUN([GMP_ASM_IA64_ALIGN_OK],[AC_CACHE_CHECK([whether assembler .align padding is good],gmp_cv_asm_ia64_align_ok,[cat >conftest.awk <<\EOF[BEGIN {want[0] = "011"want[1] = "160"want[2] = "074"want[3] = "040"want[4] = "000"want[5] = "040"want[6] = "020"want[7] = "221"want[8] = "114"want[9] = "000"want[10] = "100"want[11] = "200"want[12] = "122"want[13] = "261"want[14] = "000"want[15] = "200"want[16] = "000"want[17] = "004"want[18] = "000"want[19] = "000"want[20] = "000"want[21] = "000"want[22] = "002"want[23] = "000"want[24] = "000"want[25] = "000"want[26] = "000"want[27] = "001"want[28] = "000"want[29] = "000"want[30] = "000"want[31] = "014"want[32] = "011"want[33] = "270"want[34] = "140"want[35] = "062"want[36] = "000"want[37] = "040"want[38] = "240"want[39] = "331"want[40] = "160"want[41] = "000"want[42] = "100"want[43] = "240"want[44] = "343"want[45] = "371"want[46] = "000"want[47] = "200"result = "yes"}{for (f = 2; f <= NF; f++){for (i = 0; i < 47; i++)got[i] = got[i+1];got[47] = $f;found = 1for (i = 0; i < 48; i++)if (got[i] != want[i]){found = 0break}if (found){result = "no"exit}}}END {print result}]EOFGMP_TRY_ASSEMBLE([ .text.align 32{ .mmi; add r14 = r15, r16add r17 = r18, r19add r20 = r21, r22 ;; }.align 32{ .mmi; add r23 = r24, r25add r26 = r27, r28add r29 = r30, r31 ;; }],[gmp_cv_asm_ia64_align_ok=`od -b conftest.$OBJEXT | $AWK -f conftest.awk`],[AC_MSG_WARN([oops, cannot compile test program])gmp_cv_asm_ia64_align_ok=yes])])GMP_DEFINE_RAW(["define(<IA64_ALIGN_OK>, <\`$gmp_cv_asm_ia64_align_ok'>)"])])dnl GMP_ASM_M68K_INSTRUCTIONdnl ------------------------dnl Not sure if ".l" and "%" are independent settings, but it doesn't hurtdnl to try all four possibilities. Note that the % ones must be first, sodnl "d0" won't be interpreted as a label.dnldnl gas 1.92.3 on NetBSD 1.4 needs to be tested with a two operanddnl instruction. It takes registers without "%", but a single operanddnl "clrl %d0" only gives a warning, not an error.AC_DEFUN([GMP_ASM_M68K_INSTRUCTION],[AC_REQUIRE([GMP_ASM_TEXT])AC_CACHE_CHECK([assembler instruction and register style],gmp_cv_asm_m68k_instruction,[for i in "addl %d0,%d1" "add.l %d0,%d1" "addl d0,d1" "add.l d0,d1"; doGMP_TRY_ASSEMBLE([ $gmp_cv_asm_text$i],[gmp_cv_asm_m68k_instruction=$irm -f conftest*break])doneif test -z "$gmp_cv_asm_m68k_instruction"; thenAC_MSG_ERROR([cannot determine assembler instruction and register style])fi])case $gmp_cv_asm_m68k_instruction in"addl d0,d1") want_dot_size=no; want_register_percent=no ;;"addl %d0,%d1") want_dot_size=no; want_register_percent=yes ;;"add.l d0,d1") want_dot_size=yes; want_register_percent=no ;;"add.l %d0,%d1") want_dot_size=yes; want_register_percent=yes ;;*) AC_MSG_ERROR([oops, unrecognised instruction and register style]) ;;esacGMP_DEFINE_RAW(["define(<WANT_REGISTER_PERCENT>, <\`$want_register_percent'>)"])GMP_DEFINE_RAW(["define(<WANT_DOT_SIZE>, <\`$want_dot_size'>)"])])dnl GMP_ASM_M68K_ADDRESSINGdnl -----------------------AC_DEFUN([GMP_ASM_M68K_ADDRESSING],[AC_REQUIRE([GMP_ASM_TEXT])AC_REQUIRE([GMP_ASM_M68K_INSTRUCTION])AC_CACHE_CHECK([assembler addressing style],gmp_cv_asm_m68k_addressing,[case $gmp_cv_asm_m68k_instruction inaddl*) movel=movel ;;add.l*) movel=move.l ;;*) AC_MSG_ERROR([oops, unrecognised gmp_cv_asm_m68k_instruction]) ;;esaccase $gmp_cv_asm_m68k_instruction in*"%d0,%d1") dreg=%d0; areg=%a0 ;;*"d0,d1") dreg=d0; areg=a0 ;;*) AC_MSG_ERROR([oops, unrecognised gmp_cv_asm_m68k_instruction]) ;;esacGMP_TRY_ASSEMBLE([ $gmp_cv_asm_text$movel $dreg, $areg@-],[gmp_cv_asm_m68k_addressing=mit],[GMP_TRY_ASSEMBLE([ $gmp_cv_asm_text$movel $dreg, -($areg)],[gmp_cv_asm_m68k_addressing=motorola],[AC_MSG_ERROR([cannot determine assembler addressing style])])])])GMP_DEFINE_RAW(["define(<WANT_ADDRESSING>, <\`$gmp_cv_asm_m68k_addressing'>)"])])dnl GMP_ASM_M68K_BRANCHESdnl ---------------------dnl "bra" is the standard branch instruction. "jra" or "jbra" arednl preferred where available, since on gas for instance they give adnl displacement only as big as it needs to be, whereas "bra" is alwaysdnl 16-bits. This applies to the conditional branches "bcc" etc too.dnl However "dbcc" etc on gas are already only as big as they need to be.AC_DEFUN([GMP_ASM_M68K_BRANCHES],[AC_REQUIRE([GMP_ASM_TEXT])AC_CACHE_CHECK([assembler shortest branches],gmp_cv_asm_m68k_branches,[for i in jra jbra bra; doGMP_TRY_ASSEMBLE([ $gmp_cv_asm_textfoo$gmp_cv_asm_label_suffix$i foo],[gmp_cv_asm_m68k_branches=$irm -f conftest*break])doneif test -z "$gmp_cv_asm_m68k_branches"; thenAC_MSG_ERROR([cannot determine assembler branching style])fi])GMP_DEFINE_RAW(["define(<WANT_BRANCHES>, <\`$gmp_cv_asm_m68k_branches'>)"])])dnl GMP_ASM_POWERPC_PIC_ALWAYSdnl --------------------------dnl Determine whether PIC is the default compiler output.dnldnl SVR4 style "foo@ha" addressing is interpreted as non-PIC, and anythingdnl else is assumed to require PIC always (Darwin or AIX). SVR4 is thednl only non-PIC addressing syntax the asm files have at the moment anyway.dnldnl Libtool does this by taking "*-*-aix* | *-*-darwin* | *-*-rhapsody*" todnl mean PIC always, but it seems more reliable to grep the compilerdnl output.dnldnl The next paragraph is untrue for Tiger. Was it ever true? For tiger,dnl "cc -fast" makes non-PIC the default (and the binaries do run).dnl On Darwin "cc -static" is non-PIC with syntax "ha16(_foo)", but that'sdnl apparently only for use in the kernel, which we're not attempting todnl target at the moment, so don't look for that.AC_DEFUN([GMP_ASM_POWERPC_PIC_ALWAYS],[AC_REQUIRE([AC_PROG_CC])AC_CACHE_CHECK([whether compiler output is PIC by default],gmp_cv_asm_powerpc_pic,[gmp_cv_asm_powerpc_pic=yescat >conftest.c <<EOFint foo;int *bar() { return &foo; }EOFecho "Test program:" >&AC_FD_CCcat conftest.c >&AC_FD_CCgmp_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c >&AC_FD_CC"if AC_TRY_EVAL(gmp_compile); thenecho "Compiler output:" >&AC_FD_CCcat conftest.s >&AC_FD_CCif grep 'foo@ha' conftest.s >/dev/null 2>&AC_FD_CC; thengmp_cv_asm_powerpc_pic=nofiif grep 'ha16(_foo)' conftest.s >/dev/null 2>&AC_FD_CC; thengmp_cv_asm_powerpc_pic=nofifirm -f conftest*])GMP_DEFINE_RAW(["define(<PIC_ALWAYS>,<$gmp_cv_asm_powerpc_pic>)"])])dnl GMP_ASM_POWERPC_R_REGISTERSdnl ---------------------------dnl Determine whether the assembler takes powerpc registers with an "r" asdnl in "r6", or as plain "6". The latter is standard, but NeXT, Rhapsody,dnl and MacOS-X require the "r" forms.dnldnl See also mpn/powerpc32/powerpc-defs.m4 which uses the result of thisdnl test.AC_DEFUN([GMP_ASM_POWERPC_R_REGISTERS],[AC_REQUIRE([GMP_ASM_TEXT])AC_CACHE_CHECK([if the assembler needs r on registers],gmp_cv_asm_powerpc_r_registers,[GMP_TRY_ASSEMBLE([ $gmp_cv_asm_textmtctr 6],[gmp_cv_asm_powerpc_r_registers=no],[GMP_TRY_ASSEMBLE([ $gmp_cv_asm_textmtctr r6],[gmp_cv_asm_powerpc_r_registers=yes],[AC_MSG_ERROR([neither "mtctr 6" nor "mtctr r6" works])])])])GMP_DEFINE_RAW(["define(<WANT_R_REGISTERS>,<$gmp_cv_asm_powerpc_r_registers>)"])])dnl GMP_ASM_SPARC_REGISTERdnl ----------------------dnl Determine whether the assembler accepts the ".register" directive.dnl Old versions of solaris "as" don't.dnldnl See also mpn/sparc32/sparc-defs.m4 which uses the result of this test.AC_DEFUN([GMP_ASM_SPARC_REGISTER],[AC_REQUIRE([GMP_ASM_TEXT])AC_CACHE_CHECK([if the assembler accepts ".register"],gmp_cv_asm_sparc_register,[GMP_TRY_ASSEMBLE([ $gmp_cv_asm_text.register %g2,#scratch],[gmp_cv_asm_sparc_register=yes],[gmp_cv_asm_sparc_register=no])])GMP_DEFINE_RAW(["define(<HAVE_REGISTER>,<$gmp_cv_asm_sparc_register>)"])])dnl GMP_C_ATTRIBUTE_CONSTdnl ---------------------AC_DEFUN([GMP_C_ATTRIBUTE_CONST],[AC_CACHE_CHECK([whether gcc __attribute__ ((const)) works],gmp_cv_c_attribute_const,[AC_TRY_COMPILE([int foo (int x) __attribute__ ((const));], ,gmp_cv_c_attribute_const=yes, gmp_cv_c_attribute_const=no)])if test $gmp_cv_c_attribute_const = yes; thenAC_DEFINE(HAVE_ATTRIBUTE_CONST, 1,[Define to 1 if the compiler accepts gcc style __attribute__ ((const))])fi])dnl GMP_C_ATTRIBUTE_MALLOCdnl ----------------------dnl gcc 2.95.x accepts __attribute__ ((malloc)) but with a warning thatdnl it's ignored. Pretend it doesn't exist in this case, to avoid thatdnl warning.AC_DEFUN([GMP_C_ATTRIBUTE_MALLOC],[AC_CACHE_CHECK([whether gcc __attribute__ ((malloc)) works],gmp_cv_c_attribute_malloc,[cat >conftest.c <<EOFvoid *foo (int x) __attribute__ ((malloc));EOFgmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >conftest.out 2>&1"if AC_TRY_EVAL(gmp_compile); thenif grep "attribute directive ignored" conftest.out >/dev/null; thengmp_cv_c_attribute_malloc=noelsegmp_cv_c_attribute_malloc=yesfielsegmp_cv_c_attribute_malloc=noficat conftest.out >&AC_FD_CCrm -f conftest*])if test $gmp_cv_c_attribute_malloc = yes; thenAC_DEFINE(HAVE_ATTRIBUTE_MALLOC, 1,[Define to 1 if the compiler accepts gcc style __attribute__ ((malloc))])fi])dnl GMP_C_ATTRIBUTE_MODEdnl --------------------dnl Introduced in gcc 2.2, but perhaps not in all Apple derived versions.AC_DEFUN([GMP_C_ATTRIBUTE_MODE],[AC_CACHE_CHECK([whether gcc __attribute__ ((mode (XX))) works],gmp_cv_c_attribute_mode,[AC_TRY_COMPILE([typedef int SItype __attribute__ ((mode (SI)));], ,gmp_cv_c_attribute_mode=yes, gmp_cv_c_attribute_mode=no)])if test $gmp_cv_c_attribute_mode = yes; thenAC_DEFINE(HAVE_ATTRIBUTE_MODE, 1,[Define to 1 if the compiler accepts gcc style __attribute__ ((mode (XX)))])fi])dnl GMP_C_ATTRIBUTE_NORETURNdnl ------------------------AC_DEFUN([GMP_C_ATTRIBUTE_NORETURN],[AC_CACHE_CHECK([whether gcc __attribute__ ((noreturn)) works],gmp_cv_c_attribute_noreturn,[AC_TRY_COMPILE([void foo (int x) __attribute__ ((noreturn));], ,gmp_cv_c_attribute_noreturn=yes, gmp_cv_c_attribute_noreturn=no)])if test $gmp_cv_c_attribute_noreturn = yes; thenAC_DEFINE(HAVE_ATTRIBUTE_NORETURN, 1,[Define to 1 if the compiler accepts gcc style __attribute__ ((noreturn))])fi])dnl GMP_C_DOUBLE_FORMATdnl -------------------dnl Determine the floating point format.dnldnl The object file is grepped, in order to work when cross compiling. Adnl start and end sequence is included to avoid false matches, anddnl allowance is made for the desired data crossing an "od -b" linednl boundary. The test number is a small integer so it should appeardnl exactly, no rounding or truncation etc.dnldnl "od -b", incidentally, is supported even by Unix V7, and the awk scriptdnl used doesn't have functions or anything, so even an "old" awk shoulddnl suffice.AC_DEFUN([GMP_C_DOUBLE_FORMAT],[AC_REQUIRE([AC_PROG_CC])AC_REQUIRE([AC_PROG_AWK])AC_CACHE_CHECK([format of `double' floating point],gmp_cv_c_double_format,[gmp_cv_c_double_format=unknowncat >conftest.c <<\EOF[struct {char before[8];double x;char after[8];} foo = {{ '\001', '\043', '\105', '\147', '\211', '\253', '\315', '\357' },-123456789.0,{ '\376', '\334', '\272', '\230', '\166', '\124', '\062', '\020' },};]EOFgmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >&AC_FD_CC 2>&1"if AC_TRY_EVAL(gmp_compile); thencat >conftest.awk <<\EOF[BEGIN {found = 0}{for (f = 2; f <= NF; f++){for (i = 0; i < 23; i++)got[i] = got[i+1];got[23] = $f;# match the special begin and end sequencesif (got[0] != "001") continueif (got[1] != "043") continueif (got[2] != "105") continueif (got[3] != "147") continueif (got[4] != "211") continueif (got[5] != "253") continueif (got[6] != "315") continueif (got[7] != "357") continueif (got[16] != "376") continueif (got[17] != "334") continueif (got[18] != "272") continueif (got[19] != "230") continueif (got[20] != "166") continueif (got[21] != "124") continueif (got[22] != "062") continueif (got[23] != "020") continuesaw = " (" got[8] " " got[9] " " got[10] " " got[11] " " got[12] " " got[13] " " got[14] " " got[15] ")"if (got[8] == "000" && \got[9] == "000" && \got[10] == "000" && \got[11] == "124" && \got[12] == "064" && \got[13] == "157" && \got[14] == "235" && \got[15] == "301"){print "IEEE little endian"found = 1exit}# Little endian with the two 4-byte halves swapped, as used by ARM# when the chip is in little endian mode.#if (got[8] == "064" && \got[9] == "157" && \got[10] == "235" && \got[11] == "301" && \got[12] == "000" && \got[13] == "000" && \got[14] == "000" && \got[15] == "124"){print "IEEE little endian, swapped halves"found = 1exit}# gcc 2.95.4 on one GNU/Linux ARM system was seen generating 000 in# the last byte, whereas 124 is correct. Not sure where the bug# actually lies, but a running program didn't seem to get a full# mantissa worth of working bits.## We match this case explicitly so we can give a nice result message,# but we deliberately exclude it from the normal IEEE double setups# since it's too broken.#if (got[8] == "064" && \got[9] == "157" && \got[10] == "235" && \got[11] == "301" && \got[12] == "000" && \got[13] == "000" && \got[14] == "000" && \got[15] == "000"){print "bad ARM software floats"found = 1exit}if (got[8] == "301" && \got[9] == "235" && \got[10] == "157" && \got[11] == "064" && \got[12] == "124" && \got[13] == "000" && \got[14] == "000" && \got[15] == "000"){print "IEEE big endian"found = 1exit}if (got[8] == "353" && \got[9] == "315" && \got[10] == "242" && \got[11] == "171" && \got[12] == "000" && \got[13] == "240" && \got[14] == "000" && \got[15] == "000"){print "VAX D"found = 1exit}if (got[8] == "275" && \got[9] == "301" && \got[10] == "064" && \got[11] == "157" && \got[12] == "000" && \got[13] == "124" && \got[14] == "000" && \got[15] == "000"){print "VAX G"found = 1exit}if (got[8] == "300" && \got[9] == "033" && \got[10] == "353" && \got[11] == "171" && \got[12] == "242" && \got[13] == "240" && \got[14] == "000" && \got[15] == "000"){print "Cray CFP"found = 1exit}}}END {if (! found)print "unknown", saw}]EOFgmp_cv_c_double_format=`od -b conftest.$OBJEXT | $AWK -f conftest.awk`case $gmp_cv_c_double_format inunknown*)echo "cannot match anything, conftest.$OBJEXT contains" >&AC_FD_CCod -b conftest.$OBJEXT >&AC_FD_CC;;esacelseAC_MSG_WARN([oops, cannot compile test program])firm -f conftest*])AH_VERBATIM([HAVE_DOUBLE],[/* Define one of the following to 1 for the format of a `double'.If your format is not among these choices, or you don't know what it is,then leave all undefined.IEEE_LITTLE_SWAPPED means little endian, but with the two 4-byte halvesswapped, as used by ARM CPUs in little endian mode. */#undef HAVE_DOUBLE_IEEE_BIG_ENDIAN#undef HAVE_DOUBLE_IEEE_LITTLE_ENDIAN#undef HAVE_DOUBLE_IEEE_LITTLE_SWAPPED#undef HAVE_DOUBLE_VAX_D#undef HAVE_DOUBLE_VAX_G#undef HAVE_DOUBLE_CRAY_CFP])case $gmp_cv_c_double_format in"IEEE big endian")AC_DEFINE(HAVE_DOUBLE_IEEE_BIG_ENDIAN, 1)GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_DOUBLE_IEEE_BIG_ENDIAN')", POST);;"IEEE little endian")AC_DEFINE(HAVE_DOUBLE_IEEE_LITTLE_ENDIAN, 1)GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_DOUBLE_IEEE_LITTLE_ENDIAN')", POST);;"IEEE little endian, swapped halves")AC_DEFINE(HAVE_DOUBLE_IEEE_LITTLE_SWAPPED, 1) ;;"VAX D")AC_DEFINE(HAVE_DOUBLE_VAX_D, 1) ;;"VAX G")AC_DEFINE(HAVE_DOUBLE_VAX_G, 1) ;;"Cray CFP")AC_DEFINE(HAVE_DOUBLE_CRAY_CFP, 1) ;;"bad ARM software floats");;unknown*)AC_MSG_WARN([Could not determine float format.])AC_MSG_WARN([Conversions to and from "double" may be slow.]);;*)AC_MSG_WARN([oops, unrecognised float format: $gmp_cv_c_double_format]);;esac])dnl GMP_C_STDARGdnl ------------dnl Test whether to use <stdarg.h> or <varargs.h>.dnldnl Notice the AC_DEFINE here is HAVE_STDARG to avoid clashing withdnl HAVE_STDARG_H which could arise from AC_CHECK_HEADERS.dnldnl This test might be slight overkill, after all there's really only goingdnl to be ANSI or K&R and the two can be differentiated by AC_PROG_CC_STDCdnl or very likely by the setups for _PROTO in gmp.h. On the other handdnl this test is nice and direct, being what we're going to actually use.AC_DEFUN([GMP_C_STDARG],[AC_CACHE_CHECK([whether <stdarg.h> exists and works],gmp_cv_c_stdarg,[AC_TRY_COMPILE([#include <stdarg.h>int foo (int x, ...){va_list ap;int y;va_start (ap, x);y = va_arg (ap, int);va_end (ap);return y;}],,gmp_cv_c_stdarg=yes, gmp_cv_c_stdarg=no)])if test $gmp_cv_c_stdarg = yes; thenAC_DEFINE(HAVE_STDARG, 1, [Define to 1 if <stdarg.h> exists and works])fi])dnl GMP_FUNC_ALLOCAdnl ---------------dnl Determine whether "alloca" is available. This is AC_FUNC_ALLOCA fromdnl autoconf, but changed so it doesn't use alloca.c if alloca() isn'tdnl available, and also to use gmp-impl.h for the conditionals detectingdnl compiler builtin alloca's.AC_DEFUN([GMP_FUNC_ALLOCA],[AC_REQUIRE([GMP_HEADER_ALLOCA])AC_CACHE_CHECK([for alloca (via gmp-impl.h)],gmp_cv_func_alloca,[AC_TRY_LINK(GMP_INCLUDE_GMP_H[#include "$srcdir/gmp-impl.h"],[char *p = (char *) alloca (1);],gmp_cv_func_alloca=yes,gmp_cv_func_alloca=no)])if test $gmp_cv_func_alloca = yes; thenAC_DEFINE(HAVE_ALLOCA, 1, [Define to 1 if alloca() works (via gmp-impl.h).])fi])AC_DEFUN([GMP_HEADER_ALLOCA],[# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works# for constant arguments. Useless!AC_CACHE_CHECK([for working alloca.h],gmp_cv_header_alloca,[AC_TRY_LINK([#include <alloca.h>],[char *p = (char *) alloca (2 * sizeof (int));],gmp_cv_header_alloca=yes,gmp_cv_header_alloca=no)])if test $gmp_cv_header_alloca = yes; thenAC_DEFINE(HAVE_ALLOCA_H, 1,[Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).])fi])dnl GMP_OPTION_ALLOCAdnl -----------------dnl Decide what to do about --enable-alloca from the user.dnl This is a macro so it can require GMP_FUNC_ALLOCA.AC_DEFUN([GMP_OPTION_ALLOCA],[AC_REQUIRE([GMP_FUNC_ALLOCA])AC_CACHE_CHECK([how to allocate temporary memory],gmp_cv_option_alloca,[case $enable_alloca inyes)gmp_cv_option_alloca=alloca;;no)gmp_cv_option_alloca=malloc-reentrant;;reentrant | notreentrant)case $gmp_cv_func_alloca inyes) gmp_cv_option_alloca=alloca ;;*) gmp_cv_option_alloca=malloc-$enable_alloca ;;esac;;*)gmp_cv_option_alloca=$enable_alloca;;esac])AH_VERBATIM([WANT_TMP],[/* Define one of these to 1 for the desired temporary memory allocationmethod, per --enable-alloca. */#undef WANT_TMP_ALLOCA#undef WANT_TMP_REENTRANT#undef WANT_TMP_NOTREENTRANT#undef WANT_TMP_DEBUG])case $gmp_cv_option_alloca inalloca)if test $gmp_cv_func_alloca = no; thenAC_MSG_ERROR([--enable-alloca=alloca specified, but alloca not available])fiAC_DEFINE(WANT_TMP_ALLOCA)TAL_OBJECT=tal-reent$U.lo;;malloc-reentrant)AC_DEFINE(WANT_TMP_REENTRANT)TAL_OBJECT=tal-reent$U.lo;;malloc-notreentrant)AC_DEFINE(WANT_TMP_NOTREENTRANT)TAL_OBJECT=tal-notreent$U.lo;;debug)AC_DEFINE(WANT_TMP_DEBUG)TAL_OBJECT=tal-debug$U.lo;;*)# checks at the start of configure.in should protect usAC_MSG_ERROR([unrecognised --enable-alloca=$gmp_cv_option_alloca]);;esacAC_SUBST(TAL_OBJECT)])dnl GMP_FUNC_SSCANF_WRITABLE_INPUTdnl ------------------------------dnl Determine whether sscanf requires a writable input string.dnldnl It might be nicer to run a program to determine this when doing adnl native build, but the systems afflicted are few and far between thesednl days, so it seems good enough just to list them.AC_DEFUN([GMP_FUNC_SSCANF_WRITABLE_INPUT],[AC_CACHE_CHECK([whether sscanf needs writable input],gmp_cv_func_sscanf_writable_input,[case $host in*-*-hpux9 | *-*-hpux9.*)gmp_cv_func_sscanf_writable_input=yes ;;*) gmp_cv_func_sscanf_writable_input=no ;;esac])case $gmp_cv_func_sscanf_writable_input inyes) AC_DEFINE(SSCANF_WRITABLE_INPUT, 1,[Define to 1 if sscanf requires writable inputs]) ;;no) ;;*) AC_MSG_ERROR([unrecognised \$gmp_cv_func_sscanf_writable_input]) ;;esac])dnl GMP_FUNC_VSNPRINTFdnl ------------------dnl Check whether vsnprintf exists, and works properly.dnldnl Systems without vsnprintf include mingw32, OSF 4.dnldnl Sparc Solaris 2.7 in 64-bit mode doesn't always truncate, makingdnl vsnprintf like vsprintf, and hence completely useless. On one system adnl literal string is enough to provoke the problem, on another a "%n" wasdnl needed. There seems to be something weird going on with the optimizerdnl or something, since on the first system adding a second check withdnl "%n", or even just an initialized local variable, makes it work. Indnl any case, without bothering to get to the bottom of this, the twodnl program runs in the code below end up successfully detecting thednl problem.dnldnl glibc 2.0.x returns either -1 or bufsize-1 for an overflow (both seen,dnl not sure which 2.0.x does which), but still puts the correct nulldnl terminated result into the buffer.AC_DEFUN([GMP_FUNC_VSNPRINTF],[AC_REQUIRE([GMP_C_STDARG])AC_CHECK_FUNC(vsnprintf,[gmp_vsnprintf_exists=yes],[gmp_vsnprintf_exists=no])if test "$gmp_vsnprintf_exists" = no; thengmp_cv_func_vsnprintf=noelseAC_CACHE_CHECK([whether vsnprintf works],gmp_cv_func_vsnprintf,[gmp_cv_func_vsnprintf=yesfor i in 'check ("hello world");' 'int n; check ("%nhello world", &n);'; doAC_TRY_RUN([#include <string.h> /* for strcmp */#include <stdio.h> /* for vsnprintf */#if HAVE_STDARG#include <stdarg.h>#else#include <varargs.h>#endifint#if HAVE_STDARGcheck (const char *fmt, ...)#elsecheck (va_alist)va_dcl#endif{static char buf[128];va_list ap;int ret;#if HAVE_STDARGva_start (ap, fmt);#elsechar *fmt;va_start (ap);fmt = va_arg (ap, char *);#endifret = vsnprintf (buf, 4, fmt, ap);if (strcmp (buf, "hel") != 0)exit (1);/* allowed return values */if (ret != -1 && ret != 3 && ret != 11)exit (2);return 0;}intmain (){$iexit (0);}],[:],[gmp_cv_func_vsnprintf=no; break],[gmp_cv_func_vsnprintf=probably; break])done])if test "$gmp_cv_func_vsnprintf" = probably; thenAC_MSG_WARN([cannot check for properly working vsnprintf when cross compiling, will assume it's ok])fiif test "$gmp_cv_func_vsnprintf" != no; thenAC_DEFINE(HAVE_VSNPRINTF,1,[Define to 1 if you have the `vsnprintf' function and it works properly.])fifi])dnl GMP_H_ANSIdnl ----------dnl Check whether gmp.h recognises the compiler as ANSI capable.AC_DEFUN([GMP_H_ANSI],[AC_REQUIRE([AC_PROG_CC_STDC])case $ac_cv_prog_cc_stdc inno);;*)AC_TRY_COMPILE(GMP_INCLUDE_GMP_H[#if ! __GMP_HAVE_PROTOTYPESdie die die#endif],,,[AC_MSG_WARN([gmp.h doesnt recognise compiler as ANSI, prototypes and "const" will be unavailable])]);;esac])dnl GMP_H_EXTERN_INLINEdnl -------------------dnl If the compiler has an "inline" of some sort, check whether thednl #ifdef's in gmp.h recognise it.AC_DEFUN([GMP_H_EXTERN_INLINE],[AC_REQUIRE([AC_C_INLINE])case $ac_cv_c_inline inno) ;;*)AC_TRY_COMPILE([#define __GMP_WITHIN_CONFIGURE_INLINE 1]GMP_INCLUDE_GMP_H[#ifndef __GMP_EXTERN_INLINEdie die die#endif],,,[case $ac_cv_c_inline inyes) tmp_inline=inline ;;*) tmp_inline=$ac_cv_c_inline ;;esacAC_MSG_WARN([gmp.h doesnt recognise compiler "$tmp_inline", inlines will be unavailable])]);;esac])dnl GMP_H_HAVE_FILEdnl ---------------dnl Check whether the #ifdef's in gmp.h recognise when stdio.h has beendnl included to get FILE.AC_DEFUN([GMP_H_HAVE_FILE],[AC_TRY_COMPILE([#include <stdio.h>]GMP_INCLUDE_GMP_H[#if ! _GMP_H_HAVE_FILEdie die die#endif],,,[AC_MSG_WARN([gmp.h doesnt recognise <stdio.h>, FILE prototypes will be unavailable])])])dnl GMP_PROG_CC_FOR_BUILDdnl ---------------------dnl Establish CC_FOR_BUILD, a C compiler for the build system.dnldnl If CC_FOR_BUILD is set then it's expected to work, likewise the olddnl style HOST_CC, otherwise some likely candidates are tried, the same asdnl configfsf.guess.AC_DEFUN([GMP_PROG_CC_FOR_BUILD],[AC_REQUIRE([AC_PROG_CC])if test -n "$CC_FOR_BUILD"; thenGMP_PROG_CC_FOR_BUILD_WORKS($CC_FOR_BUILD,,[AC_MSG_ERROR([Specified CC_FOR_BUILD doesn't seem to work])])elif test -n "$HOST_CC"; thenGMP_PROG_CC_FOR_BUILD_WORKS($HOST_CC,[CC_FOR_BUILD=$HOST_CC],[AC_MSG_ERROR([Specified HOST_CC doesn't seem to work])])elsefor i in "$CC" "$CC $CFLAGS $CPPFLAGS" cc gcc c89 c99; doGMP_PROG_CC_FOR_BUILD_WORKS($i,[CC_FOR_BUILD=$ibreak])doneif test -z "$CC_FOR_BUILD"; thenAC_MSG_ERROR([Cannot find a build system compiler])fifiAC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])AC_SUBST(CC_FOR_BUILD)])dnl GMP_PROG_CC_FOR_BUILD_WORKS(cc/cflags[,[action-if-good][,action-if-bad]])dnl -------------------------------------------------------------------------dnl See if the given cc/cflags works on the build system.dnldnl It seems easiest to just use the default compiler output, rather thandnl figuring out the .exe or whatever at this stage.AC_DEFUN([GMP_PROG_CC_FOR_BUILD_WORKS],[AC_MSG_CHECKING([build system compiler $1])# remove anything that might look like compiler output to our "||" expressionrm -f conftest* a.out b.out a.exe a_out.execat >conftest.c <<EOFintmain (){exit(0);}EOFgmp_compile="$1 conftest.c"cc_for_build_works=noif AC_TRY_EVAL(gmp_compile); thenif (./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest) >&AC_FD_CC 2>&1; thencc_for_build_works=yesfifirm -f conftest* a.out b.out a.exe a_out.exeAC_MSG_RESULT($cc_for_build_works)if test "$cc_for_build_works" = yes; thenifelse([$2],,:,[$2])elseifelse([$3],,:,[$3])fi])dnl GMP_PROG_CPP_FOR_BUILDdnl ---------------------dnl Establish CPP_FOR_BUILD, the build system C preprocessor.dnl The choices tried here are the same as AC_PROG_CPP, but withdnl CC_FOR_BUILD.AC_DEFUN([GMP_PROG_CPP_FOR_BUILD],[AC_REQUIRE([GMP_PROG_CC_FOR_BUILD])AC_MSG_CHECKING([for build system preprocessor])if test -z "$CPP_FOR_BUILD"; thenAC_CACHE_VAL(gmp_cv_prog_cpp_for_build,[cat >conftest.c <<EOF#define FOO BAREOFfor i in "$CC_FOR_BUILD -E" "$CC_FOR_BUILD -E -traditional-cpp" "/lib/cpp"; dogmp_compile="$i conftest.c"if AC_TRY_EVAL(gmp_compile) >&AC_FD_CC 2>&1; thengmp_cv_prog_cpp_for_build=$ibreakfidonerm -f conftest* a.out b.out a.exe a_out.exeif test -z "$gmp_cv_prog_cpp_for_build"; thenAC_MSG_ERROR([Cannot find build system C preprocessor.])fi])CPP_FOR_BUILD=$gmp_cv_prog_cpp_for_buildfiAC_MSG_RESULT([$CPP_FOR_BUILD])AC_ARG_VAR(CPP_FOR_BUILD,[build system C preprocessor])AC_SUBST(CPP_FOR_BUILD)])dnl GMP_PROG_EXEEXT_FOR_BUILDdnl -------------------------dnl Determine EXEEXT_FOR_BUILD, the build system executable suffix.dnldnl The idea is to find what "-o conftest$foo" will make it possible to rundnl the program with ./conftest. On Unix-like systems this is of coursednl nothing, for DOS it's ".exe", or for a strange RISC OS foreign filednl system cross compile it can be ",ff8" apparently. Not sure if thednl latter actually applies to a build-system executable, maybe it doesn't,dnl but it won't hurt to try.AC_DEFUN([GMP_PROG_EXEEXT_FOR_BUILD],[AC_REQUIRE([GMP_PROG_CC_FOR_BUILD])AC_CACHE_CHECK([for build system executable suffix],gmp_cv_prog_exeext_for_build,[cat >conftest.c <<EOFintmain (){exit (0);}EOFfor i in .exe ,ff8 ""; dogmp_compile="$CC_FOR_BUILD conftest.c -o conftest$i"if AC_TRY_EVAL(gmp_compile); thenif (./conftest) 2>&AC_FD_CC; thengmp_cv_prog_exeext_for_build=$ibreakfifidonerm -f conftest*if test "${gmp_cv_prog_exeext_for_build+set}" != set; thenAC_MSG_ERROR([Cannot determine executable suffix])fi])AC_SUBST(EXEEXT_FOR_BUILD,$gmp_cv_prog_exeext_for_build)])dnl GMP_C_FOR_BUILD_ANSIdnl --------------------dnl Determine whether CC_FOR_BUILD is ANSI, and establish U_FOR_BUILDdnl accordingly.dnldnl FIXME: Use AC_PROG_CC sets ac_cv_prog_cc_c89 which could be used insteadAC_DEFUN([GMP_C_FOR_BUILD_ANSI],[AC_REQUIRE([GMP_PROG_CC_FOR_BUILD])AC_CACHE_CHECK([whether build system compiler is ANSI],gmp_cv_c_for_build_ansi,[cat >conftest.c <<EOFintmain (int argc, char **argv){exit(0);}EOFgmp_compile="$CC_FOR_BUILD conftest.c"if AC_TRY_EVAL(gmp_compile); thengmp_cv_c_for_build_ansi=yeselsegmp_cv_c_for_build_ansi=nofirm -f conftest* a.out b.out a.exe a_out.exe])if test "$gmp_cv_c_for_build_ansi" = yes; thenU_FOR_BUILD=elseAC_SUBST(U_FOR_BUILD,_)fi])dnl GMP_CHECK_LIBM_FOR_BUILDdnl ------------------------dnl Establish LIBM_FOR_BUILD as -lm, if that seems to work.dnldnl Libtool AC_CHECK_LIBM also uses -lmw on *-ncr-sysv4.3*, if it works.dnl Don't know what that does, lets assume it's not needed just for log().AC_DEFUN([GMP_CHECK_LIBM_FOR_BUILD],[AC_REQUIRE([GMP_PROG_CC_FOR_BUILD])AC_CACHE_CHECK([for build system compiler math library],gmp_cv_check_libm_for_build,[cat >conftest.c <<EOFintmain (){exit(0);}double d;doublefoo (){return log (d);}EOFgmp_compile="$CC_FOR_BUILD conftest.c -lm"if AC_TRY_EVAL(gmp_compile); thengmp_cv_check_libm_for_build=-lmelsegmp_cv_check_libm_for_build=nofirm -f conftest* a.out b.out a.exe a_out.exe])case $gmp_cv_check_libm_for_build inyes) AC_SUBST(LIBM_FOR_BUILD,-lm) ;;no) LIBM_FOR_BUILD= ;;*) LIBM_FOR_BUILD=$gmp_cv_check_libm_for_build ;;esac])