[BACK]Return to acinclude.m4 CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp

Annotation of OpenXM_contrib/gmp/acinclude.m4, Revision 1.1.1.2

1.1       maekawa     1: dnl  GMP specific autoconf macros
                      2:
                      3:
1.1.1.2 ! ohara       4: dnl  Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
1.1       maekawa     5: dnl
                      6: dnl  This file is part of the GNU MP Library.
                      7: dnl
                      8: dnl  The GNU MP Library is free software; you can redistribute it and/or modify
                      9: dnl  it under the terms of the GNU Lesser General Public License as published
                     10: dnl  by the Free Software Foundation; either version 2.1 of the License, or (at
                     11: dnl  your option) any later version.
                     12: dnl
                     13: dnl  The GNU MP Library is distributed in the hope that it will be useful, but
                     14: dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
                     15: dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
                     16: dnl  License for more details.
                     17: dnl
                     18: dnl  You should have received a copy of the GNU Lesser General Public License
                     19: dnl  along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
                     20: dnl  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
                     21: dnl  MA 02111-1307, USA.
                     22:
                     23:
1.1.1.2 ! ohara      24: define(X86_PATTERN,
        !            25: [[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*]])
        !            26:
        !            27: define(POWERPC64_PATTERN,
        !            28: [[powerpc64-*-* | powerpc64le-*-* | powerpc620-*-* | powerpc630-*-*]])
        !            29:
        !            30:
        !            31: dnl  GMP_STRIP_PATH(subdir)
        !            32: dnl  ----------------------
        !            33: dnl  Strip entries */subdir from $path.
        !            34:
        !            35: define(GMP_STRIP_PATH,
        !            36: [tmp_path=
        !            37: for i in $path; do
        !            38:   case $i in
        !            39:     */$1) ;;
        !            40:     *) tmp_path="$tmp_path $i" ;;
        !            41:   esac
        !            42: done
        !            43: path="$tmp_path"
        !            44: ])
        !            45:
        !            46:
        !            47: dnl  GMP_INCLUDE_GMP_H
        !            48: dnl  -----------------
        !            49: dnl  Expand to the right way to #include gmp-h.in.  This must be used
        !            50: dnl  instead of gmp.h, since that file isn't generated until the end of the
        !            51: dnl  configure.
        !            52: dnl
        !            53: dnl  GMP_INCLUDE_GMP_H_BITS_PER_MP_LIMB starts as a dummy, but gets
        !            54: dnl  redefined in GMP_C_SIZES when the right value is known.
        !            55:
        !            56: define(GMP_INCLUDE_GMP_H,
        !            57: [[#define __GMP_WITHIN_CONFIGURE 1   /* ignore template stuff */
        !            58: #define GMP_NAIL_BITS $GMP_NAIL_BITS]
        !            59: GMP_INCLUDE_GMP_H_BITS_PER_MP_LIMB
        !            60: [$DEFN_LONG_LONG_LIMB
        !            61: #include "$srcdir/gmp-h.in"]
        !            62: ])
        !            63:
        !            64: define(GMP_INCLUDE_GMP_H_BITS_PER_MP_LIMB,
        !            65: [[#define __GMP_BITS_PER_MP_LIMB 123 /* dummy for GMP_NUMB_BITS etc */
        !            66: #define GMP_LIMB_BITS 123]])
        !            67:
        !            68:
1.1       maekawa    69: dnl  GMP_HEADER_GETVAL(NAME,FILE)
                     70: dnl  ----------------------------
1.1.1.2 ! ohara      71: dnl  Expand at autoconf time to the value of a "#define NAME" from the given
        !            72: dnl  FILE.  The regexps here aren't very rugged, but are enough for gmp.
1.1       maekawa    73: dnl  /dev/null as a parameter prevents a hang if $2 is accidentally omitted.
                     74:
                     75: define(GMP_HEADER_GETVAL,
                     76: [patsubst(patsubst(
                     77: esyscmd([grep "^#define $1 " $2 /dev/null 2>/dev/null]),
                     78: [^.*$1[        ]+],[]),
                     79: [[
                     80:        ]*$],[])])
                     81:
                     82:
                     83: dnl  GMP_VERSION
                     84: dnl  -----------
1.1.1.2 ! ohara      85: dnl  The gmp version number, extracted from the #defines in gmp-h.in at
        !            86: dnl  autoconf time.  Two digits like 3.0 if patchlevel <= 0, or three digits
        !            87: dnl  like 3.0.1 if patchlevel > 0.
1.1       maekawa    88:
                     89: define(GMP_VERSION,
1.1.1.2 ! ohara      90: [GMP_HEADER_GETVAL(__GNU_MP_VERSION,gmp-h.in)[]dnl
        !            91: .GMP_HEADER_GETVAL(__GNU_MP_VERSION_MINOR,gmp-h.in)[]dnl
        !            92: ifelse(m4_eval(GMP_HEADER_GETVAL(__GNU_MP_VERSION_PATCHLEVEL,gmp-h.in) > 0),1,
        !            93: [.GMP_HEADER_GETVAL(__GNU_MP_VERSION_PATCHLEVEL,gmp-h.in)])])
        !            94:
        !            95:
        !            96: dnl  GMP_SUBST_CHECK_FUNCS(func,...)
        !            97: dnl  ------------------------------
        !            98: dnl  Setup an AC_SUBST of HAVE_FUNC_01 for each argument.
        !            99:
        !           100: AC_DEFUN(GMP_SUBST_CHECK_FUNCS,
        !           101: [m4_if([$1],,,
        !           102: [_GMP_SUBST_CHECK_FUNCS(ac_cv_func_[$1],HAVE_[]m4_translit([$1],[a-z],[A-Z])_01)
        !           103: GMP_SUBST_CHECK_FUNCS(m4_shift($@))])])
        !           104:
        !           105: dnl  Called: _GMP_SUBST_CHECK_FUNCS(cachvar,substvar)
        !           106: AC_DEFUN(_GMP_SUBST_CHECK_FUNCS,
        !           107: [case $[$1] in
        !           108: yes) AC_SUBST([$2],1) ;;
        !           109: no)  [$2]=0 ;;
        !           110: esac
        !           111: ])
1.1       maekawa   112:
                    113:
1.1.1.2 ! ohara     114: dnl  GMP_SUBST_CHECK_HEADERS(foo.h,...)
        !           115: dnl  ----------------------------------
        !           116: dnl  Setup an AC_SUBST of HAVE_FOO_H_01 for each argument.
        !           117:
        !           118: AC_DEFUN(GMP_SUBST_CHECK_HEADERS,
        !           119: [m4_if([$1],,,
        !           120: [_GMP_SUBST_CHECK_HEADERS(ac_cv_header_[]m4_translit([$1],[./],[__]),
        !           121: HAVE_[]m4_translit([$1],[a-z./],[A-Z__])_01)
        !           122: GMP_SUBST_CHECK_HEADERS(m4_shift($@))])])
        !           123:
        !           124: dnl  Called: _GMP_SUBST_CHECK_HEADERS(cachvar,substvar)
        !           125: AC_DEFUN(_GMP_SUBST_CHECK_HEADERS,
        !           126: [case $[$1] in
        !           127: yes) AC_SUBST([$2],1) ;;
        !           128: no)  [$2]=0 ;;
        !           129: esac
        !           130: ])
        !           131:
        !           132:
        !           133: dnl  GMP_COMPARE_GE(A1,B1, A2,B2, ...)
        !           134: dnl  ---------------------------------
        !           135: dnl  Compare two version numbers A1.A2.etc and B1.B2.etc.  Set
        !           136: dnl  $gmp_compare_ge to yes or no accoring to the result.  The A parts
        !           137: dnl  should be variables, the B parts fixed numbers.  As many parts as
        !           138: dnl  desired can be included.  An empty string in an A part is taken to be
        !           139: dnl  zero, the B parts should be non-empty and non-zero.
        !           140: dnl
        !           141: dnl  For example,
        !           142: dnl
        !           143: dnl      GMP_COMPARE($major,10, $minor,3, $subminor,1)
        !           144: dnl
        !           145: dnl  would test whether $major.$minor.$subminor is greater than or equal to
        !           146: dnl  10.3.1.
        !           147:
        !           148: AC_DEFUN(GMP_COMPARE_GE,
        !           149: [gmp_compare_ge=no
        !           150: GMP_COMPARE_GE_INTERNAL($@)
        !           151: ])
        !           152:
        !           153: AC_DEFUN(GMP_COMPARE_GE_INTERNAL,
        !           154: [ifelse(len([$3]),0,
        !           155: [if test -n "$1" && test "$1" -ge $2; then
        !           156:   gmp_compare_ge=yes
        !           157: fi],
        !           158: [if test -n "$1"; then
        !           159:   if test "$1" -gt $2; then
        !           160:     gmp_compare_ge=yes
        !           161:   else
        !           162:     if test "$1" -eq $2; then
        !           163:       GMP_COMPARE_GE_INTERNAL(m4_shift(m4_shift($@)))
        !           164:     fi
        !           165:   fi
        !           166: fi])
        !           167: ])
        !           168:
        !           169:
        !           170: dnl  GMP_PROG_AR
        !           171: dnl  -----------
        !           172: dnl  GMP additions to $AR.
        !           173: dnl
        !           174: dnl  A cross-"ar" may be necessary when cross-compiling since the build
        !           175: dnl  system "ar" might try to interpret the object files to build a symbol
        !           176: dnl  table index, hence the use of AC_CHECK_TOOL.
        !           177: dnl
        !           178: dnl  A user-selected $AR is always left unchanged.  AC_CHECK_TOOL is still
        !           179: dnl  run to get the "checking" message printed though.
        !           180: dnl
        !           181: dnl  $AR_FLAGS is set to "cq" rather than leaving it to libtool "cru".  The
        !           182: dnl  latter fails when libtool goes into piecewise mode and is unlucky
        !           183: dnl  enough to have two same-named objects in separate pieces, as happens
        !           184: dnl  for instance to random.o (and others) on vax-dec-ultrix4.5.  Naturally
        !           185: dnl  a user-selected $AR_FLAGS is left unchanged.
        !           186:
        !           187: AC_DEFUN(GMP_PROG_AR,
        !           188: [dnl  Want to establish $AR before libtool initialization.
        !           189: AC_BEFORE([$0],[AC_PROG_LIBTOOL])
        !           190: gmp_user_AR=$AR
        !           191: AC_CHECK_TOOL(AR, ar, ar)
        !           192: if test -z "$gmp_user_AR"; then
        !           193:                         eval arflags=\"\$ar${abi1}_flags\"
        !           194:   test -n "$arflags" || eval arflags=\"\$ar${abi2}_flags\"
        !           195:   if test -n "$arflags"; then
        !           196:     AC_MSG_CHECKING([for extra ar flags])
        !           197:     AR="$AR $arflags"
        !           198:     AC_MSG_RESULT([$arflags])
        !           199:   fi
        !           200: fi
        !           201: if test -z "$AR_FLAGS"; then
        !           202:   AR_FLAGS=cq
        !           203: fi
        !           204: ])
        !           205:
        !           206:
        !           207: dnl  GMP_PROG_HOST_CC
        !           208: dnl  ----------------
        !           209: dnl  Establish a value for $HOST_CC.
        !           210: dnl
        !           211: dnl  Any HOST_CC already set is used without testing.  Likewise any
        !           212: dnl  CC_FOR_BUILD is used without testing.  CC_FOR_BUILD is the new name for
        !           213: dnl  a build system compiler, see configfsf.guess.
        !           214:
        !           215: AC_DEFUN(GMP_PROG_HOST_CC,
        !           216: [AC_BEFORE([$0],[AC_PROG_LIBTOOL])
        !           217: AC_REQUIRE([AC_PROG_CC])
        !           218: AC_CACHE_CHECK([for HOST_CC build system compiler],
        !           219:                gmp_cv_prog_host_cc,
        !           220: [if test -n "$HOST_CC"; then
        !           221:   gmp_cv_prog_host_cc=$HOST_CC
        !           222: else
        !           223:   if test -n "$CC_FOR_BUILD"; then
        !           224:     gmp_cv_prog_host_cc=$CC_FOR_BUILD
        !           225:   else
        !           226:     cat >conftest.c <<EOF
        !           227: int main () { exit(0); }
        !           228: EOF
        !           229:     for c in "$CC" cc gcc c89; do
        !           230:       echo "trying $c" >&AC_FD_CC
        !           231:       if ($c conftest.c -o conftest) >&AC_FD_CC 2>&1; then
        !           232:         if (./conftest) >&AC_FD_CC 2>&1; then
        !           233:           gmp_cv_prog_host_cc=$c
        !           234:           break
        !           235:         fi
        !           236:       fi
        !           237:     done
        !           238:     rm -f conftest*
        !           239:     if test -z "$gmp_cv_prog_host_cc"; then
        !           240:       AC_MSG_ERROR([cannot find a build system compiler])
        !           241:     fi
        !           242:   fi
        !           243: fi
        !           244: ])
        !           245: HOST_CC=$gmp_cv_prog_host_cc
        !           246: ])
        !           247:
        !           248:
        !           249: dnl  GMP_PROG_LEX
        !           250: dnl  ------------
        !           251: dnl  AC_PROG_LEX bombs if $LEX is set to ${am_missing_run}flex by
        !           252: dnl  AM_PROG_LEX.  It needs to see LEX=: if lex is missing.  Avoid this by
        !           253: dnl  running AC_PROG_LEX first and then using "missing".
1.1       maekawa   254: dnl
1.1.1.2 ! ohara     255: dnl  FIXME: This can be removed and just AM_PROG_LEX used, one that macro
        !           256: dnl  works properly.
        !           257:
        !           258: AC_DEFUN(GMP_PROG_LEX,
        !           259: [AC_REQUIRE([AC_PROG_LEX])
        !           260: if test "$LEX" = :; then
        !           261:   LEX=${am_missing_run}flex
        !           262: fi
        !           263: ])
        !           264:
        !           265:
        !           266: dnl  GMP_PROG_M4
        !           267: dnl  -----------
1.1       maekawa   268: dnl  Find a working m4, either in $PATH or likely locations, and setup $M4
                    269: dnl  and an AC_SUBST accordingly.  If $M4 is already set then it's a user
                    270: dnl  choice and is accepted with no checks.  GMP_PROG_M4 is like
1.1.1.2 ! ohara     271: dnl  AC_PATH_PROG or AC_CHECK_PROG, but tests each m4 found to see if it's
        !           272: dnl  good enough.
1.1       maekawa   273: dnl
                    274: dnl  See mpn/asm-defs.m4 for details on the known bad m4s.
                    275:
                    276: AC_DEFUN(GMP_PROG_M4,
1.1.1.2 ! ohara     277: [AC_ARG_VAR(M4,[m4 macro processor])
        !           278: AC_CACHE_CHECK([for suitable m4],
1.1       maekawa   279:                 gmp_cv_prog_m4,
                    280: [if test -n "$M4"; then
                    281:   gmp_cv_prog_m4="$M4"
                    282: else
                    283:   cat >conftest.m4 <<\EOF
1.1.1.2 ! ohara     284: dnl  Must protect this against being expanded during autoconf m4!
        !           285: dnl  Dont put "dnl"s in this as autoconf will flag an error for unexpanded
        !           286: dnl  macros.
        !           287: [define(dollarhash,``$][#'')ifelse(dollarhash(x),1,`define(t1,Y)',
1.1       maekawa   288: ``bad: $][# not supported (SunOS /usr/bin/m4)
1.1.1.2 ! ohara     289: '')ifelse(eval(89),89,`define(t2,Y)',
1.1       maekawa   290: `bad: eval() doesnt support 8 or 9 in a constant (OpenBSD 2.6 m4)
1.1.1.2 ! ohara     291: ')ifelse(t1`'t2,YY,`good
        !           292: ')]
        !           293: EOF
        !           294: dnl ' <- balance the quotes for emacs sh-mode
        !           295:   echo "trying m4" >&AC_FD_CC
        !           296:   gmp_tmp_val=`(m4 conftest.m4) 2>&AC_FD_CC`
        !           297:   echo "$gmp_tmp_val" >&AC_FD_CC
1.1       maekawa   298:   if test "$gmp_tmp_val" = good; then
                    299:     gmp_cv_prog_m4="m4"
                    300:   else
                    301:     IFS="${IFS=        }"; ac_save_ifs="$IFS"; IFS=":"
                    302: dnl $ac_dummy forces splitting on constant user-supplied paths.
                    303: dnl POSIX.2 word splitting is done only on the output of word expansions,
                    304: dnl not every word.  This closes a longstanding sh security hole.
                    305:     ac_dummy="$PATH:/usr/5bin"
                    306:     for ac_dir in $ac_dummy; do
                    307:       test -z "$ac_dir" && ac_dir=.
1.1.1.2 ! ohara     308:       echo "trying $ac_dir/m4" >&AC_FD_CC
        !           309:       gmp_tmp_val=`($ac_dir/m4 conftest.m4) 2>&AC_FD_CC`
        !           310:       echo "$gmp_tmp_val" >&AC_FD_CC
1.1       maekawa   311:       if test "$gmp_tmp_val" = good; then
                    312:         gmp_cv_prog_m4="$ac_dir/m4"
                    313:         break
                    314:       fi
                    315:     done
                    316:     IFS="$ac_save_ifs"
                    317:     if test -z "$gmp_cv_prog_m4"; then
                    318:       AC_MSG_ERROR([No usable m4 in \$PATH or /usr/5bin (see config.log for reasons).])
                    319:     fi
                    320:   fi
                    321:   rm -f conftest.m4
                    322: fi])
                    323: M4="$gmp_cv_prog_m4"
                    324: AC_SUBST(M4)
                    325: ])
                    326:
                    327:
1.1.1.2 ! ohara     328: dnl  GMP_M4_M4WRAP_SPURIOUS
        !           329: dnl  ----------------------
        !           330: dnl  Check for spurious output from m4wrap(), as described in mpn/asm-defs.m4.
        !           331: dnl
        !           332: dnl  The following systems have been seen with the problem.
        !           333: dnl
        !           334: dnl  - Unicos alpha, but its assembler doesn't seem to mind.
        !           335: dnl  - MacOS X Darwin, its assembler fails.
        !           336: dnl  - NetBSD 1.4.1 m68k, and gas 1.92.3 there gives a warning and ignores
        !           337: dnl    the bad last line since it doesn't have a newline.
        !           338: dnl  - NetBSD 1.4.2 alpha, but its assembler doesn't seem to mind.
        !           339: dnl
        !           340: dnl  Enhancement: Maybe this could be in GMP_PROG_M4, and attempt to prefer
        !           341: dnl  an m4 with a working m4wrap, if it can be found.
        !           342:
        !           343: AC_DEFUN(GMP_M4_M4WRAP_SPURIOUS,
        !           344: [AC_REQUIRE([GMP_PROG_M4])
        !           345: AC_CACHE_CHECK([if m4wrap produces spurious output],
        !           346:                gmp_cv_m4_m4wrap_spurious,
        !           347: [# hide the d-n-l from autoconf's error checking
        !           348: tmp_d_n_l=d""nl
        !           349: cat >conftest.m4 <<EOF
        !           350: [changequote({,})define(x,)m4wrap({x})$tmp_d_n_l]
        !           351: EOF
        !           352: echo test input is >&AC_FD_CC
        !           353: cat conftest.m4 >&AC_FD_CC
        !           354: tmp_chars=`$M4 conftest.m4 | wc -c`
        !           355: echo produces $tmp_chars chars output >&AC_FD_CC
        !           356: rm -f conftest.m4
        !           357: if test $tmp_chars = 0; then
        !           358:   gmp_cv_m4_m4wrap_spurious=no
        !           359: else
        !           360:   gmp_cv_m4_m4wrap_spurious=yes
        !           361: fi
        !           362: ])
        !           363: GMP_DEFINE_RAW(["define(<M4WRAP_SPURIOUS>,<$gmp_cv_m4_m4wrap_spurious>)"])
        !           364: ])
        !           365:
        !           366:
        !           367: dnl  GMP_PROG_NM
        !           368: dnl  -----------
        !           369: dnl  GMP additions to libtool AC_PROG_NM.
        !           370: dnl
        !           371: dnl  Note that if AC_PROG_NM can't find a working nm it still leaves
        !           372: dnl  $NM set to "nm", so $NM can't be assumed to actually work.
        !           373: dnl
        !           374: dnl  A user-selected $NM is always left unchanged.  AC_PROG_NM is still run
        !           375: dnl  to get the "checking" message printed though.
        !           376:
        !           377: AC_DEFUN(GMP_PROG_NM,
        !           378: [dnl  Make sure we're the first to call AC_PROG_NM, so our extra flags are
        !           379: dnl   used by everyone.
        !           380: AC_BEFORE([$0],[AC_PROG_NM])
        !           381: gmp_user_NM=$NM
        !           382: AC_PROG_NM
        !           383:
        !           384: # FIXME: When cross compiling (ie. $ac_tool_prefix not empty), libtool
        !           385: # defaults to plain "nm" if a "${ac_tool_prefix}nm" is not found.  In this
        !           386: # case run it again to try the native "nm", firstly so that likely locations
        !           387: # are searched, secondly so that -B or -p are added if necessary for BSD
        !           388: # format.  This is necessary for instance on OSF with "./configure
        !           389: # --build=alphaev5-dec-osf --host=alphaev6-dec-osf".
        !           390: #
        !           391: if test -z "$gmp_user_NM" && test -n "$ac_tool_prefix" && test "$NM" = nm; then
        !           392:   $as_unset lt_cv_path_NM
        !           393:   gmp_save_ac_tool_prefix=$ac_tool_prefix
        !           394:   ac_tool_prefix=
        !           395:   NM=
        !           396:   AC_PROG_NM
        !           397:   ac_tool_prefix=$gmp_save_ac_tool_prefix
        !           398: fi
        !           399:
        !           400: if test -z "$gmp_user_NM"; then
        !           401:                         eval nmflags=\"\$nm${abi1}_flags\"
        !           402:   test -n "$nmflags" || eval nmflags=\"\$nm${abi2}_flags\"
        !           403:   if test -n "$nmflags"; then
        !           404:     AC_MSG_CHECKING([for extra nm flags])
        !           405:     NM="$NM $nmflags"
        !           406:     AC_MSG_RESULT([$nmflags])
        !           407:   fi
        !           408: fi
        !           409: ])
        !           410:
        !           411:
        !           412: dnl  GMP_PROG_CC_WORKS(cc+cflags,[ACTION-IF-WORKS][,ACTION-IF-NOT-WORKS])
        !           413: dnl  --------------------------------------------------------------------
        !           414: dnl  Check if cc+cflags can compile and link.
        !           415: dnl
        !           416: dnl  This test is designed to be run repeatedly with different cc+cflags
        !           417: dnl  selections, so the result is not cached.
        !           418: dnl
        !           419: dnl  For a native build, meaning $cross_compiling == no, we require that the
        !           420: dnl  generated program will run.  This is the same as AC_PROG_CC does in
        !           421: dnl  _AC_COMPILER_EXEEXT_WORKS, and checking here will ensure we don't pass
        !           422: dnl  a CC/CFLAGS combination that it rejects.
        !           423: dnl
        !           424: dnl  sparc-*-solaris2.7 can compile ABI=64 but won't run it if the kernel
        !           425: dnl  was booted in 32-bit mode.  The effect of requiring the compiler output
        !           426: dnl  will run is that a plain native "./configure" falls back on ABI=32, but
        !           427: dnl  ABI=64 is still available as a cross-compile.
        !           428:
        !           429: AC_DEFUN(GMP_PROG_CC_WORKS,
        !           430: [AC_MSG_CHECKING([compiler $1])
        !           431: cat >conftest.c <<EOF
        !           432:
        !           433: /* The following provokes an internal error from gcc 2.95.2 -mpowerpc64
        !           434:    (without -maix64), hence detecting an unusable compiler */
        !           435: void *g() { return (void *) 0; }
        !           436: void *f() { return g(); }
        !           437:
        !           438: /* The following provokes an invalid instruction syntax from i386 gcc
        !           439:    -march=pentiumpro on Solaris 2.8.  The native sun assembler
        !           440:    requires a non-standard syntax for cmov which gcc (as of 2.95.2 at
        !           441:    least) doesn't know.  */
        !           442: int n;
        !           443: int cmov () { return (n >= 0 ? n : 0); }
        !           444:
        !           445: /* The following provokes a linker invocation problem with gcc 3.0.3
        !           446:    on AIX 4.3 under "-maix64 -mpowerpc64 -mcpu=630".  The -mcpu=630
        !           447:    option causes gcc to incorrectly select the 32-bit libgcc.a, not
        !           448:    the 64-bit one, and consequently it misses out on the __fixunsdfdi
        !           449:    helper (double -> uint64 conversion).  */
        !           450: double d;
        !           451: unsigned long gcc303 () { return (unsigned long) d; }
        !           452:
        !           453: int main () { return 0; }
        !           454: EOF
        !           455: gmp_prog_cc_works=no
        !           456: gmp_compile="$1 conftest.c >&AC_FD_CC"
        !           457: if AC_TRY_EVAL(gmp_compile); then
        !           458:   if test "$cross_compiling" = no; then
        !           459:     if AC_TRY_COMMAND([./a.out || ./a.exe || ./conftest]); then
        !           460:       gmp_prog_cc_works=yes
1.1       maekawa   461:     fi
1.1.1.2 ! ohara     462:   else
        !           463:     gmp_prog_cc_works=yes
1.1       maekawa   464:   fi
1.1.1.2 ! ohara     465: fi
        !           466: rm -f conftest* a.out a.exe
        !           467: AC_MSG_RESULT($gmp_prog_cc_works)
        !           468: if test $gmp_prog_cc_works = yes; then
        !           469:   ifelse([$2],,:,[$2])
        !           470: else
        !           471:   ifelse([$3],,:,[$3])
        !           472: fi
        !           473: ])
        !           474:
        !           475:
        !           476: dnl  GMP_PROG_CC_IS_GNU(CC,[ACTIONS-IF-YES][,ACTIONS-IF-NO])
        !           477: dnl  -------------------------------------------------------
        !           478: dnl  Determine whether the given compiler is GNU C.
        !           479: dnl
        !           480: dnl  This test is the same as autoconf _AC_LANG_COMPILER_GNU, but doesn't
        !           481: dnl  cache the result.  The same "ifndef" style test is used, to avoid
        !           482: dnl  problems with syntax checking cpp's used on NeXT and Apple systems.
        !           483:
        !           484: AC_DEFUN(GMP_PROG_CC_IS_GNU,
        !           485: [cat >conftest.c <<EOF
        !           486: #ifndef __GNUC__
        !           487:   choke me
        !           488: #endif
        !           489: EOF
        !           490: gmp_compile="$1 -c conftest.c >&AC_FD_CC"
        !           491: if AC_TRY_EVAL(gmp_compile); then
        !           492:   rm -f conftest*
        !           493:   AC_MSG_CHECKING([whether $1 is gcc])
        !           494:   AC_MSG_RESULT(yes)
        !           495:   ifelse([$2],,:,[$2])
        !           496: else
        !           497:   rm -f conftest*
        !           498:   ifelse([$3],,:,[$3])
        !           499: fi
        !           500: ])
        !           501:
        !           502:
        !           503: dnl  GMP_PROG_CC_IS_XLC(CC,[ACTIONS-IF-YES][,ACTIONS-IF-NO])
        !           504: dnl  -------------------------------------------------------
        !           505: dnl  Determine whether the given compiler is IBM xlc (on AIX).
        !           506: dnl
        !           507: dnl  There doesn't seem to be a preprocessor symbol to test for this, or if
        !           508: dnl  there is one then it's well hidden in xlc 3.1 on AIX 4.3, so just grep
        !           509: dnl  the man page printed when xlc is invoked with no arguments.
        !           510:
        !           511: AC_DEFUN(GMP_PROG_CC_IS_XLC,
        !           512: [gmp_command="$1 2>&1 | grep xlc >/dev/null"
        !           513: if AC_TRY_EVAL(gmp_command); then
        !           514:   AC_MSG_CHECKING([whether $1 is xlc])
        !           515:   AC_MSG_RESULT(yes)
        !           516:   ifelse([$2],,:,[$2])
        !           517: else
        !           518:   ifelse([$3],,:,[$3])
        !           519: fi
        !           520: ])
        !           521:
        !           522:
        !           523: dnl  GMP_HPC_HPPA_2_0(cc,[ACTION-IF-GOOD][,ACTION-IF-BAD])
        !           524: dnl  ---------------------------------------------------------
        !           525: dnl  Find out whether a HP compiler is good enough to generate hppa 2.0.
        !           526: dnl
        !           527: dnl  This test might be repeated for different compilers, so the result is
        !           528: dnl  not cached.
        !           529:
        !           530: AC_DEFUN(GMP_HPC_HPPA_2_0,
        !           531: [AC_MSG_CHECKING([whether HP compiler $1 is good for 64-bits])
        !           532: # Bad compiler output:
        !           533: #   ccom: HP92453-01 G.10.32.05 HP C Compiler
        !           534: # Good compiler output:
        !           535: #   ccom: HP92453-01 A.10.32.30 HP C Compiler
        !           536: # Let A.10.32.30 or higher be ok.
        !           537: echo >conftest.c
        !           538: gmp_tmp_vs=`$1 $2 -V -c -o conftest.$OBJEXT conftest.c 2>&1 | grep "^ccom:"`
        !           539: echo "Version string: $gmp_tmp_vs" >&AC_FD_CC
        !           540: rm conftest*
        !           541: gmp_tmp_v1=`echo $gmp_tmp_vs | sed 's/.* .\.\(.*\)\..*\..* HP C.*/\1/'`
        !           542: gmp_tmp_v2=`echo $gmp_tmp_vs | sed 's/.* .\..*\.\(.*\)\..* HP C.*/\1/'`
        !           543: gmp_tmp_v3=`echo $gmp_tmp_vs | sed 's/.* .\..*\..*\.\(.*\) HP C.*/\1/'`
        !           544: echo "Version number: $gmp_tmp_v1.$gmp_tmp_v2.$gmp_tmp_v3" >&AC_FD_CC
        !           545: if test -z "$gmp_tmp_v1"; then
        !           546:   gmp_hpc_64bit=not-applicable
        !           547: else
        !           548:   GMP_COMPARE_GE($gmp_tmp_v1, 10, $gmp_tmp_v2, 32, $gmp_tmp_v3, 30)
        !           549:   gmp_hpc_64bit=$gmp_compare_ge
        !           550: fi
        !           551: AC_MSG_RESULT($gmp_hpc_64bit)
        !           552: if test $gmp_hpc_64bit = yes; then
        !           553:   ifelse([$2],,:,[$2])
        !           554: else
        !           555:   ifelse([$3],,:,[$3])
        !           556: fi
        !           557: ])
1.1       maekawa   558:
                    559:
1.1.1.2 ! ohara     560: dnl  GMP_GCC_VERSION_GE(CC,MAJOR[,MINOR[,SUBMINOR]])
        !           561: dnl  -----------------------------------------------
        !           562: dnl  Test whether the version of CC (which must be GNU C) is >=
        !           563: dnl  MAJOR.MINOR.SUBMINOR.  Set $gmp_compare_ge to "yes" or "no"
        !           564: dnl  accordingly, or to "error" if the version number string can't be
        !           565: dnl  parsed.
        !           566: dnl
        !           567: dnl  gcc --version is normally just "2.7.2.3" or "2.95.3" or whatever, but
        !           568: dnl  egcs gives something like "egcs-2.91".  "[a-z-]*" is used to match that
        !           569: dnl  (Solaris 8 sed doesn't support "?" or "*" of a group, like "\(...\)?"
        !           570: dnl  or "\(...\)*".)
        !           571: dnl
        !           572: dnl  There's no caching here, so that different CC's can be tested.
        !           573:
        !           574: AC_DEFUN(GMP_GCC_VERSION_GE,
        !           575: [tmp_version=`($1 --version) 2>&AC_FD_CC`
        !           576: echo "$1 --version '$tmp_version'" >&AC_FD_CC
        !           577:
        !           578: major=`(echo "$tmp_version" | sed -n ['s/^[a-z-]*\([0-9][0-9]*\).*/\1/p']) 2>&AC_FD_CC`
        !           579: echo "    major '$major'" >&AC_FD_CC
        !           580:
        !           581: ifelse([$3],,,
        !           582: [minor=`(echo "$tmp_version" | sed -n ['s/^[a-z-]*[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/p']) 2>&AC_FD_CC`
        !           583: echo "    minor '$minor'" >&AC_FD_CC])
        !           584:
        !           585: ifelse([$4],,,
        !           586: [subminor=`(echo "$tmp_version" | sed -n ['s/^[a-z-]*[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/p']) 2>&AC_FD_CC`
        !           587: echo "    subminor '$subminor'" >&AC_FD_CC])
        !           588:
        !           589: if test -z "$major"; then
        !           590:   AC_MSG_WARN([unrecognised gcc version string: $tmp_version])
        !           591:   gmp_compare_ge=error
        !           592: else
        !           593:   ifelse([$3],, [GMP_COMPARE_GE($major, $2)],
        !           594:   [ifelse([$4],,[GMP_COMPARE_GE($major, $2, $minor, $3)],
        !           595:                 [GMP_COMPARE_GE($major, $2, $minor, $3, $subminor, $4)])])
        !           596: fi
        !           597: ])
        !           598:
        !           599:
        !           600: dnl  GMP_GCC_ARM_UMODSI(CC,[ACTIONS-IF-GOOD][,ACTIONS-IF-BAD])
        !           601: dnl  ---------------------------------------------------------
        !           602: dnl  gcc 2.95.3 and earlier on arm has a bug in the libgcc __umodsi routine
        !           603: dnl  making "%" give wrong results for some operands, eg. "0x90000000 % 3".
        !           604: dnl  We're hoping it'll be fixed in 2.95.4, and we know it'll be fixed in
        !           605: dnl  gcc 3.
        !           606: dnl
        !           607: dnl  There's only a couple of places gmp cares about this, one is the
        !           608: dnl  size==1 case in mpn/generic/mode1o.c, and this shows up in
        !           609: dnl  tests/mpz/t-jac.c as a wrong result from mpz_kronecker_ui.
        !           610:
        !           611: AC_DEFUN(GMP_GCC_ARM_UMODSI,
        !           612: [AC_MSG_CHECKING([whether ARM gcc unsigned division works])
        !           613: tmp_version=`$1 --version`
        !           614: echo "$tmp_version" >&AC_FD_CC
        !           615: case $tmp_version in
        !           616:   [2.95 | 2.95.[123]])
        !           617:     ifelse([$3],,:,[$3])
        !           618:     gmp_gcc_arm_umodsi_result="no, gcc 2.95.[0123]" ;;
        !           619:   *)
        !           620:     ifelse([$2],,:,[$2])
        !           621:     gmp_gcc_arm_umodsi_result=yes ;;
        !           622: esac
        !           623: AC_MSG_RESULT([$gmp_gcc_arm_umodsi_result])
        !           624: ])
        !           625:
        !           626:
        !           627: dnl  GMP_GCC_MARCH_PENTIUMPRO(CC,[ACTIONS-IF-GOOD][,ACTIONS-IF-BAD])
        !           628: dnl  ---------------------------------------------------------------
        !           629: dnl  mpz/powm.c swox cvs rev 1.4 tickled a bug in gcc 2.95.2 and 2.95.3 when
        !           630: dnl  -march=pentiumpro was used.  The bug was wrong handling of the input to
        !           631: dnl  an ABSIZ(z) expression in mpz_redc().  Fixed in 2.95.4 and pre-release
        !           632: dnl  3.0, and didn't seem to occur in unofficial 2.96, so test for 2.95.4
        !           633: dnl  and up.
        !           634: dnl
        !           635: dnl  This macro is used only once, after finalizing a choice of CC, so the
        !           636: dnl  result is cached.
        !           637:
        !           638: AC_DEFUN(GMP_GCC_MARCH_PENTIUMPRO,
        !           639: [AC_CACHE_CHECK([whether gcc -march=pentiumpro is good],
        !           640:                 gmp_cv_gcc_march_pentiumpro,
        !           641: [GMP_GCC_VERSION_GE([$1], 2,95,4)
        !           642: case $gmp_compare_ge in
        !           643: yes|no)  gmp_cv_gcc_march_pentiumpro=$gmp_compare_ge ;;
        !           644: error|*) gmp_cv_gcc_march_pentiumpro=no ;;
        !           645: esac])
        !           646: if test $gmp_cv_gcc_march_pentiumpro = yes; then
        !           647:   ifelse([$2],,:,[$2])
1.1       maekawa   648: else
1.1.1.2 ! ohara     649:   ifelse([$3],,:,[$3])
1.1       maekawa   650: fi
1.1.1.2 ! ohara     651: ])
1.1       maekawa   652:
1.1.1.2 ! ohara     653:
        !           654: dnl  GMP_GCC_M68K_OPTIMIZE(CCBASE,CC,FLAG-VARIABLE)
        !           655: dnl  ----------------------------------------------
        !           656: dnl  m68k gcc 2.95.x gets an internal compiler error when compiling the
        !           657: dnl  current mpn/generic/gcdext.c (swox cvs rev 1.20) under -O2 or higher,
        !           658: dnl  so just use -O for the offending gcc versions.  Naturally if gcdext.c
        !           659: dnl  gets rearranged or rewritten so the ICE doesn't happen then this can be
        !           660: dnl  removed.
        !           661:
        !           662: AC_DEFUN(GMP_GCC_M68K_OPTIMIZE,
        !           663: [case $host in
        !           664: m68*-*-*)
        !           665:   if test $1 = gcc; then
        !           666:     case `$2 --version` in
        !           667:     2.95*) $3=-O ;;
        !           668:     esac
        !           669:   fi
        !           670:   ;;
        !           671: esac
        !           672: ])
        !           673:
        !           674:
        !           675: dnl  GMP_GCC_MIPS_O32(gcc,[actions-yes][,[actions-no]])
        !           676: dnl  -------------------------------------------------
        !           677: dnl  Test whether gcc supports o32.
        !           678: dnl
        !           679: dnl  gcc 2.7.2.2 only does o32, and doesn't accept -mabi=32.
        !           680: dnl
        !           681: dnl  gcc 2.95 accepts -mabi=32 but it only works on irix5, on irix6 it gives
        !           682: dnl  "cc1: The -mabi=32 support does not work yet".
        !           683:
        !           684: AC_DEFUN(GMP_GCC_MIPS_O32,
        !           685: [AC_MSG_CHECKING([whether gcc supports o32])
        !           686: echo 'int x;' >conftest.c
        !           687: echo "$1 -mabi=32 -c conftest.c" >&AC_FD_CC
        !           688: if $1 -mabi=32 -c conftest.c >conftest.out 2>&1; then
        !           689:   result=yes
        !           690: else
        !           691:   cat conftest.out >&AC_FD_CC
        !           692:   if grep "cc1: Invalid option \`abi=32'" conftest.out >/dev/null; then
        !           693:     result=yes
        !           694:   else
        !           695:     result=no
1.1       maekawa   696:   fi
                    697: fi
1.1.1.2 ! ohara     698: rm -f conftest.*
        !           699: AC_MSG_RESULT($result)
        !           700: if test $result = yes; then
        !           701:   ifelse([$2],,:,[$2])
        !           702: else
        !           703:   ifelse([$3],,:,[$3])
        !           704: fi
        !           705: ])
1.1       maekawa   706:
                    707:
1.1.1.2 ! ohara     708: dnl  GMP_GCC_NO_CPP_PRECOMP(CCBASE,CC,CFLAGS,[ACTIONS-YES][,ACTIONS-NO])
        !           709: dnl  -------------------------------------------------------------------
        !           710: dnl  Check whether -no-cpp-precomp should be used on this compiler, and
        !           711: dnl  execute the corresponding ACTIONS-YES or ACTIONS-NO.
        !           712: dnl
        !           713: dnl  -no-cpp-precomp is only meant for Apple's hacked version of gcc found
        !           714: dnl  on powerpc*-*-darwin*, but we can give it a try on any gcc.  Normal gcc
        !           715: dnl  (as of 3.0 at least) only gives a warning, not an actual error, and we
        !           716: dnl  watch for that and decide against the option in that case, to avoid
        !           717: dnl  confusing the user.
        !           718:
        !           719: AC_DEFUN(GMP_GCC_NO_CPP_PRECOMP,
        !           720: [if test "$ccbase" = gcc; then
        !           721:   AC_MSG_CHECKING([compiler $2 $3 -no-cpp-precomp])
        !           722:   result=no
        !           723:   cat >conftest.c <<EOF
        !           724: int main () { return 0; }
        !           725: EOF
        !           726:   gmp_compile="$2 $3 -no-cpp-precomp conftest.c >conftest.out 2>&1"
        !           727:   if AC_TRY_EVAL(gmp_compile); then
        !           728:     if grep "unrecognized option.*-no-cpp-precomp" conftest.out >/dev/null; then : ;
        !           729:     else
        !           730:       result=yes
        !           731:     fi
        !           732:   fi
        !           733:   cat conftest.out >&AC_FD_CC
        !           734:   rm -f conftest* a.out
        !           735:   AC_MSG_RESULT($result)
        !           736:   if test "$result" = yes; then
        !           737:       ifelse([$4],,:,[$4])
        !           738:   else
        !           739:       ifelse([$5],,:,[$5])
        !           740:   fi
        !           741: fi
        !           742: ])
        !           743:
        !           744:
        !           745: dnl  GMP_GCC_WA_MCPU(CC+CFLAGS, NEWFLAG [,ACTION-YES [,ACTION-NO]])
        !           746: dnl  --------------------------------------------------------------
        !           747: dnl  Check whether gcc (or gas rather) accepts a flag like "-Wa,-mev67".
        !           748: dnl
        !           749: dnl  Gas doesn't give an error for an unknown cpu, it only prints a warning
        !           750: dnl  like "Warning: Unknown CPU identifier `ev78'".
        !           751: dnl
        !           752: dnl  This is intended for use on alpha, since only recent versions of gas
        !           753: dnl  accept -mev67, but there's nothing here that's alpha specific.
        !           754:
        !           755: AC_DEFUN(GMP_GCC_WA_MCPU,
        !           756: [AC_MSG_CHECKING([assembler $1 $2])
        !           757: result=no
        !           758: cat >conftest.c <<EOF
        !           759: int main () {}
        !           760: EOF
        !           761: gmp_compile="$1 $2 -c conftest.c >conftest.out 2>&1"
        !           762: if AC_TRY_EVAL(gmp_compile); then
        !           763:   if grep "Unknown CPU identifier" conftest.out >/dev/null; then : ;
        !           764:   else
        !           765:     result=yes
        !           766:   fi
        !           767: fi
        !           768: cat conftest.out >&AC_FD_CC
        !           769: rm -f conftest*
        !           770: AC_MSG_RESULT($result)
        !           771: if test "$result" = yes; then
        !           772:   ifelse([$3],,:,[$3])
        !           773: else
        !           774:   ifelse([$4],,:,[$4])
        !           775: fi
        !           776: ])
        !           777:
        !           778:
        !           779: dnl  GMP_PROG_CXX_WORKS(cxx/cxxflags [, ACTION-YES [,ACTION-NO]])
        !           780: dnl  ------------------------------------------------------------
        !           781: dnl  Check whether cxx/cxxflags can compile and link.
        !           782: dnl
        !           783: dnl  This test is designed to be run repeatedly with different cxx/cxxflags
        !           784: dnl  selections, so the result is not cached.
        !           785:
        !           786: AC_DEFUN(GMP_PROG_CXX_WORKS,
        !           787: [AC_MSG_CHECKING([C++ compiler $1])
        !           788: cat >conftest.cc <<EOF
        !           789: #include <iostream>
        !           790: using namespace std;
        !           791: int
        !           792: main (void)
        !           793: {
        !           794:   cout.setf (ios::hex);
        !           795:   cout << 123;
        !           796:   return 0;
        !           797: }
        !           798: EOF
        !           799:
        !           800: gmp_cxxcompile="$1 conftest.cc -o conftest >&AC_FD_CC"
        !           801: if AC_TRY_EVAL(gmp_cxxcompile); then
        !           802:   rm -f conftest*
        !           803:   AC_MSG_RESULT(yes)
        !           804:   ifelse([$2],,:,[$2])
        !           805: else
        !           806:   rm -f conftest*
        !           807:   AC_MSG_RESULT(no)
        !           808:   ifelse([$3],,:,[$3])
        !           809: fi
        !           810: ])
1.1       maekawa   811:
                    812:
                    813: dnl  GMP_INIT([M4-DEF-FILE])
1.1.1.2 ! ohara     814: dnl  -----------------------
        !           815: dnl  Initializations for GMP config.m4 generation.
        !           816: dnl
        !           817: dnl  FIXME: The generated config.m4 doesn't get recreated by config.status.
        !           818: dnl  Maybe the relevant "echo"s should go through AC_CONFIG_COMMANDS.
        !           819:
1.1       maekawa   820: AC_DEFUN(GMP_INIT,
                    821: [ifelse([$1], , gmp_configm4=config.m4, gmp_configm4="[$1]")
                    822: gmp_tmpconfigm4=cnfm4.tmp
                    823: gmp_tmpconfigm4i=cnfm4i.tmp
                    824: gmp_tmpconfigm4p=cnfm4p.tmp
1.1.1.2 ! ohara     825: rm -f $gmp_tmpconfigm4 $gmp_tmpconfigm4i $gmp_tmpconfigm4p
        !           826:
        !           827: # CONFIG_TOP_SRCDIR is a path from the mpn builddir to the top srcdir.
        !           828: # The pattern here tests for an absolute path the same way as
        !           829: # _AC_OUTPUT_FILES in autoconf acgeneral.m4.
        !           830: case $srcdir in
        !           831: [[\\/]]* | ?:[[\\/]]* )  tmp="$srcdir"    ;;
        !           832: *)                       tmp="../$srcdir" ;;
        !           833: esac
        !           834: echo ["define(<CONFIG_TOP_SRCDIR>,<\`$tmp'>)"] >>$gmp_tmpconfigm4
        !           835:
        !           836: # All CPUs use asm-defs.m4
        !           837: echo ["include(CONFIG_TOP_SRCDIR\`/mpn/asm-defs.m4')"] >>$gmp_tmpconfigm4i
        !           838: ])
        !           839:
1.1       maekawa   840:
                    841: dnl  GMP_FINISH
                    842: dnl  ----------
                    843: dnl  Create config.m4 from its accumulated parts.
                    844: dnl
                    845: dnl  __CONFIG_M4_INCLUDED__ is used so that a second or subsequent include
                    846: dnl  of config.m4 is harmless.
                    847: dnl
                    848: dnl  A separate ifdef on the angle bracket quoted part ensures the quoting
                    849: dnl  style there is respected.  The basic defines from gmp_tmpconfigm4 are
                    850: dnl  fully quoted but are still put under an ifdef in case any have been
                    851: dnl  redefined by one of the m4 include files.
                    852: dnl
                    853: dnl  Doing a big ifdef within asm-defs.m4 and/or other macro files wouldn't
                    854: dnl  work, since it'd interpret parentheses and quotes in dnl comments, and
                    855: dnl  having a whole file as a macro argument would overflow the string space
                    856: dnl  on BSD m4.
                    857:
                    858: AC_DEFUN(GMP_FINISH,
                    859: [AC_REQUIRE([GMP_INIT])
                    860: echo "creating $gmp_configm4"
1.1.1.2 ! ohara     861: echo ["d""nl $gmp_configm4.  Generated automatically by configure."] > $gmp_configm4
1.1       maekawa   862: if test -f $gmp_tmpconfigm4; then
1.1.1.2 ! ohara     863:   echo ["changequote(<,>)"] >> $gmp_configm4
1.1       maekawa   864:   echo ["ifdef(<__CONFIG_M4_INCLUDED__>,,<"] >> $gmp_configm4
                    865:   cat $gmp_tmpconfigm4 >> $gmp_configm4
                    866:   echo [">)"] >> $gmp_configm4
1.1.1.2 ! ohara     867:   echo ["changequote(\`,')"] >> $gmp_configm4
1.1       maekawa   868:   rm $gmp_tmpconfigm4
                    869: fi
                    870: echo ["ifdef(\`__CONFIG_M4_INCLUDED__',,\`"] >> $gmp_configm4
                    871: if test -f $gmp_tmpconfigm4i; then
                    872:   cat $gmp_tmpconfigm4i >> $gmp_configm4
                    873:   rm $gmp_tmpconfigm4i
                    874: fi
                    875: if test -f $gmp_tmpconfigm4p; then
                    876:   cat $gmp_tmpconfigm4p >> $gmp_configm4
                    877:   rm $gmp_tmpconfigm4p
                    878: fi
                    879: echo ["')"] >> $gmp_configm4
                    880: echo ["define(\`__CONFIG_M4_INCLUDED__')"] >> $gmp_configm4
1.1.1.2 ! ohara     881: ])
1.1       maekawa   882:
                    883:
1.1.1.2 ! ohara     884: dnl  GMP_INCLUDE_MPN(FILE)
        !           885: dnl  ---------------------
        !           886: dnl  Add an include_mpn(`FILE') to config.m4.  FILE should be a path
        !           887: dnl  relative to the mpn source directory, for example
        !           888: dnl
        !           889: dnl      GMP_INCLUDE_MPN(`x86/x86-defs.m4')
        !           890: dnl
        !           891:
        !           892: AC_DEFUN(GMP_INCLUDE_MPN,
1.1       maekawa   893: [AC_REQUIRE([GMP_INIT])
1.1.1.2 ! ohara     894: echo ["include_mpn(\`$1')"] >> $gmp_tmpconfigm4i
        !           895: ])
        !           896:
        !           897:
        !           898: dnl  GMP_DEFINE(MACRO, DEFINITION [, LOCATION])
        !           899: dnl  ------------------------------------------
        !           900: dnl  Define M4 macro MACRO as DEFINITION in temporary file.
        !           901: dnl
        !           902: dnl  If LOCATION is `POST', the definition will appear after any include()
        !           903: dnl  directives inserted by GMP_INCLUDE.  Mind the quoting!  No shell
        !           904: dnl  variables will get expanded.  Don't forget to invoke GMP_FINISH to
        !           905: dnl  create file config.m4.  config.m4 uses `<' and '>' as quote characters
        !           906: dnl  for all defines.
1.1       maekawa   907:
                    908: AC_DEFUN(GMP_DEFINE,
                    909: [AC_REQUIRE([GMP_INIT])
1.1.1.2 ! ohara     910: echo ['define(<$1>, <$2>)'] >>ifelse([$3], [POST],
        !           911:                               $gmp_tmpconfigm4p, $gmp_tmpconfigm4)
        !           912: ])
        !           913:
        !           914:
        !           915: dnl  GMP_DEFINE_RAW(STRING, [, LOCATION])
        !           916: dnl  ------------------------------------
        !           917: dnl  Put STRING into config.m4 file.
        !           918: dnl
        !           919: dnl  If LOCATION is `POST', the definition will appear after any include()
        !           920: dnl  directives inserted by GMP_INCLUDE.  Don't forget to invoke GMP_FINISH
        !           921: dnl  to create file config.m4.
1.1       maekawa   922:
                    923: AC_DEFUN(GMP_DEFINE_RAW,
                    924: [AC_REQUIRE([GMP_INIT])
                    925: echo [$1] >> ifelse([$2], [POST], $gmp_tmpconfigm4p, $gmp_tmpconfigm4)
1.1.1.2 ! ohara     926: ])
        !           927:
        !           928:
        !           929: dnl  GMP_TRY_ASSEMBLE(asm-code,[action-success][,action-fail])
        !           930: dnl  ----------------------------------------------------------
        !           931: dnl  Attempt to assemble the given code.
        !           932: dnl  Do "action-success" if this succeeds, "action-fail" if not.
        !           933: dnl
        !           934: dnl  conftest.o and conftest.out are available for inspection in
        !           935: dnl  "action-success".  If either action does a "break" out of a loop then
        !           936: dnl  an explicit "rm -f conftest*" will be necessary.
        !           937: dnl
        !           938: dnl  This is not unlike AC_TRY_COMPILE, but there's no default includes or
        !           939: dnl  anything in "asm-code", everything wanted must be given explicitly.
        !           940:
        !           941: AC_DEFUN(GMP_TRY_ASSEMBLE,
        !           942: [cat >conftest.s <<EOF
        !           943: [$1]
        !           944: EOF
        !           945: gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1"
        !           946: if AC_TRY_EVAL(gmp_assemble); then
        !           947:   cat conftest.out >&AC_FD_CC
        !           948:   ifelse([$2],,:,[$2])
        !           949: else
        !           950:   cat conftest.out >&AC_FD_CC
        !           951:   echo "configure: failed program was:" >&AC_FD_CC
        !           952:   cat conftest.s >&AC_FD_CC
        !           953:   ifelse([$3],,:,[$3])
        !           954: fi
        !           955: rm -f conftest*
        !           956: ])
        !           957:
1.1       maekawa   958:
1.1.1.2 ! ohara     959: dnl  GMP_ASM_LABEL_SUFFIX
        !           960: dnl  --------------------
1.1       maekawa   961: dnl  Should a label have a colon or not?
1.1.1.2 ! ohara     962:
        !           963: AC_DEFUN(GMP_ASM_LABEL_SUFFIX,
1.1       maekawa   964: [AC_CACHE_CHECK([what assembly label suffix to use],
1.1.1.2 ! ohara     965:                 gmp_cv_asm_label_suffix,
        !           966: [case $host in
        !           967:   # Empty is only for the HP-UX hppa assembler; hppa gas requires a colon.
        !           968:   *-*-hpux*) gmp_cv_asm_label_suffix=  ;;
        !           969:   *)         gmp_cv_asm_label_suffix=: ;;
        !           970: esac
        !           971: ])
        !           972: echo ["define(<LABEL_SUFFIX>, <\$][1$gmp_cv_asm_label_suffix>)"] >> $gmp_tmpconfigm4
        !           973: ])
        !           974:
        !           975:
        !           976: dnl  GMP_ASM_UNDERSCORE
        !           977: dnl  ------------------
        !           978: dnl  Determine whether global symbols need to be prefixed with an underscore.
        !           979: dnl  A test program is linked to an assembler module with or without an
        !           980: dnl  underscore to see which works.
        !           981: dnl
        !           982: dnl  This method should be more reliable than grepping a .o file or using
        !           983: dnl  nm, since it corresponds to what a real program is going to do.  Note
        !           984: dnl  in particular that grepping doesn't work with SunOS 4 native grep since
        !           985: dnl  that grep seems to have trouble with '\0's in files.
        !           986:
        !           987: AC_DEFUN(GMP_ASM_UNDERSCORE,
        !           988: [AC_REQUIRE([GMP_ASM_TEXT])
        !           989: AC_REQUIRE([GMP_ASM_GLOBL])
        !           990: AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])
        !           991: AC_CACHE_CHECK([if globals are prefixed by underscore],
        !           992:                gmp_cv_asm_underscore,
        !           993: [cat >conftes1.c <<EOF
        !           994: #ifdef __cplusplus
        !           995: extern "C" { void underscore_test(); }
        !           996: #endif
        !           997: main () { underscore_test(); }
        !           998: EOF
        !           999: for tmp_underscore in "" "_"; do
        !          1000:   cat >conftes2.s <<EOF
        !          1001:        $gmp_cv_asm_text
        !          1002:        $gmp_cv_asm_globl ${tmp_underscore}underscore_test
        !          1003: ${tmp_underscore}underscore_test$gmp_cv_asm_label_suffix
        !          1004: EOF
        !          1005:   case $host in
        !          1006:   *-*-aix*)
        !          1007:     cat >>conftes2.s <<EOF
        !          1008:        $gmp_cv_asm_globl .${tmp_underscore}underscore_test
        !          1009: .${tmp_underscore}underscore_test$gmp_cv_asm_label_suffix
        !          1010: EOF
        !          1011:     ;;
        !          1012:   esac
        !          1013:   gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftes1.c >&AC_FD_CC && $CCAS $CFLAGS conftes2.s >&AC_FD_CC && $CC $CFLAGS conftes1.$OBJEXT conftes2.$OBJEXT >&AC_FD_CC"
        !          1014:   if AC_TRY_EVAL(gmp_compile); then
        !          1015:     eval tmp_result$tmp_underscore=yes
        !          1016:   else
        !          1017:     eval tmp_result$tmp_underscore=no
        !          1018:   fi
        !          1019: done
        !          1020:
        !          1021: if test $tmp_result_ = yes; then
        !          1022:   if test $tmp_result = yes; then
        !          1023:     AC_MSG_ERROR([Test program unexpectedly links both with and without underscore.])
1.1       maekawa  1024:   else
1.1.1.2 ! ohara    1025:     gmp_cv_asm_underscore=yes
1.1       maekawa  1026:   fi
                   1027: else
1.1.1.2 ! ohara    1028:   if test $tmp_result = yes; then
        !          1029:     gmp_cv_asm_underscore=no
        !          1030:   else
        !          1031:     AC_MSG_ERROR([Test program links neither with nor without underscore.])
        !          1032:   fi
1.1       maekawa  1033: fi
1.1.1.2 ! ohara    1034: rm -f conftes1* conftes2* a.out
1.1       maekawa  1035: ])
1.1.1.2 ! ohara    1036: if test "$gmp_cv_asm_underscore" = "yes"; then
1.1       maekawa  1037:   GMP_DEFINE(GSYM_PREFIX, [_])
                   1038: else
                   1039:   GMP_DEFINE(GSYM_PREFIX, [])
                   1040: fi
1.1.1.2 ! ohara    1041: ])
1.1       maekawa  1042:
1.1.1.2 ! ohara    1043:
        !          1044: dnl  GMP_ASM_ALIGN_LOG
        !          1045: dnl  -----------------
1.1       maekawa  1046: dnl  Is parameter to `.align' logarithmic?
1.1.1.2 ! ohara    1047:
        !          1048: AC_DEFUN(GMP_ASM_ALIGN_LOG,
        !          1049: [AC_REQUIRE([GMP_ASM_GLOBL])
        !          1050: AC_REQUIRE([GMP_ASM_DATA])
        !          1051: AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])
        !          1052: AC_REQUIRE([GMP_PROG_NM])
1.1       maekawa  1053: AC_CACHE_CHECK([if .align assembly directive is logarithmic],
1.1.1.2 ! ohara    1054:                gmp_cv_asm_align_log,
        !          1055: [GMP_TRY_ASSEMBLE(
        !          1056: [              $gmp_cv_asm_data
1.1       maekawa  1057:        .align  4
1.1.1.2 ! ohara    1058:        $gmp_cv_asm_globl       foo
1.1       maekawa  1059:        .byte   1
                   1060:        .align  4
1.1.1.2 ! ohara    1061: foo$gmp_cv_asm_label_suffix
        !          1062:        .byte   2],
        !          1063:   [gmp_tmp_val=[`$NM conftest.$OBJEXT | grep foo | \
        !          1064:      sed -e 's;[[][0-9][]]\(.*\);\1;' -e 's;[^1-9]*\([0-9]*\).*;\1;'`]
1.1       maekawa  1065:   if test "$gmp_tmp_val" = "10" || test "$gmp_tmp_val" = "16"; then
1.1.1.2 ! ohara    1066:     gmp_cv_asm_align_log=yes
1.1       maekawa  1067:   else
1.1.1.2 ! ohara    1068:     gmp_cv_asm_align_log=no
        !          1069:   fi],
        !          1070:   [AC_MSG_ERROR([cannot assemble alignment test])])])
        !          1071:
        !          1072: GMP_DEFINE_RAW(["define(<ALIGN_LOGARITHMIC>,<$gmp_cv_asm_align_log>)"])
1.1       maekawa  1073: ])
                   1074:
                   1075:
1.1.1.2 ! ohara    1076: dnl  GMP_ASM_ALIGN_FILL_0x90
        !          1077: dnl  -----------------------
1.1       maekawa  1078: dnl  Determine whether a ",0x90" suffix works on a .align directive.
1.1.1.2 ! ohara    1079: dnl  This is only meant for use on x86, 0x90 being a "nop".
        !          1080: dnl
        !          1081: dnl  Old gas, eg. 1.92.3
        !          1082: dnl       Needs ",0x90" or else the fill is 0x00, which can't be executed
        !          1083: dnl       across.
1.1       maekawa  1084: dnl
1.1.1.2 ! ohara    1085: dnl  New gas, eg. 2.91
        !          1086: dnl       Generates multi-byte nop fills even when ",0x90" is given.
        !          1087: dnl
        !          1088: dnl  Solaris 2.6 as
        !          1089: dnl       ",0x90" is not allowed, causes a fatal error.
        !          1090: dnl
        !          1091: dnl  Solaris 2.8 as
        !          1092: dnl       ",0x90" does nothing, generates a warning that it's being ignored.
        !          1093: dnl
        !          1094: dnl  SCO OpenServer 5 as
        !          1095: dnl       Second parameter is max bytes to fill, not a fill pattern.
        !          1096: dnl       ",0x90" is an error due to being bigger than the first parameter.
        !          1097: dnl       Multi-byte nop fills are generated in text segments.
1.1       maekawa  1098: dnl
                   1099: dnl  Note that both solaris "as"s only care about ",0x90" if they actually
1.1.1.2 ! ohara    1100: dnl  have to use it to fill something, hence the .byte in the test.  It's
        !          1101: dnl  the second .align which provokes the error or warning.
1.1       maekawa  1102: dnl
1.1.1.2 ! ohara    1103: dnl  The warning from solaris 2.8 is supressed to stop anyone worrying that
        !          1104: dnl  something might be wrong.
1.1       maekawa  1105:
1.1.1.2 ! ohara    1106: AC_DEFUN(GMP_ASM_ALIGN_FILL_0x90,
        !          1107: [AC_REQUIRE([GMP_ASM_TEXT])
        !          1108: AC_CACHE_CHECK([if the .align directive accepts an 0x90 fill in .text],
        !          1109:                gmp_cv_asm_align_fill_0x90,
        !          1110: [GMP_TRY_ASSEMBLE(
        !          1111: [              $gmp_cv_asm_text
1.1       maekawa  1112:        .align  4, 0x90
                   1113:        .byte   0
1.1.1.2 ! ohara    1114:        .align  4, 0x90],
        !          1115: [if grep "Warning: Fill parameter ignored for executable section" conftest.out >/dev/null; then
        !          1116:   echo "Supressing this warning by omitting 0x90" 1>&AC_FD_CC
        !          1117:   gmp_cv_asm_align_fill_0x90=no
        !          1118: else
        !          1119:   gmp_cv_asm_align_fill_0x90=yes
        !          1120: fi],
        !          1121: [gmp_cv_asm_align_fill_0x90=no])])
        !          1122:
        !          1123: GMP_DEFINE_RAW(["define(<ALIGN_FILL_0x90>,<$gmp_cv_asm_align_fill_0x90>)"])
        !          1124: ])
        !          1125:
        !          1126:
        !          1127: dnl  GMP_ASM_TEXT
        !          1128: dnl  ------------
        !          1129:
        !          1130: AC_DEFUN(GMP_ASM_TEXT,
        !          1131: [AC_CACHE_CHECK([how to switch to text section],
        !          1132:                 gmp_cv_asm_text,
        !          1133: [case $host in
        !          1134:   *-*-aix*)  gmp_cv_asm_text=[".csect .text[PR]"] ;;
        !          1135:   *-*-hpux*) gmp_cv_asm_text=".code" ;;
        !          1136:   *)         gmp_cv_asm_text=".text" ;;
        !          1137: esac
        !          1138: ])
        !          1139: echo ["define(<TEXT>, <$gmp_cv_asm_text>)"] >> $gmp_tmpconfigm4
        !          1140: ])
        !          1141:
        !          1142:
        !          1143: dnl  GMP_ASM_DATA
        !          1144: dnl  ------------
        !          1145: dnl  Can we say `.data'?
        !          1146:
        !          1147: AC_DEFUN(GMP_ASM_DATA,
        !          1148: [AC_CACHE_CHECK([how to switch to data section],
        !          1149:                 gmp_cv_asm_data,
        !          1150: [case $host in
        !          1151:   *-*-aix*) gmp_cv_asm_data=[".csect .data[RW]"] ;;
        !          1152:   *)        gmp_cv_asm_data=".data" ;;
        !          1153: esac
        !          1154: ])
        !          1155: echo ["define(<DATA>, <$gmp_cv_asm_data>)"] >> $gmp_tmpconfigm4
        !          1156: ])
        !          1157:
        !          1158:
        !          1159: dnl  GMP_ASM_RODATA
        !          1160: dnl  --------------
        !          1161: dnl  Find out how to switch to the read-only data section.
        !          1162: dnl
        !          1163: dnl  The compiler output is grepped for the right directive.  It's not
        !          1164: dnl  considered wise to just probe for ".section .rodata" or whatever works,
        !          1165: dnl  since arbitrary section names might be accepted, but not necessarily do
        !          1166: dnl  the right thing when they get to the linker.
        !          1167: dnl
        !          1168: dnl  Only a few asm files use RODATA, so this code is perhaps a bit
        !          1169: dnl  excessive right now, but should find more uses in the future.
        !          1170: dnl
        !          1171: dnl  FIXME: gcc on aix generates something like ".csect _foo.ro_c[RO],3"
        !          1172: dnl  where foo is the object file.  Might need to check for that if we use
        !          1173: dnl  RODATA there.
        !          1174:
        !          1175: AC_DEFUN(GMP_ASM_RODATA,
        !          1176: [AC_REQUIRE([GMP_ASM_TEXT])
        !          1177: AC_REQUIRE([GMP_ASM_DATA])
        !          1178: AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])
        !          1179: AC_REQUIRE([GMP_ASM_UNDERSCORE])
        !          1180: AC_CACHE_CHECK([how to switch to read-only data section],
        !          1181:                gmp_cv_asm_rodata,
        !          1182: [
        !          1183: dnl Default to DATA on CPUs with split code/data caching, and TEXT
        !          1184: dnl elsewhere.  i386 means generic x86, so use DATA on it.
        !          1185: case $host in
        !          1186: X86_PATTERN) gmp_cv_asm_rodata="$gmp_cv_asm_data" ;;
        !          1187: *)           gmp_cv_asm_rodata="$gmp_cv_asm_text" ;;
        !          1188: esac
        !          1189:
        !          1190: cat >conftest.c <<EOF
        !          1191: const int foo = 123;
1.1       maekawa  1192: EOF
1.1.1.2 ! ohara    1193: echo "Test program:" >&AC_FD_CC
        !          1194: cat conftest.c >&AC_FD_CC
        !          1195: gmp_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c >&AC_FD_CC"
        !          1196: if AC_TRY_EVAL(gmp_compile); then
        !          1197:   echo "Compiler output:" >&AC_FD_CC
        !          1198:   cat conftest.s >&AC_FD_CC
        !          1199:   if test $gmp_cv_asm_underscore = yes; then
        !          1200:     tmp_gsym_prefix=_
        !          1201:   else
        !          1202:     tmp_gsym_prefix=
        !          1203:   fi
        !          1204:   # must see our label
        !          1205:   if grep "^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix" conftest.s >/dev/null 2>&AC_FD_CC; then
        !          1206:     # take the last directive before our label (hence skipping segments
        !          1207:     # getting debugging info etc)
        !          1208:     tmp_match=`sed -n ["/^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix/q
        !          1209:                         /^[.   ]*data/p
        !          1210:                         /^[.   ]*rdata/p
        !          1211:                         /^[.   ]*text/p
        !          1212:                         /^[.   ]*section/p
        !          1213:                         /^[.   ]*csect/p
        !          1214:                         /^[.   ]*CSECT/p"] conftest.s | sed -n '$p'`
        !          1215:     echo "Match: $tmp_match" >&AC_FD_CC
        !          1216:     if test -n "$tmp_match"; then
        !          1217:       gmp_cv_asm_rodata=$tmp_match
        !          1218:     fi
        !          1219:   else
        !          1220:     echo "Couldn't find label: ^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix" >&AC_FD_CC
1.1       maekawa  1221:   fi
                   1222: fi
                   1223: ])
