Merge "Uplift scenario files to Liberty" into stable/brahmaputra
[fuel.git] / build / cache.mk
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 ##############################################################################
10
11 #############################################################################
12 # Cache operations - only used when building through ci/build.sh
13 #
14 # This is the global cache implementation, providing the main target "cache"
15 # which is called from ci/build.sh, and recursively calling the cache
16 # operations clean-cache, get-cache and put-cache on all $(SUBDIRS).
17 #############################################################################
18
19
20 export CACHETOOL := $(BUILD_BASE)/cache.sh
21
22 # Call sub caches
23 SUBGETCACHE = $(addsuffix .getcache,$(SUBDIRS))
24 $(SUBGETCACHE): %.getcache:
25         $(MAKE) -C $* -f Makefile get-cache
26
27 SUBPUTCACHE = $(addsuffix .putcache,$(SUBDIRS))
28 $(SUBPUTCACHE): %.putcache:
29         $(MAKE) -C $* -f Makefile put-cache
30
31 SUBCLEANCACHE = $(addsuffix .cleancache,$(SUBDIRS))
32 $(SUBCLEANCACHE): %.cleancache:
33         $(MAKE) -C $* -f Makefile clean-cache
34
35 # Overlay implementation:
36 #   - clean
37 #   - clean cache identities
38 #   - get caches
39 #   - build iso
40 #   - store caches
41 .PHONY: cached-all
42 cached-all: clean clean-cache $(SUBCLEANCACHE) get-cache $(SUBGETCACHE) iso put-cache $(SUBPUTCACHE)
43         @echo "Cached build is complete"
44
45
46 # cache: The target for ci/build.sh
47 .PHONY: cache
48 cache:
49         @if [ -z "${CACHEBASE}" ]; then \
50                 echo "CACHEBASE not set, are you really building through build.sh?"; \
51                 exit 1; \
52         fi
53         @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
54         @make -C docker
55         docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) cached-all