Chinaunix首页 | 论坛 | 博客
  • 博客访问: 83362
  • 博文数量: 22
  • 博客积分: 2200
  • 博客等级: 大尉
  • 技术积分: 640
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-16 22:20
文章分类
文章存档

2011年(1)

2008年(21)

我的朋友

分类: LINUX

2008-05-18 11:14:59


续,在交叉编译过程中需要修正*.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
阅读(904) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~