1.1.1.2 ! ohara    1224: echo ["define(<RODATA>, <$gmp_cv_asm_rodata>)"] >> $gmp_tmpconfigm4
1.1       maekawa  1225: ])
                   1226:
                   1227:
1.1.1.2 ! ohara    1228: dnl  GMP_ASM_GLOBL
        !          1229: dnl  -------------
        !          1230: dnl  Can we say `.global'?
        !          1231:
        !          1232: AC_DEFUN(GMP_ASM_GLOBL,
        !          1233: [AC_CACHE_CHECK([how to export a symbol],
        !          1234:                 gmp_cv_asm_globl,
        !          1235: [case $host in
        !          1236:   *-*-hpux*) gmp_cv_asm_globl=".export" ;;
        !          1237:   *)         gmp_cv_asm_globl=".globl" ;;
1.1       maekawa  1238: esac
                   1239: ])
1.1.1.2 ! ohara    1240: echo ["define(<GLOBL>, <$gmp_cv_asm_globl>)"] >> $gmp_tmpconfigm4
        !          1241: ])
1.1       maekawa  1242:
1.1.1.2 ! ohara    1243:
        !          1244: dnl  GMP_ASM_GLOBL_ATTR
        !          1245: dnl  ------------------
        !          1246: dnl  Do we need something after `.global symbol'?
        !          1247:
        !          1248: AC_DEFUN(GMP_ASM_GLOBL_ATTR,
        !          1249: [AC_CACHE_CHECK([if the export directive needs an attribute],
        !          1250:                 gmp_cv_asm_globl_attr,
        !          1251: [case $host in
        !          1252:   *-*-hpux*) gmp_cv_asm_globl_attr=",entry" ;;
        !          1253:   *)         gmp_cv_asm_globl_attr="" ;;
1.1       maekawa  1254: esac
                   1255: ])
