| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # Copyright (C) 2013-2025 Free Software Foundation, Inc. |
| 3 | # |
| 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) |
| 7 | # any later version. |
| 8 | # |
| 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. |
| 13 | # |
| 14 | # You should have received a copy of the GNU General Public License |
| 15 | # along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | |
| 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. |
| 19 | |
| 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). |
| 24 | required=gcc |
| 25 | . test-init.shscip-shell source . . `test-init.sh`. |
| 26 | |
| 27 | echoscip-shell system . . echo. bin_PROGRAMS = foo > Makefile.am |
| 28 | echoscip-shell system . . echo. 'int main (void) { return 0; }' > foo.c |
| 29 | |
| 30 | cpscip-shell system . . cp. configure.ac configure.bak |
| 31 | |
| 32 | catscip-shell system . . cat. > acinclude.m4 <<'END' |
| 33 | AC_DEFUN([AM_TWEAKED_OUTPUT], [ |
| 34 | # For debugging. |
| 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 |
| 38 | $CC -v || exit 1 |
| 39 | # $CC rewrite should only take place on time. |
| 40 | case " $CC " in |
| 41 | *" compile"*" compile"*) AC_MSG_ERROR([CC rewritten twice]);; |
| 42 | esac |
| 43 | AC_OUTPUT |
| 44 | ]) |
| 45 | END |
| 46 | |
| 47 | # --- |
| 48 | |
| 49 | catscip-shell system . . cat. configure.bak - > configure.ac << 'END' |
| 50 | dnl It's OK to call AM_PROG_CC_C_O after AC_PROG_CC. |
| 51 | AC_PROG_CC |
| 52 | AM_PROG_CC_C_O |
| 53 | AM_TWEAKED_OUTPUT |
| 54 | END |
| 55 | |
| 56 | $ACLOCAL |
| 57 | $AUTOCONF |
| 58 | $AUTOMAKE --add-missing |
| 59 | |
| 60 | ./configure >stdout || { catscip-shell system . . cat. stdout; exit 1; } |
| 61 | catscip-shell system . . cat. stdout |
| 62 | if testscip-shell system . . test. "$AM_TESTSUITE_SIMULATING_NO_CC_C_O" != no; then |
| 63 | $EGREP 'understands? -c and -o together.* no$' stdout |
| 64 | else |
| 65 | $EGREP 'understands? -c and -o together.* yes$' stdout |
| 66 | fi |
| 67 | |
| 68 | # No repeated checks please. |
| 69 | testscip-shell system . . test. $(grepscip-shell system . . grep. -c ".*-c['\" ].*-o['\" ]" stdout) -eq 1 |
| 70 | |
| 71 | $MAKE |
| 72 | $MAKE maintainer-clean |
| 73 | rmscip-shell system . . rm. -rf autom4te*.cache |
| 74 | |
| 75 | # --- |
| 76 | |
| 77 | catscip-shell system . . cat. configure.bak - > configure.ac << 'END' |
| 78 | dnl It's also OK to call AM_PROG_CC_C_O *before* AC_PROG_CC. |
| 79 | AM_PROG_CC_C_O |
| 80 | AC_PROG_CC |
| 81 | AM_TWEAKED_OUTPUT |
| 82 | END |
| 83 | |
| 84 | $ACLOCAL |
| 85 | $AUTOCONF |
| 86 | $AUTOMAKE --add-missing |
| 87 | |
| 88 | ./configure >stdout || { catscip-shell system . . cat. stdout; exit 1; } |
| 89 | catscip-shell system . . cat. stdout |
| 90 | if testscip-shell system . . test. "$AM_TESTSUITE_SIMULATING_NO_CC_C_O" != no; then |
| 91 | $EGREP 'understands? -c and -o together.* no$' stdout |
| 92 | else |
| 93 | $EGREP 'understands? -c and -o together.* yes$' stdout |
| 94 | fi |
| 95 | |
| 96 | # Repeated checks are OK in this case, but should be cached. |
| 97 | testscip-shell system . . test. $(grepscip-shell system . . grep. ".*-c['\" ].*-o['\" ]" stdout \ |
| 98 | | $FGREP -v ' (cached) ' | wc -l) -eq 1 |
| 99 | |
| 100 | $MAKE |
| 101 | $MAKE maintainer-clean |
| 102 | rmscip-shell system . . rm. -rf autom4te*.cache |
| 103 | |
| 104 | # --- |
| 105 | |
| 106 | catscip-shell system . . cat. configure.bak - > configure.ac << 'END' |
| 107 | dnl It's also OK to call AM_PROG_CC_C_O *without* AC_PROG_CC. |
| 108 | AM_PROG_CC_C_O |
| 109 | AM_TWEAKED_OUTPUT |
| 110 | END |
| 111 | |
| 112 | $ACLOCAL |
| 113 | $AUTOCONF |
| 114 | $AUTOMAKE --add-missing |
| 115 | |
| 116 | # Make sure the compiler doesn't understand '-c -o' |
| 117 | CC=$am_testaux_builddir/cc-no-c-o; export CC |
| 118 | |
| 119 | ./configure >stdout || { catscip-shell system . . cat. stdout; exit 1; } |
| 120 | catscip-shell system . . cat. stdout |
| 121 | $EGREP 'understands? -c and -o together.* no$' stdout |
| 122 | # No repeated checks please. |
| 123 | testscip-shell system . . test. $(grepscip-shell system . . grep. -c ".*-c['\" ].*-o['\" ]" stdout) -eq 1 |
| 124 | $MAKE |
| 125 | |
| 126 | : |