设置首页  |   加入收藏  |  联系我们   
您的位置: 主页>Linux知识>嵌入式系统>正文
FREEBSD下使用crunch集成编译程序
文章来源:cufug   编辑:  发布时间:2007-10-27

鼓捣linux的朋友都知道,linux下有一个叫busybox的项目,它把大多数unix的基本命令都集成编译成一个单独的程序。 FREEBSD也有一种机制,叫做crunch.它允许我们不用加载标准库也可以利用其它程序中的相同函数。crunch使用一个平板的文本文件来定制集成的程序、编译选项以及需要的LIBS。下面是我在freebsd4.9RELEASE上,集成编译 /bin和/sbin下常用程序的一个配置文件,这些文件如果静态编译,大约占用16M左右的空间.

# cat tinyware.conf

#crunch配置文件最常见的指令有buildopts(编译选项)、srcdirs(指定代码路径)
#progs(指定要集成的程序)、ln(创建指向一个程序的连接)、libs(指定需要的库)
#其他指令和crunch的细节请参看 man crunchgen和crunchide

#指定编译时不包含ipsec、ipv6、和crypt

buildopts -DRELEASE_CRUNCH -DNOIPSEC -DNOINET6 -DNOCRYPT

#指定程序需要的代码路径
srcdirs /usr/src/bin
srcdirs /usr/src/sbin
srcdirs /usr/src/secure/lib

#/bin下的常见程序
progs cat chio chmod cp csh date dd df domainname echo
progs expr hostname kill ln ls mkdir mv ps pwd rm sh rmdir
progs sleep stty sync test ed

#创建一个指向test的连接
ln test [

#/sbin下的常见程序
progs adjkerntz dmesg disklabel fsck ifconfig init
progs ipf ipfs ipfstat ipfw ipmon ipnat natd
progs kldconfig kldload kldstat kldunload ldconfig md5 mknod
progs mount mount_null mount_union newfs mount_std umount
ln mount_std mount_procfs
ln newfs mount_mfs
progs ping reboot restore route routed shutdown sysctl

#指定这些程序需要的库,想知道这些程序都需要什么库,你可以使用这样的命令:
# grep -ir LDADD /usr/src/bin/*

# 这样就能抽取出包含在Makefile中的指定库的行
libs -ltermcap -lcrypt -lutil -lm -lcipher -lkvm -ll -ledit
libs -lcrypto -lipx -lncurses -lmd -lalias -lipsec


写完配置文件后,就可以使用crunchgen来生成Makefile和代码了。

# crunchgen -m Makefile tinyware.conf

然后你可以这样编译它:
# make -f Makefile

如果没什么错误,应该就可以生成tinyware的可执行程序,如果出错,请重新检查是
否没写全libs和srcdirs

原文链接:http://cnfug.org/journal/systems/2004/000085.html




Tags:编译 程序 集成 使用 progs 指定 一个 srcdirs 文件 ln
Google
 
上一篇: ucLinux下sqlite数据库移植全攻略   下一篇: 嵌入式系统 Boot Loader 技术内幕
【返回顶部】 【打印】 【大】 【中】 【小】 【关闭】

 我来说两句
用户名: 新注册) 密码: 匿名评论 [论坛讨论]
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 相关文章
 热门文章

 
版权所有  2005-2006  Linux集中营  闽ICP备07500055号