1.1.1.2 ! ohara    1256: echo ["define(<GLOBL_ATTR>, <$gmp_cv_asm_globl_attr>)"] >> $gmp_tmpconfigm4
        !          1257: ])
1.1       maekawa  1258:
1.1.1.2 ! ohara    1259:
        !          1260: dnl  GMP_ASM_TYPE
        !          1261: dnl  ------------
        !          1262: dnl  Can we say ".type", and how?
        !          1263: dnl
        !          1264: dnl  For i386 GNU/Linux ELF systems, and very likely other ELF systems,
        !          1265: dnl  .type and .size are important on functions in shared libraries.  If
        !          1266: dnl  .type is omitted and the mainline program references that function then
        !          1267: dnl  the code will be copied down to the mainline at load time like a piece
        !          1268: dnl  of data.  If .size is wrong or missing (it defaults to 4 bytes or some
        !          1269: dnl  such) then incorrect bytes will be copied and a segv is the most likely
        !          1270: dnl  result.  In any case such copying is not what's wanted, a .type
        !          1271: dnl  directive will ensure a PLT entry is used.
        !          1272: dnl
        !          1273: dnl  In GMP the assembler functions are normally only used from within the
        !          1274: dnl  library (since most programs are not interested in the low level
        !          1275: dnl  routines), and in those circumstances a missing .type isn't fatal,
        !          1276: dnl  letting the problem go unnoticed.  tests/mpn/t-asmtype.c aims to check
        !          1277: dnl  for it.
        !          1278:
        !          1279: AC_DEFUN(GMP_ASM_TYPE,
        !          1280: [AC_CACHE_CHECK([for assembler .type directive],
        !          1281:                 gmp_cv_asm_type,
        !          1282: [gmp_cv_asm_type=
1.1       maekawa  1283: for gmp_tmp_prefix in @ \# %; do
1.1.1.2 ! ohara    1284:   GMP_TRY_ASSEMBLE([   .type   sym,${gmp_tmp_prefix}function],
        !          1285:     [if grep "\.type pseudo-op used outside of \.def/\.endef ignored" conftest.out >/dev/null; then : ;
        !          1286:     else
        !          1287:       gmp_cv_asm_type=".type   \$][1,${gmp_tmp_prefix}\$][2"
        !          1288:       break
        !          1289:     fi])
1.1       maekawa  1290: done
1.1.1.2 ! ohara    1291: rm -f conftest*
1.1       maekawa  1292: ])
1.1.1.2 ! ohara    1293: echo ["define(<TYPE>, <$gmp_cv_asm_type>)"] >> $gmp_tmpconfigm4
        !          1294: ])
        !          1295:
