Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ################################################################################
- # msp430_build.sh
- #
- # MSP430 Tool-Chain Build Script.
- #
- # Maintained By: Ryan Jacobs <[email protected]>
- #
- # May 24 -> Original creation.
- ################################################################################
- # Global Variables
- INSTALL_PREFIX=/opt/msp430
- START_DIR="$PWD"
- PATH="$PATH:$INSTALL_PREFIX"
- ########################################
- # Error Checking
- ########################################
- function errors()
- {
- if [ -d build_area ]; then
- printf "Error: Directory 'build_area' already exists! Please delete this and retry.\n"
- exit 1
- fi
- }
- ########################################
- # Download the Files
- ########################################
- function dl()
- {
- pushd "$START_DIR"
- mkdir -p dl
- pushd dl
- urls=(\
- 'http://ftpmirror.gnu.org/gdb/gdb-7.2a.tar.bz2' \
- 'http://www.netgull.com/gcc/releases/gcc-4.9.0/gcc-4.9.0.tar.bz2' \
- 'ftp://ftp.kernel.org/pub/linux/devel/binutils/binutils-2.24.51.0.3.tar.xz'\
- 'http://softlayer-dal.dl.sourceforge.net/project/mspdebug/mspdebug-0.22.tar.gz'\
- 'http://iweb.dl.sourceforge.net/project/mspgcc/msp430mcu/msp430mcu-20130321.tar.bz2'\
- 'http://iweb.dl.sourceforge.net/project/mspgcc/msp430-libc/msp430-libc-20120716.tar.bz2'\
- )
- for url in ${urls[@]}; do
- wget --continue --tries=1 "$url"
- if [ $? -eq 0 ]; then
- printf "Successfully downloaded: %s.\n\n" "$url"
- else
- printf "Download failed: %s.\n\n" "$url"
- exit 1
- fi
- done
- popd
- popd
- }
- ########################################
- # Extract Everything
- ########################################
- function extract()
- {
- pushd "$START_DIR"
- mkdir -p build_area
- pushd build_area
- # Extract all of the tarballs
- printf "\n"
- parallel '\
- printf "Extracting %s.\n" {};\
- tar xf {};\
- ' ::: ../dl/*tar*
- popd
- popd
- }
- ########################################
- # Build Everything
- ########################################
- function build()
- {
- pushd "$START_DIR/build_area"
- mkdir -p binutils-2.24-msp430
- mkdir -p gcc-4.9.0-msp430
- mkdir -p gdb-7.2-msp430
- # Binutils
- pushd binutils-2.24-msp430
- ../binutils-2.24/configure --prefix="$INSTALL_PREFIX" --target=msp430-elf --program-prefix="msp430-"
- make || {
- printf "\n\nError: compiling binutils-2.24\n"
- # We get this weird compile error and this seems to fix it
- printf "Trying this command: sed -i 's/),.*TRUE)/))/g' bfd/bfd.h\n\n"
- sed -i 's/),.*TRUE)/))/g' bfd/bfd.h
- sleep 5
- }
- make || {
- printf "\n\nError: compiling binutils-2.24\n"
- exit 1
- }
- # sudo make install
- popd
- # GCC
- pushd gcc-4.9.0-msp430
- pushd ../gcc-4.9.0
- ./contrib/download_prerequisites
- popd
- ../gcc-4.9.0/configure --prefix="$INSTALL_PREFIX" --target=msp430-elf --enable-languages=c --program-prefix="msp430-"
- make || {
- printf "\n\nError: compiling gcc-4.9.0\n"
- exit 1
- }
- # sudo make install
- popd
- # GDB
- pushd gdb-7.2-msp430
- ../gdb-7.2/configure --prefix="$INSTALL_PREFIX" --target=msp430-elf --program-prefix="msp430-"
- make || {
- printf "\n\nError: compiling gdb-7.2\n"
- exit 1
- }
- # sudo make install
- popd
- # mspgcc-mcu files
- pushd msp430mcu-20130321
- # sudo MSP430MCU_ROOT=`pwd` ./scripts/install.sh "$INSTALL_PREFIX"
- popd
- # mspgcc-libc files
- pushd msp430-libc-20120716
- ./configure
- pushd src
- make || {
- printf "\n\nError: compiling msp430-libc-20120716\n"
- exit 1
- }
- # sudo make PREFIX="$INSTALL_PREFIX" install
- popd
- popd
- # mspdebug
- pushd mspdebug-0.22
- make || {
- printf "\n\nError: compiling mspdebug-0.22\n"
- exit 1
- }
- # sudo make install
- popd
- popd
- }
- function install()
- {
- pushd "$START_DIR/build_area"
- ########################################
- # Install Everything
- ########################################
- # Binutils
- pushd binutils-2.24-msp430
- sudo make install
- popd
- # GCC
- pushd gcc-4.9.0-msp430
- sudo make install
- popd
- # GDB
- pushd gdb-7.2-msp430
- sudo make install
- popd
- # mspgcc-mcu files
- pushd msp430mcu-20130321
- sudo MSP430MCU_ROOT=`pwd` ./scripts/install.sh "$INSTALL_PREFIX"
- popd
- # mspgcc-libc files
- pushd msp430-libc-20120716
- sudo make PREFIX="$INSTALL_PREFIX" install
- popd
- # mspdebug
- pushd mspdebug-0.22
- sudo make install
- popd
- popd
- popd
- }
- ########################################
- # Main
- ########################################
- START_TIME=$(date)
- errors && {
- printf "\n****************************************************\n"
- printf "* Done error checking! Now starting the downloads. *\n"
- printf "****************************************************\n\n"
- }
- dl && {
- printf "\n*******************************************************\n"
- printf "* Done downloading! Now starting to extract the files *\n"
- printf "*******************************************************\n\n"
- }
- extract && {
- printf "\n********************************************\n"
- printf "* Done extracting! Now starting to build. *\n"
- printf "********************************************\n\n"
- }
- build && {
- printf "\n*******************************************\n"
- printf "* Done building! Now starting to install. *\n"
- printf "*******************************************\n\n"
- }
- install && {
- printf "\n*******************************************\n"
- printf "* Done installing! *\n"
- printf "*******************************************\n\n"
- }
Advertisement
Add Comment
Please, Sign In to add comment