针对的是:http://kamikaze.openwrt.org/docs/openwrt.html#x1-390002

1.If you want, you can also modify the kernel config for the selected target system. simply run "make kernel_menuconfig" and the build system will unpack the kernel sources (if necessary), run menuconfig inside of the kernel tree, and then copy the kernel config to target/linux/<platform>/config so that it is preserved over "make clean" calls.  ---- 如果你愿意,你也可以修改内核配置为选定的目标系统。简单地运行“make kernel_menuconfig”和构建系统将解压缩内核源代码(如果有必要)。此命令会展示针对内核的配置选择界面,然后其结果再复制内核配置到目标/ linux的/<platform>/配置。这样得到的针对内核的.config文件,在"make clean"后依然是保留的。

2.During the build process, buildroot will download all sources to the "dl" directory and will start patching and compiling them in the "build_dir/<arch> " directory. When finished, the resulting firmware will be in the "bin" directory and packages will be in the "bin/packages" directory -- 在编译过程中,buildroot会将所有的源下载到“dl”目录下,并在“build_dir/<arch>”目录中对它们进行patch和编译。完成后,所产生的固件将在“bin”目录,而各个package将在“bin/packages"目录中

3.openwrt中的一个典型的package目录结构:

  • package/<name>/Makefile  --- 必须存在;其作用是定义下载包和编译包的步骤
  • package/<name>/patches   --- 可有可无;是对所下载包的修复和优化,即补丁
  • package/<name>/files        --- 可有可无;是此包特有的启动脚本和配置文件

4.openwrt中的一个典型的package目录结构(以backfire的package/bridge-utils为例)。其makefile的内容如下:

#
# Copyright (C) 2006-2008 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=bridge-utils    //The name of the package, as seen via menuconfig and ipkg。不过我在CPE上使用opkg list命令,看到的是bridge - 1.4-1;而通过make menuconfig看到的是 bridge(在Base System里面)。 此外,在package中有一个bridge-utils;在feeds/package中也有一个。到底这些如何对应呢?
PKG_RELEASE:=1  //The version of this package Makefile
PKG_SOURCE_URL:=@SF/bridge  //Where to download the sources from (no trailing slash), you can add multiple download sources by separating them with a and a carriage return. @SF表示从SourceForge下载

ifeq ($(CONFIG_LINUX_2_4),y)
  PKG_VERSION:=1.0.6
  PKG_MD5SUM:=9b7dc52656f5cbec846a7ba3299f73bd
endif

ifeq ($(CONFIG_LINUX_2_6),y)
  PKG_VERSION:=1.4  //The upstream version number that we are downloading
  PKG_MD5SUM:=0182fcac3a2b307113bbec34e5f1c673  //A checksum to validate the download
endif

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz   //The filename of the original sources,这里就是 bridge-utils-1.4.tar.gz

include $(INCLUDE_DIR)/package.mk  //位于 backfire_10.03/include/package.mk,用于定义任何一个package下载的统一的方式脚本

define Package/bridge
  SECTION:=net   //The type of package (currently unused)
  CATEGORY:=Base system   //Which menu it appears in menuconfig: Network, Sound, Utilities, Multimedia ...
  TITLE:=Ethernet bridging configuration utility  //A short description of the package
  URL:=http://bridge.sourceforge.net/   //Where to find the original software
endef

define Package/bridge/description
 Manage ethernet bridging: a way to connect networks together to
 form a larger network.
endef

CONFIGURE_ARGS += \
    --with-linux-headers="$(LINUX_DIR)" \

define Build/Prepare   //这是可选项。A set of commands to unpack and patch the sources. You may safely leave this undefined.
$(call Build/Prepare/Default)
    ( cd $(PKG_BUILD_DIR) ; \   //PKG_BUILD_DIR定义在下载包后将此包解压缩到$(BUILD_DIR)的具体位置。对于此bridge-util包,其位置在backfire_10.03/build_dir/linux-brcm47xx/bridge-utils-1.4 中;同时这就说明用的是package中的,而不是feeds/package中的
        [ -f ./configure ] || { \
            ln -sf configure.in configure.ac ; \
            autoconf ; \
        } \
    )
endef

define Package/bridge/install
    $(INSTALL_DIR) $(1)/usr/sbin   //$(INSTALL_DIR)即为:install -d -m0755  
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/brctl/brctl $(1)/usr/sbin/   //$(INSTALL_BIN)即为: install -m0755
endef

$(eval $(call BuildPackage,bridge))   //这是真正开始执行的位置。BuildPackage定义在package.mk中,其调用的参数是bridge。这样就会走到package.mk中的:define BuildPackage
  $(Build/IncludeOverlay)
  $(eval $(Package/Default))
  $(eval $(Package/$(1)))   //对应就是$(Package/bridge),从而又找到package/bridge-utils/Makefile中的 define Package/bridge 位置。

再举一个稍微复杂的例子,package/dropbear(一个轻量级的ssh客户端与服务端开源),其目录中包含了:files(内含配置文件和启动脚本),patches(内含补丁)和Makefile;如下是Makefile:

