为了生成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.
$(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 TITLE:=LuoYe first OpenWRT IPK -- prints a snarky message(标题) 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:
-
语句结尾不要留有多余的空格,否则可能编译出错
-
必须符合makefile书写规则,target 语句之前一定加TABTAB
-
官方文档:http://wiki.openwrt.org/doc/devel/packages