Chinaunix首页 | 论坛 | 博客
  • 博客访问: 395214
  • 博文数量: 85
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1707
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-27 11:18
个人简介

学无止境……

文章分类

全部博文(85)

分类: 嵌入式

2014-10-14 09:45:47

为了生成IPK文件,OpenWRT定制了一套自己的makefile规则.其目录位于软件源码目录之上.

集成OpenWRT的非官方包之Makefile规则

include $(TOPDIR)/rules.mk 
Name and release number of this package etc...
PKG_NAME:=helloworld --  软件包名字(和文件夹名称一样) PKG_VERSION:=1.0 -- 软件包版本 PKG_RELEASE:=1 -- 照抄吧 
This specifies the directory where we're going to build the program.其中 $(BUILD_DIR) 应该位于SDK_DIR\build_dir\target-mipsel_24kec+dsp_uClibc-0.9.33.2\
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) 
pkg_source infomation , if you need.
#PKG_SOURCE:=helloworld.tar.gz -- The filename of the original sources #PKG_SOURCE_URL:=xxxxx    -- Where to download the sources from (directory) #PKG_MD5SUM:=xxxxxxxxxx   -- A checksum to validate the download  #PKG_CAT:=zcat  -- How to decompress the sources (zcat, bzcat, unzip) 
$(INCLUDE_DIR) 位于 SDK_DIR/include/ ,包含所需官方文件
include $(INCLUDE_DIR)/package.mk 
Specify package information for this program
define Package/$(PKG_NAME) SECTION:=utils      -- The type of package (currently unused) CATEGORY:=Utilities -- Which menu it appears in menuconfig #DEPENDS:=(optional)[依赖包 两个之间通过空格分隔 前面加+为默认显示 选中该软件包自动选中依赖包 不加+为默认不显示 选中依赖包才显示] TITLE:=LuoYe first OpenWRT IPK   -- prints a snarky message(标题) #DESCRIPTION:=This variable is obsolete. use the Package/name/description define instead! #URL:=    --http://blog.chinaunix.net/uid/29145190.html #MAINTAINER:=LuoYe   -- Author endef 
Description of PKG
define Package/$(PKG_NAME)/description
    My first OpenWRT pkg , its function is printf hello LuoYe ! endef 
Specify what needs to be done to prepare for building the package.将源码copy至build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2 便于编译
define Build/Prepare mkdir -p $(PKG_BUILD_DIR) $(CP) ./src/* $(PKG_BUILD_DIR)/
endef 
How to install the compiled source
define Package/$(PKG_NAME)/install
    $(INSTALL_DIR) $(1)/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/bin/
endef 
编译成IPK的最终执行命令
$(eval $(call BuildPackage,$(PKG_NAME))) 

Tips:

  1. 语句结尾不要留有多余的空格,否则可能编译出错
  2. 必须符合makefile书写规则,target 语句之前一定加TABTAB
  3. 官方文档:http://wiki.openwrt.org/doc/devel/packages
阅读(2216) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~