#
# Copyright (C) 2006-2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=dropbear  //The name of the package, as seen via menuconfig and ipkg
PKG_VERSION:=0.52  //The upstream version number that we are downloading
PKG_RELEASE:=4  //The version of this package Makefile

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz   //The filename of the original sources,这里就是 dropbear-0.52.tar.gz
PKG_SOURCE_URL:= \     //下载源码包的url地址,这里就写了多个地址,用回车换行+一个斜杠来排列表示
    http://matt.ucc.asn.au/dropbear/releases/ \
    http://www.mirrors.wiretapped.net/security/cryptography/apps/ssh/dropbear/
PKG_MD5SUM:=1c69ec674481d7745452f68f2ea5597e  //MD5校验和

include $(INCLUDE_DIR)/package.mk  //实际是include了 backfire_10.03/include/package.mk

define Package/dropbear/Default
  URL:=http://matt.ucc.asn.au/dropbear/  //Where to find the original software
endef

define Package/dropbear   //由 BuildPackage 命令调用
  $(call Package/dropbear/Default)
  SECTION:=net  //The type of package (currently unused)
  CATEGORY:=Base system  //Which menu it appears in menuconfig: Network, Sound, Utilities, Multimedia ...
  TITLE:=Small SSH2 client/server  //A short description of the package
endef

define Package/dropbear/description
 A small SSH2 server/client designed for small memory environments.
endef

define Package/dropbear/conffiles  //此项可选,A list of config files installed by this package, one file per line.表示此package会安装的一些配置文件
/etc/dropbear/dropbear_rsa_host_key
/etc/dropbear/dropbear_dss_host_key
/etc/config/dropbear
endef

define Package/dropbearconvert   //这是另一个package,也是从dropbear的源码包里面会得到的。
  $(call Package/dropbear/Default)
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=Utility for converting SSH keys
endef

CONFIGURE_ARGS += \
    --with-shared \
    --disable-pam \
    --enable-openpty \
    --enable-syslog \
    $(if $(CONFIG_SHADOW_PASSWORDS),,--disable-shadow) \
    --disable-lastlog \
    --disable-utmp \
    --disable-utmpx \
    --disable-wtmp \
    --disable-wtmpx \
    --disable-loginfunc \
    --disable-pututline \
    --disable-pututxline \
    --disable-zlib

define Build/Configure  //此项可选。用于编译时传递一些自定义参数
    $(SED) 's,^/\* #define PKG_MULTI.*,#define PKG_MULTI,g' $(PKG_BUILD_DIR)/options.h
    $(SED) 's,^#define DO_HOST_LOOKUP,/* & */,g' $(PKG_BUILD_DIR)/options.h
    $(call Build/Configure/Default)
endef

define Build/Compile  //此项可选。表示如何编译源码包
    $(MAKE) -C $(PKG_BUILD_DIR) \
        $(TARGET_CONFIGURE_OPTS) \
        LD="$(TARGET_CC)" \
        PROGRAMS="dropbear dbclient dropbearkey scp" \
        MULTI=1 SCPPROGRESS=1
    $(MAKE) -C $(PKG_BUILD_DIR) \
        $(TARGET_CONFIGURE_OPTS) \
        LD="$(TARGET_CC)" \
        PROGRAMS="dropbearconvert"
endef

define Package/dropbear/install  //A set of commands to copy files out of the compiled source and into the ipkg which is represented by the $(1) directory
    $(INSTALL_DIR) $(1)/usr/sbin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
    $(INSTALL_DIR) $(1)/usr/bin
    ln -sf ../sbin/dropbear $(1)/usr/bin/scp
    ln -sf ../sbin/dropbear $(1)/usr/bin/ssh
    ln -sf ../sbin/dropbear $(1)/usr/bin/dbclient
    ln -sf ../sbin/dropbear $(1)/usr/bin/dropbearkey
    $(INSTALL_DIR) $(1)/etc/config
    $(INSTALL_DATA) ./files/dropbear.config $(1)/etc/config/dropbear
    $(INSTALL_DIR) $(1)/etc/init.d
    $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
    $(INSTALL_DIR) $(1)/usr/lib/opkg/info
    $(INSTALL_DIR) $(1)/etc/dropbear
    touch $(1)/etc/dropbear/dropbear_rsa_host_key
    touch $(1)/etc/dropbear/dropbear_dss_host_key
endef

define Package/dropbearconvert/install
    $(INSTALL_DIR) $(1)/usr/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
endef

$(eval $(call BuildPackage,dropbear))  //调用package.mk中的BuildPackage,开始编译dropbear
$(eval $(call BuildPackage,dropbearconvert))  //调用package.mk中的BuildPackage,开始编译dropbearconvert

在你创建你的 package/<NAME>/ Makefile文件后,新的软件包会自动在下一次运行“make menuconfig时”,出现在菜单中。如果选中,此该package将在下一次make中被自动编译