1.1       maekawa  1296:
1.1.1.2 ! ohara    1297: dnl  GMP_ASM_SIZE
        !          1298: dnl  ------------
1.1       maekawa  1299: dnl  Can we say `.size'?
1.1.1.2 ! ohara    1300:
        !          1301: AC_DEFUN(GMP_ASM_SIZE,
        !          1302: [AC_CACHE_CHECK([for assembler .size directive],
        !          1303:                 gmp_cv_asm_size,
        !          1304: [gmp_cv_asm_size=
        !          1305: GMP_TRY_ASSEMBLE([     .size   sym,1],
        !          1306:   [if grep "\.size pseudo-op used outside of \.def/\.endef ignored" conftest.out >/dev/null; then : ;
        !          1307:   else
        !          1308:     gmp_cv_asm_size=".size     \$][1,\$][2"
        !          1309:   fi])
1.1       maekawa  1310: ])
1.1.1.2 ! ohara    1311: echo ["define(<SIZE>, <$gmp_cv_asm_size>)"] >> $gmp_tmpconfigm4
        !          1312: ])
        !          1313:
1.1       maekawa  1314:
1.1.1.2 ! ohara    1315: dnl  GMP_ASM_LSYM_PREFIX
        !          1316: dnl  -------------------
1.1       maekawa  1317: dnl  What is the prefix for a local label?
1.1.1.2 ! ohara    1318: dnl
        !          1319: dnl  The prefixes tested are,
        !          1320: dnl
        !          1321: dnl      L  - usual for underscore systems
        !          1322: dnl      .L - usual for non-underscore systems
        !          1323: dnl      $  - alpha (gas and OSF system assembler)
        !          1324: dnl      L$ - hppa (gas and HP-UX system assembler)
        !          1325: dnl
        !          1326: dnl  The default is "L" if the tests fail for any reason.  There's a good
        !          1327: dnl  chance this will be adequate, since on most systems labels are local
        !          1328: dnl  anyway unless given a ".globl", and an "L" will avoid clashes with
        !          1329: dnl  other identifers.
        !          1330: dnl
        !          1331: dnl  For gas, ".L" is normally purely local to the assembler, it doesn't get
        !          1332: dnl  put into the object file at all.  This style is preferred, to keep the
        !          1333: dnl  object files nice and clean.
        !          1334: dnl
        !          1335: dnl  BSD format nm produces a line like the following.  The lower case "t"
        !          1336: dnl  indicates a local text segment label.  On OSF with "nm -B", an "N" is
        !          1337: dnl  printed instead.
        !          1338: dnl
        !          1339: dnl      00000000 t Lgurkmacka
        !          1340: dnl
        !          1341: dnl  HP-UX nm prints an error message (though seems to give a 0 exit) if
        !          1342: dnl  there's no symbols at all in an object file, hence the use of "dummy".
        !          1343:
        !          1344: AC_DEFUN(GMP_ASM_LSYM_PREFIX,
        !          1345: [AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])
        !          1346: AC_REQUIRE([GMP_PROG_NM])
1.1       maekawa  1347: AC_CACHE_CHECK([what prefix to use for a local label],
1.1.1.2 ! ohara    1348:                gmp_cv_asm_lsym_prefix,
        !          1349: [for gmp_tmp_pre in L .L $ L$; do
        !          1350:   echo "Trying $gmp_tmp_pre" >&AC_FD_CC
        !          1351:   GMP_TRY_ASSEMBLE(
        !          1352: [dummy${gmp_cv_asm_label_suffix}
        !          1353: ${gmp_tmp_pre}gurkmacka${gmp_cv_asm_label_suffix}],
        !          1354:   [if $NM conftest.$OBJEXT >conftest.nm 2>&AC_FD_CC; then : ; else
        !          1355:     cat conftest.nm >&AC_FD_CC
        !          1356:     AC_MSG_WARN(["$NM" failure])
        !          1357:     break
        !          1358:   fi
        !          1359:   cat conftest.nm >&AC_FD_CC
        !          1360:   if grep gurkmacka conftest.nm >/dev/null; then : ; else
        !          1361:     # no mention of the symbol, this is good
        !          1362:     gmp_cv_asm_lsym_prefix="$gmp_tmp_pre"
        !          1363:     break
        !          1364:   fi
        !          1365:   if grep [' [Nt] .*gurkmacka'] conftest.nm >/dev/null; then
        !          1366:     # symbol mentioned as a local, use this if nothing better
        !          1367:     if test -z "$gmp_cv_asm_lsym_prefix"; then
        !          1368:       gmp_cv_asm_lsym_prefix="$gmp_tmp_pre"
1.1       maekawa  1369:     fi
                   1370:   fi
1.1.1.2 ! ohara    1371:   ])
1.1       maekawa  1372: done
                   1373: rm -f conftest*
1.1.1.2 ! ohara    1374: if test -z "$gmp_cv_asm_lsym_prefix"; then
        !          1375:   gmp_cv_asm_lsym_prefix=L
        !          1376:   AC_MSG_WARN([cannot determine local label, using default $gmp_cv_asm_lsym_prefix])
        !          1377: fi
1.1       maekawa  1378: ])
1.1.1.2 ! ohara    1379: echo ["define(<LSYM_PREFIX>, <${gmp_cv_asm_lsym_prefix}>)"] >> $gmp_tmpconfigm4
        !          1380: AC_DEFINE_UNQUOTED(LSYM_PREFIX, "$gmp_cv_asm_lsym_prefix",
        !          1381:                    [Assembler local label prefix])
1.1       maekawa  1382: ])
                   1383:
                   1384:
1.1.1.2 ! ohara    1385: dnl  GMP_ASM_W32
        !          1386: dnl  -----------
        !          1387: dnl  How to define a 32-bit word.
        !          1388:
        !          1389: AC_DEFUN(GMP_ASM_W32,
        !          1390: [AC_REQUIRE([GMP_ASM_DATA])
        !          1391: AC_REQUIRE([GMP_ASM_GLOBL])
        !          1392: AC_REQUIRE([GMP_ASM_LABEL_SUFFIX])
        !          1393: AC_REQUIRE([GMP_PROG_NM])
        !          1394: AC_CACHE_CHECK([how to define a 32-bit word],
        !          1395:               gmp_cv_asm_w32,
        !          1396: [case $host in
1.1       maekawa  1397:   *-*-hpux*)
1.1.1.2 ! ohara    1398:     # FIXME: HPUX puts first symbol at 0x40000000, breaking our assumption
        !          1399:     # that it's at 0x0.  We'll have to declare another symbol before the
        !          1400:     # .long/.word and look at the distance between the two symbols.  The
        !          1401:     # only problem is that the sed expression(s) barfs (on Solaris, for
        !          1402:     # example) for the symbol with value 0.  For now, HPUX uses .word.
        !          1403:     gmp_cv_asm_w32=".word"
1.1       maekawa  1404:     ;;
                   1405:   *-*-*)
1.1.1.2 ! ohara    1406:     gmp_tmp_val=
1.1       maekawa  1407:     for gmp_tmp_op in .long .word; do
1.1.1.2 ! ohara    1408:       GMP_TRY_ASSEMBLE(
        !          1409: [      $gmp_cv_asm_data
        !          1410:        $gmp_cv_asm_globl       foo
1.1       maekawa  1411:        $gmp_tmp_op     0
1.1.1.2 ! ohara    1412: foo$gmp_cv_asm_label_suffix
        !          1413:        .byte   0],
        !          1414:         [gmp_tmp_val=[`$NM conftest.$OBJEXT | grep foo | \
        !          1415:           sed -e 's;[[][0-9][]]\(.*\);\1;' -e 's;[^1-9]*\([0-9]*\).*;\1;'`]
        !          1416:         if test "$gmp_tmp_val" = 4; then
        !          1417:           gmp_cv_asm_w32="$gmp_tmp_op"
1.1       maekawa  1418:           break
1.1.1.2 ! ohara    1419:         fi])
1.1       maekawa  1420:     done
1.1.1.2 ! ohara    1421:     rm -f conftest*
1.1       maekawa  1422:     ;;
                   1423: esac
1.1.1.2 ! ohara    1424: if test -z "$gmp_cv_asm_w32"; then
        !          1425:   AC_MSG_ERROR([cannot determine how to define a 32-bit word])
1.1       maekawa  1426: fi
                   1427: ])
1.1.1.2 ! ohara    1428: echo ["define(<W32>, <$gmp_cv_asm_w32>)"] >> $gmp_tmpconfigm4
1.1       maekawa  1429: ])
                   1430:
1.1.1.2 ! ohara    1431:
        !          1432: dnl  GMP_ASM_X86_MMX([ACTION-IF-YES][,ACTION-IF-NO])
        !          1433: dnl  -----------------------------------------------
        !          1434: dnl  Determine whether the assembler supports MMX instructions.
        !          1435: dnl
        !          1436: dnl  This macro is wanted before GMP_ASM_TEXT, so ".text" is hard coded
        !          1437: dnl  here.  ".text" is believed to be correct on all x86 systems, certainly
        !          1438: dnl  it's all GMP_ASM_TEXT gives currently.  Actually ".text" probably isn't
        !          1439: dnl  needed at all, at least for just checking instruction syntax.
        !          1440: dnl
        !          1441: dnl  "movq %mm0, %mm1" should assemble to "0f 6f c8", but Solaris 2.6 and
        !          1442: dnl  2.7 wrongly assemble it to "0f 6f c1" (that being the reverse "movq
        !          1443: dnl  %mm1, %mm0").  It seems more trouble than it's worth to work around
        !          1444: dnl  this in the code, so just detect and reject.
        !          1445:
        !          1446: AC_DEFUN(GMP_ASM_X86_MMX,
        !          1447: [AC_CACHE_CHECK([if the assembler knows about MMX instructions],
        !          1448:                gmp_cv_asm_x86_mmx,
        !          1449: [GMP_TRY_ASSEMBLE(
        !          1450: [      .text
        !          1451:        movq    %mm0, %mm1],
        !          1452: [gmp_cv_asm_x86_mmx=yes
        !          1453: case $host in
        !          1454: *-*-solaris*)
        !          1455:   if (dis conftest.$OBJEXT >conftest.out) 2>/dev/null; then
        !          1456:     if grep "0f 6f c1" conftest.out >/dev/null; then
        !          1457:       gmp_cv_asm_x86_mmx=movq-bug
        !          1458:     fi
        !          1459:   else
        !          1460:     AC_MSG_WARN(["dis" not available to check for "as" movq bug])
        !          1461:   fi
        !          1462: esac],
        !          1463: [gmp_cv_asm_x86_mmx=no])])
        !          1464:
        !          1465: case $gmp_cv_asm_x86_mmx in
        !          1466: movq-bug)
        !          1467:   AC_MSG_WARN([+----------------------------------------------------------])
        !          1468:   AC_MSG_WARN([| WARNING WARNING WARNING])
        !          1469:   AC_MSG_WARN([| Host CPU has MMX code, but the assembler])
        !          1470:   AC_MSG_WARN([|     $CCAS $CFLAGS])
        !          1471:   AC_MSG_WARN([| has the Solaris 2.6 and 2.7 bug where register to register])
        !          1472:   AC_MSG_WARN([| movq operands are reversed.])
        !          1473:   AC_MSG_WARN([| Non-MMX replacements will be used.])
        !          1474:   AC_MSG_WARN([| This will be an inferior build.])
        !          1475:   AC_MSG_WARN([+----------------------------------------------------------])
        !          1476:   ;;
        !          1477: no)
        !          1478:   AC_MSG_WARN([+----------------------------------------------------------])
        !          1479:   AC_MSG_WARN([| WARNING WARNING WARNING])
        !          1480:   AC_MSG_WARN([| Host CPU has MMX code, but it can't be assembled by])
        !          1481:   AC_MSG_WARN([|     $CCAS $CFLAGS])
        !          1482:   AC_MSG_WARN([| Non-MMX replacements will be used.])
        !          1483:   AC_MSG_WARN([| This will be an inferior build.])
        !          1484:   AC_MSG_WARN([+----------------------------------------------------------])
        !          1485:   ;;
        !          1486: esac
        !          1487: if test "$gmp_cv_asm_x86_mmx" = yes; then
        !          1488:   ifelse([$1],,:,[$1])
        !          1489: else
        !          1490:   ifelse([$2],,:,[$2])
1.1       maekawa  1491: fi
                   1492: ])
1.1.1.2 ! ohara    1493:
        !          1494:
        !          1495: dnl  GMP_ASM_X86_SHLDL_CL
        !          1496: dnl  --------------------
        !          1497:
        !          1498: AC_DEFUN(GMP_ASM_X86_SHLDL_CL,
        !          1499: [AC_REQUIRE([GMP_ASM_TEXT])
        !          1500: AC_CACHE_CHECK([if the assembler takes cl with shldl],
        !          1501:                gmp_cv_asm_x86_shldl_cl,
        !          1502: [GMP_TRY_ASSEMBLE(
        !          1503: [      $gmp_cv_asm_text
        !          1504:        shldl   %cl, %eax, %ebx],
        !          1505:   gmp_cv_asm_x86_shldl_cl=yes,
        !          1506:   gmp_cv_asm_x86_shldl_cl=no)
        !          1507: ])
        !          1508: if test "$gmp_cv_asm_x86_shldl_cl" = "yes"; then
        !          1509:   GMP_DEFINE(WANT_SHLDL_CL,1)
1.1       maekawa  1510: else
1.1.1.2 ! ohara    1511:   GMP_DEFINE(WANT_SHLDL_CL,0)
        !          1512: fi
        !          1513: ])
        !          1514:
        !          1515:
        !          1516: dnl  GMP_ASM_X86_SSE2([ACTION-IF-YES][,ACTION-IF-NO])
        !          1517: dnl  ------------------------------------------------
        !          1518: dnl  Determine whether the assembler supports SSE2 instructions.
        !          1519: dnl
        !          1520: dnl  This macro is wanted before GMP_ASM_TEXT, so ".text" is hard coded
        !          1521: dnl  here.  ".text" is believed to be correct on all x86 systems, certainly
        !          1522: dnl  it's all GMP_ASM_TEXT gives currently.  Actually ".text" probably isn't
        !          1523: dnl  needed at all, at least for just checking instruction syntax.
        !          1524:
        !          1525: AC_DEFUN(GMP_ASM_X86_SSE2,
        !          1526: [AC_CACHE_CHECK([if the assembler knows about SSE2 instructions],
        !          1527:                gmp_cv_asm_x86_sse2,
        !          1528: [GMP_TRY_ASSEMBLE(
        !          1529: [      .text
        !          1530:        paddq   %mm0, %mm1],
        !          1531:   [gmp_cv_asm_x86_sse2=yes],
        !          1532:   [gmp_cv_asm_x86_sse2=no])
        !          1533: ])
        !          1534: case $gmp_cv_asm_x86_sse2 in
        !          1535: yes)
        !          1536:   ifelse([$1],,:,[$1])
        !          1537:   ;;
        !          1538: *)
1.1       maekawa  1539:   AC_MSG_WARN([+----------------------------------------------------------])
                   1540:   AC_MSG_WARN([| WARNING WARNING WARNING])
1.1.1.2 ! ohara    1541:   AC_MSG_WARN([| Host CPU has SSE2 code, but it can't be assembled by])
1.1       maekawa  1542:   AC_MSG_WARN([|     $CCAS $CFLAGS])
1.1.1.2 ! ohara    1543:   AC_MSG_WARN([| Non-SSE2 replacements will be used.])
1.1       maekawa  1544:   AC_MSG_WARN([| This will be an inferior build.])
                   1545:   AC_MSG_WARN([+----------------------------------------------------------])
1.1.1.2 ! ohara    1546:   ifelse([$2],,:,[$2])
        !          1547:   ;;
        !          1548: esac
        !          1549: ])
        !          1550:
        !          1551:
        !          1552: dnl  GMP_ASM_X86_MCOUNT
        !          1553: dnl  ------------------
        !          1554: dnl  Find out how to call mcount for profiling on an x86 system.
        !          1555: dnl
        !          1556: dnl  A dummy function is compiled and the ".s" output examined.  The pattern
        !          1557: dnl  matching might be a bit fragile, but should work at least with gcc on
        !          1558: dnl  sensible systems.  Certainly it's better than hard coding a table of
        !          1559: dnl  conventions.
        !          1560: dnl
        !          1561: dnl  For non-PIC, any ".data" is taken to mean a counter might be passed.
        !          1562: dnl  It's assumed a movl will set it up, and the right register is taken
        !          1563: dnl  from that movl.  Any movl involving %esp is ignored (a frame pointer
        !          1564: dnl  setup normally).
        !          1565: dnl
        !          1566: dnl  For PIC, any ".data" is similarly interpreted, but a GOTOFF identifies
        !          1567: dnl  the line setting up the right register.
        !          1568: dnl
        !          1569: dnl  In both cases a line with "mcount" identifies the call and that line is
        !          1570: dnl  used literally.
        !          1571: dnl
        !          1572: dnl  On some systems (eg. FreeBSD 3.5) gcc emits ".data" but doesn't use it,
        !          1573: dnl  so it's not an error to have .data but then not find a register.
        !          1574: dnl
        !          1575: dnl  Variations in mcount conventions on different x86 systems can be found
        !          1576: dnl  in gcc config/i386.  mcount can have a "_" prefix or be .mcount or
        !          1577: dnl  _mcount_ptr, and for PIC it can be called through a GOT entry, or via
        !          1578: dnl  the PLT.  If a pointer to a counter is required it's passed in %eax or
        !          1579: dnl  %edx.
        !          1580: dnl
        !          1581: dnl  Flags to specify PIC are taken from $lt_prog_compiler_pic set by
        !          1582: dnl  AC_PROG_LIBTOOL.
        !          1583: dnl
        !          1584: dnl  Enhancement: Cache the values determined here. But what's the right way
        !          1585: dnl  to get two variables (mcount_nonpic_reg and mcount_nonpic_call say) set
        !          1586: dnl  from one block of commands?
        !          1587:
        !          1588: AC_DEFUN(GMP_ASM_X86_MCOUNT,
        !          1589: [AC_REQUIRE([AC_ENABLE_SHARED])
        !          1590: AC_REQUIRE([AC_PROG_LIBTOOL])
        !          1591: AC_MSG_CHECKING([how to call x86 mcount])
        !          1592: cat >conftest.c <<EOF
        !          1593: foo(){bar();}
        !          1594: EOF
        !          1595:
        !          1596: if test "$enable_static" = yes; then
        !          1597:   gmp_asmout_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c 1>&AC_FD_CC"
        !          1598:   if AC_TRY_EVAL(gmp_asmout_compile); then
        !          1599:     if grep '\.data' conftest.s >/dev/null; then
        !          1600:       mcount_nonpic_reg=`sed -n ['/esp/!s/.*movl.*,\(%[a-z]*\).*$/\1/p'] conftest.s`
        !          1601:     else
        !          1602:       mcount_nonpic_reg=
        !          1603:     fi
        !          1604:     mcount_nonpic_call=`grep 'call.*mcount' conftest.s`
        !          1605:     if test -z "$mcount_nonpic_call"; then
        !          1606:       AC_MSG_ERROR([Cannot find mcount call for non-PIC])
        !          1607:     fi
        !          1608:   else
        !          1609:     AC_MSG_ERROR([Cannot compile test program for non-PIC])
        !          1610:   fi
1.1       maekawa  1611: fi
                   1612:
1.1.1.2 ! ohara    1613: if test "$enable_shared" = yes; then
        !          1614:   gmp_asmout_compile="$CC $CFLAGS $CPPFLAGS $lt_prog_compiler_pic -S conftest.c 1>&AC_FD_CC"
        !          1615:   if AC_TRY_EVAL(gmp_asmout_compile); then
        !          1616:     if grep '\.data' conftest.s >/dev/null; then
        !          1617:       case $lt_prog_compiler_pic in
        !          1618:         *-DDLL_EXPORT*)
        !          1619:           # Windows DLLs have non-PIC style mcount
        !          1620:           mcount_pic_reg=`sed -n ['/esp/!s/.*movl.*,\(%[a-z]*\).*$/\1/p'] conftest.s`
        !          1621:           ;;
        !          1622:         *)
        !          1623:           mcount_pic_reg=`sed -n ['s/.*GOTOFF.*,\(%[a-z]*\).*$/\1/p'] conftest.s`
        !          1624:           ;;
        !          1625:       esac
        !          1626:     else
        !          1627:       mcount_pic_reg=
        !          1628:     fi
        !          1629:     mcount_pic_call=`grep 'call.*mcount' conftest.s`
        !          1630:     if test -z "$mcount_pic_call"; then
        !          1631:       AC_MSG_ERROR([Cannot find mcount call for PIC])
        !          1632:     fi
        !          1633:   else
        !          1634:     AC_MSG_ERROR([Cannot compile test program for PIC])
        !          1635:   fi
1.1       maekawa  1636: fi
1.1.1.2 ! ohara    1637:
        !          1638: GMP_DEFINE_RAW(["define(<MCOUNT_NONPIC_REG>, <\`$mcount_nonpic_reg'>)"])
        !          1639: GMP_DEFINE_RAW(["define(<MCOUNT_NONPIC_CALL>,<\`$mcount_nonpic_call'>)"])
        !          1640: GMP_DEFINE_RAW(["define(<MCOUNT_PIC_REG>,    <\`$mcount_pic_reg'>)"])
        !          1641: GMP_DEFINE_RAW(["define(<MCOUNT_PIC_CALL>,   <\`$mcount_pic_call'>)"])
        !          1642:
        !          1643: rm -f conftest.*
        !          1644: AC_MSG_RESULT([determined])
        !          1645: ])
        !          1646:
        !          1647:
        !          1648: dnl  GMP_ASM_M68K_INSTRUCTION
        !          1649: dnl  ------------------------
        !          1650: dnl  Not sure if ".l" and "%" are independent settings, but it doesn't hurt
        !          1651: dnl  to try all four possibilities.  Note that the % ones must be first, so
        !          1652: dnl  "d0" won't be interpreted as a label.
        !          1653: dnl
        !          1654: dnl  gas 1.92.3 on NetBSD 1.4 needs to be tested with a two operand
        !          1655: dnl  instruction.  It takes registers without "%", but a single operand
        !          1656: dnl  "clrl %d0" only gives a warning, not an error.
        !          1657:
        !          1658: AC_DEFUN(GMP_ASM_M68K_INSTRUCTION,
        !          1659: [AC_REQUIRE([GMP_ASM_TEXT])
        !          1660: AC_CACHE_CHECK([assembler instruction and register style],
        !          1661:                gmp_cv_asm_m68k_instruction,
        !          1662: [gmp_cv_asm_m68k_instruction=unknown
        !          1663: for i in "addl %d0,%d1" "add.l %d0,%d1" "addl d0,d1" "add.l d0,d1"; do
        !          1664:   GMP_TRY_ASSEMBLE(
        !          1665:     [  $gmp_cv_asm_text
        !          1666:        $i],
        !          1667:     [gmp_cv_asm_m68k_instruction=$i
        !          1668:     rm -f conftest*
        !          1669:     break])
        !          1670: done
        !          1671: ])
        !          1672: case $gmp_cv_asm_m68k_instruction in
        !          1673: "addl d0,d1")    want_dot_size=no;  want_register_percent=no  ;;
        !          1674: "addl %d0,%d1")  want_dot_size=no;  want_register_percent=yes ;;
        !          1675: "add.l d0,d1")   want_dot_size=yes; want_register_percent=no  ;;
        !          1676: "add.l %d0,%d1") want_dot_size=yes; want_register_percent=yes ;;
        !          1677: *) AC_MSG_ERROR([cannot determine assembler instruction and register style]) ;;
        !          1678: esac
        !          1679: GMP_DEFINE_RAW(["define(<WANT_REGISTER_PERCENT>, <\`$want_register_percent'>)"])
        !          1680: GMP_DEFINE_RAW(["define(<WANT_DOT_SIZE>, <\`$want_dot_size'>)"])
1.1       maekawa  1681: ])
1.1.1.2 ! ohara    1682:
        !          1683:
        !          1684: dnl  GMP_ASM_M68K_ADDRESSING
        !          1685: dnl  -----------------------
        !          1686:
        !          1687: AC_DEFUN(GMP_ASM_M68K_ADDRESSING,
        !          1688: [AC_REQUIRE([GMP_ASM_TEXT])
        !          1689: AC_REQUIRE([GMP_ASM_M68K_INSTRUCTION])
        !          1690: AC_CACHE_CHECK([assembler addressing style],
        !          1691:                gmp_cv_asm_m68k_addressing,
        !          1692: [case $gmp_cv_asm_m68k_instruction in
        !          1693: addl*)  movel=movel ;;
        !          1694: add.l*) movel=move.l ;;
        !          1695: *) AC_MSG_ERROR([oops, unrecognised gmp_cv_asm_m68k_instruction]) ;;
        !          1696: esac
        !          1697: case $gmp_cv_asm_m68k_instruction in
        !          1698: *"%d0,%d1") dreg=%d0; areg=%a0 ;;
        !          1699: *"d0,d1")   dreg=d0;  areg=a0  ;;
        !          1700: *) AC_MSG_ERROR([oops, unrecognised gmp_cv_asm_m68k_instruction]) ;;
        !          1701: esac
        !          1702: GMP_TRY_ASSEMBLE(
        !          1703: [      $gmp_cv_asm_text
        !          1704:        $movel  $dreg, $areg@-],
        !          1705:   [gmp_cv_asm_m68k_addressing=mit],
        !          1706: [GMP_TRY_ASSEMBLE(
        !          1707: [      $gmp_cv_asm_text
        !          1708:        $movel  $dreg, -($areg)],
        !          1709:   [gmp_cv_asm_m68k_addressing=motorola],
        !          1710: [AC_MSG_ERROR([cannot determine assembler addressing style])])])
        !          1711: ])
        !          1712: GMP_DEFINE_RAW(["define(<WANT_ADDRESSING>, <\`$gmp_cv_asm_m68k_addressing'>)"])
        !          1713: ])
        !          1714:
        !          1715:
        !          1716: dnl  GMP_ASM_M68K_BRANCHES
        !          1717: dnl  ---------------------
        !          1718: dnl  "bra" is the standard branch instruction.  "jra" or "jbra" are
        !          1719: dnl  preferred where available, since on gas for instance they give a
        !          1720: dnl  displacement only as big as it needs to be, whereas "bra" is always
        !          1721: dnl  16-bits.  This applies to the conditional branches "bcc" etc too.
        !          1722: dnl  However "dbcc" etc on gas are already only as big as they need to be.
        !          1723:
        !          1724: AC_DEFUN(GMP_ASM_M68K_BRANCHES,
        !          1725: [AC_REQUIRE([GMP_ASM_TEXT])
        !          1726: AC_CACHE_CHECK([assembler shortest branches],
        !          1727:                gmp_cv_asm_m68k_branches,
        !          1728: [gmp_cv_asm_m68k_branches=unknown
        !          1729: for i in jra jbra bra; do
        !          1730:   GMP_TRY_ASSEMBLE(
        !          1731: [      $gmp_cv_asm_text
        !          1732: foo$gmp_cv_asm_label_suffix
        !          1733:        $i      foo],
        !          1734:   [gmp_cv_asm_m68k_branches=$i
        !          1735:   rm -f conftest*
        !          1736:   break])
        !          1737: done
        !          1738: ])
        !          1739: if test "$gmp_cv_asm_m68k_branches" = unknown; then
        !          1740:   AC_MSG_ERROR([cannot determine assembler branching style])
        !          1741: fi
        !          1742: GMP_DEFINE_RAW(["define(<WANT_BRANCHES>, <\`$gmp_cv_asm_m68k_branches'>)"])
        !          1743: ])
        !          1744:
        !          1745:
        !          1746: dnl  GMP_ASM_POWERPC_R_REGISTERS
        !          1747: dnl  ---------------------------
        !          1748: dnl  Determine whether the assembler takes powerpc registers with an "r" as
        !          1749: dnl  in "r6", or as plain "6".  The latter is standard, but NeXT, Rhapsody,
        !          1750: dnl  and MacOS-X require the "r" forms.
        !          1751: dnl
        !          1752: dnl  See also mpn/powerpc32/powerpc-defs.m4 which uses the result of this
        !          1753: dnl  test.
        !          1754:
        !          1755: AC_DEFUN(GMP_ASM_POWERPC_R_REGISTERS,
        !          1756: [AC_REQUIRE([GMP_ASM_TEXT])
        !          1757: AC_CACHE_CHECK([if the assembler needs r on registers],
        !          1758:                gmp_cv_asm_powerpc_r_registers,
        !          1759: [GMP_TRY_ASSEMBLE(
        !          1760: [      $gmp_cv_asm_text
        !          1761:        mtctr   6],
        !          1762: [gmp_cv_asm_powerpc_r_registers=no],
        !          1763: [GMP_TRY_ASSEMBLE(
        !          1764: [      $gmp_cv_asm_text
        !          1765:        mtctr   r6],
        !          1766: [gmp_cv_asm_powerpc_r_registers=yes],
        !          1767: [AC_MSG_ERROR([neither "mtctr 6" nor "mtctr r6" works])])])])
        !          1768:
        !          1769: GMP_DEFINE_RAW(["define(<WANT_R_REGISTERS>,<$gmp_cv_asm_powerpc_r_registers>)"])
        !          1770: ])
        !          1771:
        !          1772:
        !          1773: dnl  GMP_ASM_SPARC_REGISTER
        !          1774: dnl  ----------------------
        !          1775: dnl  Determine whether the assembler accepts the ".register" directive.
        !          1776: dnl  Old versions of solaris "as" don't.
        !          1777: dnl
        !          1778: dnl  See also mpn/sparc32/sparc-defs.m4 which uses the result of this test.
        !          1779:
        !          1780: AC_DEFUN(GMP_ASM_SPARC_REGISTER,
        !          1781: [AC_REQUIRE([GMP_ASM_TEXT])
        !          1782: AC_CACHE_CHECK([if the assembler accepts ".register"],
        !          1783:                gmp_cv_asm_sparc_register,
        !          1784: [GMP_TRY_ASSEMBLE(
        !          1785: [      $gmp_cv_asm_text
        !          1786:        .register       %g2,#scratch
        !          1787: ],
        !          1788: [gmp_cv_asm_sparc_register=yes],
        !          1789: [gmp_cv_asm_sparc_register=no])])
        !          1790:
        !          1791: GMP_DEFINE_RAW(["define(<HAVE_REGISTER>,<$gmp_cv_asm_sparc_register>)"])
        !          1792: ])
        !          1793:
        !          1794:
        !          1795: dnl  GMP_C_ATTRIBUTE_CONST
        !          1796: dnl  ---------------------
        !          1797:
        !          1798: AC_DEFUN(GMP_C_ATTRIBUTE_CONST,
        !          1799: [AC_CACHE_CHECK([whether gcc __attribute__ ((const)) works],
        !          1800:                 gmp_cv_c_attribute_const,
        !          1801: [AC_TRY_COMPILE([int foo (int x) __attribute__ ((const));], ,
        !          1802:   gmp_cv_c_attribute_const=yes, gmp_cv_c_attribute_const=no)
        !          1803: ])
        !          1804: if test $gmp_cv_c_attribute_const = yes; then
        !          1805:   AC_DEFINE(HAVE_ATTRIBUTE_CONST, 1,
        !          1806:   [Define if the compiler accepts gcc style __attribute__ ((const))])
        !          1807: fi
        !          1808: ])
        !          1809:
        !          1810:
        !          1811: dnl  GMP_C_ATTRIBUTE_MALLOC
        !          1812: dnl  ----------------------
        !          1813: dnl  gcc 2.95.x accepts __attribute__ ((malloc)) but with a warning that
        !          1814: dnl  it's ignored.  Pretend it doesn't exist in this case, to avoid that
        !          1815: dnl  warning.
        !          1816:
        !          1817: AC_DEFUN(GMP_C_ATTRIBUTE_MALLOC,
        !          1818: [AC_CACHE_CHECK([whether gcc __attribute__ ((malloc)) works],
        !          1819:                 gmp_cv_c_attribute_malloc,
        !          1820: [cat >conftest.c <<EOF
        !          1821: void *foo (int x) __attribute__ ((malloc));
        !          1822: EOF
        !          1823: gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >conftest.out 2>&1"
        !          1824: if AC_TRY_EVAL(gmp_compile); then
        !          1825:   if grep "attribute directive ignored" conftest.out >/dev/null; then
        !          1826:     gmp_cv_c_attribute_malloc=no
        !          1827:   else
        !          1828:     gmp_cv_c_attribute_malloc=yes
        !          1829:   fi
1.1       maekawa  1830: else
1.1.1.2 ! ohara    1831:   gmp_cv_c_attribute_malloc=no
        !          1832: fi
        !          1833: cat conftest.out >&AC_FD_CC
        !          1834: rm -f conftest*
        !          1835: ])
        !          1836: if test $gmp_cv_c_attribute_malloc = yes; then
        !          1837:   AC_DEFINE(HAVE_ATTRIBUTE_MALLOC, 1,
        !          1838:   [Define if the compiler accepts gcc style __attribute__ ((malloc))])
1.1       maekawa  1839: fi
1.1.1.2 ! ohara    1840: ])
1.1       maekawa  1841:
1.1.1.2 ! ohara    1842:
        !          1843: dnl  GMP_C_ATTRIBUTE_MODE
        !          1844: dnl  --------------------
        !          1845: dnl  Introduced in gcc 2.2, but perhaps not in all Apple derived versions.
        !          1846:
        !          1847: AC_DEFUN(GMP_C_ATTRIBUTE_MODE,
        !          1848: [AC_CACHE_CHECK([whether gcc __attribute__ ((mode (XX))) works],
        !          1849:                 gmp_cv_c_attribute_mode,
        !          1850: [AC_TRY_COMPILE([typedef int SItype __attribute__ ((mode (SI)));], ,
        !          1851:   gmp_cv_c_attribute_mode=yes, gmp_cv_c_attribute_mode=no)
        !          1852: ])
        !          1853: if test $gmp_cv_c_attribute_mode = yes; then
        !          1854:   AC_DEFINE(HAVE_ATTRIBUTE_MODE, 1,
        !          1855:   [Define if the compiler accepts gcc style __attribute__ ((mode (XX)))])
1.1       maekawa  1856: fi
1.1.1.2 ! ohara    1857: ])
        !          1858:
1.1       maekawa  1859:
1.1.1.2 ! ohara    1860: dnl  GMP_C_ATTRIBUTE_NORETURN
        !          1861: dnl  ------------------------
        !          1862:
        !          1863: AC_DEFUN(GMP_C_ATTRIBUTE_NORETURN,
        !          1864: [AC_CACHE_CHECK([whether gcc __attribute__ ((noreturn)) works],
        !          1865:                 gmp_cv_c_attribute_noreturn,
        !          1866: [AC_TRY_COMPILE([void foo (int x) __attribute__ ((noreturn));], ,
        !          1867:   gmp_cv_c_attribute_noreturn=yes, gmp_cv_c_attribute_noreturn=no)
        !          1868: ])
        !          1869: if test $gmp_cv_c_attribute_noreturn = yes; then
        !          1870:   AC_DEFINE(HAVE_ATTRIBUTE_NORETURN, 1,
        !          1871:   [Define if the compiler accepts gcc style __attribute__ ((noreturn))])
        !          1872: fi
        !          1873: ])
        !          1874:
        !          1875:
        !          1876: dnl  GMP_C_DOUBLE_FORMAT
        !          1877: dnl  -------------------
        !          1878: dnl  Determine the floating point format.
        !          1879: dnl
        !          1880: dnl  The object file is grepped, in order to work when cross compiling.  A
        !          1881: dnl  start and end sequence is included to avoid false matches, and
        !          1882: dnl  allowance is made for the desired data crossing an "od -b" line
        !          1883: dnl  boundary.  The test number is a small integer so it should appear
        !          1884: dnl  exactly, no rounding or truncation etc.
        !          1885: dnl
        !          1886: dnl  "od -b", incidentally, is supported even by Unix V7, and the awk script
        !          1887: dnl  used doesn't have functions or anything, so even an "old" awk should
        !          1888: dnl  suffice.
        !          1889:
        !          1890: AC_DEFUN(GMP_C_DOUBLE_FORMAT,
        !          1891: [AC_REQUIRE([AC_PROG_CC])
        !          1892: AC_REQUIRE([AC_PROG_AWK])
        !          1893: AC_CACHE_CHECK([format of `double' floating point],
        !          1894:                 gmp_cv_c_double_format,
        !          1895: [gmp_cv_c_double_format=unknown
        !          1896: cat >conftest.c <<\EOF
        !          1897: [struct {
        !          1898:   char    before[8];
        !          1899:   double  x;
        !          1900:   char    after[8];
        !          1901: } foo = {
        !          1902:   { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
        !          1903:   -123456789.0,
        !          1904:   { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 },
        !          1905: };]
        !          1906: EOF
        !          1907: gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >&AC_FD_CC 2>&1"
        !          1908: if AC_TRY_EVAL(gmp_compile); then
        !          1909: cat >conftest.awk <<\EOF
        !          1910: [
        !          1911: BEGIN {
        !          1912:   found = 0
        !          1913: }
        !          1914:
        !          1915: {
        !          1916:   for (f = 2; f <= NF; f++)
        !          1917:     {
        !          1918:       for (i = 0; i < 23; i++)
        !          1919:         got[i] = got[i+1];
        !          1920:       got[23] = $f;
        !          1921:
        !          1922:       # match the special begin and end sequences
        !          1923:       if (got[0] != "001") continue
        !          1924:       if (got[1] != "043") continue
        !          1925:       if (got[2] != "105") continue
        !          1926:       if (got[3] != "147") continue
        !          1927:       if (got[4] != "211") continue
        !          1928:       if (got[5] != "253") continue
        !          1929:       if (got[6] != "315") continue
        !          1930:       if (got[7] != "357") continue
        !          1931:       if (got[16] != "376") continue
        !          1932:       if (got[17] != "334") continue
        !          1933:       if (got[18] != "272") continue
        !          1934:       if (got[19] != "230") continue
        !          1935:       if (got[20] != "166") continue
        !          1936:       if (got[21] != "124") continue
        !          1937:       if (got[22] != "062") continue
        !          1938:       if (got[23] != "020") continue
        !          1939:
        !          1940:       saw = " (" got[8] " " got[9] " " got[10] " " got[11] " " got[12] " " got[13] " " got[14] " " got[15] ")"
        !          1941:
        !          1942:       if (got[8]  == "000" &&  \
        !          1943:           got[9]  == "000" &&  \
        !          1944:           got[10] == "000" &&  \
        !          1945:           got[11] == "124" &&  \
        !          1946:           got[12] == "064" &&  \
        !          1947:           got[13] == "157" &&  \
        !          1948:           got[14] == "235" &&  \
        !          1949:           got[15] == "301")
        !          1950:         {
        !          1951:           print "IEEE little endian"
        !          1952:           found = 1
        !          1953:           exit
        !          1954:         }
        !          1955:
        !          1956:       # ARM style little endian but with the two 4-byte halves swapped
        !          1957:       if (got[8]  == "064" &&  \
        !          1958:           got[9]  == "157" &&  \
        !          1959:           got[10] == "235" &&  \
        !          1960:           got[11] == "301" &&  \
        !          1961:           got[12] == "000" &&  \
        !          1962:           got[13] == "000" &&  \
        !          1963:           got[14] == "000" &&  \
        !          1964:           got[15] == "124")
        !          1965:         {
        !          1966:           print "IEEE little endian, swapped halves"
        !          1967:           found = 1
        !          1968:           exit
        !          1969:         }
        !          1970:
        !          1971:       if (got[8]  == "301" &&  \
        !          1972:           got[9]  == "235" &&  \
        !          1973:           got[10] == "157" &&  \
        !          1974:           got[11] == "064" &&  \
        !          1975:           got[12] == "124" &&  \
        !          1976:           got[13] == "000" &&  \
        !          1977:           got[14] == "000" &&  \
        !          1978:          got[15] == "000")
        !          1979:         {
        !          1980:           print "IEEE big endian"
        !          1981:           found = 1
        !          1982:           exit
        !          1983:         }
        !          1984:
        !          1985:       if (got[8]  == "353" &&  \
        !          1986:           got[9]  == "315" &&  \
        !          1987:           got[10] == "242" &&  \
        !          1988:           got[11] == "171" &&  \
        !          1989:           got[12] == "000" &&  \
        !          1990:           got[13] == "240" &&  \
        !          1991:           got[14] == "000" &&  \
        !          1992:           got[15] == "000")
        !          1993:         {
        !          1994:           print "VAX D"
        !          1995:           found = 1
        !          1996:           exit
        !          1997:         }
        !          1998:
        !          1999:       if (got[8]  == "275" &&  \
        !          2000:           got[9]  == "301" &&  \
        !          2001:           got[10] == "064" &&  \
        !          2002:           got[11] == "157" &&  \
        !          2003:           got[12] == "000" &&  \
        !          2004:           got[13] == "124" &&  \
        !          2005:           got[14] == "000" &&  \
        !          2006:           got[15] == "000")
        !          2007:         {
        !          2008:           print "VAX G"
        !          2009:           found = 1
        !          2010:           exit
        !          2011:         }
        !          2012:
        !          2013:       if (got[8]  == "300" &&  \
        !          2014:           got[9]  == "033" &&  \
        !          2015:           got[10] == "353" &&  \
        !          2016:           got[11] == "171" &&  \
        !          2017:           got[12] == "242" &&  \
        !          2018:           got[13] == "240" &&  \
        !          2019:           got[14] == "000" &&  \
        !          2020:           got[15] == "000")
        !          2021:         {
        !          2022:           print "Cray CFP"
        !          2023:           found = 1
        !          2024:           exit
        !          2025:         }
        !          2026:     }
        !          2027: }
        !          2028:
        !          2029: END {
        !          2030:   if (! found)
        !          2031:     print "unknown", saw
        !          2032: }
        !          2033: ]
        !          2034: EOF
        !          2035:   gmp_cv_c_double_format=`od -b conftest.$OBJEXT | $AWK -f conftest.awk`
        !          2036:   case $gmp_cv_c_double_format in
        !          2037:   unknown*)
        !          2038:     echo "cannot match anything, conftest.$OBJEXT contains" >&AC_FD_CC
        !          2039:     od -b conftest.$OBJEXT >&AC_FD_CC
        !          2040:     ;;
        !          2041:   esac
1.1       maekawa  2042: else
1.1.1.2 ! ohara    2043:   AC_MSG_WARN([oops, cannot compile test program])
1.1       maekawa  2044: fi
1.1.1.2 ! ohara    2045: ])
1.1       maekawa  2046:
1.1.1.2 ! ohara    2047: AH_VERBATIM([HAVE_DOUBLE],
        !          2048: [/* Define one (and only one) of the following for the format of a `double'.
        !          2049:    If your format is not among these choices, or you don't know what it is,
        !          2050:    then leave all of them undefined.
        !          2051:    "IEEE_LITTLE_SWAPPED" means little endian, but with the two 4-byte halves
        !          2052:    swapped, as used by ARM CPUs in little endian mode.  */
        !          2053: #undef HAVE_DOUBLE_IEEE_BIG_ENDIAN
        !          2054: #undef HAVE_DOUBLE_IEEE_LITTLE_ENDIAN
        !          2055: #undef HAVE_DOUBLE_IEEE_LITTLE_SWAPPED
        !          2056: #undef HAVE_DOUBLE_VAX_D
        !          2057: #undef HAVE_DOUBLE_VAX_G
        !          2058: #undef HAVE_DOUBLE_CRAY_CFP])
        !          2059:
        !          2060: case $gmp_cv_c_double_format in
        !          2061:   "IEEE big endian")
        !          2062:     AC_DEFINE(HAVE_DOUBLE_IEEE_BIG_ENDIAN, 1) ;;
        !          2063:   "IEEE little endian")
        !          2064:     AC_DEFINE(HAVE_DOUBLE_IEEE_LITTLE_ENDIAN, 1) ;;
        !          2065:   "IEEE little endian, swapped halves")
        !          2066:     AC_DEFINE(HAVE_DOUBLE_IEEE_LITTLE_SWAPPED, 1) ;;
        !          2067:   "VAX D")
        !          2068:     AC_DEFINE(HAVE_DOUBLE_VAX_D, 1) ;;
        !          2069:   "VAX G")
        !          2070:     AC_DEFINE(HAVE_DOUBLE_VAX_G, 1) ;;
        !          2071:   "Cray CFP")
        !          2072:     AC_DEFINE(HAVE_DOUBLE_CRAY_CFP, 1) ;;
        !          2073:   unknown*)
        !          2074:     ;;
        !          2075:   *)
        !          2076:     AC_MSG_WARN([oops, unrecognised float format: $gmp_cv_c_double_format])
        !          2077:     ;;
        !          2078: esac
        !          2079: ])
