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 --- Makefile.in | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Makefile.in') diff --git a/Makefile.in b/Makefile.in index 8f399a2ab..bc03ab9ce 100644 --- a/Makefile.in +++ b/Makefile.in @@ -23,6 +23,7 @@ endif COMPLETIONDIRS = src/zsh_completion src/bash_completion +.PHONY: all all: all_items mydirs $(MAN_TARGET) filters APPS = src/firecfg/firecfg src/firejail/firejail src/firemon/firemon src/profstats/profstats src/jailtest/jailtest SBOX_APPS = src/fbuilder/fbuilder src/ftee/ftee @@ -72,6 +73,7 @@ seccomp.mdwx: src/fseccomp/fseccomp seccomp.mdwx.32: src/fseccomp/fseccomp src/fseccomp/fseccomp memory-deny-write-execute.32 seccomp.mdwx.32 +.PHONY: clean clean: for dir in $$(dirname $(ALL_ITEMS)) $(MYDIRS); do \ $(MAKE) -C $$dir clean; \ @@ -91,6 +93,7 @@ clean: rm -f test/sysutils/firejail_t* cd test/compile; ./compile.sh --clean; cd ../.. +.PHONY: distclean distclean: clean for dir in $$(dirname $(ALL_ITEMS)) $(MYDIRS); do \ $(MAKE) -C $$dir distclean; \ -- cgit v1.2.3-54-g00ecf