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

2024-11-24 Thread Michael Pratt
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 
Signed-off-by: Michael Pratt 
---
 Makefile.am  | 13 +
 config/eu.am |  9 -
 2 files changed, 9 insertions(+), 13 deletions(-)

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
-- 
2.30.2




[PATCH 3/3] Consolidate list of custom phony targets

2024-11-24 Thread Michael Pratt
Having a target defined as phony within a condition
while another target is always defined as phony
causes an automake warning:

  Makefile.am:67: warning: .PHONY was already defined in condition TRUE, which 
includes condition GCOV ...
  config/eu.am:141: ... '.PHONY' previously defined here
  Makefile.am:21:   'config/eu.am' included from here
  tests/Makefile.am:895: warning: .PHONY was already defined in condition TRUE, 
which includes condition GCOV ...
  config/eu.am:141: ... '.PHONY' previously defined here
  tests/Makefile.am:19:   'config/eu.am' included from here

Instead, list all the custom targets that are phony
in the common definitions in the eu.am file.

Since it is all related to coverage at this moment,
the list can be grouped as it is instead of moved or split.

* Makefile.am: remove .PHONY list in conditional
* config/eu.am: add coverage target to .PHONY list
* tests/Makefile.am: remove .PHONY list in conditional

Signed-off-by: Michael Pratt 
---
 Makefile.am   | 1 -
 config/eu.am  | 3 ++-
 tests/Makefile.am | 1 -
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index e44bbe62..3a181d75 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -64,7 +64,6 @@ 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))
 
-.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 475d5836..e4fcbd1a 100644
--- a/config/eu.am
+++ b/config/eu.am
@@ -138,7 +138,8 @@ endif
 COVERAGE_OUTPUT_DIRECTORY = coverage
 COVERAGE_OUTPUT_FILE = $(PACKAGE_NAME).lcov
 
-.PHONY: clean-coverage
+.PHONY: clean-coverage coverage
+
 clean-local: clean-coverage
 clean-coverage:
-rm -rf $(COVERAGE_OUTPUT_DIRECTORY)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 44cbb825..8f087798 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -892,7 +892,6 @@ CLEANFILES = $(BUILT_SOURCES)
 
 if GCOV
 check: check-am coverage
-.PHONY: coverage
 coverage:
-$(srcdir)/coverage.sh
 endif
-- 
2.30.2




[PATCH 1/3] Makefile.am: include common eu.am definitions

2024-11-24 Thread Michael Pratt
Some definitions in Makefile.am can be moved
to the common definitions in config/eu.am,
but for them to apply to the top-level Makefile after moving,
eu.am must be added as an include statement.

Except for "CLEANFILES", handled in the next commit,
there are no definitions in eu.am that are defined in Makefile.am,
so there are no other conflicts or overrides between the two.

Signed-off-by: Michael Pratt 
---
 Makefile.am | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 92130b57..9a8e5a52 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,6 +18,8 @@
 ## You should have received a copy of the GNU General Public License
 ## along with this program.  If not, see .
 ##
+include $(top_srcdir)/config/eu.am
+
 ACLOCAL_AMFLAGS = -I m4
 
 # automake already tells which subdir is being entered.
-- 
2.30.2