0
点赞
收藏
分享

微信扫一扫

对目录下所有库文件进行rpath更改操作的SHELL脚本

回溯 2022-01-27 阅读 120


LINUX和MAC差异是命令不同。

function quantum6_change_rpath_command_3param()
{
# echo ${1} ${2} ${3}
# linux chrpath
install_name_tool -change \
${2} \
${3} \
${1}
}

function quantum6_change_rpath_file2_3param()
{
mac_change_rpath_command \
${1} \
${2} \
${3}/${2}
}

function quantum6_change_rpath_file_3param()
{
local SRC_TEXTS=`otool -L ${1}`
if [ "${SRC_TEXTS}" == "" ]; then
return
fi

for item in ${SRC_TEXTS}
do
local LIB_NAME
if [[ ${item} == *${2}* ]]; then
LIB_NAME=`echo ${item} | awk -F '/' '{ print $6 }'`
elif [[ ${item} == /lib*dylib ]]; then
LIB_NAME=`echo ${item} | awk -F '/' '{ print $2 }'`
elif [[ ${item} == lib*dylib ]]; then
LIB_NAME=${item}
else
continue
fi

# echo ${item} ${LIB_NAME}

quantum6_change_rpath_command_3param \
${1} \
${item} \
${3}/${LIB_NAME}

done

}

function quantum6_change_rpath_dir_3param()
{
local CURR_DIR=`pwd`
cd "$1"
# pwd

local files=`ls | tr " " "\?"`
for item in ${files}
do
if [ -d "${item}" ]; then
quantum6_change_rpath_dir_3param "${item}" ${2} ${3}
elif [ -f "${item}" ]; then
quantum6_change_rpath_file_3param "${item}" ${2} ${3}
fi
done

cd ${CURR_DIR}
}

RPATH_SRC="/Users/taishansoft/lib-ffmpeg"
DEST_DIR=/Users/taishansoft/eclipse-workspace/FontTest/lib-ffmpeg
RPATH_DEST="./lib-ffmpeg"

mquantum6_change_rpath_dir_3param ${DEST_DIR} ${RPATH_SRC} ${RPATH_DEST}


举报

相关推荐

0 条评论