LINUX和MAC差异是命令不同。
#!/bin/bash # sudo apt -y install libx11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev function mac_change_rpath_command_3param() { # linux: local RPATH_TOOL=chrpath local RPATH_TOOL=install_name_tool local RPATH_CMD=/usr/bin/${RPATH_TOOL} if [ ! -f ${RPATH_CMD} ]; then RPATH_CMD=./${RPATH_TOOL} fi ${RPATH_CMD} -change \ "${2}" \ "${3}" \ "${1}" } function mac_change_rpath_file_3param() { local SRC_TEXTS=`otool -L "${1}"` if [ "${SRC_TEXTS}" == "" ]; then return fi local item 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} mac_change_rpath_command_3param \ "${1}" \ "${item}" \ "${3}"/${LIB_NAME} done } function mac_change_rpath_dir_3param() { local CURR_DIR=`pwd` cd "${1}" # pwd local files=`ls | tr " " "\?"` local item for item in ${files} do if [ -d ${item} ]; then mac_change_rpath_dir_3param "${item}" "${2}" "${3}" elif [ -f ${item} ]; then mac_change_rpath_file_3param "${1}/${item}" "${2}" "${3}" fi done cd "${CURR_DIR}" } # {{{{{{{{{{ INSTALL_LIB_DIR=`pwd` INSTALL_LIB_DIR="${INSTALL_LIB_DIR}/ffmpeg" RPATH_SRC="/Users/tsit/lib-ffmpeg/lib" RPATH_DEST="${INSTALL_LIB_DIR}" mac_change_rpath_dir_3param "${INSTALL_LIB_DIR}" "${RPATH_SRC}" "${RPATH_DEST}" # }}}}}}}}}}