基于 ncurses 的 文本 配置界面:
Shell
make menuconfigmake menuconfig
同配置linux内核类似,几乎每一个设置都有三个选项:y / m / n,分别代表如下含义:* `` (按下`y`)这个包会被包含进固件镜像
* `` (按下`m`)这个包会在生成刷新OpenWrt的镜像文件以后被编译,但是不会被包含进镜像文件
* `` (按下`n`)这个包不会被编译
当你保存你的配置后,~/openwrt/trunk/.config这个文件会按照你的配置被生成。
\\编译环境会提供一个这样的配置文件给OpenWrt 'Backfire' 10.03.1-RC5。
同配置Linux内核类似,几乎每一个设置都有三个选项:y / m / n,分别代表如下含义: * `` (按下`y`)这个包会被包含进固件镜像 * `` (按下`m`)这个包会在生成刷新OpenWrt的镜像文件以后被编译,但是不会被包含进镜像文件 * `` (按下`n`)这个包不会被编译 当你保存你的配置后,~/openwrt/trunk/.config这个文件会按照你的配置被生成。 \\编译环境会提供一个这样的配置文件给OpenWrt 'Backfire' 10.03.1-RC5。
默认配置(Defconfig)在启用默认配置以前先选择的你的目标平台
Shell
make defconfigmake defconfig
总体配置Shell
make menuconfigmake menuconfig
这会自动更新你现在存在的配置的依赖,方便你你准备编译你更新过的镜像。
配置过程包括:
目标系统 软件包设定 系统构建设定 内核模块三种选择模式:
< > 该代码将 不会 被编译
<M> 该代码将被交叉编译,生成的ipk软件包将被放在 /buildsystem/bla/bla/bla , 但该软件包不会放入固件中
<*> 该代码将被放入固件中 (on the SqashFS partition)
内核配置Shell
make kernel_menuconfigmake kernel_menuconfig
See: Customizing the kernel options
配置文件在编译前编辑配置文件可以在以下目录:
Shell
<buildroot dir>/files/<buildroot dir>/files/
例如,在编译前配置防火墙,需要把防火墙配置文件’firewall’放入以下文件夹
Shell
<buildroot dir>/files/etc/config/<buildrootdir>/files/etc/config/
编译镜像Shell
makemake
编译选项在多核CPU上编译
可通过 -j 选项启用多个进程以加速编译过程:
Shell
make -j 3make -j 3
编译单个包Shell
make package/cups/compile V=99make package/cups/compile V=99
编译完成 本地固件本地固件存放在:
Shell
cd ~/openwrt/trunk/bincd ~/openwrt/trunk/bin
清理 clean清除上次的make命令所产生的object文件(后缀为“.o”的文件)及可执行文件。
Shell
make cleanmake clean
deletes contents of bin and build_dir directories.
dircleanShell
make dircleanmake dirclean
deletes contents of /bin and /build_dir directories and additionally /staging_dir and /toolchain (=the cross-compile tools). ‘Dirclean’ is your basic “Full clean” operation.
Distcleanmake distclean类似make clean,但同时也将configure生成的文件全部删除掉,包括Makefile。
Shell
make distcleanmake distclean
nukes everything you have compiled or configured and also deletes all downloaded feeds contents and package sources.
注意:此操作会清除所有配置文件(.config)和一些其他选项。谨慎使用。
在编译openwrt时,还有许多其他功能,以上是常用功能
故障排除Shell
make V=99make V=99
此命令会显示详细的编译报错,找到报错的软件包,手动wget即可
一些链接编译例子: 编译X86 openwrt(for vmware)
编译例子: 编译shadowsocks for openwrt的ipk
官方链接: https://wiki.openwrt.org/zh-cn/doc/howto/build