Chinaunix首页 | 论坛 | 博客
  • 博客访问: 236369
  • 博文数量: 51
  • 博客积分: 1065
  • 博客等级: 少尉
  • 技术积分: 556
  • 用 户 组: 普通用户
  • 注册时间: 2007-01-11 14:50
文章分类

全部博文(51)

文章存档

2012年(1)

2011年(6)

2010年(39)

2008年(1)

2007年(4)

分类:

2010-05-21 16:05:15

1,从下面ftp站点下载最新的Linux file命令源代码file-5.04.tar.gz:
  ftp://ftp.astron.com/pub/file

2,解压缩并编写configure脚本如下,并执行该脚本:
[guowenxue@localhost file-5.04]$ cat build.sh 
#!/bin/sh
CROSS=/opt/buildroot_350/build_arm/staging_dir/bin/arm-linux-

./configure --host=arm-linux --enable-static  --disable-shared CC=${CROSS}gcc AS=${CROSS}as LD=${CROSS}ld AR=${CROSS}ar RANLIB=${CROSS}ranlib

3,修改file-5.04/src/Makefile文件,添加--static到CFLAGS里,使用静态链接:
  CFLAGS = -g -O2 --static

4,修改源代码file-5.04/src/file.c中的main()函数,将
  const char *magicfile 设置为 "/usr/share/magic.mgc"或其它路径;

5,执行make,编译生成file-5.04/src/file二进制文件;

6,将编译生成的file二进制文件和file-5.04/magic/Magdir/放到下载到ARM开发板(/tmp目录下),使用file命令生成magic.mgc文件:
/tmp >: ./file -C -m Magdir
/tmp >: ls Magdir.mgc 
Magdir.mgc

7,将Magdir.mgc拷贝为/usr/share/magic.mgc;

8,现在可以在ARM上使用file命令了.
/tmp >: ./file -m Magdir.mgc file
file: ELF 32-bit LSB executable, ARM, version 1, statically linked, not stripped
/tmp >: mv Magdir.mgc /usr/share/magic.mgc
/tmp >: ./file file
file: ELF 32-bit LSB executable, ARM, version 1, statically linked, not stripped
/tmp >: ./file /usr/sbin/nup 
/usr/sbin/nup: POSIX shell script text executable



阅读(3044) | 评论(0) | 转发(0) |
0

上一篇:index()函数

下一篇:根文件系统使用NFS启动

给主人留下些什么吧!~~