3 # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 # Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
6 # This program and the accompanying materials
7 # are licensed and made available under the terms and conditions of the BSD License
8 # which accompanies this distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 # Setup workspace if it is not set
22 if [ -z "$WORKSPACE" ]
24 echo Initializing workspace
25 if [ ! -e `pwd`/edksetup.sh
]
29 # This version is for the tools in the BaseTools project.
30 # this assumes svn pulls have the same root dir
31 # export EDK_TOOLS_PATH=`pwd`/../BaseTools
32 # This version is for the tools source in edk2
33 export EDK_TOOLS_PATH
=`pwd`/BaseTools
35 source edksetup.sh BaseTools
37 echo Building from
: $WORKSPACE
41 # Configure defaults for various options
55 # Pick a default tool type for a given OS
60 echo Cygwin not fully supported yet.
63 Major
=$
(uname
-r | cut
-f 1 -d '.')
64 # Major is Darwin version, not OS X version.
65 # OS X Yosemite 10.10.2 returns 14.
68 echo OvmfPkg requires OS X Snow Leopard
10.6 or newer OS
78 # Mavericks and future assume XCODE5 (clang + lldb)
84 gcc_version
=$
(gcc
-v 2>&1 |
tail -1 |
awk '{print $3}')
87 echo OvmfPkg requires GCC4.4 or later
115 # Scan command line to override defaults
120 if [ -z "$LAST_ARG" ]; then
134 BUILD_OPTIONS
="$BUILD_OPTIONS $arg"
140 if [[ x
"$arg" != x
"IA32" && x
"$arg" != x
"X64" ]]; then
141 echo Unsupported processor architecture
: $arg
142 echo Only IA32 or X64 is supported
160 BUILD_OPTIONS
="$BUILD_OPTIONS $arg"
168 if [[ "$ARCH_IA32" == "yes" && "$ARCH_X64" == "yes" ]]; then
171 BUILD_OPTIONS
="$BUILD_OPTIONS -a IA32 -a X64"
172 PLATFORM_BUILD_DIR
=Ovmf3264
174 elif [[ "$ARCH_IA32" == "yes" && "$ARCH_X64" == "no" ]]; then
177 BUILD_OPTIONS
="$BUILD_OPTIONS -a IA32"
178 PLATFORM_BUILD_DIR
=Ovmf
$Processor
179 BUILD_ROOT_ARCH
=$PROCESSOR
183 BUILD_OPTIONS
="$BUILD_OPTIONS -a X64"
184 PLATFORM_BUILD_DIR
=Ovmf
$Processor
190 if [ -n "$QEMU_COMMAND" ]; then
192 # The user set the QEMU_COMMAND variable. We'll use it to run QEMU.
195 elif [ -x `which qemu-system-i386` ]; then
196 QEMU_COMMAND
=qemu-system-i386
197 elif [ -x `which qemu-system-x86_64` ]; then
198 QEMU_COMMAND
=qemu-system-x86_64
199 elif [ -x `which qemu` ]; then
202 echo Unable to
find QEMU
for IA32 architecture
!
207 if [ -z "$QEMU_COMMAND" ]; then
209 # The user didn't set the QEMU_COMMAND variable.
211 QEMU_COMMAND
=qemu-system-x86_64
215 echo Unsupported processor architecture
: $PROCESSOR
216 echo Only IA32 or X64 is supported
221 if [ -z "$PLATFORMFILE" ]; then
222 PLATFORMFILE
=$WORKSPACE/OvmfPkg
/OvmfPkg
$Processor.dsc
225 if [[ "$RUN_QEMU" == "yes" ]]; then
226 qemu_version
=$
($QEMU_COMMAND -version 2>&1 | \
227 grep -o -E 'version [0-9]+\.[0-9]+\.[0-9]+' | \
229 case $qemu_version in
230 1.
[6-9].
*|
1.
[1-9][0-9].
*|
2.
*.
*)
239 -hd[a-d
]|
-fd[ab
]|
-cdrom)
248 # Uncomment this block for parameter parsing debug
250 #echo RUN_QEMU=$RUN_QEMU
251 #echo BUILD_OPTIONS=$BUILD_OPTIONS
252 #echo BUILDTARGET=$BUILDTARGET
253 #echo TARGET_TOOLS=$TARGET_TOOLS
254 #echo PROCESSOR=$PROCESSOR
255 #echo Remaining for qemu: $*
258 BUILD_ROOT
=$WORKSPACE/Build
/$PLATFORM_BUILD_DIR/"$BUILDTARGET"_
"$TARGET_TOOLS"
259 FV_DIR
=$BUILD_ROOT/FV
260 BUILD_ROOT_ARCH
=$BUILD_ROOT/$BUILD_ROOT_ARCH
261 QEMU_FIRMWARE_DIR
=$BUILD_ROOT/QEMU
263 if [[ ! -f `which build` ||
! -f `which GenFv` ]];
265 # build the tools if they don't yet exist. Bin scheme
266 echo Building tools as they are not
in the path
267 make -C $WORKSPACE/BaseTools
268 elif [[ ( -f `which build` ||
-f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source
/C
/bin
]];
270 # build the tools if they don't yet exist. BinWrapper scheme
271 echo Building tools no
$EDK_TOOLS_PATH/Source
/C
/bin directory
272 make -C $WORKSPACE/BaseTools
274 echo using prebuilt tools
278 if [[ "$RUN_QEMU" == "yes" ]]; then
279 if [[ ! -d $QEMU_FIRMWARE_DIR ]]; then
280 mkdir
$QEMU_FIRMWARE_DIR
282 ln -sf $FV_DIR/OVMF.fd
$QEMU_FIRMWARE_DIR/bios.bin
283 if [[ "$ENABLE_FLASH" == "yes" ]]; then
284 QEMU_COMMAND
="$QEMU_COMMAND -pflash $QEMU_FIRMWARE_DIR/bios.bin"
286 QEMU_COMMAND
="$QEMU_COMMAND -L $QEMU_FIRMWARE_DIR"
288 if [[ "$ADD_QEMU_HDA" == "yes" ]]; then
289 QEMU_COMMAND
="$QEMU_COMMAND -hda fat:$BUILD_ROOT_ARCH"
291 echo Running
: $QEMU_COMMAND "$@"
297 # Build the edk2 OvmfPkg
299 echo Running edk2 build
for OvmfPkg
$Processor
300 build
-p $PLATFORMFILE $BUILD_OPTIONS -b $BUILDTARGET -t $TARGET_TOOLS -n $THREADNUMBER