1#! /bin/sh 2# Copyright (C) 2012-2021 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 $(am__make_dryrun) works as expected. 18 19. test-init.sh 20 21plan_ 60 22 23if echo "all: ; +@printf %sbb%s aa cc" | $MAKE -n -f - | grep aabbcc; then 24 make_plus_silence () { return 0; } 25else 26 make_plus_silence () { return 1; } 27fi 28 29mkdir none # Also used later. 30if echo nil: | $MAKE -I none -f -; then 31 make_supports_option_I () { return 0; } 32else 33 make_supports_option_I () { return 1; } 34fi 35 36echo AC_OUTPUT >> configure.ac 37 38cat > Makefile.am <<'END' 39all: 40 : Dummy, nothing to do. 41run: 42 @echo ":: $$MAKEFLAGS :: $$MFLAGS ::" ;: For debugging. 43 $(am__make_dryrun) && exit 1; echo ok > from-run 44dry: 45 +@echo ":: $$MAKEFLAGS :: $$MFLAGS ::" ;: For debugging. 46 +$(am__make_dryrun) || exit 1; echo ok > from-dry 47END 48 49check_make () 50{ 51 msg= mode= condition=: directive= reason= skip_reason= 52 case $1 in 53 --dry) mode=dry;; 54 --run) mode=run;; 55 *) fatal_ "check_run: invalid usage";; 56 esac 57 shift 58 while test $# -gt 0; do 59 case $1 in 60 -C) condition=$2 skip_reason=$3; shift; shift;; 61 -M) msg=$2; shift;; 62 --) shift; break;; 63 *) break;; 64 esac 65 shift 66 done 67 for opts in '' '-s' '-s -r'; do 68 r=ok 69 pmsg=${mode}${msg:+" [$msg]"}${opts:+" ($opts)"} 70 if $condition; then 71 $MAKE $opts "$mode" ${1+"$@"} || r='not ok' 72 test -f from-$mode || r='not ok' 73 test ! -e bad || r='not ok' 74 rm -f bad from-* || fatal_ "cleaning up" 75 else 76 directive=SKIP reason=$skip_reason 77 fi 78 result_ "$r" -D "$directive" -r "$reason" "$pmsg" 79 done 80 unset r msg pmsg opts mode condition directive reason skip_reason 81} 82 83# ---------------------------------------------------------------------- 84 85$ACLOCAL || fatal_ "aclocal failed" 86$AUTOCONF || fatal_ "autoconf failed" 87$AUTOMAKE || fatal_ "automake failed" 88./configure || fatal_ "configure failed" 89 90# ---------------------------------------------------------------------- 91 92check_make --run 93 94# Test against a known regression. This was especially heinous, since 95# make running in normal mode was sometimes mistaken for make running 96# in dry mode. 97check_make --run TESTS="n1.test n2.test" 98check_make --run TESTS="n1 n2" AM_MAKEFLAGS="TESTS='n1 n2'" 99check_make --run TESTS="n1 n2" AM_MAKEFLAGS='TESTS="n1 n2"' 100check_make --run FOOFLAGS="-n -n -knf2 n --none -n" 101check_make --run MYFLAGS="-n --dryrun -n --dry-run -n" 102 103# ---------------------------------------------------------------------- 104 105check_make --dry -C make_plus_silence 'recipe prefix "+" unsupported' -n 106check_make --dry -C using_gmake "\$MAKE is not GNU make" --dry-run -k 107 108# ---------------------------------------------------------------------- 109 110# Automake bug#13760: the "n" in "none" used to confound am__make_dryrun 111# into thinking the '-n' option had been passed. 112 113pr='bug#13760' 114 115check_make --run -C make_supports_option_I "-I make option unsupported" \ 116 -M "$pr" -I none 117 118check_make --run -C using_gmake "\$MAKE is not GNU make" \ 119 -M "$pr" -I none --include dry-run 120 121check_make --dry -C make_supports_option_I "-I make option unsupported" \ 122 -M "$pr" -I none -n 123 124check_make --dry -C using_gmake "\$MAKE is not GNU make" \ 125 -M "$pr" --dry-run -I none --include dry-run 126 127# ---------------------------------------------------------------------- 128 129# Test for when shell metacharacters or backslashes are in $(MAKEFLAGS). 130 131check_metachars () 132{ 133 check_make --run -M "metachars" "$@" 134} 135 136check_metachars MYFLAGS="-n \"n\" '-n' --none -n" 137check_metachars MYFLAGS='-knf2\ n\ \\n' 138check_metachars MYFLAGS="(&) | ; \" \` '" 139check_metachars MYFLAGS=" ' # ' " 140check_metachars MYFLAGS='$(foo)' 141check_metachars MYFLAGS='$(foo -n)' 142check_metachars MYFLAGS='`touch bad`' 143check_metachars MYFLAGS='`touch --dry-run bad`' 144 145# ---------------------------------------------------------------------- 146 147: 148