Skip to contentSkip to conversation

configure: Tidy up removal of generated artifacts

PATCH Superseded Ricardo B. Marliere via ltp 3 participants 13 messages Mar 27, 2025 – Apr 1, 2025

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover configure: Tidy up removal of generated artifacts

Hello folks,

The goal of this series is to fix the top-level make maintainer-clean [1] so that it removes everything the build system generated. The motivation is that I was using git clean -fdx instead of -fdX and inevitably lost some work, then I realized the cleaning targets were not actually cleaning everything, e.g.:

(master)

$ make autotools
$ ./configure
$ make maintainer-clean
$ git clean -fdx
Removing aclocal.m4
Removing compile
Removing config.guess
Removing config.sub
Removing configure
Removing include/config.h.in
Removing include/lapi/syscalls.h
Removing include/mk/config-openposix.mk
Removing install-sh
Removing m4/Makefile.in
Removing missing
Removing testcases/open_posix_testsuite/autom4te.cache/
Removing testcases/open_posix_testsuite/configure

So, with this series applied then git clean -fdx won't have anything left to remove.

Please consider pulling,
- Ricardo.

[1]: https://www.gnu.org/prep/standards/html_node/Standard-Targets.html

---
Ricardo B. Marlière (4):
configure: Add missing include/mk/config-openposix.mk reference
openposix: Makefile: Add the standard "maintainer-clean" target include/Makefile: Fix cleaning targets
configure: Add missing files for removal in ac-maintainer-clean target

 configure.ac                            |  2 ++
 include/Makefile                        |  4 ++--
 include/mk/automake.mk                  | 11 ++++++-----
 testcases/open_posix_testsuite/Makefile | 10 +++++++++-
 4 files changed, 19 insertions(+), 8 deletions(-)

---
base-commit: e3aef569f0d0e7079bdb646965afaf419035eaa5
change-id: 20250327-fix_make_clean-8e57ffe1ce2c

Best regards,

