From 2465f9248e1e2737479fad5065d8310a860ce415 Mon Sep 17 00:00:00 2001 From: "Kelvin M. Klann" Date: Fri, 12 Feb 2021 05:25:23 -0300 Subject: makefiles: make all, clean and distclean PHONY Avoid a stat() call for each affected target and also potentially speed up parallel builds. From the GNU make manual[1]: > Phony targets are also useful in conjunction with recursive > invocations of make (see Recursive Use of make). In this situation > the makefile will often contain a variable which lists a number of > sub-directories to be built. [...] > The implicit rule search (see Implicit Rules) is skipped for .PHONY > targets. This is why declaring a target as .PHONY is good for > performance, even if you are not worried about the actual file > existing. Commands used to search, replace and cleanup: $ find -type f -name '*Makefile.in' -exec sed -i.bak \ -e 's/^all:/.PHONY: all\nall:/' \ -e 's/^clean:/.PHONY: clean\nclean:/' \ -e 's/^distclean:/.PHONY: distclean\ndistclean:/' '{}' + $ find -type f -name '*Makefile.in.bak' -exec rm '{}' + [1]: https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html --- test/Makefile.in | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test') diff --git a/test/Makefile.in b/test/Makefile.in index 5bfad42fa..264314a3b 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -5,8 +5,10 @@ $(TESTS): cd $@ && ./$@.sh 2>&1 | tee $@.log cd $@ && grep -a TESTING $@.log && grep -a -L "TESTING ERROR" $@.log +.PHONY: clean clean: for test in $(TESTS); do rm -f "$$test/$$test.log"; done +.PHONY: distclean distclean: clean rm -f Makefile -- cgit v1.2.3-54-g00ecf