1.1       maekawa  2080:
                   2081:
1.1.1.2 ! ohara    2082: dnl  GMP_C_INLINE
        !          2083: dnl  ------------
        !          2084: dnl  Establish an "inline" keyword, if possible.
        !          2085: dnl
        !          2086: dnl  This is the same as AC_C_INLINE, but introduing a typedef into the test
        !          2087: dnl  program.  Some versions of HP C succeed when the return value is a
        !          2088: dnl  plain builtin type like "int", but fail when it's a typedef.
        !          2089: dnl
        !          2090: dnl  FIXME: Hopefully autoconf will do this extra itself one day.
        !          2091:
        !          2092: AC_DEFUN(GMP_C_INLINE,
        !          2093: [AC_CACHE_CHECK([for inline], gmp_cv_c_inline,
        !          2094: [gmp_cv_c_inline=no
        !          2095: for i in inline __inline__ __inline; do
        !          2096:   AC_TRY_COMPILE(
        !          2097: [#ifndef __cplusplus
        !          2098: typedef int foo_t;
        !          2099: $i foo_t func1 () { return 0; }
        !          2100: static $i foo_t func2 () { return 0; }
        !          2101: #endif], ,
        !          2102:     [gmp_cv_c_inline=$i
        !          2103:     break])
        !          2104: done
        !          2105: if test $gmp_cv_c_inline = inline; then
        !          2106:   gmp_cv_c_inline=yes
        !          2107: fi
        !          2108: ])
        !          2109: case $gmp_cv_c_inline in
        !          2110:   inline | yes) ;;
        !          2111:   no) AC_DEFINE(inline,,
        !          2112:                 [Define as `__inline' if that's what the C compiler calls it,
        !          2113:                  or to nothing if it is not supported.]) ;;
        !          2114:   *)  AC_DEFINE_UNQUOTED(inline, $gmp_cv_c_inline) ;;
        !          2115: esac
        !          2116: ])
        !          2117:
        !          2118:
        !          2119: dnl  GMP_C_RESTRICT
1.1       maekawa  2120: dnl  --------------
1.1.1.2 ! ohara    2121: dnl  Establish a "restrict" keyword, if possible, like AC_C_INLINE.
1.1       maekawa  2122: dnl
1.1.1.2 ! ohara    2123: dnl  If restrict works already, then do nothing.  Otherwise AC_DEFINE it to
        !          2124: dnl  __restrict__ or __restrict if they work, or to empty otherwise.
        !          2125: dnl
        !          2126: dnl  "restrict" is in C99.  GCC 2.95 and up has it in c99 mode, and also as
        !          2127: dnl  __restrict__ and __restrict in all modes.
        !          2128: dnl
        !          2129: dnl  "yes" is used in the cache variable if plain "restrict" works, to make
        !          2130: dnl  the configure message look nicer.
        !          2131:
        !          2132: AC_DEFUN(GMP_C_RESTRICT,
        !          2133: [AC_CACHE_CHECK([for restrict], gmp_cv_c_restrict,
        !          2134: [gmp_cv_c_restrict=no
        !          2135: for r in restrict __restrict__ __restrict; do
        !          2136:   AC_TRY_COMPILE(, [char * $r foo;],
        !          2137:     [gmp_cv_c_restrict=$r
        !          2138:     break])
        !          2139: done
        !          2140: if test $gmp_cv_c_restrict = restrict; then
        !          2141:   gmp_cv_c_restrict=yes
        !          2142: fi
        !          2143: ])
        !          2144: case $gmp_cv_c_restrict in
        !          2145:   restrict | yes) ;;
        !          2146:   no) AC_DEFINE(restrict,,
        !          2147:                 [Define as `__restrict' if that's what the C compiler calls it,
        !          2148:                  or to nothing if it is not supported.]) ;;
        !          2149:   *)  AC_DEFINE_UNQUOTED(restrict, $gmp_cv_c_restrict) ;;
        !          2150: esac
        !          2151: ])
        !          2152:
        !          2153:
        !          2154: dnl  GMP_C_SIZES
        !          2155: dnl  -----------
        !          2156: dnl  Determine some sizes, if not alredy provided by gmp-mparam.h.
        !          2157: dnl  $gmp_mparam_source is the selected gmp-mparam.h.
        !          2158: dnl
        !          2159: dnl  BITS_PER_MP_LIMB, BYTES_PER_MP_LIMB and BITS_PER_ULONG are needed at
        !          2160: dnl  preprocessing time when building the library, for use in #if
        !          2161: dnl  conditionals.
        !          2162: dnl
        !          2163: dnl  BITS_PER_MP_LIMB is also wanted as a plain constant for some macros in
        !          2164: dnl  the generated gmp.h, and is instantiated as BITS_PER_MP_LIMB.
        !          2165: dnl
        !          2166: dnl  If some assembler code depends on a particular type size it's probably
        !          2167: dnl  best to put explicit #defines for these in gmp-mparam.h.  That way if
        !          2168: dnl  strange compiler options change the size then a mismatch will be
        !          2169: dnl  detected by t-constants.c rather than only by the code crashing or
        !          2170: dnl  giving wrong results.
        !          2171: dnl
        !          2172: dnl  None of the assembler code depends on BITS_PER_ULONG currently, so it's
        !          2173: dnl  just as easy to let configure find its size as to put explicit values.
        !          2174: dnl
        !          2175: dnl  The tests here assume bits=8*sizeof, but that might not be universally
        !          2176: dnl  true.  It'd be better to probe for how many bits seem to work, like
        !          2177: dnl  t-constants does.  But all currently supported systems have limbs and
        !          2178: dnl  ulongs with bits=8*sizeof, so it's academic.  Strange systems can
        !          2179: dnl  always have the right values put in gmp-mparam.h explicitly.
        !          2180:
        !          2181: AC_DEFUN(GMP_C_SIZES,
        !          2182: [BITS_PER_MP_LIMB=[`sed -n 's/^#define BITS_PER_MP_LIMB[       ][      ]*\([0-9]*\).*$/\1/p' $gmp_mparam_source`]
        !          2183: if test -n "$BITS_PER_MP_LIMB" \
        !          2184:    && grep "^#define BYTES_PER_MP_LIMB" $gmp_mparam_source >/dev/null; then : ;
1.1       maekawa  2185: else
1.1.1.2 ! ohara    2186:   AC_CHECK_SIZEOF(mp_limb_t,,
        !          2187: [#include <stdio.h>]
        !          2188: GMP_INCLUDE_GMP_H)
        !          2189:   if test "$ac_cv_sizeof_mp_limb_t" = 0; then
        !          2190:     AC_MSG_ERROR([some sort of compiler problem, mp_limb_t doesn't seem to work])
        !          2191:   fi
        !          2192:   if test -z "$BITS_PER_MP_LIMB"; then
        !          2193:     BITS_PER_MP_LIMB="(8*$ac_cv_sizeof_mp_limb_t)"
        !          2194:   fi
        !          2195:   if grep "^#define BYTES_PER_MP_LIMB" $gmp_mparam_source >/dev/null; then : ;
        !          2196:   else
        !          2197:     AC_DEFINE_UNQUOTED(BYTES_PER_MP_LIMB, $ac_cv_sizeof_mp_limb_t,
        !          2198:                        [bytes per mp_limb_t, if not in gmp-mparam.h])
        !          2199:   fi
1.1       maekawa  2200: fi
1.1.1.2 ! ohara    2201: AC_SUBST(BITS_PER_MP_LIMB)
        !          2202: define([GMP_INCLUDE_GMP_H_BITS_PER_MP_LIMB],
        !          2203: [[#define __GMP_BITS_PER_MP_LIMB $BITS_PER_MP_LIMB
        !          2204: #define GMP_LIMB_BITS $BITS_PER_MP_LIMB]])
        !          2205:
        !          2206: if grep "^#define BITS_PER_ULONG" $gmp_mparam_source >/dev/null; then : ;
        !          2207: else
        !          2208:   case $limb_chosen in
        !          2209:   longlong)
        !          2210:     AC_CHECK_SIZEOF(unsigned long)
        !          2211:     AC_DEFINE_UNQUOTED(BITS_PER_ULONG, (8 * $ac_cv_sizeof_unsigned_long),
        !          2212:                        [bits per unsigned long, if not in gmp-mparam.h])
        !          2213:     ;;
        !          2214:   *)
        !          2215:     # Copy the limb size when a limb is a ulong
        !          2216:     AC_DEFINE(BITS_PER_ULONG, BITS_PER_MP_LIMB)
        !          2217:     ;;
        !          2218:   esac
        !          2219: fi
        !          2220: ])
        !          2221:
        !          2222:
        !          2223: dnl  GMP_C_STDARG
        !          2224: dnl  ------------
        !          2225: dnl  Test whether to use <stdarg.h> or <varargs.h>.
        !          2226: dnl
        !          2227: dnl  Notice the AC_DEFINE here is HAVE_STDARG to avoid clashing with
        !          2228: dnl  HAVE_STDARG_H which could arise from AC_CHECK_HEADERS.
        !          2229: dnl
        !          2230: dnl  This test might be slight overkill, after all there's really only going
        !          2231: dnl  to be ANSI or K&R and the two can be differentiated by AC_PROG_CC_STDC
        !          2232: dnl  or very likely by the setups for _PROTO in gmp.h.  On the other hand
        !          2233: dnl  this test is nice and direct, being what we're going to actually use.
        !          2234:
        !          2235: AC_DEFUN(GMP_C_STDARG,
        !          2236: [AC_CACHE_CHECK([whether <stdarg.h> exists and works],
        !          2237:                 gmp_cv_c_stdarg,
        !          2238: [AC_TRY_COMPILE(
        !          2239: [#include <stdarg.h>
        !          2240: int foo (int x, ...)
        !          2241: {
        !          2242:   va_list  ap;
        !          2243:   int      y;
        !          2244:   va_start (ap, x);
        !          2245:   y = va_arg (ap, int);
        !          2246:   va_end (ap);
        !          2247:   return y;
        !          2248: }],,
        !          2249: gmp_cv_c_stdarg=yes, gmp_cv_c_stdarg=no)
1.1       maekawa  2250: ])
1.1.1.2 ! ohara    2251: if test $gmp_cv_c_stdarg = yes; then
        !          2252:   AC_DEFINE(HAVE_STDARG, 1, [Define if <stdarg.h> exists and works])
        !          2253: fi
        !          2254: ])
        !          2255:
        !          2256:
        !          2257: dnl  GMP_FUNC_ALLOCA
        !          2258: dnl  ---------------
        !          2259: dnl  Determine whether "alloca" is available.  This is AC_FUNC_ALLOCA from
        !          2260: dnl  autoconf, but changed so it doesn't use alloca.c if alloca() isn't
        !          2261: dnl  available, and also to use gmp-impl.h for the conditionals detecting
        !          2262: dnl  compiler builtin alloca's.
        !          2263:
        !          2264: AC_DEFUN(GMP_FUNC_ALLOCA,
        !          2265: [AC_REQUIRE([GMP_HEADER_ALLOCA])
        !          2266: AC_CACHE_CHECK([for alloca (via gmp-impl.h)],
        !          2267:                gmp_cv_func_alloca,
        !          2268: [AC_TRY_LINK(
        !          2269: GMP_INCLUDE_GMP_H
        !          2270: [#include "$srcdir/gmp-impl.h"
        !          2271: ],
        !          2272:   [char *p = (char *) alloca (1);],
        !          2273:   gmp_cv_func_alloca=yes,
        !          2274:   gmp_cv_func_alloca=no)])
        !          2275: if test $gmp_cv_func_alloca = yes; then
        !          2276:   AC_DEFINE(HAVE_ALLOCA, 1,
        !          2277:     [Define if alloca() works (via gmp-impl.h).])
        !          2278: fi
        !          2279: ])
        !          2280:
        !          2281: AC_DEFUN(GMP_HEADER_ALLOCA,
        !          2282: [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
        !          2283: # for constant arguments.  Useless!
        !          2284: AC_CACHE_CHECK([for working alloca.h],
        !          2285:                gmp_cv_header_alloca,
        !          2286: [AC_TRY_LINK([#include <alloca.h>],
        !          2287:   [char *p = (char *) alloca (2 * sizeof (int));],
        !          2288:   gmp_cv_header_alloca=yes,
        !          2289:   gmp_cv_header_alloca=no)])
        !          2290: if test $gmp_cv_header_alloca = yes; then
        !          2291:   AC_DEFINE(HAVE_ALLOCA_H, 1,
        !          2292:     [Define if you have <alloca.h> and it should be used (not on Ultrix).])
        !          2293: fi
        !          2294: ])
        !          2295:
        !          2296:
        !          2297: dnl  GMP_OPTION_ALLOCA
        !          2298: dnl  -----------------
        !          2299: dnl  Decide what to do about --enable-alloca from the user.
        !          2300: dnl  This is a macro so it can require GMP_FUNC_ALLOCA.
        !          2301:
        !          2302: AC_DEFUN(GMP_OPTION_ALLOCA,
        !          2303: [AC_REQUIRE([GMP_FUNC_ALLOCA])
        !          2304: AC_CACHE_CHECK([how to allocate temporary memory],
        !          2305:                gmp_cv_option_alloca,
        !          2306: [case $enable_alloca in
        !          2307:   yes)
        !          2308:     gmp_cv_option_alloca=alloca
        !          2309:     ;;
        !          2310:   no)
        !          2311:     gmp_cv_option_alloca=malloc-reentrant
        !          2312:     ;;
        !          2313:   reentrant | notreentrant)
        !          2314:     case $gmp_cv_func_alloca in
        !          2315:     yes)  gmp_cv_option_alloca=alloca ;;
        !          2316:     *)    gmp_cv_option_alloca=malloc-$enable_alloca ;;
        !          2317:     esac
        !          2318:     ;;
        !          2319:   *)
        !          2320:     gmp_cv_option_alloca=$enable_alloca
        !          2321:     ;;
        !          2322: esac
        !          2323: ])
        !          2324: case $gmp_cv_option_alloca in
        !          2325:   alloca)
        !          2326:     if test $gmp_cv_func_alloca = no; then
        !          2327:       AC_MSG_ERROR([--enable-alloca=alloca specified, but alloca not available])
        !          2328:     fi
        !          2329:     AC_DEFINE(WANT_TMP_ALLOCA, 1, [--enable-alloca=yes])
        !          2330:     ;;
        !          2331:   malloc-reentrant)
        !          2332:     AC_DEFINE(WANT_TMP_REENTRANT, 1, [--enable-alloca=malloc-reentrant])
        !          2333:     TAL_OBJECT=tal-reent$U.lo
        !          2334:     ;;
        !          2335:   malloc-notreentrant)
        !          2336:     AC_DEFINE(WANT_TMP_NOTREENTRANT, 1, [--enable-alloca=malloc-notreentrant])
        !          2337:     TAL_OBJECT=tal-notreent$U.lo
        !          2338:     ;;
        !          2339:   debug)
        !          2340:     AC_DEFINE(WANT_TMP_DEBUG, 1, [--enable-alloca=debug])
        !          2341:     TAL_OBJECT=tal-debug$U.lo
        !          2342:     ;;
        !          2343:   *)
        !          2344:     # checks at the start of configure.in should protect us
        !          2345:     AC_MSG_ERROR([unrecognised --enable-alloca=$gmp_cv_option_alloca])
        !          2346:     ;;
        !          2347: esac
        !          2348: AC_SUBST(TAL_OBJECT)
        !          2349: ])
        !          2350:
        !          2351:
        !          2352: dnl  GMP_FUNC_SSCANF_WRITABLE_INPUT
        !          2353: dnl  ------------------------------
        !          2354: dnl  Determine whether sscanf requires a writable input string.
        !          2355: dnl
        !          2356: dnl  FIXME: Run a program to try this, when doing a native build.
        !          2357:
        !          2358: AC_DEFUN(GMP_FUNC_SSCANF_WRITABLE_INPUT,
        !          2359: [AC_CACHE_CHECK([whether sscanf needs writable input],
        !          2360:                  gmp_cv_func_sscanf_writable_input,
        !          2361: [case $host in
        !          2362:   *-*-hpux9 | *-*-hpux9.*)
        !          2363:      gmp_cv_func_sscanf_writable_input=yes ;;
        !          2364:   *) gmp_cv_func_sscanf_writable_input=no  ;;
        !          2365: esac
        !          2366: ])
        !          2367: case $gmp_cv_func_sscanf_writable_input in
        !          2368:   yes) AC_DEFINE(SSCANF_WRITABLE_INPUT, 1,
        !          2369:                  [Define if sscanf requires writable inputs]) ;;
        !          2370:   no)  ;;
        !          2371:   *)   AC_MSG_ERROR([unrecognised \$gmp_cv_func_sscanf_writable_input]) ;;
        !          2372: esac
        !          2373: ])
        !          2374:
        !          2375:
        !          2376: dnl  GMP_FUNC_VSNPRINTF
        !          2377: dnl  ------------------
        !          2378: dnl  Check whether vsnprintf exists, and works properly.
        !          2379: dnl
        !          2380: dnl  Sparc Solaris 2.7 in 64-bit mode doesn't always truncate, making
        !          2381: dnl  vsnprintf like vsprintf, and hence completely useless.  On one system a
        !          2382: dnl  literal string is enough to provoke the problem, on another a "%n" was
        !          2383: dnl  needed.  There seems to be something weird going on with the optimizer
        !          2384: dnl  or something, since on the first system adding a second check with
        !          2385: dnl  "%n", or even just an initialized local variable, makes it work.  In
        !          2386: dnl  any case, without bothering to get to the bottom of this, the two
        !          2387: dnl  program runs in the code below end up successfully detecting the
        !          2388: dnl  problem.
        !          2389: dnl
        !          2390: dnl  glibc 2.0.x returns either -1 or bufsize-1 for an overflow (both seen,
        !          2391: dnl  not sure which 2.0.x does which), but still puts the correct null
        !          2392: dnl  terminated result into the buffer.
        !          2393:
        !          2394: AC_DEFUN(GMP_FUNC_VSNPRINTF,
        !          2395: [AC_REQUIRE([GMP_C_STDARG])
        !          2396: AC_CHECK_FUNC(vsnprintf,
        !          2397:               [gmp_vsnprintf_exists=yes],
        !          2398:               [gmp_vsnprintf_exists=no])
        !          2399: if test "$gmp_vsnprintf_exists" = no; then
        !          2400:   gmp_cv_func_vsnprintf=no
1.1       maekawa  2401: else
1.1.1.2 ! ohara    2402:   AC_CACHE_CHECK([whether vsnprintf works],
        !          2403:                  gmp_cv_func_vsnprintf,
        !          2404:   [gmp_cv_func_vsnprintf=yes
        !          2405:    for i in 'check ("hello world");' 'int n; check ("%nhello world", &n);'; do
        !          2406:      AC_TRY_RUN([
        !          2407: #include <string.h>  /* for strcmp */
        !          2408: #include <stdio.h>   /* for vsnprintf */
        !          2409:
        !          2410: #if HAVE_STDARG
        !          2411: #include <stdarg.h>
        !          2412: #else
        !          2413: #include <varargs.h>
        !          2414: #endif
        !          2415:
        !          2416: int
        !          2417: #if HAVE_STDARG
        !          2418: check (const char *fmt, ...)
        !          2419: #else
        !          2420: check (va_alist)
        !          2421:      va_dcl
        !          2422: #endif
        !          2423: {
        !          2424:   static char  buf[128];
        !          2425:   va_list  ap;
        !          2426:   int      ret;
        !          2427:
        !          2428: #if HAVE_STDARG
        !          2429:   va_start (ap, fmt);
        !          2430: #else
        !          2431:   char *fmt;
        !          2432:   va_start (ap);
        !          2433:   fmt = va_arg (ap, char *);
        !          2434: #endif
        !          2435:
        !          2436:   ret = vsnprintf (buf, 4, fmt, ap);
        !          2437:
        !          2438:   if (strcmp (buf, "hel") != 0)
        !          2439:     exit (1);
        !          2440:
        !          2441:   /* allowed return values */
        !          2442:   if (ret != -1 && ret != 3 && ret != 11)
        !          2443:     exit (2);
        !          2444:
        !          2445:   return 0;
        !          2446: }
        !          2447:
        !          2448: int
        !          2449: main ()
        !          2450: {
        !          2451: $i
        !          2452:   exit (0);
        !          2453: }
        !          2454: ],
        !          2455:       [:],
        !          2456:       [gmp_cv_func_vsnprintf=no; break],
        !          2457:       [gmp_cv_func_vsnprintf=probably; break])
        !          2458:   done
        !          2459:   ])
        !          2460:   if test "$gmp_cv_func_vsnprintf" = probably; then
        !          2461:     AC_MSG_WARN([cannot check for properly working vsnprintf when cross compiling, will assume it's ok])
        !          2462:   fi
        !          2463:   if test "$gmp_cv_func_vsnprintf" != no; then
        !          2464:     AC_DEFINE(HAVE_VSNPRINTF,1,
        !          2465:               [Define if you have vsnprintf and it works properly.])
        !          2466:   fi
1.1       maekawa  2467: fi
                   2468: ])
                   2469:
                   2470:
1.1.1.2 ! ohara    2471: dnl  GMP_H_ANSI
        !          2472: dnl  ----------
        !          2473: dnl  Check whether gmp.h recognises the compiler as ANSI capable.
        !          2474:
        !          2475: AC_DEFUN(GMP_H_ANSI,
        !          2476: [AC_REQUIRE([AC_PROG_CC_STDC])
        !          2477: case $ac_cv_prog_cc_stdc in
        !          2478:   no)
        !          2479:     ;;
        !          2480:   *)
        !          2481:     AC_TRY_COMPILE(
        !          2482: GMP_INCLUDE_GMP_H
        !          2483: [#if ! __GMP_HAVE_PROTOTYPES
        !          2484: die die die
        !          2485: #endif
        !          2486: ],,,
        !          2487:     [AC_MSG_WARN([gmp.h doesnt recognise compiler as ANSI, prototypes and "const" will be unavailable])])
        !          2488:     ;;
        !          2489: esac
        !          2490: ])
        !          2491:
        !          2492:
        !          2493: dnl  GMP_H_EXTERN_INLINE
        !          2494: dnl  -------------------
        !          2495: dnl  If the compiler has an "inline" of some sort, check whether the
        !          2496: dnl  #ifdef's in gmp.h recognise it.
        !          2497:
        !          2498: AC_DEFUN(GMP_H_EXTERN_INLINE,
        !          2499: [AC_REQUIRE([GMP_C_INLINE])
        !          2500: case $gmp_cv_c_inline in
        !          2501: no) ;;
        !          2502: *)
        !          2503:   AC_TRY_COMPILE(
        !          2504: [#define __GMP_WITHIN_CONFIGURE_INLINE 1
        !          2505: ]GMP_INCLUDE_GMP_H[
        !          2506: #ifndef __GMP_EXTERN_INLINE
        !          2507: die die die
        !          2508: #endif
        !          2509: ],,,
        !          2510:   [case $gmp_cv_c_inline in
        !          2511:   yes) tmp_inline=inline ;;
        !          2512:   *)   tmp_inline=$gmp_cv_c_inline ;;
        !          2513:   esac
        !          2514:   AC_MSG_WARN([gmp.h doesnt recognise compiler "$tmp_inline", inlines will be unavailable])])
        !          2515:   ;;
        !          2516: esac
        !          2517: ])
        !          2518:
        !          2519:
        !          2520: dnl  GMP_H_HAVE_FILE
        !          2521: dnl  ---------------
        !          2522: dnl  Check whether the #ifdef's in gmp.h recognise when stdio.h has been
        !          2523: dnl  included to get FILE.
        !          2524:
        !          2525: AC_DEFUN(GMP_H_HAVE_FILE,
        !          2526: [AC_TRY_COMPILE(
        !          2527: [#include <stdio.h>]
        !          2528: GMP_INCLUDE_GMP_H
        !          2529: [#if ! _GMP_H_HAVE_FILE
        !          2530: die die die
        !          2531: #endif
        !          2532: ],,,
        !          2533:   [AC_MSG_WARN([gmp.h doesnt recognise <stdio.h>, FILE prototypes will be unavailable])])
        !          2534: ])
        !          2535:
        !          2536:
        !          2537: dnl  GMP_IMPL_H_IEEE_FLOATS
        !          2538: dnl  ----------------------
        !          2539: dnl  Check whether the #ifdef's in gmp-impl.h recognise IEEE format and
        !          2540: dnl  endianness.
        !          2541:
        !          2542: AC_DEFUN(GMP_IMPL_H_IEEE_FLOATS,
        !          2543: [case $host in
        !          2544:   vax*-*-*)
        !          2545:     # not IEEE (neither D nor G formats are IEEE)
        !          2546:     ;;
        !          2547:   none-*-*)
        !          2548:     # don't worry about this when CPU "none"
        !          2549:     ;;
        !          2550:   *)
        !          2551:     case $path in
        !          2552:       *cray/cfp*)
        !          2553:         # not IEEE
        !          2554:         ;;
        !          2555:       *)
        !          2556:         AC_TRY_COMPILE(
        !          2557: [#include <stdio.h>]
        !          2558: GMP_INCLUDE_GMP_H
        !          2559: [#include "$srcdir/gmp-impl.h"
        !          2560: #ifndef _GMP_IEEE_FLOATS
        !          2561: die die die
        !          2562: #endif
        !          2563: ],,,[
        !          2564:           AC_MSG_WARN([gmp-impl.h doesnt recognise "double" as IEEE.])
        !          2565:           AC_MSG_WARN([If your CPU floats are in fact IEEE then you])
        !          2566:          AC_MSG_WARN([might like to augment the tests there.])
        !          2567:         ])
        !          2568:         ;;
        !          2569:     esac
        !          2570:     ;;
        !          2571: esac
        !          2572: ])

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>