Consolidate and add files to clean target variables

Message ID 20241023063238.27386-1-mcpratt@pm.me
State Committed
Headers
Series Consolidate and add files to clean target variables |

Commit Message

Michael Pratt Oct. 23, 2024, 6:33 a.m. UTC
  To increase the consistency of how automatic clean targets run,
define the variables together without +=, default to MOSTLYCLEANFILES
when there is no need for different levels or
add more clean levels to match other subdirectories,
add more files that are built, remove duplication, and cleanup.

Do the same for EXTRA_DIST where it is equally messy.

    * backends/Makefile.am: add more objects to clean, improve spacing.
    * debuginfod/Makefile.am: Likewise, and remove duplicates.
    * lib/Makefile.am: improve spacing.
    * libasm/Makefile.am: add more objects to clean, split similar to debuginfod.
    * libcpu/Makefile.am: use normal =, add more objects to clean.
    * libdw/Makefile.am: add more objects to clean, split similar to debuginfod.
    * libdwelf/Makefile.am: add more objects to clean, use lowest clean level.
    * libdwfl/Makefile.am: Likewise.
    * libebl/Makefile.am: add more objects to clean.
    * libelf/Makefile.am: add more objects to clean, split similar to debuginfod.
    * src/Makefile.am: consolidate including EXTRA_DIST, split clean levels,
      define with normal =, define with variables.
    * tests/Makefile.am: Likewise, but not including EXTRA_DIST.

Signed-off-by: Michael Pratt <mcpratt@pm.me>
---
 backends/Makefile.am   |  3 ++-
 debuginfod/Makefile.am |  5 +++--
 lib/Makefile.am        |  1 +
 libasm/Makefile.am     |  4 +++-
 libcpu/Makefile.am     |  6 +++---
 libdw/Makefile.am      |  3 ++-
 libdwelf/Makefile.am   |  2 +-
 libdwfl/Makefile.am    |  2 +-
 libebl/Makefile.am     |  2 +-
 libelf/Makefile.am     |  3 ++-
 src/Makefile.am        | 10 +++++-----
 tests/Makefile.am      |  4 ++--
 12 files changed, 26 insertions(+), 19 deletions(-)
  

Comments

Aaron Merey Nov. 8, 2024, 10:35 p.m. UTC | #1
Hi Michael,

On Wed, Oct 23, 2024 at 2:34 AM Michael Pratt <mcpratt@pm.me> wrote:
>
> To increase the consistency of how automatic clean targets run,
> define the variables together without +=, default to MOSTLYCLEANFILES
> when there is no need for different levels or
> add more clean levels to match other subdirectories,
> add more files that are built, remove duplication, and cleanup.
>
> Do the same for EXTRA_DIST where it is equally messy.
>
>     * backends/Makefile.am: add more objects to clean, improve spacing.
>     * debuginfod/Makefile.am: Likewise, and remove duplicates.
>     * lib/Makefile.am: improve spacing.
>     * libasm/Makefile.am: add more objects to clean, split similar to debuginfod.
>     * libcpu/Makefile.am: use normal =, add more objects to clean.
>     * libdw/Makefile.am: add more objects to clean, split similar to debuginfod.
>     * libdwelf/Makefile.am: add more objects to clean, use lowest clean level.
>     * libdwfl/Makefile.am: Likewise.
>     * libebl/Makefile.am: add more objects to clean.
>     * libelf/Makefile.am: add more objects to clean, split similar to debuginfod.
>     * src/Makefile.am: consolidate including EXTRA_DIST, split clean levels,
>       define with normal =, define with variables.
>     * tests/Makefile.am: Likewise, but not including EXTRA_DIST.
>
> Signed-off-by: Michael Pratt <mcpratt@pm.me>

Thanks for the patch. Pushed.

Aaron
  

Patch

diff --git a/backends/Makefile.am b/backends/Makefile.am
index 926464ae..347dad52 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -120,6 +120,7 @@  libebl_backends_pic_a_SOURCES =
 am_libebl_backends_pic_a_OBJECTS = $(libebl_backends_a_SOURCES:.c=.os)
 
 noinst_HEADERS = libebl_CPU.h common-reloc.c linux-core-note.c x86_corenote.c
+
 EXTRA_DIST = $(modules:=_reloc.def)
 
