| 1 | dnl |
| 2 | dnl This ugly hack is needed because the Cygnus configure script won't |
| 3 | dnl tell us what CC is going to be, and "cc" isn't always right. (The |
| 4 | dnl top-level Makefile will always override anything we choose here, so |
| 5 | dnl the usual gcc/cc selection is useless.) |
| 6 | dnl |
| 7 | dnl It knows where it is in the tree; don't try using it elsewhere. |
| 8 | dnl |
| 9 | undefine([AC_PROG_CC])dnl |
| 10 | AC_DEFUN(AC_PROG_CC, |
| 11 | [AC_BEFORE([$0], [AC_PROG_CPP])dnl |
| 12 | dnl |
| 13 | dnl The ugly bit... |
| 14 | dnl |
| 15 | AC_MSG_CHECKING([for CC]) |
| 16 | dnl Don't bother with cache. |
| 17 | test -z "$CC" && CC=`egrep '^CC *=' ../Makefile | tail -1 | sed 's/^CC *= *//'` |
| 18 | test -z "$CC" && CC=cc |
| 19 | AC_MSG_RESULT(setting CC to $CC) |
| 20 | AC_SUBST(CC) |
| 21 | dnl |
| 22 | dnl |
| 23 | # Find out if we are using GNU C, under whatever name. |
| 24 | cat > conftest.c <<EOF |
| 25 | #ifdef __GNUC__ |
| 26 | yes |
| 27 | #endif |
| 28 | EOF |
| 29 | ${CC-cc} -E conftest.c > conftest.out 2>&1 |
| 30 | if egrep yes conftest.out >/dev/null 2>&1; then |
| 31 | GCC=yes |
| 32 | else |
| 33 | GCC= |
| 34 | fi |
| 35 | rm -f conftest* |
| 36 | ])dnl |
| 37 | dnl |
| 38 | dnl GAS_CHECK_DECL_NEEDED(name, typedefname, typedef, headers) |
| 39 | AC_DEFUN(GAS_CHECK_DECL_NEEDED,[ |
| 40 | AC_MSG_CHECKING(whether declaration is required for $1) |
| 41 | AC_CACHE_VAL(gas_cv_decl_needed_$1, |
| 42 | AC_TRY_LINK([$4], |
| 43 | [ |
| 44 | typedef $3; |
| 45 | $2 x; |
| 46 | x = ($2) $1; |
| 47 | ], gas_cv_decl_needed_$1=no, gas_cv_decl_needed_$1=yes))dnl |
| 48 | AC_MSG_RESULT($gas_cv_decl_needed_$1) |
| 49 | test $gas_cv_decl_needed_$1 = no || { |
| 50 | ifelse(index($1,[$]),-1, |
| 51 | [AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]))], |
| 52 | [gas_decl_name_upcase=`echo $1 | tr '[a-z]' '[A-Z]'` |
| 53 | AC_DEFINE_UNQUOTED(NEED_DECLARATION_$gas_decl_name_upcase)]) |
| 54 | } |
| 55 | ])dnl |
| 56 | dnl |
| 57 | dnl Some non-ANSI preprocessors botch requoting inside strings. That's bad |
| 58 | dnl enough, but on some of those systems, the assert macro relies on requoting |
| 59 | dnl working properly! |
| 60 | dnl GAS_WORKING_ASSERT |
| 61 | AC_DEFUN(GAS_WORKING_ASSERT, |
| 62 | [AC_MSG_CHECKING([for working assert macro]) |
| 63 | AC_CACHE_VAL(gas_cv_assert_ok, |
| 64 | AC_TRY_LINK([#include <assert.h> |
| 65 | #include <stdio.h>], [ |
| 66 | /* check for requoting problems */ |
| 67 | static int a, b, c, d; |
| 68 | static char *s; |
| 69 | assert (!strcmp(s, "foo bar baz quux")); |
| 70 | /* check for newline handling */ |
| 71 | assert (a == b |
| 72 | || c == d); |
| 73 | ], gas_cv_assert_ok=yes, gas_cv_assert_ok=no))dnl |
| 74 | AC_MSG_RESULT($gas_cv_assert_ok) |
| 75 | test $gas_cv_assert_ok = yes || AC_DEFINE(BROKEN_ASSERT) |
| 76 | ])dnl |