Commit | Line | Data |
---|---|---|
3b1e82d2 | 1 | #! /usr/bin/env bash |
8fcce42e | 2 | # Copyright 2012 Adam Green (http://mbed.org/users/AdamGreen/) |
3b1e82d2 AW |
3 | # |
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 | |
7 | # | |
8 | # http://www.apache.org/licenses/LICENSE-2.0 | |
9 | # | |
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. | |
15 | ||
16 | ||
17 | # Logs the command to be run and then executes the command while logging the results. | |
18 | RunAndLog () { | |
501ebba4 BG |
19 | echo `date` Executing "$@">>"$LOGFILE" |
20 | "$@" 1>>"$LOGFILE" 2>"$ERRORFILE" | |
3b1e82d2 | 21 | if [ "$?" != "0" ] ; then |
63c41eae BG |
22 | cat "$ERRORFILE" >>"$LOGFILE" |
23 | echo `date` Failure forced early exit>>"$LOGFILE" | |
24 | cat "$LOGFILE" | |
25 | rm -f "$ERRORFILE" | |
3b1e82d2 AW |
26 | popd >/dev/null |
27 | read -n 1 -sp "Press any key to continue..." dummy ; echo | |
28 | exit 1 | |
29 | fi | |
30 | } | |
31 | ||
32 | ||
33 | # Setup script variables. | |
34 | ROOTDIR=$0 | |
35 | ROOTDIR=${ROOTDIR%/*} | |
36 | pushd $ROOTDIR | |
37 | ROOTDIR=$PWD | |
501ebba4 BG |
38 | LOGFILE="$ROOTDIR"/mac_install.log |
39 | ERRORFILE="$ROOTDIR"/mac_install.err | |
ce6ee091 JM |
40 | GCC4ARM_VERSION=gcc-arm-none-eabi-4_8-2014q1 |
41 | GCC4ARM_FILENAME=gcc-arm-none-eabi-4_8-2014q1-20140314-mac.tar.bz2 | |
42 | GCC4ARM_URL=https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/$GCC4ARM_FILENAME | |
501ebba4 | 43 | GCC4ARM_TAR="$ROOTDIR"/$GCC4ARM_FILENAME |
ce6ee091 | 44 | GCC4ARM_MD5=5d34d95a53ba545f1585b9136cbb6805 |
501ebba4 BG |
45 | GCC4ARM_EXTRACT="$ROOTDIR"/$GCC4ARM_VERSION |
46 | GCC4ARM_DIR="$ROOTDIR"/gcc-arm-none-eabi | |
8fcce42e | 47 | GCC4ARM_BINDIR=$GCC4ARM_DIR/bin |
501ebba4 BG |
48 | MACBIN_DIR="$ROOTDIR"/build/osx64 |
49 | BUILDSHELL_CMD="$ROOTDIR"/BuildShell | |
3b1e82d2 AW |
50 | |
51 | ||
63c41eae BG |
52 | echo Logging install results to "$LOGFILE" |
53 | echo `date` Starting $0 $*>"$LOGFILE" | |
3b1e82d2 | 54 | |
8fcce42e | 55 | echo Downloading GNU Tools for ARM Embedded Processors... |
63c41eae | 56 | echo `date` Executing curl -L0 $GCC4ARM_URL>>"$LOGFILE" |
8fcce42e | 57 | curl -L0 $GCC4ARM_URL >$GCC4ARM_FILENAME |
3b1e82d2 | 58 | |
8fcce42e | 59 | echo Validating md5 signature of GNU Tools for ARM Embedded Processors... |
63c41eae | 60 | echo `date` Validating md5 signature of GNU Tools for ARM Embedded Processors>>"$LOGFILE" |
8fcce42e | 61 | archive_match=`md5 -q $GCC4ARM_FILENAME | grep -c $GCC4ARM_MD5` |
3b1e82d2 | 62 | if [ "$archive_match" != "1" ] ; then |
63c41eae BG |
63 | echo $GCC4ARM_FILENAME failed MD5 signature check.>>"$LOGFILE" |
64 | echo `date` Failure forced early exit>>"$LOGFILE" | |
65 | cat "$LOGFILE" | |
66 | rm -f "$ERRORFILE" | |
3b1e82d2 AW |
67 | popd >/dev/null |
68 | read -n 1 -sp "Press any key to continue..." dummy ; echo | |
69 | exit 1 | |
70 | fi | |
71 | ||
8fcce42e | 72 | echo Extracting GNU Tools for ARM Embedded Processors... |
501ebba4 BG |
73 | rm -r "$GCC4ARM_DIR" >/dev/null 2>/dev/null |
74 | echo $GCC4ARM_TAR | |
75 | RunAndLog tar xf "$GCC4ARM_TAR" | |
76 | RunAndLog mv "$GCC4ARM_EXTRACT" "$GCC4ARM_DIR" | |
3b1e82d2 | 77 | |
172d42d9 | 78 | echo Installing patched 64-bit Intel Mac OS X GDB binaries... |
501ebba4 | 79 | RunAndLog cp "$MACBIN_DIR"/arm-none-eabi-gdb* "$GCC4ARM_BINDIR/" |
3b1e82d2 AW |
80 | |
81 | echo Creating helper scripts... | |
501ebba4 BG |
82 | echo "#! /usr/bin/env bash">"$BUILDSHELL_CMD" |
83 | echo "# Modify next line and set destination drive to match mbed device">>"$BUILDSHELL_CMD" | |
84 | echo "export LPC_DEPLOY='cp PROJECT.bin /Volumes/MBED/ ; sync'">>"$BUILDSHELL_CMD" | |
85 | echo>>"$BUILDSHELL_CMD" | |
86 | echo "SCRIPT_PATH=\$0">>"$BUILDSHELL_CMD" | |
87 | echo "SCRIPT_PATH=\${SCRIPT_PATH%/*}">>"$BUILDSHELL_CMD" | |
88 | echo "cd \$SCRIPT_PATH">>"$BUILDSHELL_CMD" | |
89 | echo "SCRIPT_PATH=\$PWD">>"$BUILDSHELL_CMD" | |
90 | echo "export PATH=\$SCRIPT_PATH/gcc-arm-none-eabi/bin:\$SCRIPT_PATH/build/osx64:\$PATH">>"$BUILDSHELL_CMD" | |
91 | echo "exec bash">>"$BUILDSHELL_CMD" | |
92 | chmod +x "$BUILDSHELL_CMD" | |
3b1e82d2 | 93 | |
8fcce42e | 94 | echo Cleaning up intermediate files... |
501ebba4 | 95 | RunAndLog rm "$GCC4ARM_TAR" |
3b1e82d2 AW |
96 | |
97 | echo | |
172d42d9 | 98 | echo To build Smoothie, you will first need to run the following script |
3b1e82d2 AW |
99 | echo so that your environment variables are set correctly: |
100 | echo $BUILDSHELL_CMD | |
101 | echo You will want to run this each time you start a new Terminal. You | |
102 | echo can simply double-click on this script file from Finder to launch a | |
172d42d9 AG |
103 | echo bash Terminal that has been properly initialized for building. Feel |
104 | echo free to customize it as you desire. | |
3b1e82d2 AW |
105 | echo |
106 | echo You can also just edit your existing setup script such as \~/.profile | |
107 | echo to update the PATH environment variable to include: | |
8fcce42e | 108 | echo $GCC4ARM_BINDIR |
3b1e82d2 AW |
109 | |
110 | ||
111 | # Restore current directory and exit script on success. | |
63c41eae | 112 | echo `date` Finished successfully>>"$LOGFILE" |
3b1e82d2 | 113 | echo Finished successfully |
63c41eae | 114 | rm -f "$ERRORFILE" |
3b1e82d2 AW |
115 | popd >/dev/null |
116 | read -n 1 -sp "Press any key to continue..." dummy ; echo |