autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How AC_PROG_CC find the cross-compiler?


From: Tzu-Chien Chiu
Subject: How AC_PROG_CC find the cross-compiler?
Date: Tue, 25 Jul 2006 20:57:09 +0800

Hello, everyone.

I'm on cygwin. autoconf 2.59. aclocal 1.9.6.

The problem is that 'configure' script incorrectly finds the host C
compiler (gcc) when the cross compiler (or32-elf-gcc) should be found.

The content of 'configure.ac' is:

AC_PREREQ(2.59)

AC_INIT(foo, 1,0)
set -x -v
AC_CANONICAL_SYSTEM
AC_PROG_CC
set +x +v

The cross compiler is called 'or32-elf-gcc', and it's installed in
'/usr/local/cross/bin'. /usr/local/cross/bin is also in the PATH
environment variable.

$ aclocal
/usr/share/aclocal/pstoedit.m4:7: warning: underquoted definition of
AM_PATH_PSTOEDIT
 run info '(automake)Extending aclocal'
 or see http://sources.redhat.com/automake/automake.html#Extending-aclocal
/usr/share/aclocal/libsmi.m4:8: warning: underquoted definition of
AM_PATH_LIBSMI
/usr/share/aclocal/libmcrypt.m4:17: warning: underquoted definition of
AM_PATH_LIBMCRYPT
/usr/share/aclocal/cppunit.m4:4: warning: underquoted definition of
AM_PATH_CPPUNIT
$ autoconf
$ ./configure --target=or32-elf
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking target system type... or32-unknown-elf
checking for gcc... gcc

In 'configure', AC_CANONICAL_SYSTEM produces:
 ac_cv_target_alias=or32-elf
 program_prefix=or32-elf

I guess AC_PROG_CC should prefix 'gcc' with 'ac_cv_target_alias' to
find the C compiler, isn't it?

But it didn't. From the code snippet in /usr/share/autoconf/autoconf/c.m4:

# AC_PROG_CC([COMPILER ...])
# --------------------------
# COMPILER ... is a space separated list of C compilers to search for.
# This just gives the user an opportunity to specify an alternative
# search list for the C compiler.
AN_MAKEVAR([CC],  [AC_PROG_CC])
AN_PROGRAM([cc],  [AC_PROG_CC])
AN_PROGRAM([gcc], [AC_PROG_CC])
AC_DEFUN([AC_PROG_CC],
[AC_LANG_PUSH(C)dnl
AC_ARG_VAR([CC],     [C compiler command])dnl
AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
_AC_ARG_VAR_LDFLAGS()dnl
_AC_ARG_VAR_CPPFLAGS()dnl
m4_ifval([$1],
     [AC_CHECK_TOOLS(CC, [$1])],
[AC_CHECK_TOOL(CC, gcc)
if test -z "$CC"; then
 AC_CHECK_TOOL(CC, cc)
fi
if test -z "$CC"; then
 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
fi
if test -z "$CC"; then
 AC_CHECK_TOOLS(CC, cl)
fi
])

--
Tzu-Chien Chiu
URL: http://www.csie.nctu.edu.tw/~jwchiu/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]