Signature · 5 lines
Ricardo B. Marlière <[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH 1/4 configure: Add missing include/mk/config-openposix.mk reference

From: Ricardo B. Marlière <[email protected]>

The file include/mk/config-openposix.mk should be added to the AUTOGENERATED_FILES array in include/mk/automake.mk so that it can be cleaned in the cleaning targets. Also, add a small comment in configure.ac so it does not happen again.

Cc Cyril Hrubis <[email protected]>
Fixes 63b6532ff150 ("open_posix_testsuite: Propagate configure params")
---
 configure.ac           | 2 ++
 include/mk/automake.mk | 1 +
 2 files changed, 3 insertions(+)
configure.ac +2 -0
index 671079f3aa48c72866f69e7c545d3428ba87f931..ddb1f6e4e0787fe4bc4d9729470e52237930a120 100644
@@ -7,6 +7,8 @@ AC_CONFIG_AUX_DIR([.])
 AM_INIT_AUTOMAKE
 AC_CONFIG_HEADERS([include/config.h])
 AC_CONFIG_MACRO_DIR([m4])
+
+# Adding files here? Please update include/mk/automake.mk
 AC_CONFIG_FILES([ \
     include/mk/config.mk \
     include/mk/config-openposix.mk \
include/mk/automake.mk +1 -0
index 79f83a5a2edf2a4a10b7587a36e792397cfb5d64..3df3b4ba99ca865caa89388999e53cbc500615dc 100644
@@ -76,6 +76,7 @@ ac-maintainer-clean:: ac-distclean
 #
 AUTOGENERATED_FILES	= \
 			include/mk/config.mk	\
+			include/mk/config-openposix.mk \
 			include/mk/features.mk	\
 			lib/ltp.pc		\
 			m4/Makefile
Signature · 5 lines
2.49.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Re: [LTP] [PATCH 1/4] configure: Add missing include/mk/config-openposix.mk reference

Hi all,

thanks obvious fix, merged.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

PATCH 2/4 openposix: Makefile: Add the standard "maintainer-clean" target

In reply to Ricardo B. Marliere via ltp

From: Ricardo B. Marlière <[email protected]>

The include/mk/automake.mk file define the standard "maintainer-clean" and "ac-maintainer-clean" targets and therein it calls the same targets under each AUTOCONFED_SUBDIRS, but in the case of the openposix test suite, they don't exist. Add them and also remove some dangling files in ac-clean.

This fixes the following error when calling make maintainer-clean from the project's top level directory:

make[1]: Entering directory './testcases/open_posix_testsuite' make[1]: *** No rule to make target 'ac-maintainer-clean'. Stop. make[1]: Leaving directory './testcases/open_posix_testsuite'
make: *** [./include/mk/automake.mk:68: ac-maintainer-clean] Error 2

---
 testcases/open_posix_testsuite/Makefile | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
testcases/open_posix_testsuite/Makefile +9 -1
index 8b4c8c0a24b833fa0fb21ce3e253629f358f1800..c0ccd499b8b9c93e45133f5b3f189eda7d09beb3 100644
@@ -31,11 +31,16 @@ AUTOGENERATED_FILES = include/mk/config.mk
 
 .PHONY: ac-clean
 ac-clean: clean
+	$(RM) -rf autom4te.cache
+	$(RM) -f config.log config.status
+
+.PHONE: ac-maintainer-clean
+ac-maintainer-clean:
+	$(RM) -f configure
 
 .PHONY: clean
 clean:
 	$(RM) -f $(LOGFILE)*
-	$(RM) -f config.log config.status
 	@for dir in $(SUBDIRS) tools; do \
 		$(MAKE) -C $$dir clean >/dev/null; \
 	done
@@ -51,6 +56,9 @@ distclean-makefiles:
 		$(MAKE) -C $$dir $@; \
 	done
 
+.PHONY: maintainer-clean
+maintainer-clean: distclean-makefiles ac-maintainer-clean
+
 $(AUTOGENERATED_FILES): $(top_builddir)/config.status
 	$(SHELL) $^
 
Signature · 5 lines
2.49.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 2/4
#5 lore raw

Re: [LTP] [PATCH 2/4] openposix: Makefile: Add the standard "maintainer-clean" target

Hi Ricardo,

Quoted 5 lines

The include/mk/automake.mk file define the standard "maintainer-clean" and "ac-maintainer-clean" targets and therein it calls the same targets under each AUTOCONFED_SUBDIRS, but in the case of the openposix test suite, they don't exist. Add them and also remove some dangling files in ac-clean.

Quoted 7 lines

This fixes the following error when calling make maintainer-clean from the project's top level directory:

make[1]: Entering directory './testcases/open_posix_testsuite' make[1]: *** No rule to make target 'ac-maintainer-clean'. Stop. make[1]: Leaving directory './testcases/open_posix_testsuite'
make: *** [./include/mk/automake.mk:68: ac-maintainer-clean] Error 2

Thanks for fixing dark corners of LTP build system.

What a strange target name. Obviously it was meant to be run before release file, but it was not even called in Makefile.release which I removed in 1088d93d99.

I was thinking whether we really need this target. Maybe it could be part of distclean.

Kind regards,
Petr

Quoted 36 lines
---
 testcases/open_posix_testsuite/Makefile | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
testcases/open_posix_testsuite/Makefile +9 -1
index 8b4c8c0a24b833fa0fb21ce3e253629f358f1800..c0ccd499b8b9c93e45133f5b3f189eda7d09beb3 100644
@@ -31,11 +31,16 @@ AUTOGENERATED_FILES = include/mk/config.mk
 
 .PHONY: ac-clean
 ac-clean: clean
+	$(RM) -rf autom4te.cache
+	$(RM) -f config.log config.status
+
+.PHONE: ac-maintainer-clean
+ac-maintainer-clean:
+	$(RM) -f configure
 
 .PHONY: clean
 clean:
 	$(RM) -f $(LOGFILE)*
-	$(RM) -f config.log config.status
 	@for dir in $(SUBDIRS) tools; do \
 		$(MAKE) -C $$dir clean >/dev/null; \
 	done
@@ -51,6 +56,9 @@ distclean-makefiles:
 		$(MAKE) -C $$dir $@; \
 	done
 
+.PHONY: maintainer-clean
+maintainer-clean: distclean-makefiles ac-maintainer-clean
+
 $(AUTOGENERATED_FILES): $(top_builddir)/config.status
 	$(SHELL) $^
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Re: [LTP] [PATCH 2/4] openposix: Makefile: Add the standard "maintainer-clean" target

Quoted 17 lines · Petr Vorel

Hi Ricardo,

Quoted 5 lines

The include/mk/automake.mk file define the standard "maintainer-clean" and "ac-maintainer-clean" targets and therein it calls the same targets under each AUTOCONFED_SUBDIRS, but in the case of the openposix test suite, they don't exist. Add them and also remove some dangling files in ac-clean.

Quoted 7 lines

This fixes the following error when calling make maintainer-clean from the project's top level directory:

make[1]: Entering directory './testcases/open_posix_testsuite' make[1]: *** No rule to make target 'ac-maintainer-clean'. Stop. make[1]: Leaving directory './testcases/open_posix_testsuite'
make: *** [./include/mk/automake.mk:68: ac-maintainer-clean] Error 2

Quoted 8 lines

Thanks for fixing dark corners of LTP build system.

What a strange target name. Obviously it was meant to be run before release file, but it was not even called in Makefile.release which I removed in 1088d93d99.

I was thinking whether we really need this target. Maybe it could be part of distclean.

Strange indeed, I was not aware of it until now... As I mentioned in the cover letter, its a standard target. Both approaches make sense to me, either we keep it or unify it with distclean. Not sure what others prefer, but I would like to have a proper clean without relying on git.

Thank you,
- Ricardo.

Quoted 40 lines

Kind regards,
Petr

Quoted 36 lines
---
 testcases/open_posix_testsuite/Makefile | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
testcases/open_posix_testsuite/Makefile +9 -1
index 8b4c8c0a24b833fa0fb21ce3e253629f358f1800..c0ccd499b8b9c93e45133f5b3f189eda7d09beb3 100644
@@ -31,11 +31,16 @@ AUTOGENERATED_FILES = include/mk/config.mk
 
 .PHONY: ac-clean
 ac-clean: clean
+	$(RM) -rf autom4te.cache
+	$(RM) -f config.log config.status
+
+.PHONE: ac-maintainer-clean
+ac-maintainer-clean:
+	$(RM) -f configure
 
 .PHONY: clean
 clean:
 	$(RM) -f $(LOGFILE)*
-	$(RM) -f config.log config.status
 	@for dir in $(SUBDIRS) tools; do \
 		$(MAKE) -C $$dir clean >/dev/null; \
 	done
@@ -51,6 +56,9 @@ distclean-makefiles:
 		$(MAKE) -C $$dir $@; \
 	done
 
+.PHONY: maintainer-clean
+maintainer-clean: distclean-makefiles ac-maintainer-clean
+
 $(AUTOGENERATED_FILES): $(top_builddir)/config.status
 	$(SHELL) $^
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

PATCH 3/4 include/Makefile: Fix cleaning targets

In reply to Ricardo B. Marliere via ltp

From: Ricardo B. Marlière <[email protected]>

Add ac-clean target as dependency of ac-maintainer-clean and add missing files to the removal list. This way the project top level Makefile cleaning targets can make use of it.

Cc Andrea Cervesato <[email protected]>
Fixes 817d8095fbfe ("Rename linux_syscall_numbers.h to lapi/syscalls.h")
---
 include/Makefile       | 4 ++--
 include/mk/automake.mk | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
include/Makefile +2 -2
index 25e96df9b8cdd7d1d7e6f19925bf2160d682f0d9..6b31b046e452e71afb5097cc3fadf8af01282629 100644
@@ -18,8 +18,8 @@ MAKE_TARGETS		:=
 distclean:: clean ac-distclean
 maintainer-clean:: distclean ac-maintainer-clean
 ac-clean ac-distclean::
-	$(RM) -f config.h
-ac-maintainer-clean::
+	$(RM) -f config.h lapi/syscalls.h stamp-h1
+ac-maintainer-clean:: ac-clean
 	$(RM) -f config.h.in
 
 vpath %.h $(abs_srcdir)
include/mk/automake.mk +2 -2
index 3df3b4ba99ca865caa89388999e53cbc500615dc..d96da8313dc8dc4f4d6d728db72b0f749d269bfe 100644
@@ -45,7 +45,7 @@ m4/ltp-version.m4: VERSION
 	sed -n '1{s:LTP-:m4_define([LTP_VERSION],[:;s:$$:]):;p;q}' $< > $@
 
 .PHONY: automake
-AUTOMAKE_FILES := config.guess config.sub install-sh missing stamp-h1
+AUTOMAKE_FILES := config.guess config.sub install-sh missing
 automake: aclocal $(AUTOMAKE_FILES)
 $(AUTOMAKE_FILES): m4/Makefile.in
 m4/Makefile.in: m4/Makefile.am aclocal.m4
@@ -55,8 +55,8 @@ m4/Makefile.in: m4/Makefile.am aclocal.m4
 ac-clean::
 	$(RM) -rf autom4te.cache
 	$(RM) -f config.log config.status
-	$(RM) -f include/config.h include/stamp-h1
 	$(RM) -f m4/Makefile m4/ltp-version.m4
+	$(MAKE) -C "$(top_srcdir)/include" $@;
 	for d in $(AUTOCONFED_SUBDIRS); do \
 	    $(MAKE) -C "$(top_srcdir)/$$d" $@; \
 	done
Signature · 5 lines
2.49.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 3/4
#8 lore raw

Re: [LTP] [PATCH 3/4] include/Makefile: Fix cleaning targets

Hi Ricardo,

Quoted 6 lines

Add ac-clean target as dependency of ac-maintainer-clean and add missing files to the removal list. This way the project top level Makefile cleaning targets can make use of it.

Cc Andrea Cervesato <[email protected]>
Fixes 817d8095fbfe ("Rename linux_syscall_numbers.h to lapi/syscalls.h")

I did not get how this commit broke the functionality.

Change LGTM.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#9 lore raw

Re: [LTP] [PATCH 3/4] include/Makefile: Fix cleaning targets

Quoted 10 lines · Petr Vorel

Hi Ricardo,

Quoted 6 lines

Add ac-clean target as dependency of ac-maintainer-clean and add missing files to the removal list. This way the project top level Makefile cleaning targets can make use of it.

Cc Andrea Cervesato <[email protected]>
Fixes 817d8095fbfe ("Rename linux_syscall_numbers.h to lapi/syscalls.h")

I did not get how this commit broke the functionality.

It did not break anything, but either that commit or the one that added the older "linux_syscall_numbers.h" file should have also marked it for removal. Should I drop the Fixes: tag?

Quoted 4 lines

Change LGTM.

Thanks,
- Ricardo.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw

Re: [LTP] [PATCH 3/4] include/Makefile: Fix cleaning targets

Quoted 7 lines · Petr Vorel
Quoted 5 lines

Hi Ricardo,

Quoted 3 lines

Add ac-clean target as dependency of ac-maintainer-clean and add missing files to the removal list. This way the project top level Makefile cleaning targets can make use of it.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Cc Andrea Cervesato <[email protected]>
Fixes 817d8095fbfe ("Rename linux_syscall_numbers.h to lapi/syscalls.h")

I did not get how this commit broke the functionality.

It did not break anything, but either that commit or the one that added the older "linux_syscall_numbers.h" file should have also marked it for removal. Should I drop the Fixes: tag?

I guess it's ok to keep.

Kind regards,
Petr

Quoted 6 lines
Quoted 3 lines

Change LGTM.

Thanks,

(quoted diff) +0 -1
-	Ricardo.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#11 lore raw

PATCH 4/4 configure: Add missing files for removal in ac-maintainer-clean target

In reply to Ricardo B. Marliere via ltp

From: Ricardo B. Marlière <[email protected]>

The ac-maintainer-clean target should be responsible to remove all generated files, in this case from make autotools. Add the remaining to the list and also make sure it happens before any call to other targets in nested Makefiles, so if there are any errors in them, they happen lastly.

---
 include/mk/automake.mk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/mk/automake.mk +3 -3
index d96da8313dc8dc4f4d6d728db72b0f749d269bfe..40fab124370d7c9a71fa502ff75e39cb1d31197f 100644
@@ -63,11 +63,11 @@ ac-clean::
 
 ac-distclean:: ac-clean
 ac-maintainer-clean:: ac-distclean
+	$(RM) -f $(AUTOMAKE_FILES) aclocal.m4 compile config.guess config.sub configure m4/Makefile.in
+	$(MAKE) -C "$(top_srcdir)/include" $@;
 	for d in $(AUTOCONFED_SUBDIRS); do \
 	    $(MAKE) -C "$(top_srcdir)/$$d" $@; \
 	done
-	$(RM) -f aclocal.m4 configure $(AUTOMAKE_FILES) m4/Makefile.in
-	$(RM) -f include/*config.h.in
 
 # Don't include config.h, or make will (rightfully) whine about overriding
 # rules.
@@ -82,10 +82,10 @@ AUTOGENERATED_FILES	= \
 			m4/Makefile
 
 distclean:: %: clean ac-distclean
+	$(RM) -f $(AUTOGENERATED_FILES)
 	for d in $(AUTOCONFED_SUBDIRS); do \
 	    $(MAKE) -C "$(top_srcdir)/$$d" $@; \
 	done
-	$(RM) -f $(AUTOGENERATED_FILES)
 
 maintainer-clean:: distclean ac-maintainer-clean
 
Signature · 5 lines
2.49.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#12 lore raw

Re: [LTP] [PATCH 4/4] configure: Add missing files for removal in ac-maintainer-clean target

Quoted 18 lines

From: Ricardo B. Marlière <[email protected]>

The ac-maintainer-clean target should be responsible to remove all generated files, in this case from make autotools. Add the remaining to the list and also make sure it happens before any call to other targets in nested Makefiles, so if there are any errors in them, they happen lastly.

---
 include/mk/automake.mk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/mk/automake.mk +0 -0
index d96da8313dc8dc4f4d6d728db72b0f749d269bfe..40fab124370d7c9a71fa502ff75e39cb1d31197f 100644

include/mk/automake.mk ac-clean:: · line 66

Quoted 4 lines
include/mk/automake.mk +1 -0
@@ -63,11 +63,11 @@ ac-clean::
 
 ac-distclean:: ac-clean
 ac-maintainer-clean:: ac-distclean
+	$(RM) -f $(AUTOMAKE_FILES) aclocal.m4 compile config.guess config.sub configure m4/Makefile.in

OK, this removes "compile" file (Wrapper for compilers which do not understand '-c -o'). Interesting. IMHO the rest of newly explicitly added files (e.g. config.guess, config.sub, m4/Makefile.in) were removed without this change (part of $(AUTOMAKE_FILES) ).

rm -f -f aclocal.m4 configure config.guess config.sub install-sh missing m4/Makefile.in rm -f -f include/*config.h.in

Kind regards,
Petr

Quoted 20 lines
include/mk/automake.mk +2 -3
+	$(MAKE) -C "$(top_srcdir)/include" $@;
 	for d in $(AUTOCONFED_SUBDIRS); do \
 	    $(MAKE) -C "$(top_srcdir)/$$d" $@; \
 	done
-	$(RM) -f aclocal.m4 configure $(AUTOMAKE_FILES) m4/Makefile.in
-	$(RM) -f include/*config.h.in
 
 # Don't include config.h, or make will (rightfully) whine about overriding
 # rules.
@@ -82,10 +82,10 @@ AUTOGENERATED_FILES	= \
 			m4/Makefile
 
 distclean:: %: clean ac-distclean
+	$(RM) -f $(AUTOGENERATED_FILES)
 	for d in $(AUTOCONFED_SUBDIRS); do \
 	    $(MAKE) -C "$(top_srcdir)/$$d" $@; \
 	done
-	$(RM) -f $(AUTOGENERATED_FILES)
 
 maintainer-clean:: distclean ac-maintainer-clean
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp