1 dnl GMP specific autoconf macros
4 dnl Copyright (C) 2000 Free Software Foundation, Inc.
6 dnl This file is part of the GNU MP Library.
8 dnl The GNU MP Library is free software; you can redistribute it and/or modify
9 dnl it under the terms of the GNU Lesser General Public License as published
10 dnl by the Free Software Foundation; either version 2.1 of the License, or (at
11 dnl your option) any later version.
13 dnl The GNU MP Library is distributed in the hope that it will be useful, but
14 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 dnl License for more details.
18 dnl You should have received a copy of the GNU Lesser General Public License
19 dnl along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20 dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 dnl MA 02111-1307, USA.
24 dnl GMP_HEADER_GETVAL(NAME,FILE)
25 dnl ----------------------------
26 dnl Expand to the value of a "#define NAME" from the given FILE.
27 dnl The regexps here aren't very rugged, but are enough for gmp.
28 dnl /dev/null as a parameter prevents a hang if $2 is accidentally omitted.
30 define(GMP_HEADER_GETVAL,
32 esyscmd([grep "^#define $1 " $2 /dev/null 2>/dev/null]),
40 dnl The gmp version number, extracted from the #defines in gmp.h.
41 dnl Two digits like 3.0 if patchlevel <= 0, or three digits like 3.0.1 if
45 [GMP_HEADER_GETVAL(__GNU_MP_VERSION,gmp.h)[]dnl
46 .GMP_HEADER_GETVAL(__GNU_MP_VERSION_MINOR,gmp.h)[]dnl
47 ifelse(m4_eval(GMP_HEADER_GETVAL(__GNU_MP_VERSION_PATCHLEVEL,gmp.h) > 0),1,
48 [.GMP_HEADER_GETVAL(__GNU_MP_VERSION_PATCHLEVEL,gmp.h)])])
54 dnl Find a working m4, either in $PATH or likely locations, and setup $M4
55 dnl and an AC_SUBST accordingly. If $M4 is already set then it's a user
56 dnl choice and is accepted with no checks. GMP_PROG_M4 is like
57 dnl AC_PATH_PROG or AC_CHECK_PROG, but it tests each m4 found to see if
60 dnl See mpn/asm-defs.m4 for details on the known bad m4s.
63 [AC_CACHE_CHECK([for suitable m4],
65 [if test -n "$M4"; then
68 cat >conftest.m4 <<\EOF
69 dnl must protect this against being expanded during autoconf m4!
70 [define(dollarhash,``$][#'')dnl
71 ifelse(dollarhash(x),1,`define(t1,Y)',
72 ``bad: $][# not supported (SunOS /usr/bin/m4)
74 ifelse(eval(89),89,`define(t2,Y)',
75 `bad: eval() doesnt support 8 or 9 in a constant (OpenBSD 2.6 m4)
77 ifelse(t1`'t2,YY,`good
80 echo "trying m4" 1>&AC_FD_CC
81 gmp_tmp_val="`(m4 conftest.m4) 2>&AC_FD_CC`"
82 echo "$gmp_tmp_val" 1>&AC_FD_CC
83 if test "$gmp_tmp_val" = good; then
86 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
87 dnl $ac_dummy forces splitting on constant user-supplied paths.
88 dnl POSIX.2 word splitting is done only on the output of word expansions,
89 dnl not every word. This closes a longstanding sh security hole.
90 ac_dummy="$PATH:/usr/5bin"
91 for ac_dir in $ac_dummy; do
92 test -z "$ac_dir" && ac_dir=.
93 echo "trying $ac_dir/m4" 1>&AC_FD_CC
94 gmp_tmp_val="`($ac_dir/m4 conftest.m4) 2>&AC_FD_CC`"
95 echo "$gmp_tmp_val" 1>&AC_FD_CC
96 if test "$gmp_tmp_val" = good; then
97 gmp_cv_prog_m4="$ac_dir/m4"
102 if test -z "$gmp_cv_prog_m4"; then
103 AC_MSG_ERROR([No usable m4 in \$PATH or /usr/5bin (see config.log for reasons).])
113 dnl GMP_PROG_CC_FIND([CC_LIST], [REQ_64BIT_CC])
114 dnl Find first working compiler in CC_LIST.
115 dnl If REQ_64BIT_CC is "yes", the compiler is required to be able to
116 dnl produce 64-bit code.
117 dnl NOTE: If a compiler needs any special flags for producing 64-bit code,
118 dnl these have to be found in shell variable `gmp_cflags64_{cc}', where `{cc}'
119 dnl is the name of the compiler.
120 dnl Set CC to the name of the first working compiler.
121 dnl If a 64-bit compiler is found, set CC64 to the name of the compiler and
122 dnl CFLAGS64 to flags to use.
123 dnl This macro does not test if any of the compilers found is a GNU compiler.
124 dnl To do this, when you have finally made up your mind on which one to use,
125 dnl and set CC accordingly, invoke [GMP_PROG_CC_SELECT]. That macro will
126 dnl also make sure that your selection of CFLAGS is valid.
128 AC_DEFUN(GMP_PROG_CC_FIND,
129 [AC_BEFORE([$0], [CC_PROG_CPP])
130 ifelse([$1], , gmp_cc_list="gcc cc", gmp_cc_list="[$1]")
131 ifelse([$2], , gmp_req_64bit_cc="no", gmp_req_64bit_cc="[$2]")
135 for c in $gmp_cc_list; do
139 AC_CHECK_TOOL(CC, $c, $c)
140 if test -n "$CC"; then
141 eval c_flags=\$gmp_cflags_$c
142 GMP_PROG_CC_WORKS($CC, $c_flags,
143 gmp_prog_cc_works=yes,
144 gmp_prog_cc_works=no)
146 if test "$gmp_prog_cc_works" != "yes"; then
150 # Save first working compiler, whether 32- or 64-bit capable.
151 if test -z "$CC32"; then
154 if test "$gmp_req_64bit_cc" = "yes"; then
155 eval c_flags=\$gmp_cflags64_$c
157 # Verify that the compiler works in 64-bit mode as well.
158 # /usr/ucb/cc on Solaris 7 can *compile* in 64-bit mode, but not link.
159 GMP_PROG_CC_WORKS($c, $c_flags,
160 gmp_prog_cc_works=yes,
161 gmp_prog_cc_works=no)
163 if test "$gmp_prog_cc_works" = "yes"; then
164 GMP_CHECK_CC_64BIT($c, $c_flags)
165 if test "$gmp_cv_cc_64bit" = "yes"; then
166 test -z "$CC64" && CC64="$c"
167 test -z "$CFLAGS64" && CFLAGS64="$c_flags"
168 # We have CC64 so we're done.
173 # We have CC32, and we don't need a 64-bit compiler so we're done.
181 dnl GMP_PROG_CC_SELECT
182 dnl Check that `CC' works with `CFLAGS'. Check if `CC' is a GNU compiler.
183 dnl Cache the result as `ac_cv_prog_CC'.
184 AC_DEFUN(GMP_PROG_CC_SELECT,
185 [AC_BEFORE([$0], [CC_PROG_CPP])
189 if test "$ac_cv_prog_gcc" = "yes"; then
195 # Set CFLAGS if not already set.
196 if test -z "$CFLAGS"; then
198 if test "$GCC" = "yes"; then
204 AC_CACHE_VAL(ac_cv_prog_CC, ac_cv_prog_CC="$CC")
205 AC_PROVIDE([AC_PROG_CC])
208 dnl GMP_CHECK_CC_64BIT(cc, cflags64)
209 dnl Find out if `CC' can produce 64-bit code.
210 dnl Requires NM to be set to nm for target.
211 dnl FIXME: Cache result.
212 AC_DEFUN(GMP_CHECK_CC_64BIT,
214 gmp_tmp_CC_save="$CC"
216 AC_MSG_CHECKING([whether the C compiler ($CC) is 64-bit capable])
217 if test -z "$NM"; then
218 echo; echo ["configure: $0: fatal: need nm"]
221 gmp_tmp_CFLAGS_save="$CFLAGS"
226 # FIXME: If gcc is installed under another name than "gcc", we will
227 # test the wrong thing.
228 if test "$CC" != "gcc"; then
229 dnl Let compiler version A.10.32.30 or higher be ok.
230 dnl Bad compiler output:
231 dnl ccom: HP92453-01 G.10.32.05 HP C Compiler
232 dnl Good compiler output:
233 dnl ccom: HP92453-01 A.10.32.30 HP C Compiler
235 gmp_tmp_vs=`$CC $CFLAGS -V -c -o conftest.o conftest.c 2>&1 | grep "^ccom:"`
237 gmp_tmp_v1=`echo $gmp_tmp_vs | sed 's/.* .\.\(.*\)\..*\..* HP C.*/\1/'`
238 gmp_tmp_v2=`echo $gmp_tmp_vs | sed 's/.* .\..*\.\(.*\)\..* HP C.*/\1/'`
239 gmp_tmp_v3=`echo $gmp_tmp_vs | sed 's/.* .\..*\..*\.\(.*\) HP C.*/\1/'`
241 test -n "$gmp_tmp_v1" && test "$gmp_tmp_v1" -ge "10" \
242 && test -n "$gmp_tmp_v2" && test "$gmp_tmp_v2" -ge "32" \
243 && test -n "$gmp_tmp_v3" && test "$gmp_tmp_v3" -ge "30" \
244 && gmp_cv_cc_64bit=yes
246 # FIXME: Compile a minimal file and determine if the resulting object
247 # file is an ELF file. If so, gcc can produce 64-bit code.
248 # Do we have file(1) for target?
253 # We use `-n32' to cc and `-mabi=n32' to gcc, resulting in 64-bit
254 # arithmetic but not 64-bit pointers, so the general test for sizeof
255 # (void *) is not valid.
256 # Simply try to compile an empty main. If that succeeds return
259 gmp_cv_cc_64bit=yes, gmp_cv_cc_64bit=no,
263 # Allocate an array of size sizeof (void *) and use nm to determine its
264 # size. We depend on the first declared variable being put at address 0.
265 cat >conftest.c <<EOF
266 [char arr[sizeof (void *)]={0};
269 gmp_compile="$CC $CFLAGS -c conftest.c 1>&AC_FD_CC"
270 if AC_TRY_EVAL(gmp_compile); then
272 gmp_tmp_val=`$NM conftest.o | grep post | sed -e 's;[[][0-9][]]\(.*\);\1;' \
273 -e 's;[^1-9]*\([0-9]*\).*;\1;'`
275 if test "$gmp_tmp_val" = "8"; then
281 echo "configure: failed program was:" >&AC_FD_CC
282 cat conftest.$ac_ext >&AC_FD_CC
289 CC="$gmp_tmp_CC_save"
290 CFLAGS="$gmp_tmp_CFLAGS_save"
291 AC_MSG_RESULT($gmp_cv_cc_64bit)
294 dnl GMP_INIT([M4-DEF-FILE])
297 [ifelse([$1], , gmp_configm4=config.m4, gmp_configm4="[$1]")
298 gmp_tmpconfigm4=cnfm4.tmp
299 gmp_tmpconfigm4i=cnfm4i.tmp
300 gmp_tmpconfigm4p=cnfm4p.tmp
301 test -f $gmp_tmpconfigm4 && rm $gmp_tmpconfigm4
302 test -f $gmp_tmpconfigm4i && rm $gmp_tmpconfigm4i
303 test -f $gmp_tmpconfigm4p && rm $gmp_tmpconfigm4p
308 dnl Create config.m4 from its accumulated parts.
310 dnl __CONFIG_M4_INCLUDED__ is used so that a second or subsequent include
311 dnl of config.m4 is harmless.
313 dnl A separate ifdef on the angle bracket quoted part ensures the quoting
314 dnl style there is respected. The basic defines from gmp_tmpconfigm4 are
315 dnl fully quoted but are still put under an ifdef in case any have been
316 dnl redefined by one of the m4 include files.
318 dnl Doing a big ifdef within asm-defs.m4 and/or other macro files wouldn't
319 dnl work, since it'd interpret parentheses and quotes in dnl comments, and
320 dnl having a whole file as a macro argument would overflow the string space
324 [AC_REQUIRE([GMP_INIT])
325 echo "creating $gmp_configm4"
326 echo ["dnl $gmp_configm4. Generated automatically by configure."] > $gmp_configm4
327 if test -f $gmp_tmpconfigm4; then
328 echo ["changequote(<,>)dnl"] >> $gmp_configm4
329 echo ["ifdef(<__CONFIG_M4_INCLUDED__>,,<"] >> $gmp_configm4
330 cat $gmp_tmpconfigm4 >> $gmp_configm4
331 echo [">)"] >> $gmp_configm4
332 echo ["changequote(\`,')dnl"] >> $gmp_configm4
335 echo ["ifdef(\`__CONFIG_M4_INCLUDED__',,\`"] >> $gmp_configm4
336 if test -f $gmp_tmpconfigm4i; then
337 cat $gmp_tmpconfigm4i >> $gmp_configm4
340 if test -f $gmp_tmpconfigm4p; then
341 cat $gmp_tmpconfigm4p >> $gmp_configm4
344 echo ["')"] >> $gmp_configm4
345 echo ["define(\`__CONFIG_M4_INCLUDED__')"] >> $gmp_configm4
348 dnl GMP_INCLUDE(FILE)
349 AC_DEFUN(GMP_INCLUDE,
350 [AC_REQUIRE([GMP_INIT])
351 echo ["include(\`$1')"] >> $gmp_tmpconfigm4i
354 dnl GMP_SINCLUDE(FILE)
355 AC_DEFUN(GMP_SINCLUDE,
356 [AC_REQUIRE([GMP_INIT])
357 echo ["sinclude(\`$1')"] >> $gmp_tmpconfigm4i
360 dnl GMP_DEFINE(MACRO, DEFINITION [, LOCATION])
361 dnl [ Define M4 macro MACRO as DEFINITION in temporary file. ]
362 dnl [ If LOCATION is `POST', the definition will appear after any ]
363 dnl [ include() directives inserted by GMP_INCLUDE/GMP_SINCLUDE. ]
364 dnl [ Mind the quoting! No shell variables will get expanded. ]
365 dnl [ Don't forget to invoke GMP_FINISH to create file config.m4. ]
366 dnl [ config.m4 uses `<' and '>' as quote characters for all defines. ]
368 [AC_REQUIRE([GMP_INIT])
369 echo ['define(<$1>, <$2>)'] >> ifelse([$3], [POST], $gmp_tmpconfigm4p, $gmp_tmpconfigm4)
372 dnl GMP_DEFINE_RAW(STRING, [, LOCATION])
373 dnl [ Put STRING in temporary file. ]
374 dnl [ If LOCATION is `POST', the definition will appear after any ]
375 dnl [ include() directives inserted by GMP_INCLUDE/GMP_SINCLUDE. ]
376 dnl [ Don't forget to invoke GMP_FINISH to create file config.m4. ]
377 AC_DEFUN(GMP_DEFINE_RAW,
378 [AC_REQUIRE([GMP_INIT])
379 echo [$1] >> ifelse([$2], [POST], $gmp_tmpconfigm4p, $gmp_tmpconfigm4)
382 dnl GMP_CHECK_ASM_LABEL_SUFFIX
383 dnl Should a label have a colon or not?
384 AC_DEFUN(GMP_CHECK_ASM_LABEL_SUFFIX,
385 [AC_CACHE_CHECK([what assembly label suffix to use],
386 gmp_cv_check_asm_label_suffix,
388 *-*-hpux*) gmp_cv_check_asm_label_suffix=[""] ;;
389 *) gmp_cv_check_asm_label_suffix=[":"] ;;
392 echo ["define(<LABEL_SUFFIX>, <\$][1$gmp_cv_check_asm_label_suffix>)"] >> $gmp_tmpconfigm4
395 dnl GMP_CHECK_ASM_UNDERSCORE([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
396 dnl Shamelessly borrowed from glibc.
397 AC_DEFUN(GMP_CHECK_ASM_UNDERSCORE,
398 [AC_CACHE_CHECK([if symbols are prefixed by underscore],
399 gmp_cv_check_asm_underscore,
400 [cat > conftest.$ac_ext <<EOF
401 dnl This sometimes fails to find confdefs.h, for some reason.
402 dnl [#]line __oline__ "[$]0"
403 [#]line __oline__ "configure"
404 #include "confdefs.h"
405 int underscore_test() {
408 if AC_TRY_EVAL(ac_compile); then
409 if grep _underscore_test conftest* >/dev/null; then
410 gmp_cv_check_asm_underscore=yes
412 gmp_cv_check_asm_underscore=no
415 echo "configure: failed program was:" >&AC_FD_CC
416 cat conftest.$ac_ext >&AC_FD_CC
420 if test "$gmp_cv_check_asm_underscore" = "yes"; then
421 GMP_DEFINE(GSYM_PREFIX, [_])
422 ifelse([$1], , :, [$1])
424 GMP_DEFINE(GSYM_PREFIX, [])
425 ifelse([$2], , :, [$2])
429 dnl GMP_CHECK_ASM_ALIGN_LOG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
430 dnl Is parameter to `.align' logarithmic?
431 dnl Requires NM to be set to nm for target.
432 AC_DEFUN(GMP_CHECK_ASM_ALIGN_LOG,
433 [AC_REQUIRE([GMP_CHECK_ASM_GLOBL])
434 AC_REQUIRE([GMP_CHECK_ASM_DATA])
435 AC_REQUIRE([GMP_CHECK_ASM_LABEL_SUFFIX])
436 AC_CACHE_CHECK([if .align assembly directive is logarithmic],
437 gmp_cv_check_asm_align_log,
438 [if test -z "$NM"; then
439 echo; echo ["configure: $0: fatal: need nm"]
442 cat > conftest.s <<EOF
443 $gmp_cv_check_asm_data
445 $gmp_cv_check_asm_globl foo
448 foo$gmp_cv_check_asm_label_suffix
451 ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
452 if AC_TRY_EVAL(ac_assemble); then
454 gmp_tmp_val=`$NM conftest.o | grep foo | sed -e 's;[[][0-9][]]\(.*\);\1;' \
455 -e 's;[^1-9]*\([0-9]*\).*;\1;'`
457 if test "$gmp_tmp_val" = "10" || test "$gmp_tmp_val" = "16"; then
458 gmp_cv_check_asm_align_log=yes
460 gmp_cv_check_asm_align_log=no
463 echo "configure: failed program was:" >&AC_FD_CC
464 cat conftest.s >&AC_FD_CC
468 GMP_DEFINE_RAW(["define(<ALIGN_LOGARITHMIC>,<$gmp_cv_check_asm_align_log>)"])
469 if test "$gmp_cv_check_asm_align_log" = "yes"; then
470 ifelse([$1], , :, [$1])
472 ifelse([$2], , :, [$2])
477 dnl GMP_CHECK_ASM_ALIGN_FILL_0x90
478 dnl -----------------------------
479 dnl Determine whether a ",0x90" suffix works on a .align directive.
480 dnl This is only meant for use on x86, where 0x90 is a "nop".
482 dnl Old gas, eg. 1.92.3 - needs ",0x90" or else the fill is an invalid 0x00.
483 dnl New gas, eg. 2.91 - generates the good multibyte nop fills even when
484 dnl ",0x90" is given.
485 dnl Solaris 2.6 as - doesn't allow ",0x90", gives a fatal error.
486 dnl Solaris 2.8 as - gives a warning for ",0x90", no ill effect.
488 dnl Note that both solaris "as"s only care about ",0x90" if they actually
489 dnl have to use it to fill something, hence the .byte in the sample. It's
490 dnl only the second .align that provokes an error or warning.
492 dnl We prefer to suppress the warning from solaris 2.8 to stop anyone
493 dnl worrying something might be wrong.
495 AC_DEFUN(GMP_CHECK_ASM_ALIGN_FILL_0x90,
496 [AC_CACHE_CHECK([if the .align directive accepts an 0x90 fill in .text],
497 gmp_cv_check_asm_align_fill_0x90,
498 [AC_REQUIRE([GMP_CHECK_ASM_TEXT])
499 cat > conftest.s <<EOF
500 $gmp_cv_check_asm_text
505 gmp_tmp_val="`$CCAS $CFLAGS conftest.s 2>&1`"
507 echo "$gmp_tmp_val" 1>&AC_FD_CC
508 if echo "$gmp_tmp_val" | grep "Warning: Fill parameter ignored for executable section"; then
509 echo "Supressing this warning by omitting 0x90" 1>&AC_FD_CC
510 gmp_cv_check_asm_align_fill_0x90=no
512 gmp_cv_check_asm_align_fill_0x90=yes
515 echo "Non-zero exit code" 1>&AC_FD_CC
516 echo "$gmp_tmp_val" 1>&AC_FD_CC
517 gmp_cv_check_asm_align_fill_0x90=no
522 ["define(<ALIGN_FILL_0x90>,<$gmp_cv_check_asm_align_fill_0x90>)"])
526 dnl GMP_CHECK_ASM_TEXT
527 AC_DEFUN(GMP_CHECK_ASM_TEXT,
528 [AC_CACHE_CHECK([how to switch to text section], gmp_cv_check_asm_text,
532 gmp_cv_check_asm_text={".csect .text[PR]"}
535 *-*-hpux*) gmp_cv_check_asm_text=[".code"] ;;
536 *) gmp_cv_check_asm_text=[".text"] ;;
539 echo ["define(<TEXT>, <$gmp_cv_check_asm_text>)"] >> $gmp_tmpconfigm4
542 dnl GMP_CHECK_ASM_DATA
543 dnl Can we say `.data'?
544 AC_DEFUN(GMP_CHECK_ASM_DATA,
545 [AC_CACHE_CHECK([how to switch to data section], gmp_cv_check_asm_data,
549 gmp_cv_check_asm_data={".csect .data[RW]"}
552 *) gmp_cv_check_asm_data=[".data"] ;;
555 echo ["define(<DATA>, <$gmp_cv_check_asm_data>)"] >> $gmp_tmpconfigm4
558 dnl GMP_CHECK_ASM_GLOBL
559 dnl Can we say `.global'?
560 AC_DEFUN(GMP_CHECK_ASM_GLOBL,
561 [AC_CACHE_CHECK([how to export a symbol], gmp_cv_check_asm_globl,
563 *-*-hpux*) gmp_cv_check_asm_globl=[".export"] ;;
564 *) gmp_cv_check_asm_globl=[".globl"] ;;
567 echo ["define(<GLOBL>, <$gmp_cv_check_asm_globl>)"] >> $gmp_tmpconfigm4
570 dnl GMP_CHECK_ASM_TYPE
571 dnl Can we say `.type'?
572 AC_DEFUN(GMP_CHECK_ASM_TYPE,
573 [AC_CACHE_CHECK([how the .type assembly directive should be used],
574 gmp_cv_check_asm_type,
575 [ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
576 for gmp_tmp_prefix in @ \# %; do
577 echo " .type sym,${gmp_tmp_prefix}function" > conftest.s
578 if AC_TRY_EVAL(ac_assemble); then
579 gmp_cv_check_asm_type="[.type \$][1,${gmp_tmp_prefix}\$][2]"
583 if test -z "$gmp_cv_check_asm_type"; then
584 gmp_cv_check_asm_type="[dnl]"
587 echo ["define(<TYPE>, <$gmp_cv_check_asm_type>)"] >> $gmp_tmpconfigm4
590 dnl GMP_CHECK_ASM_SIZE
591 dnl Can we say `.size'?
592 AC_DEFUN(GMP_CHECK_ASM_SIZE,
593 [AC_CACHE_CHECK([if the .size assembly directive works], gmp_cv_check_asm_size,
594 [ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
595 echo ' .size sym,1' > conftest.s
596 if AC_TRY_EVAL(ac_assemble); then
597 gmp_cv_check_asm_size="[.size \$][1,\$][2]"
599 gmp_cv_check_asm_size="[dnl]"
602 echo ["define(<SIZE>, <$gmp_cv_check_asm_size>)"] >> $gmp_tmpconfigm4
605 dnl GMP_CHECK_ASM_LSYM_PREFIX
606 dnl What is the prefix for a local label?
607 dnl Requires NM to be set to nm for target.
608 AC_DEFUN(GMP_CHECK_ASM_LSYM_PREFIX,
609 [AC_REQUIRE([GMP_CHECK_ASM_LABEL_SUFFIX])
610 AC_CACHE_CHECK([what prefix to use for a local label],
611 gmp_cv_check_asm_lsym_prefix,
612 [if test -z "$NM"; then
613 echo; echo ["$0: fatal: need nm"]
616 ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
617 gmp_cv_check_asm_lsym_prefix="L"
618 for gmp_tmp_pre in L .L $ L$; do
619 cat > conftest.s <<EOF
620 dummy${gmp_cv_check_asm_label_suffix}
621 ${gmp_tmp_pre}gurkmacka${gmp_cv_check_asm_label_suffix}
624 if AC_TRY_EVAL(ac_assemble); then
625 $NM conftest.o >/dev/null 2>&1
627 if test "$gmp_rc" != "0"; then
628 echo "configure: $NM failure, using default"
631 if $NM conftest.o | grep gurkmacka >/dev/null; then true; else
632 gmp_cv_check_asm_lsym_prefix="$gmp_tmp_pre"
636 echo "configure: failed program was:" >&AC_FD_CC
637 cat conftest.s >&AC_FD_CC
643 echo ["define(<LSYM_PREFIX>, <${gmp_cv_check_asm_lsym_prefix}>)"] >> $gmp_tmpconfigm4
646 dnl GMP_CHECK_ASM_W32
647 dnl How to [define] a 32-bit word.
648 dnl Requires NM to be set to nm for target.
649 AC_DEFUN(GMP_CHECK_ASM_W32,
650 [AC_REQUIRE([GMP_CHECK_ASM_DATA])
651 AC_REQUIRE([GMP_CHECK_ASM_GLOBL])
652 AC_REQUIRE([GMP_CHECK_ASM_LABEL_SUFFIX])
653 AC_CACHE_CHECK([how to [define] a 32-bit word],
654 gmp_cv_check_asm_w32,
655 [if test -z "$NM"; then
656 echo; echo ["configure: $0: fatal: need nm"]
660 # FIXME: HPUX puts first symbol at 0x40000000, breaking our assumption
661 # that it's at 0x0. We'll have to declare another symbol before the
662 # .long/.word and look at the distance between the two symbols. The
663 # only problem is that the sed expression(s) barfs (on Solaris, for
664 # example) for the symbol with value 0. For now, HPUX uses .word.
668 gmp_cv_check_asm_w32=".word"
671 ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
672 for gmp_tmp_op in .long .word; do
673 cat > conftest.s <<EOF
674 $gmp_cv_check_asm_data
675 $gmp_cv_check_asm_globl foo
677 foo${gmp_cv_check_asm_label_suffix}
680 if AC_TRY_EVAL(ac_assemble); then
682 gmp_tmp_val=`$NM conftest.o | grep foo | sed -e 's;[[][0-9][]]\(.*\);\1;' \
683 -e 's;[^1-9]*\([0-9]*\).*;\1;'`
685 if test "$gmp_tmp_val" = "4"; then
686 gmp_cv_check_asm_w32="$gmp_tmp_op"
694 if test -z "$gmp_cv_check_asm_w32"; then
695 echo; echo ["configure: $0: fatal: do not know how to define a 32-bit word"]
700 echo ["define(<W32>, <$gmp_cv_check_asm_w32>)"] >> $gmp_tmpconfigm4
703 dnl GMP_CHECK_ASM_MMX([ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND]])
704 dnl Can we assemble MMX insns?
705 AC_DEFUN(GMP_CHECK_ASM_MMX,
706 [AC_REQUIRE([GMP_CHECK_ASM_TEXT])
707 AC_CACHE_CHECK([if the assembler knows about MMX instructions],
708 gmp_cv_check_asm_mmx,
709 [cat > conftest.s <<EOF
710 $gmp_cv_check_asm_text
713 ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
714 if AC_TRY_EVAL(ac_assemble); then
715 gmp_cv_check_asm_mmx=yes
717 gmp_cv_check_asm_mmx=no
721 if test "$gmp_cv_check_asm_mmx" = "yes"; then
722 ifelse([$1], , :, [$1])
724 AC_MSG_WARN([+----------------------------------------------------------])
725 AC_MSG_WARN([| WARNING WARNING WARNING])
726 AC_MSG_WARN([| Target CPU has MMX code, but it can't be assembled by])
727 AC_MSG_WARN([| $CCAS $CFLAGS])
728 AC_MSG_WARN([| Non-MMX replacements will be used.])
729 AC_MSG_WARN([| This will be an inferior build.])
730 AC_MSG_WARN([+----------------------------------------------------------])
731 ifelse([$2], , :, [$2])
735 dnl GMP_CHECK_ASM_SHLDL_CL([ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND]])
736 AC_DEFUN(GMP_CHECK_ASM_SHLDL_CL,
737 [AC_REQUIRE([GMP_CHECK_ASM_TEXT])
738 AC_CACHE_CHECK([if the assembler takes cl with shldl],
739 gmp_cv_check_asm_shldl_cl,
740 [cat > conftest.s <<EOF
741 $gmp_cv_check_asm_text
742 shldl %cl, %eax, %ebx
744 ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
745 if AC_TRY_EVAL(ac_assemble); then
746 gmp_cv_check_asm_shldl_cl=yes
748 gmp_cv_check_asm_shldl_cl=no
752 if test "$gmp_cv_check_asm_shldl_cl" = "yes"; then
753 ifelse([$1], , :, [$1])
755 ifelse([$2], , :, [$2])
759 dnl GMP_PROG_CC_WORKS(CC, CFLAGS, ACTION-IF-WORKS, [ACTION-IF-NOT-WORKS])
760 dnl Check if CC can compile and link. Perform various target specific tests.
761 dnl FIXME: Require `$target'.
762 AC_DEFUN(GMP_PROG_CC_WORKS,
763 [AC_LANG_C dnl Note: Destructive.
766 AC_MSG_CHECKING([if the C compiler ($CC) works with flags $CFLAGS])
768 # Simple test for all targets.
769 AC_TRY_COMPILER([int main(){return(0);}],
770 tmp_works, tmp_cross)
772 # Target specific tests.
773 if test "$tmp_works" = "yes"; then
775 *-*-aix*) # Returning a funcptr.
776 AC_TRY_COMPILE( , [} void *g(); void *f() { return g(); } int bar(){],
777 tmp_works=yes, tmp_works=no)
782 if test "$tmp_works" = "yes"; then
785 ifelse([$4], , :, [$4])
788 AC_MSG_RESULT($tmp_works)
794 dnl Setup to use ansi2knr if necessary.
796 dnl The test here is simply that if an ANSI style function works then
797 dnl ansi2knr isn't needed. The normal tests for whether $CC works mean we
798 dnl don't need to worry here about anything badly broken.
800 dnl AM_C_PROTOTYPES is the normal way to set up ansi2knr, but (in automake
801 dnl March 2000) it gives the wrong answer on a C++ compiler because its
802 dnl test requires that the compiler accept both ANSI and K&R, or otherwise
803 dnl ansi2knr is used. A C++ compiler fails on the K&R part, which makes
804 dnl AM_C_PROTOTYPES think it needs ansi2knr! GMP has no bare K&R so we
805 dnl only need ANSI or K&R to work, not both.
807 AC_DEFUN(GMP_C_ANSI2KNR,
808 [AC_CACHE_CHECK([if ansi2knr should be used],
810 [cat >conftest.c <<EOF
811 int main (int argc, char *argv[]) { return 0; }
813 if AC_TRY_EVAL(ac_compile); then
816 gmp_cv_c_ansi2knr=yes
820 if test $gmp_cv_c_ansi2knr = no; then
823 U=_ ANSI2KNR=./ansi2knr
824 # Ensure some checks needed by ansi2knr itself.
826 AC_CHECK_HEADERS(string.h)
833 dnl Deal with bad synchronization of Autoconf with Libtool.
834 AC_DEFUN(AC_CANONICAL_BUILD, [_AC_CANONICAL_BUILD])
835 AC_DEFUN(AC_CHECK_TOOL_PREFIX, [_AC_CHECK_TOOL_PREFIX])