您的位置:首页 > 运维架构

debian6编译openwrt过程

2013-03-21 22:25 316 查看
1. 安装编译OpenWrt需 用到的软件包:

sudo apt-get install g++ libncurses5-dev zlib1g-dev bison flex unzip autoconf gawk unzip make gettext gcc binutils patch asciidoc bzip2 libz-dev libc6-dev linux-headers-2.6.32-38

2. 安装 svn.

sudo apt-get install subversion

如果版本不是1.7的话需要手动下载安装包。

对应问题:在执行./script/feeds update -a会提示需要1.7以上版本

在svn安装过程中需要依赖apr,apr-util,sqlite,neon

1)安装 apr 1.2

cd srclib/apr

./configure --prefix=/opt/apr/

make

make test

make install

对应问题:

error: checking for APR... no configure: WARNING: APR not found The Apache Portable Runtime (APR) library cannot be found. Please install APR on this system and supply the appropriate --with-apr option to 'configure'

2)安装 apr-util 1.2

cd ../apr-util

./configure --prefix=/usr/local/apr-util-httpd/ –with-apr=/opt/apr/ ;注意这是apr的安装目录,要加上,不然安装apr-util的时候会检测不到apr的存在

make

make test

make install

对应问题:

error: checking APR version... 1.3.3 configure: Apache Portable Runtime Utility (APRUTIL) library configuration checking for APR-util... no configure: WARNING: APRUTIL not found The Apache Portable Runtime Utility (APRUTIL) library cannot be found. Either install
APRUTIL on this system and supply the appropriate

3)将sqlite-amalgamation-3071000.zip解压,将sqlite3.c 放到指定的位置:

unzip sqlite-amalgamation-3070900.zip

mkdir –p subversion-1.7.2/sqlite-amalgamation

cd sqlite-amalgamation-3070900

cp sqlite3.c ../subversion-1.7.2/sqlite-amalgamation/

对应问题:

error, checking sqlite library version (via pkg-config)... no An appropriate version of sqlite could not be found. We recommmend 3.7.6.3, but require at least 3.6.18.

4)安装neon

./configure --prefix=/usr/local/neon/

make && make install

对应问题:

在执行./script/feeds update -a时会出现

svn: Unrecognized URL scheme

5)安装svn

./configure --with-apr=/opt/apr/ --with-apr-util=/usr/local/apr-util-httpd/ --with-neon=/usr/local/neon/

make && make install

3.下载源码(这里是12.09的)

svn co svn://svn.openwrt.org/openwrt/branches/attitude_adjustment

其他的源码见https://dev.openwrt.org/wiki/GetSource

如果不是刚下载的代码,为了保持代码为最新状态,应该定期运行Svn up更新代码。

4. 下载feeds

./scripts/feeds update -a

5. 安装feed

./scripts/feeds install -a

会出现

: No such file or directory

Failed to build tmp/.config-package.in

: No such file or directory

make[1]: *** [prepare-tmpinfo] Error 1

make: *** [package/symlinks] Error 2

原因是windows和linux的末尾结束符不对,你的源码可能是从windows下拷贝来的。

建议还是在linux直接svn,否则后面编译过程中还会出现问题。

Well the problem was windows line endings. Since my build machine wasn't online at first I used TortoiseSVN on my windows machine to sync with the OpenWrt trunk and then transferred to my linux machine. I didn't have my eol-style set to LF so the line ending
in all my makefiles scripts etc got hosed. Once i converted those back to linux line endings I am up and building.

解决:

cd /home/openwrt(源码根目录目录)

find . | xargs -n1 flip -u

这里要预先安装flip程序 sudo apt-get install flip

6. 配置(引用别人的原话)

[openwrt@localhost trunk]$ make defconfig

[openwrt@localhost trunk]$ make prereq

[openwrt@localhost trunk]$ make menuconfig

通过文本对话框进行选项配置,最主要的配置项有:

Target system(目标系统类型)

Package selection(软件包选择)

Build system settings (编译系统设置)

Kernel modules (内核模块)

[*]表示:这个包裹选中编译,并安装在firmware中;

[M]表示:这个软件包选中编译,但并不安装在firmware中。

在退出Menuconfig的时,会提示是否保存配置。

在此我只对target system进行了选择;勾选了Advanced configuration option和Build the OpenWrt SDK选项。

7. 编译直接用make,在出现错误后系统会提示用make V=s重新编译并查看错误原因

问题:

在下载过程中会出现wget: unable to resolve host address

需要

1)修改/etc/resolv.conf 文件,这里可以加入nameserver 8.8.8.8

推荐DNS如下:

Google Public DNS: 8.8.8.8; 8.8.4.4.

Norton DNS: 198.153.192.1; 198.153.194.1.

OpenDNS: 208.67.222.222; 208.67.220.220.

2)修改/etc/hosts文件加入未解析的ip和域名

例如:216.137.53.162 production.cf.rubygems.org

执行以上操作后重启网络服务:

在debian下执行sudo /etc/init.d/network-manager restart

问题:

src/bcm_tag.h:1:6: error: expected '=', ',', ';', 'asm' or '__attribute__'

before '.' token

这也是由于源文件从windows处得到的原因。

(以下为引用)

(1)一般情况,使用一个简单的命令:

[openwrt@localhost trunk]$ make

(2)在多核处理器系统上为提高速度,可使用(例如用3核处理器):

[openwrt@localhost trunk]$ make –j 3

(3)在后台进行编译,使用空闲的I/O资源和CPU性能,可使用(例如使用双核处理器)

[openwrt@localhost trunk]$ onice -c 3 nice -n 20 make -j 2

(4)编译一个单独的软件包(例如在cups软件包):

[openwrt@localhost trunk]$ make package/cups/compile V=99

(5)如果特殊原因需要分析编译报错信息:

[openwrt@localhost trunk]$ make V=99 2>&1 |tee build.log |grep -i error

说明:将编译的所有输出信息保存在build.log中,将error信息打印在屏幕上。

(6)一个复杂指令的应用

[openwrt@localhost trunk]$ ionice -c 3 nice -n 20 make -j 2 V=99 CONFIG_DEBUG_SECTION_MISMATCH=y 2>&1 \|tee build.log |egrep -i '(warn|error)'

说明:将编译的所有输出信息保存在build.log中,将error和warning信息打印在屏幕上。编译过程使用双核CPU,占用后台资源。

8.生成镜像(Image)位置(引用)

新生成的镜像会默认放在新建的一个bin目录下。例如:/bin/brcm-2.4/packages

[openwrt@localhost trunk]$ ls bin/*

将编译好的镜像做个备份,例如备份到/目录下:

[openwrt@localhost trunk]$ cp bin /

9.清理工作(引用)

建议现在清理编译产生的文件,以免下次编译时造成冲突,(文件如果存在的话,将不会被替换),执行make clean

注意:在执行clean命令,确保已经将编译好的image进行了备份。清理工作会清楚bin目录。

[openwrt@localhost trunk]$ make clean

除了清除生成的目录,还想清除交叉编译工具(以及工具链目录)

[openwrt@localhost trunk]$ make dirclean

清除所有相关的东西,包括下载的软件包,配置文件,feed内容等:(不建议使用)

[openwrt@localhost trunk]$ make distclean

对于更新feeds后出现的错误:

ERROR:please fix package/feeds/packages/mc/Makefile 等类似的问题,需要执行这条语句进行系统的清理

更详细的信息建议您参考

http://downloads.openwrt.org/kamikaze/docs/openwrt.html

应该是当前最新最权威的文档

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: