[51c195d5] | 1 | dnl |
---|
| 2 | dnl $Id$ |
---|
| 3 | dnl |
---|
| 4 | dnl Check for target gcc |
---|
| 5 | dnl |
---|
| 6 | dnl Adaptation of autoconf-2.12's AC_PROG_CC to rtems |
---|
| 7 | dnl |
---|
| 8 | dnl 98/02/10 Ralf Corsepius (corsepiu@faw.uni-ulm.de) |
---|
| 9 | dnl |
---|
| 10 | |
---|
| 11 | AC_DEFUN(RTEMS_PROG_CC, |
---|
| 12 | [ |
---|
| 13 | AC_BEFORE([$0], [AC_PROG_CPP])dnl |
---|
| 14 | AC_BEFORE([$0], [AC_PROG_CC])dnl |
---|
| 15 | AC_CHECK_PROG(CC, gcc, gcc) |
---|
| 16 | if test -z "$CC"; then |
---|
| 17 | AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc) |
---|
| 18 | test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH]) |
---|
| 19 | fi |
---|
| 20 | |
---|
| 21 | RTEMS_PROG_CC_WORKS |
---|
| 22 | AC_PROG_CC_GNU |
---|
| 23 | |
---|
| 24 | if test $ac_cv_prog_gcc = yes; then |
---|
| 25 | GCC=yes |
---|
| 26 | dnl Check whether -g works, even if CFLAGS is set, in case the package |
---|
| 27 | dnl plays around with CFLAGS (such as to build both debugging and |
---|
| 28 | dnl normal versions of a library), tasteless as that idea is. |
---|
| 29 | ac_test_CFLAGS="${CFLAGS+set}" |
---|
| 30 | ac_save_CFLAGS="$CFLAGS" |
---|
| 31 | CFLAGS= |
---|
| 32 | AC_PROG_CC_G |
---|
| 33 | if test "$ac_test_CFLAGS" = set; then |
---|
| 34 | CFLAGS="$ac_save_CFLAGS" |
---|
| 35 | elif test $ac_cv_prog_cc_g = yes; then |
---|
| 36 | CFLAGS="-g -O2" |
---|
| 37 | else |
---|
| 38 | CFLAGS="-O2" |
---|
| 39 | fi |
---|
| 40 | else |
---|
| 41 | GCC= |
---|
| 42 | test "${CFLAGS+set}" = set || CFLAGS="-g" |
---|
| 43 | fi |
---|
| 44 | |
---|
| 45 | CC_FOR_TARGET=$CC |
---|
| 46 | rtems_cv_prog_gcc=$ac_cv_prog_gcc |
---|
| 47 | rtems_cv_prog_cc_g=$ac_cv_prog_cc_g |
---|
| 48 | |
---|
| 49 | dnl restore initial values |
---|
| 50 | unset CC |
---|
| 51 | unset ac_cv_prog_gcc |
---|
| 52 | unset ac_cv_prog_cc_g |
---|
| 53 | unset ac_cv_prog_CC |
---|
| 54 | ]) |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | dnl Almost identical to AC_PROG_CC_WORKS |
---|
| 58 | dnl added malloc to program fragment, because rtems has its own malloc |
---|
| 59 | dnl which is not available while bootstrapping rtems |
---|
| 60 | |
---|
| 61 | AC_DEFUN(RTEMS_PROG_CC_WORKS, |
---|
| 62 | [AC_MSG_CHECKING([whether the target C compiler ($CC $CFLAGS $LDFLAGS) works]) |
---|
| 63 | AC_LANG_SAVE |
---|
| 64 | AC_LANG_C |
---|
| 65 | AC_TRY_COMPILER( |
---|
[5b3cf09] | 66 | [ |
---|
| 67 | #if defined(__PPC__) |
---|
| 68 | int __SDATA_START__; int __SDATA2_START__; |
---|
| 69 | int __GOT_START__; int __GOT_END__; |
---|
| 70 | int __GOT2_START__; int __GOT2_END__; |
---|
| 71 | int __SBSS_END__; int __SBSS2_END__; |
---|
| 72 | int __FIXUP_START__; int __FIXUP_END__; |
---|
| 73 | int __EXCEPT_START__; int __EXCEPT_END__; |
---|
| 74 | int __init; int __fini; |
---|
| 75 | #endif |
---|
| 76 | #if defined(__hppa__) |
---|
| 77 | asm ( ".subspa \$GLOBAL\$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=40"); |
---|
| 78 | asm ( ".export \$global\$" ); |
---|
| 79 | asm ( "\$global\$:"); |
---|
| 80 | #endif |
---|
| 81 | int atexit() { return 0; } |
---|
| 82 | void *malloc() { return 0; } |
---|
[51c195d5] | 83 | main(){return(0);}], |
---|
| 84 | rtems_cv_prog_cc_works, rtems_cv_prog_cc_cross) |
---|
| 85 | AC_LANG_RESTORE |
---|
| 86 | AC_MSG_RESULT($rtems_cv_prog_cc_works) |
---|
| 87 | if test $rtems_cv_prog_cc_works = no; then |
---|
| 88 | AC_MSG_ERROR([installation or configuration problem: target C compiler cannot create executables.]) |
---|
| 89 | fi |
---|
| 90 | AC_MSG_CHECKING([whether the target C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler]) |
---|
| 91 | AC_MSG_RESULT($rtems_cv_prog_cc_cross) |
---|
| 92 | ]) |
---|