概述
#!/bin/bash
print_help() {
cat <<EOF
Usage: command
command:
export cross_compiler
unset
example:
source ./toolchain.sh export arm-linux-androideabi
source ./toolchain.sh unset
EOF
}
main() {
if [ $# -lt 1 ]; then
print_help
return
fi
COMMAND=$1
if [ $COMMAND = "export" ]; then
if [ $# -lt 2 ]; then
print_help
return
fi
CROSS=$2
if [ ${CROSS:${#CROSS}-1:1} != "-" ]; then
CROSS=${CROSS}-
fi
echo "CROSS = $CROSS"
export CC=${CROSS}gcc
export CXX=${CROSS}g++
export AR=${CROSS}ar
export AS=${CROSS}as
export LD=${CROSS}ld
export STRIP=${CROSS}strip
export RANLIB=${CROSS}ranlib
export NM=${CROSS}nm
elif [ $COMMAND = "unset" ]; then
unset CC
unset CXX
unset AR
unset AS
unset LD
unset STRIP
unset RANLIB
unset NM
else
print_help
return
fi
}
main $@
echo "CC = $CC"
echo "CXX = $CXX"
echo "AR = $AR"
echo "AS = $AS"
echo "LD = $LD"
echo "STRIP = $STRIP"
echo "RANLIB = $RANLIB"
echo "NM = $NM"
用法:
source ./toolchain.sh export arm-linux-androideabi
最后
以上就是听话太阳为你收集整理的交叉编译工具链设置环境变量脚本的全部内容,希望文章能够帮你解决交叉编译工具链设置环境变量脚本所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复