-MOSTLYCLEANFILES = $(am_libebl_backends_pic_a_OBJECTS)
+MOSTLYCLEANFILES = $(am_libebl_backends_a_OBJECTS) $(am_libebl_backends_pic_a_OBJECTS)
diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
index 5ad4e188..45b5339f 100644
--- a/debuginfod/Makefile.am
+++ b/debuginfod/Makefile.am
@@ -125,8 +125,9 @@  uninstall: uninstall-am
 endif
 
 EXTRA_DIST = libdebuginfod.map
-MOSTLYCLEANFILES = $(am_libdebuginfod_pic_a_OBJECTS) $(LIBDEBUGINFOD_SONAME)
-CLEANFILES += $(am_libdebuginfod_pic_a_OBJECTS) libdebuginfod.so
+
+MOSTLYCLEANFILES = $(am_libdebuginfod_a_OBJECTS) $(am_libdebuginfod_pic_a_OBJECTS) $(LIBDEBUGINFOD_SONAME)
+CLEANFILES = libdebuginfod.so
 
 # automake std-options override: arrange to pass LD_LIBRARY_PATH
 installcheck-binPROGRAMS: $(bin_PROGRAMS)
diff --git a/lib/Makefile.am b/lib/Makefile.am
index e324c18d..50c8036b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -41,4 +41,5 @@  noinst_HEADERS = fixedsizehash.h libeu.h system.h dynamicsizehash.h list.h \
 		 eu-config.h color.h printversion.h bpf.h \
 		 atomics.h stdatomic-fbsd.h dynamicsizehash_concurrent.h \
 		 eu-search.h locks.h
+
 EXTRA_DIST = dynamicsizehash.c dynamicsizehash_concurrent.c
diff --git a/libasm/Makefile.am b/libasm/Makefile.am
index 1e6b63e8..324fd095 100644
--- a/libasm/Makefile.am
+++ b/libasm/Makefile.am
@@ -84,6 +84,8 @@  uninstall: uninstall-am
 	rmdir --ignore-fail-on-non-empty $(DESTDIR)$(includedir)/elfutils
 
 noinst_HEADERS = libasmP.h symbolhash.h
+
 EXTRA_DIST = libasm.map
 
-CLEANFILES += $(am_libasm_pic_a_OBJECTS) libasm.so libasm.so.$(VERSION)
+MOSTLYCLEANFILES = $(am_libasm_a_OBJECTS) $(am_libasm_pic_a_OBJECTS) libasm.so.$(VERSION)
+CLEANFILES = libasm.so
diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am
index 4ba1be56..32835237 100644
--- a/libcpu/Makefile.am
+++ b/libcpu/Makefile.am
@@ -101,6 +101,6 @@  bpf_disasm_CFLAGS = -Wno-format-nonliteral
 
 EXTRA_DIST = defs/i386
 
-MOSTLYCLEANFILES = $(am_libcpu_pic_a_OBJECTS)
-CLEANFILES += $(foreach P,i386 x86_64,$P_defs $P.mnemonics)
-MAINTAINERCLEANFILES = $(foreach P,i386 x86_64, $P_dis.h)
+MOSTLYCLEANFILES = $(am_libcpu_a_OBJECTS) $(am_libcpu_pic_a_OBJECTS) $(i386_gendis_OBJECTS)
+CLEANFILES = $(foreach P,i386 x86_64,$P_defs $P.mnemonics)
+MAINTAINERCLEANFILES = $(foreach P,i386 x86_64, $P_defs $P_dis.h $P_parse.h)
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 4b9c4413..62f4359e 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -152,5 +152,6 @@  noinst_HEADERS = libdwP.h memory-access.h dwarf_abbrev_hash.h \
 
 EXTRA_DIST = libdw.map
 
-MOSTLYCLEANFILES = $(am_libdw_pic_a_OBJECTS) libdw.so libdw.so.$(VERSION)
+MOSTLYCLEANFILES = $(am_libdw_a_OBJECTS) $(am_libdw_pic_a_OBJECTS) libdw.so.$(VERSION)
+CLEANFILES = libdw.so
 MAINTAINERCLEANFILES = $(srcdir)/known-dwarf.h
