1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # stefan.k.berg@ericsson.com
4 # jonas.bjurel@ericsson.com
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
12 CACHEVALIDATE := $(addsuffix .validate,$(SUBDIRS))
13 CACHECLEAN := $(addsuffix .clean,$(CACHEFILES) $(CACHEDIRS))
15 ############################################################################
16 # BEGIN of variables to customize
18 CACHEFILES += .versions
19 CACHEFILES += $(shell basename $(ISOSRC))
21 # END of variables to customize
22 ############################################################################
25 prepare-cache: make-cache-dir $(CACHEDIRS) $(CACHEFILES)
27 .PHONY: make-cache-dir
33 clean-cache: $(CACHECLEAN)
38 @mkdir -p $(dir $(CACHE_DIR)/$@)
39 @if [ ! -d $(BUILD_BASE)/$@ ]; then\
40 mkdir -p $(BUILD_BASE)/$@;\
42 @ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@
46 @mkdir -p $(dir $(CACHE_DIR)/$@)
47 @if [ ! -d $(dir $(BUILD_BASE)/$@) ]; then\
48 mkdir -p $(dir $(BUILD_BASE)/$@);\
51 @if [ ! -f $(BUILD_BASE)/$@ ]; then\
52 echo " " > $(BUILD_BASE)/$@;\
53 ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@;\
54 rm -f $(BUILD_BASE)/$@;\
56 ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@;\
59 .PHONY: validate-cache
60 validate-cache: $(CACHEVALIDATE)
61 @if [[ $(shell md5sum $(BUILD_BASE)/config.mk | cut -f1 -d " ") != $(shell cat $(VERSION_FILE) | grep config.mk | awk '{print $$NF}') ]]; then\
62 echo "Cache does not match current config.mk definition, cache must be rebuilt";\
66 @if [[ $(shell md5sum $(BUILD_BASE)/cache.mk | cut -f1 -d " ") != $(shell cat $(VERSION_FILE) | grep cache.mk | awk '{print $$NF}') ]]; then\
67 echo "Cache does not match current cache.mk definition, cache must be rebuilt";\
71 .PHONY: $(CACHEVALIDATE)
72 $(CACHEVALIDATE): %.validate:
73 @echo VALIDATE $(CACHEVALIDATE)
74 $(MAKE) -C $* -f Makefile validate-cache
77 $(CACHECLEAN): %.clean:
78 rm -rf ${CACHE_DIR}/$*