一、已知宿主机编译需要的依赖:
- asciidoc
- GNU Bash
- GNU Binutils
- bzip2
- flex
- git
- GNU C++ Compiler
- GNU C Compiler
- GNU Time
- getopt
- GNU awk
- help2man
- intltool-update
- libelf-dev
- libz, libz-dev
- make
- ncurses
- openssl/ssl.h
- patch
- perl-ExtUtils-MakeMaker
- perl-Thread-Queue
- python2-dev
- unzip
- GNU Wget
- xgettext
- xsltproc
- zlib, zlib-static
二、Ubuntu环境安装宿主机需要的编译依赖:
sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev python rsync man-db gawk flex quilt libssl-dev xsltproc libxml-parser-perl mercurial gettext bzr ecj cvs unzip zip wget time
三、下载OpenWrt源码:
可以通过如下列出的3个Git源码版本控制URL中选择一个,建议选择国内克隆地址。
- git clone https://git.openwrt.org/openwrt/openwrt.git (官方地址)
- git clone https://github.com/openwrt/openwrt.git (官方同步地址)
- git clone https://gitee.com/harvey520/openwrt.git (国内克隆地址)
四、更新所有软件包定义及安装软链接
1、建议修改feeds.conf.default文件中的软件包定义为国内的克隆地址:
src-git packages https://gitee.com/harvey520/packages.git
src-git luci https://gitee.com/harvey520/luci.git
src-git routing https://gitee.com/harvey520/routing.git
src-git telephony https://gitee.com/harvey520/telephony.git
#src-git packages https://git.openwrt.org/feed/packages.git
#src-git luci https://git.openwrt.org/project/luci.git
#src-git routing https://git.openwrt.org/feed/routing.git
#src-git telephony https://git.openwrt.org/feed/telephony.git
2、执行如下命令进行软件包预处理
./scripts/feeds update -a (获取在feeds.conf.default中所有软件包定义,下载到feeds目录)
./scripts/feeds install -a (安装所有软件包到package/feeds的软链接)
五、提前下载软件包所有依赖源码到dl编译目录
(该步可选,但提前下载可以在后面编译项目时节省大量时间)
git clone https://e.coding.net/yao7778899/openwrt-dependent-dl.git dl
六、选择编译目标系统(X86 64位编译固件)
make menuconfig
“Target System” ⇒ “x86”
“Subtarget” ⇒ “x86_64”
七、执行固件编译
make V=s -j2 (输出详细编译信息,使用2个线程并行执行Make任务)
八、生成固件
编译完成以后,固件可以在目录 ./bin/targets/x86/64目录中找到。
“openwrt-x86-64-generic-ext4-combined.img.gz”可以用于构建虚拟机所需硬盘格式的原始镜像文件。
备注:
1、可以参见《Ubuntu环境在Virtualbox虚拟机运行OpenWrt》文档描述使用生成的固件在Virtualbox虚拟机上运行OpenWrt
2、默认编译的固件不包含Web管理软件包,可以在虚拟机成功运行OpenWrt后,通过如下命令安装Web管理软件包
opkg update
opkg install luci