分类: 嵌入式
2015-05-17 20:58:28
原文地址:OpenWRT之自建IPK 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)))
- 语句结尾不要留有多余的空格,否则可能编译出错
- 必须符合makefile书写规则,target 语句之前一定加TABTAB
- 官方文档:http://wiki.openwrt.org/doc/devel/packages