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 CACHEDIRS := opendaylight/f_odl/package
20 CACHEFILES := opendaylight/.odl-build-history
21 CACHEFILES += opendaylight/.odl-build.log
22 CACHEFILES += .versions
23 CACHEFILES += $(shell basename $(ISOSRC))
25 # END of variables to customize
26 ############################################################################
29 prepare-cache: make-cache-dir $(CACHEDIRS) $(CACHEFILES)
31 .PHONY: make-cache-dir
37 clean-cache: $(CACHECLEAN)
42 @mkdir -p $(dir $(CACHE_DIR)/$@)
43 @if [ ! -d $(BUILD_BASE)/$@ ]; then\
44 mkdir -p $(BUILD_BASE)/$@;\
46 @ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@
50 @mkdir -p $(dir $(CACHE_DIR)/$@)
51 @if [ ! -d $(dir $(BUILD_BASE)/$@) ]; then\
52 mkdir -p $(dir $(BUILD_BASE)/$@);\
55 @if [ ! -f $(BUILD_BASE)/$@ ]; then\
56 echo " " > $(BUILD_BASE)/$@;\
57 ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@;\
58 rm -f $(BUILD_BASE)/$@;\
60 ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@;\
63 .PHONY: validate-cache
64 validate-cache: prepare $(CACHEVALIDATE)
65 @if [[ $(shell md5sum $(BUILD_BASE)/config.mk | cut -f1 -d " ") != $(shell cat $(VERSION_FILE) | grep config.mk | awk '{print $$NF}') ]]; then\
66 echo "Cache does not match current config.mk definition, cache must be rebuilt";\
70 @if [[ $(shell md5sum $(BUILD_BASE)/cache.mk | cut -f1 -d " ") != $(shell cat $(VERSION_FILE) | grep cache.mk | awk '{print $$NF}') ]]; then\
71 echo "Cache does not match current cache.mk definition, cache must be rebuilt";\
75 # Once the Make structure is refactored, this should go in as a validate-cache
76 # taget in the fuel Makefile
78 @REMOTE_ID=$(shell git ls-remote $(FUEL_MAIN_REPO) $(FUEL_MAIN_TAG)^{} | awk '{print $$(NF-1)}'); \
79 if [ -z $$REMOTE_ID ] || [ $$REMOTE_ID = " " ]; \
81 REMOTE_ID=$(shell git ls-remote $(FUEL_MAIN_REPO) $(FUEL_MAIN_TAG) | awk '{print $$(NF-1)}'); \
83 if [ $$REMOTE_ID != $(shell cat $(VERSION_FILE) | grep fuel | awk '{print $$NF}') ]; \
85 echo "Cache does not match upstream Fuel, cache must be rebuilt!"; \
89 #$(MAKE) -C opendaylight validate-cache
91 .PHONY: $(CACHEVALIDATE)
92 $(CACHEVALIDATE): %.validate:
93 @echo VALIDATE $(CACHEVALIDATE)
94 $(MAKE) -C $* -f Makefile validate-cache
97 $(CACHECLEAN): %.clean:
98 rm -rf ${CACHE_DIR}/$*