diff --git a/libdwelf/Makefile.am b/libdwelf/Makefile.am
index a35a2873..30abdf81 100644
--- a/libdwelf/Makefile.am
+++ b/libdwelf/Makefile.am
@@ -54,4 +54,4 @@  libeu = ../lib/libeu.a
 libdwelf_pic_a_SOURCES =
 am_libdwelf_pic_a_OBJECTS = $(libdwelf_a_SOURCES:.c=.os)
 
-CLEANFILES += $(am_libdwelf_pic_a_OBJECTS)
+MOSTLYCLEANFILES = $(am_libdwelf_a_OBJECTS) $(am_libdwelf_pic_a_OBJECTS)
diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am
index 57c89604..171bb368 100644
--- a/libdwfl/Makefile.am
+++ b/libdwfl/Makefile.am
@@ -94,4 +94,4 @@  am_libdwfl_pic_a_OBJECTS = $(libdwfl_a_SOURCES:.c=.os)
 
 noinst_HEADERS = libdwflP.h
 
-CLEANFILES += $(am_libdwfl_pic_a_OBJECTS)
+MOSTLYCLEANFILES = $(am_libdwfl_a_OBJECTS) $(am_libdwfl_pic_a_OBJECTS)
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index d84e7ee2..e94eaa7f 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -61,4 +61,4 @@  am_libebl_pic_a_OBJECTS = $(libebl_a_SOURCES:.c=.os)
 
 noinst_HEADERS = libebl.h libeblP.h ebl-hooks.h
 
-MOSTLYCLEANFILES = $(am_libebl_pic_a_OBJECTS)
+MOSTLYCLEANFILES = $(am_libebl_a_OBJECTS) $(am_libebl_pic_a_OBJECTS)
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index 3402863e..44934392 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -135,4 +135,5 @@  uninstall: uninstall-am
 
 EXTRA_DIST = libelf.map
 
-CLEANFILES += $(am_libelf_pic_a_OBJECTS) libelf.so libelf.so.$(VERSION)
+MOSTLYCLEANFILES = $(am_libelf_a_OBJECTS) $(am_libelf_pic_a_OBJECTS) libelf.so.$(VERSION)
+CLEANFILES = libelf.so
diff --git a/src/Makefile.am b/src/Makefile.am
index 6bdf2dfb..97a0c61a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,11 +39,12 @@  noinst_LIBRARIES = libar.a
 
 libar_a_SOURCES = arlib.c arlib2.c arlib-argp.c
 
-EXTRA_DIST = arlib.h debugpred.h
-
 bin_SCRIPTS = make-debug-archive
-EXTRA_DIST += make-debug-archive.in
-CLEANFILES += make-debug-archive
+
+EXTRA_DIST = arlib.h debugpred.h make-debug-archive.in
+
+MOSTLYCLEANFILES = *.gconv
+CLEANFILES = $(bin_SCRIPTS)
 
 if BUILD_STATIC
 libasm = ../libasm/libasm.a
@@ -122,7 +123,6 @@  installcheck-binPROGRAMS: $(bin_PROGRAMS)
 	  done; \
 	done; rm -f c$${pid}_.???; exit $$bad
 
-CLEANFILES += *.gconv
 
 make-debug-archive: $(srcdir)/make-debug-archive.in
 	$(AM_V_GEN)UNSTRIP=$(bindir)/`echo unstrip | sed '$(transform)'`; \
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 76f1682f..d891c79b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -871,7 +871,6 @@  declfiles_LDADD = $(libdw)
 # Don't include any -I CPPFLAGS. Except when we install our own elf.h.
 # For the gelf test we do want our own libelf.h, but nothing else.
 BUILT_SOURCES = libelf.h
-CLEANFILES += libelf.h
 libelf.h: $(top_srcdir)/libelf/libelf.h
 	ln -s $< $@
 if !INSTALL_ELFH
@@ -885,7 +884,8 @@  system_elf_libelf_test_LDADD = $(libelf)
 system_elf_gelf_test_LDADD = $(libelf)
 
 # A lock file used to make sure only one test dumps core at a time
-CLEANFILES += core-dump-backtrace.lock
+MOSTLYCLEANFILES = core-dump-backtrace.lock
+CLEANFILES = $(BUILT_SOURCES)
 
 if GCOV
 check: check-am coverage