2 # Copyright (C) 2013-2015 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Check that uses of the obsolescent AM_PROG_CC_C_O macro doesn't
18 # cause spurious warnings or errors. Suggested by Eric Blake.
20 # We need gcc for for two reasons:
21 # 1. to ensure our C compiler grasps "-c -o" together.
22 # 2. to be able to later fake a dumb compiler not grasping that
23 # (done with 'cc-no-c-o' script below, which required gcc).
27 echo bin_PROGRAMS
= foo
> Makefile.am
28 echo 'int main (void) { return 0; }' > foo.c
30 cp configure.ac configure.bak
32 cat > acinclude.
m4 <<'END'
33 AC_DEFUN([AM_TWEAKED_OUTPUT], [
35 printf "CC = '%s'\\n" "$CC"
36 # Make sure that $CC can be used after AM_PROG_CC_C_O.
37 $CC --version || exit 1
39 # $CC rewrite should only take place on time.
41 *" compile"*" compile"*) AC_MSG_ERROR([CC rewritten twice]);;
49 cat configure.bak
- > configure.ac
<< 'END'
50 dnl It
's OK to call AM_PROG_CC_C_O after AC_PROG_CC.
58 $AUTOMAKE --add-missing
60 ./configure >stdout || { cat stdout; exit 1; }
62 if test "$AM_TESTSUITE_SIMULATING_NO_CC_C_O" != no; then
63 $EGREP 'understands?
-c and
-o together.
* no$
' stdout
65 $EGREP 'understands?
-c and
-o together.
* yes$
' stdout
68 # No repeated checks please.
69 test $(grep -c ".*-c['\" ].
*-o['\" ]" stdout) -eq 1
72 $MAKE maintainer-clean
73 rm -rf autom4te*.cache
77 cat configure.bak - > configure.ac << 'END
'
78 dnl It's also OK to call AM_PROG_CC_C_O
*before
* AC_PROG_CC.
86 $AUTOMAKE --add-missing
88 .
/configure
>stdout ||
{ cat stdout
; exit 1; }
90 if test "$AM_TESTSUITE_SIMULATING_NO_CC_C_O" != no
; then
91 $EGREP 'understands? -c and -o together.* no$' stdout
93 $EGREP 'understands? -c and -o together.* yes$' stdout
96 # Repeated checks are OK in this case, but should be cached.
97 test $
(grep ".*-c['\" ].*-o['\" ]" stdout \
98 |
$FGREP -v ' (cached) ' |
wc -l) -eq 1
101 $MAKE maintainer-clean
102 rm -rf autom4te
*.cache
106 cat configure.bak
- > configure.ac
<< 'END'
107 dnl It
's also OK to call AM_PROG_CC_C_O *without* AC_PROG_CC.
114 $AUTOMAKE --add-missing
116 # Make sure the compiler doesn't understand
'-c -o'
117 CC
=$am_testaux_builddir/cc-no-c-o
; export CC
119 .
/configure
>stdout ||
{ cat stdout
; exit 1; }
121 $EGREP 'understands? -c and -o together.* no$' stdout
122 # No repeated checks please.
123 test $
(grep -c ".*-c['\" ].*-o['\" ]" stdout
) -eq 1