forked from projectacrn/acrn-hypervisor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
230 lines (188 loc) · 8.36 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# acrn-hypervisor/Makefile
# global helper variables
T := $(CURDIR)
TARGET_DIR ?=
# BOARD/SCENARIO/BOARD_FILE/SCENARIO_FILE/KCONFIG_FILE parameters sanity check:
#
# Only below usages are VALID: (target = all | hypervisor)
# 1. make <target>
# 2. make <target> KCONFIG_FILE=xxx [TARGET_DIR=xxx]
# 3. make <target> BOARD=xxx SCENARIO=xxx [TARGET_DIR=xxx]
# 4. make <target> BOARD_FILE=xxx SCENARIO_FILE=xxx [TARGET_DIR=xxx]
#
# Especially for case 1 that no any parameters are specified:
# a. If hypervisor/build/.config file which generated by "make menuconfig" exist,
# the .config file will be loaded as KCONFIG_FILE:
# i.e. equal: make <target> KCONFIG_FILE=hypervisor/build/.config
#
# b. If hypervisor/build/.config file does not exist,
# the default BOARD/SCENARIO will be loaded:
# i.e. equal: make <target> BOARD=$(BOARD) SCENARIO=$(SCENARIO)
#
# For case 2/3, configurations are imported from TARGET_DIR when TARGET_DIR is specified;
# For case 4, configurations are from XML files and saved to TARGET_DIR if it is specified;
#
# The grep process did not handle corner case when '#' is manually put right after config value as comments,
# i.e. it will be failed in the case of "CONFIG_XXX=y # some comments here "
ifneq ($(KCONFIG_FILE),)
ifneq ($(KCONFIG_FILE), $(wildcard $(KCONFIG_FILE)))
$(error KCONFIG_FILE: $(KCONFIG_FILE) does not exist)
endif
override KCONFIG_FILE := $(realpath $(KCONFIG_FILE))
else
override KCONFIG_FILE := $(T)/hypervisor/build/.config
endif
ifneq ($(BOARD)$(SCENARIO),)
ifneq ($(BOARD_FILE)$(SCENARIO_FILE),)
$(error BOARD/SCENARIO parameter could not coexist with BOARD_FILE/SCENARIO_FILE)
endif
endif
ifneq ($(TARGET_DIR),)
CFG_DIR := $(realpath $(TARGET_DIR))
ifeq ($(CFG_DIR),)
ifeq ($(BOARD_FILE)$(SCENARIO_FILE),)
$(error TARGET_DIR $(TARGET_DIR) does not exist)
endif
endif
override TARGET_DIR := $(abspath $(TARGET_DIR))
endif
ifneq ($(BOARD_FILE)$(SCENARIO_FILE),)
ifneq ($(BOARD_FILE), $(wildcard $(BOARD_FILE)))
$(error BOARD_FILE: $(BOARD_FILE) does not exist)
endif
ifneq ($(SCENARIO_FILE), $(wildcard $(SCENARIO_FILE)))
$(error SCENARIO_FILE: $(SCENARIO_FILE) does not exist)
endif
override BOARD_FILE := $(realpath $(BOARD_FILE))
override SCENARIO_FILE := $(realpath $(SCENARIO_FILE))
endif
ifeq ($(KCONFIG_FILE), $(wildcard $(KCONFIG_FILE)))
ifneq ($(BOARD)$(SCENARIO),)
$(error BOARD/SCENARIO parameter could not coexist with Kconfig file: $(KCONFIG_FILE))
endif
ifneq ($(BOARD_FILE)$(SCENARIO_FILE),)
$(error BOARD_FILE/SCENARIO_FILE parameter could not coexist with Kconfig file: $(KCONFIG_FILE))
endif
BOARD_IN_KCONFIG := $(shell grep CONFIG_BOARD= $(KCONFIG_FILE) | grep -v '\#' | awk -F '"' '{print $$2}')
ifeq ($(BOARD_IN_KCONFIG),)
$(error no BOARD info in KCONFIG_FILE: $(KCONFIG_FILE))
endif
SCENARIO_IN_KCONFIG := $(shell grep CONFIG_SCENARIO= $(KCONFIG_FILE) | grep -v '\#' | awk -F '"' '{print $$2}')
ifeq ($(SCENARIO_IN_KCONFIG),)
$(error no SCENARIO info in KCONFIG_FILE: $(KCONFIG_FILE))
endif
override BOARD := $(BOARD_IN_KCONFIG)
override SCENARIO := $(SCENARIO_IN_KCONFIG)
RELEASE := $(shell grep CONFIG_RELEASE=y $(KCONFIG_FILE) | grep -v '\#')
ifneq ($(RELEASE),)
override RELEASE := 1
endif
endif
BOARD ?= kbl-nuc-i7
ifeq ($(BOARD), apl-nuc)
override BOARD := nuc6cayh
else ifeq ($(BOARD), kbl-nuc-i7)
override BOARD := nuc7i7dnb
endif
SCENARIO ?= industry
O ?= build
ROOT_OUT := $(shell mkdir -p $(O);cd $(O);pwd)
HV_OUT := $(ROOT_OUT)/hypervisor
DM_OUT := $(ROOT_OUT)/devicemodel
TOOLS_OUT := $(ROOT_OUT)/misc/tools
DOC_OUT := $(ROOT_OUT)/doc
BUILD_VERSION ?=
BUILD_TAG ?=
HV_CFG_LOG = $(HV_OUT)/cfg.log
VM_CONFIGS_DIR = $(T)/misc/vm_configs
DEFCONFIG_FILE = scenarios/$(SCENARIO)/$(BOARD)/$(BOARD).config
export TOOLS_OUT BOARD SCENARIO RELEASE
.PHONY: all hypervisor devicemodel tools doc
all: hypervisor devicemodel tools
@cat $(HV_CFG_LOG)
include $(T)/hypervisor/scripts/makefile/cfg_update.mk
#help functions to build acrn and install acrn/acrn symbols
define build_acrn
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)/$(1) BOARD=$(1) SCENARIO=$(2) RELEASE=$(RELEASE) clean
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)/$(1) BOARD=$(1) SCENARIO=$(2) RELEASE=$(RELEASE) defconfig
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)/$(1) BOARD=$(1) SCENARIO=$(2) RELEASE=$(RELEASE) oldconfig
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)/$(1) BOARD=$(1) SCENARIO=$(2) RELEASE=$(RELEASE)
endef
define install_acrn
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)/$(1) BOARD=$(1) SCENARIO=$(2) RELEASE=$(RELEASE) install
endef
define install_acrn_debug
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)/$(1) BOARD=$(1) SCENARIO=$(2) RELEASE=$(RELEASE) install-debug
endef
hypervisor:
@if [ "$(BOARD_FILE)" != "" ] && [ -f $(BOARD_FILE) ] && [ "$(SCENARIO_FILE)" != "" ] && [ -f $(SCENARIO_FILE) ] && [ "$(TARGET_DIR)" = "" ]; then \
echo "No TARGET_DIR parameter is specified, the original configuration source is overwritten!";\
fi
$(MAKE) -C $(T)/hypervisor BOARD=$(BOARD) HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) TARGET_DIR=$(TARGET_DIR) defconfig;
$(MAKE) -C $(T)/hypervisor BOARD=$(BOARD) HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) TARGET_DIR=$(TARGET_DIR) oldconfig;
$(MAKE) -C $(T)/hypervisor BOARD=$(BOARD) HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) TARGET_DIR=$(TARGET_DIR)
@echo -e "\n\033[47;30mACRN Configuration Summary:\033[0m \nBOARD = $(BOARD)\t SCENARIO = $(SCENARIO)" > $(HV_CFG_LOG); \
echo -e "BUILD type = \c" >> $(HV_CFG_LOG); \
if [ "$(RELEASE)" = "0" ]; then echo -e "DEBUG" >> $(HV_CFG_LOG); else echo -e "RELEASE" >> $(HV_CFG_LOG); fi; \
if [ -f $(KCONFIG_FILE) ]; then \
echo -e "Hypervisor configuration is based on:\n\tKconfig file:\t$(KCONFIG_FILE);" >> $(HV_CFG_LOG); \
fi; \
echo -e "Hypervisor configuration is based on:" >> $(HV_CFG_LOG); \
if [ "$(TARGET_DIR)" = "" ]; then \
if [ ! -f $(KCONFIG_FILE) ]; then \
echo -e "\tdefconfig file:\t\t\t$(VM_CONFIGS_DIR)/$(DEFCONFIG_FILE);" >> $(HV_CFG_LOG); \
fi; \
elif [ ! -f $(KCONFIG_FILE) ]; then \
echo -e "\tdefconfig file:\t\t\t$(TARGET_DIR)/$(DEFCONFIG_FILE);" >> $(HV_CFG_LOG); \
fi; \
echo -e "\tOthers are set by default in:\t$(T)/hypervisor/arch/x86/Kconfig;" >> $(HV_CFG_LOG); \
echo -e "VM configuration is based on:" >> $(HV_CFG_LOG); \
if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \
echo -e "\tBOARD File:\t\t$(BOARD_FILE);\n\t\tSCENARIO File:\t$(SCENARIO_FILE);" >> $(HV_CFG_LOG); \
elif [ "$(TARGET_DIR)" = "" ]; then \
echo -e "\tSource code at:\t\t\t$(VM_CONFIGS_DIR)" >> $(HV_CFG_LOG); \
else \
echo -e "\tSource code at:\t\t\t$(TARGET_DIR)" >> $(HV_CFG_LOG); \
fi;
@cat $(HV_CFG_LOG)
devicemodel: tools
$(MAKE) -C $(T)/devicemodel DM_OBJDIR=$(DM_OUT) DM_BUILD_VERSION=$(BUILD_VERSION) DM_BUILD_TAG=$(BUILD_TAG) DM_ASL_COMPILER=$(ASL_COMPILER) RELEASE=$(RELEASE)
tools:
mkdir -p $(TOOLS_OUT)
$(MAKE) -C $(T)/misc OUT_DIR=$(TOOLS_OUT) RELEASE=$(RELEASE)
doc:
$(MAKE) -C $(T)/doc html BUILDDIR=$(DOC_OUT)
.PHONY: clean
clean:
$(MAKE) -C $(T)/misc OUT_DIR=$(TOOLS_OUT) clean
$(MAKE) -C $(T)/doc BUILDDIR=$(DOC_OUT) clean
rm -rf $(ROOT_OUT)
rm -rf $(TARGET_DIR)
.PHONY: install
install: hypervisor-install devicemodel-install tools-install
hypervisor-install:
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD=$(BOARD) SCENARIO=$(SCENARIO) RELEASE=$(RELEASE) install
hypervisor-install-debug:
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD=$(BOARD) SCENARIO=$(SCENARIO) RELEASE=$(RELEASE) install-debug
kbl-nuc-i7-industry:
$(call build_acrn,nuc7i7dnb,industry)
apl-up2-hybrid:
$(call build_acrn,apl-up2,hybrid)
sbl-hypervisor: kbl-nuc-i7-industry \
apl-up2-hybrid
kbl-nuc-i7-industry-install:
$(call install_acrn,nuc7i7dnb,industry)
apl-up2-hybrid-install:
$(call install_acrn,apl-up2,hybrid)
sbl-hypervisor-install: kbl-nuc-i7-industry-install \
apl-up2-hybrid-install
kbl-nuc-i7-industry-install-debug:
$(call install_acrn_debug,nuc7i7dnb,industry)
apl-up2-hybrid-install-debug:
$(call install_acrn_debug,apl-up2,hybrid)
sbl-hypervisor-install-debug: kbl-nuc-i7-industry-install-debug \
apl-up2-hybrid-install-debug
devicemodel-install:
$(MAKE) -C $(T)/devicemodel DM_OBJDIR=$(DM_OUT) install
tools-install:
$(MAKE) -C $(T)/misc OUT_DIR=$(TOOLS_OUT) RELEASE=$(RELEASE) install