jw-pkg/make/cache.mk
Jan Lindemann b2d6e6f554 Everywhere: Rename MODDIR -> JWBDIR
Rename the omnipresent MODDIR variable to JWBDIR, since that's more to the
point.

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-06-29 21:34:18 +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) $(JWBDIR)/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)