本篇博客主要参考了以下内容:
http://www.cnblogs.com/sammei/p/3968916.html
openwrt目录结构
官方源下载速度太度,我从github上clone了openwrt的代码仓库。
git clone https://github.com/openwrt-mirror/openwrt.git
上图是openwrt目录结构,其中第一行是原始目录,第二行是编译过程中生成的目录。各目录的作用是:
- tools - 编译时需要一些工具, tools里包含了获取和编译这些工具的命令。里面是一些Makefile,有的可能还有patch。每个Makefile里都有一句
$(eval $(call HostBuild))
,表示编译这个工具是为了在主机上使用的。 - toolchain - 包含一些命令去获取kernel headers, C library, binutils, compiler, debugger
- target - 各平台在这个目录里定义了firmware和kernel的编译过程。
- package - 包含针对各个软件包的Makefile。openwrt定义了一套Makefile模板,各软件参照这个模板定义了自己的信息,如软件包的版本、下载地址、编译方式、安装地址等。
- include - openwrt的Makefile都存放在这里。
- scripts - 一些perl脚本,用于软件包管理。
- dl - 软件包下载后都放到这个目录里
- build_dir - 软件包都解压到build_dir/里,然后在此编译
-
staging_dir - 最终安装目录。tools, toolchain被安装到这里,rootfs也会放到这里。
- feeds -
- bin - 编译完成之后,firmware和各ipk会放到此目录下。