Austin Schuh | dace2a6 | 2020-08-18 10:56:48 -0700 | [diff] [blame] | 1 | dnl GMP specific autoconf macros |
| 2 | |
| 3 | |
| 4 | dnl Copyright 2000-2006, 2009, 2011, 2013-2018 Free Software Foundation, Inc. |
| 5 | dnl |
| 6 | dnl This file is part of the GNU MP Library. |
| 7 | dnl |
| 8 | dnl The GNU MP Library is free software; you can redistribute it and/or modify |
| 9 | dnl it under the terms of either: |
| 10 | dnl |
| 11 | dnl * the GNU Lesser General Public License as published by the Free |
| 12 | dnl Software Foundation; either version 3 of the License, or (at your |
| 13 | dnl option) any later version. |
| 14 | dnl |
| 15 | dnl or |
| 16 | dnl |
| 17 | dnl * the GNU General Public License as published by the Free Software |
| 18 | dnl Foundation; either version 2 of the License, or (at your option) any |
| 19 | dnl later version. |
| 20 | dnl |
| 21 | dnl or both in parallel, as here. |
| 22 | dnl |
| 23 | dnl The GNU MP Library is distributed in the hope that it will be useful, but |
| 24 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 25 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 26 | dnl for more details. |
| 27 | dnl |
| 28 | dnl You should have received copies of the GNU General Public License and the |
| 29 | dnl GNU Lesser General Public License along with the GNU MP Library. If not, |
| 30 | dnl see https://www.gnu.org/licenses/. |
| 31 | |
| 32 | |
| 33 | dnl Some tests use, or must delete, the default compiler output. The |
| 34 | dnl possible filenames are based on what autoconf looks for, namely |
| 35 | dnl |
| 36 | dnl a.out - normal unix style |
| 37 | dnl b.out - i960 systems, including gcc there |
| 38 | dnl a.exe - djgpp |
| 39 | dnl a_out.exe - OpenVMS DEC C called via GNV wrapper (gnv.sourceforge.net) |
| 40 | dnl conftest.exe - various DOS compilers |
| 41 | |
| 42 | |
| 43 | define(IA64_PATTERN, |
| 44 | [[ia64*-*-* | itanium-*-* | itanium2-*-*]]) |
| 45 | |
| 46 | dnl Need to be careful not to match m6811, m6812, m68hc11 and m68hc12, all |
| 47 | dnl of which config.sub accepts. (Though none of which are likely to work |
| 48 | dnl with GMP.) |
| 49 | dnl |
| 50 | define(M68K_PATTERN, |
| 51 | [[m68k-*-* | m68[0-9][0-9][0-9]-*-*]]) |
| 52 | |
| 53 | define(POWERPC64_PATTERN, |
| 54 | [[powerpc64-*-* | powerpc64le-*-* | powerpc620-*-* | powerpc630-*-* | powerpc970-*-* | power[3-9]-*-*]]) |
| 55 | |
| 56 | define(S390_PATTERN, |
| 57 | [[s390-*-* | z900esa-*-* | z990esa-*-* | z9esa-*-* | z10esa-*-* | z196esa-*-*]]) |
| 58 | |
| 59 | define(S390X_PATTERN, |
| 60 | [[s390x-*-* | z900-*-* | z990-*-* | z9-*-* | z10-*-* | z196-*-*]]) |
| 61 | |
| 62 | define(X86_PATTERN, |
| 63 | [[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-* | geode*-*-* | atom-*-*]]) |
| 64 | |
| 65 | define(X86_64_PATTERN, |
| 66 | [[athlon64-*-* | k8-*-* | k10-*-* | bobcat-*-* | jaguar*-*-* | bulldozer*-*-* | piledriver*-*-* | steamroller*-*-* | excavator*-*-* | zen*-*-* | pentium4-*-* | atom-*-* | silvermont-*-* | goldmont-*-* | core2-*-* | corei*-*-* | x86_64-*-* | nano-*-* | nehalem*-*-* | westmere*-*-* | sandybridge*-*-* | ivybridge*-*-* | haswell*-*-* | broadwell*-*-* | skylake*-*-* | kabylake*-*-*]]) |
| 67 | |
| 68 | dnl GMP_FAT_SUFFIX(DSTVAR, DIRECTORY) |
| 69 | dnl --------------------------------- |
| 70 | dnl Emit code to set shell variable DSTVAR to the suffix for a fat binary |
| 71 | dnl routine from DIRECTORY. DIRECTORY can be a shell expression like $foo |
| 72 | dnl etc. |
| 73 | dnl |
| 74 | dnl The suffix is directory separators / or \ changed to underscores, and |
| 75 | dnl if there's more than one directory part, then the first is dropped. |
| 76 | dnl |
| 77 | dnl For instance, |
| 78 | dnl |
| 79 | dnl x86 -> x86 |
| 80 | dnl x86/k6 -> k6 |
| 81 | dnl x86/k6/mmx -> k6_mmx |
| 82 | |
| 83 | define(GMP_FAT_SUFFIX, |
| 84 | [[$1=`echo $2 | sed -e '/\//s:^[^/]*/::' -e 's:[\\/]:_:g'`]]) |
| 85 | |
| 86 | |
| 87 | dnl GMP_REMOVE_FROM_LIST(listvar,item) |
| 88 | dnl ---------------------------------- |
| 89 | dnl Emit code to remove any occurrence of ITEM from $LISTVAR. ITEM can be a |
| 90 | dnl shell expression like $foo if desired. |
| 91 | |
| 92 | define(GMP_REMOVE_FROM_LIST, |
| 93 | [remove_from_list_tmp= |
| 94 | for remove_from_list_i in $[][$1]; do |
| 95 | if test $remove_from_list_i = [$2]; then :; |
| 96 | else |
| 97 | remove_from_list_tmp="$remove_from_list_tmp $remove_from_list_i" |
| 98 | fi |
| 99 | done |
| 100 | [$1]=$remove_from_list_tmp |
| 101 | ]) |
| 102 | |
| 103 | |
| 104 | dnl GMP_STRIP_PATH(subdir) |
| 105 | dnl ---------------------- |
| 106 | dnl Strip entries */subdir from $path and $fat_path. |
| 107 | |
| 108 | define(GMP_STRIP_PATH, |
| 109 | [GMP_STRIP_PATH_VAR(path, [$1]) |
| 110 | GMP_STRIP_PATH_VAR(fat_path, [$1]) |
| 111 | ]) |
| 112 | |
| 113 | define(GMP_STRIP_PATH_VAR, |
| 114 | [tmp_path= |
| 115 | for i in $[][$1]; do |
| 116 | case $i in |
| 117 | */[$2]) ;; |
| 118 | *) tmp_path="$tmp_path $i" ;; |
| 119 | esac |
| 120 | done |
| 121 | [$1]="$tmp_path" |
| 122 | ]) |
| 123 | |
| 124 | |
| 125 | dnl GMP_INCLUDE_GMP_H |
| 126 | dnl ----------------- |
| 127 | dnl Expand to the right way to #include gmp-h.in. This must be used |
| 128 | dnl instead of gmp.h, since that file isn't generated until the end of the |
| 129 | dnl configure. |
| 130 | dnl |
| 131 | dnl Dummy value for GMP_LIMB_BITS is enough |
| 132 | dnl for all current configure-time uses of gmp.h. |
| 133 | |
| 134 | define(GMP_INCLUDE_GMP_H, |
| 135 | [[#define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ |
| 136 | #define GMP_NAIL_BITS $GMP_NAIL_BITS |
| 137 | #define GMP_LIMB_BITS 123 |
| 138 | $DEFN_LONG_LONG_LIMB |
| 139 | #include "$srcdir/gmp-h.in"] |
| 140 | ]) |
| 141 | |
| 142 | |
| 143 | dnl GMP_HEADER_GETVAL(NAME,FILE) |
| 144 | dnl ---------------------------- |
| 145 | dnl Expand at autoconf time to the value of a "#define NAME" from the given |
| 146 | dnl FILE. The regexps here aren't very rugged, but are enough for gmp. |
| 147 | dnl /dev/null as a parameter prevents a hang if $2 is accidentally omitted. |
| 148 | |
| 149 | define(GMP_HEADER_GETVAL, |
| 150 | [patsubst(patsubst( |
| 151 | esyscmd([grep "^#define $1 " $2 /dev/null 2>/dev/null]), |
| 152 | [^.*$1[ ]+],[]), |
| 153 | [[ |
| 154 | ]*$],[])]) |
| 155 | |
| 156 | |
| 157 | dnl GMP_VERSION |
| 158 | dnl ----------- |
| 159 | dnl The gmp version number, extracted from the #defines in gmp-h.in at |
| 160 | dnl autoconf time. Two digits like 3.0 if patchlevel <= 0, or three digits |
| 161 | dnl like 3.0.1 if patchlevel > 0. |
| 162 | |
| 163 | define(GMP_VERSION, |
| 164 | [GMP_HEADER_GETVAL(__GNU_MP_VERSION,gmp-h.in)[]dnl |
| 165 | .GMP_HEADER_GETVAL(__GNU_MP_VERSION_MINOR,gmp-h.in)[]dnl |
| 166 | .GMP_HEADER_GETVAL(__GNU_MP_VERSION_PATCHLEVEL,gmp-h.in)]) |
| 167 | |
| 168 | |
| 169 | dnl GMP_SUBST_CHECK_FUNCS(func,...) |
| 170 | dnl ------------------------------ |
| 171 | dnl Setup an AC_SUBST of HAVE_FUNC_01 for each argument. |
| 172 | |
| 173 | AC_DEFUN([GMP_SUBST_CHECK_FUNCS], |
| 174 | [m4_if([$1],,, |
| 175 | [_GMP_SUBST_CHECK_FUNCS(ac_cv_func_[$1],HAVE_[]m4_translit([$1],[a-z],[A-Z])_01) |
| 176 | GMP_SUBST_CHECK_FUNCS(m4_shift($@))])]) |
| 177 | |
| 178 | dnl Called: _GMP_SUBST_CHECK_FUNCS(cachevar,substvar) |
| 179 | AC_DEFUN([_GMP_SUBST_CHECK_FUNCS], |
| 180 | [case $[$1] in |
| 181 | yes) AC_SUBST([$2],1) ;; |
| 182 | no) [$2]=0 ;; |
| 183 | esac |
| 184 | ]) |
| 185 | |
| 186 | |
| 187 | dnl GMP_SUBST_CHECK_HEADERS(foo.h,...) |
| 188 | dnl ---------------------------------- |
| 189 | dnl Setup an AC_SUBST of HAVE_FOO_H_01 for each argument. |
| 190 | |
| 191 | AC_DEFUN([GMP_SUBST_CHECK_HEADERS], |
| 192 | [m4_if([$1],,, |
| 193 | [_GMP_SUBST_CHECK_HEADERS(ac_cv_header_[]m4_translit([$1],[./],[__]), |
| 194 | HAVE_[]m4_translit([$1],[a-z./],[A-Z__])_01) |
| 195 | GMP_SUBST_CHECK_HEADERS(m4_shift($@))])]) |
| 196 | |
| 197 | dnl Called: _GMP_SUBST_CHECK_HEADERS(cachevar,substvar) |
| 198 | AC_DEFUN([_GMP_SUBST_CHECK_HEADERS], |
| 199 | [case $[$1] in |
| 200 | yes) AC_SUBST([$2],1) ;; |
| 201 | no) [$2]=0 ;; |
| 202 | esac |
| 203 | ]) |
| 204 | |
| 205 | |
| 206 | dnl GMP_COMPARE_GE(A1,B1, A2,B2, ...) |
| 207 | dnl --------------------------------- |
| 208 | dnl Compare two version numbers A1.A2.etc and B1.B2.etc. Set |
| 209 | dnl $gmp_compare_ge to yes or no according to the result. The A parts |
| 210 | dnl should be variables, the B parts fixed numbers. As many parts as |
| 211 | dnl desired can be included. An empty string in an A part is taken to be |
| 212 | dnl zero, the B parts should be non-empty and non-zero. |
| 213 | dnl |
| 214 | dnl For example, |
| 215 | dnl |
| 216 | dnl GMP_COMPARE($major,10, $minor,3, $subminor,1) |
| 217 | dnl |
| 218 | dnl would test whether $major.$minor.$subminor is greater than or equal to |
| 219 | dnl 10.3.1. |
| 220 | |
| 221 | AC_DEFUN([GMP_COMPARE_GE], |
| 222 | [gmp_compare_ge=no |
| 223 | GMP_COMPARE_GE_INTERNAL($@) |
| 224 | ]) |
| 225 | |
| 226 | AC_DEFUN([GMP_COMPARE_GE_INTERNAL], |
| 227 | [ifelse(len([$3]),0, |
| 228 | [if test -n "$1" && test "$1" -ge $2; then |
| 229 | gmp_compare_ge=yes |
| 230 | fi], |
| 231 | [if test -n "$1"; then |
| 232 | if test "$1" -gt $2; then |
| 233 | gmp_compare_ge=yes |
| 234 | else |
| 235 | if test "$1" -eq $2; then |
| 236 | GMP_COMPARE_GE_INTERNAL(m4_shift(m4_shift($@))) |
| 237 | fi |
| 238 | fi |
| 239 | fi]) |
| 240 | ]) |
| 241 | |
| 242 | |
| 243 | dnl GMP_PROG_AR |
| 244 | dnl ----------- |
| 245 | dnl GMP additions to $AR. |
| 246 | dnl |
| 247 | dnl A cross-"ar" may be necessary when cross-compiling since the build |
| 248 | dnl system "ar" might try to interpret the object files to build a symbol |
| 249 | dnl table index, hence the use of AC_CHECK_TOOL. |
| 250 | dnl |
| 251 | dnl A user-selected $AR is always left unchanged. AC_CHECK_TOOL is still |
| 252 | dnl run to get the "checking" message printed though. |
| 253 | dnl |
| 254 | dnl If extra flags are added to AR, then ac_cv_prog_AR and |
| 255 | dnl ac_cv_prog_ac_ct_AR are set too, since libtool (cvs 2003-03-31 at |
| 256 | dnl least) will do an AC_CHECK_TOOL and that will AR from one of those two |
| 257 | dnl cached variables. (ac_cv_prog_AR is used if there's an ac_tool_prefix, |
| 258 | dnl or ac_cv_prog_ac_ct_AR is used otherwise.) FIXME: This is highly |
| 259 | dnl dependent on autoconf internals, perhaps it'd work to put our extra |
| 260 | dnl flags into AR_FLAGS instead. |
| 261 | dnl |
| 262 | dnl $AR_FLAGS is set to "cq" rather than leaving it to libtool "cru". The |
| 263 | dnl latter fails when libtool goes into piecewise mode and is unlucky |
| 264 | dnl enough to have two same-named objects in separate pieces, as happens |
| 265 | dnl for instance to random.o (and others) on vax-dec-ultrix4.5. Naturally |
| 266 | dnl a user-selected $AR_FLAGS is left unchanged. |
| 267 | dnl |
| 268 | dnl For reference, $ARFLAGS is used by automake (1.8) for its ".a" archive |
| 269 | dnl file rules. This doesn't get used by the piecewise linking, so we |
| 270 | dnl leave it at the default "cru". |
| 271 | dnl |
| 272 | dnl FIXME: Libtool 1.5.2 has its own arrangements for "cq", but that version |
| 273 | dnl is broken in other ways. When we can upgrade, remove the forcible |
| 274 | dnl AR_FLAGS=cq. |
| 275 | |
| 276 | AC_DEFUN([GMP_PROG_AR], |
| 277 | [dnl Want to establish $AR before libtool initialization. |
| 278 | AC_BEFORE([$0],[AC_PROG_LIBTOOL]) |
| 279 | gmp_user_AR=$AR |
| 280 | AC_CHECK_TOOL(AR, ar, ar) |
| 281 | if test -z "$gmp_user_AR"; then |
| 282 | eval arflags=\"\$ar${abi1}_flags\" |
| 283 | test -n "$arflags" || eval arflags=\"\$ar${abi2}_flags\" |
| 284 | if test -n "$arflags"; then |
| 285 | AC_MSG_CHECKING([for extra ar flags]) |
| 286 | AR="$AR $arflags" |
| 287 | ac_cv_prog_AR="$AR $arflags" |
| 288 | ac_cv_prog_ac_ct_AR="$AR $arflags" |
| 289 | AC_MSG_RESULT([$arflags]) |
| 290 | fi |
| 291 | fi |
| 292 | if test -z "$AR_FLAGS"; then |
| 293 | AR_FLAGS=cq |
| 294 | fi |
| 295 | ]) |
| 296 | |
| 297 | |
| 298 | dnl GMP_PROG_M4 |
| 299 | dnl ----------- |
| 300 | dnl Find a working m4, either in $PATH or likely locations, and setup $M4 |
| 301 | dnl and an AC_SUBST accordingly. If $M4 is already set then it's a user |
| 302 | dnl choice and is accepted with no checks. GMP_PROG_M4 is like |
| 303 | dnl AC_PATH_PROG or AC_CHECK_PROG, but tests each m4 found to see if it's |
| 304 | dnl good enough. |
| 305 | dnl |
| 306 | dnl See mpn/asm-defs.m4 for details on the known bad m4s. |
| 307 | |
| 308 | AC_DEFUN([GMP_PROG_M4], |
| 309 | [AC_ARG_VAR(M4,[m4 macro processor]) |
| 310 | AC_CACHE_CHECK([for suitable m4], |
| 311 | gmp_cv_prog_m4, |
| 312 | [if test -n "$M4"; then |
| 313 | gmp_cv_prog_m4="$M4" |
| 314 | else |
| 315 | cat >conftest.m4 <<\EOF |
| 316 | dnl Must protect this against being expanded during autoconf m4! |
| 317 | dnl Dont put "dnl"s in this as autoconf will flag an error for unexpanded |
| 318 | dnl macros. |
| 319 | [define(dollarhash,``$][#'')ifelse(dollarhash(x),1,`define(t1,Y)', |
| 320 | ``bad: $][# not supported (SunOS /usr/bin/m4) |
| 321 | '')ifelse(eval(89),89,`define(t2,Y)', |
| 322 | `bad: eval() doesnt support 8 or 9 in a constant (OpenBSD 2.6 m4) |
| 323 | ')ifelse(eval(9,9),10,`define(t3,Y)', |
| 324 | `bad: eval() doesnt support radix in eval (FreeBSD 8.x,9.0,9.1,9.2 m4) |
| 325 | ')ifelse(t1`'t2`'t3,YYY,`good |
| 326 | ')] |
| 327 | EOF |
| 328 | dnl ' <- balance the quotes for emacs sh-mode |
| 329 | echo "trying m4" >&AC_FD_CC |
| 330 | gmp_tmp_val=`(m4 conftest.m4) 2>&AC_FD_CC` |
| 331 | echo "$gmp_tmp_val" >&AC_FD_CC |
| 332 | if test "$gmp_tmp_val" = good; then |
| 333 | gmp_cv_prog_m4="m4" |
| 334 | else |
| 335 | IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" |
| 336 | dnl $ac_dummy forces splitting on constant user-supplied paths. |
| 337 | dnl POSIX.2 word splitting is done only on the output of word expansions, |
| 338 | dnl not every word. This closes a longstanding sh security hole. |
| 339 | ac_dummy="$PATH:/usr/5bin" |
| 340 | for ac_dir in $ac_dummy; do |
| 341 | test -z "$ac_dir" && ac_dir=. |
| 342 | echo "trying $ac_dir/m4" >&AC_FD_CC |
| 343 | gmp_tmp_val=`($ac_dir/m4 conftest.m4) 2>&AC_FD_CC` |
| 344 | echo "$gmp_tmp_val" >&AC_FD_CC |
| 345 | if test "$gmp_tmp_val" = good; then |
| 346 | gmp_cv_prog_m4="$ac_dir/m4" |
| 347 | break |
| 348 | fi |
| 349 | done |
| 350 | IFS="$ac_save_ifs" |
| 351 | if test -z "$gmp_cv_prog_m4"; then |
| 352 | AC_MSG_ERROR([No usable m4 in \$PATH or /usr/5bin (see config.log for reasons).]) |
| 353 | fi |
| 354 | fi |
| 355 | rm -f conftest.m4 |
| 356 | fi]) |
| 357 | M4="$gmp_cv_prog_m4" |
| 358 | AC_SUBST(M4) |
| 359 | ]) |
| 360 | |
| 361 | |
| 362 | dnl GMP_M4_M4WRAP_SPURIOUS |
| 363 | dnl ---------------------- |
| 364 | dnl Check for spurious output from m4wrap(), as described in mpn/asm-defs.m4. |
| 365 | dnl |
| 366 | dnl The following systems have been seen with the problem. |
| 367 | dnl |
| 368 | dnl - Unicos alpha, but its assembler doesn't seem to mind. |
| 369 | dnl - MacOS X Darwin, its assembler fails. |
| 370 | dnl - NetBSD 1.4.1 m68k, and gas 1.92.3 there gives a warning and ignores |
| 371 | dnl the bad last line since it doesn't have a newline. |
| 372 | dnl - NetBSD 1.4.2 alpha, but its assembler doesn't seem to mind. |
| 373 | dnl - HP-UX ia64. |
| 374 | dnl |
| 375 | dnl Enhancement: Maybe this could be in GMP_PROG_M4, and attempt to prefer |
| 376 | dnl an m4 with a working m4wrap, if it can be found. |
| 377 | |
| 378 | AC_DEFUN([GMP_M4_M4WRAP_SPURIOUS], |
| 379 | [AC_REQUIRE([GMP_PROG_M4]) |
| 380 | AC_CACHE_CHECK([if m4wrap produces spurious output], |
| 381 | gmp_cv_m4_m4wrap_spurious, |
| 382 | [# hide the d-n-l from autoconf's error checking |
| 383 | tmp_d_n_l=d""nl |
| 384 | cat >conftest.m4 <<EOF |
| 385 | [changequote({,})define(x,)m4wrap({x})$tmp_d_n_l] |
| 386 | EOF |
| 387 | echo test input is >&AC_FD_CC |
| 388 | cat conftest.m4 >&AC_FD_CC |
| 389 | tmp_chars=`$M4 conftest.m4 | wc -c` |
| 390 | echo produces $tmp_chars chars output >&AC_FD_CC |
| 391 | rm -f conftest.m4 |
| 392 | if test $tmp_chars = 0; then |
| 393 | gmp_cv_m4_m4wrap_spurious=no |
| 394 | else |
| 395 | gmp_cv_m4_m4wrap_spurious=yes |
| 396 | fi |
| 397 | ]) |
| 398 | GMP_DEFINE_RAW(["define(<M4WRAP_SPURIOUS>,<$gmp_cv_m4_m4wrap_spurious>)"]) |
| 399 | ]) |
| 400 | |
| 401 | |
| 402 | dnl GMP_PROG_NM |
| 403 | dnl ----------- |
| 404 | dnl GMP additions to libtool AC_PROG_NM. |
| 405 | dnl |
| 406 | dnl Note that if AC_PROG_NM can't find a working nm it still leaves |
| 407 | dnl $NM set to "nm", so $NM can't be assumed to actually work. |
| 408 | dnl |
| 409 | dnl A user-selected $NM is always left unchanged. AC_PROG_NM is still run |
| 410 | dnl to get the "checking" message printed though. |
| 411 | dnl |
| 412 | dnl Perhaps it'd be worthwhile checking that nm works, by running it on an |
| 413 | dnl actual object file. For instance on sparcv9 solaris old versions of |
| 414 | dnl GNU nm don't recognise 64-bit objects. Checking would give a better |
| 415 | dnl error message than just a failure in later tests like GMP_ASM_W32 etc. |
| 416 | dnl |
| 417 | dnl On the other hand it's not really normal autoconf practice to take too |
| 418 | dnl much trouble over detecting a broken set of tools. And libtool doesn't |
| 419 | dnl do anything at all for say ranlib or strip. So for now we're inclined |
| 420 | dnl to just demand that the user provides a coherent environment. |
| 421 | |
| 422 | AC_DEFUN([GMP_PROG_NM], |
| 423 | [dnl Make sure we're the first to call AC_PROG_NM, so our extra flags are |
| 424 | dnl used by everyone. |
| 425 | AC_BEFORE([$0],[AC_PROG_NM]) |
| 426 | gmp_user_NM=$NM |
| 427 | AC_PROG_NM |
| 428 | |
| 429 | # FIXME: When cross compiling (ie. $ac_tool_prefix not empty), libtool |
| 430 | # defaults to plain "nm" if a "${ac_tool_prefix}nm" is not found. In this |
| 431 | # case run it again to try the native "nm", firstly so that likely locations |
| 432 | # are searched, secondly so that -B or -p are added if necessary for BSD |
| 433 | # format. This is necessary for instance on OSF with "./configure |
| 434 | # --build=alphaev5-dec-osf --host=alphaev6-dec-osf". |
| 435 | # |
| 436 | if test -z "$gmp_user_NM" && test -n "$ac_tool_prefix" && test "$NM" = nm; then |
| 437 | $as_unset lt_cv_path_NM |
| 438 | gmp_save_ac_tool_prefix=$ac_tool_prefix |
| 439 | ac_tool_prefix= |
| 440 | NM= |
| 441 | AC_PROG_NM |
| 442 | ac_tool_prefix=$gmp_save_ac_tool_prefix |
| 443 | fi |
| 444 | |
| 445 | if test -z "$gmp_user_NM"; then |
| 446 | eval nmflags=\"\$nm${abi1}_flags\" |
| 447 | test -n "$nmflags" || eval nmflags=\"\$nm${abi2}_flags\" |
| 448 | if test -n "$nmflags"; then |
| 449 | AC_MSG_CHECKING([for extra nm flags]) |
| 450 | NM="$NM $nmflags" |
| 451 | AC_MSG_RESULT([$nmflags]) |
| 452 | fi |
| 453 | fi |
| 454 | ]) |
| 455 | |
| 456 | |
| 457 | dnl GMP_PROG_CC_WORKS(cc+cflags,[ACTION-IF-WORKS][,ACTION-IF-NOT-WORKS]) |
| 458 | dnl -------------------------------------------------------------------- |
| 459 | dnl Check if cc+cflags can compile and link. |
| 460 | dnl |
| 461 | dnl This test is designed to be run repeatedly with different cc+cflags |
| 462 | dnl selections, so the result is not cached. |
| 463 | dnl |
| 464 | dnl For a native build, meaning $cross_compiling == no, we require that the |
| 465 | dnl generated program will run. This is the same as AC_PROG_CC does in |
| 466 | dnl _AC_COMPILER_EXEEXT_WORKS, and checking here will ensure we don't pass |
| 467 | dnl a CC/CFLAGS combination that it rejects. |
| 468 | dnl |
| 469 | dnl sparc-*-solaris2.7 can compile ABI=64 but won't run it if the kernel |
| 470 | dnl was booted in 32-bit mode. The effect of requiring the compiler output |
| 471 | dnl will run is that a plain native "./configure" falls back on ABI=32, but |
| 472 | dnl ABI=64 is still available as a cross-compile. |
| 473 | dnl |
| 474 | dnl The various specific problems we try to detect are done in separate |
| 475 | dnl compiles. Although this is probably a bit slower than one test |
| 476 | dnl program, it makes it easy to indicate the problem in AC_MSG_RESULT, |
| 477 | dnl hence giving the user a clue about why we rejected the compiler. |
| 478 | |
| 479 | AC_DEFUN([GMP_PROG_CC_WORKS], |
| 480 | [AC_MSG_CHECKING([compiler $1]) |
| 481 | gmp_prog_cc_works=yes |
| 482 | |
| 483 | # first see a simple "main()" works, then go on to other checks |
| 484 | GMP_PROG_CC_WORKS_PART([$1], []) |
| 485 | |
| 486 | GMP_PROG_CC_WORKS_PART([$1], [function pointer return], |
| 487 | [/* The following provokes an internal error from gcc 2.95.2 -mpowerpc64 |
| 488 | (without -maix64), hence detecting an unusable compiler */ |
| 489 | void *g() { return (void *) 0; } |
| 490 | void *f() { return g(); } |
| 491 | ]) |
| 492 | |
| 493 | GMP_PROG_CC_WORKS_PART([$1], [cmov instruction], |
| 494 | [/* The following provokes an invalid instruction syntax from i386 gcc |
| 495 | -march=pentiumpro on Solaris 2.8. The native sun assembler |
| 496 | requires a non-standard syntax for cmov which gcc (as of 2.95.2 at |
| 497 | least) doesn't know. */ |
| 498 | int n; |
| 499 | int cmov () { return (n >= 0 ? n : 0); } |
| 500 | ]) |
| 501 | |
| 502 | GMP_PROG_CC_WORKS_PART([$1], [double -> ulong conversion], |
| 503 | [/* The following provokes a linker invocation problem with gcc 3.0.3 |
| 504 | on AIX 4.3 under "-maix64 -mpowerpc64 -mcpu=630". The -mcpu=630 |
| 505 | option causes gcc to incorrectly select the 32-bit libgcc.a, not |
| 506 | the 64-bit one, and consequently it misses out on the __fixunsdfdi |
| 507 | helper (double -> uint64 conversion). */ |
| 508 | double d; |
| 509 | unsigned long gcc303 () { return (unsigned long) d; } |
| 510 | ]) |
| 511 | |
| 512 | GMP_PROG_CC_WORKS_PART([$1], [double negation], |
| 513 | [/* The following provokes an error from hppa gcc 2.95 under -mpa-risc-2-0 if |
| 514 | the assembler doesn't know hppa 2.0 instructions. fneg is a 2.0 |
| 515 | instruction, and a negation like this comes out using it. */ |
| 516 | double fneg_data; |
| 517 | unsigned long fneg () { return -fneg_data; } |
| 518 | ]) |
| 519 | |
| 520 | GMP_PROG_CC_WORKS_PART([$1], [double -> float conversion], |
| 521 | [/* The following makes gcc 3.3 -march=pentium4 generate an SSE2 xmm insn |
| 522 | (cvtsd2ss) which will provoke an error if the assembler doesn't recognise |
| 523 | those instructions. Not sure how much of the gmp code will come out |
| 524 | wanting sse2, but it's easiest to reject an option we know is bad. */ |
| 525 | double ftod_data; |
| 526 | float ftod () { return (float) ftod_data; } |
| 527 | ]) |
| 528 | |
| 529 | GMP_PROG_CC_WORKS_PART([$1], [gnupro alpha ev6 char spilling], |
| 530 | [/* The following provokes an internal compiler error from gcc version |
| 531 | "2.9-gnupro-99r1" under "-O2 -mcpu=ev6", apparently relating to char |
| 532 | values being spilled into floating point registers. The problem doesn't |
| 533 | show up all the time, but has occurred enough in GMP for us to reject |
| 534 | this compiler+flags. */ |
| 535 | #include <string.h> /* for memcpy */ |
| 536 | struct try_t |
| 537 | { |
| 538 | char dst[2]; |
| 539 | char size; |
| 540 | long d0, d1, d2, d3, d4, d5, d6; |
| 541 | char overlap; |
| 542 | }; |
| 543 | struct try_t param[6]; |
| 544 | int |
| 545 | param_init () |
| 546 | { |
| 547 | struct try_t *p; |
| 548 | memcpy (p, ¶m[ 2 ], sizeof (*p)); |
| 549 | memcpy (p, ¶m[ 2 ], sizeof (*p)); |
| 550 | p->size = 2; |
| 551 | memcpy (p, ¶m[ 1 ], sizeof (*p)); |
| 552 | p->dst[0] = 1; |
| 553 | p->overlap = 2; |
| 554 | memcpy (p, ¶m[ 3 ], sizeof (*p)); |
| 555 | p->dst[0] = 1; |
| 556 | p->overlap = 8; |
| 557 | memcpy (p, ¶m[ 4 ], sizeof (*p)); |
| 558 | memcpy (p, ¶m[ 4 ], sizeof (*p)); |
| 559 | p->overlap = 8; |
| 560 | memcpy (p, ¶m[ 5 ], sizeof (*p)); |
| 561 | memcpy (p, ¶m[ 5 ], sizeof (*p)); |
| 562 | memcpy (p, ¶m[ 5 ], sizeof (*p)); |
| 563 | return 0; |
| 564 | } |
| 565 | ]) |
| 566 | |
| 567 | # __builtin_alloca is not available everywhere, check it exists before |
| 568 | # seeing that it works |
| 569 | GMP_PROG_CC_WORKS_PART_TEST([$1],[__builtin_alloca availability], |
| 570 | [int k; int foo () { __builtin_alloca (k); }], |
| 571 | [GMP_PROG_CC_WORKS_PART([$1], [alloca array], |
| 572 | [/* The following provokes an internal compiler error from Itanium HP-UX cc |
| 573 | under +O2 or higher. We use this sort of code in mpn/generic/mul_fft.c. */ |
| 574 | int k; |
| 575 | int foo () |
| 576 | { |
| 577 | int i, **a; |
| 578 | a = __builtin_alloca (k); |
| 579 | for (i = 0; i <= k; i++) |
| 580 | a[i] = __builtin_alloca (1 << i); |
| 581 | } |
| 582 | ])]) |
| 583 | |
| 584 | GMP_PROG_CC_WORKS_PART([$1], [abs int -> double conversion], |
| 585 | [/* The following provokes an internal error from the assembler on |
| 586 | power2-ibm-aix4.3.1.0. gcc -mrios2 compiles to nabs+fcirz, and this |
| 587 | results in "Internal error related to the source program domain". |
| 588 | |
| 589 | For reference it seems to be the combination of nabs+fcirz which is bad, |
| 590 | not either alone. This sort of thing occurs in mpz/get_str.c with the |
| 591 | way double chars_per_bit_exactly is applied in MPN_SIZEINBASE. Perhaps |
| 592 | if that code changes to a scaled-integer style then we won't need this |
| 593 | test. */ |
| 594 | |
| 595 | double fp[1]; |
| 596 | int x; |
| 597 | int f () |
| 598 | { |
| 599 | int a; |
| 600 | a = (x >= 0 ? x : -x); |
| 601 | return a * fp[0]; |
| 602 | } |
| 603 | ]) |
| 604 | |
| 605 | GMP_PROG_CC_WORKS_PART([$1], [long long reliability test 1], |
| 606 | [/* The following provokes a segfault in the compiler on powerpc-apple-darwin. |
| 607 | Extracted from tests/mpn/t-iord_u.c. Causes Apple's gcc 3.3 build 1640 and |
| 608 | 1666 to segfault with e.g., -O2 -mpowerpc64. */ |
| 609 | |
| 610 | #if defined (__GNUC__) && ! defined (__cplusplus) |
| 611 | typedef unsigned long long t1;typedef t1*t2; |
| 612 | void g(){} |
| 613 | void h(){} |
| 614 | static __inline__ t1 e(t2 rp,t2 up,int n,t1 v0) |
| 615 | {t1 c,x,r;int i;if(v0){c=1;for(i=1;i<n;i++){x=up[i];r=x+1;rp[i]=r;}}return c;} |
| 616 | void f(){static const struct{t1 n;t1 src[9];t1 want[9];}d[]={{1,{0},{1}},};t1 got[9];int i; |
| 617 | for(i=0;i<1;i++){if(e(got,got,9,d[i].n)==0)h();g(i,d[i].src,d[i].n,got,d[i].want,9);if(d[i].n)h();}} |
| 618 | #else |
| 619 | int dummy; |
| 620 | #endif |
| 621 | ]) |
| 622 | |
| 623 | GMP_PROG_CC_WORKS_PART([$1], [long long reliability test 2], |
| 624 | [/* The following provokes an internal compiler error on powerpc-apple-darwin. |
| 625 | Extracted from mpz/cfdiv_q_2exp.c. Causes Apple's gcc 3.3 build 1640 and |
| 626 | 1666 to get an ICE with -O1 -mpowerpc64. */ |
| 627 | |
| 628 | #if defined (__GNUC__) && ! defined (__cplusplus) |
| 629 | int g(); |
| 630 | void f(int u){int i;long long x;x=u?~0:0;if(x)for(i=0;i<9;i++);x&=g();if(x)g();} |
| 631 | int g(){return 0;} |
| 632 | #else |
| 633 | int dummy; |
| 634 | #endif |
| 635 | ]) |
| 636 | |
| 637 | GMP_PROG_CC_WORKS_PART([$1], [freebsd hacked gcc], |
| 638 | [/* Provokes an ICE on i386-freebsd with the FreeBSD-hacked gcc, under |
| 639 | -O2 -march=amdfam10. We call helper functions here "open" and "close" in |
| 640 | order for linking to succeed. */ |
| 641 | |
| 642 | #if defined (__GNUC__) && ! defined (__cplusplus) |
| 643 | int open(int*,int*,int);void*close(int);void g(int*rp,int*up,int un){ |
| 644 | __builtin_expect(un<=0x7f00,1)?__builtin_alloca(un):close(un);if(__builtin_clzl |
| 645 | (up[un])){open(rp,up,un);while(1){if(rp[un-1]!=0)break;un--;}}} |
| 646 | #else |
| 647 | int dummy; |
| 648 | #endif |
| 649 | ]) |
| 650 | |
| 651 | GMP_PROG_CC_WORKS_PART_MAIN([$1], [mpn_lshift_com optimization], |
| 652 | [/* The following is mis-compiled by HP ia-64 cc version |
| 653 | cc: HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003] |
| 654 | under "cc +O3", both in +DD32 and +DD64 modes. The mpn_lshift_com gets |
| 655 | inlined and its return value somehow botched to be 0 instead of 1. This |
| 656 | arises in the real mpn_lshift_com in mul_fft.c. A lower optimization |
| 657 | level, like +O2 seems ok. This code needs to be run to show the problem, |
| 658 | but that's fine, the offending cc is a native-only compiler so we don't |
| 659 | have to worry about cross compiling. */ |
| 660 | |
| 661 | #if ! defined (__cplusplus) |
| 662 | unsigned long |
| 663 | lshift_com (rp, up, n, cnt) |
| 664 | unsigned long *rp; |
| 665 | unsigned long *up; |
| 666 | long n; |
| 667 | unsigned cnt; |
| 668 | { |
| 669 | unsigned long retval, high_limb, low_limb; |
| 670 | unsigned tnc; |
| 671 | long i; |
| 672 | tnc = 8 * sizeof (unsigned long) - cnt; |
| 673 | low_limb = *up++; |
| 674 | retval = low_limb >> tnc; |
| 675 | high_limb = low_limb << cnt; |
| 676 | for (i = n - 1; i != 0; i--) |
| 677 | { |
| 678 | low_limb = *up++; |
| 679 | *rp++ = ~(high_limb | (low_limb >> tnc)); |
| 680 | high_limb = low_limb << cnt; |
| 681 | } |
| 682 | return retval; |
| 683 | } |
| 684 | int |
| 685 | main () |
| 686 | { |
| 687 | unsigned long cy, rp[2], up[2]; |
| 688 | up[0] = ~ 0L; |
| 689 | up[1] = 0; |
| 690 | cy = lshift_com (rp, up, 2L, 1); |
| 691 | if (cy != 1L) |
| 692 | return 1; |
| 693 | return 0; |
| 694 | } |
| 695 | #else |
| 696 | int |
| 697 | main () |
| 698 | { |
| 699 | return 0; |
| 700 | } |
| 701 | #endif |
| 702 | ]) |
| 703 | |
| 704 | GMP_PROG_CC_WORKS_PART_MAIN([$1], [mpn_lshift_com optimization 2], |
| 705 | [/* The following is mis-compiled by Intel ia-64 icc version 1.8 under |
| 706 | "icc -O3", After several calls, the function writes partial garbage to |
| 707 | the result vector. Perhaps relates to the chk.a.nc insn. This code needs |
| 708 | to be run to show the problem, but that's fine, the offending cc is a |
| 709 | native-only compiler so we don't have to worry about cross compiling. */ |
| 710 | |
| 711 | #if ! defined (__cplusplus) |
| 712 | #include <stdlib.h> |
| 713 | void |
| 714 | lshift_com (rp, up, n, cnt) |
| 715 | unsigned long *rp; |
| 716 | unsigned long *up; |
| 717 | long n; |
| 718 | unsigned cnt; |
| 719 | { |
| 720 | unsigned long high_limb, low_limb; |
| 721 | unsigned tnc; |
| 722 | long i; |
| 723 | up += n; |
| 724 | rp += n; |
| 725 | tnc = 8 * sizeof (unsigned long) - cnt; |
| 726 | low_limb = *--up; |
| 727 | high_limb = low_limb << cnt; |
| 728 | for (i = n - 1; i != 0; i--) |
| 729 | { |
| 730 | low_limb = *--up; |
| 731 | *--rp = ~(high_limb | (low_limb >> tnc)); |
| 732 | high_limb = low_limb << cnt; |
| 733 | } |
| 734 | *--rp = ~high_limb; |
| 735 | } |
| 736 | int |
| 737 | main () |
| 738 | { |
| 739 | unsigned long *r, *r2; |
| 740 | unsigned long a[88 + 1]; |
| 741 | long i; |
| 742 | for (i = 0; i < 88 + 1; i++) |
| 743 | a[i] = ~0L; |
| 744 | r = calloc (10000, sizeof (unsigned long)); |
| 745 | r2 = r; |
| 746 | for (i = 0; i < 528; i += 23) |
| 747 | { |
| 748 | lshift_com (r2, a, |
| 749 | i / (8 * sizeof (unsigned long)) + 1, |
| 750 | i % (8 * sizeof (unsigned long))); |
| 751 | r2 += 88 + 1; |
| 752 | } |
| 753 | if (r[2048] != 0 || r[2049] != 0 || r[2050] != 0 || r[2051] != 0 || |
| 754 | r[2052] != 0 || r[2053] != 0 || r[2054] != 0) |
| 755 | abort (); |
| 756 | free (r); |
| 757 | return 0; |
| 758 | } |
| 759 | #else |
| 760 | int |
| 761 | main () |
| 762 | { |
| 763 | return 0; |
| 764 | } |
| 765 | #endif |
| 766 | ]) |
| 767 | |
| 768 | |
| 769 | # A certain _GLOBAL_OFFSET_TABLE_ problem in past versions of gas, tickled |
| 770 | # by recent versions of gcc. |
| 771 | # |
| 772 | if test "$gmp_prog_cc_works" = yes; then |
| 773 | case $host in |
| 774 | X86_PATTERN) |
| 775 | # this problem only arises in PIC code, so don't need to test when |
| 776 | # --disable-shared. We don't necessarily have $enable_shared set to |
| 777 | # yes at this point, it will still be unset for the default (which is |
| 778 | # yes); hence the use of "!= no". |
| 779 | if test "$enable_shared" != no; then |
| 780 | GMP_PROG_CC_X86_GOT_EAX_EMITTED([$1], |
| 781 | [GMP_ASM_X86_GOT_EAX_OK([$1],, |
| 782 | [gmp_prog_cc_works="no, bad gas GOT with eax"])]) |
| 783 | fi |
| 784 | ;; |
| 785 | esac |
| 786 | fi |
| 787 | |
| 788 | AC_MSG_RESULT($gmp_prog_cc_works) |
| 789 | case $gmp_prog_cc_works in |
| 790 | yes) |
| 791 | [$2] |
| 792 | ;; |
| 793 | *) |
| 794 | [$3] |
| 795 | ;; |
| 796 | esac |
| 797 | ]) |
| 798 | |
| 799 | dnl Called: GMP_PROG_CC_WORKS_PART(CC+CFLAGS,FAIL-MESSAGE [,CODE]) |
| 800 | dnl A dummy main() is appended to the CODE given. |
| 801 | dnl |
| 802 | AC_DEFUN([GMP_PROG_CC_WORKS_PART], |
| 803 | [GMP_PROG_CC_WORKS_PART_MAIN([$1],[$2], |
| 804 | [$3] |
| 805 | [int main () { return 0; }]) |
| 806 | ]) |
| 807 | |
| 808 | dnl Called: GMP_PROG_CC_WORKS_PART_MAIN(CC+CFLAGS,FAIL-MESSAGE,CODE) |
| 809 | dnl CODE must include a main(). |
| 810 | dnl |
| 811 | AC_DEFUN([GMP_PROG_CC_WORKS_PART_MAIN], |
| 812 | [GMP_PROG_CC_WORKS_PART_TEST([$1],[$2],[$3], |
| 813 | [], |
| 814 | gmp_prog_cc_works="no[]m4_if([$2],,,[[, ]])[$2]", |
| 815 | gmp_prog_cc_works="no[]m4_if([$2],,,[[, ]])[$2][[, program does not run]]") |
| 816 | ]) |
| 817 | |
| 818 | dnl Called: GMP_PROG_CC_WORKS_PART_TEST(CC+CFLAGS,TITLE,[CODE], |
| 819 | dnl [ACTION-GOOD],[ACTION-BAD][ACTION-NORUN]) |
| 820 | dnl |
| 821 | AC_DEFUN([GMP_PROG_CC_WORKS_PART_TEST], |
| 822 | [if test "$gmp_prog_cc_works" = yes; then |
| 823 | # remove anything that might look like compiler output to our "||" expression |
| 824 | rm -f conftest* a.out b.out a.exe a_out.exe |
| 825 | cat >conftest.c <<EOF |
| 826 | [$3] |
| 827 | EOF |
| 828 | echo "Test compile: [$2]" >&AC_FD_CC |
| 829 | gmp_compile="$1 conftest.c >&AC_FD_CC" |
| 830 | if AC_TRY_EVAL(gmp_compile); then |
| 831 | cc_works_part=yes |
| 832 | if test "$cross_compiling" = no; then |
| 833 | if AC_TRY_COMMAND([./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest]); then :; |
| 834 | else |
| 835 | cc_works_part=norun |
| 836 | fi |
| 837 | fi |
| 838 | else |
| 839 | cc_works_part=no |
| 840 | fi |
| 841 | if test "$cc_works_part" != yes; then |
| 842 | echo "failed program was:" >&AC_FD_CC |
| 843 | cat conftest.c >&AC_FD_CC |
| 844 | fi |
| 845 | rm -f conftest* a.out b.out a.exe a_out.exe |
| 846 | case $cc_works_part in |
| 847 | yes) |
| 848 | $4 |
| 849 | ;; |
| 850 | no) |
| 851 | $5 |
| 852 | ;; |
| 853 | norun) |
| 854 | $6 |
| 855 | ;; |
| 856 | esac |
| 857 | fi |
| 858 | ]) |
| 859 | |
| 860 | |
| 861 | dnl GMP_PROG_CC_WORKS_LONGLONG(cc+cflags,[ACTION-YES][,ACTION-NO]) |
| 862 | dnl -------------------------------------------------------------- |
| 863 | dnl Check that cc+cflags accepts "long long". |
| 864 | dnl |
| 865 | dnl This test is designed to be run repeatedly with different cc+cflags |
| 866 | dnl selections, so the result is not cached. |
| 867 | |
| 868 | AC_DEFUN([GMP_PROG_CC_WORKS_LONGLONG], |
| 869 | [AC_MSG_CHECKING([compiler $1 has long long]) |
| 870 | cat >conftest.c <<EOF |
| 871 | long long foo; |
| 872 | long long bar () { return foo; } |
| 873 | int main () { return 0; } |
| 874 | EOF |
| 875 | gmp_prog_cc_works=no |
| 876 | gmp_compile="$1 -c conftest.c >&AC_FD_CC" |
| 877 | if AC_TRY_EVAL(gmp_compile); then |
| 878 | gmp_prog_cc_works=yes |
| 879 | else |
| 880 | echo "failed program was:" >&AC_FD_CC |
| 881 | cat conftest.c >&AC_FD_CC |
| 882 | fi |
| 883 | rm -f conftest* a.out b.out a.exe a_out.exe |
| 884 | AC_MSG_RESULT($gmp_prog_cc_works) |
| 885 | if test $gmp_prog_cc_works = yes; then |
| 886 | ifelse([$2],,:,[$2]) |
| 887 | else |
| 888 | ifelse([$3],,:,[$3]) |
| 889 | fi |
| 890 | ]) |
| 891 | |
| 892 | |
| 893 | dnl GMP_C_TEST_SIZEOF(cc/cflags,test,[ACTION-GOOD][,ACTION-BAD]) |
| 894 | dnl ------------------------------------------------------------ |
| 895 | dnl The given cc/cflags compiler is run to check the size of a type |
| 896 | dnl specified by the "test" argument. "test" can either be a string, or a |
| 897 | dnl variable like $foo. The value should be for instance "sizeof-long-4", |
| 898 | dnl to test that sizeof(long)==4. |
| 899 | dnl |
| 900 | dnl This test is designed to be run for different compiler and/or flags |
| 901 | dnl combinations, so the result is not cached. |
| 902 | dnl |
| 903 | dnl The idea for making an array that has a negative size if the desired |
| 904 | dnl condition test is false comes from autoconf AC_CHECK_SIZEOF. The cast |
| 905 | dnl to "long" in the array dimension also follows autoconf, apparently it's |
| 906 | dnl a workaround for a HP compiler bug. |
| 907 | |
| 908 | AC_DEFUN([GMP_C_TEST_SIZEOF], |
| 909 | [echo "configure: testlist $2" >&AC_FD_CC |
| 910 | [gmp_sizeof_type=`echo "$2" | sed 's/sizeof-\([a-z\*]*\).*/\1/'`] |
| 911 | [gmp_sizeof_want=`echo "$2" | sed 's/sizeof-[a-z\*]*-\([0-9]*\).*/\1/'`] |
| 912 | AC_MSG_CHECKING([compiler $1 has sizeof($gmp_sizeof_type)==$gmp_sizeof_want]) |
| 913 | cat >conftest.c <<EOF |
| 914 | [int |
| 915 | main () |
| 916 | { |
| 917 | static int test_array [1 - 2 * (long) (sizeof ($gmp_sizeof_type) != $gmp_sizeof_want)]; |
| 918 | test_array[0] = 0; |
| 919 | return 0; |
| 920 | }] |
| 921 | EOF |
| 922 | gmp_c_testlist_sizeof=no |
| 923 | gmp_compile="$1 -c conftest.c >&AC_FD_CC" |
| 924 | if AC_TRY_EVAL(gmp_compile); then |
| 925 | gmp_c_testlist_sizeof=yes |
| 926 | fi |
| 927 | rm -f conftest* |
| 928 | AC_MSG_RESULT($gmp_c_testlist_sizeof) |
| 929 | if test $gmp_c_testlist_sizeof = yes; then |
| 930 | ifelse([$3],,:,[$3]) |
| 931 | else |
| 932 | ifelse([$4],,:,[$4]) |
| 933 | fi |
| 934 | ]) |
| 935 | |
| 936 | |
| 937 | dnl GMP_PROG_CC_IS_GNU(CC,[ACTIONS-IF-YES][,ACTIONS-IF-NO]) |
| 938 | dnl ------------------------------------------------------- |
| 939 | dnl Determine whether the given compiler is GNU C. |
| 940 | dnl |
| 941 | dnl This test is the same as autoconf _AC_LANG_COMPILER_GNU, but doesn't |
| 942 | dnl cache the result. The same "ifndef" style test is used, to avoid |
| 943 | dnl problems with syntax checking cpp's used on NeXT and Apple systems. |
| 944 | |
| 945 | AC_DEFUN([GMP_PROG_CC_IS_GNU], |
| 946 | [cat >conftest.c <<EOF |
| 947 | #if ! defined (__GNUC__) || defined (__INTEL_COMPILER) |
| 948 | choke me |
| 949 | #endif |
| 950 | EOF |
| 951 | gmp_compile="$1 -c conftest.c >&AC_FD_CC" |
| 952 | if AC_TRY_EVAL(gmp_compile); then |
| 953 | rm -f conftest* |
| 954 | AC_MSG_CHECKING([whether $1 is gcc]) |
| 955 | AC_MSG_RESULT(yes) |
| 956 | ifelse([$2],,:,[$2]) |
| 957 | else |
| 958 | rm -f conftest* |
| 959 | ifelse([$3],,:,[$3]) |
| 960 | fi |
| 961 | ]) |
| 962 | |
| 963 | |
| 964 | dnl GMP_PROG_CC_IS_XLC(CC,[ACTIONS-IF-YES][,ACTIONS-IF-NO]) |
| 965 | dnl ------------------------------------------------------- |
| 966 | dnl Determine whether the given compiler is IBM xlc (on AIX). |
| 967 | dnl |
| 968 | dnl There doesn't seem to be a preprocessor symbol to test for this, or if |
| 969 | dnl there is one then it's well hidden in xlc 3.1 on AIX 4.3, so just grep |
| 970 | dnl the man page printed when xlc is invoked with no arguments. |
| 971 | |
| 972 | AC_DEFUN([GMP_PROG_CC_IS_XLC], |
| 973 | [gmp_command="$1 2>&1 | grep xlc >/dev/null" |
| 974 | if AC_TRY_EVAL(gmp_command); then |
| 975 | AC_MSG_CHECKING([whether $1 is xlc]) |
| 976 | AC_MSG_RESULT(yes) |
| 977 | ifelse([$2],,:,[$2]) |
| 978 | else |
| 979 | ifelse([$3],,:,[$3]) |
| 980 | fi |
| 981 | ]) |
| 982 | |
| 983 | |
| 984 | dnl GMP_PROG_CC_X86_GOT_EAX_EMITTED(CC+CFLAGS, [ACTION-YES] [, ACTION-NO]) |
| 985 | dnl ---------------------------------------------------------------------- |
| 986 | dnl Determine whether CC+CFLAGS emits instructions using %eax with |
| 987 | dnl _GLOBAL_OFFSET_TABLE_. This test is for use on x86 systems. |
| 988 | dnl |
| 989 | dnl Recent versions of gcc will use %eax for the GOT in leaf functions, for |
| 990 | dnl instance gcc 3.3.3 with -O3. This avoids having to save and restore |
| 991 | dnl %ebx which otherwise usually holds the GOT, and is what gcc used in the |
| 992 | dnl past. |
| 993 | dnl |
| 994 | dnl %ecx and %edx are also candidates for this sort of optimization, and |
| 995 | dnl are used under lesser optimization levels, like -O2 in 3.3.3. FIXME: |
| 996 | dnl It's not quite clear what the conditions for using %eax are, we might |
| 997 | dnl need more test code to provoke it. |
| 998 | dnl |
| 999 | dnl The motivation for this test is that past versions of gas have bugs |
| 1000 | dnl affecting this usage, see GMP_ASM_X86_GOT_EAX_OK. |
| 1001 | dnl |
| 1002 | dnl This test is not specific to gcc, other compilers might emit %eax GOT |
| 1003 | dnl insns like this, though we've not investigated that. |
| 1004 | dnl |
| 1005 | dnl This is for use by compiler probing in GMP_PROG_CC_WORKS, so we doesn't |
| 1006 | dnl cache the result. |
| 1007 | dnl |
| 1008 | dnl -fPIC is hard coded here, because this test is for use before libtool |
| 1009 | dnl has established the pic options. It's right for gcc, but perhaps not |
| 1010 | dnl other compilers. |
| 1011 | |
| 1012 | AC_DEFUN([GMP_PROG_CC_X86_GOT_EAX_EMITTED], |
| 1013 | [echo "Testing gcc GOT with eax emitted" >&AC_FD_CC |
| 1014 | cat >conftest.c <<\EOF |
| 1015 | [int foo; |
| 1016 | int bar () { return foo; } |
| 1017 | ]EOF |
| 1018 | tmp_got_emitted=no |
| 1019 | gmp_compile="$1 -fPIC -S conftest.c >&AC_FD_CC 2>&1" |
| 1020 | if AC_TRY_EVAL(gmp_compile); then |
| 1021 | if grep "addl.*_GLOBAL_OFFSET_TABLE_.*eax" conftest.s >/dev/null; then |
| 1022 | tmp_got_emitted=yes |
| 1023 | fi |
| 1024 | fi |
| 1025 | rm -f conftest.* |
| 1026 | echo "Result: $tmp_got_emitted" >&AC_FD_CC |
| 1027 | if test "$tmp_got_emitted" = yes; then |
| 1028 | ifelse([$2],,:,[$2]) |
| 1029 | else |
| 1030 | ifelse([$3],,:,[$3]) |
| 1031 | fi |
| 1032 | ]) |
| 1033 | |
| 1034 | |
| 1035 | dnl GMP_HPC_HPPA_2_0(cc,[ACTION-IF-GOOD][,ACTION-IF-BAD]) |
| 1036 | dnl --------------------------------------------------------- |
| 1037 | dnl Find out whether a HP compiler is good enough to generate hppa 2.0. |
| 1038 | dnl |
| 1039 | dnl This test might be repeated for different compilers, so the result is |
| 1040 | dnl not cached. |
| 1041 | |
| 1042 | AC_DEFUN([GMP_HPC_HPPA_2_0], |
| 1043 | [AC_MSG_CHECKING([whether HP compiler $1 is good for 64-bits]) |
| 1044 | # Bad compiler output: |
| 1045 | # ccom: HP92453-01 G.10.32.05 HP C Compiler |
| 1046 | # Good compiler output: |
| 1047 | # ccom: HP92453-01 A.10.32.30 HP C Compiler |
| 1048 | # Let A.10.32.30 or higher be ok. |
| 1049 | echo >conftest.c |
| 1050 | gmp_tmp_vs=`$1 $2 -V -c -o conftest.$OBJEXT conftest.c 2>&1 | grep "^ccom:"` |
| 1051 | echo "Version string: $gmp_tmp_vs" >&AC_FD_CC |
| 1052 | rm conftest* |
| 1053 | gmp_tmp_v1=`echo $gmp_tmp_vs | sed 's/.* .\.\([[0-9]]*\).*/\1/'` |
| 1054 | gmp_tmp_v2=`echo $gmp_tmp_vs | sed 's/.* .\..*\.\(.*\)\..* HP C.*/\1/'` |
| 1055 | gmp_tmp_v3=`echo $gmp_tmp_vs | sed 's/.* .\..*\..*\.\(.*\) HP C.*/\1/'` |
| 1056 | echo "Version number: $gmp_tmp_v1.$gmp_tmp_v2.$gmp_tmp_v3" >&AC_FD_CC |
| 1057 | if test -z "$gmp_tmp_v1"; then |
| 1058 | gmp_hpc_64bit=not-applicable |
| 1059 | else |
| 1060 | GMP_COMPARE_GE($gmp_tmp_v1, 10, $gmp_tmp_v2, 32, $gmp_tmp_v3, 30) |
| 1061 | gmp_hpc_64bit=$gmp_compare_ge |
| 1062 | fi |
| 1063 | AC_MSG_RESULT($gmp_hpc_64bit) |
| 1064 | if test $gmp_hpc_64bit = yes; then |
| 1065 | ifelse([$2],,:,[$2]) |
| 1066 | else |
| 1067 | ifelse([$3],,:,[$3]) |
| 1068 | fi |
| 1069 | ]) |
| 1070 | |
| 1071 | |
| 1072 | dnl GMP_GCC_ARM_UMODSI(CC,[ACTIONS-IF-GOOD][,ACTIONS-IF-BAD]) |
| 1073 | dnl --------------------------------------------------------- |
| 1074 | dnl gcc 2.95.3 and earlier on arm has a bug in the libgcc __umodsi routine |
| 1075 | dnl making "%" give wrong results for some operands, eg. "0x90000000 % 3". |
| 1076 | dnl We're hoping it'll be fixed in 2.95.4, and we know it'll be fixed in |
| 1077 | dnl gcc 3. |
| 1078 | dnl |
| 1079 | dnl There's only a couple of places gmp cares about this, one is the |
| 1080 | dnl size==1 case in mpn/generic/mode1o.c, and this shows up in |
| 1081 | dnl tests/mpz/t-jac.c as a wrong result from mpz_kronecker_ui. |
| 1082 | |
| 1083 | AC_DEFUN([GMP_GCC_ARM_UMODSI], |
| 1084 | [AC_MSG_CHECKING([whether ARM gcc unsigned division works]) |
| 1085 | tmp_version=`$1 --version` |
| 1086 | echo "$tmp_version" >&AC_FD_CC |
| 1087 | case $tmp_version in |
| 1088 | [2.95 | 2.95.[123]]) |
| 1089 | ifelse([$3],,:,[$3]) |
| 1090 | gmp_gcc_arm_umodsi_result=["no, gcc 2.95.[0123]"] ;; |
| 1091 | *) |
| 1092 | ifelse([$2],,:,[$2]) |
| 1093 | gmp_gcc_arm_umodsi_result=yes ;; |
| 1094 | esac |
| 1095 | AC_MSG_RESULT([$gmp_gcc_arm_umodsi_result]) |
| 1096 | ]) |
| 1097 | |
| 1098 | |
| 1099 | dnl GMP_GCC_MIPS_O32(gcc,[actions-yes][,[actions-no]]) |
| 1100 | dnl ------------------------------------------------- |
| 1101 | dnl Test whether gcc supports o32. |
| 1102 | dnl |
| 1103 | dnl gcc 2.7.2.2 only does o32, and doesn't accept -mabi=32. |
| 1104 | dnl |
| 1105 | dnl gcc 2.95 accepts -mabi=32 but it only works on irix5, on irix6 it gives |
| 1106 | dnl "cc1: The -mabi=32 support does not work yet". |
| 1107 | |
| 1108 | AC_DEFUN([GMP_GCC_MIPS_O32], |
| 1109 | [AC_MSG_CHECKING([whether gcc supports o32]) |
| 1110 | echo 'int x;' >conftest.c |
| 1111 | echo "$1 -mabi=32 -c conftest.c" >&AC_FD_CC |
| 1112 | if $1 -mabi=32 -c conftest.c >conftest.out 2>&1; then |
| 1113 | result=yes |
| 1114 | else |
| 1115 | cat conftest.out >&AC_FD_CC |
| 1116 | if grep "cc1: Invalid option \`abi=32'" conftest.out >/dev/null; then |
| 1117 | result=yes |
| 1118 | else |
| 1119 | result=no |
| 1120 | fi |
| 1121 | fi |
| 1122 | rm -f conftest.* |
| 1123 | AC_MSG_RESULT($result) |
| 1124 | if test $result = yes; then |
| 1125 | ifelse([$2],,:,[$2]) |
| 1126 | else |
| 1127 | ifelse([$3],,:,[$3]) |
| 1128 | fi |
| 1129 | ]) |
| 1130 | |
| 1131 | |
| 1132 | dnl GMP_GCC_NO_CPP_PRECOMP(CCBASE,CC,CFLAGS,[ACTIONS-YES][,ACTIONS-NO]) |
| 1133 | dnl ------------------------------------------------------------------- |
| 1134 | dnl Check whether -no-cpp-precomp should be used on this compiler, and |
| 1135 | dnl execute the corresponding ACTIONS-YES or ACTIONS-NO. |
| 1136 | dnl |
| 1137 | dnl -no-cpp-precomp is only meant for Apple's hacked version of gcc found |
| 1138 | dnl on powerpc*-*-darwin*, but we can give it a try on any gcc. Normal gcc |
| 1139 | dnl (as of 3.0 at least) only gives a warning, not an actual error, and we |
| 1140 | dnl watch for that and decide against the option in that case, to avoid |
| 1141 | dnl confusing the user. |
| 1142 | |
| 1143 | AC_DEFUN([GMP_GCC_NO_CPP_PRECOMP], |
| 1144 | [if test "$ccbase" = gcc; then |
| 1145 | AC_MSG_CHECKING([compiler $2 $3 -no-cpp-precomp]) |
| 1146 | result=no |
| 1147 | cat >conftest.c <<EOF |
| 1148 | int main () { return 0; } |
| 1149 | EOF |
| 1150 | gmp_compile="$2 $3 -no-cpp-precomp conftest.c >conftest.out 2>&1" |
| 1151 | if AC_TRY_EVAL(gmp_compile); then |
| 1152 | if grep "unrecognized option.*-no-cpp-precomp" conftest.out >/dev/null; then : ; |
| 1153 | else |
| 1154 | result=yes |
| 1155 | fi |
| 1156 | fi |
| 1157 | cat conftest.out >&AC_FD_CC |
| 1158 | rm -f conftest* a.out b.out a.exe a_out.exe |
| 1159 | AC_MSG_RESULT($result) |
| 1160 | if test "$result" = yes; then |
| 1161 | ifelse([$4],,:,[$4]) |
| 1162 | else |
| 1163 | ifelse([$5],,:,[$5]) |
| 1164 | fi |
| 1165 | fi |
| 1166 | ]) |
| 1167 | |
| 1168 | |
| 1169 | dnl GMP_GCC_PENTIUM4_SSE2(CC+CFLAGS,[ACTION-IF-YES][,ACTION-IF-NO]) |
| 1170 | dnl --------------------------------------------------------------- |
| 1171 | dnl Determine whether gcc CC+CFLAGS is a good enough version for |
| 1172 | dnl -march=pentium4 with sse2. |
| 1173 | dnl |
| 1174 | dnl Gcc 3.2.1 was seen generating incorrect code for raw double -> int |
| 1175 | dnl conversions through a union. We believe the problem is in all 3.1 and |
| 1176 | dnl 3.2 versions, but that it's fixed in 3.3. |
| 1177 | |
| 1178 | AC_DEFUN([GMP_GCC_PENTIUM4_SSE2], |
| 1179 | [AC_MSG_CHECKING([whether gcc is good for sse2]) |
| 1180 | case `$1 -dumpversion` in |
| 1181 | [3.[012] | 3.[012].*]) result=no ;; |
| 1182 | *) result=yes ;; |
| 1183 | esac |
| 1184 | AC_MSG_RESULT($result) |
| 1185 | if test "$result" = yes; then |
| 1186 | ifelse([$2],,:,[$2]) |
| 1187 | else |
| 1188 | ifelse([$3],,:,[$3]) |
| 1189 | fi |
| 1190 | ]) |
| 1191 | |
| 1192 | |
| 1193 | dnl GMP_GCC_WA_MCPU(CC+CFLAGS, NEWFLAG [,ACTION-YES [,ACTION-NO]]) |
| 1194 | dnl -------------------------------------------------------------- |
| 1195 | dnl Check whether gcc (or gas rather) accepts a flag like "-Wa,-mev67". |
| 1196 | dnl |
| 1197 | dnl Gas doesn't give an error for an unknown cpu, it only prints a warning |
| 1198 | dnl like "Warning: Unknown CPU identifier `ev78'". |
| 1199 | dnl |
| 1200 | dnl This is intended for use on alpha, since only recent versions of gas |
| 1201 | dnl accept -mev67, but there's nothing here that's alpha specific. |
| 1202 | |
| 1203 | AC_DEFUN([GMP_GCC_WA_MCPU], |
| 1204 | [AC_MSG_CHECKING([assembler $1 $2]) |
| 1205 | result=no |
| 1206 | cat >conftest.c <<EOF |
| 1207 | int main () {} |
| 1208 | EOF |
| 1209 | gmp_compile="$1 $2 -c conftest.c >conftest.out 2>&1" |
| 1210 | if AC_TRY_EVAL(gmp_compile); then |
| 1211 | if grep "Unknown CPU identifier" conftest.out >/dev/null; then : ; |
| 1212 | else |
| 1213 | result=yes |
| 1214 | fi |
| 1215 | fi |
| 1216 | cat conftest.out >&AC_FD_CC |
| 1217 | rm -f conftest* |
| 1218 | AC_MSG_RESULT($result) |
| 1219 | if test "$result" = yes; then |
| 1220 | ifelse([$3],,:,[$3]) |
| 1221 | else |
| 1222 | ifelse([$4],,:,[$4]) |
| 1223 | fi |
| 1224 | ]) |
| 1225 | |
| 1226 | |
| 1227 | dnl GMP_GCC_WA_OLDAS(CC+CFLAGS [,ACTION-YES [,ACTION-NO]]) |
| 1228 | dnl ------------------------------------------------------ |
| 1229 | dnl Check whether gcc should be run with "-Wa,-oldas". |
| 1230 | dnl |
| 1231 | dnl On systems alpha*-*-osf* (or maybe just osf5), apparently there's a |
| 1232 | dnl newish Compaq "as" which doesn't work with the gcc mips-tfile. |
| 1233 | dnl Compiling an empty file with "gcc -c foo.c" produces for instance |
| 1234 | dnl |
| 1235 | dnl mips-tfile, /tmp/ccaqUNnF.s:7 Segmentation fault |
| 1236 | dnl |
| 1237 | dnl The fix is to pass "-oldas" to that assembler, as noted by |
| 1238 | dnl |
| 1239 | dnl http://gcc.gnu.org/install/specific.html#alpha*-dec-osf* |
| 1240 | dnl |
| 1241 | dnl The test here tries to compile an empty file, and if that fails but |
| 1242 | dnl adding -Wa,-oldas makes it succeed, then that flag is considered |
| 1243 | dnl necessary. |
| 1244 | dnl |
| 1245 | dnl We look for the failing case specifically, since it may not be a good |
| 1246 | dnl idea to use -Wa,-oldas in other circumstances. For instance gas takes |
| 1247 | dnl "-oldas" to mean the "-o" option and will write a file called "ldas" as |
| 1248 | dnl its output. Normally gcc puts its own "-o" after any -Wa options, so |
| 1249 | dnl -oldas ends up being harmless, but clearly that's only through good |
| 1250 | dnl luck. |
| 1251 | dnl |
| 1252 | dnl This macro is designed for use while probing for a good compiler, and |
| 1253 | dnl so doesn't cache it's result. |
| 1254 | |
| 1255 | AC_DEFUN([GMP_GCC_WA_OLDAS], |
| 1256 | [AC_MSG_CHECKING([for $1 -Wa,-oldas]) |
| 1257 | result=no |
| 1258 | cat >conftest.c <<EOF |
| 1259 | EOF |
| 1260 | echo "with empty conftest.c" >&AC_FD_CC |
| 1261 | gmp_compile="$1 -c conftest.c >&AC_FD_CC 2>&1" |
| 1262 | if AC_TRY_EVAL(gmp_compile); then : ; |
| 1263 | else |
| 1264 | # empty fails |
| 1265 | gmp_compile="$1 -Wa,-oldas -c conftest.c >&AC_FD_CC 2>&1" |
| 1266 | if AC_TRY_EVAL(gmp_compile); then |
| 1267 | # but with -Wa,-oldas it works |
| 1268 | result=yes |
| 1269 | fi |
| 1270 | fi |
| 1271 | rm -f conftest* |
| 1272 | AC_MSG_RESULT($result) |
| 1273 | if test "$result" = yes; then |
| 1274 | ifelse([$2],,:,[$2]) |
| 1275 | else |
| 1276 | ifelse([$3],,:,[$3]) |
| 1277 | fi |
| 1278 | ]) |
| 1279 | |
| 1280 | |
| 1281 | dnl GMP_OS_X86_XMM(CC+CFLAGS,[ACTION-IF-YES][,ACTION-IF-NO]) |
| 1282 | dnl -------------------------------------------------------- |
| 1283 | dnl Determine whether the operating system supports XMM registers. |
| 1284 | dnl |
| 1285 | dnl If build==host then a test program is run, executing an SSE2 |
| 1286 | dnl instruction using an XMM register. This will give a SIGILL if the |
| 1287 | dnl system hasn't set the OSFXSR bit in CR4 to say it knows it must use |
| 1288 | dnl fxsave/fxrestor in a context switch (to save xmm registers). |
| 1289 | dnl |
| 1290 | dnl If build!=host, we can fallback on: |
| 1291 | dnl |
| 1292 | dnl - FreeBSD version 4 is the first supporting xmm. |
| 1293 | dnl |
| 1294 | dnl - Linux kernel 2.4 might be the first stable series supporting xmm |
| 1295 | dnl (not sure). But there's no version number in the GNU/Linux |
| 1296 | dnl config tuple to test anyway. |
| 1297 | dnl |
| 1298 | dnl The default is to allow xmm. This might seem rash, but it's likely |
| 1299 | dnl most systems know xmm by now, so this will normally be what's wanted. |
| 1300 | dnl And cross compiling is a bit hairy anyway, so hopefully anyone doing it |
| 1301 | dnl will be smart enough to know what to do. |
| 1302 | dnl |
| 1303 | dnl In the test program, .text and .globl are hard coded because this macro |
| 1304 | dnl is wanted before GMP_ASM_TEXT and GMP_ASM_GLOBL are run. A .byte |
| 1305 | dnl sequence is used (for xorps %xmm0, %xmm0) to make us independent of |
| 1306 | dnl tests for whether the assembler supports sse2/xmm. Obviously we need |
| 1307 | dnl both assembler and OS support, but this means we don't force the order |
| 1308 | dnl in which we test. |
| 1309 | dnl |
| 1310 | dnl FIXME: Maybe we should use $CCAS to assemble, if it's set. (Would |
| 1311 | dnl still want $CC/$CFLAGS for the link.) But this test is used before |
| 1312 | dnl AC_PROG_CC sets $OBJEXT, so we'd need to check for various object file |
| 1313 | dnl suffixes ourselves. |
| 1314 | |
| 1315 | AC_DEFUN([GMP_OS_X86_XMM], |
| 1316 | [AC_CACHE_CHECK([whether the operating system supports XMM registers], |
| 1317 | gmp_cv_os_x86_xmm, |
| 1318 | [if test "$build" = "$host"; then |
| 1319 | # remove anything that might look like compiler output to our "||" expression |
| 1320 | rm -f conftest* a.out b.out a.exe a_out.exe |
| 1321 | cat >conftest.s <<EOF |
| 1322 | .text |
| 1323 | main: |
| 1324 | _main: |
| 1325 | .globl main |
| 1326 | .globl _main |
| 1327 | .byte 0x0f, 0x57, 0xc0 |
| 1328 | xorl %eax, %eax |
| 1329 | ret |
| 1330 | EOF |
| 1331 | gmp_compile="$1 conftest.s -o conftest >&AC_FD_CC" |
| 1332 | if AC_TRY_EVAL(gmp_compile); then |
| 1333 | if AC_TRY_COMMAND([./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest]); then |
| 1334 | gmp_cv_os_x86_xmm=yes |
| 1335 | else |
| 1336 | gmp_cv_os_x86_xmm=no |
| 1337 | fi |
| 1338 | else |
| 1339 | AC_MSG_WARN([Oops, cannot compile test program]) |
| 1340 | fi |
| 1341 | rm -f conftest* |
| 1342 | fi |
| 1343 | |
| 1344 | if test -z "$gmp_cv_os_x86_xmm"; then |
| 1345 | case $host_os in |
| 1346 | [freebsd[123] | freebsd[123].*]) |
| 1347 | gmp_cv_os_x86_xmm=no ;; |
| 1348 | freebsd*) |
| 1349 | gmp_cv_os_x86_xmm=yes ;; |
| 1350 | *) |
| 1351 | gmp_cv_os_x86_xmm=probably ;; |
| 1352 | esac |
| 1353 | fi |
| 1354 | ]) |
| 1355 | |
| 1356 | if test "$gmp_cv_os_x86_xmm" = probably; then |
| 1357 | AC_MSG_WARN([Not certain of OS support for xmm when cross compiling.]) |
| 1358 | AC_MSG_WARN([Will assume it's ok, expect a SIGILL if this is wrong.]) |
| 1359 | fi |
| 1360 | |
| 1361 | case $gmp_cv_os_x86_xmm in |
| 1362 | no) |
| 1363 | $3 |
| 1364 | ;; |
| 1365 | *) |
| 1366 | $2 |
| 1367 | ;; |
| 1368 | esac |
| 1369 | ]) |
| 1370 | |
| 1371 | |
| 1372 | dnl GMP_CRAY_HOST_TYPES(C90/T90-IEEE, C90/T90-CFP, J90/SV1) |
| 1373 | dnl ------------------------------------------------------- |
| 1374 | dnl Execute the actions in the arguments on the respective Cray vector |
| 1375 | dnl systems. For other hosts, do nothing. |
| 1376 | dnl |
| 1377 | dnl This macro should be used after the C compiler has been chosen, since |
| 1378 | dnl on c90 and t90 we ask the compiler whether we're in IEEE or CFP float |
| 1379 | dnl mode. |
| 1380 | dnl |
| 1381 | dnl This code is in a macro so that any AC_REQUIRE pre-requisites of |
| 1382 | dnl AC_EGREP_CPP will be expanded at the top-level, ie. for all hosts not |
| 1383 | dnl merely c90 and t90. In autoconf 2.57 for instance this means |
| 1384 | dnl AC_PROG_EGREP, which is needed by various other macros. |
| 1385 | |
| 1386 | AC_DEFUN([GMP_CRAY_OPTIONS], |
| 1387 | [case $host_cpu in |
| 1388 | c90 | t90) |
| 1389 | AC_EGREP_CPP(yes, |
| 1390 | [#ifdef _CRAYIEEE |
| 1391 | yes |
| 1392 | #endif], |
| 1393 | [$1], |
| 1394 | [$2]) |
| 1395 | ;; |
| 1396 | j90 | sv1) |
| 1397 | [$3] |
| 1398 | ;; |
| 1399 | esac |
| 1400 | ]) |
| 1401 | |
| 1402 | |
| 1403 | dnl GMP_HPPA_LEVEL_20(cc/cflags [, ACTION-GOOD [,ACTION-BAD]]) |
| 1404 | dnl ---------------------------------------------------------- |
| 1405 | dnl Check that the given cc/cflags accepts HPPA 2.0n assembler code. |
| 1406 | dnl |
| 1407 | dnl Old versions of gas don't know 2.0 instructions. It rejects ".level |
| 1408 | dnl 2.0" for a start, so just test that. |
| 1409 | dnl |
| 1410 | dnl This test is designed to be run for various different compiler and |
| 1411 | dnl flags combinations, and hence doesn't cache its result. |
| 1412 | |
| 1413 | AC_DEFUN([GMP_HPPA_LEVEL_20], |
| 1414 | [AC_MSG_CHECKING([$1 assembler knows hppa 2.0]) |
| 1415 | result=no |
| 1416 | cat >conftest.s <<EOF |
| 1417 | .level 2.0 |
| 1418 | EOF |
| 1419 | gmp_compile="$1 -c conftest.s >&AC_FD_CC 2>&1" |
| 1420 | if AC_TRY_EVAL(gmp_compile); then |
| 1421 | result=yes |
| 1422 | else |
| 1423 | echo "failed program was" >&AC_FD_CC |
| 1424 | cat conftest.s >&AC_FD_CC |
| 1425 | fi |
| 1426 | rm -f conftest* |
| 1427 | AC_MSG_RESULT($result) |
| 1428 | if test "$result" = yes; then |
| 1429 | ifelse([$2],,:,[$2]) |
| 1430 | else |
| 1431 | ifelse([$3],,:,[$3]) |
| 1432 | fi |
| 1433 | ]) |
| 1434 | |
| 1435 | |
| 1436 | dnl GMP_PROG_CXX_WORKS(cxx/cxxflags [, ACTION-YES [,ACTION-NO]]) |
| 1437 | dnl ------------------------------------------------------------ |
| 1438 | dnl Check whether cxx/cxxflags can compile and link. |
| 1439 | dnl |
| 1440 | dnl This test is designed to be run repeatedly with different cxx/cxxflags |
| 1441 | dnl selections, so the result is not cached. |
| 1442 | dnl |
| 1443 | dnl For a native build, we insist on being able to run the program, so as |
| 1444 | dnl to detect any problems with the standard C++ library. During |
| 1445 | dnl development various systems with broken or incomplete C++ installations |
| 1446 | dnl were seen. |
| 1447 | dnl |
| 1448 | dnl The various features and problems we try to detect are done in separate |
| 1449 | dnl compiles. Although this is probably a bit slower than one test |
| 1450 | dnl program, it makes it easy to indicate the problem in AC_MSG_RESULT, |
| 1451 | dnl hence giving the user a clue about why we rejected the compiler. |
| 1452 | |
| 1453 | AC_DEFUN([GMP_PROG_CXX_WORKS], |
| 1454 | [AC_MSG_CHECKING([C++ compiler $1]) |
| 1455 | gmp_prog_cxx_works=yes |
| 1456 | |
| 1457 | # start with a plain "main()", then go on to further checks |
| 1458 | GMP_PROG_CXX_WORKS_PART([$1], []) |
| 1459 | |
| 1460 | GMP_PROG_CXX_WORKS_PART([$1], [namespace], |
| 1461 | [namespace foo { } |
| 1462 | using namespace foo; |
| 1463 | ]) |
| 1464 | |
| 1465 | # GMP requires the standard C++ iostream classes |
| 1466 | GMP_PROG_CXX_WORKS_PART([$1], [std iostream], |
| 1467 | [/* This test rejects g++ 2.7.2 which doesn't have <iostream>, only a |
| 1468 | pre-standard iostream.h. */ |
| 1469 | #include <iostream> |
| 1470 | |
| 1471 | /* This test rejects OSF 5.1 Compaq C++ in its default pre-standard iostream |
| 1472 | mode, since that mode puts cout in the global namespace, not "std". */ |
| 1473 | void someoutput (void) { std::cout << 123; } |
| 1474 | ]) |
| 1475 | |
| 1476 | AC_MSG_RESULT($gmp_prog_cxx_works) |
| 1477 | case $gmp_prog_cxx_works in |
| 1478 | yes) |
| 1479 | [$2] |
| 1480 | ;; |
| 1481 | *) |
| 1482 | [$3] |
| 1483 | ;; |
| 1484 | esac |
| 1485 | ]) |
| 1486 | |
| 1487 | dnl Called: GMP_PROG_CXX_WORKS_PART(CXX+CXXFLAGS, FAIL-MESSAGE [,CODE]) |
| 1488 | dnl |
| 1489 | AC_DEFUN([GMP_PROG_CXX_WORKS_PART], |
| 1490 | [if test "$gmp_prog_cxx_works" = yes; then |
| 1491 | # remove anything that might look like compiler output to our "||" expression |
| 1492 | rm -f conftest* a.out b.out a.exe a_out.exe |
| 1493 | cat >conftest.cc <<EOF |
| 1494 | [$3] |
| 1495 | int main (void) { return 0; } |
| 1496 | EOF |
| 1497 | echo "Test compile: [$2]" >&AC_FD_CC |
| 1498 | gmp_cxxcompile="$1 conftest.cc >&AC_FD_CC" |
| 1499 | if AC_TRY_EVAL(gmp_cxxcompile); then |
| 1500 | if test "$cross_compiling" = no; then |
| 1501 | if AC_TRY_COMMAND([./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest]); then :; |
| 1502 | else |
| 1503 | gmp_prog_cxx_works="no[]m4_if([$2],,,[, ])[$2], program does not run" |
| 1504 | fi |
| 1505 | fi |
| 1506 | else |
| 1507 | gmp_prog_cxx_works="no[]m4_if([$2],,,[, ])[$2]" |
| 1508 | fi |
| 1509 | case $gmp_prog_cxx_works in |
| 1510 | no*) |
| 1511 | echo "failed program was:" >&AC_FD_CC |
| 1512 | cat conftest.cc >&AC_FD_CC |
| 1513 | ;; |
| 1514 | esac |
| 1515 | rm -f conftest* a.out b.out a.exe a_out.exe |
| 1516 | fi |
| 1517 | ]) |
| 1518 | |
| 1519 | |
| 1520 | dnl GMP_INIT([M4-DEF-FILE]) |
| 1521 | dnl ----------------------- |
| 1522 | dnl Initializations for GMP config.m4 generation. |
| 1523 | dnl |
| 1524 | dnl FIXME: The generated config.m4 doesn't get recreated by config.status. |
| 1525 | dnl Maybe the relevant "echo"s should go through AC_CONFIG_COMMANDS. |
| 1526 | |
| 1527 | AC_DEFUN([GMP_INIT], |
| 1528 | [ifelse([$1], , gmp_configm4=config.m4, gmp_configm4="[$1]") |
| 1529 | gmp_tmpconfigm4=cnfm4.tmp |
| 1530 | gmp_tmpconfigm4i=cnfm4i.tmp |
| 1531 | gmp_tmpconfigm4p=cnfm4p.tmp |
| 1532 | rm -f $gmp_tmpconfigm4 $gmp_tmpconfigm4i $gmp_tmpconfigm4p |
| 1533 | |
| 1534 | # CONFIG_TOP_SRCDIR is a path from the mpn builddir to the top srcdir. |
| 1535 | # The pattern here tests for an absolute path the same way as |
| 1536 | # _AC_OUTPUT_FILES in autoconf acgeneral.m4. |
| 1537 | case $srcdir in |
| 1538 | [[\\/]]* | ?:[[\\/]]* ) tmp="$srcdir" ;; |
| 1539 | *) tmp="../$srcdir" ;; |
| 1540 | esac |
| 1541 | echo ["define(<CONFIG_TOP_SRCDIR>,<\`$tmp'>)"] >>$gmp_tmpconfigm4 |
| 1542 | |
| 1543 | # All CPUs use asm-defs.m4 |
| 1544 | echo ["include][(CONFIG_TOP_SRCDIR\`/mpn/asm-defs.m4')"] >>$gmp_tmpconfigm4i |
| 1545 | ]) |
| 1546 | |
| 1547 | |
| 1548 | dnl GMP_FINISH |
| 1549 | dnl ---------- |
| 1550 | dnl Create config.m4 from its accumulated parts. |
| 1551 | dnl |
| 1552 | dnl __CONFIG_M4_INCLUDED__ is used so that a second or subsequent include |
| 1553 | dnl of config.m4 is harmless. |
| 1554 | dnl |
| 1555 | dnl A separate ifdef on the angle bracket quoted part ensures the quoting |
| 1556 | dnl style there is respected. The basic defines from gmp_tmpconfigm4 are |
| 1557 | dnl fully quoted but are still put under an ifdef in case any have been |
| 1558 | dnl redefined by one of the m4 include files. |
| 1559 | dnl |
| 1560 | dnl Doing a big ifdef within asm-defs.m4 and/or other macro files wouldn't |
| 1561 | dnl work, since it'd interpret parentheses and quotes in dnl comments, and |
| 1562 | dnl having a whole file as a macro argument would overflow the string space |
| 1563 | dnl on BSD m4. |
| 1564 | |
| 1565 | AC_DEFUN([GMP_FINISH], |
| 1566 | [AC_REQUIRE([GMP_INIT]) |
| 1567 | echo "creating $gmp_configm4" |
| 1568 | echo ["d""nl $gmp_configm4. Generated automatically by configure."] > $gmp_configm4 |
| 1569 | if test -f $gmp_tmpconfigm4; then |
| 1570 | echo ["changequote(<,>)"] >> $gmp_configm4 |
| 1571 | echo ["ifdef(<__CONFIG_M4_INCLUDED__>,,<"] >> $gmp_configm4 |
| 1572 | cat $gmp_tmpconfigm4 >> $gmp_configm4 |
| 1573 | echo [">)"] >> $gmp_configm4 |
| 1574 | echo ["changequote(\`,')"] >> $gmp_configm4 |
| 1575 | rm $gmp_tmpconfigm4 |
| 1576 | fi |
| 1577 | echo ["ifdef(\`__CONFIG_M4_INCLUDED__',,\`"] >> $gmp_configm4 |
| 1578 | if test -f $gmp_tmpconfigm4i; then |
| 1579 | cat $gmp_tmpconfigm4i >> $gmp_configm4 |
| 1580 | rm $gmp_tmpconfigm4i |
| 1581 | fi |
| 1582 | if test -f $gmp_tmpconfigm4p; then |
| 1583 | cat $gmp_tmpconfigm4p >> $gmp_configm4 |
| 1584 | rm $gmp_tmpconfigm4p |
| 1585 | fi |
| 1586 | echo ["')"] >> $gmp_configm4 |
| 1587 | echo ["define(\`__CONFIG_M4_INCLUDED__')"] >> $gmp_configm4 |
| 1588 | ]) |
| 1589 | |
| 1590 | |
| 1591 | dnl GMP_INCLUDE_MPN(FILE) |
| 1592 | dnl --------------------- |
| 1593 | dnl Add an include_mpn(`FILE') to config.m4. FILE should be a path |
| 1594 | dnl relative to the mpn source directory, for example |
| 1595 | dnl |
| 1596 | dnl GMP_INCLUDE_MPN(`x86/x86-defs.m4') |
| 1597 | dnl |
| 1598 | |
| 1599 | AC_DEFUN([GMP_INCLUDE_MPN], |
| 1600 | [AC_REQUIRE([GMP_INIT]) |
| 1601 | echo ["include_mpn(\`$1')"] >> $gmp_tmpconfigm4i |
| 1602 | ]) |
| 1603 | |
| 1604 | |
| 1605 | dnl GMP_DEFINE(MACRO, DEFINITION [, LOCATION]) |
| 1606 | dnl ------------------------------------------ |
| 1607 | dnl Define M4 macro MACRO as DEFINITION in temporary file. |
| 1608 | dnl |
| 1609 | dnl If LOCATION is `POST', the definition will appear after any include() |
| 1610 | dnl directives inserted by GMP_INCLUDE. Mind the quoting! No shell |
| 1611 | dnl variables will get expanded. Don't forget to invoke GMP_FINISH to |
| 1612 | dnl create file config.m4. config.m4 uses `<' and '>' as quote characters |
| 1613 | dnl for all defines. |
| 1614 | |
| 1615 | AC_DEFUN([GMP_DEFINE], |
| 1616 | [AC_REQUIRE([GMP_INIT]) |
| 1617 | echo ['define(<$1>, <$2>)'] >>ifelse([$3], [POST], |
| 1618 | $gmp_tmpconfigm4p, $gmp_tmpconfigm4) |
| 1619 | ]) |
| 1620 | |
| 1621 | |
| 1622 | dnl GMP_DEFINE_RAW(STRING [, LOCATION]) |
| 1623 | dnl ------------------------------------ |
| 1624 | dnl Put STRING into config.m4 file. |
| 1625 | dnl |
| 1626 | dnl If LOCATION is `POST', the definition will appear after any include() |
| 1627 | dnl directives inserted by GMP_INCLUDE. Don't forget to invoke GMP_FINISH |
| 1628 | dnl to create file config.m4. |
| 1629 | |
| 1630 | AC_DEFUN([GMP_DEFINE_RAW], |
| 1631 | [AC_REQUIRE([GMP_INIT]) |
| 1632 | echo [$1] >> ifelse([$2], [POST], $gmp_tmpconfigm4p, $gmp_tmpconfigm4) |
| 1633 | ]) |
| 1634 | |
| 1635 | |
| 1636 | dnl GMP_TRY_ASSEMBLE(asm-code,[action-success][,action-fail]) |
| 1637 | dnl ---------------------------------------------------------- |
| 1638 | dnl Attempt to assemble the given code. |
| 1639 | dnl Do "action-success" if this succeeds, "action-fail" if not. |
| 1640 | dnl |
| 1641 | dnl conftest.o and conftest.out are available for inspection in |
| 1642 | dnl "action-success". If either action does a "break" out of a loop then |
| 1643 | dnl an explicit "rm -f conftest*" will be necessary. |
| 1644 | dnl |
| 1645 | dnl This is not unlike AC_TRY_COMPILE, but there's no default includes or |
| 1646 | dnl anything in "asm-code", everything wanted must be given explicitly. |
| 1647 | |
| 1648 | AC_DEFUN([GMP_TRY_ASSEMBLE], |
| 1649 | [cat >conftest.s <<EOF |
| 1650 | [$1] |
| 1651 | EOF |
| 1652 | gmp_assemble="$CCAS $CFLAGS $CPPFLAGS conftest.s >conftest.out 2>&1" |
| 1653 | if AC_TRY_EVAL(gmp_assemble); then |
| 1654 | cat conftest.out >&AC_FD_CC |
| 1655 | ifelse([$2],,:,[$2]) |
| 1656 | else |
| 1657 | cat conftest.out >&AC_FD_CC |
| 1658 | echo "configure: failed program was:" >&AC_FD_CC |
| 1659 | cat conftest.s >&AC_FD_CC |
| 1660 | ifelse([$3],,:,[$3]) |
| 1661 | fi |
| 1662 | rm -f conftest* |
| 1663 | ]) |
| 1664 | |
| 1665 | |
| 1666 | dnl Checks whether the stack can be marked nonexecutable by passing an option |
| 1667 | dnl to the C-compiler when acting on .s files. Appends that option to ASMFLAGS. |
| 1668 | dnl This macro is adapted from one found in GLIBC-2.3.5. |
| 1669 | dnl FIXME: This test looks broken. It tests that a file with .note.GNU-stack... |
| 1670 | dnl can be compiled/assembled with -Wa,--noexecstack. It does not determine |
| 1671 | dnl if that command-line option has any effect on general asm code. |
| 1672 | AC_DEFUN([CL_AS_NOEXECSTACK],[ |
| 1673 | dnl AC_REQUIRE([AC_PROG_CC]) GMP uses something else |
| 1674 | AC_CACHE_CHECK([whether assembler supports --noexecstack option], |
| 1675 | cl_cv_as_noexecstack, [dnl |
| 1676 | cat > conftest.c <<EOF |
| 1677 | void foo() {} |
| 1678 | EOF |
| 1679 | if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS |
| 1680 | -S -o conftest.s conftest.c >/dev/null]) \ |
| 1681 | && grep .note.GNU-stack conftest.s >/dev/null \ |
| 1682 | && AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -Wa,--noexecstack |
| 1683 | -c -o conftest.o conftest.s >/dev/null]) |
| 1684 | then |
| 1685 | cl_cv_as_noexecstack=yes |
| 1686 | else |
| 1687 | cl_cv_as_noexecstack=no |
| 1688 | fi |
| 1689 | rm -f conftest*]) |
| 1690 | if test "$cl_cv_as_noexecstack" = yes; then |
| 1691 | ASMFLAGS="$ASMFLAGS -Wa,--noexecstack" |
| 1692 | fi |
| 1693 | AC_SUBST(ASMFLAGS) |
| 1694 | ]) |
| 1695 | |
| 1696 | |
| 1697 | dnl GMP_ASM_LABEL_SUFFIX |
| 1698 | dnl -------------------- |
| 1699 | dnl : - is usual. |
| 1700 | dnl empty - hppa on HP-UX doesn't use a :, just the label name |
| 1701 | dnl |
| 1702 | dnl Note that it's necessary to test the empty case first, since HP "as" |
| 1703 | dnl will accept "somelabel:", and take it to mean a label with a name that |
| 1704 | dnl happens to end in a colon. |
| 1705 | |
| 1706 | AC_DEFUN([GMP_ASM_LABEL_SUFFIX], |
| 1707 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 1708 | AC_CACHE_CHECK([for assembler label suffix], |
| 1709 | gmp_cv_asm_label_suffix, |
| 1710 | [gmp_cv_asm_label_suffix=unknown |
| 1711 | for i in "" ":"; do |
| 1712 | echo "trying $i" >&AC_FD_CC |
| 1713 | GMP_TRY_ASSEMBLE( |
| 1714 | [ $gmp_cv_asm_text |
| 1715 | somelabel$i], |
| 1716 | [gmp_cv_asm_label_suffix=$i |
| 1717 | rm -f conftest* |
| 1718 | break], |
| 1719 | [cat conftest.out >&AC_FD_CC]) |
| 1720 | done |
| 1721 | if test "$gmp_cv_asm_label_suffix" = "unknown"; then |
| 1722 | AC_MSG_ERROR([Cannot determine label suffix]) |
| 1723 | fi |
| 1724 | ]) |
| 1725 | echo ["define(<LABEL_SUFFIX>, <$gmp_cv_asm_label_suffix>)"] >> $gmp_tmpconfigm4 |
| 1726 | ]) |
| 1727 | |
| 1728 | |
| 1729 | dnl GMP_ASM_UNDERSCORE |
| 1730 | dnl ------------------ |
| 1731 | dnl Determine whether global symbols need to be prefixed with an underscore. |
| 1732 | dnl The output from "nm" is grepped to see what a typical symbol looks like. |
| 1733 | dnl |
| 1734 | dnl This test used to grep the .o file directly, but that failed with greps |
| 1735 | dnl that don't like binary files (eg. SunOS 4). |
| 1736 | dnl |
| 1737 | dnl This test also used to construct an assembler file with and without an |
| 1738 | dnl underscore and try to link that to a C file, to see which worked. |
| 1739 | dnl Although that's what will happen in the real build we don't really want |
| 1740 | dnl to depend on creating asm files within configure for every possible CPU |
| 1741 | dnl (or at least we don't want to do that more than we have to). |
| 1742 | dnl |
| 1743 | dnl The fallback on no underscore is based on the assumption that the world |
| 1744 | dnl is moving towards non-underscore systems. There should actually be no |
| 1745 | dnl good reason for nm to fail though. |
| 1746 | |
| 1747 | AC_DEFUN([GMP_ASM_UNDERSCORE], |
| 1748 | [AC_REQUIRE([GMP_PROG_NM]) |
| 1749 | AC_CACHE_CHECK([if globals are prefixed by underscore], |
| 1750 | gmp_cv_asm_underscore, |
| 1751 | [gmp_cv_asm_underscore="unknown" |
| 1752 | cat >conftest.c <<EOF |
| 1753 | int gurkmacka; |
| 1754 | EOF |
| 1755 | gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >&AC_FD_CC" |
| 1756 | if AC_TRY_EVAL(gmp_compile); then |
| 1757 | $NM conftest.$OBJEXT >conftest.out |
| 1758 | if grep "[[ ]]_gurkmacka" conftest.out >/dev/null; then |
| 1759 | gmp_cv_asm_underscore=yes |
| 1760 | elif grep "[[ ]]gurkmacka" conftest.out >/dev/null; then |
| 1761 | gmp_cv_asm_underscore=no |
| 1762 | else |
| 1763 | echo "configure: $NM doesn't have gurkmacka:" >&AC_FD_CC |
| 1764 | cat conftest.out >&AC_FD_CC |
| 1765 | fi |
| 1766 | else |
| 1767 | echo "configure: failed program was:" >&AC_FD_CC |
| 1768 | cat conftest.c >&AC_FD_CC |
| 1769 | fi |
| 1770 | rm -f conftest* |
| 1771 | ]) |
| 1772 | case $gmp_cv_asm_underscore in |
| 1773 | yes) |
| 1774 | GMP_DEFINE(GSYM_PREFIX, [_]) ;; |
| 1775 | no) |
| 1776 | GMP_DEFINE(GSYM_PREFIX, []) ;; |
| 1777 | *) |
| 1778 | AC_MSG_WARN([+----------------------------------------------------------]) |
| 1779 | AC_MSG_WARN([| Cannot determine global symbol prefix.]) |
| 1780 | AC_MSG_WARN([| $NM output doesn't contain a global data symbol.]) |
| 1781 | AC_MSG_WARN([| Will proceed with no underscore.]) |
| 1782 | AC_MSG_WARN([| If this is wrong then you'll get link errors referring]) |
| 1783 | AC_MSG_WARN([| to ___gmpn_add_n (note three underscores).]) |
| 1784 | AC_MSG_WARN([| In this case do a fresh build with an override,]) |
| 1785 | AC_MSG_WARN([| ./configure gmp_cv_asm_underscore=yes]) |
| 1786 | AC_MSG_WARN([+----------------------------------------------------------]) |
| 1787 | GMP_DEFINE(GSYM_PREFIX, []) |
| 1788 | ;; |
| 1789 | esac |
| 1790 | ]) |
| 1791 | |
| 1792 | |
| 1793 | dnl GMP_ASM_ALIGN_LOG |
| 1794 | dnl ----------------- |
| 1795 | dnl Is parameter to `.align' logarithmic? |
| 1796 | |
| 1797 | AC_DEFUN([GMP_ASM_ALIGN_LOG], |
| 1798 | [AC_REQUIRE([GMP_ASM_GLOBL]) |
| 1799 | AC_REQUIRE([GMP_ASM_BYTE]) |
| 1800 | AC_REQUIRE([GMP_ASM_DATA]) |
| 1801 | AC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) |
| 1802 | AC_REQUIRE([GMP_PROG_NM]) |
| 1803 | AC_CACHE_CHECK([if .align assembly directive is logarithmic], |
| 1804 | gmp_cv_asm_align_log, |
| 1805 | [GMP_TRY_ASSEMBLE( |
| 1806 | [ $gmp_cv_asm_data |
| 1807 | .align 4 |
| 1808 | $gmp_cv_asm_globl foo |
| 1809 | $gmp_cv_asm_byte 1 |
| 1810 | .align 4 |
| 1811 | foo$gmp_cv_asm_label_suffix |
| 1812 | $gmp_cv_asm_byte 2], |
| 1813 | [gmp_tmp_val=[`$NM conftest.$OBJEXT | grep foo | \ |
| 1814 | sed -e 's;[[][0-9][]]\(.*\);\1;' -e 's;[^1-9]*\([0-9]*\).*;\1;'`] |
| 1815 | if test "$gmp_tmp_val" = "10" || test "$gmp_tmp_val" = "16"; then |
| 1816 | gmp_cv_asm_align_log=yes |
| 1817 | else |
| 1818 | gmp_cv_asm_align_log=no |
| 1819 | fi], |
| 1820 | [AC_MSG_ERROR([cannot assemble alignment test])])]) |
| 1821 | |
| 1822 | GMP_DEFINE_RAW(["define(<ALIGN_LOGARITHMIC>,<$gmp_cv_asm_align_log>)"]) |
| 1823 | ]) |
| 1824 | |
| 1825 | |
| 1826 | dnl GMP_ASM_ALIGN_FILL_0x90 |
| 1827 | dnl ----------------------- |
| 1828 | dnl Determine whether a ",0x90" suffix works on a .align directive. |
| 1829 | dnl This is only meant for use on x86, 0x90 being a "nop". |
| 1830 | dnl |
| 1831 | dnl Old gas, eg. 1.92.3 |
| 1832 | dnl Needs ",0x90" or else the fill is 0x00, which can't be executed |
| 1833 | dnl across. |
| 1834 | dnl |
| 1835 | dnl New gas, eg. 2.91 |
| 1836 | dnl Generates multi-byte nop fills even when ",0x90" is given. |
| 1837 | dnl |
| 1838 | dnl Solaris 2.6 as |
| 1839 | dnl ",0x90" is not allowed, causes a fatal error. |
| 1840 | dnl |
| 1841 | dnl Solaris 2.8 as |
| 1842 | dnl ",0x90" does nothing, generates a warning that it's being ignored. |
| 1843 | dnl |
| 1844 | dnl SCO OpenServer 5 as |
| 1845 | dnl Second parameter is max bytes to fill, not a fill pattern. |
| 1846 | dnl ",0x90" is an error due to being bigger than the first parameter. |
| 1847 | dnl Multi-byte nop fills are generated in text segments. |
| 1848 | dnl |
| 1849 | dnl Note that both solaris "as"s only care about ",0x90" if they actually |
| 1850 | dnl have to use it to fill something, hence the .byte in the test. It's |
| 1851 | dnl the second .align which provokes the error or warning. |
| 1852 | dnl |
| 1853 | dnl The warning from solaris 2.8 is suppressed to stop anyone worrying that |
| 1854 | dnl something might be wrong. |
| 1855 | |
| 1856 | AC_DEFUN([GMP_ASM_ALIGN_FILL_0x90], |
| 1857 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 1858 | AC_CACHE_CHECK([if the .align directive accepts an 0x90 fill in .text], |
| 1859 | gmp_cv_asm_align_fill_0x90, |
| 1860 | [GMP_TRY_ASSEMBLE( |
| 1861 | [ $gmp_cv_asm_text |
| 1862 | .align 4, 0x90 |
| 1863 | .byte 0 |
| 1864 | .align 4, 0x90], |
| 1865 | [if grep "Warning: Fill parameter ignored for executable section" conftest.out >/dev/null; then |
| 1866 | echo "Suppressing this warning by omitting 0x90" 1>&AC_FD_CC |
| 1867 | gmp_cv_asm_align_fill_0x90=no |
| 1868 | else |
| 1869 | gmp_cv_asm_align_fill_0x90=yes |
| 1870 | fi], |
| 1871 | [gmp_cv_asm_align_fill_0x90=no])]) |
| 1872 | |
| 1873 | GMP_DEFINE_RAW(["define(<ALIGN_FILL_0x90>,<$gmp_cv_asm_align_fill_0x90>)"]) |
| 1874 | ]) |
| 1875 | |
| 1876 | |
| 1877 | dnl GMP_ASM_BYTE |
| 1878 | dnl ------------ |
| 1879 | dnl .byte - is usual. |
| 1880 | dnl data1 - required by ia64 (on hpux at least). |
| 1881 | dnl |
| 1882 | dnl This macro is just to support other configure tests, not any actual asm |
| 1883 | dnl code. |
| 1884 | |
| 1885 | AC_DEFUN([GMP_ASM_BYTE], |
| 1886 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 1887 | AC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) |
| 1888 | AC_CACHE_CHECK([for assembler byte directive], |
| 1889 | gmp_cv_asm_byte, |
| 1890 | [for i in .byte data1; do |
| 1891 | echo "trying $i" >&AC_FD_CC |
| 1892 | GMP_TRY_ASSEMBLE( |
| 1893 | [ $gmp_cv_asm_data |
| 1894 | $i 0 |
| 1895 | ], |
| 1896 | [gmp_cv_asm_byte=$i |
| 1897 | rm -f conftest* |
| 1898 | break], |
| 1899 | [cat conftest.out >&AC_FD_CC]) |
| 1900 | done |
| 1901 | if test -z "$gmp_cv_asm_byte"; then |
| 1902 | AC_MSG_ERROR([Cannot determine how to emit a data byte]) |
| 1903 | fi |
| 1904 | ]) |
| 1905 | ]) |
| 1906 | |
| 1907 | |
| 1908 | dnl GMP_ASM_TEXT |
| 1909 | dnl ------------ |
| 1910 | dnl .text - is usual. |
| 1911 | dnl .code - is needed by the hppa on HP-UX (but ia64 HP-UX uses .text) |
| 1912 | dnl .csect .text[PR] - is for AIX. |
| 1913 | |
| 1914 | AC_DEFUN([GMP_ASM_TEXT], |
| 1915 | [AC_CACHE_CHECK([how to switch to text section], |
| 1916 | gmp_cv_asm_text, |
| 1917 | [for i in ".text" ".code" [".csect .text[PR]"]; do |
| 1918 | echo "trying $i" >&AC_FD_CC |
| 1919 | GMP_TRY_ASSEMBLE([ $i], |
| 1920 | [gmp_cv_asm_text=$i |
| 1921 | rm -f conftest* |
| 1922 | break]) |
| 1923 | done |
| 1924 | if test -z "$gmp_cv_asm_text"; then |
| 1925 | AC_MSG_ERROR([Cannot determine text section directive]) |
| 1926 | fi |
| 1927 | ]) |
| 1928 | echo ["define(<TEXT>, <$gmp_cv_asm_text>)"] >> $gmp_tmpconfigm4 |
| 1929 | ]) |
| 1930 | |
| 1931 | |
| 1932 | dnl GMP_ASM_DATA |
| 1933 | dnl ------------ |
| 1934 | dnl Can we say `.data'? |
| 1935 | |
| 1936 | AC_DEFUN([GMP_ASM_DATA], |
| 1937 | [AC_CACHE_CHECK([how to switch to data section], |
| 1938 | gmp_cv_asm_data, |
| 1939 | [case $host in |
| 1940 | *-*-aix*) gmp_cv_asm_data=[".csect .data[RW]"] ;; |
| 1941 | *) gmp_cv_asm_data=".data" ;; |
| 1942 | esac |
| 1943 | ]) |
| 1944 | echo ["define(<DATA>, <$gmp_cv_asm_data>)"] >> $gmp_tmpconfigm4 |
| 1945 | ]) |
| 1946 | |
| 1947 | |
| 1948 | dnl GMP_ASM_RODATA |
| 1949 | dnl -------------- |
| 1950 | dnl Find out how to switch to the read-only data section. |
| 1951 | dnl |
| 1952 | dnl The compiler output is grepped for the right directive. It's not |
| 1953 | dnl considered wise to just probe for ".section .rodata" or whatever works, |
| 1954 | dnl since arbitrary section names might be accepted, but not necessarily do |
| 1955 | dnl the right thing when they get to the linker. |
| 1956 | dnl |
| 1957 | dnl Only a few asm files use RODATA, so this code is perhaps a bit |
| 1958 | dnl excessive right now, but should find more uses in the future. |
| 1959 | dnl |
| 1960 | dnl FIXME: gcc on aix generates something like ".csect _foo.ro_c[RO],3" |
| 1961 | dnl where foo is the object file. Might need to check for that if we use |
| 1962 | dnl RODATA there. |
| 1963 | |
| 1964 | AC_DEFUN([GMP_ASM_RODATA], |
| 1965 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 1966 | AC_REQUIRE([GMP_ASM_DATA]) |
| 1967 | AC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) |
| 1968 | AC_REQUIRE([GMP_ASM_UNDERSCORE]) |
| 1969 | AC_CACHE_CHECK([how to switch to read-only data section], |
| 1970 | gmp_cv_asm_rodata, |
| 1971 | [ |
| 1972 | dnl Default to DATA on CPUs with split code/data caching, and TEXT |
| 1973 | dnl elsewhere. i386 means generic x86, so use DATA on it. |
| 1974 | case $host in |
| 1975 | X86_PATTERN | x86_64-*-*) |
| 1976 | gmp_cv_asm_rodata="$gmp_cv_asm_data" ;; |
| 1977 | *) |
| 1978 | gmp_cv_asm_rodata="$gmp_cv_asm_text" ;; |
| 1979 | esac |
| 1980 | |
| 1981 | cat >conftest.c <<EOF |
| 1982 | extern const int foo[[]]; /* Suppresses C++'s suppression of foo */ |
| 1983 | const int foo[[]] = {1,2,3}; |
| 1984 | EOF |
| 1985 | echo "Test program:" >&AC_FD_CC |
| 1986 | cat conftest.c >&AC_FD_CC |
| 1987 | gmp_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c >&AC_FD_CC" |
| 1988 | if AC_TRY_EVAL(gmp_compile); then |
| 1989 | echo "Compiler output:" >&AC_FD_CC |
| 1990 | cat conftest.s >&AC_FD_CC |
| 1991 | if test $gmp_cv_asm_underscore = yes; then |
| 1992 | tmp_gsym_prefix=_ |
| 1993 | else |
| 1994 | tmp_gsym_prefix= |
| 1995 | fi |
| 1996 | # must see our label |
| 1997 | if grep "^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix" conftest.s >/dev/null 2>&AC_FD_CC; then |
| 1998 | # take the last directive before our label (hence skipping segments |
| 1999 | # getting debugging info etc) |
| 2000 | tmp_match=`sed -n ["/^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix/q |
| 2001 | /^[. ]*data/p |
| 2002 | /^[. ]*rdata/p |
| 2003 | /^[. ]*text/p |
| 2004 | /^[. ]*section/p |
| 2005 | /^[. ]*csect/p |
| 2006 | /^[. ]*CSECT/p"] conftest.s | sed -n '$p'` |
| 2007 | echo "Match: $tmp_match" >&AC_FD_CC |
| 2008 | if test -n "$tmp_match"; then |
| 2009 | gmp_cv_asm_rodata=$tmp_match |
| 2010 | fi |
| 2011 | else |
| 2012 | echo "Couldn't find label: ^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix" >&AC_FD_CC |
| 2013 | fi |
| 2014 | fi |
| 2015 | rm -f conftest* |
| 2016 | ]) |
| 2017 | echo ["define(<RODATA>, <$gmp_cv_asm_rodata>)"] >> $gmp_tmpconfigm4 |
| 2018 | ]) |
| 2019 | |
| 2020 | |
| 2021 | dnl GMP_ASM_GLOBL |
| 2022 | dnl ------------- |
| 2023 | dnl The assembler directive to mark a label as a global symbol. |
| 2024 | dnl |
| 2025 | dnl ia64 - .global is standard, according to the Intel documentation. |
| 2026 | dnl |
| 2027 | dnl hppa - ".export foo,entry" is demanded by HP hppa "as". ".global" is a |
| 2028 | dnl kind of import. |
| 2029 | dnl |
| 2030 | dnl other - .globl is usual. |
| 2031 | dnl |
| 2032 | dnl "gas" tends to accept .globl everywhere, in addition to .export or |
| 2033 | dnl .global or whatever the system assembler demands. |
| 2034 | |
| 2035 | AC_DEFUN([GMP_ASM_GLOBL], |
| 2036 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 2037 | AC_CACHE_CHECK([for assembler global directive], |
| 2038 | gmp_cv_asm_globl, |
| 2039 | [case $host in |
| 2040 | hppa*-*-*) gmp_cv_asm_globl=.export ;; |
| 2041 | IA64_PATTERN) gmp_cv_asm_globl=.global ;; |
| 2042 | *) gmp_cv_asm_globl=.globl ;; |
| 2043 | esac |
| 2044 | ]) |
| 2045 | echo ["define(<GLOBL>, <$gmp_cv_asm_globl>)"] >> $gmp_tmpconfigm4 |
| 2046 | ]) |
| 2047 | |
| 2048 | |
| 2049 | dnl GMP_ASM_GLOBL_ATTR |
| 2050 | dnl ------------------ |
| 2051 | dnl Do we need something after `GLOBL symbol'? |
| 2052 | |
| 2053 | AC_DEFUN([GMP_ASM_GLOBL_ATTR], |
| 2054 | [AC_REQUIRE([GMP_ASM_GLOBL]) |
| 2055 | AC_CACHE_CHECK([for assembler global directive attribute], |
| 2056 | gmp_cv_asm_globl_attr, |
| 2057 | [case $gmp_cv_asm_globl in |
| 2058 | .export) gmp_cv_asm_globl_attr=",entry" ;; |
| 2059 | *) gmp_cv_asm_globl_attr="" ;; |
| 2060 | esac |
| 2061 | ]) |
| 2062 | echo ["define(<GLOBL_ATTR>, <$gmp_cv_asm_globl_attr>)"] >> $gmp_tmpconfigm4 |
| 2063 | ]) |
| 2064 | |
| 2065 | |
| 2066 | dnl GMP_ASM_TYPE |
| 2067 | dnl ------------ |
| 2068 | dnl Can we say ".type", and how? |
| 2069 | dnl |
| 2070 | dnl For i386 GNU/Linux ELF systems, and very likely other ELF systems, |
| 2071 | dnl .type and .size are important on functions in shared libraries. If |
| 2072 | dnl .type is omitted and the mainline program references that function then |
| 2073 | dnl the code will be copied down to the mainline at load time like a piece |
| 2074 | dnl of data. If .size is wrong or missing (it defaults to 4 bytes or some |
| 2075 | dnl such) then incorrect bytes will be copied and a segv is the most likely |
| 2076 | dnl result. In any case such copying is not what's wanted, a .type |
| 2077 | dnl directive will ensure a PLT entry is used. |
| 2078 | dnl |
| 2079 | dnl In GMP the assembler functions are normally only used from within the |
| 2080 | dnl library (since most programs are not interested in the low level |
| 2081 | dnl routines), and in those circumstances a missing .type isn't fatal, |
| 2082 | dnl letting the problem go unnoticed. tests/mpn/t-asmtype.c aims to check |
| 2083 | dnl for it. |
| 2084 | |
| 2085 | AC_DEFUN([GMP_ASM_TYPE], |
| 2086 | [AC_CACHE_CHECK([for assembler .type directive], |
| 2087 | gmp_cv_asm_type, |
| 2088 | [gmp_cv_asm_type= |
| 2089 | for gmp_tmp_prefix in @ \# %; do |
| 2090 | GMP_TRY_ASSEMBLE([ .type sym,${gmp_tmp_prefix}function], |
| 2091 | [if grep "\.type pseudo-op used outside of \.def/\.endef ignored" conftest.out >/dev/null; then : ; |
| 2092 | else |
| 2093 | gmp_cv_asm_type=".type \$][1,${gmp_tmp_prefix}\$][2" |
| 2094 | break |
| 2095 | fi]) |
| 2096 | done |
| 2097 | rm -f conftest* |
| 2098 | ]) |
| 2099 | echo ["define(<TYPE>, <$gmp_cv_asm_type>)"] >> $gmp_tmpconfigm4 |
| 2100 | ]) |
| 2101 | |
| 2102 | |
| 2103 | dnl GMP_ASM_SIZE |
| 2104 | dnl ------------ |
| 2105 | dnl Can we say `.size'? |
| 2106 | |
| 2107 | AC_DEFUN([GMP_ASM_SIZE], |
| 2108 | [AC_CACHE_CHECK([for assembler .size directive], |
| 2109 | gmp_cv_asm_size, |
| 2110 | [gmp_cv_asm_size= |
| 2111 | GMP_TRY_ASSEMBLE([ .size sym,1], |
| 2112 | [if grep "\.size pseudo-op used outside of \.def/\.endef ignored" conftest.out >/dev/null; then : ; |
| 2113 | else |
| 2114 | gmp_cv_asm_size=".size \$][1,\$][2" |
| 2115 | fi]) |
| 2116 | ]) |
| 2117 | echo ["define(<SIZE>, <$gmp_cv_asm_size>)"] >> $gmp_tmpconfigm4 |
| 2118 | ]) |
| 2119 | |
| 2120 | |
| 2121 | dnl GMP_ASM_COFF_TYPE |
| 2122 | dnl ----------------- |
| 2123 | dnl Determine whether the assembler supports COFF type information. |
| 2124 | dnl |
| 2125 | dnl Currently this is only needed for mingw (and cygwin perhaps) and so is |
| 2126 | dnl run only on the x86s, but it ought to work anywhere. |
| 2127 | dnl |
| 2128 | dnl On MINGW, recent versions of the linker have an automatic import scheme |
| 2129 | dnl for data in a DLL which is referenced by a mainline but without |
| 2130 | dnl __declspec (__dllimport__) on the prototype. It seems functions |
| 2131 | dnl without type information are treated as data, or something, and calls |
| 2132 | dnl to them from the mainline will crash. gcc puts type information on the |
| 2133 | dnl C functions it generates, we need to do the same for assembler |
| 2134 | dnl functions. |
| 2135 | dnl |
| 2136 | dnl This applies only to functions without __declspec(__dllimport__), |
| 2137 | dnl ie. without __GMP_DECLSPEC in the case of libgmp, so it also works just |
| 2138 | dnl to ensure all assembler functions used from outside libgmp have |
| 2139 | dnl __GMP_DECLSPEC on their prototypes. But this isn't an ideal situation, |
| 2140 | dnl since we don't want perfectly valid calls going wrong just because |
| 2141 | dnl there wasn't a prototype in scope. |
| 2142 | dnl |
| 2143 | dnl When an auto-import takes place, the following warning is given by the |
| 2144 | dnl linker. This shouldn't be seen for any functions. |
| 2145 | dnl |
| 2146 | dnl Info: resolving _foo by linking to __imp__foo (auto-import) |
| 2147 | dnl |
| 2148 | dnl |
| 2149 | dnl COFF type directives look like the following |
| 2150 | dnl |
| 2151 | dnl .def _foo |
| 2152 | dnl .scl 2 |
| 2153 | dnl .type 32 |
| 2154 | dnl .endef |
| 2155 | dnl |
| 2156 | dnl _foo is the symbol with GSYM_PREFIX (_). .scl is the storage class, 2 |
| 2157 | dnl for external, 3 for static. .type is the object type, 32 for a |
| 2158 | dnl function. |
| 2159 | dnl |
| 2160 | dnl On an ELF system, this is (correctly) rejected due to .def, .endef and |
| 2161 | dnl .scl being invalid, and .type not having enough arguments. |
| 2162 | |
| 2163 | AC_DEFUN([GMP_ASM_COFF_TYPE], |
| 2164 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 2165 | AC_REQUIRE([GMP_ASM_GLOBL]) |
| 2166 | AC_REQUIRE([GMP_ASM_GLOBL_ATTR]) |
| 2167 | AC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) |
| 2168 | AC_REQUIRE([GMP_ASM_UNDERSCORE]) |
| 2169 | AC_CACHE_CHECK([for assembler COFF type directives], |
| 2170 | gmp_cv_asm_x86_coff_type, |
| 2171 | [GMP_TRY_ASSEMBLE( |
| 2172 | [ $gmp_cv_asm_text |
| 2173 | $gmp_cv_asm_globl ${tmp_gsym_prefix}foo$gmp_cv_asm_globl_attr |
| 2174 | .def ${tmp_gsym_prefix}foo |
| 2175 | .scl 2 |
| 2176 | .type 32 |
| 2177 | .endef |
| 2178 | ${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix |
| 2179 | ], |
| 2180 | [gmp_cv_asm_x86_coff_type=yes], |
| 2181 | [gmp_cv_asm_x86_coff_type=no]) |
| 2182 | ]) |
| 2183 | echo ["define(<HAVE_COFF_TYPE>, <$gmp_cv_asm_x86_coff_type>)"] >> $gmp_tmpconfigm4 |
| 2184 | ]) |
| 2185 | |
| 2186 | |
| 2187 | dnl GMP_ASM_LSYM_PREFIX |
| 2188 | dnl ------------------- |
| 2189 | dnl What is the prefix for a local label? |
| 2190 | dnl |
| 2191 | dnl The prefixes tested are, |
| 2192 | dnl |
| 2193 | dnl L - usual for underscore systems |
| 2194 | dnl .L - usual for non-underscore systems |
| 2195 | dnl $ - alpha (gas and OSF system assembler) |
| 2196 | dnl L$ - hppa (gas and HP-UX system assembler) |
| 2197 | dnl |
| 2198 | dnl The default is "L" if the tests fail for any reason. There's a good |
| 2199 | dnl chance this will be adequate, since on most systems labels are local |
| 2200 | dnl anyway unless given a ".globl", and an "L" will avoid clashes with |
| 2201 | dnl other identifers. |
| 2202 | dnl |
| 2203 | dnl For gas, ".L" is normally purely local to the assembler, it doesn't get |
| 2204 | dnl put into the object file at all. This style is preferred, to keep the |
| 2205 | dnl object files nice and clean. |
| 2206 | dnl |
| 2207 | dnl BSD format nm produces a line like |
| 2208 | dnl |
| 2209 | dnl 00000000 t Lgurkmacka |
| 2210 | dnl |
| 2211 | dnl The symbol code is normally "t" for text, but any lower case letter |
| 2212 | dnl indicates a local definition. |
| 2213 | dnl |
| 2214 | dnl Code "n" is for a debugging symbol, OSF "nm -B" gives that as an upper |
| 2215 | dnl case "N" for a local. |
| 2216 | dnl |
| 2217 | dnl HP-UX nm prints an error message (though seems to give a 0 exit) if |
| 2218 | dnl there's no symbols at all in an object file, hence the use of "dummy". |
| 2219 | |
| 2220 | AC_DEFUN([GMP_ASM_LSYM_PREFIX], |
| 2221 | [AC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) |
| 2222 | AC_REQUIRE([GMP_ASM_TEXT]) |
| 2223 | AC_REQUIRE([GMP_PROG_NM]) |
| 2224 | AC_CACHE_CHECK([for assembler local label prefix], |
| 2225 | gmp_cv_asm_lsym_prefix, |
| 2226 | [gmp_tmp_pre_appears=yes |
| 2227 | for gmp_tmp_pre in L .L $L $ L$; do |
| 2228 | echo "Trying $gmp_tmp_pre" >&AC_FD_CC |
| 2229 | GMP_TRY_ASSEMBLE( |
| 2230 | [ $gmp_cv_asm_text |
| 2231 | dummy${gmp_cv_asm_label_suffix} |
| 2232 | ${gmp_tmp_pre}gurkmacka${gmp_cv_asm_label_suffix}], |
| 2233 | [if $NM conftest.$OBJEXT >conftest.nm 2>&AC_FD_CC; then : ; else |
| 2234 | cat conftest.nm >&AC_FD_CC |
| 2235 | AC_MSG_WARN(["$NM" failure]) |
| 2236 | break |
| 2237 | fi |
| 2238 | cat conftest.nm >&AC_FD_CC |
| 2239 | if grep gurkmacka conftest.nm >/dev/null; then : ; else |
| 2240 | # no mention of the symbol, this is good |
| 2241 | echo "$gmp_tmp_pre label doesn't appear in object file at all (good)" >&AC_FD_CC |
| 2242 | gmp_cv_asm_lsym_prefix="$gmp_tmp_pre" |
| 2243 | gmp_tmp_pre_appears=no |
| 2244 | break |
| 2245 | fi |
| 2246 | if grep [' [a-zN] .*gurkmacka'] conftest.nm >/dev/null; then |
| 2247 | # symbol mentioned as a local, use this if nothing better |
| 2248 | echo "$gmp_tmp_pre label is local but still in object file" >&AC_FD_CC |
| 2249 | if test -z "$gmp_cv_asm_lsym_prefix"; then |
| 2250 | gmp_cv_asm_lsym_prefix="$gmp_tmp_pre" |
| 2251 | fi |
| 2252 | else |
| 2253 | echo "$gmp_tmp_pre label is something unknown" >&AC_FD_CC |
| 2254 | fi |
| 2255 | ]) |
| 2256 | done |
| 2257 | rm -f conftest* |
| 2258 | if test -z "$gmp_cv_asm_lsym_prefix"; then |
| 2259 | gmp_cv_asm_lsym_prefix=L |
| 2260 | AC_MSG_WARN([cannot determine local label, using default $gmp_cv_asm_lsym_prefix]) |
| 2261 | fi |
| 2262 | # for development purposes, note whether we got a purely temporary local label |
| 2263 | echo "Local label appears in object files: $gmp_tmp_pre_appears" >&AC_FD_CC |
| 2264 | ]) |
| 2265 | echo ["define(<LSYM_PREFIX>, <${gmp_cv_asm_lsym_prefix}>)"] >> $gmp_tmpconfigm4 |
| 2266 | AC_DEFINE_UNQUOTED(LSYM_PREFIX, "$gmp_cv_asm_lsym_prefix", |
| 2267 | [Assembler local label prefix]) |
| 2268 | ]) |
| 2269 | |
| 2270 | |
| 2271 | dnl GMP_ASM_W32 |
| 2272 | dnl ----------- |
| 2273 | dnl How to define a 32-bit word. |
| 2274 | dnl |
| 2275 | dnl FIXME: This test is not right for ia64-*-hpux*. The directive should |
| 2276 | dnl be "data4", but the W32 macro is not currently used by the mpn/ia64 asm |
| 2277 | dnl files. |
| 2278 | |
| 2279 | AC_DEFUN([GMP_ASM_W32], |
| 2280 | [AC_REQUIRE([GMP_ASM_DATA]) |
| 2281 | AC_REQUIRE([GMP_ASM_BYTE]) |
| 2282 | AC_REQUIRE([GMP_ASM_GLOBL]) |
| 2283 | AC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) |
| 2284 | AC_REQUIRE([GMP_PROG_NM]) |
| 2285 | AC_CACHE_CHECK([how to define a 32-bit word], |
| 2286 | gmp_cv_asm_w32, |
| 2287 | [case $host in |
| 2288 | *-*-hpux*) |
| 2289 | # FIXME: HPUX puts first symbol at 0x40000000, breaking our assumption |
| 2290 | # that it's at 0x0. We'll have to declare another symbol before the |
| 2291 | # .long/.word and look at the distance between the two symbols. The |
| 2292 | # only problem is that the sed expression(s) barfs (on Solaris, for |
| 2293 | # example) for the symbol with value 0. For now, HPUX uses .word. |
| 2294 | gmp_cv_asm_w32=".word" |
| 2295 | ;; |
| 2296 | *-*-*) |
| 2297 | gmp_tmp_val= |
| 2298 | for gmp_tmp_op in .long .word data4; do |
| 2299 | GMP_TRY_ASSEMBLE( |
| 2300 | [ $gmp_cv_asm_data |
| 2301 | $gmp_cv_asm_globl foo |
| 2302 | $gmp_tmp_op 0 |
| 2303 | foo$gmp_cv_asm_label_suffix |
| 2304 | $gmp_cv_asm_byte 0], |
| 2305 | [gmp_tmp_val=[`$NM conftest.$OBJEXT | grep foo | \ |
| 2306 | sed -e 's;[[][0-9][]]\(.*\);\1;' -e 's;[^1-9]*\([0-9]*\).*;\1;'`] |
| 2307 | if test "$gmp_tmp_val" = 4; then |
| 2308 | gmp_cv_asm_w32="$gmp_tmp_op" |
| 2309 | break |
| 2310 | fi]) |
| 2311 | done |
| 2312 | rm -f conftest* |
| 2313 | ;; |
| 2314 | esac |
| 2315 | if test -z "$gmp_cv_asm_w32"; then |
| 2316 | AC_MSG_ERROR([cannot determine how to define a 32-bit word]) |
| 2317 | fi |
| 2318 | ]) |
| 2319 | echo ["define(<W32>, <$gmp_cv_asm_w32>)"] >> $gmp_tmpconfigm4 |
| 2320 | ]) |
| 2321 | |
| 2322 | |
| 2323 | dnl GMP_X86_ASM_GOT_UNDERSCORE |
| 2324 | dnl -------------------------- |
| 2325 | dnl Determine whether i386 _GLOBAL_OFFSET_TABLE_ needs an additional |
| 2326 | dnl underscore prefix. |
| 2327 | dnl |
| 2328 | dnl SVR4 - the standard is _GLOBAL_OFFSET_TABLE_ |
| 2329 | dnl GNU/Linux - follows SVR4 |
| 2330 | dnl OpenBSD - an a.out underscore system, uses __GLOBAL_OFFSET_TABLE_ |
| 2331 | dnl NetBSD - also an a.out underscore system, but _GLOBAL_OFFSET_TABLE_ |
| 2332 | dnl |
| 2333 | dnl The test attempts to link a program using _GLOBAL_OFFSET_TABLE_ or |
| 2334 | dnl __GLOBAL_OFFSET_TABLE_ to see which works. |
| 2335 | dnl |
| 2336 | dnl $lt_prog_compiler_pic is included in the compile because old versions |
| 2337 | dnl of gas wouldn't accept PIC idioms without the right option (-K). This |
| 2338 | dnl is the same as what libtool and mpn/Makeasm.am will do. |
| 2339 | dnl |
| 2340 | dnl $lt_prog_compiler_pic is also included in the link because OpenBSD ld |
| 2341 | dnl won't accept an R_386_GOTPC relocation without the right options. This |
| 2342 | dnl is not what's done by the Makefiles when building executables, but |
| 2343 | dnl let's hope it's ok (it works fine with gcc). |
| 2344 | dnl |
| 2345 | dnl The fallback is no additional underscore, on the basis that this will |
| 2346 | dnl suit SVR4/ELF style systems, which should be much more common than |
| 2347 | dnl a.out systems with shared libraries. |
| 2348 | dnl |
| 2349 | dnl Note that it's not an error for the tests to fail, since for instance |
| 2350 | dnl cygwin, mingw and djgpp don't have a _GLOBAL_OFFSET_TABLE_ scheme at |
| 2351 | dnl all. |
| 2352 | dnl |
| 2353 | dnl Perhaps $CCAS could be asked to do the linking as well as the |
| 2354 | dnl assembling, but in the Makefiles it's only used for assembling, so lets |
| 2355 | dnl keep it that way. |
| 2356 | dnl |
| 2357 | dnl The test here is run even under --disable-shared, so that PIC objects |
| 2358 | dnl can be built and tested by the tune/many.pl development scheme. The |
| 2359 | dnl tests will be reasonably quick and won't give a fatal error, so this |
| 2360 | dnl arrangement is ok. AC_LIBTOOL_PROG_COMPILER_PIC does its |
| 2361 | dnl $lt_prog_compiler_pic setups even for --disable-shared too. |
| 2362 | |
| 2363 | AC_DEFUN([GMP_ASM_X86_GOT_UNDERSCORE], |
| 2364 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 2365 | AC_REQUIRE([GMP_ASM_GLOBL]) |
| 2366 | AC_REQUIRE([GMP_ASM_GLOBL_ATTR]) |
| 2367 | AC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) |
| 2368 | AC_REQUIRE([GMP_ASM_UNDERSCORE]) |
| 2369 | AC_REQUIRE([AC_LIBTOOL_PROG_COMPILER_PIC]) |
| 2370 | AC_CACHE_CHECK([if _GLOBAL_OFFSET_TABLE_ is prefixed by underscore], |
| 2371 | gmp_cv_asm_x86_got_underscore, |
| 2372 | [gmp_cv_asm_x86_got_underscore="not applicable" |
| 2373 | if test $gmp_cv_asm_underscore = yes; then |
| 2374 | tmp_gsym_prefix=_ |
| 2375 | else |
| 2376 | tmp_gsym_prefix= |
| 2377 | fi |
| 2378 | for tmp_underscore in "" "_"; do |
| 2379 | cat >conftest.s <<EOF |
| 2380 | $gmp_cv_asm_text |
| 2381 | $gmp_cv_asm_globl ${tmp_gsym_prefix}main$gmp_cv_asm_globl_attr |
| 2382 | ${tmp_gsym_prefix}main$gmp_cv_asm_label_suffix |
| 2383 | addl $ ${tmp_underscore}_GLOBAL_OFFSET_TABLE_, %ebx |
| 2384 | EOF |
| 2385 | gmp_compile="$CCAS $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.s >&AC_FD_CC && $CC $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.$OBJEXT >&AC_FD_CC" |
| 2386 | if AC_TRY_EVAL(gmp_compile); then |
| 2387 | if test "$tmp_underscore" = "_"; then |
| 2388 | gmp_cv_asm_x86_got_underscore=yes |
| 2389 | else |
| 2390 | gmp_cv_asm_x86_got_underscore=no |
| 2391 | fi |
| 2392 | break |
| 2393 | fi |
| 2394 | done |
| 2395 | rm -f conftest* a.out b.out a.exe a_out.exe |
| 2396 | ]) |
| 2397 | if test "$gmp_cv_asm_x86_got_underscore" = "yes"; then |
| 2398 | GMP_DEFINE(GOT_GSYM_PREFIX, [_]) |
| 2399 | else |
| 2400 | GMP_DEFINE(GOT_GSYM_PREFIX, []) |
| 2401 | fi |
| 2402 | ]) |
| 2403 | |
| 2404 | |
| 2405 | dnl GMP_ASM_X86_GOT_EAX_OK(CC+CFLAGS, [ACTION-YES] [, ACTION-NO]) |
| 2406 | dnl ------------------------------------------------------------- |
| 2407 | dnl Determine whether _GLOBAL_OFFSET_TABLE_ used with %eax is ok. |
| 2408 | dnl |
| 2409 | dnl An instruction |
| 2410 | dnl |
| 2411 | dnl addl $_GLOBAL_OFFSET_TABLE_, %eax |
| 2412 | dnl |
| 2413 | dnl is incorrectly assembled by gas 2.12 (or thereabouts) and earlier. It |
| 2414 | dnl puts an addend 2 into the R_386_GOTPC relocation, but it should be 1 |
| 2415 | dnl for this %eax form being a 1 byte opcode (with other registers it's 2 |
| 2416 | dnl opcode bytes). See note about this in mpn/x86/README too. |
| 2417 | dnl |
| 2418 | dnl We assemble this, surrounded by some unlikely byte sequences as |
| 2419 | dnl delimiters, and check for the bad output. |
| 2420 | dnl |
| 2421 | dnl This is for use by compiler probing in GMP_PROG_CC_WORKS, so the result |
| 2422 | dnl is not cached. |
| 2423 | dnl |
| 2424 | dnl This test is not specific to gas, but old gas is the only assembler we |
| 2425 | dnl know of with this problem. The Solaris has been seen coming out ok. |
| 2426 | dnl |
| 2427 | dnl ".text" is hard coded because this macro is wanted before GMP_ASM_TEXT. |
| 2428 | dnl This should be fine, ".text" is normal on x86 systems, and certainly |
| 2429 | dnl will be fine with the offending gas. |
| 2430 | dnl |
| 2431 | dnl If an error occurs when assembling, we consider the assembler ok, since |
| 2432 | dnl the bad output does not occur. This happens for instance on mingw, |
| 2433 | dnl where _GLOBAL_OFFSET_TABLE_ results in a bfd error, since there's no |
| 2434 | dnl GOT etc in PE object files. |
| 2435 | dnl |
| 2436 | dnl This test is used before the object file extension has been determined, |
| 2437 | dnl so we force output to conftest.o. Using -o with -c is not portable, |
| 2438 | dnl but we think all x86 compilers will accept -o with -c, certainly gcc |
| 2439 | dnl does. |
| 2440 | dnl |
| 2441 | dnl -fPIC is hard coded here, because this test is for use before libtool |
| 2442 | dnl has established the pic options. It's right for gcc, but perhaps not |
| 2443 | dnl other compilers. |
| 2444 | |
| 2445 | AC_DEFUN([GMP_ASM_X86_GOT_EAX_OK], |
| 2446 | [echo "Testing gas GOT with eax good" >&AC_FD_CC |
| 2447 | cat >conftest.awk <<\EOF |
| 2448 | [BEGIN { |
| 2449 | want[0] = "001" |
| 2450 | want[1] = "043" |
| 2451 | want[2] = "105" |
| 2452 | want[3] = "147" |
| 2453 | want[4] = "211" |
| 2454 | want[5] = "253" |
| 2455 | want[6] = "315" |
| 2456 | want[7] = "357" |
| 2457 | |
| 2458 | want[8] = "005" |
| 2459 | want[9] = "002" |
| 2460 | want[10] = "000" |
| 2461 | want[11] = "000" |
| 2462 | want[12] = "000" |
| 2463 | |
| 2464 | want[13] = "376" |
| 2465 | want[14] = "334" |
| 2466 | want[15] = "272" |
| 2467 | want[16] = "230" |
| 2468 | want[17] = "166" |
| 2469 | want[18] = "124" |
| 2470 | want[19] = "062" |
| 2471 | want[20] = "020" |
| 2472 | |
| 2473 | result = "yes" |
| 2474 | } |
| 2475 | { |
| 2476 | for (f = 2; f <= NF; f++) |
| 2477 | { |
| 2478 | for (i = 0; i < 20; i++) |
| 2479 | got[i] = got[i+1]; |
| 2480 | got[20] = $f; |
| 2481 | |
| 2482 | found = 1 |
| 2483 | for (i = 0; i < 21; i++) |
| 2484 | if (got[i] != want[i]) |
| 2485 | { |
| 2486 | found = 0 |
| 2487 | break |
| 2488 | } |
| 2489 | if (found) |
| 2490 | { |
| 2491 | result = "no" |
| 2492 | exit |
| 2493 | } |
| 2494 | } |
| 2495 | } |
| 2496 | END { |
| 2497 | print result |
| 2498 | } |
| 2499 | ]EOF |
| 2500 | cat >conftest.s <<\EOF |
| 2501 | [ .text |
| 2502 | .byte 1, 35, 69, 103, 137, 171, 205, 239 |
| 2503 | addl $_GLOBAL_OFFSET_TABLE_, %eax |
| 2504 | .byte 254, 220, 186, 152, 118, 84, 50, 16 |
| 2505 | ]EOF |
| 2506 | tmp_got_good=yes |
| 2507 | gmp_compile="$1 -fPIC -o conftest.o -c conftest.s >&AC_FD_CC 2>&1" |
| 2508 | if AC_TRY_EVAL(gmp_compile); then |
| 2509 | tmp_got_good=`od -b conftest.o | $AWK -f conftest.awk` |
| 2510 | fi |
| 2511 | rm -f conftest.* |
| 2512 | echo "Result: $tmp_got_good" >&AC_FD_CC |
| 2513 | if test "$tmp_got_good" = no; then |
| 2514 | ifelse([$3],,:,[$3]) |
| 2515 | else |
| 2516 | ifelse([$2],,:,[$2]) |
| 2517 | fi |
| 2518 | ]) |
| 2519 | |
| 2520 | |
| 2521 | dnl GMP_ASM_X86_MMX([ACTION-IF-YES][,ACTION-IF-NO]) |
| 2522 | dnl ----------------------------------------------- |
| 2523 | dnl Determine whether the assembler supports MMX instructions. |
| 2524 | dnl |
| 2525 | dnl This macro is wanted before GMP_ASM_TEXT, so ".text" is hard coded |
| 2526 | dnl here. ".text" is believed to be correct on all x86 systems. Actually |
| 2527 | dnl ".text" probably isn't needed at all, at least for just checking |
| 2528 | dnl instruction syntax. |
| 2529 | dnl |
| 2530 | dnl "movq %mm0, %mm1" should assemble to "0f 6f c8", but Solaris 2.6 and |
| 2531 | dnl 2.7 wrongly assemble it to "0f 6f c1" (that being the reverse "movq |
| 2532 | dnl %mm1, %mm0"). It seems more trouble than it's worth to work around |
| 2533 | dnl this in the code, so just detect and reject. |
| 2534 | |
| 2535 | AC_DEFUN([GMP_ASM_X86_MMX], |
| 2536 | [AC_CACHE_CHECK([if the assembler knows about MMX instructions], |
| 2537 | gmp_cv_asm_x86_mmx, |
| 2538 | [GMP_TRY_ASSEMBLE( |
| 2539 | [ .text |
| 2540 | movq %mm0, %mm1], |
| 2541 | [gmp_cv_asm_x86_mmx=yes |
| 2542 | case $host in |
| 2543 | *-*-solaris*) |
| 2544 | if (dis conftest.$OBJEXT >conftest.out) 2>/dev/null; then |
| 2545 | if grep "0f 6f c1" conftest.out >/dev/null; then |
| 2546 | gmp_cv_asm_x86_mmx=movq-bug |
| 2547 | fi |
| 2548 | else |
| 2549 | AC_MSG_WARN(["dis" not available to check for "as" movq bug]) |
| 2550 | fi |
| 2551 | esac], |
| 2552 | [gmp_cv_asm_x86_mmx=no])]) |
| 2553 | |
| 2554 | case $gmp_cv_asm_x86_mmx in |
| 2555 | movq-bug) |
| 2556 | AC_MSG_WARN([+----------------------------------------------------------]) |
| 2557 | AC_MSG_WARN([| WARNING WARNING WARNING]) |
| 2558 | AC_MSG_WARN([| Host CPU has MMX code, but the assembler]) |
| 2559 | AC_MSG_WARN([| $CCAS $CFLAGS $CPPFLAGS]) |
| 2560 | AC_MSG_WARN([| has the Solaris 2.6 and 2.7 bug where register to register]) |
| 2561 | AC_MSG_WARN([| movq operands are reversed.]) |
| 2562 | AC_MSG_WARN([| Non-MMX replacements will be used.]) |
| 2563 | AC_MSG_WARN([| This will be an inferior build.]) |
| 2564 | AC_MSG_WARN([+----------------------------------------------------------]) |
| 2565 | ;; |
| 2566 | no) |
| 2567 | AC_MSG_WARN([+----------------------------------------------------------]) |
| 2568 | AC_MSG_WARN([| WARNING WARNING WARNING]) |
| 2569 | AC_MSG_WARN([| Host CPU has MMX code, but it can't be assembled by]) |
| 2570 | AC_MSG_WARN([| $CCAS $CFLAGS $CPPFLAGS]) |
| 2571 | AC_MSG_WARN([| Non-MMX replacements will be used.]) |
| 2572 | AC_MSG_WARN([| This will be an inferior build.]) |
| 2573 | AC_MSG_WARN([+----------------------------------------------------------]) |
| 2574 | ;; |
| 2575 | esac |
| 2576 | if test "$gmp_cv_asm_x86_mmx" = yes; then |
| 2577 | ifelse([$1],,:,[$1]) |
| 2578 | else |
| 2579 | ifelse([$2],,:,[$2]) |
| 2580 | fi |
| 2581 | ]) |
| 2582 | |
| 2583 | |
| 2584 | dnl GMP_ASM_X86_SHLDL_CL |
| 2585 | dnl -------------------- |
| 2586 | |
| 2587 | AC_DEFUN([GMP_ASM_X86_SHLDL_CL], |
| 2588 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 2589 | AC_CACHE_CHECK([if the assembler takes cl with shldl], |
| 2590 | gmp_cv_asm_x86_shldl_cl, |
| 2591 | [GMP_TRY_ASSEMBLE( |
| 2592 | [ $gmp_cv_asm_text |
| 2593 | shldl %cl, %eax, %ebx], |
| 2594 | gmp_cv_asm_x86_shldl_cl=yes, |
| 2595 | gmp_cv_asm_x86_shldl_cl=no) |
| 2596 | ]) |
| 2597 | if test "$gmp_cv_asm_x86_shldl_cl" = "yes"; then |
| 2598 | GMP_DEFINE(WANT_SHLDL_CL,1) |
| 2599 | else |
| 2600 | GMP_DEFINE(WANT_SHLDL_CL,0) |
| 2601 | fi |
| 2602 | ]) |
| 2603 | |
| 2604 | |
| 2605 | dnl GMP_ASM_X86_SSE2([ACTION-IF-YES][,ACTION-IF-NO]) |
| 2606 | dnl ------------------------------------------------ |
| 2607 | dnl Determine whether the assembler supports SSE2 instructions. |
| 2608 | dnl |
| 2609 | dnl This macro is wanted before GMP_ASM_TEXT, so ".text" is hard coded |
| 2610 | dnl here. ".text" is believed to be correct on all x86 systems, certainly |
| 2611 | dnl it's all GMP_ASM_TEXT gives currently. Actually ".text" probably isn't |
| 2612 | dnl needed at all, at least for just checking instruction syntax. |
| 2613 | |
| 2614 | AC_DEFUN([GMP_ASM_X86_SSE2], |
| 2615 | [AC_CACHE_CHECK([if the assembler knows about SSE2 instructions], |
| 2616 | gmp_cv_asm_x86_sse2, |
| 2617 | [GMP_TRY_ASSEMBLE( |
| 2618 | [ .text |
| 2619 | paddq %mm0, %mm1], |
| 2620 | [gmp_cv_asm_x86_sse2=yes], |
| 2621 | [gmp_cv_asm_x86_sse2=no]) |
| 2622 | ]) |
| 2623 | case $gmp_cv_asm_x86_sse2 in |
| 2624 | yes) |
| 2625 | ifelse([$1],,:,[$1]) |
| 2626 | ;; |
| 2627 | *) |
| 2628 | AC_MSG_WARN([+----------------------------------------------------------]) |
| 2629 | AC_MSG_WARN([| WARNING WARNING WARNING]) |
| 2630 | AC_MSG_WARN([| Host CPU has SSE2 code, but it can't be assembled by]) |
| 2631 | AC_MSG_WARN([| $CCAS $CFLAGS $CPPFLAGS]) |
| 2632 | AC_MSG_WARN([| Non-SSE2 replacements will be used.]) |
| 2633 | AC_MSG_WARN([| This will be an inferior build.]) |
| 2634 | AC_MSG_WARN([+----------------------------------------------------------]) |
| 2635 | ifelse([$2],,:,[$2]) |
| 2636 | ;; |
| 2637 | esac |
| 2638 | ]) |
| 2639 | |
| 2640 | |
| 2641 | dnl GMP_ASM_X86_MULX([ACTION-IF-YES][,ACTION-IF-NO]) |
| 2642 | dnl ------------------------------------------------ |
| 2643 | dnl Determine whether the assembler supports the mulx instruction which debut |
| 2644 | dnl with Haswell. |
| 2645 | dnl |
| 2646 | dnl This macro is wanted before GMP_ASM_TEXT, so ".text" is hard coded |
| 2647 | dnl here. ".text" is believed to be correct on all x86 systems, certainly |
| 2648 | dnl it's all GMP_ASM_TEXT gives currently. Actually ".text" probably isn't |
| 2649 | dnl needed at all, at least for just checking instruction syntax. |
| 2650 | |
| 2651 | AC_DEFUN([GMP_ASM_X86_MULX], |
| 2652 | [AC_CACHE_CHECK([if the assembler knows about the mulx instruction], |
| 2653 | gmp_cv_asm_x86_mulx, |
| 2654 | [GMP_TRY_ASSEMBLE( |
| 2655 | [ .text |
| 2656 | mulx %r8, %r9, %r10], |
| 2657 | [gmp_cv_asm_x86_mulx=yes], |
| 2658 | [gmp_cv_asm_x86_mulx=no]) |
| 2659 | ]) |
| 2660 | case $gmp_cv_asm_x86_mulx in |
| 2661 | yes) |
| 2662 | AC_DEFINE(X86_ASM_MULX, 1, |
| 2663 | [Define to 1 if the assembler understands the mulx instruction]) |
| 2664 | ifelse([$1],,:,[$1]) |
| 2665 | ;; |
| 2666 | *) |
| 2667 | AC_MSG_WARN([+----------------------------------------------------------]) |
| 2668 | AC_MSG_WARN([| WARNING WARNING WARNING]) |
| 2669 | AC_MSG_WARN([| Host CPU has the mulx instruction, but it can't be]) |
| 2670 | AC_MSG_WARN([| assembled by]) |
| 2671 | AC_MSG_WARN([| $CCAS $CFLAGS $CPPFLAGS]) |
| 2672 | AC_MSG_WARN([| Older x86 instructions will be used.]) |
| 2673 | AC_MSG_WARN([| This will be an inferior build.]) |
| 2674 | AC_MSG_WARN([+----------------------------------------------------------]) |
| 2675 | ifelse([$2],,:,[$2]) |
| 2676 | ;; |
| 2677 | esac |
| 2678 | ]) |
| 2679 | |
| 2680 | |
| 2681 | dnl GMP_ASM_X86_MCOUNT |
| 2682 | dnl ------------------ |
| 2683 | dnl Find out how to call mcount for profiling on an x86 system. |
| 2684 | dnl |
| 2685 | dnl A dummy function is compiled and the ".s" output examined. The pattern |
| 2686 | dnl matching might be a bit fragile, but should work at least with gcc on |
| 2687 | dnl sensible systems. Certainly it's better than hard coding a table of |
| 2688 | dnl conventions. |
| 2689 | dnl |
| 2690 | dnl For non-PIC, any ".data" is taken to mean a counter might be passed. |
| 2691 | dnl It's assumed a movl will set it up, and the right register is taken |
| 2692 | dnl from that movl. Any movl involving %esp is ignored (a frame pointer |
| 2693 | dnl setup normally). |
| 2694 | dnl |
| 2695 | dnl For PIC, any ".data" is similarly interpreted, but a GOTOFF identifies |
| 2696 | dnl the line setting up the right register. |
| 2697 | dnl |
| 2698 | dnl In both cases a line with "mcount" identifies the call and that line is |
| 2699 | dnl used literally. |
| 2700 | dnl |
| 2701 | dnl On some systems (eg. FreeBSD 3.5) gcc emits ".data" but doesn't use it, |
| 2702 | dnl so it's not an error to have .data but then not find a register. |
| 2703 | dnl |
| 2704 | dnl Variations in mcount conventions on different x86 systems can be found |
| 2705 | dnl in gcc config/i386. mcount can have a "_" prefix or be .mcount or |
| 2706 | dnl _mcount_ptr, and for PIC it can be called through a GOT entry, or via |
| 2707 | dnl the PLT. If a pointer to a counter is required it's passed in %eax or |
| 2708 | dnl %edx. |
| 2709 | dnl |
| 2710 | dnl Flags to specify PIC are taken from $lt_prog_compiler_pic set by |
| 2711 | dnl AC_PROG_LIBTOOL. |
| 2712 | dnl |
| 2713 | dnl Enhancement: Cache the values determined here. But what's the right way |
| 2714 | dnl to get two variables (mcount_nonpic_reg and mcount_nonpic_call say) set |
| 2715 | dnl from one block of commands? |
| 2716 | |
| 2717 | AC_DEFUN([GMP_ASM_X86_MCOUNT], |
| 2718 | [AC_REQUIRE([AC_ENABLE_SHARED]) |
| 2719 | AC_REQUIRE([AC_PROG_LIBTOOL]) |
| 2720 | AC_MSG_CHECKING([how to call x86 mcount]) |
| 2721 | cat >conftest.c <<EOF |
| 2722 | foo(){bar();} |
| 2723 | EOF |
| 2724 | |
| 2725 | if test "$enable_static" = yes; then |
| 2726 | gmp_asmout_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c 1>&AC_FD_CC" |
| 2727 | if AC_TRY_EVAL(gmp_asmout_compile); then |
| 2728 | if grep '\.data' conftest.s >/dev/null; then |
| 2729 | mcount_nonpic_reg=`sed -n ['/esp/!s/.*movl.*,\(%[a-z]*\).*$/\1/p'] conftest.s` |
| 2730 | else |
| 2731 | mcount_nonpic_reg= |
| 2732 | fi |
| 2733 | mcount_nonpic_call=`grep 'call.*mcount' conftest.s` |
| 2734 | if test -z "$mcount_nonpic_call"; then |
| 2735 | AC_MSG_ERROR([Cannot find mcount call for non-PIC]) |
| 2736 | fi |
| 2737 | else |
| 2738 | AC_MSG_ERROR([Cannot compile test program for non-PIC]) |
| 2739 | fi |
| 2740 | fi |
| 2741 | |
| 2742 | if test "$enable_shared" = yes; then |
| 2743 | gmp_asmout_compile="$CC $CFLAGS $CPPFLAGS $lt_prog_compiler_pic -S conftest.c 1>&AC_FD_CC" |
| 2744 | if AC_TRY_EVAL(gmp_asmout_compile); then |
| 2745 | if grep '\.data' conftest.s >/dev/null; then |
| 2746 | case $lt_prog_compiler_pic in |
| 2747 | *-DDLL_EXPORT*) |
| 2748 | # Windows DLLs have non-PIC style mcount |
| 2749 | mcount_pic_reg=`sed -n ['/esp/!s/.*movl.*,\(%[a-z]*\).*$/\1/p'] conftest.s` |
| 2750 | ;; |
| 2751 | *) |
| 2752 | mcount_pic_reg=`sed -n ['s/.*GOTOFF.*,\(%[a-z]*\).*$/\1/p'] conftest.s` |
| 2753 | ;; |
| 2754 | esac |
| 2755 | else |
| 2756 | mcount_pic_reg= |
| 2757 | fi |
| 2758 | mcount_pic_call=`grep 'call.*mcount' conftest.s` |
| 2759 | if test -z "$mcount_pic_call"; then |
| 2760 | AC_MSG_ERROR([Cannot find mcount call for PIC]) |
| 2761 | fi |
| 2762 | else |
| 2763 | AC_MSG_ERROR([Cannot compile test program for PIC]) |
| 2764 | fi |
| 2765 | fi |
| 2766 | |
| 2767 | GMP_DEFINE_RAW(["define(<MCOUNT_NONPIC_REG>, <\`$mcount_nonpic_reg'>)"]) |
| 2768 | GMP_DEFINE_RAW(["define(<MCOUNT_NONPIC_CALL>,<\`$mcount_nonpic_call'>)"]) |
| 2769 | GMP_DEFINE_RAW(["define(<MCOUNT_PIC_REG>, <\`$mcount_pic_reg'>)"]) |
| 2770 | GMP_DEFINE_RAW(["define(<MCOUNT_PIC_CALL>, <\`$mcount_pic_call'>)"]) |
| 2771 | |
| 2772 | rm -f conftest.* |
| 2773 | AC_MSG_RESULT([determined]) |
| 2774 | ]) |
| 2775 | |
| 2776 | |
| 2777 | dnl GMP_ASM_IA64_ALIGN_OK |
| 2778 | dnl --------------------- |
| 2779 | dnl Determine whether .align correctly pads with nop instructions in a text |
| 2780 | dnl segment. |
| 2781 | dnl |
| 2782 | dnl gas 2.14 and earlier byte swaps its padding bundle on big endian |
| 2783 | dnl systems, which is incorrect (endianness only changes data). What |
| 2784 | dnl should be "nop.m / nop.f / nop.i" comes out as "break" instructions. |
| 2785 | dnl |
| 2786 | dnl The test here detects the bad case, and assumes anything else is ok |
| 2787 | dnl (there are many sensible nop bundles, so it'd be impractical to try to |
| 2788 | dnl match everything good). |
| 2789 | |
| 2790 | AC_DEFUN([GMP_ASM_IA64_ALIGN_OK], |
| 2791 | [AC_CACHE_CHECK([whether assembler .align padding is good], |
| 2792 | gmp_cv_asm_ia64_align_ok, |
| 2793 | [cat >conftest.awk <<\EOF |
| 2794 | [BEGIN { |
| 2795 | want[0] = "011" |
| 2796 | want[1] = "160" |
| 2797 | want[2] = "074" |
| 2798 | want[3] = "040" |
| 2799 | want[4] = "000" |
| 2800 | want[5] = "040" |
| 2801 | want[6] = "020" |
| 2802 | want[7] = "221" |
| 2803 | want[8] = "114" |
| 2804 | want[9] = "000" |
| 2805 | want[10] = "100" |
| 2806 | want[11] = "200" |
| 2807 | want[12] = "122" |
| 2808 | want[13] = "261" |
| 2809 | want[14] = "000" |
| 2810 | want[15] = "200" |
| 2811 | |
| 2812 | want[16] = "000" |
| 2813 | want[17] = "004" |
| 2814 | want[18] = "000" |
| 2815 | want[19] = "000" |
| 2816 | want[20] = "000" |
| 2817 | want[21] = "000" |
| 2818 | want[22] = "002" |
| 2819 | want[23] = "000" |
| 2820 | want[24] = "000" |
| 2821 | want[25] = "000" |
| 2822 | want[26] = "000" |
| 2823 | want[27] = "001" |
| 2824 | want[28] = "000" |
| 2825 | want[29] = "000" |
| 2826 | want[30] = "000" |
| 2827 | want[31] = "014" |
| 2828 | |
| 2829 | want[32] = "011" |
| 2830 | want[33] = "270" |
| 2831 | want[34] = "140" |
| 2832 | want[35] = "062" |
| 2833 | want[36] = "000" |
| 2834 | want[37] = "040" |
| 2835 | want[38] = "240" |
| 2836 | want[39] = "331" |
| 2837 | want[40] = "160" |
| 2838 | want[41] = "000" |
| 2839 | want[42] = "100" |
| 2840 | want[43] = "240" |
| 2841 | want[44] = "343" |
| 2842 | want[45] = "371" |
| 2843 | want[46] = "000" |
| 2844 | want[47] = "200" |
| 2845 | |
| 2846 | result = "yes" |
| 2847 | } |
| 2848 | { |
| 2849 | for (f = 2; f <= NF; f++) |
| 2850 | { |
| 2851 | for (i = 0; i < 47; i++) |
| 2852 | got[i] = got[i+1]; |
| 2853 | got[47] = $f; |
| 2854 | |
| 2855 | found = 1 |
| 2856 | for (i = 0; i < 48; i++) |
| 2857 | if (got[i] != want[i]) |
| 2858 | { |
| 2859 | found = 0 |
| 2860 | break |
| 2861 | } |
| 2862 | if (found) |
| 2863 | { |
| 2864 | result = "no" |
| 2865 | exit |
| 2866 | } |
| 2867 | } |
| 2868 | } |
| 2869 | END { |
| 2870 | print result |
| 2871 | } |
| 2872 | ]EOF |
| 2873 | GMP_TRY_ASSEMBLE( |
| 2874 | [ .text |
| 2875 | .align 32 |
| 2876 | { .mmi; add r14 = r15, r16 |
| 2877 | add r17 = r18, r19 |
| 2878 | add r20 = r21, r22 ;; } |
| 2879 | .align 32 |
| 2880 | { .mmi; add r23 = r24, r25 |
| 2881 | add r26 = r27, r28 |
| 2882 | add r29 = r30, r31 ;; } |
| 2883 | ], |
| 2884 | [gmp_cv_asm_ia64_align_ok=`od -b conftest.$OBJEXT | $AWK -f conftest.awk`], |
| 2885 | [AC_MSG_WARN([oops, cannot compile test program]) |
| 2886 | gmp_cv_asm_ia64_align_ok=yes]) |
| 2887 | ]) |
| 2888 | GMP_DEFINE_RAW(["define(<IA64_ALIGN_OK>, <\`$gmp_cv_asm_ia64_align_ok'>)"]) |
| 2889 | ]) |
| 2890 | |
| 2891 | |
| 2892 | |
| 2893 | |
| 2894 | dnl GMP_ASM_M68K_INSTRUCTION |
| 2895 | dnl ------------------------ |
| 2896 | dnl Not sure if ".l" and "%" are independent settings, but it doesn't hurt |
| 2897 | dnl to try all four possibilities. Note that the % ones must be first, so |
| 2898 | dnl "d0" won't be interpreted as a label. |
| 2899 | dnl |
| 2900 | dnl gas 1.92.3 on NetBSD 1.4 needs to be tested with a two operand |
| 2901 | dnl instruction. It takes registers without "%", but a single operand |
| 2902 | dnl "clrl %d0" only gives a warning, not an error. |
| 2903 | |
| 2904 | AC_DEFUN([GMP_ASM_M68K_INSTRUCTION], |
| 2905 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 2906 | AC_CACHE_CHECK([assembler instruction and register style], |
| 2907 | gmp_cv_asm_m68k_instruction, |
| 2908 | [for i in "addl %d0,%d1" "add.l %d0,%d1" "addl d0,d1" "add.l d0,d1"; do |
| 2909 | GMP_TRY_ASSEMBLE( |
| 2910 | [ $gmp_cv_asm_text |
| 2911 | $i], |
| 2912 | [gmp_cv_asm_m68k_instruction=$i |
| 2913 | rm -f conftest* |
| 2914 | break]) |
| 2915 | done |
| 2916 | if test -z "$gmp_cv_asm_m68k_instruction"; then |
| 2917 | AC_MSG_ERROR([cannot determine assembler instruction and register style]) |
| 2918 | fi |
| 2919 | ]) |
| 2920 | case $gmp_cv_asm_m68k_instruction in |
| 2921 | "addl d0,d1") want_dot_size=no; want_register_percent=no ;; |
| 2922 | "addl %d0,%d1") want_dot_size=no; want_register_percent=yes ;; |
| 2923 | "add.l d0,d1") want_dot_size=yes; want_register_percent=no ;; |
| 2924 | "add.l %d0,%d1") want_dot_size=yes; want_register_percent=yes ;; |
| 2925 | *) AC_MSG_ERROR([oops, unrecognised instruction and register style]) ;; |
| 2926 | esac |
| 2927 | GMP_DEFINE_RAW(["define(<WANT_REGISTER_PERCENT>, <\`$want_register_percent'>)"]) |
| 2928 | GMP_DEFINE_RAW(["define(<WANT_DOT_SIZE>, <\`$want_dot_size'>)"]) |
| 2929 | ]) |
| 2930 | |
| 2931 | |
| 2932 | dnl GMP_ASM_M68K_ADDRESSING |
| 2933 | dnl ----------------------- |
| 2934 | |
| 2935 | AC_DEFUN([GMP_ASM_M68K_ADDRESSING], |
| 2936 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 2937 | AC_REQUIRE([GMP_ASM_M68K_INSTRUCTION]) |
| 2938 | AC_CACHE_CHECK([assembler addressing style], |
| 2939 | gmp_cv_asm_m68k_addressing, |
| 2940 | [case $gmp_cv_asm_m68k_instruction in |
| 2941 | addl*) movel=movel ;; |
| 2942 | add.l*) movel=move.l ;; |
| 2943 | *) AC_MSG_ERROR([oops, unrecognised gmp_cv_asm_m68k_instruction]) ;; |
| 2944 | esac |
| 2945 | case $gmp_cv_asm_m68k_instruction in |
| 2946 | *"%d0,%d1") dreg=%d0; areg=%a0 ;; |
| 2947 | *"d0,d1") dreg=d0; areg=a0 ;; |
| 2948 | *) AC_MSG_ERROR([oops, unrecognised gmp_cv_asm_m68k_instruction]) ;; |
| 2949 | esac |
| 2950 | GMP_TRY_ASSEMBLE( |
| 2951 | [ $gmp_cv_asm_text |
| 2952 | $movel $dreg, $areg@-], |
| 2953 | [gmp_cv_asm_m68k_addressing=mit], |
| 2954 | [GMP_TRY_ASSEMBLE( |
| 2955 | [ $gmp_cv_asm_text |
| 2956 | $movel $dreg, -($areg)], |
| 2957 | [gmp_cv_asm_m68k_addressing=motorola], |
| 2958 | [AC_MSG_ERROR([cannot determine assembler addressing style])])]) |
| 2959 | ]) |
| 2960 | GMP_DEFINE_RAW(["define(<WANT_ADDRESSING>, <\`$gmp_cv_asm_m68k_addressing'>)"]) |
| 2961 | ]) |
| 2962 | |
| 2963 | |
| 2964 | dnl GMP_ASM_M68K_BRANCHES |
| 2965 | dnl --------------------- |
| 2966 | dnl "bra" is the standard branch instruction. "jra" or "jbra" are |
| 2967 | dnl preferred where available, since on gas for instance they give a |
| 2968 | dnl displacement only as big as it needs to be, whereas "bra" is always |
| 2969 | dnl 16-bits. This applies to the conditional branches "bcc" etc too. |
| 2970 | dnl However "dbcc" etc on gas are already only as big as they need to be. |
| 2971 | |
| 2972 | AC_DEFUN([GMP_ASM_M68K_BRANCHES], |
| 2973 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 2974 | AC_CACHE_CHECK([assembler shortest branches], |
| 2975 | gmp_cv_asm_m68k_branches, |
| 2976 | [for i in jra jbra bra; do |
| 2977 | GMP_TRY_ASSEMBLE( |
| 2978 | [ $gmp_cv_asm_text |
| 2979 | foo$gmp_cv_asm_label_suffix |
| 2980 | $i foo], |
| 2981 | [gmp_cv_asm_m68k_branches=$i |
| 2982 | rm -f conftest* |
| 2983 | break]) |
| 2984 | done |
| 2985 | if test -z "$gmp_cv_asm_m68k_branches"; then |
| 2986 | AC_MSG_ERROR([cannot determine assembler branching style]) |
| 2987 | fi |
| 2988 | ]) |
| 2989 | GMP_DEFINE_RAW(["define(<WANT_BRANCHES>, <\`$gmp_cv_asm_m68k_branches'>)"]) |
| 2990 | ]) |
| 2991 | |
| 2992 | |
| 2993 | dnl GMP_ASM_POWERPC_PIC_ALWAYS |
| 2994 | dnl -------------------------- |
| 2995 | dnl Determine whether PIC is the default compiler output. |
| 2996 | dnl |
| 2997 | dnl SVR4 style "foo@ha" addressing is interpreted as non-PIC, and anything |
| 2998 | dnl else is assumed to require PIC always (Darwin or AIX). SVR4 is the |
| 2999 | dnl only non-PIC addressing syntax the asm files have at the moment anyway. |
| 3000 | dnl |
| 3001 | dnl Libtool does this by taking "*-*-aix* | *-*-darwin* | *-*-rhapsody*" to |
| 3002 | dnl mean PIC always, but it seems more reliable to grep the compiler |
| 3003 | dnl output. |
| 3004 | dnl |
| 3005 | dnl The next paragraph is untrue for Tiger. Was it ever true? For tiger, |
| 3006 | dnl "cc -fast" makes non-PIC the default (and the binaries do run). |
| 3007 | dnl On Darwin "cc -static" is non-PIC with syntax "ha16(_foo)", but that's |
| 3008 | dnl apparently only for use in the kernel, which we're not attempting to |
| 3009 | dnl target at the moment, so don't look for that. |
| 3010 | |
| 3011 | AC_DEFUN([GMP_ASM_POWERPC_PIC_ALWAYS], |
| 3012 | [AC_REQUIRE([AC_PROG_CC]) |
| 3013 | AC_CACHE_CHECK([whether compiler output is PIC by default], |
| 3014 | gmp_cv_asm_powerpc_pic, |
| 3015 | [gmp_cv_asm_powerpc_pic=yes |
| 3016 | cat >conftest.c <<EOF |
| 3017 | int foo; |
| 3018 | int *bar() { return &foo; } |
| 3019 | EOF |
| 3020 | echo "Test program:" >&AC_FD_CC |
| 3021 | cat conftest.c >&AC_FD_CC |
| 3022 | gmp_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c >&AC_FD_CC" |
| 3023 | if AC_TRY_EVAL(gmp_compile); then |
| 3024 | echo "Compiler output:" >&AC_FD_CC |
| 3025 | cat conftest.s >&AC_FD_CC |
| 3026 | if grep 'foo@ha' conftest.s >/dev/null 2>&AC_FD_CC; then |
| 3027 | gmp_cv_asm_powerpc_pic=no |
| 3028 | fi |
| 3029 | if grep 'ha16(_foo)' conftest.s >/dev/null 2>&AC_FD_CC; then |
| 3030 | gmp_cv_asm_powerpc_pic=no |
| 3031 | fi |
| 3032 | fi |
| 3033 | rm -f conftest* |
| 3034 | ]) |
| 3035 | GMP_DEFINE_RAW(["define(<PIC_ALWAYS>,<$gmp_cv_asm_powerpc_pic>)"]) |
| 3036 | ]) |
| 3037 | |
| 3038 | |
| 3039 | dnl GMP_ASM_POWERPC_R_REGISTERS |
| 3040 | dnl --------------------------- |
| 3041 | dnl Determine whether the assembler takes powerpc registers with an "r" as |
| 3042 | dnl in "r6", or as plain "6". The latter is standard, but NeXT, Rhapsody, |
| 3043 | dnl and MacOS-X require the "r" forms. |
| 3044 | dnl |
| 3045 | dnl See also mpn/powerpc32/powerpc-defs.m4 which uses the result of this |
| 3046 | dnl test. |
| 3047 | |
| 3048 | AC_DEFUN([GMP_ASM_POWERPC_R_REGISTERS], |
| 3049 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 3050 | AC_CACHE_CHECK([if the assembler needs r on registers], |
| 3051 | gmp_cv_asm_powerpc_r_registers, |
| 3052 | [GMP_TRY_ASSEMBLE( |
| 3053 | [ $gmp_cv_asm_text |
| 3054 | mtctr 6], |
| 3055 | [gmp_cv_asm_powerpc_r_registers=no], |
| 3056 | [GMP_TRY_ASSEMBLE( |
| 3057 | [ $gmp_cv_asm_text |
| 3058 | mtctr r6], |
| 3059 | [gmp_cv_asm_powerpc_r_registers=yes], |
| 3060 | [AC_MSG_ERROR([neither "mtctr 6" nor "mtctr r6" works])])])]) |
| 3061 | |
| 3062 | GMP_DEFINE_RAW(["define(<WANT_R_REGISTERS>,<$gmp_cv_asm_powerpc_r_registers>)"]) |
| 3063 | ]) |
| 3064 | |
| 3065 | |
| 3066 | dnl GMP_ASM_SPARC_REGISTER |
| 3067 | dnl ---------------------- |
| 3068 | dnl Determine whether the assembler accepts the ".register" directive. |
| 3069 | dnl Old versions of solaris "as" don't. |
| 3070 | dnl |
| 3071 | dnl See also mpn/sparc32/sparc-defs.m4 which uses the result of this test. |
| 3072 | |
| 3073 | AC_DEFUN([GMP_ASM_SPARC_REGISTER], |
| 3074 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 3075 | AC_CACHE_CHECK([if the assembler accepts ".register"], |
| 3076 | gmp_cv_asm_sparc_register, |
| 3077 | [GMP_TRY_ASSEMBLE( |
| 3078 | [ $gmp_cv_asm_text |
| 3079 | .register %g2,#scratch |
| 3080 | ], |
| 3081 | [gmp_cv_asm_sparc_register=yes], |
| 3082 | [gmp_cv_asm_sparc_register=no])]) |
| 3083 | |
| 3084 | GMP_DEFINE_RAW(["define(<HAVE_REGISTER>,<$gmp_cv_asm_sparc_register>)"]) |
| 3085 | ]) |
| 3086 | |
| 3087 | |
| 3088 | dnl GMP_ASM_SPARC_GOTDATA |
| 3089 | dnl ---------------------- |
| 3090 | dnl Determine whether the assembler accepts gotdata relocations. |
| 3091 | dnl |
| 3092 | dnl See also mpn/sparc32/sparc-defs.m4 which uses the result of this test. |
| 3093 | |
| 3094 | AC_DEFUN([GMP_ASM_SPARC_GOTDATA], |
| 3095 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 3096 | AC_CACHE_CHECK([if the assembler accepts gotdata relocations], |
| 3097 | gmp_cv_asm_sparc_gotdata, |
| 3098 | [GMP_TRY_ASSEMBLE( |
| 3099 | [ $gmp_cv_asm_text |
| 3100 | .text |
| 3101 | sethi %gdop_hix22(symbol), %g1 |
| 3102 | or %g1, %gdop_lox10(symbol), %g1 |
| 3103 | ], |
| 3104 | [gmp_cv_asm_sparc_gotdata=yes], |
| 3105 | [gmp_cv_asm_sparc_gotdata=no])]) |
| 3106 | |
| 3107 | GMP_DEFINE_RAW(["define(<HAVE_GOTDATA>,<$gmp_cv_asm_sparc_gotdata>)"]) |
| 3108 | ]) |
| 3109 | |
| 3110 | |
| 3111 | dnl GMP_ASM_SPARC_SHARED_THUNKS |
| 3112 | dnl ---------------------- |
| 3113 | dnl Determine whether the assembler supports all of the features |
| 3114 | dnl necessary in order to emit shared PIC thunks on sparc. |
| 3115 | dnl |
| 3116 | dnl See also mpn/sparc32/sparc-defs.m4 which uses the result of this test. |
| 3117 | |
| 3118 | AC_DEFUN([GMP_ASM_SPARC_SHARED_THUNKS], |
| 3119 | [AC_REQUIRE([GMP_ASM_TEXT]) |
| 3120 | AC_CACHE_CHECK([if the assembler can support shared PIC thunks], |
| 3121 | gmp_cv_asm_sparc_shared_thunks, |
| 3122 | [GMP_TRY_ASSEMBLE( |
| 3123 | [ $gmp_cv_asm_text |
| 3124 | .section .text.__sparc_get_pc_thunk.l7,"axG",@progbits,__sparc_get_pc_thunk.l7,comdat |
| 3125 | .weak __sparc_get_pc_thunk.l7 |
| 3126 | .hidden __sparc_get_pc_thunk.l7 |
| 3127 | .type __sparc_get_pc_thunk.l7, #function |
| 3128 | __sparc_get_pc_thunk.l7: |
| 3129 | jmp %o7+8 |
| 3130 | add %o7, %l7, %l7 |
| 3131 | ], |
| 3132 | [gmp_cv_asm_sparc_shared_thunks=yes], |
| 3133 | [gmp_cv_asm_sparc_shared_thunks=no])]) |
| 3134 | |
| 3135 | GMP_DEFINE_RAW(["define(<HAVE_SHARED_THUNKS>,<$gmp_cv_asm_sparc_shared_thunks>)"]) |
| 3136 | ]) |
| 3137 | |
| 3138 | |
| 3139 | dnl GMP_C_ATTRIBUTE_CONST |
| 3140 | dnl --------------------- |
| 3141 | |
| 3142 | AC_DEFUN([GMP_C_ATTRIBUTE_CONST], |
| 3143 | [AC_CACHE_CHECK([whether gcc __attribute__ ((const)) works], |
| 3144 | gmp_cv_c_attribute_const, |
| 3145 | [AC_TRY_COMPILE([int foo (int x) __attribute__ ((const));], , |
| 3146 | gmp_cv_c_attribute_const=yes, gmp_cv_c_attribute_const=no) |
| 3147 | ]) |
| 3148 | if test $gmp_cv_c_attribute_const = yes; then |
| 3149 | AC_DEFINE(HAVE_ATTRIBUTE_CONST, 1, |
| 3150 | [Define to 1 if the compiler accepts gcc style __attribute__ ((const))]) |
| 3151 | fi |
| 3152 | ]) |
| 3153 | |
| 3154 | |
| 3155 | dnl GMP_C_ATTRIBUTE_MALLOC |
| 3156 | dnl ---------------------- |
| 3157 | dnl gcc 2.95.x accepts __attribute__ ((malloc)) but with a warning that |
| 3158 | dnl it's ignored. Pretend it doesn't exist in this case, to avoid that |
| 3159 | dnl warning. |
| 3160 | |
| 3161 | AC_DEFUN([GMP_C_ATTRIBUTE_MALLOC], |
| 3162 | [AC_CACHE_CHECK([whether gcc __attribute__ ((malloc)) works], |
| 3163 | gmp_cv_c_attribute_malloc, |
| 3164 | [cat >conftest.c <<EOF |
| 3165 | void *foo (int x) __attribute__ ((malloc)); |
| 3166 | EOF |
| 3167 | gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >conftest.out 2>&1" |
| 3168 | if AC_TRY_EVAL(gmp_compile); then |
| 3169 | if grep "attribute directive ignored" conftest.out >/dev/null; then |
| 3170 | gmp_cv_c_attribute_malloc=no |
| 3171 | else |
| 3172 | gmp_cv_c_attribute_malloc=yes |
| 3173 | fi |
| 3174 | else |
| 3175 | gmp_cv_c_attribute_malloc=no |
| 3176 | fi |
| 3177 | cat conftest.out >&AC_FD_CC |
| 3178 | rm -f conftest* |
| 3179 | ]) |
| 3180 | if test $gmp_cv_c_attribute_malloc = yes; then |
| 3181 | AC_DEFINE(HAVE_ATTRIBUTE_MALLOC, 1, |
| 3182 | [Define to 1 if the compiler accepts gcc style __attribute__ ((malloc))]) |
| 3183 | fi |
| 3184 | ]) |
| 3185 | |
| 3186 | |
| 3187 | dnl GMP_C_ATTRIBUTE_MODE |
| 3188 | dnl -------------------- |
| 3189 | dnl Introduced in gcc 2.2, but perhaps not in all Apple derived versions. |
| 3190 | |
| 3191 | AC_DEFUN([GMP_C_ATTRIBUTE_MODE], |
| 3192 | [AC_CACHE_CHECK([whether gcc __attribute__ ((mode (XX))) works], |
| 3193 | gmp_cv_c_attribute_mode, |
| 3194 | [AC_TRY_COMPILE([typedef int SItype __attribute__ ((mode (SI)));], , |
| 3195 | gmp_cv_c_attribute_mode=yes, gmp_cv_c_attribute_mode=no) |
| 3196 | ]) |
| 3197 | if test $gmp_cv_c_attribute_mode = yes; then |
| 3198 | AC_DEFINE(HAVE_ATTRIBUTE_MODE, 1, |
| 3199 | [Define to 1 if the compiler accepts gcc style __attribute__ ((mode (XX)))]) |
| 3200 | fi |
| 3201 | ]) |
| 3202 | |
| 3203 | |
| 3204 | dnl GMP_C_ATTRIBUTE_NORETURN |
| 3205 | dnl ------------------------ |
| 3206 | |
| 3207 | AC_DEFUN([GMP_C_ATTRIBUTE_NORETURN], |
| 3208 | [AC_CACHE_CHECK([whether gcc __attribute__ ((noreturn)) works], |
| 3209 | gmp_cv_c_attribute_noreturn, |
| 3210 | [AC_TRY_COMPILE([void foo (int x) __attribute__ ((noreturn));], , |
| 3211 | gmp_cv_c_attribute_noreturn=yes, gmp_cv_c_attribute_noreturn=no) |
| 3212 | ]) |
| 3213 | if test $gmp_cv_c_attribute_noreturn = yes; then |
| 3214 | AC_DEFINE(HAVE_ATTRIBUTE_NORETURN, 1, |
| 3215 | [Define to 1 if the compiler accepts gcc style __attribute__ ((noreturn))]) |
| 3216 | fi |
| 3217 | ]) |
| 3218 | |
| 3219 | dnl GMP_C_HIDDEN_ALIAS |
| 3220 | dnl ------------------------ |
| 3221 | |
| 3222 | AC_DEFUN([GMP_C_HIDDEN_ALIAS], |
| 3223 | [AC_CACHE_CHECK([whether gcc hidden aliases work], |
| 3224 | gmp_cv_c_hidden_alias, |
| 3225 | [AC_TRY_COMPILE( |
| 3226 | [void hid() __attribute__ ((visibility("hidden"))); |
| 3227 | void hid() {} |
| 3228 | void pub() __attribute__ ((alias("hid")));], |
| 3229 | , gmp_cv_c_hidden_alias=yes, gmp_cv_c_hidden_alias=no) |
| 3230 | ]) |
| 3231 | if test $gmp_cv_c_hidden_alias = yes; then |
| 3232 | AC_DEFINE(HAVE_HIDDEN_ALIAS, 1, |
| 3233 | [Define to 1 if the compiler accepts gcc style __attribute__ ((visibility)) |
| 3234 | and __attribute__ ((alias))]) |
| 3235 | fi |
| 3236 | ]) |
| 3237 | |
| 3238 | dnl GMP_C_DOUBLE_FORMAT |
| 3239 | dnl ------------------- |
| 3240 | dnl Determine the floating point format. |
| 3241 | dnl |
| 3242 | dnl The object file is grepped, in order to work when cross compiling. A |
| 3243 | dnl start and end sequence is included to avoid false matches, and allowance |
| 3244 | dnl is made for the desired data crossing an "od -b" line boundary. The test |
| 3245 | dnl number is a small integer so it should appear exactly, no rounding or |
| 3246 | dnl truncation etc. |
| 3247 | dnl |
| 3248 | dnl "od -b", incidentally, is supported even by Unix V7, and the awk script |
| 3249 | dnl used doesn't have functions or anything, so even an "old" awk should |
| 3250 | dnl suffice. |
| 3251 | dnl |
| 3252 | dnl The C code here declares the variable foo as extern; without that, some |
| 3253 | dnl C++ compilers will not put foo in the object file. |
| 3254 | |
| 3255 | AC_DEFUN([GMP_C_DOUBLE_FORMAT], |
| 3256 | [AC_REQUIRE([AC_PROG_CC]) |
| 3257 | AC_REQUIRE([AC_PROG_AWK]) |
| 3258 | AC_CACHE_CHECK([format of `double' floating point], |
| 3259 | gmp_cv_c_double_format, |
| 3260 | [gmp_cv_c_double_format=unknown |
| 3261 | cat >conftest.c <<\EOF |
| 3262 | [#include <stdio.h> |
| 3263 | struct foo { |
| 3264 | char before[8]; |
| 3265 | double x; |
| 3266 | char after[8]; |
| 3267 | }; |
| 3268 | extern struct foo foo; |
| 3269 | struct foo foo = { |
| 3270 | { '\001', '\043', '\105', '\147', '\211', '\253', '\315', '\357' }, |
| 3271 | -123456789.0, |
| 3272 | { '\376', '\334', '\272', '\230', '\166', '\124', '\062', '\020' }, |
| 3273 | }; |
| 3274 | int main(){ |
| 3275 | int i; |
| 3276 | for (i = 0; i < 8; i++) { |
| 3277 | printf ("%d %f\n", foo.before[i] + foo.after[i], foo.x); |
| 3278 | } |
| 3279 | return 0; |
| 3280 | }] |
| 3281 | EOF |
| 3282 | gmp_compile="$CC $CFLAGS $CPPFLAGS conftest.c -o conftest$EXEEXT >&AC_FD_CC 2>&1" |
| 3283 | if AC_TRY_EVAL(gmp_compile); then |
| 3284 | cat >conftest.awk <<\EOF |
| 3285 | [ |
| 3286 | BEGIN { |
| 3287 | found = 0 |
| 3288 | } |
| 3289 | |
| 3290 | { |
| 3291 | for (f = 2; f <= NF; f++) |
| 3292 | { |
| 3293 | for (i = 0; i < 23; i++) |
| 3294 | got[i] = got[i+1]; |
| 3295 | got[23] = $f; |
| 3296 | |
| 3297 | # match the special begin and end sequences |
| 3298 | if (got[0] != "001") continue |
| 3299 | if (got[1] != "043") continue |
| 3300 | if (got[2] != "105") continue |
| 3301 | if (got[3] != "147") continue |
| 3302 | if (got[4] != "211") continue |
| 3303 | if (got[5] != "253") continue |
| 3304 | if (got[6] != "315") continue |
| 3305 | if (got[7] != "357") continue |
| 3306 | if (got[16] != "376") continue |
| 3307 | if (got[17] != "334") continue |
| 3308 | if (got[18] != "272") continue |
| 3309 | if (got[19] != "230") continue |
| 3310 | if (got[20] != "166") continue |
| 3311 | if (got[21] != "124") continue |
| 3312 | if (got[22] != "062") continue |
| 3313 | if (got[23] != "020") continue |
| 3314 | |
| 3315 | saw = " (" got[8] " " got[9] " " got[10] " " got[11] " " got[12] " " got[13] " " got[14] " " got[15] ")" |
| 3316 | |
| 3317 | if (got[8] == "000" && \ |
| 3318 | got[9] == "000" && \ |
| 3319 | got[10] == "000" && \ |
| 3320 | got[11] == "124" && \ |
| 3321 | got[12] == "064" && \ |
| 3322 | got[13] == "157" && \ |
| 3323 | got[14] == "235" && \ |
| 3324 | got[15] == "301") |
| 3325 | { |
| 3326 | print "IEEE little endian" |
| 3327 | found = 1 |
| 3328 | exit |
| 3329 | } |
| 3330 | |
| 3331 | # Little endian with the two 4-byte halves swapped, as used by ARM |
| 3332 | # when the chip is in little endian mode. |
| 3333 | # |
| 3334 | if (got[8] == "064" && \ |
| 3335 | got[9] == "157" && \ |
| 3336 | got[10] == "235" && \ |
| 3337 | got[11] == "301" && \ |
| 3338 | got[12] == "000" && \ |
| 3339 | got[13] == "000" && \ |
| 3340 | got[14] == "000" && \ |
| 3341 | got[15] == "124") |
| 3342 | { |
| 3343 | print "IEEE little endian, swapped halves" |
| 3344 | found = 1 |
| 3345 | exit |
| 3346 | } |
| 3347 | |
| 3348 | # gcc 2.95.4 on one GNU/Linux ARM system was seen generating 000 in |
| 3349 | # the last byte, whereas 124 is correct. Not sure where the bug |
| 3350 | # actually lies, but a running program didn't seem to get a full |
| 3351 | # mantissa worth of working bits. |
| 3352 | # |
| 3353 | # We match this case explicitly so we can give a nice result message, |
| 3354 | # but we deliberately exclude it from the normal IEEE double setups |
| 3355 | # since it's too broken. |
| 3356 | # |
| 3357 | if (got[8] == "064" && \ |
| 3358 | got[9] == "157" && \ |
| 3359 | got[10] == "235" && \ |
| 3360 | got[11] == "301" && \ |
| 3361 | got[12] == "000" && \ |
| 3362 | got[13] == "000" && \ |
| 3363 | got[14] == "000" && \ |
| 3364 | got[15] == "000") |
| 3365 | { |
| 3366 | print "bad ARM software floats" |
| 3367 | found = 1 |
| 3368 | exit |
| 3369 | } |
| 3370 | |
| 3371 | if (got[8] == "301" && \ |
| 3372 | got[9] == "235" && \ |
| 3373 | got[10] == "157" && \ |
| 3374 | got[11] == "064" && \ |
| 3375 | got[12] == "124" && \ |
| 3376 | got[13] == "000" && \ |
| 3377 | got[14] == "000" && \ |
| 3378 | got[15] == "000") |
| 3379 | { |
| 3380 | print "IEEE big endian" |
| 3381 | found = 1 |
| 3382 | exit |
| 3383 | } |
| 3384 | |
| 3385 | if (got[8] == "353" && \ |
| 3386 | got[9] == "315" && \ |
| 3387 | got[10] == "242" && \ |
| 3388 | got[11] == "171" && \ |
| 3389 | got[12] == "000" && \ |
| 3390 | got[13] == "240" && \ |
| 3391 | got[14] == "000" && \ |
| 3392 | got[15] == "000") |
| 3393 | { |
| 3394 | print "VAX D" |
| 3395 | found = 1 |
| 3396 | exit |
| 3397 | } |
| 3398 | |
| 3399 | if (got[8] == "275" && \ |
| 3400 | got[9] == "301" && \ |
| 3401 | got[10] == "064" && \ |
| 3402 | got[11] == "157" && \ |
| 3403 | got[12] == "000" && \ |
| 3404 | got[13] == "124" && \ |
| 3405 | got[14] == "000" && \ |
| 3406 | got[15] == "000") |
| 3407 | { |
| 3408 | print "VAX G" |
| 3409 | found = 1 |
| 3410 | exit |
| 3411 | } |
| 3412 | |
| 3413 | if (got[8] == "300" && \ |
| 3414 | got[9] == "033" && \ |
| 3415 | got[10] == "353" && \ |
| 3416 | got[11] == "171" && \ |
| 3417 | got[12] == "242" && \ |
| 3418 | got[13] == "240" && \ |
| 3419 | got[14] == "000" && \ |
| 3420 | got[15] == "000") |
| 3421 | { |
| 3422 | print "Cray CFP" |
| 3423 | found = 1 |
| 3424 | exit |
| 3425 | } |
| 3426 | } |
| 3427 | } |
| 3428 | |
| 3429 | END { |
| 3430 | if (! found) |
| 3431 | print "unknown", saw |
| 3432 | } |
| 3433 | ] |
| 3434 | EOF |
| 3435 | gmp_cv_c_double_format=`od -b conftest$EXEEXT | $AWK -f conftest.awk` |
| 3436 | case $gmp_cv_c_double_format in |
| 3437 | unknown*) |
| 3438 | echo "cannot match anything, conftest$EXEEXT contains" >&AC_FD_CC |
| 3439 | od -b conftest$EXEEXT >&AC_FD_CC |
| 3440 | ;; |
| 3441 | esac |
| 3442 | else |
| 3443 | AC_MSG_WARN([oops, cannot compile test program]) |
| 3444 | fi |
| 3445 | rm -f conftest* |
| 3446 | ]) |
| 3447 | |
| 3448 | AH_VERBATIM([HAVE_DOUBLE], |
| 3449 | [/* Define one of the following to 1 for the format of a `double'. |
| 3450 | If your format is not among these choices, or you don't know what it is, |
| 3451 | then leave all undefined. |
| 3452 | IEEE_LITTLE_SWAPPED means little endian, but with the two 4-byte halves |
| 3453 | swapped, as used by ARM CPUs in little endian mode. */ |
| 3454 | #undef HAVE_DOUBLE_IEEE_BIG_ENDIAN |
| 3455 | #undef HAVE_DOUBLE_IEEE_LITTLE_ENDIAN |
| 3456 | #undef HAVE_DOUBLE_IEEE_LITTLE_SWAPPED |
| 3457 | #undef HAVE_DOUBLE_VAX_D |
| 3458 | #undef HAVE_DOUBLE_VAX_G |
| 3459 | #undef HAVE_DOUBLE_CRAY_CFP]) |
| 3460 | |
| 3461 | case $gmp_cv_c_double_format in |
| 3462 | "IEEE big endian") |
| 3463 | AC_DEFINE(HAVE_DOUBLE_IEEE_BIG_ENDIAN, 1) |
| 3464 | GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_DOUBLE_IEEE_BIG_ENDIAN')", POST) |
| 3465 | ;; |
| 3466 | "IEEE little endian") |
| 3467 | AC_DEFINE(HAVE_DOUBLE_IEEE_LITTLE_ENDIAN, 1) |
| 3468 | GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_DOUBLE_IEEE_LITTLE_ENDIAN')", POST) |
| 3469 | ;; |
| 3470 | "IEEE little endian, swapped halves") |
| 3471 | AC_DEFINE(HAVE_DOUBLE_IEEE_LITTLE_SWAPPED, 1) ;; |
| 3472 | "VAX D") |
| 3473 | AC_DEFINE(HAVE_DOUBLE_VAX_D, 1) ;; |
| 3474 | "VAX G") |
| 3475 | AC_DEFINE(HAVE_DOUBLE_VAX_G, 1) ;; |
| 3476 | "Cray CFP") |
| 3477 | AC_DEFINE(HAVE_DOUBLE_CRAY_CFP, 1) ;; |
| 3478 | "bad ARM software floats") |
| 3479 | ;; |
| 3480 | unknown*) |
| 3481 | AC_MSG_WARN([Could not determine float format.]) |
| 3482 | AC_MSG_WARN([Conversions to and from "double" may be slow.]) |
| 3483 | ;; |
| 3484 | *) |
| 3485 | AC_MSG_WARN([oops, unrecognised float format: $gmp_cv_c_double_format]) |
| 3486 | ;; |
| 3487 | esac |
| 3488 | ]) |
| 3489 | |
| 3490 | |
| 3491 | dnl GMP_C_STDARG |
| 3492 | dnl ------------ |
| 3493 | dnl Test whether to use <stdarg.h>. |
| 3494 | dnl |
| 3495 | dnl Notice the AC_DEFINE here is HAVE_STDARG to avoid clashing with |
| 3496 | dnl HAVE_STDARG_H which could arise from AC_CHECK_HEADERS. |
| 3497 | dnl |
| 3498 | dnl This test might be slight overkill, after all there's really only going |
| 3499 | dnl to be ANSI or K&R and the two can be differentiated by AC_PROG_CC_STDC |
| 3500 | dnl or very likely by the setups for _PROTO in gmp.h. On the other hand |
| 3501 | dnl this test is nice and direct, being what we're going to actually use. |
| 3502 | |
| 3503 | dnl AC_DEFUN([GMP_C_STDARG], |
| 3504 | dnl [AC_CACHE_CHECK([whether <stdarg.h> exists and works], |
| 3505 | dnl gmp_cv_c_stdarg, |
| 3506 | dnl [AC_TRY_COMPILE( |
| 3507 | dnl [#include <stdarg.h> |
| 3508 | dnl int foo (int x, ...) |
| 3509 | dnl { |
| 3510 | dnl va_list ap; |
| 3511 | dnl int y; |
| 3512 | dnl va_start (ap, x); |
| 3513 | dnl y = va_arg (ap, int); |
| 3514 | dnl va_end (ap); |
| 3515 | dnl return y; |
| 3516 | dnl }],, |
| 3517 | dnl gmp_cv_c_stdarg=yes, gmp_cv_c_stdarg=no) |
| 3518 | dnl ]) |
| 3519 | dnl if test $gmp_cv_c_stdarg = yes; then |
| 3520 | dnl AC_DEFINE(HAVE_STDARG, 1, [Define to 1 if <stdarg.h> exists and works]) |
| 3521 | dnl fi |
| 3522 | dnl ]) |
| 3523 | |
| 3524 | |
| 3525 | dnl GMP_FUNC_ALLOCA |
| 3526 | dnl --------------- |
| 3527 | dnl Determine whether "alloca" is available. This is AC_FUNC_ALLOCA from |
| 3528 | dnl autoconf, but changed so it doesn't use alloca.c if alloca() isn't |
| 3529 | dnl available, and also to use gmp-impl.h for the conditionals detecting |
| 3530 | dnl compiler builtin alloca's. |
| 3531 | |
| 3532 | AC_DEFUN([GMP_FUNC_ALLOCA], |
| 3533 | [AC_REQUIRE([GMP_HEADER_ALLOCA]) |
| 3534 | AC_CACHE_CHECK([for alloca (via gmp-impl.h)], |
| 3535 | gmp_cv_func_alloca, |
| 3536 | [AC_TRY_LINK( |
| 3537 | GMP_INCLUDE_GMP_H |
| 3538 | [#include "$srcdir/gmp-impl.h" |
| 3539 | ], |
| 3540 | [char *p = (char *) alloca (1);], |
| 3541 | gmp_cv_func_alloca=yes, |
| 3542 | gmp_cv_func_alloca=no)]) |
| 3543 | if test $gmp_cv_func_alloca = yes; then |
| 3544 | AC_DEFINE(HAVE_ALLOCA, 1, [Define to 1 if alloca() works (via gmp-impl.h).]) |
| 3545 | fi |
| 3546 | ]) |
| 3547 | |
| 3548 | AC_DEFUN([GMP_HEADER_ALLOCA], |
| 3549 | [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works |
| 3550 | # for constant arguments. Useless! |
| 3551 | AC_CACHE_CHECK([for working alloca.h], |
| 3552 | gmp_cv_header_alloca, |
| 3553 | [AC_TRY_LINK([#include <alloca.h>], |
| 3554 | [char *p = (char *) alloca (2 * sizeof (int));], |
| 3555 | gmp_cv_header_alloca=yes, |
| 3556 | gmp_cv_header_alloca=no)]) |
| 3557 | if test $gmp_cv_header_alloca = yes; then |
| 3558 | AC_DEFINE(HAVE_ALLOCA_H, 1, |
| 3559 | [Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).]) |
| 3560 | fi |
| 3561 | ]) |
| 3562 | |
| 3563 | |
| 3564 | dnl GMP_OPTION_ALLOCA |
| 3565 | dnl ----------------- |
| 3566 | dnl Decide what to do about --enable-alloca from the user. |
| 3567 | dnl This is a macro so it can require GMP_FUNC_ALLOCA. |
| 3568 | |
| 3569 | AC_DEFUN([GMP_OPTION_ALLOCA], |
| 3570 | [AC_REQUIRE([GMP_FUNC_ALLOCA]) |
| 3571 | AC_CACHE_CHECK([how to allocate temporary memory], |
| 3572 | gmp_cv_option_alloca, |
| 3573 | [case $enable_alloca in |
| 3574 | yes) |
| 3575 | gmp_cv_option_alloca=alloca |
| 3576 | ;; |
| 3577 | no) |
| 3578 | gmp_cv_option_alloca=malloc-reentrant |
| 3579 | ;; |
| 3580 | reentrant | notreentrant) |
| 3581 | case $gmp_cv_func_alloca in |
| 3582 | yes) gmp_cv_option_alloca=alloca ;; |
| 3583 | *) gmp_cv_option_alloca=malloc-$enable_alloca ;; |
| 3584 | esac |
| 3585 | ;; |
| 3586 | *) |
| 3587 | gmp_cv_option_alloca=$enable_alloca |
| 3588 | ;; |
| 3589 | esac |
| 3590 | ]) |
| 3591 | |
| 3592 | AH_VERBATIM([WANT_TMP], |
| 3593 | [/* Define one of these to 1 for the desired temporary memory allocation |
| 3594 | method, per --enable-alloca. */ |
| 3595 | #undef WANT_TMP_ALLOCA |
| 3596 | #undef WANT_TMP_REENTRANT |
| 3597 | #undef WANT_TMP_NOTREENTRANT |
| 3598 | #undef WANT_TMP_DEBUG]) |
| 3599 | |
| 3600 | case $gmp_cv_option_alloca in |
| 3601 | alloca) |
| 3602 | if test $gmp_cv_func_alloca = no; then |
| 3603 | AC_MSG_ERROR([--enable-alloca=alloca specified, but alloca not available]) |
| 3604 | fi |
| 3605 | AC_DEFINE(WANT_TMP_ALLOCA) |
| 3606 | TAL_OBJECT=tal-reent$U.lo |
| 3607 | ;; |
| 3608 | malloc-reentrant) |
| 3609 | AC_DEFINE(WANT_TMP_REENTRANT) |
| 3610 | TAL_OBJECT=tal-reent$U.lo |
| 3611 | ;; |
| 3612 | malloc-notreentrant) |
| 3613 | AC_DEFINE(WANT_TMP_NOTREENTRANT) |
| 3614 | TAL_OBJECT=tal-notreent$U.lo |
| 3615 | ;; |
| 3616 | debug) |
| 3617 | AC_DEFINE(WANT_TMP_DEBUG) |
| 3618 | TAL_OBJECT=tal-debug$U.lo |
| 3619 | ;; |
| 3620 | *) |
| 3621 | # checks at the start of configure.in should protect us |
| 3622 | AC_MSG_ERROR([unrecognised --enable-alloca=$gmp_cv_option_alloca]) |
| 3623 | ;; |
| 3624 | esac |
| 3625 | AC_SUBST(TAL_OBJECT) |
| 3626 | ]) |
| 3627 | |
| 3628 | |
| 3629 | dnl GMP_FUNC_SSCANF_WRITABLE_INPUT |
| 3630 | dnl ------------------------------ |
| 3631 | dnl Determine whether sscanf requires a writable input string. |
| 3632 | dnl |
| 3633 | dnl It might be nicer to run a program to determine this when doing a |
| 3634 | dnl native build, but the systems afflicted are few and far between these |
| 3635 | dnl days, so it seems good enough just to list them. |
| 3636 | |
| 3637 | AC_DEFUN([GMP_FUNC_SSCANF_WRITABLE_INPUT], |
| 3638 | [AC_CACHE_CHECK([whether sscanf needs writable input], |
| 3639 | gmp_cv_func_sscanf_writable_input, |
| 3640 | [case $host in |
| 3641 | *-*-hpux9 | *-*-hpux9.*) |
| 3642 | gmp_cv_func_sscanf_writable_input=yes ;; |
| 3643 | *) gmp_cv_func_sscanf_writable_input=no ;; |
| 3644 | esac |
| 3645 | ]) |
| 3646 | case $gmp_cv_func_sscanf_writable_input in |
| 3647 | yes) AC_DEFINE(SSCANF_WRITABLE_INPUT, 1, |
| 3648 | [Define to 1 if sscanf requires writable inputs]) ;; |
| 3649 | no) ;; |
| 3650 | *) AC_MSG_ERROR([unrecognised \$gmp_cv_func_sscanf_writable_input]) ;; |
| 3651 | esac |
| 3652 | ]) |
| 3653 | |
| 3654 | |
| 3655 | dnl GMP_FUNC_VSNPRINTF |
| 3656 | dnl ------------------ |
| 3657 | dnl Check whether vsnprintf exists, and works properly. |
| 3658 | dnl |
| 3659 | dnl Systems without vsnprintf include mingw32, OSF 4. |
| 3660 | dnl |
| 3661 | dnl Sparc Solaris 2.7 in 64-bit mode doesn't always truncate, making |
| 3662 | dnl vsnprintf like vsprintf, and hence completely useless. On one system a |
| 3663 | dnl literal string is enough to provoke the problem, on another a "%n" was |
| 3664 | dnl needed. There seems to be something weird going on with the optimizer |
| 3665 | dnl or something, since on the first system adding a second check with |
| 3666 | dnl "%n", or even just an initialized local variable, makes it work. In |
| 3667 | dnl any case, without bothering to get to the bottom of this, the two |
| 3668 | dnl program runs in the code below end up successfully detecting the |
| 3669 | dnl problem. |
| 3670 | dnl |
| 3671 | dnl glibc 2.0.x returns either -1 or bufsize-1 for an overflow (both seen, |
| 3672 | dnl not sure which 2.0.x does which), but still puts the correct null |
| 3673 | dnl terminated result into the buffer. |
| 3674 | |
| 3675 | AC_DEFUN([GMP_FUNC_VSNPRINTF], |
| 3676 | [AC_CHECK_FUNC(vsnprintf, |
| 3677 | [gmp_vsnprintf_exists=yes], |
| 3678 | [gmp_vsnprintf_exists=no]) |
| 3679 | if test "$gmp_vsnprintf_exists" = no; then |
| 3680 | gmp_cv_func_vsnprintf=no |
| 3681 | else |
| 3682 | AC_CACHE_CHECK([whether vsnprintf works], |
| 3683 | gmp_cv_func_vsnprintf, |
| 3684 | [gmp_cv_func_vsnprintf=yes |
| 3685 | for i in 'return check ("hello world");' 'int n; return check ("%nhello world", &n);'; do |
| 3686 | AC_TRY_RUN([ |
| 3687 | #include <string.h> /* for strcmp */ |
| 3688 | #include <stdio.h> /* for vsnprintf */ |
| 3689 | |
| 3690 | #include <stdarg.h> |
| 3691 | |
| 3692 | int |
| 3693 | check (const char *fmt, ...) |
| 3694 | { |
| 3695 | static char buf[128]; |
| 3696 | va_list ap; |
| 3697 | int ret; |
| 3698 | |
| 3699 | va_start (ap, fmt); |
| 3700 | |
| 3701 | ret = vsnprintf (buf, 4, fmt, ap); |
| 3702 | |
| 3703 | if (ret == -1 || strcmp (buf, "hel") != 0) |
| 3704 | return 1; |
| 3705 | |
| 3706 | /* allowed return values */ |
| 3707 | if (ret != 3 && ret != 11) |
| 3708 | return 2; |
| 3709 | |
| 3710 | return 0; |
| 3711 | } |
| 3712 | |
| 3713 | int |
| 3714 | main () |
| 3715 | { |
| 3716 | $i |
| 3717 | } |
| 3718 | ], |
| 3719 | [:], |
| 3720 | [gmp_cv_func_vsnprintf=no; break], |
| 3721 | [gmp_cv_func_vsnprintf=probably; break]) |
| 3722 | done |
| 3723 | ]) |
| 3724 | if test "$gmp_cv_func_vsnprintf" = probably; then |
| 3725 | AC_MSG_WARN([cannot check for properly working vsnprintf when cross compiling, will assume it's ok]) |
| 3726 | fi |
| 3727 | if test "$gmp_cv_func_vsnprintf" != no; then |
| 3728 | AC_DEFINE(HAVE_VSNPRINTF,1, |
| 3729 | [Define to 1 if you have the `vsnprintf' function and it works properly.]) |
| 3730 | fi |
| 3731 | fi |
| 3732 | ]) |
| 3733 | |
| 3734 | |
| 3735 | dnl GMP_H_EXTERN_INLINE |
| 3736 | dnl ------------------- |
| 3737 | dnl If the compiler has an "inline" of some sort, check whether the |
| 3738 | dnl #ifdef's in gmp.h recognise it. |
| 3739 | |
| 3740 | AC_DEFUN([GMP_H_EXTERN_INLINE], |
| 3741 | [AC_REQUIRE([AC_C_INLINE]) |
| 3742 | case $ac_cv_c_inline in |
| 3743 | no) ;; |
| 3744 | *) |
| 3745 | AC_TRY_COMPILE( |
| 3746 | [#define __GMP_WITHIN_CONFIGURE_INLINE 1 |
| 3747 | ]GMP_INCLUDE_GMP_H[ |
| 3748 | #ifndef __GMP_EXTERN_INLINE |
| 3749 | die die die |
| 3750 | #endif |
| 3751 | ],,, |
| 3752 | [case $ac_cv_c_inline in |
| 3753 | yes) tmp_inline=inline ;; |
| 3754 | *) tmp_inline=$ac_cv_c_inline ;; |
| 3755 | esac |
| 3756 | AC_MSG_WARN([gmp.h doesnt recognise compiler "$tmp_inline", inlines will be unavailable])]) |
| 3757 | ;; |
| 3758 | esac |
| 3759 | ]) |
| 3760 | |
| 3761 | |
| 3762 | dnl GMP_H_HAVE_FILE |
| 3763 | dnl --------------- |
| 3764 | dnl Check whether the #ifdef's in gmp.h recognise when stdio.h has been |
| 3765 | dnl included to get FILE. |
| 3766 | |
| 3767 | AC_DEFUN([GMP_H_HAVE_FILE], |
| 3768 | [AC_TRY_COMPILE( |
| 3769 | [#include <stdio.h>] |
| 3770 | GMP_INCLUDE_GMP_H |
| 3771 | [#if ! _GMP_H_HAVE_FILE |
| 3772 | die die die |
| 3773 | #endif |
| 3774 | ],,, |
| 3775 | [AC_MSG_WARN([gmp.h doesnt recognise <stdio.h>, FILE prototypes will be unavailable])]) |
| 3776 | ]) |
| 3777 | |
| 3778 | |
| 3779 | dnl GMP_PROG_CC_FOR_BUILD |
| 3780 | dnl --------------------- |
| 3781 | dnl Establish CC_FOR_BUILD, a C compiler for the build system. |
| 3782 | dnl |
| 3783 | dnl If CC_FOR_BUILD is set then it's expected to work, likewise the old |
| 3784 | dnl style HOST_CC, otherwise some likely candidates are tried, the same as |
| 3785 | dnl configfsf.guess. |
| 3786 | |
| 3787 | AC_DEFUN([GMP_PROG_CC_FOR_BUILD], |
| 3788 | [AC_REQUIRE([AC_PROG_CC]) |
| 3789 | if test -n "$CC_FOR_BUILD"; then |
| 3790 | GMP_PROG_CC_FOR_BUILD_WORKS($CC_FOR_BUILD,, |
| 3791 | [AC_MSG_ERROR([Specified CC_FOR_BUILD doesn't seem to work])]) |
| 3792 | elif test -n "$HOST_CC"; then |
| 3793 | GMP_PROG_CC_FOR_BUILD_WORKS($HOST_CC, |
| 3794 | [CC_FOR_BUILD=$HOST_CC], |
| 3795 | [AC_MSG_ERROR([Specified HOST_CC doesn't seem to work])]) |
| 3796 | else |
| 3797 | for i in "$CC" "$CC $CFLAGS $CPPFLAGS" cc gcc c89 c99; do |
| 3798 | GMP_PROG_CC_FOR_BUILD_WORKS($i, |
| 3799 | [CC_FOR_BUILD=$i |
| 3800 | break]) |
| 3801 | done |
| 3802 | if test -z "$CC_FOR_BUILD"; then |
| 3803 | AC_MSG_ERROR([Cannot find a build system compiler]) |
| 3804 | fi |
| 3805 | fi |
| 3806 | |
| 3807 | AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler]) |
| 3808 | AC_SUBST(CC_FOR_BUILD) |
| 3809 | ]) |
| 3810 | |
| 3811 | |
| 3812 | dnl GMP_PROG_CC_FOR_BUILD_WORKS(cc/cflags[,[action-if-good][,action-if-bad]]) |
| 3813 | dnl ------------------------------------------------------------------------- |
| 3814 | dnl See if the given cc/cflags works on the build system. |
| 3815 | dnl |
| 3816 | dnl It seems easiest to just use the default compiler output, rather than |
| 3817 | dnl figuring out the .exe or whatever at this stage. |
| 3818 | |
| 3819 | AC_DEFUN([GMP_PROG_CC_FOR_BUILD_WORKS], |
| 3820 | [AC_MSG_CHECKING([build system compiler $1]) |
| 3821 | # remove anything that might look like compiler output to our "||" expression |
| 3822 | rm -f conftest* a.out b.out a.exe a_out.exe |
| 3823 | cat >conftest.c <<EOF |
| 3824 | int |
| 3825 | main () |
| 3826 | { |
| 3827 | return 0; |
| 3828 | } |
| 3829 | EOF |
| 3830 | gmp_compile="$1 conftest.c" |
| 3831 | cc_for_build_works=no |
| 3832 | if AC_TRY_EVAL(gmp_compile); then |
| 3833 | if (./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest) >&AC_FD_CC 2>&1; then |
| 3834 | cc_for_build_works=yes |
| 3835 | fi |
| 3836 | fi |
| 3837 | rm -f conftest* a.out b.out a.exe a_out.exe |
| 3838 | AC_MSG_RESULT($cc_for_build_works) |
| 3839 | if test "$cc_for_build_works" = yes; then |
| 3840 | ifelse([$2],,:,[$2]) |
| 3841 | else |
| 3842 | ifelse([$3],,:,[$3]) |
| 3843 | fi |
| 3844 | ]) |
| 3845 | |
| 3846 | |
| 3847 | dnl GMP_PROG_CPP_FOR_BUILD |
| 3848 | dnl --------------------- |
| 3849 | dnl Establish CPP_FOR_BUILD, the build system C preprocessor. |
| 3850 | dnl The choices tried here are the same as AC_PROG_CPP, but with |
| 3851 | dnl CC_FOR_BUILD. |
| 3852 | |
| 3853 | AC_DEFUN([GMP_PROG_CPP_FOR_BUILD], |
| 3854 | [AC_REQUIRE([GMP_PROG_CC_FOR_BUILD]) |
| 3855 | AC_MSG_CHECKING([for build system preprocessor]) |
| 3856 | if test -z "$CPP_FOR_BUILD"; then |
| 3857 | AC_CACHE_VAL(gmp_cv_prog_cpp_for_build, |
| 3858 | [cat >conftest.c <<EOF |
| 3859 | #define FOO BAR |
| 3860 | EOF |
| 3861 | for i in "$CC_FOR_BUILD -E" "$CC_FOR_BUILD -E -traditional-cpp" "/lib/cpp"; do |
| 3862 | gmp_compile="$i conftest.c" |
| 3863 | if AC_TRY_EVAL(gmp_compile) >&AC_FD_CC 2>&1; then |
| 3864 | gmp_cv_prog_cpp_for_build=$i |
| 3865 | break |
| 3866 | fi |
| 3867 | done |
| 3868 | rm -f conftest* a.out b.out a.exe a_out.exe |
| 3869 | if test -z "$gmp_cv_prog_cpp_for_build"; then |
| 3870 | AC_MSG_ERROR([Cannot find build system C preprocessor.]) |
| 3871 | fi |
| 3872 | ]) |
| 3873 | CPP_FOR_BUILD=$gmp_cv_prog_cpp_for_build |
| 3874 | fi |
| 3875 | AC_MSG_RESULT([$CPP_FOR_BUILD]) |
| 3876 | |
| 3877 | AC_ARG_VAR(CPP_FOR_BUILD,[build system C preprocessor]) |
| 3878 | AC_SUBST(CPP_FOR_BUILD) |
| 3879 | ]) |
| 3880 | |
| 3881 | |
| 3882 | dnl GMP_PROG_EXEEXT_FOR_BUILD |
| 3883 | dnl ------------------------- |
| 3884 | dnl Determine EXEEXT_FOR_BUILD, the build system executable suffix. |
| 3885 | dnl |
| 3886 | dnl The idea is to find what "-o conftest$foo" will make it possible to run |
| 3887 | dnl the program with ./conftest. On Unix-like systems this is of course |
| 3888 | dnl nothing, for DOS it's ".exe", or for a strange RISC OS foreign file |
| 3889 | dnl system cross compile it can be ",ff8" apparently. Not sure if the |
| 3890 | dnl latter actually applies to a build-system executable, maybe it doesn't, |
| 3891 | dnl but it won't hurt to try. |
| 3892 | |
| 3893 | AC_DEFUN([GMP_PROG_EXEEXT_FOR_BUILD], |
| 3894 | [AC_REQUIRE([GMP_PROG_CC_FOR_BUILD]) |
| 3895 | AC_CACHE_CHECK([for build system executable suffix], |
| 3896 | gmp_cv_prog_exeext_for_build, |
| 3897 | [cat >conftest.c <<EOF |
| 3898 | int |
| 3899 | main () |
| 3900 | { |
| 3901 | return 0; |
| 3902 | } |
| 3903 | EOF |
| 3904 | for i in .exe ,ff8 ""; do |
| 3905 | gmp_compile="$CC_FOR_BUILD conftest.c -o conftest$i" |
| 3906 | if AC_TRY_EVAL(gmp_compile); then |
| 3907 | if (./conftest) 2>&AC_FD_CC; then |
| 3908 | gmp_cv_prog_exeext_for_build=$i |
| 3909 | break |
| 3910 | fi |
| 3911 | fi |
| 3912 | done |
| 3913 | rm -f conftest* |
| 3914 | if test "${gmp_cv_prog_exeext_for_build+set}" != set; then |
| 3915 | AC_MSG_ERROR([Cannot determine executable suffix]) |
| 3916 | fi |
| 3917 | ]) |
| 3918 | AC_SUBST(EXEEXT_FOR_BUILD,$gmp_cv_prog_exeext_for_build) |
| 3919 | ]) |
| 3920 | |
| 3921 | |
| 3922 | dnl GMP_C_FOR_BUILD_ANSI |
| 3923 | dnl -------------------- |
| 3924 | dnl Determine whether CC_FOR_BUILD is ANSI, and establish U_FOR_BUILD |
| 3925 | dnl accordingly. |
| 3926 | dnl |
| 3927 | dnl FIXME: Use AC_PROG_CC sets ac_cv_prog_cc_c89 which could be used instead |
| 3928 | |
| 3929 | AC_DEFUN([GMP_C_FOR_BUILD_ANSI], |
| 3930 | [AC_REQUIRE([GMP_PROG_CC_FOR_BUILD]) |
| 3931 | AC_CACHE_CHECK([whether build system compiler is ANSI], |
| 3932 | gmp_cv_c_for_build_ansi, |
| 3933 | [cat >conftest.c <<EOF |
| 3934 | int |
| 3935 | main (int argc, char **argv) |
| 3936 | { |
| 3937 | return 0; |
| 3938 | } |
| 3939 | EOF |
| 3940 | gmp_compile="$CC_FOR_BUILD conftest.c" |
| 3941 | if AC_TRY_EVAL(gmp_compile); then |
| 3942 | gmp_cv_c_for_build_ansi=yes |
| 3943 | else |
| 3944 | gmp_cv_c_for_build_ansi=no |
| 3945 | fi |
| 3946 | rm -f conftest* a.out b.out a.exe a_out.exe |
| 3947 | ]) |
| 3948 | if test "$gmp_cv_c_for_build_ansi" = yes; then |
| 3949 | U_FOR_BUILD= |
| 3950 | else |
| 3951 | AC_SUBST(U_FOR_BUILD,_) |
| 3952 | fi |
| 3953 | ]) |
| 3954 | |
| 3955 | |
| 3956 | dnl GMP_CHECK_LIBM_FOR_BUILD |
| 3957 | dnl ------------------------ |
| 3958 | dnl Establish LIBM_FOR_BUILD as -lm, if that seems to work. |
| 3959 | dnl |
| 3960 | dnl Libtool AC_CHECK_LIBM also uses -lmw on *-ncr-sysv4.3*, if it works. |
| 3961 | dnl Don't know what that does, lets assume it's not needed just for log(). |
| 3962 | |
| 3963 | AC_DEFUN([GMP_CHECK_LIBM_FOR_BUILD], |
| 3964 | [AC_REQUIRE([GMP_PROG_CC_FOR_BUILD]) |
| 3965 | AC_CACHE_CHECK([for build system compiler math library], |
| 3966 | gmp_cv_check_libm_for_build, |
| 3967 | [cat >conftest.c <<EOF |
| 3968 | #include <math.h> |
| 3969 | int |
| 3970 | main () |
| 3971 | { |
| 3972 | return 0; |
| 3973 | } |
| 3974 | double d; |
| 3975 | double |
| 3976 | foo () |
| 3977 | { |
| 3978 | return log (d); |
| 3979 | } |
| 3980 | EOF |
| 3981 | gmp_compile="$CC_FOR_BUILD conftest.c -lm" |
| 3982 | if AC_TRY_EVAL(gmp_compile); then |
| 3983 | gmp_cv_check_libm_for_build=-lm |
| 3984 | else |
| 3985 | gmp_cv_check_libm_for_build=no |
| 3986 | fi |
| 3987 | rm -f conftest* a.out b.out a.exe a_out.exe |
| 3988 | ]) |
| 3989 | case $gmp_cv_check_libm_for_build in |
| 3990 | yes) AC_SUBST(LIBM_FOR_BUILD,-lm) ;; |
| 3991 | no) LIBM_FOR_BUILD= ;; |
| 3992 | *) LIBM_FOR_BUILD=$gmp_cv_check_libm_for_build ;; |
| 3993 | esac |
| 3994 | ]) |