1 ##############################################################################
2 # Copyright (c) 2016 Cavium
3 # Copyright (c) 2016 Enea AB and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 # NOTE: Armband patching consists of:
11 # - clone upstream repositories to git submodules;
12 # - checkout submodule commits where set in Fuel@OPNFV's config.mk
13 # (e.g. FUEL_ASTUTE_COMMIT=...);
14 # - tag each submodule (before patching) with "armband-workbench-root";
15 # - apply Armband patches for each submodule;
16 # - tag each submodule (after patching) with "armband-workbench";
17 # - pass updated repository info to Fuel@OPNFV build system
18 # (e.g. FUEL_ASTUTE_COMMIT=HEAD) via armband.mk;
20 # NOTE: Long-term goals (Armband repo should merge with Fuel@OPNFV):
21 # - all build related changes should affect Fuel@OPNFV, NOT Armband;
22 # - Armband make/build system should only handle patching,
23 # including eventual build related patching of Fuel@OPNFV,
24 # and then invoke Fuel@OPNFV's build system;
25 # - Fuel@OPNFV is made aware of an Armband type build by passing
26 # the "ARMBAND_BASE" env var;
28 # Fist, inherit Fuel submodule commit references from Fuel@OPNFV
29 # using "config.mk" as a make target that links to Fuel's config.mk.
30 # Some values will be overriden at Fuel ISO build time by armband.mk.
33 export ARMBAND_BASE := $(shell pwd)
34 export OPNFV_GIT_SHA := $(shell git rev-parse HEAD)
37 # Prepare for future directory re-layout when merging with Fuel@OPNFV
38 PATCH_DIR := ${ARMBAND_BASE}/patches
39 SUBMOD_DIR := ${ARMBAND_BASE}/upstream
40 FUEL_BASE := ${SUBMOD_DIR}/fuel
44 # Use config.mk & clean_cache.sh from Fuel@OPNFV
45 config.mk: submodules-init
46 @ln -sf ${FUEL_BASE}/build/config.mk ${ARMBAND_BASE}/config.mk
47 @ln -sf ${FUEL_BASE}/ci/clean_cache.sh ${ARMBAND_BASE}/ci/clean_cache.sh
49 # Fetch & update git submodules, checkout remote HEAD
50 .PHONY: submodules-init
52 @if [ ! -d ${FUEL_BASE}/build ]; then \
53 git submodule -q init; \
54 git submodule -q sync; \
55 git submodule update --remote; \
58 # Clean any changes made to submodules, checkout Armband root commit
59 .PHONY: submodules-clean
60 submodules-clean: submodules-init
61 @git submodule -q foreach ' \
62 git am -q --abort 2>/dev/null; \
63 git checkout -q armband-workbench-root 2>/dev/null; \
64 git branch -q -D armband-workbench 2>/dev/null; \
65 git tag -d armband-workbench-root 2>/dev/null; \
66 git reset -q --hard HEAD; \
69 # Generate patches from submodules
70 .PHONY: patches-export
71 patches-export: submodules-init
72 @git submodule -q foreach ' \
73 mkdir -p ${PATCH_DIR}/$$name; \
74 git format-patch --no-signature \
75 -o ${PATCH_DIR}/$$name -N armband-workbench-root'
76 @find ${PATCH_DIR} -name '*.patch' -exec sed -i -e '1d' {} \;
78 # Apply patches from patches/* to respective submodules
79 # For repos pinned in Fuel@OPNFV's config.mk, checkout pinned commit first
80 .PHONY: patches-import
81 patches-import: submodules-init
82 @cd ${FUEL_BASE} && git checkout -q master
83 @cd ${SUBMOD_DIR}/fuel-agent && git checkout -q ${FUEL_AGENT_COMMIT}
84 @cd ${SUBMOD_DIR}/fuel-astute && git checkout -q ${ASTUTE_COMMIT}
85 @cd ${SUBMOD_DIR}/fuel-library && git checkout -q ${FUELLIB_COMMIT}
86 @cd ${SUBMOD_DIR}/fuel-mirror && git checkout -q ${FUEL_MIRROR_COMMIT}
87 @cd ${SUBMOD_DIR}/fuel-nailgun-agent && \
88 git checkout -q ${FUEL_NAILGUN_AGENT_COMMIT}
89 @cd ${SUBMOD_DIR}/fuel-web && git checkout -q ${NAILGUN_COMMIT}
90 @git submodule -q foreach ' \
91 mkdir -p ${PATCH_DIR}/$$name; \
92 git tag armband-workbench-root; \
93 git checkout -q -b armband-workbench; \
94 if [ ! -z "$$(ls ${PATCH_DIR}/$$name/)" ]; then \
95 echo "-- patching $$name"; \
96 git am --whitespace=nowarn \
97 --committer-date-is-author-date \
98 ${PATCH_DIR}/$$name/*.patch; \
101 # Pass down clean/deepclean/build to Fuel@OPNFV
103 clean: submodules-init
104 $(MAKE) -e --no-print-directory -C ${FUEL_BASE}/build clean
107 deepclean: submodules-init
108 $(MAKE) -e --no-print-directory -C ${FUEL_BASE}/build deepclean
112 $(MAKE) -e --no-print-directory -C ${FUEL_BASE}/build all
115 release: export LC_ALL=en_US.UTF-8
116 release: submodules-clean patches-import build