* configure.in: Run ../bfd/configure.host before AC_PROG_CC.
[external/binutils.git] / opcodes / aclocal.m4
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 Find out if we are using GNU C, under whatever name.
23 dnl The semicolon is to pacify NeXT's syntax-checking cpp.
24 cat > conftest.c <<EOF
25 #ifdef __GNUC__
26   yes;
27 #endif
28 EOF
29 if ${CC-cc} -E conftest.c 2>&AC_FD_CC | egrep yes >/dev/null 2>&1; then
30   GCC=yes
31   if test "${CFLAGS+set}" != set; then
32     echo 'void f(){}' > conftest.c
33     if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
34       CFLAGS="-g -O"
35     else
36       CFLAGS="-O"
37     fi
38   fi
39 else
40   GCC=
41   test "${CFLAGS+set}" = set || CFLAGS="-g"
42 fi
43 rm -f conftest*
44 ])dnl
45 dnl