Adding support for BeagleBoard.
[mirror_edk2.git] / BeagleBoardPkg / build.sh
CommitLineData
2ef2b01e
A
1#!/bin/bash
2# Copyright (c) 2008 - 2009, Apple, Inc. All rights reserved.
3# All rights reserved. This program and the accompanying materials
4# are licensed and made available under the terms and conditions of the BSD License
5# which accompanies this distribution. The full text of the license may be found at
6# http://opensource.org/licenses/bsd-license.php
7#
8# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
10#
11
12set -e
13shopt -s nocasematch
14
15function process_debug_scripts {
16 if [[ -d $1 ]]; then
17 for filename in `ls $1`
18 do
19 sed -e "s@ZZZZZZ@$BUILD_ROOT@g" -e "s@WWWWWW@$WORKSPACE@g" \
20 "$1/$filename" \
21 > "$BUILD_ROOT/$filename"
22
23 #For ARMCYGWIN, we have to change /cygdrive/c to c:
24 if [[ $TARGET_TOOLS == RVCT31CYGWIN ]]
25 then
26 mv "$BUILD_ROOT/$filename" "$BUILD_ROOT/$filename"_temp
27 sed -e "s@/cygdrive/\(.\)@\1:@g" \
28 "$BUILD_ROOT/$filename"_temp \
29 > "$BUILD_ROOT/$filename"
30 rm -f "$BUILD_ROOT/$filename"_temp
31 fi
32 done
33 fi
34}
35
36
37#
38# Setup workspace if it is not set
39#
40if [ -z "$WORKSPACE" ]
41then
42 echo Initializing workspace
43 cd ..
44 export EDK_TOOLS_PATH=`pwd`/BaseTools
45 source edksetup.sh BaseTools
46else
47 echo Building from: $WORKSPACE
48fi
49
50#
51# Pick a default tool type for a given OS
52#
53case `uname` in
54 CYGWIN*)
55 TARGET_TOOLS=RVCT31CYGWIN
56 ;;
57 Linux*)
58 # Not tested
59 TARGET_TOOLS=ELFGCC
60 ;;
61 Darwin*)
62 Major=$(uname -r | cut -f 1 -d '.')
63 if [[ $Major == 9 ]]
64 then
65 # Not supported by this open source project
66 TARGET_TOOLS=XCODE31
67 else
68 TARGET_TOOLS=XCODE32
69 fi
70 ;;
71esac
72
73BUILD_ROOT=$WORKSPACE/Build/BeagleBoard/DEBUG_"$TARGET_TOOLS"
74GENERATE_IMAGE=$WORKSPACE/BeagleBoardPkg/Tools/generate_image
75FLASH_BOOT=$BUILD_ROOT/FV/BeagleBoard_EFI_flashboot.fd
76
77if [[ ! -f `which build` || ! -f `which GenFv` ]];
78then
79 # build the tools if they don't yet exist
80 echo Building tools
81 make -C $WORKSPACE/BaseTools
82else
83 echo using prebuilt tools
84fi
85
86#
87# Build the edk2 BeagleBoard code
88#
89build -p $WORKSPACE/BeagleBoardPkg/BeagleBoardPkg.dsc -a ARM -t $TARGET_TOOLS $1 $2 $3 $4 $5 $6 $7 $8
90
91for arg in "$@"
92do
93 if [[ $arg == clean ]]; then
94 # no need to post process if we are doing a clean
95 exit
96 elif [[ $arg == cleanall ]]; then
97 make -C BaseTools/ clean
98 make -C $WORKSPACE/BeagleBoardPkg/Tools clean
99 exit
100
101 fi
102done
103
104
105#
106# Build the tool used to patch the FLASH image to work with the Beagle board ROM
107#
108if [[ ! -e $GENERATE_IMAGE ]];
109then
110 make -C $WORKSPACE/BeagleBoardPkg/Tools
111fi
112
113echo Patching FD to work with BeagleBoard ROM
114rm -f $FLASH_BOOT
115
116#
117# Ram starts at 0x80000000
118# OMAP 3530 TRM defines 0x80008208 as the entry point
119# The reset vector is caught by the mask ROM in the OMAP 3530 so that is why this entry
120# point looks so strange.
121# OMAP 3430 TRM section 26.4.8 has Image header information. (missing in OMAP 3530 TRM)
122#
123$GENERATE_IMAGE -D $WORKSPACE/BeagleBoardPkg/ConfigurationHeader.dat -E 0x80008208 -I $BUILD_ROOT/FV/BEAGLEBOARD_EFI.fd -O $FLASH_BOOT
124
125echo Creating debugger scripts
126process_debug_scripts $WORKSPACE/BeagleBoardPkg/Debugger_scripts
127