2 # Copyright (C) 2013 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 >> configure.ac << 'END'
33 # Since AM_PROG_CC_C_O rewrites $CC, it's an error to call AC_PROG_CC
39 $ACLOCAL -Wnone 2>stderr && { cat stderr >&2; exit 1; }
41 grep '^configure\.ac:7:.* AC_PROG_CC .*called after AM_PROG_CC_C_O' stderr
43 cat configure.bak - > configure.ac << 'END'
44 dnl It's OK to call AM_PROG_CC_C_O after AC_PROG_CC.
47 # Make sure that $CC can be used after AM_PROG_CC_C_O.
48 $CC --version || exit 1
55 $AUTOMAKE --add-missing
57 ./configure >stdout || { cat stdout; exit 1; }
59 grep 'understands -c and -o together.* yes$' stdout
60 # No repeated checks please.
61 test $(grep -c ".*-c['\" ].*-o['\" ]" stdout) -eq 1
64 $MAKE maintainer-clean
66 rm -rf autom4te*.cache
68 cat configure.bak - > configure.ac << 'END'
69 dnl It's also OK to call AM_PROG_CC_C_O *without* AC_PROG_CC.
71 # Make sure that $CC can be used after AM_PROG_CC_C_O.
72 $CC --version || exit 1
79 $AUTOMAKE --add-missing
81 # Make sure the compiler doesn't understand '-c -o'
82 CC=$am_testaux_builddir/cc-no-c-o; export CC
84 ./configure >stdout || { cat stdout; exit 1; }
86 grep 'understands -c and -o together.* no$' stdout
87 # No repeated checks please.
88 test $(grep -c ".*-c['\" ].*-o['\" ]" stdout) -eq 1