<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/ DTD/wml_1.1.xml">

<wml>
<head>
<meta http-equiv="cache-control" content="max-age=180,private" />
</head>
<card title="tomato 编译详解">
<p>
作者:<a href="index.php?action=showuser&amp;userid=1&amp;hash=">admin</a><br />时间:2011-10-13 07:50<br />分类:<a href="index.php?action=list&amp;cid=3&amp;hash=">电脑技术</a><br />内容:

tomato 编译详解
一. 先打开 linux终端,在终端命令行下执行,安装编译所需的组件




    sudo apt-get install build-essential linux-headers-$(uname -r)

    sudo apt-get install libncurses5 libncurses5-dev m4 bison flex libstdc++6-4.4-dev g++-4.4 g++ libtool sqlite

    sudo apt-get install gcc g++ binutils patch bzip2 flex bison make gettext unzip zlib1g-dev

    sudo apt-get install libc6 libncurses5-dev  automake automake1.7 automake1.9

    sudo apt-get install git-core

    sudo apt-get install gitk




复制代码

以上每复制一行,然后在终执行一次, 如果都可以顺利完成,请看下一步

二. 获取tomato源代码




    cd ~

    sudo -s

    mkdir tomato_git

    cd tomato_git

    git clone git://repo.or.cz/tomato.git




复制代码

稍等10~30分钟(取决于网速),完成后,先备份好源码以便在编译时改乱了,能恢复原始状态,需不要重复痛苦的重新下载源码




    tar zcvf tomato_git.tar.gz ./tomato  




复制代码

完成后,将在当前目录下生成tomato_git.tar.gz 备份包, 以备不时之需.

如果源码有更新, 那么不需要重新下载源码,只需执行下列命令,可增量同步更新




    git pull




复制代码

三. 建立交叉编译变量环境




    sudo ln -s ~/tomato_git/tomato/tools/brcm /opt/brcm




复制代码




    nano /root/.profile

    在最后一行处加入

    if [ -d &quot;/opt/brcm&quot; ] ; then

        PATH=/opt/brcm/hndtools-mipsel-uclibc/bin:/opt/brcm/hndtools-mipsel-linux/bin:$PATH

    fi

    按ctrl+x y 保存退出, 以便每次启动linux时能找到编译器.




复制代码

四. 查看并获取当前tomato 分支源码

这部分源码并不包含在前面的源码包中, 需要另外下载,

1.查看当前源码分支




    cd ~/tomato_git/tomato

    git branch -r

    例:

    debian:~/tomato_git/tomato# git branch -r

      origin/Clientmon

      origin/HEAD -&gt; origin/tomato

      origin/IPT-X

      origin/QOS-DEV

      origin/QOS-Limiter

      origin/Static-ARP

      origin/Teaman-BWM

      origin/Teaman-IPTraffic

      origin/Teaman-ND

      origin/Teaman-ND-SDHC

      origin/Teaman-RT

      origin/Toastman-IPT-ND

      origin/Toastman-ND

      origin/Toastman-RT

      origin/Toastman-RT-N

      origin/Toastman-VLAN

      origin/Toastman-VLAN-ND

      origin/Toastman-VLAN-RT

      origin/Toastman-VLAN-RT-N

      origin/Tomato-RAF

      origin/Transmission

      origin/VLAN-GUI

      origin/VLAN-MultiSSID

      origin/minidlna

      origin/multilanguage

      origin/nfs_server

      origin/ntfs-3g

      origin/p910nd

      origin/tomato

      origin/tomato-K26-WL

      origin/tomato-ND-USBmod

      origin/tomato-ND-usbmod-mixvpn

      origin/tomato-RT

      origin/tomato-RT-N

      origin/tomato-miniupnpd

      origin/tomato-sdhc-ND-vlan

      origin/tomato-shibby

      origin/tomatovpn

      origin/vpngui

      origin/vsftpd

    debian:~/tomato_git/tomato#




复制代码

2. 获取分支源码

吐司超人版:




    git checkout origin/Toastman-RT

    git checkout -b origin/Toastman-RT




复制代码

Shibby mod版




    git checkout origin/tomato-shibby

    git checkout -b origin/tomato-shibby




复制代码

但是要注意,您一次只能获取一种分支源码,不能同时下载, 如果已经下载了吐司超人版源码.. 后来又想编译Shibby源码,那么需要将整个tomato目录删掉,重新解压源码备份,再获取shibby源码,这样获得的源码才干净.




    sudo rm -rf ~/tomato_git/tomato

    tar zxvf ~/tomato_git/tomato.tar.gz .




复制代码

