[2/3] Consolidate custom clean targets for coverage files

Message ID 20241124190223.28061-2-mcpratt@pm.me
State Committed
Headers
Series [1/3] Makefile.am: include common eu.am definitions |

Commit Message

Michael Pratt Nov. 24, 2024, 7:03 p.m. UTC
  As reported by Mark:

Since b2f225d6b ("Consolidate and add files to clean target variables")
autoreconf (automake) produces these warnings:

debuginfod/Makefile.am:130: warning: CLEANFILES multiply defined in condition TRUE ...
config/eu.am:138: ... 'CLEANFILES' previously defined here
debuginfod/Makefile.am:32:   'config/eu.am' included from here
libasm/Makefile.am:91: warning: CLEANFILES multiply defined in condition TRUE ...
config/eu.am:138: ... 'CLEANFILES' previously defined here
libasm/Makefile.am:30:   'config/eu.am' included from here
libcpu/Makefile.am:105: warning: CLEANFILES multiply defined in condition TRUE ...
config/eu.am:138: ... 'CLEANFILES' previously defined here
libcpu/Makefile.am:30:   'config/eu.am' included from here
libdw/Makefile.am:156: warning: CLEANFILES multiply defined in condition TRUE ...
config/eu.am:138: ... 'CLEANFILES' previously defined here
libdw/Makefile.am:30:   'config/eu.am' included from here
libelf/Makefile.am:142: warning: CLEANFILES multiply defined in condition TRUE ...
config/eu.am:138: ... 'CLEANFILES' previously defined here
libelf/Makefile.am:30:   'config/eu.am' included from here
src/Makefile.am:47: warning: CLEANFILES multiply defined in condition TRUE ...
config/eu.am:138: ... 'CLEANFILES' previously defined here
src/Makefile.am:19:   'config/eu.am' included from here
tests/Makefile.am:891: warning: CLEANFILES multiply defined in condition TRUE ...
config/eu.am:138: ... 'CLEANFILES' previously defined here
tests/Makefile.am:19:   'config/eu.am' included from here

This is because config/eu.am defines a default "CLEANFILES".

However, the list is only for the removal of coverage files.
Since there is an exising custom clean rule for coverage in Makefile.am
because there is a directory involved as well as files,
further simplification of these rule definitions can resolve this.

Define cleaning targets for coverage files
in a single place and as a common definition
for all generated Makefiles using a custom rule.
This allows for avoiding the use of "CLEANFILES"
variables for anything related to removing coverage files,
and removing the usage of this variable where there is a conflict,
as it is no longer needed to be defined there.

    * Makefile.am: remove variables and custom clean target.
    * config/eu.am: remove clean variables, add variables
      and custom clean target based on removed definitions.

Fixes: b2f225d6b ("Consolidate and add files to clean target variables")
Reported-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Michael Pratt <mcpratt@pm.me>
---
 Makefile.am  | 13 +------------
 config/eu.am |  9 ++++++++-
 2 files changed, 9 insertions(+), 13 deletions(-)
  

Patch

diff --git a/Makefile.am b/Makefile.am
index 9a8e5a52..e44bbe62 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -55,8 +55,6 @@  rpmbuild: dist
 
 if GCOV
 
-COVERAGE_OUTPUT_FILE = $(PACKAGE_NAME).lcov
-COVERAGE_OUTPUT_DIRECTORY = coverage
 COVERAGE_OUTPUT_INDEX_HTML = $(COVERAGE_OUTPUT_DIRECTORY)/index.html
 COVERAGE_TITLE = $(PACKAGE_NAME)-$(PACKAGE_VERSION)
 
@@ -66,16 +64,7 @@  build_COVERAGE_DIRS = $(patsubst %,$(builddir)/%,$(COVERAGE_DIRS))
 all_COVERAGE_DIRS = $(sort $(src_COVERAGE_DIRS) $(build_COVERAGE_DIRS))
 LCOV_DIRS_ARGS = $(patsubst %,--directory=%,$(all_COVERAGE_DIRS))
 
-CLEANFILES = $(COVERAGE_OUTPUT_FILE)
-
-.PHONY: coverage coverage-clean
-
-clean-local: coverage-clean
-distclean-local: coverage-clean
-
-coverage-clean:
-	-rm -rf $(COVERAGE_OUTPUT_DIRECTORY)
-
+.PHONY: coverage
 coverage: $(COVERAGE_OUTPUT_INDEX_HTML)
 	@echo 'file://$(abs_builddir)/$(COVERAGE_OUTPUT_INDEX_HTML)'
 
diff --git a/config/eu.am b/config/eu.am
index 0b7dab5b..475d5836 100644
--- a/config/eu.am
+++ b/config/eu.am
@@ -135,7 +135,14 @@  else
 	$(AM_V_CC)$(COMPILE.os) -c -o $@ $(fpic_CFLAGS) $(DEFS.os) $<
 endif
 
-CLEANFILES = *.gcno *.gcda
+COVERAGE_OUTPUT_DIRECTORY = coverage
+COVERAGE_OUTPUT_FILE = $(PACKAGE_NAME).lcov
+
+.PHONY: clean-coverage
+clean-local: clean-coverage
+clean-coverage:
+	-rm -rf $(COVERAGE_OUTPUT_DIRECTORY)
+	-rm -f $(COVERAGE_OUTPUT_FILE) *.gcno *.gcda
 
 textrel_msg = echo "WARNING: TEXTREL found in '$@'"
 if FATAL_TEXTREL