2 # Copyright 2011 Adam Green (http://mbed.org/users/AdamGreen/)
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # Simple script to setup Code Sourcery files to build on Mac OS X
18 # TODO: Will most likely need to change this for each build of tools.
19 # Expected location of files based on Code Sourcery script
20 src_path
=/scratch
/janisjo
/arm-eabi-lite
/src
22 # TODO: Will need to be customized for newer builds.
23 # Name of the tarball archive to be used for building the toolchain.
24 archive_name
=arm-2011.03
-42-arm-none-eabi.src.
tar.bz2
25 archive_url
=https
://sourcery.mentor.com
/sgpp
/lite
/arm
/portal
/package7812
/public
/arm-none-eabi
/$archive_name
26 archive_md5
=7c302162ec813d039b8388bd7d2b4176
28 # This script expects to be sitting in the same directory as the main archive
29 # from Code Sourcery so change into the directory before attempting to
30 # perform the extraction of the source code
32 SCRIPT_PATH
=${SCRIPT_PATH%/*}
35 # Pull the tarball down from the Mentor Graphics/Code Sourcery website.
36 echo Downloading
$archive_url
39 echo Validating the MD5 signature on
$archive_name
40 archive_match
=`md5 -q $archive_name | grep -c $archive_md5`
41 if [ "$archive_match" != "1" ] ; then
42 echo $archive_name failed MD5 signature check.
46 # Extract the various tool sources from the provided archive
47 echo Extracting
$archive_name
49 archive_out
=${archive_name%%.src.tar.bz2}
51 # Now extract the sources for each tool from their respective archive
52 echo Extracting sources from
$archive_out
53 pushd $archive_out >/dev
/null
55 for archive
in `ls *.tar.bz2` ; do
56 echo Extracting
$archive
57 tar -xf $archive -C $src_path
60 # Find the build bash script
61 scripts
=(`ls arm-*-arm-none-eabi.sh`)
62 if [ "${#scripts[*]}" != "1" ] ; then
63 echo This
script only expects to
find one build
script in the package
64 echo Actually found
${scripts[*]}
69 # Modify the script to skip portions not needed for Mac OS and
70 # replace the i686-pc-linux-gnu as appropriate for the Mac GCC toolchain
71 echo Creating modified bash build
script appropriate
for the Mac
72 sed -f ..
/build.
sed $script >build.sh
75 # The build of GCC requires libgcc in /usr/lib without a version number so create a symbolic link.
76 if [[ ! (-a /usr
/lib
/libgcc_s.dylib
) ]]; then
77 echo Creating symbolic link
for /usr
/lib
/libgcc_s.dylib
78 sudo
ln -s /usr
/lib
/libgcc_s
.10.5.dylib
/usr
/lib
/libgcc_s.dylib
81 echo Apply patches to the
source code.
82 cp ..
/src.
patch $src_path
84 patch -p5 -N <src.
patch
86 echo You should now be able to run the
$archive_out/build.sh
script to kick off the build.