]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
rm: convert more cases to am__rm_f
authorMike Frysinger <vapier@gentoo.org>
Wed, 4 Jan 2023 02:46:38 +0000 (21:46 -0500)
committerMike Frysinger <vapier@gentoo.org>
Mon, 9 Jan 2023 05:07:42 +0000 (00:07 -0500)
Fixes automake bug https://bugs.gnu.org/10828.

Clean up a few more cases where we were doing `test ... || rm ...` to
avoid calling `rm -f` without arguments by leveraging am__rm_f.  These
were harder to find in the source due to their constructed nature.

The clean programs rules in particular were much more complicated than
they needed to be.  This logic boiled down to two things: delete the
list of programs, and then delete the list without the exeext suffix,
but only if the list of programs is non-empty.

The check-TESTS rule was converted to am__rm_f, but a simplification
was missed where the $list variable is inlined.

* bin/automake.in: Delete test -z logic and always call am__rm_f.
* contrib/check-html.am: Use $(am__rm_f) helper.
* doc/automake.texi: Update examples to match current behavior.
* lib/am/check.am: Inline $list variable.
* lib/am/progs.am: Rewrite rule to use $(am__rm_f).

bin/automake.in
contrib/check-html.am
doc/automake.texi
lib/am/check.am
lib/am/progs.am

index b847a09930e801b77953b5b20a791ad449a7e658..3069132796f114e9dfcf1d3ab0ae82224b738db6 100644 (file)
@@ -4733,12 +4733,7 @@ sub handle_clean
       prog_error 'invalid entry in %clean_files'
        unless exists $rms{$when};
 
-      my $rm = "rm -f $file";
-      # If file is a variable, make sure when don't call 'rm -f' without args.
-      $rm ="test -z \"$file\" || $rm"
-       if ($file =~ /^\s*\$(\(.*\)|\{.*\})\s*$/);
-
-      push @{$rms{$when}}, "\t-$rm\n";
+      push @{$rms{$when}}, "\t-\$(am__rm_f) $file\n";
     }
 
   $output_rules .= file_contents
index 1588acf2e2ffdfeb3a76e8c85e41dd95d360be89..27bb62e8e21588c1f7854e4c7cc8c713f21f2b0e 100644 (file)
@@ -24,8 +24,7 @@ TEST_SUITE_HTML = $(TEST_SUITE_LOG:.log=.html)
 mostlyclean-local: mostlyclean-check-html
 .PHONY: mostlyclean-check-html
 mostlyclean-check-html:
-## Expand $(TEST_LOGS) only once, to avoid exceeding line length limits.
-       list='$(TEST_LOGS:.log=.html)'; test -z "$$list" || rm -f $$list
+       $(am__rm_f) $(TEST_LOGS:.log=.html)
        rm -f $(TEST_SUITE_HTML)
 
 .log.html:
index 58156d9bf744981b65c5c07ad7109d79f5fdfdad..ec14c5c4c734d8c0ea2fd543ef28b374a10e2034 100644 (file)
@@ -7527,8 +7527,8 @@ if you try to run @samp{make foo} explicitly:
 
 @example
 % make clean
-test -z "bindir.h" || rm -f bindir.h
-test -z "foo" || rm -f foo
+rm -f bindir.h
+rm -f foo
 rm -f *.o
 % : > .deps/foo.Po # Suppress previously recorded dependencies
 % make foo
@@ -11324,7 +11324,7 @@ gcc -Wall -o foo main.o func.o
 
 @i{Clean up, so that we can rebuild everything from scratch.}
 % @kbd{make clean}
-test -z "foo" || rm -f foo
+rm -f foo
 rm -f *.o
 
 @i{Silent rules enabled: the output is minimal but informative.  In
index f0c9ddfbe863d29840f00610ac22c2980f458be2..eca7935821ec4730a4273bf3bc6e875c8a451f50 100644 (file)
@@ -405,8 +405,8 @@ RECHECK_LOGS = $(TEST_LOGS)
 ## ------------------------------------------ ##
 
 check-TESTS: %CHECK_DEPS%
-       @list='$(RECHECK_LOGS)';           $(am__rm_f) $$list
-       @list='$(RECHECK_LOGS:.log=.trs)'; $(am__rm_f) $$list
+       @$(am__rm_f) $(RECHECK_LOGS)
+       @$(am__rm_f) $(RECHECK_LOGS:.log=.trs)
 ## We always have to remove $(TEST_SUITE_LOG), to ensure its rule is run
 ## in any case even in lazy mode: otherwise, if no test needs rerunning,
 ## or a prior run plus reruns all happen within the same timestamp (can
index 0b74cca2e4d044075997a1e3c3e1b82bcc461a88..e665a1f516fb51097c3f04049e73c25e3c160a7d 100644 (file)
@@ -114,13 +114,8 @@ clean-%DIR%PROGRAMS:
 ## Cleaning the '_libs/' or '.libs/' directory is done from clean-libtool.
 ## FIXME: In the future (i.e., when it works) it would be nice to delegate
 ## this task to "libtool --mode=clean".
-?LIBTOOL?      @list='$(%DIR%_PROGRAMS)'; test -n "$$list" || exit 0; \
-?LIBTOOL?      echo " rm -f" $$list; \
-?LIBTOOL?      rm -f $$list || exit $$?; \
-?LIBTOOL?      test -n "$(EXEEXT)" || exit 0; \
-?LIBTOOL?      list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
-?LIBTOOL?      echo " rm -f" $$list; \
-?LIBTOOL?      rm -f $$list
+?LIBTOOL?      $(am__rm_f) $(%DIR%_PROGRAMS)
+?LIBTOOL?      test -z "$(EXEEXT)" || $(am__rm_f) $(%DIR%_PROGRAMS:$(EXEEXT)=)
 
 
 ## ---------- ##