使用SDK
SDK是一个可再定位的,预编译好的OpenWrt工具链,适用于在不从头开始编译整个系统的前提下,针对一个特定平台交叉编译单个用户空间包。
使用SDK的原因:
- 为了保证二进制和特性兼容性,针对特定的发行版编译自定义软件
- 编译更新版本的指定包文件
- 使用自定义的补丁或者不同特性来重新编译已经存在的包
我们做了一个中文的说明: http://see.sl088.com/wiki/%E6%90%AD%E5%BB%BAOpenwrt_SDK
获得SDK
Download
You should find bz2-archives ready for download in the corresponding download directory:
Create one
Usage
By default the SDK ships with no package definitions.
Makefiles for packages to compile must be checked out from the OpenWrt repository and placed into the package/ directory first.
Obtain Definitions
Use the svn export command to obtain package definitions.
OpenWrt's Trunk package feed is located at svn://svn.openwrt.org/openwrt/packages,
the Trac browser can be used to find the appropriate subdirectory.
The example below checks out the nano editor from the repository:
$ svn export svn://svn.openwrt.org/openwrt/packages/utils/nano package/nano
A package/nano
A package/nano/Makefile
Exported revision 20365. |
Many packages require additional dependencies which can be found in the package Makefile:
$ grep DEPENDS package/nano/Makefile
DEPENDS:=+libncurses |
If there are additional dependencies, those need to be fetched and compiled as well.
Compile Packages
After the Makefile is in place, the usual buildroot commands apply:
make package/example/download- download the soures of examplemake package/example/prepare- extract the sources, apply patches and download if necessarymake package/example/compile- compile example, prepare and download if necessarymake package/example/clean- clean the sourcecodemake package/index- build a repository index to make the output directory usable as local opkg source
The common command to recompile a package example and enable verbose output is:
$ make package/example/{clean,compile} V=99 |
After the compilation is finished, the generated .ipk files are placed in the bin directory.
Example
The example below rebuilds nano.
$ svn export svn:svn.openwrt.org/openwrt/packages/utils/nano package/nano
A package/nano
A package/nano/Makefile
Exported revision 20365.
$ grep DEPENDS package/nano/Makefile
DEPENDS:=+libncurses
$ svn export svn:svn.openwrt.org/openwrt/trunk/package/ncurses package/ncurses
A package/ncurses
A package/ncurses/patches
A package/ncurses/patches/100-ncurses-5.6-20080112-urxvt.patch
A package/ncurses/patches/900-terminfo.patch
A package/ncurses/patches/101-ncurses-5.6-20080628-kbs.patch
A package/ncurses/patches/500-cross.patch
A package/ncurses/Makefile
Exported revision 20365.
$ make package/ncurses/compile
Collecting package info: done
make[1] package/ncurses/compile
make[2] -C package/ncurses compile
$ make package/nano/compile
make[1] package/nano/compile
make[2] -C package/ncurses compile
make[2] -C package/nano compile
$ make package/index
make[1] package/index
$ ls bin/packages/mipsel/
libncurses_5.7-2_mipsel.ipk nano_2.2.3-1_mipsel.ipk Packages Packages.gz |