[51c195d5] | 1 | dnl |
---|
| 2 | dnl $Id$ |
---|
| 3 | dnl |
---|
| 4 | dnl Check for target g++ |
---|
| 5 | dnl |
---|
| 6 | dnl Adaptation of autoconf-2.12's AC_PROG_CXX to rtems |
---|
| 7 | dnl |
---|
| 8 | dnl 98/02/10 Ralf Corsepius (corsepiu@faw.uni-ulm.de) |
---|
| 9 | dnl |
---|
| 10 | |
---|
| 11 | AC_DEFUN(RTEMS_PROG_CXX, |
---|
| 12 | [ |
---|
| 13 | AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl |
---|
| 14 | AC_BEFORE([$0], [AC_PROG_CXX])dnl |
---|
| 15 | AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++, gcc) |
---|
| 16 | |
---|
| 17 | RTEMS_PROG_CXX_WORKS |
---|
| 18 | AC_PROG_CXX_GNU |
---|
| 19 | |
---|
| 20 | if test $ac_cv_prog_gxx = yes; then |
---|
| 21 | GXX=yes |
---|
| 22 | dnl Check whether -g works, even if CXXFLAGS is set, in case the package |
---|
| 23 | dnl plays around with CXXFLAGS (such as to build both debugging and |
---|
| 24 | dnl normal versions of a library), tasteless as that idea is. |
---|
| 25 | ac_test_CXXFLAGS="${CXXFLAGS+set}" |
---|
| 26 | ac_save_CXXFLAGS="$CXXFLAGS" |
---|
| 27 | CXXFLAGS= |
---|
| 28 | AC_PROG_CXX_G |
---|
| 29 | if test "$ac_test_CXXFLAGS" = set; then |
---|
| 30 | CXXFLAGS="$ac_save_CXXFLAGS" |
---|
| 31 | elif test $ac_cv_prog_cxx_g = yes; then |
---|
| 32 | CXXFLAGS="-g -O2" |
---|
| 33 | else |
---|
| 34 | CXXFLAGS="-O2" |
---|
| 35 | fi |
---|
| 36 | else |
---|
| 37 | GXX= |
---|
| 38 | test "${CXXFLAGS+set}" = set || CXXFLAGS="-g" |
---|
| 39 | fi |
---|
| 40 | CXX_FOR_TARGET=$CXX |
---|
| 41 | |
---|
| 42 | dnl restore initial values |
---|
| 43 | unset CXX |
---|
| 44 | unset ac_cv_prog_gxx |
---|
| 45 | ]) |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | dnl Almost identical to AC_PROG_CXX_WORKS |
---|
| 49 | dnl Additional handling of malloc |
---|
| 50 | dnl NOTE: using newlib with a native compiler is cross-compiling, indeed. |
---|
| 51 | AC_DEFUN(RTEMS_PROG_CXX_WORKS, |
---|
| 52 | [AC_MSG_CHECKING([whether the target C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works]) |
---|
| 53 | AC_LANG_SAVE |
---|
| 54 | AC_LANG_CPLUSPLUS |
---|
| 55 | |
---|
| 56 | dnl this fails if rtems uses newlib, because rtems has its own malloc which |
---|
| 57 | dnl is not available at bootstrap |
---|
| 58 | AC_TRY_COMPILER( |
---|
| 59 | [main(){return(0);}], |
---|
| 60 | rtems_cv_prog_cxx_works, rtems_cv_prog_cxx_cross) |
---|
| 61 | if test "$rtems_cv_prog_cxx_works" = "no"; then |
---|
| 62 | dnl now retry with our own version of malloc |
---|
| 63 | AC_TRY_COMPILER( |
---|
[5b3cf09] | 64 | [extern "C" void *malloc(); void *malloc() { return (0); } |
---|
| 65 | extern "C" int atexit(); int atexit() { return 0; } |
---|
| 66 | #if defined(__PPC__) |
---|
| 67 | int __SDATA_START__; int __SDATA2_START__; |
---|
| 68 | int __GOT_START__; int __GOT_END__; |
---|
| 69 | int __GOT2_START__; int __GOT2_END__; |
---|
| 70 | int __SBSS_END__; int __SBSS2_END__; |
---|
| 71 | int __FIXUP_START__; int __FIXUP_END__; |
---|
| 72 | int __EXCEPT_START__; int __EXCEPT_END__; |
---|
| 73 | int __init; int __fini; |
---|
| 74 | #endif |
---|
| 75 | #if defined(__hppa__) |
---|
| 76 | asm ( ".subspa \$GLOBAL\$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=40"); |
---|
| 77 | asm ( ".export \$global\$" ); |
---|
| 78 | asm ( "\$global\$:"); |
---|
| 79 | #endif |
---|
| 80 | |
---|
[51c195d5] | 81 | main(){return(0);}], |
---|
| 82 | rtems_cv_prog_cxx_works, rtems_cv_prog_cxx_cross) |
---|
| 83 | fi |
---|
| 84 | AC_LANG_RESTORE |
---|
| 85 | AC_MSG_RESULT($rtems_cv_prog_cxx_works) |
---|
| 86 | if test $rtems_cv_prog_cxx_works = no; then |
---|
| 87 | AC_MSG_ERROR([installation or configuration problem: target C++ compiler cannot create executables.]) |
---|
| 88 | fi |
---|
| 89 | AC_MSG_CHECKING([whether the target C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler]) |
---|
| 90 | AC_MSG_RESULT($rtems_cv_prog_cxx_cross) |
---|
| 91 | ]) |
---|