]> git.proxmox.com Git - mirror_edk2.git/blob - EmulatorPkg/build.sh
Create a MAX_TIMER_TICK_DURATION for the error handling in 8254 timer module.
[mirror_edk2.git] / EmulatorPkg / build.sh
1 #!/bin/bash
2 #
3 # Copyright (c) 2008 - 2011, 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=
45 BUILDTARGET=DEBUG
46 BUILD_OPTIONS=
47 PLATFORMFILE=
48 LAST_ARG=
49 RUN_EMULATOR=no
50 CLEAN_TYPE=none
51 TARGET_TOOLS=GCC44
52 NETWORK_SUPPORT=
53 BUILD_NEW_SHELL=
54 BUILD_FAT=
55 HOST_PROCESSOR=X64
56
57 case `uname` in
58 CYGWIN*) echo Cygwin not fully supported yet. ;;
59 Darwin*)
60 Major=$(uname -r | cut -f 1 -d '.')
61 if [[ $Major == 9 ]]
62 then
63 echo UnixPkg requires Snow Leopard or later OS
64 exit 1
65 else
66 HOST_TOOLS=XCODE32
67 TARGET_TOOLS=XCLANG
68 fi
69 BUILD_NEW_SHELL="-D BUILD_NEW_SHELL"
70 BUILD_FAT="-D BUILD_FAT"
71 ;;
72 Linux*)
73 case `uname -m` in
74 i386)
75 HOST_PROCESSOR=IA32
76 ;;
77 i686)
78 HOST_PROCESSOR=IA32
79 ;;
80 x86_64)
81 HOST_PROCESSOR=X64
82 ;;
83 esac
84
85 gcc_version=$(gcc -v 2>&1 | tail -1 | awk '{print $3}')
86 case $gcc_version in
87 4.5.*)
88 TARGET_TOOLS=GCC45
89 ;;
90 4.6.*)
91 TARGET_TOOLS=GCC46
92 ;;
93 4.[789].*)
94 TARGET_TOOLS=GCC47
95 ;;
96 *)
97 TARGET_TOOLS=GCC44
98 ;;
99 esac
100 ;;
101 esac
102
103 #
104 # Scan command line to override defaults
105 #
106
107 for arg in "$@"
108 do
109 if [ -z "$LAST_ARG" ]; then
110 case $arg in
111 -a|-b|-t|-p)
112 LAST_ARG=$arg
113 ;;
114 run)
115 RUN_EMULATOR=yes
116 shift
117 break
118 ;;
119 clean|cleanall)
120 CLEAN_TYPE=$arg
121 shift
122 break
123 ;;
124 *)
125 BUILD_OPTIONS="$BUILD_OPTIONS $arg"
126 ;;
127 esac
128 else
129 case $LAST_ARG in
130 -a)
131 PROCESSOR=$arg
132 ;;
133 -b)
134 BUILDTARGET=$arg
135 ;;
136 -p)
137 PLATFORMFILE=$arg
138 ;;
139 -t)
140 HOST_TOOLS=$arg
141 ;;
142 *)
143 BUILD_OPTIONS="$BUILD_OPTIONS $arg"
144 ;;
145 esac
146 LAST_ARG=
147 fi
148 shift
149 done
150 if [ -z "$HOST_TOOLS" ]
151 then
152 HOST_TOOLS=$TARGET_TOOLS
153 fi
154
155 if [ -z "$PROCESSOR" ]
156 then
157 PROCESSOR=$HOST_PROCESSOR
158 fi
159
160 case $PROCESSOR in
161 IA32)
162 ARCH_SIZE=32
163 BUILD_OUTPUT_DIR=$WORKSPACE/Build/Emulator32
164 LIB_NAMES="ld-linux.so.2 libdl.so.2 crt1.o crti.o crtn.o"
165 LIB_SEARCH_PATHS="/usr/lib/i386-linux-gnu /usr/lib32 /lib32 /usr/lib /lib"
166 ;;
167 X64)
168 ARCH_SIZE=64
169 BUILD_OUTPUT_DIR=$WORKSPACE/Build/Emulator
170 LIB_NAMES="ld-linux-x86-64.so.2 libdl.so.2 crt1.o crti.o crtn.o"
171 LIB_SEARCH_PATHS="/usr/lib/x86_64-linux-gnu /usr/lib64 /lib64 /usr/lib /lib"
172 ;;
173 esac
174
175 for libname in $LIB_NAMES
176 do
177 for dirname in $LIB_SEARCH_PATHS
178 do
179 if [ -e $dirname/$libname ]; then
180 export HOST_DLINK_PATHS="$HOST_DLINK_PATHS $dirname/$libname"
181 break
182 fi
183 done
184 done
185
186 PLATFORMFILE=$WORKSPACE/EmulatorPkg/EmulatorPkg.dsc
187 BUILD_ROOT_ARCH=$BUILD_OUTPUT_DIR/DEBUG_"$TARGET_TOOLS"/$PROCESSOR
188
189 if [[ ! -f `which build` || ! -f `which GenFv` ]];
190 then
191 # build the tools if they don't yet exist. Bin scheme
192 echo Building tools as they are not in the path
193 make -C $WORKSPACE/BaseTools
194 elif [[ ( -f `which build` || -f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]];
195 then
196 # build the tools if they don't yet exist. BinWrapper scheme
197 echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
198 make -C $WORKSPACE/BaseTools
199 else
200 echo using prebuilt tools
201 fi
202
203
204 if [[ "$RUN_EMULATOR" == "yes" ]]; then
205 case `uname` in
206 Darwin*)
207 #
208 # On Darwin we can't use dlopen, so we have to load the real PE/COFF images.
209 # This .gdbinit script sets a breakpoint that loads symbols for the PE/COFFEE
210 # images that get loaded in Host
211 #
212 cp $WORKSPACE/EmulatorPkg/Unix/.gdbinit $BUILD_OUTPUT_DIR/DEBUG_"$TARGET_TOOLS"/$PROCESSOR
213 ;;
214 esac
215
216 /usr/bin/gdb $BUILD_ROOT_ARCH/Host -q -cd=$BUILD_ROOT_ARCH -x $WORKSPACE/EmulatorPkg/Unix/GdbRun
217 exit
218 fi
219
220 case $CLEAN_TYPE in
221 clean)
222 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -b $BUILDTARGET -t $HOST_TOOLS -D UNIX_SEC_BUILD -n 3 clean
223 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS -n 3 clean
224 exit $?
225 ;;
226 cleanall)
227 make -C $WORKSPACE/BaseTools clean
228 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -b $BUILDTARGET -t $HOST_TOOLS -D UNIX_SEC_BUILD -n 3 clean
229 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS -n 3 clean
230 build -p $WORKSPACE/ShellPkg/ShellPkg.dsc -a IA32 -b $BUILDTARGET -t $TARGET_TOOLS -n 3 clean
231 exit $?
232 ;;
233 esac
234
235
236 #
237 # Build the edk2 EmulatorPkg
238 #
239 if [[ $HOST_TOOLS == $TARGET_TOOLS ]]; then
240 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc $BUILD_OPTIONS -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS -D BUILD_$ARCH_SIZE -D UNIX_SEC_BUILD $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3
241 else
242 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc $BUILD_OPTIONS -a $PROCESSOR -b $BUILDTARGET -t $HOST_TOOLS -D BUILD_$ARCH_SIZE -D UNIX_SEC_BUILD -D SKIP_MAIN_BUILD -n 3 modules
243 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc $BUILD_OPTIONS -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS -D BUILD_$ARCH_SIZE $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3
244 cp $BUILD_OUTPUT_DIR/DEBUG_"$HOST_TOOLS"/$PROCESSOR/Host $BUILD_ROOT_ARCH
245 fi
246 exit $?
247