openwrt 中新增新的檔案、指令碼、可執行程式到韌體
阿新 • • 發佈:2019-02-16
網上有許多介紹如何編譯程式到韌體的文章,寫一篇將多個檔案編譯到韌體中的方法的文章。
#
# Copyright (C) 2007-2016 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
#
# 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
include $(INCLUDE_DIR)/package.mk
PKG_NAME:=luceyi
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
#include $(INCLUDE_DIR)/package.mk
define Package/luceyi
SECTION:=base
CATEGORY:=Utilities
TITLE:=Luceyi cfg and script
DEPENDS:=+librt +libcurl +libpthread #可以程式所依賴的庫
VERSION:=$(PKG_RELEASE)-$(REVISION)
endef
define Package/luceyi/description
This package contains Configure and scripts for Luceyi.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR) #編譯時創立的資料夾
endef
define Build/Compile #預設安裝,不能少
echo
endef
define Package/luceyi/install
$(INSTALL_DIR) $(1)/lib/ $(1)/etc/ $(1)/usr/ #在openwrt 中建立新的目錄
$(CP) -rf ./files/etc $(1)/ #從本地複製檔案到openwrt下目錄
$(CP) -rf ./files/lib $(1)/
$(INSTALL_DIR) $(1)/usr/local/scanner/ #安裝可執行檔案
$(INSTALL_BIN) ./files/usr/local/scanner/scanner $(1)/usr/local/scanner/
(cd $(1)/usr/local/scanner; $(LN) workspace back1) #建立連線目錄
endef
$(eval $(call BuildPackage,luceyi)) #不能少