openWRT自学---对官方的开发指导文档的解读和理解 记录1:编译一个package的更多相关文章

  1. openWRT自学---对官方的开发指导文档的解读和理解 记录3:一些常用方法

    1.约定 configuration files follow the convention:  <name>.conf init files follow the convention: ...

  2. openWRT自学---对官方的开发指导文档的解读和理解 记录2:如何控制内核模块的编译

    openwrt对于kernel module的处理分两类:随内核主线而来的kernel module 和 其他作为独立project的kernel module.而这两种,openwrt将采用相同的模 ...

  3. Enterprise Solution 2.2 开发帮助文档集合

    首先是一个PPT文档,从宏观层面展示Enterprise Soltion的几个功能特色. Enterprise Solution解决方案安装与配置 将源代码解决方案和演示程序在电脑中进行配置,作为了解 ...

  4. Spring MVC 指导文档解读(一)

    22.1 指导文档章节 In the Web MVC framework, each DispatcherServlet has its own WebApplicationContext, whic ...

  5. WEB前端开发规范文档(转)

    http://codeguide.bootcss.com/  编写灵活.稳定.高质量的 HTML 和 CSS 代码的规范上面的文档 再结合下面的规范: 无论是从技术角度还是开发视角,对于web前端开发 ...

  6. Android APP开发需求文档范本

    Android  APP开发需求文档范本 软件需求文档格式的标准写法 1.引言 1.1 编写目的 • 阐明开发本软件的目的: 1.2 项目背景 • 标识待开发软件产品的名称.代码: • 列出本项目的任 ...

  7. 网站开发进阶(三十八)Web前端开发规范文档你需要知道的事

    Web前端开发规范文档你需要知道的事 规范目的 为提高团队协作效率, 便于后台人员添加功能及前端后期优化维护, 输出高质量的文档, 特制订此文档. 本规范文档一经确认, 前端开发人员必须按本文档规范进 ...

  8. FlappyBird开发帮助文档

    FlappyBird开发帮助文档 项目需求 完成FlappyBird游戏. 功能说明: 游戏开始后,间歇性的点击鼠标,让小鸟向上飞,不会掉下来,并且要穿过柱子的空隙,不能碰到柱子,碰到就dead了,穿 ...

  9. Web前端开发规范文档你需要知道的事

    Web前端开发规范文档你需要知道的事 规范目的 为提高团队协作效率, 便于后台人员添加功能及前端后期优化维护, 输出高质量的文档, 特制订此文档. 本规范文档一经确认, 前端开发人员必须按本文档规范进 ...

随机推荐

  1. 纯CSS实现网站常用的五角星评分和分数展示交互效果

    最近做的一个项目涉及到评分和展示分数的模块,UI设计师也给了几个切好的图片,实现五角星评分方式很多,本质爱折腾的精神和对性能追求以及便于维护的考虑,搜集和尝试了很多方式,最终采用了纯css驱动的实现方 ...

  2. python3.6使用pickle序列化class

    from library.connecter.database.mongo import Op_Mongo a = pickle.dumps(Op_Mongo) #序列化 b = pickle.loa ...

  3. scala,import test._ ; import test.{ClassA,ClassB}

    在scala中,*不是通配符,下斜杠“_”才是通配符.因此当使用某个package所有的类时,直接使用:import test._:使用某几个时,直接使用:import test.{ClassA,Cl ...

  4. linux的dd命令详解

    一.dd命令的解释 dd:用指定大小的块拷贝一个文件,并在拷贝的同时进行指定的转换. 块大小可以使用的计量表 参数注释: 1. if=文件名:输入文件名,缺省为标准输入stdin.即指定源文件.< ...

  5. Qt自己定义事件实现及子线程向主线程传送事件消息

    近期在又一次学习Qt的时候,由于要涉及到子线程与主线程传递消息,所以便琢磨了一下.顺便把有用的记录下来,方便自己以后查询及各位同仁的參考! 特此声明,本篇博文主要讲述有用的,也就是直接说明怎么实现,就 ...

  6. django静态html中做动态变化

    在搭建网站中经常有筛选分类的需求 在django中为了简便,我们经常将某些相同部分的内容取出来单独存放形成一个base模板,其他的template继承这个base就可以使用其中的内容 但是这些相同的部 ...

  7. ECShop后台管理菜单修改

    ECShop中,和后台菜单相关的文件有两个: ·菜单项:admin\includes\inc_menu.php·菜单文本:languages\zh_cn\admin\common.php 所以,要修改 ...

  8. SpringMVC 下载XLS文档的设置

    页面设置参考上文.SpringMVC 下载文本文档的设置 此文是关于xls文档下载的,这个文档使用Apache的POI生成,需要的jar包可以从下面地址下载: http://pan.baidu.com ...

  9. 在html页面中直接嵌入图片数据

    一般情况,通常是在html页面中应用图片的链接,如: <img src="http://baidu.com/logo.gif">   但是,这样的前提是我们需要将图片先 ...

  10. Android学习(二) 标签滚动跳过

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools= ...