diff options
author | Dan Radez <dradez@redhat.com> | 2015-08-14 09:49:45 -0400 |
---|---|---|
committer | Dan Radez <dradez@redhat.com> | 2015-08-14 10:00:37 -0400 |
commit | 02831889deee512a5a7e06beffe973532a5e4f5d (patch) | |
tree | 7cedfa8700005f66fde57479d0e0db6f3806d08b /build/cache.mk | |
parent | a5f42c9daf85f4a6b8f9aa5eca2383f8e1755dd1 (diff) |
Adding initial build scripts based on RDO manager
Change-Id: Ib5f8ed4dfcaa42bcefcf2a7914c201a887beeacd
Signed-off-by: Dan Radez <dradez@redhat.com>
Diffstat (limited to 'build/cache.mk')
-rw-r--r-- | build/cache.mk | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/build/cache.mk b/build/cache.mk new file mode 100644 index 00000000..fdfd0034 --- /dev/null +++ b/build/cache.mk @@ -0,0 +1,78 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +SHELL = /bin/bash +CACHEVALIDATE := $(addsuffix .validate,$(SUBDIRS)) +CACHECLEAN := $(addsuffix .clean,$(CACHEFILES) $(CACHEDIRS)) + +############################################################################ +# BEGIN of variables to customize +# +CACHEFILES += .versions +CACHEFILES += $(shell basename $(ISOSRC)) +# +# END of variables to customize +############################################################################ + +.PHONY: prepare-cache +prepare-cache: make-cache-dir $(CACHEDIRS) $(CACHEFILES) + +.PHONY: make-cache-dir +make-cache-dir: + @rm -rf ${CACHE_DIR} + @mkdir ${CACHE_DIR} + +.PHONY: clean-cache +clean-cache: $(CACHECLEAN) + @rm -rf ${CACHE_DIR} + +.PHONY: $(CACHEDIRS) +$(CACHEDIRS): + @mkdir -p $(dir $(CACHE_DIR)/$@) + @if [ ! -d $(BUILD_BASE)/$@ ]; then\ + mkdir -p $(BUILD_BASE)/$@;\ + fi + @ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@ + +.PHONY: $(CACHEFILES) +$(CACHEFILES): + @mkdir -p $(dir $(CACHE_DIR)/$@) + @if [ ! -d $(dir $(BUILD_BASE)/$@) ]; then\ + mkdir -p $(dir $(BUILD_BASE)/$@);\ + fi + + @if [ ! -f $(BUILD_BASE)/$@ ]; then\ + echo " " > $(BUILD_BASE)/$@;\ + ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@;\ + rm -f $(BUILD_BASE)/$@;\ + else\ + ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@;\ + fi + +.PHONY: validate-cache +validate-cache: $(CACHEVALIDATE) + @if [[ $(shell md5sum $(BUILD_BASE)/config.mk | cut -f1 -d " ") != $(shell cat $(VERSION_FILE) | grep config.mk | awk '{print $$NF}') ]]; then\ + echo "Cache does not match current config.mk definition, cache must be rebuilt";\ + exit 1;\ + fi; + + @if [[ $(shell md5sum $(BUILD_BASE)/cache.mk | cut -f1 -d " ") != $(shell cat $(VERSION_FILE) | grep cache.mk | awk '{print $$NF}') ]]; then\ + echo "Cache does not match current cache.mk definition, cache must be rebuilt";\ + exit 1;\ + fi; + +.PHONY: $(CACHEVALIDATE) +$(CACHEVALIDATE): %.validate: + @echo VALIDATE $(CACHEVALIDATE) + $(MAKE) -C $* -f Makefile validate-cache + +.PHONY: $(CACHECLEAN) +$(CACHECLEAN): %.clean: + rm -rf ${CACHE_DIR}/$* |