四. 开始编译.
如果需要自己配置核心, 添加对更多硬件的支持. 那么




    R1版:

    cd ~/tomato_git/tomato/release/src/linux/linux

    或R2版:

    cd ~/tomato_git/tomato/release/src-rt/linux-2.6

     

    sudo make menuconfig




复制代码

根据情况自行选择内核参数, 没有经验不建议更改,很容易导致核心挂掉(省略5000字)

开始编译.




    R1版:

    cd ~/tomato_git/tomato/release/src

    或R2版:

    cd ~/tomato_git/tomato/release/src-rt




复制代码

查看有那些参数可选.不同的分支版本,编译参数是不同的.具体查看




    make help




复制代码

例:
debian:~/tomato_git/tomato/release/src-rt# make help
m            Ext - (standard plus extra utilities and NTFS support)
c            BTgui - (Ext plus BT gui)
r            BT - (Ext plus BT Client)
t            BT-VPN - (BT plus VPN)
a            Big - (Ext plus NOCAT plus NFS plus BT gui)
n            Mega - (Big + BT Client minus NOCAT)
e            VPN - (standard plus VPN, extra utilities and NTFS support)
b            Big-VPN - (Big plus VPN)
o            Mega-VPN - (Mega plus VPN plus NOCAT minus NFS)
i            MiniIPv6 - (IPv6 with no USB support minus CIFS and RIPv1/2)
s            Std - (no USB support)
f            Mini - (no USB support minus CIFS and RIPv1/2)
v            VPN (no usb) - (VPN with no USB support)
w            SD-VPN (no usb) - (VPN with SD-MOD and no USB support)
r2m          MIPS Release 2 Ext
r2c          MIPS Release 2 BTgui
r2r          MIPS Release 2 BT
r2t          MIPS Release 2 BT-VPN
r2a          MIPS Release 2 Big
r2n          MIPS Release 2 Mega
r2e          MIPS Release 2 VPN
r2b          MIPS Release 2 Big-VPN
r2o          MIPS Release 2 Mega-VPN
r2z          MIPS Release 2 AIO (for routers +8MB flash)
r2v          MIPS Release 2 VPN (no usb)
r2s          MIPS Release 2 Std
r2i          MIPS Release 2 MiniIPv6 (for 4MB flash)
r2f          MIPS Release 2 Mini (for netgear)
n60m         Linksys E-series build Ext
n60c         Linksys E-series build BTGui
n60r         Linksys E-series build BT
n60t         Linksys E-series build BT-VPN
n60a         Linksys E-series build Big
n60n         Linksys E-series build Mega
n60e         Linksys E-series build VPN
n60b         Linksys E-series build Big-VPN
n60o         Linksys E-series build Mega-VPN
n60s         Linksys E-series build Std with IPv6
n60v         Linksys E-series build VPN with IPv6


开始编译




    sudo make V1=Shibby V2=-20111007 r2r




复制代码

说明: 其中V1=分支名称 ,V2=版本号, 两个可以自定义,也可以都不要,您自己决定. 它会出现在固件的about 页面中的版本中. r2r是表示编译的是r2版本带内置bt的功能.

可以休息了, 大约1小时到2小时,取决您的电脑速度.
中间如果有出错,请根据出错提示信息纠错解决(需要一定经验和知识)
编译完成. 在当前的image目录下可查到,将它复制出来.然后刷机,测试..

五. 重新编译




    同一版本

    make clean

     

    改动较大版本

    make distclean




复制代码

清整掉以后,再用本节方法重新make.

六. 其他
如果您决定编译shibby源码最新版. 因为最新版的transmission需要libevent-2.0.10 以上组件, 请替换掉源码中的libevent旧版本,再进行编译.否则会出错




    rm -rf ~/tomato_git/tomato/release/src/router/libevent/

    wget http://www.monkey.org/~provos/libevent-2.0.10-stable.tar.gz

     

    tar xzvf libevent-2.0.10-stable.tar.gz -C ~/tomato_git/tomato/release/src/router/libevent/




复制代码

补充参考网站:
tomatousb官网编译教程(此教程没有说明如何获取tomato分支代码)
http://tomatousb.org/tut:how-to- ... ato-for-total-noobs

数位天堂tomato讨论区,认真看,受益非浅.
http://digiland.tw/viewforum.php?id=42


</p><p>
<a href="index.php?action=login&amp;hash=">立即登陆发表评论</a><br />
</p>
<p><a href="index.php?action=list&amp;hash=">返回日志列表</a><br /><a href="index.php?action=index&amp;hash=">返回主页</a></p>
</card>
</wml>
