]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/build32.sh
3b0516b0efe91f65daa191e6314f4c61298b02e0
[mirror_edk2.git] / OvmfPkg / build32.sh
1 #!/bin/bash
2 #
3 # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 # Copyright (c) 2010, 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 PROCESSOR=IA32
41 Processor=Ia32
42
43 #
44 # Pick a default tool type for a given OS
45 #
46 TARGET_TOOLS=MYTOOLS
47 case `uname` in
48 CYGWIN*) echo Cygwin not fully supported yet. ;;
49 Darwin*)
50 Major=$(uname -r | cut -f 1 -d '.')
51 if [[ $Major == 9 ]]
52 then
53 echo OvmfPkg requires Snow Leopard or later OS
54 exit 1
55 else
56 TARGET_TOOLS=XCODE32
57 fi
58 ;;
59 Linux*)
60 TARGET_TOOLS=GCC44
61 ;;
62
63 esac
64
65 BUILD_ROOT=$WORKSPACE/Build/Ovmf$Processor/DEBUG_"$TARGET_TOOLS"
66 FV_DIR=$BUILD_ROOT/FV
67 BUILD_ROOT_ARCH=$BUILD_ROOT/$PROCESSOR
68 QEMU_FIRMWARE_DIR=$BUILD_ROOT/QEMU
69
70 if [[ ! -f `which build` || ! -f `which GenFv` ]];
71 then
72 # build the tools if they don't yet exist. Bin scheme
73 echo Building tools as they are not in the path
74 make -C $WORKSPACE/BaseTools
75 elif [[ ( -f `which build` || -f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]];
76 then
77 # build the tools if they don't yet exist. BinWrapper scheme
78 echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
79 make -C $WORKSPACE/BaseTools
80 else
81 echo using prebuilt tools
82 fi
83
84
85 for arg in "$@"
86 do
87 if [[ $arg == qemu ]]; then
88 shift
89 if [[ ! -d $QEMU_FIRMWARE_DIR ]]; then
90 mkdir $QEMU_FIRMWARE_DIR
91 ln -s $FV_DIR/OVMF.fd $QEMU_FIRMWARE_DIR/bios.bin
92 ln -s $FV_DIR/CirrusLogic5446.rom $QEMU_FIRMWARE_DIR/vgabios-cirrus.bin
93 fi
94 QEMU_COMMAND="qemu -L $QEMU_FIRMWARE_DIR -hda fat:$BUILD_ROOT_ARCH $*"
95 echo Running: $QEMU_COMMAND
96 $QEMU_COMMAND
97 exit
98 fi
99
100 if [[ $arg == cleanall ]]; then
101 make -C $WORKSPACE/BaseTools clean
102 build -p $WORKSPACE/OvmfPkg/OvmfPkg$Processor.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 clean
103 exit $?
104 fi
105
106 if [[ $arg == clean ]]; then
107 build -p $WORKSPACE/OvmfPkg/OvmfPkg$Processor.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 clean
108 exit $?
109 fi
110 done
111
112
113 #
114 # Build the edk2 OvmfPkg
115 #
116 echo Running edk2 build for OvmfPkg$Processor
117 build -p $WORKSPACE/OvmfPkg/OvmfPkg$Processor.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 $*
118 exit $?
119