]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/build.sh
Clean up GCD DEBUG() macros so DEBUG_CODE() is only used to enable/disable the DBG...
[mirror_edk2.git] / OvmfPkg / build.sh
CommitLineData
5a9745b9 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
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=
47LAST_ARG=
48RUN_QEMU=no
5a9745b9 49
50#
51# Pick a default tool type for a given OS
52#
53TARGET_TOOLS=MYTOOLS
54case `uname` in
66325870 55 CYGWIN*)
56 echo Cygwin not fully supported yet.
57 ;;
5a9745b9 58 Darwin*)
59 Major=$(uname -r | cut -f 1 -d '.')
60 if [[ $Major == 9 ]]
61 then
62 echo OvmfPkg requires Snow Leopard or later OS
63 exit 1
64 else
65 TARGET_TOOLS=XCODE32
66 fi
67 ;;
68 Linux*)
69 TARGET_TOOLS=GCC44
70 ;;
66325870 71esac
72
73#
74# Scan command line to override defaults
75#
5a9745b9 76
66325870 77for arg in "$@"
78do
79 if [ -z "$LAST_ARG" ]; then
80 case $arg in
81 -a|-b|-t)
82 LAST_ARG=$arg
83 ;;
84 qemu)
85 RUN_QEMU=yes
86 shift
87 break
88 ;;
89 *)
90 BUILD_OPTIONS="$BUILD_OPTIONS $arg"
91 ;;
92 esac
93 else
94 case $LAST_ARG in
95 -a)
96 PROCESSOR=$arg
97 ;;
98 -b)
99 BUILDTARGET=$arg
100 ;;
101 -t)
102 TARGET_TOOLS=$arg
103 ;;
104 *)
105 BUILD_OPTIONS="$BUILD_OPTIONS $arg"
106 ;;
107 esac
108 LAST_ARG=
109 fi
110 shift
111done
112
113case $PROCESSOR in
114 IA32)
115 Processor=Ia32
116 QEMU_COMMAND=qemu
117 ;;
118 X64)
119 Processor=X64
120 QEMU_COMMAND=qemu-system-x86_64
121 ;;
122 *)
123 echo Unsupported processor architecture: $PROCESSOR
124 echo Only IA32 or X64 is supported
125 exit 1
126 ;;
5a9745b9 127esac
128
66325870 129ADD_QEMU_HDA=yes
130for arg in "$@"
131do
132 case $arg in
133 -hd[a-d]|-fd[ab]|-cdrom)
134 ADD_QEMU_HDA=no
135 break
136 ;;
137 esac
138done
139
140#
141# Uncomment this block for parameter parsing debug
142#
143#echo RUN_QEMU=$RUN_QEMU
144#echo BUILD_OPTIONS=$BUILD_OPTIONS
145#echo BUILDTARGET=$BUILDTARGET
146#echo TARGET_TOOLS=$TARGET_TOOLS
147#echo PROCESSOR=$PROCESSOR
148#echo Remaining for qemu: $*
149#exit 1
150
151BUILD_ROOT=$WORKSPACE/Build/Ovmf$Processor/"$BUILDTARGET"_"$TARGET_TOOLS"
5a9745b9 152FV_DIR=$BUILD_ROOT/FV
153BUILD_ROOT_ARCH=$BUILD_ROOT/$PROCESSOR
154QEMU_FIRMWARE_DIR=$BUILD_ROOT/QEMU
155
156if [[ ! -f `which build` || ! -f `which GenFv` ]];
157then
158 # build the tools if they don't yet exist. Bin scheme
159 echo Building tools as they are not in the path
160 make -C $WORKSPACE/BaseTools
161elif [[ ( -f `which build` || -f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]];
162then
163 # build the tools if they don't yet exist. BinWrapper scheme
164 echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
165 make -C $WORKSPACE/BaseTools
166else
167 echo using prebuilt tools
168fi
169
170
66325870 171if [[ "$RUN_QEMU" == "yes" ]]; then
172 if [[ ! -d $QEMU_FIRMWARE_DIR ]]; then
173 mkdir $QEMU_FIRMWARE_DIR
174 ln -s $FV_DIR/OVMF.fd $QEMU_FIRMWARE_DIR/bios.bin
175 ln -s $FV_DIR/CirrusLogic5446.rom $QEMU_FIRMWARE_DIR/vgabios-cirrus.bin
5a9745b9 176 fi
66325870 177 if [[ "$ADD_QEMU_HDA" == "yes" ]]; then
178 AUTO_QEMU_HDA="-hda fat:$BUILD_ROOT_ARCH"
179 else
180 AUTO_QEMU_HDA=
5a9745b9 181 fi
66325870 182 QEMU_COMMAND="$QEMU_COMMAND -L $QEMU_FIRMWARE_DIR $AUTO_QEMU_HDA $*"
183 echo Running: $QEMU_COMMAND
184 $QEMU_COMMAND
185 exit $?
186fi
5a9745b9 187
188#
189# Build the edk2 OvmfPkg
190#
191echo Running edk2 build for OvmfPkg$Processor
66325870 192build -p $WORKSPACE/OvmfPkg/OvmfPkg$Processor.dsc $BUILD_OPTIONS -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS
5a9745b9 193exit $?
194