• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Check for the extension used for executables on build platform.
2# This is necessary for cross-compiling where the build platform
3# may differ from the host platform.
4AC_DEFUN([AC_BUILD_EXEEXT],
5[
6AC_MSG_CHECKING([for executable suffix on build platform])
7AC_CACHE_VAL(ac_cv_build_exeext,
8[if test "$CYGWIN" = yes || test "$MINGW32" = yes; then
9  ac_cv_build_exeext=.exe
10else
11  ac_build_prefix=${build_alias}-
12
13  AC_CHECK_PROG(BUILD_CC, ${ac_build_prefix}gcc, ${ac_build_prefix}gcc)
14  if test -z "$BUILD_CC"; then
15     AC_CHECK_PROG(BUILD_CC, gcc, gcc)
16     if test -z "$BUILD_CC"; then
17       AC_CHECK_PROG(BUILD_CC, cc, cc, , , /usr/ucb/cc)
18     fi
19  fi
20  test -z "$BUILD_CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
21  ac_build_link='${BUILD_CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&AS_MESSAGE_LOG_FD'
22  rm -f conftest*
23  echo 'int main () { return 0; }' > conftest.$ac_ext
24  ac_cv_build_exeext=
25  if AC_TRY_EVAL(ac_build_link); then
26    for file in conftest.*; do
27      case $file in
28      *.c | *.o | *.obj | *.dSYM) ;;
29      *) ac_cv_build_exeext=`echo $file | sed -e s/conftest//` ;;
30      esac
31    done
32  else
33    AC_MSG_ERROR([installation or configuration problem: compiler cannot create executables.])
34  fi
35  rm -f conftest*
36  test x"${ac_cv_build_exeext}" = x && ac_cv_build_exeext=blank
37fi])
38BUILD_EXEEXT=""
39test x"${ac_cv_build_exeext}" != xblank && BUILD_EXEEXT=${ac_cv_build_exeext}
40AC_MSG_RESULT(${ac_cv_build_exeext})
41ac_build_exeext=$BUILD_EXEEXT
42AC_SUBST(BUILD_EXEEXT)])
43