以下脚本可以在编译时指定./configure --prefix=`pwd`/dist 中放入一个profile文件,然后使用的时候直接source profile,可以实现当前任意目录执行脚本,环境变量生效
#/bin/bash
SHELL_PATH=$(readlink -f `dirname ${BASH_SOURCE[0]}` )
export PATH=$SHELL_PATH/bin:$PATH
export LD_LIBRARY_PATH=$SHELL_PATH/lib:$SHELL_PATH/lib64:$LD_LIBRARY_PATH
echo $PATH
echo $LD_LIBRARY_PATH