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 --- Makefile | 8 +++++- buildrom-withgrub.mk | 2 +- grub-mkstandalone.mk | 2 +- modules.mk | 78 +++++++++++++++++++++++++++++++++++++++------------- 4 files changed, 68 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index e9501fe..5822815 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ romtypes = txtmode vesafb i945boards = x60 x60t t60 -build: \ +build: PHONY \ $(foreach board,$(boards),\ $(foreach keymap,$(keymaps),\ $(foreach romtype,$(romtypes),\ @@ -53,3 +53,9 @@ include modules.mk include build.mk include grub-mkstandalone.mk include buildrom-withgrub.mk + + + +.DELETE_ON_ERROR: +PHONY: +.PHONY: PHONY diff --git a/buildrom-withgrub.mk b/buildrom-withgrub.mk index 1bfa553..3a054be 100644 --- a/buildrom-withgrub.mk +++ b/buildrom-withgrub.mk @@ -3,7 +3,7 @@ resources/libreboot/config/%_vesafb_config: resources/libreboot/config/%_txtmode sed 's/# CONFIG_FRAMEBUFFER_KEEP_VESA_MODE is not set/CONFIG_FRAMEBUFFER_KEEP_VESA_MODE=y/' < $< > $@ define rule_rom_nokeyboard -tmp/$(board)_nokeyboard_$(romtype).rom: builddeps-coreboot \ +tmp/$(board)_nokeyboard_$(romtype).rom: tmp/builddeps-coreboot.stamp \ tmp/grub_$(romtype).elf \ resources/libreboot/config/$(board)_$(romtype)_config rm -f src/coreboot/.config src/coreboot/grub.elf diff --git a/grub-mkstandalone.mk b/grub-mkstandalone.mk index 62bd3cb..ef03eb1 100644 --- a/grub-mkstandalone.mk +++ b/grub-mkstandalone.mk @@ -9,7 +9,7 @@ grub_vesafb_memdisk_deps = resources/grub/background/backgroun # A rule-variable is used here to avoid needing .SECONDEXPANSION define rule_grub_elf tmp/grub_$(romtype).elf: \ - builddeps-grub \ + tmp/builddeps-grub.stamp \ $(keymapdir)/list.mk resources/utilities/grub-assemble/modules.conf \ resources/grub/config/grub_memdisk.cfg \ $(grub_$(romtype)_memdisk_deps) \ 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 $