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