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( |
---|
66 | [main(){return(0);}], |
---|
67 | rtems_cv_prog_cc_works, rtems_cv_prog_cc_cross) |
---|
68 | AC_LANG_RESTORE |
---|
69 | AC_MSG_RESULT($rtems_cv_prog_cc_works) |
---|
70 | if test $rtems_cv_prog_cc_works = no; then |
---|
71 | AC_MSG_ERROR([installation or configuration problem: target C compiler cannot create executables.]) |
---|
72 | fi |
---|
73 | AC_MSG_CHECKING([whether the target C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler]) |
---|
74 | AC_MSG_RESULT($rtems_cv_prog_cc_cross) |
---|
75 | ]) |
---|