1#!/bin/bash 2 3# command to install toolchain in the "dirname" which you Specified. 4# source ./env_install_toolchain.sh dirname 5INSTALL_TARGET_DIR= 6toolchain_cross=`pwd` 7toolchain_cross=$(basename ${toolchain_cross}) 8if [ -n "$1" ]; then 9 if [ -d "$1" ]; then 10 INSTALL_TARGET_DIR=$1 11 build_toolchain_path="${INSTALL_TARGET_DIR}/$toolchain_cross/bin" 12 else 13 echo "error: not found dir $1" 14 echo "command format: source $0 [dirname]" 15 echo " [dirname] is optional" 16 return 1 17 fi 18else 19 build_toolchain_path="${PWD}/bin" 20fi 21 22# default 1 23selectopt=1 24 25case $selectopt in 26 0) 27 if [ -n "$INSTALL_TARGET_DIR" ]; then 28 sudo cp -rfa $PWD $INSTALL_TARGET_DIR 29 fi 30 sudo echo "export PATH=$build_toolchain_path/:\$PATH" >> /etc/profile 31 source /etc/profile 32 ;; 33 1) 34 if [ -n "$INSTALL_TARGET_DIR" ]; then 35 cp -rfa $PWD $INSTALL_TARGET_DIR 36 fi 37 cmdsed="sed -i '/^export PATH.*${toolchain_cross}\/bin/d' \$HOME\/.bashrc" 38 eval $cmdsed 39 echo "export PATH=$build_toolchain_path:\$PATH" >> $HOME/.bashrc 40 source $HOME/.bashrc 41 ;; 42 *) 43 echo "Please check input." 44 ;; 45esac 46