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 += stack/overcloud-full.tar
20 CACHEFILES += stack/undercloud.qcow2
21 CACHEFILES += $(shell basename $(ISOSRC))
23 # END of variables to customize
24 ############################################################################
27 prepare-cache: make-cache-dir $(CACHEDIRS) $(CACHEFILES)
29 .PHONY: make-cache-dir
35 clean-cache: $(CACHECLEAN)
40 @mkdir -p $(dir $(CACHE_DIR)/$@)
41 @if [ ! -d $(BUILD_BASE)/$@ ]; then\
42 mkdir -p $(BUILD_BASE)/$@;\
44 @ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@
48 @mkdir -p $(dir $(CACHE_DIR)/$@)
49 @if [ ! -d $(dir $(BUILD_BASE)/$@) ]; then\
50 mkdir -p $(dir $(BUILD_BASE)/$@);\
53 @if [ ! -f $(BUILD_BASE)/$@ ]; then\
54 echo " " > $(BUILD_BASE)/$@;\
55 ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@;\
56 rm -f $(BUILD_BASE)/$@;\
58 ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@;\
61 .PHONY: validate-cache
62 validate-cache: $(CACHEVALIDATE)
63 @if [[ $(shell md5sum $(BUILD_BASE)/config.mk | cut -f1 -d " ") != $(shell cat $(VERSION_FILE) | grep config.mk | awk '{print $$NF}') ]]; then\
64 echo "Cache does not match current config.mk definition, cache must be rebuilt";\
68 @if [[ $(shell md5sum $(BUILD_BASE)/cache.mk | cut -f1 -d " ") != $(shell cat $(VERSION_FILE) | grep cache.mk | awk '{print $$NF}') ]]; then\
69 echo "Cache does not match current cache.mk definition, cache must be rebuilt";\
73 .PHONY: $(CACHEVALIDATE)
74 $(CACHEVALIDATE): %.validate:
75 @echo VALIDATE $(CACHEVALIDATE)
76 $(MAKE) -C $* -f Makefile validate-cache
79 $(CACHECLEAN): %.clean:
80 rm -rf ${CACHE_DIR}/$*