]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/build.sh
StdLib: Fix some corrupted comments and inconsistent indentation.
[mirror_edk2.git] / OvmfPkg / build.sh
CommitLineData
5a9745b9 1#!/bin/bash
2#
3# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
04629652 4# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
5a9745b9 5#
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
10#
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.
13#
14
15set -e
16shopt -s nocasematch
17
18
19#
20# Setup workspace if it is not set
21#
22if [ -z "$WORKSPACE" ]
23then
24 echo Initializing workspace
25 if [ ! -e `pwd`/edksetup.sh ]
26 then
27 cd ..
28 fi
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
34 echo $EDK_TOOLS_PATH
35 source edksetup.sh BaseTools
36else
37 echo Building from: $WORKSPACE
38fi
39
66325870 40#
41# Configure defaults for various options
42#
43
5a9745b9 44PROCESSOR=X64
66325870 45BUILDTARGET=DEBUG
46BUILD_OPTIONS=
04629652 47PLATFORMFILE=
66325870 48LAST_ARG=
49RUN_QEMU=no
5a9745b9 50
51#
52# Pick a default tool type for a given OS
53#
54TARGET_TOOLS=MYTOOLS
55case `uname` in
66325870 56 CYGWIN*)
57 echo Cygwin not fully supported yet.
58 ;;
5a9745b9 59 Darwin*)
60 Major=$(uname -r | cut -f 1 -d '.')
61 if [[ $Major == 9 ]]
62 then
63 echo OvmfPkg requires Snow Leopard or later OS
64 exit 1
65 else
66 TARGET_TOOLS=XCODE32
67 fi
68 ;;
69 Linux*)
8567a8ca 70 gcc_version=$(gcc -v 2>&1 | tail -1 | awk '{print $3}')
71 case $gcc_version in
72 4.5.*)
73 TARGET_TOOLS=GCC45
74 ;;
75 4.6.*)
76 TARGET_TOOLS=GCC46
77 ;;
78 *)
79 TARGET_TOOLS=GCC44
80 exit 1
81 ;;
82 esac
66325870 83esac
84
85#
86# Scan command line to override defaults
87#
5a9745b9 88
66325870 89for arg in "$@"
90do
91 if [ -z "$LAST_ARG" ]; then
92 case $arg in
04629652 93 -a|-b|-t|-p)
66325870 94 LAST_ARG=$arg
95 ;;
96 qemu)
97 RUN_QEMU=yes
98 shift
99 break
100 ;;
101 *)
102 BUILD_OPTIONS="$BUILD_OPTIONS $arg"
103 ;;
104 esac
105 else
106 case $LAST_ARG in
107 -a)
108 PROCESSOR=$arg
109 ;;
110 -b)
111 BUILDTARGET=$arg
112 ;;
04629652 113 -p)
114 PLATFORMFILE=$arg
115 ;;
66325870 116 -t)
117 TARGET_TOOLS=$arg
118 ;;
119 *)
120 BUILD_OPTIONS="$BUILD_OPTIONS $arg"
121 ;;
122 esac
123 LAST_ARG=
124 fi
125 shift
126done
127
128case $PROCESSOR in
129 IA32)
130 Processor=Ia32
131 QEMU_COMMAND=qemu
132 ;;
133 X64)
134 Processor=X64
135 QEMU_COMMAND=qemu-system-x86_64
136 ;;
137 *)
138 echo Unsupported processor architecture: $PROCESSOR
139 echo Only IA32 or X64 is supported
140 exit 1
141 ;;
5a9745b9 142esac
143
04629652 144if [ -z "$PLATFORMFILE" ]; then
145 PLATFORMFILE=$WORKSPACE/OvmfPkg/OvmfPkg$Processor.dsc
146fi
147
66325870 148ADD_QEMU_HDA=yes
149for arg in "$@"
150do
151 case $arg in
152 -hd[a-d]|-fd[ab]|-cdrom)
153 ADD_QEMU_HDA=no
154 break
155 ;;
156 esac
157done
158
159#
160# Uncomment this block for parameter parsing debug
161#
162#echo RUN_QEMU=$RUN_QEMU
163#echo BUILD_OPTIONS=$BUILD_OPTIONS
164#echo BUILDTARGET=$BUILDTARGET
165#echo TARGET_TOOLS=$TARGET_TOOLS
166#echo PROCESSOR=$PROCESSOR
167#echo Remaining for qemu: $*
168#exit 1
169
170BUILD_ROOT=$WORKSPACE/Build/Ovmf$Processor/"$BUILDTARGET"_"$TARGET_TOOLS"
5a9745b9 171FV_DIR=$BUILD_ROOT/FV
172BUILD_ROOT_ARCH=$BUILD_ROOT/$PROCESSOR
173QEMU_FIRMWARE_DIR=$BUILD_ROOT/QEMU
174
175if [[ ! -f `which build` || ! -f `which GenFv` ]];
176then
177 # build the tools if they don't yet exist. Bin scheme
178 echo Building tools as they are not in the path
179 make -C $WORKSPACE/BaseTools
180elif [[ ( -f `which build` || -f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]];
181then
182 # build the tools if they don't yet exist. BinWrapper scheme
183 echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
184 make -C $WORKSPACE/BaseTools
185else
186 echo using prebuilt tools
187fi
188
189
66325870 190if [[ "$RUN_QEMU" == "yes" ]]; then
191 if [[ ! -d $QEMU_FIRMWARE_DIR ]]; then
192 mkdir $QEMU_FIRMWARE_DIR
5a9745b9 193 fi
eaf4f336 194 ln -sf $FV_DIR/OVMF.fd $QEMU_FIRMWARE_DIR/bios.bin
195 ln -sf $FV_DIR/OvmfVideo.rom $QEMU_FIRMWARE_DIR/vgabios-cirrus.bin
66325870 196 if [[ "$ADD_QEMU_HDA" == "yes" ]]; then
197 AUTO_QEMU_HDA="-hda fat:$BUILD_ROOT_ARCH"
198 else
199 AUTO_QEMU_HDA=
5a9745b9 200 fi
66325870 201 QEMU_COMMAND="$QEMU_COMMAND -L $QEMU_FIRMWARE_DIR $AUTO_QEMU_HDA $*"
202 echo Running: $QEMU_COMMAND
203 $QEMU_COMMAND
204 exit $?
205fi
5a9745b9 206
207#
208# Build the edk2 OvmfPkg
209#
210echo Running edk2 build for OvmfPkg$Processor
04629652 211build -p $PLATFORMFILE $BUILD_OPTIONS -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS
5a9745b9 212exit $?
213