自己从源码编译dd-wrt
从源码构建DD-WRT不很困难,但是比编译openwrt要难一点。一、安装系统和依赖的软件包
需要一个linux系统和相关的编译工具,我严重向大家推荐debian和ubuntu,因为它们比较方便。
编译需要的软件包如下:
Automake v1.9.4
GNU Make v?
GCC/G++ v4
ncurses
binutils
tar
bzip2
gzip
g++
patch
flex
bison
make
gettext
unzip
libz-dev
libc headers
安装以上的软件包用以命令: sudo apt-get install gcc g++ binutils patch bzip2 flex bison make gettext unzipzlib1g-dev libc6二、获取DD-WRT的源码
DD-WRT的源码文件结构如下:
src/ source
router/ packages
linux/ kernel
opt/ make/control
通过以下命令获取DD-WRT的最新源码:svn co svn://svn.dd-wrt.com/DD-WRT .这个命令会下载DD-WRT的全部源码到当前目录中,因为它的源码比较大,可能有2G左右,而且到国外的速度比较慢,所以可能需要一天才能下载完。
你需要下载 3.4.6 和4.1.0 版本的mipsl uclibc 工具链,可以从以下地址下载到:
http://www.dd-wrt.com/dd-wrtv2/d ... .debian.sp1.tar.bz2
把文件下载完后,解压到/homte/db90h目录中。
三、编译DD-WRT
要编译DD-WRT你只需要简单的做以下步骤:
0. 执行 ready_ddwrt.sh 和 ready_ddwrt_root.sh (这个脚本在后面).
1. 添加 4.1.0 toolchains 执行文件目录到环境变量中。
PATH=$PATH:/home/db90h/toolchains/4.1.0-uclibc/bin
2. 进入DD-WRT/opt 目录运行 ./install.sh。或者执行不同的./install_×××,以编译出不同的固件版本.
以下两个在编译前需要执行的脚本文件:
重要提醒:这两个脚本都依赖于你系统中dd-wrt的下载目录和gcc toolchain的解压目录。所以你在运行前都要修改两个脚本中的内容以适合本机的情况,否则不能起到预期的作用。
#!/bin/sh
#
# title: ready_ddwrt.sh
# version: 1.14
# author: Jeremy Collake <jeremy@bitsum.com>
#
# This silly script will prepare a build environment
# for DD-WRT. You must also run ready_ddwrt_root.sh.
#
# RL 11/01/2006: Added line to compile tools/webcomp.c and write4.c
#
MINPARAMS=1
if [ $# -lt "$MINPARAMS" ]
then
echo usage:
echo ready_ddwrt.sh
echo
echo i.e.:
echo ready_ddwrt.sh /home/db90h/DD-WRT
echo
exit 1
fi
ME=`whoami`
DDROOT=$1
echo I am $ME
echo DD-WRT is at $DDROOT
echo ................................................................
echo creating some symlinks
echo ................................................................
rm $DDROOT/src/linux/brcm/linux.v23/include/asm
ln -s $DDROOT/src/linux/brcm/linux.v23/include/asm-mips $DDROOT/src/linux/brcm/linux.v23/include/asm
# for CFE building
ln -s $DDROOT/src/linux/brcm/linux.v23 $DDROOT/src/linux/linux
echo done
echo ................................................................
echo adjusting some attributes
echo ................................................................
chmod +x $DDROOT/src/router/iptables/extensions/.dccp-test
chmod +x $DDROOT/src/router/iptables/extensions/.layer7-test
echo done
#echo ................................................................
#echo fixing alconf's
#echo ................................................................
#cd src/router/pptpd
#aclocal
#cd ../../..
echo ................................................................
echo "re-building some tools"
echo ................................................................
cd $DDROOT
# make bb_mkdep
cd src/router/busybox/scripts
rm bb_mkdep
make bb_mkdep
cd ../../../..
# make jsformat
cd src/router/tools
rm jsformat
make jsformat
cd ../../..
# make mksquashfs-lzma
cd src/squashfs-tools/
rm mksquashfs-lzma
make
cp mksquashfs-lzma ../linux/brcm/linux.v23/scripts/squashfs
cd ../..
# make strip
cd tools
rm ./strip
gcc strip.c -o ./strip
cd ..
# make write3
cd tools
rm ./write3
gcc write3.c -o ./write3
cd ..
# make write4
cd tools
rm ./write4
gcc write4.c -o ./write4
cd ..
# make webcomp
cd tools
rm ./webcomp
gcc -o webcomp -DUEMF -DWEBS -DLINUX webcomp.c
cd ..第二脚本要以root权限运行。#!/bin/sh
#
# title: ready_ddwrt_root.sh
# version: 1.1
# author: Jeremy Collake <jeremy@bitsum.com> aka db90h
#
# This silly script will prepare a build environment
# for DD-WRT. You must also run ready_ddwrt.sh.
#
MINPARAMS=2
if [ $# -lt "$MINPARAMS" ]
then
echo
echo This script needs root access.
echo
echo usage:
echo ready_ddwrt_root.sh
echo
echo i.e.:
echo ready_ddwrt_root.sh /home/db90h/DD-WRT /home/db90h/3.4.6-ucliblc-0.9.28
echo
exit 1
fi
ME=`whoami`
DDROOT=$1
TCHAIN=$2
echo I am $ME
echo DD-WRT is at $DDROOT
echo mipsl-uclibc-x toolchain is at $TCHAIN
echo ................................................................
echo creating some symlinks
echo ................................................................
# duh, this will already be here
mkdir -p /opt
rm /opt/3.3.6
ln -s $TCHAIN /opt/3.3.6
rm /GruppenLW
ln -s $DDROOT/image /GruppenLWecho All done!
四、更改DD-WRT
进入 /src/router 目录,你会看到 .config* 文件. 使用 'make menuconfig' 编辑配置文件. 可以进入 /src/router/busybox 目录选择要编译的busybox选项。
Change micro configuration: WARNING: Before and after doing this you need to copy and restore the "Internal Options" section of the .config files. These options don't seem to be in #the Config template.
cd DD-WRT/src/router
cp .config .config_micro
make menuconfig
cp .config_micro .config
Change micro Busybox configuration:
cd DD-WRT/src/router/busybox
cp .config .config_micro
make menuconfig
cp .config_micro .config
Change micro kernel configuration:
cd DD-WRT/src/router/busybox
cp .config .config_micro
make menuconfig
cp .config_micro .config
原文链接:http://www.dd-wrt.com/wiki/index.php/Development 等广告的美刀到了 我也败个玩玩 呵呵! 哈哈!
不错!!
执行ready_ddwrt.sh出错,请看一下是什么固原
root@wedo-desktop:~# sh /media/disk-1/DD-WRT/ready_ddwrt.sh /media/disk-1/DD-WRTI am root
DD-WRT is at /media/disk-1/DD-WRT
................................................................
creating some symlinks
................................................................
done
................................................................
adjusting some attributes
................................................................
chmod: cannot access `/media/disk-1/DD-WRT/src/router/iptables/extensions/.dccp-test': No such file or directory
chmod: cannot access `/media/disk-1/DD-WRT/src/router/iptables/extensions/.layer7-test': No such file or directory
done
................................................................
re-building some tools
................................................................
rm: cannot remove `bb_mkdep': No such file or directory
make: *** No rule to make target `bb_mkdep'.Stop.
cc jsformat.c -o jsformat
jsformat.c: In function ‘filter’:
jsformat.c:11: warning: incompatible implicit declaration of built-in function ‘malloc’
rm: cannot remove `mksquashfs-lzma': No such file or directory
make -C ./lzma/C/7zip/Compress/LZMA_Lib
make: Entering directory `/media/disk-1/DD-WRT/src/squashfs-tools/lzma/C/7zip/Compress/LZMA_Lib'
make: Nothing to be done for `all'.
make: Leaving directory `/media/disk-1/DD-WRT/src/squashfs-tools/lzma/C/7zip/Compress/LZMA_Lib'
g++ mksquashfs.o read_fs.o sort.o -L./lzma/C/7zip/Compress/LZMA_Lib -llzma -o mksquashfs-lzma
make: g++: Command not found
make: *** Error 127
cp: cannot stat `mksquashfs-lzma': No such file or directory
strip.c: In function ‘main’:
strip.c:14: warning: incompatible implicit declaration of built-in function ‘memset’
strip.c:24: warning: incompatible implicit declaration of built-in function ‘strstr’
strip.c:30: warning: incompatible implicit declaration of built-in function ‘strlen’
strip.c:79: warning: incompatible implicit declaration of built-in function ‘memcpy’
strip.c:87: warning: incompatible implicit declaration of built-in function ‘strlen’
write4.c: In function ‘filter’:
write4.c:65: warning: incompatible implicit declaration of built-in function ‘strlen’
write4.c:80: warning: incompatible implicit declaration of built-in function ‘memcpy’
webcomp.c: In function ‘compile’:
webcomp.c:142: warning: comparison of distinct pointer types lacks a cast
其实那些提示没的文件或目录的(如红色标出的)源码里本来就没有的呢
[ 本帖最后由 WeDone 于 2008-2-19 23:21 编辑 ] DDROOT/src/linux/brcm/linux.v23/include/asm
ln -s $DDROOT/src/linux/brcm/linux.v23/include/asm-mips $DDROOT/src/linux/brcm/linux.v23/include/asm
# for CFE building
ln -s $DDROOT/src/linux/brcm/linux.v23 $DDROOT/src/linux/linux
echo done
echo ................................................................
echo adjusting some attributes
echo ................................................................
chmod +x $DDROOT/src/router/iptables/extensions/ LINUX啊,看到晕 好多步骤,mark,马上就用得上了。 好多步骤,mark,马上就用得上了
非常感谢~~~~~~~~~~~
页:
[1]