续,在交叉编译过程中需要修正*.la的libtool库文件和*.pc文件,下面是修正的脚本:
Fix *.la:
LIBTOOL_FILE_DIR=$TARGET_PREFIX/usr/lib/
for file in `ls $LIBTOOL_FILE_DIR/*.la`
do
# fix libdir variable
libdir=`sed -n "/^libdir=\.*/p" $file`
if [ -z "$libdir" ]; then
echo "Warning, can not find partern in file $file"
else
cp $file "$file"_tmp
sed '/^libdir=\.*/c\libdir="$TARGET_PREFIX/usr/lib"' "$file"_tmp > $file
rm -f "$file"_tmp
fi
# fix dependency lib
new_depend_lib_var=" ";
depend_lib_var=`sed -n "/^dependency_libs=\.*/p" $file`
depend_lib=`echo $depend_lib_var | cut -d= -f2`
depend_lib=`echo $depend_lib | sed "1,$ s/['|\"]//g"`
for dlib in $depend_lib
do
if [ -z `echo $dlib | grep -o '$TARGET_PREFIX'` ] && [ -z `echo $dlib | grep "$TARGET_PREFIX"` ] \
&& [ -z `echo $dlib | grep 'crosstool'` ] && [ ! -z `echo $dlib | grep '/usr/lib'` ]; then
dlib=`echo $dlib | sed '1,$ s/\/usr\/lib/$TARGET_PREFIX\/usr\/lib/g'`
new_depend_lib_var="$new_depend_lib_var $dlib"
elif [ ! -z $dlib ]; then
new_depend_lib_var="$new_depend_lib_var $dlib"
fi
done
cp $file "$file"_tmp
dep_sed_ptrn="/^dependency_libs=\\.*/c\\dependency_libs=\"$new_depend_lib_var\""
sed "$dep_sed_ptrn" "$file"_tmp > $file
rm -f "$file"_tmp
done
fix *.pc:
PKG_CONFIG_FILE_DIR=$TARGET_PREFIX/usr/lib/pkgconfig
for file in `ls $PKG_CONFIG_FILE_DIR/*.pc`
do
found=`sed -n "/^prefix=\.*/p" $file`
if [ -z "$found" ]; then
echo "Warning, can not find partern in file $file"
else
cp $file "$file"_tmp
sed "/^prefix=\.*/c\prefix=$TARGET_PREFIX/usr" "$file"_tmp > $file
rm -f "$file"_tmp
fi
done
阅读(938) | 评论(0) | 转发(0) |