| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 | #! /bin/sh# Copyright (C) 1998-2017 Free Software Foundation, Inc.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2, or (at your option)# any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program.  If not, see <http://www.gnu.org/licenses/>.# Removing subdir objects does not cause too much 'rm' invocations.# Also, if we rename a source file in a subdirectory, the stale# compiled object corresponding to the old name still gets removed# by "make mostlyclean".  See automake bug#10697.# This is the libtool case.  Keep this test in sync with sister test# 'subobj-clean-pr10697.sh', which deals with the non-libtool case.required='cc libtoolize'. test-init.shcat >> configure.ac << 'END'AM_PROG_ARAC_PROG_LIBTOOLAC_PROG_CCAC_OUTPUTENDoPATH=$PATHocwd=$(pwd) || fatal_ "getting current working directory"# An rm(1) wrapper that fails when invoked too many times.mkdir rm-wrapmax_rm_invocations=6count_file=$ocwd/rm-wrap/countcat > rm-wrap/rm <<END#!$AM_TEST_RUNNER_SHELL -ecount=\$((\$(cat '$count_file') + 1))if ! test \$count -le $max_rm_invocations; then  echo "rm invoked more than $max_rm_invocations times" >&2  exit 1fiecho "\$count" > '$count_file'PATH='$oPATH'; export PATHexec rm "\$@"ENDchmod a+x rm-wrap/rmecho "0" > rm-wrap/countcat > Makefile.am <<'END'.PHONY: sanity-check-rmsanity-check-rm:	rm -f 1	rm -f 2	rm -f 3	rm -f 4	rm -f 5	rm -f 6	rm -f x && exit 1; :	echo "0" > rm-wrap/countAUTOMAKE_OPTIONS = subdir-objectslib_LTLIBRARIES = libfoo.lalibfoo_la_SOURCES = \  sub1/a.c \  sub1/b.c \  sub1/c.c \  sub1/d.c \  sub1/e.c \  sub1/f.c \  sub2/a.c \  sub2/b.c \  sub2/c.c \  sub2/d.c \  sub2/e.c \  sub2/f.c \  main.cENDmkdir sub1 sub2echo 'int libmain (void)' > main.cecho '{' >> main.cfor i in 1 2; do  for j in a b c d e f; do    echo "void $j$i (void) { }" > sub$i/$j.c    echo "  $j$i ();" >> main.c  donedoneecho '  return 0;' >> main.cecho '}' >> main.ccat main.c # For debugging.libtoolize$ACLOCAL$AUTOCONF$AUTOMAKE -a./configure# The use of this variable is only meant to keep us better in sync# with the sister test 'subobj-clean-pr10697.sh'.OBJEXT=lo$MAKE# This must go after configure, since that will invoke rm many times.PATH=$ocwd/rm-wrap$PATH_SEPARATOR$PATH; export PATH$MAKE sanity-check-rm || fatal_ "rm wrapper doesn't work as expected"$MAKE mostlycleanls -l . sub1 sub2for i in 1 2; do  for j in a b c d e f; do    test ! -e sub$i/$j.o    test ! -e sub$i/$j.obj    test ! -e sub$i/$j.lo    test -f sub$i/$j.c || exit 99 # Sanity check  donedonePATH=$oPATH; export PATHrm -rf rm-wrap$MAKE clean$MAKEtest -f sub1/a.$OBJEXTtest -f sub2/d.$OBJEXT$sleepmv -f sub2/d.c sub2/x.crm -f sub1/a.csed -e '/ a1 ()/d' main.c > tmv -f t main.csed -e '/sub1\/a\.c/d' -e 's|sub2/d\.c|sub2/x.c|' Makefile.am > tmv -f t Makefile.amusing_gmake || $MAKE Makefile$MAKEtest -f sub2/x.$OBJEXT# The stale objects are still there after a mere "make all" ...test -f sub1/a.$OBJEXTtest -f sub2/a.$OBJEXT# ... but they get removed by "make mostlyclean" ...$MAKE mostlycleantest ! -e sub1/a.$OBJEXTtest ! -e sub2/d.$OBJEXT# ... and do not get rebuilt ...$MAKE clean$MAKE alltest ! -e sub1/a.$OBJEXTtest ! -e sub2/d.$OBJEXT# ... while the non-stale files do.test -f sub1/b.$OBJEXTtest -f sub2/x.$OBJEXT:
 |