From 1ed6fe4326b46d0693bffbea34d6850a046a939c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 28 Dec 2014 18:40:37 -0500 Subject: Make timestamp files for builddeps rules to avoid extra work --- modules.mk | 78 +++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 19 deletions(-) (limited to 'modules.mk') diff --git a/modules.mk b/modules.mk index 00c506e..acc045d 100644 --- a/modules.mk +++ b/modules.mk @@ -11,60 +11,100 @@ modules = \ # powertop only needs to be used when running './powertop.trisquel6' all_modules = $(modules) powertop +# Easy names for src/% and tmp/builddeps-%.stamp +$(addprefix get,$(all_modules)): get%: PHONY src/% +$(addprefix builddeps-,$(all_modules)): builddeps-%: PHONY tmp/builddeps-%.stamp + +# The "all" rules getall: $(addprefix src/,$(modules)) builddeps: $(addprefix builddeps-,$(modules)) cleandeps: $(addprefix cleandeps-,$(all_modules)) - rm -rf bin/* + rm -rf bin/* tmp/* -# The generic rules +# If we depend on a file in src/*/*, we should generate it by calling +# the builddep rule. +$(foreach module,$(all_modules),$(eval src/$(module)/%: | tmp/builddeps-$(module).stamp; test -e $$@)) -$(foreach module,$(all_modules),$(eval src/$(module)/%: builddeps-$(module); test -e $$@)) + +# The generic rules +# "get" rules +$(addprefix src/,$(all_modules)): \ src/%: get source-locations.sh ./get $* -builddeps-%: src/% + test -e $@ + touch $@ + +# "builddeps" rules +tmp/builddeps-%.stamp: src/% $(MAKE) -C $< -cleandeps-%: + touch $@ + +# "cleandeps" rules +$(addprefix cleandeps-,$(all_modules)): \ +cleandeps-%: PHONY cleandeps-%-custom + rm -f tmp/builddeps-%.stamp +cleandeps-%-custom: PHONY test ! -f src/$*/Makefile || $(MAKE) -C src/$* clean + # The overrides -builddeps-coreboot:: src/coreboot - $(MAKE) -C $