Forked from joegoggins/install and add gcc arm to PATH.sh
Last active
August 29, 2015 14:02
-
-
Save ericboehs/0cea8c5778aff405c445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Ensure compiler isn't already installed | |
[[ -d /usr/local/gcc_arm/ ]] && echo 'gcc_arm already installed. Aborting...' && exit 1 | |
echo '---> Downloading gcc arm to your current directory' | |
[[ ! -f gcc-arm-none-eabi-4_8-2014q2-20140609-mac.tar.bz2 ]] && \ | |
curl https://s3.amazonaws.com/ericboehs-uploads/gcc-arm-none-eabi-4_8-2014q2-20140609-mac.tar.bz2 > gcc-arm-none-eabi-4_8-2014q2-20140609-mac.tar.bz2 | |
# Rehosted on Amazon S3 as launchpad is really slow. | |
# If you are uncomfortable downloading from an unknown source, replace the above with: | |
# curl -L https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q2-update/+download/gcc-arm-none-eabi-4_8-2014q2-20140609-mac.tar.bz2 > gcc-arm-none-eabi-4_8-2014q2-20140609-mac.tar.bz2 | |
# Note the md5 from launchpad is here: https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q2-update/+download/gcc-arm-none-eabi-4_8-2014q2-20140609-mac.tar.bz2/+md5 | |
# And this script aborts if it doesn't match | |
# Verify downloaded file matches MD5 checksum | |
[[ "$(md5 -q gcc-arm-*.tar.bz2)" != "4a05e26d9eb30f43752667a34001e755" ]] && echo 'MD5 mismatch! Aborting...' && exit 1 | |
# Check if extraction directory already exists | |
[[ -d gcc-arm-none-eabi-4_8-2014q2-20140609-mac ]] && echo 'gcc-arm-none-eabi-4_8-2014q2-20140609-mac already exists; Aborting...' && exit 1 | |
echo '---> Extracting gcc arm file. This will take 10+ seconds even on a fast machine' | |
tar -xzf gcc-arm-*.tar.bz2 | |
# Clean up bzip2 tar file | |
rm gcc-arm-*.tar.bz2 | |
# Create directory for gcc arm to live | |
mkdir -p /usr/local/gcc_arm | |
# Move extracted files into place | |
mv gcc-arm-*/* /usr/local/gcc_arm | |
# Clean up empty gcc arm directory from working dir | |
rmdir gcc-arm-*/ | |
# Prepend gcc arm bin dir to your PATH | |
grep -Fxq '/usr/local/gcc_arm/bin' /etc/paths && \ | |
echo '---> Already in /etc/paths. Skipping...' || \ | |
sudo sed -iold '1i\'$'\n''/usr/local/gcc_arm/bin\'$'\n' /etc/paths | |
# Prepend your path for this session | |
export PATH="/usr/local/gcc/arm/bin:$PATH" | |
# Ensure binary is setup right by showwing the gcc-arm compiler version | |
echo '---> Check to ensure the gcc-arm firmware compiler is available (so `make clean dependents all` will work.)' | |
echo ' You should see something like:' | |
echo ' arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.8.4 20140526 (release) [ARM/embedded-4_8-branch revision 211358]' | |
echo " Running 'arm-none-eabi-gcc --version | head -1' now:" | |
echo | |
arm-none-eabi-gcc --version | head -1 | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This shouldn't be too hard to create a homebrew formula for this.
#TODO