| 1 | dnl This file is included into all any other acinclude file that needs
|
|---|
| 2 | dnl to use these macros.
|
|---|
| 3 |
|
|---|
| 4 | dnl This is copied from autoconf 2.12, but does calls our own AC_PROG_CC_WORKS,
|
|---|
| 5 | dnl and doesn't call AC_PROG_CXX_GNU, cause we test for that in AC_PROG_CC_WORKS.
|
|---|
| 6 | dnl We are probably using a cross compiler, which will not be able to fully
|
|---|
| 7 | dnl link an executable. This should really be fixed in autoconf itself.
|
|---|
| 8 | dnl Find a working G++ cross compiler. This only works for the GNU C++ compiler.
|
|---|
| 9 | AC_DEFUN(CYG_AC_PROG_CXX_CROSS,
|
|---|
| 10 | [AC_BEFORE([$0], [AC_PROG_CXXCPP])
|
|---|
| 11 | AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
|
|---|
| 12 |
|
|---|
| 13 | CYG_AC_PROG_GXX_WORKS
|
|---|
| 14 |
|
|---|
| 15 | if test $ac_cv_prog_gxx = yes; then
|
|---|
| 16 | GXX=yes
|
|---|
| 17 | dnl Check whether -g works, even if CXXFLAGS is set, in case the package
|
|---|
| 18 | dnl plays around with CXXFLAGS (such as to build both debugging and
|
|---|
| 19 | dnl normal versions of a library), tasteless as that idea is.
|
|---|
| 20 | ac_test_CXXFLAGS="${CXXFLAGS+set}"
|
|---|
| 21 | ac_save_CXXFLAGS="$CXXFLAGS"
|
|---|
| 22 | CXXFLAGS=
|
|---|
| 23 | AC_PROG_CXX_G
|
|---|
| 24 | if test "$ac_test_CXXFLAGS" = set; then
|
|---|
| 25 | CXXFLAGS="$ac_save_CXXFLAGS"
|
|---|
| 26 | elif test $ac_cv_prog_cxx_g = yes; then
|
|---|
| 27 | CXXFLAGS="-g -O2"
|
|---|
| 28 | else
|
|---|
| 29 | CXXFLAGS="-O2"
|
|---|
| 30 | fi
|
|---|
| 31 | else
|
|---|
| 32 | GXX=
|
|---|
| 33 | test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
|
|---|
| 34 | fi
|
|---|
| 35 | ])
|
|---|
| 36 |
|
|---|
| 37 | dnl See if the G++ compiler we found works.
|
|---|
| 38 | AC_DEFUN(CYG_AC_PROG_GXX_WORKS,
|
|---|
| 39 | [AC_MSG_CHECKING([whether the G++ compiler ($CXX $CXXFLAGS $LDFLAGS) actually works])
|
|---|
| 40 | AC_LANG_SAVE
|
|---|
| 41 | AC_LANG_CPLUSPLUS
|
|---|
| 42 | dnl Try a test case. We only compile, because it's close to impossible
|
|---|
| 43 | dnl to get a correct fully linked executable with a cross compiler. For
|
|---|
| 44 | dnl most cross compilers, this test is bogus. For G++, we can use various
|
|---|
| 45 | dnl other compile line options to get a decent idea that the cross compiler
|
|---|
| 46 | dnl actually does work, even though we can't produce an executable without
|
|---|
| 47 | dnl more info about the target it's being compiled for. This only works
|
|---|
| 48 | dnl for the GNU C++ compiler.
|
|---|
| 49 |
|
|---|
| 50 | dnl Transform the name of the compiler to it's cross variant, unless
|
|---|
| 51 | dnl CXX is set. This is also what CXX gets set to in the generated
|
|---|
| 52 | dnl Makefile.
|
|---|
| 53 | if test x"${CXX}" = xc++ ; then
|
|---|
| 54 | CXX=`echo gcc | sed -e "${program_transform_name}"`
|
|---|
| 55 | fi
|
|---|
| 56 |
|
|---|
| 57 | dnl Get G++'s full path to libgcc.a
|
|---|
| 58 | libgccpath=`${CXX} --print-libgcc`
|
|---|
| 59 |
|
|---|
| 60 | dnl If we don't have a path with libgcc.a on the end, this isn't G++.
|
|---|
| 61 | if test `echo $libgccpath | sed -e 's:/.*/::'` = libgcc.a ; then
|
|---|
| 62 | ac_cv_prog_gxx=yes
|
|---|
| 63 | else
|
|---|
| 64 | ac_cv_prog_gxx=no
|
|---|
| 65 | fi
|
|---|
| 66 |
|
|---|
| 67 | dnl If we are using G++, look for the files that need to exist if this
|
|---|
| 68 | dnl compiler works.
|
|---|
| 69 | if test x"${ac_cv_prog_gxx}" = xyes ; then
|
|---|
| 70 | gccfiles=`echo $libgccpath | sed -e 's:/libgcc.a::'`
|
|---|
| 71 | if test -f ${gccfiles}/specs -a -f ${gccfiles}/cpp -a -f ${gccfiles}/cc1plus; then
|
|---|
| 72 | gccfiles=yes
|
|---|
| 73 | else
|
|---|
| 74 | gccfiles=no
|
|---|
| 75 | fi
|
|---|
| 76 | gcclibs=`echo $libgccpath | sed -e 's:lib/gcc-lib/::' -e 's:/libgcc.a::' -e 's,\(.*\)/.*,\1,g'`/lib
|
|---|
| 77 | if test -d ${gcclibs}/ldscripts -a -f ${gcclibs}/libc.a -a -f ${gcclibs}/libstdc++.a ; then
|
|---|
| 78 | gcclibs=yes
|
|---|
| 79 | else
|
|---|
| 80 | gcclibs=no
|
|---|
| 81 | fi
|
|---|
| 82 | fi
|
|---|
| 83 |
|
|---|
| 84 | dnl If everything is OK, then we can safely assume the compiler works.
|
|---|
| 85 | if test x"${gccfiles}" = xno -o x"${gcclibs}" = xno; then
|
|---|
| 86 | ac_cv_prog_cxx_works=no
|
|---|
| 87 | AC_MSG_ERROR(${CXX} is a non-working cross compiler)
|
|---|
| 88 | else
|
|---|
| 89 | ac_cv_prog_cxx_works=yes
|
|---|
| 90 | fi
|
|---|
| 91 |
|
|---|
| 92 | AC_LANG_RESTORE
|
|---|
| 93 | AC_MSG_RESULT($ac_cv_prog_cxx_works)
|
|---|
| 94 | if test x"$ac_cv_prog_cxx_works" = xno; then
|
|---|
| 95 | AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.])
|
|---|
| 96 | fi
|
|---|
| 97 | AC_MSG_CHECKING([whether the G++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler])
|
|---|
| 98 | AC_MSG_RESULT($ac_cv_prog_cxx_cross)
|
|---|
| 99 | cross_compiling=$ac_cv_prog_cxx_cross
|
|---|
| 100 | AC_SUBST(CXX)
|
|---|
| 101 | ])
|
|---|
| 102 |
|
|---|
| 103 | dnl ====================================================================
|
|---|
| 104 | dnl Find a working GCC cross compiler. This only works for the GNU gcc compiler.
|
|---|
| 105 | dnl This is based on the macros above for G++.
|
|---|
| 106 | AC_DEFUN(CYG_AC_PROG_CC_CROSS,
|
|---|
| 107 | [AC_BEFORE([$0], [AC_PROG_CCPP])
|
|---|
| 108 | AC_CHECK_PROGS(CC, cc, gcc)
|
|---|
|
|---|