jw-pkg/make/cache.mk
Jan Lindemann 3dd55cf067 Further improve build time: Try to avoid calling projects.py
This commit tries to remove the necessity to call projects.py from $(TOPDIR) to
speed up recursive builds over all projects yet again. This is a major
undertaking. There are two variables which are filled py projects.py in
$(TOPDIR): PREREQ and PREREQ_DIRS. Sadly, the latter is a path relative to
$(TOPDIR)/make, so this is kind of pointless. Unless the cache is maintained in
$(TOPDIR), a thing I tried to avoid. So this commit is only able to cache
$(PREREQ), not $(PREREQ_DIRS), which still is a hassle. Introduced defs-dirs.mk
for that, to make it accessible to make.mk, and modified all the other parts of
the machinery, too.

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-02-28 14:48:57 +00:00

24 lines
687 B
Makefile

# ----- define these variables
# CACHED_FILES = $(TOPDIR)/VERSION
# CACHED_VARS = VERSION
.PHONY: cache
CACHE_FILE_MK ?= .cache.mk
# if not checked against MAKECMDGOALS, a standard rule kicks in from rules.mk,
# and $(CACHE_FILE_MK) is remade with the clean target
all: cache
ifneq ($(foreach g,all cache,$(findstring $(g),$(MAKECMDGOALS))),)
cache: $(CACHE_FILE_MK)
$(CACHE_FILE_MK): $(CACHED_FILES) $(MODDIR)/make/cache.mk
ifeq ($(wildcard $(CACHE_FILE_MK)),)
@echo $(foreach v,$(CACHED_VARS),$v := $(value $(v))EOL) | $(SED) 's/EOL */\n/g;' | $(GREP) . | tee $@.tmp
mv $@.tmp $@
else
rm $@
make $@
endif
endif
clean: clean-cache
clean-cache:
$(RM) -f $(CACHE_FILE_MK)