include $(TOPDIR)/rules.mk

PKG_NAME:=FastZigbee
VERSION_YEAR=$(shell date +%Y)
VERSION_MAJOR=$(shell expr $(VERSION_YEAR) - 2018)
VERSION_MINOR=$(shell date +%V%u)
#VERSION_REVISION=$(shell date +%H%M)
VERSION_REVISION=0000
PKG_VERSION:=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION)


include $(INCLUDE_DIR)/package.mk

define Package/$(PKG_NAME)
	SECTION:=DYIOT
	CATEGORY:=DYIOT Software
	TITLE:=ZLG FAST Zigbee support
	DEPENDS:=+libuci +libdyutils +libubox +uart_tool +libipc_session
endef

define Package/$(PKG_NAME)/description
	ZLG FAST Zigbee support
endef

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Package/$(PKG_NAME)/install
	$(INSTALL_DIR) $(1)/app/config
	$(INSTALL_DIR) $(1)/etc/init.d/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/fastzigbee $(1)/app/
	$(INSTALL_BIN) ./files/fastzigbee_1.initd $(1)/etc/init.d/fastzigbee_1
	$(INSTALL_BIN) ./files/fastzigbee_2.initd $(1)/etc/init.d/fastzigbee_2
	$(INSTALL_BIN) ./files/fastzigbee_3.initd $(1)/etc/init.d/fastzigbee_3
	$(INSTALL_BIN) ./files/fastzigbee_4.initd $(1)/etc/init.d/fastzigbee_4
	$(INSTALL_BIN) ./files/fastzigbee_cfg_1.json $(1)/app/config
	$(INSTALL_BIN) ./files/fastzigbee_cfg_2.json $(1)/app/config
	$(INSTALL_BIN) ./files/fastzigbee_cfg_3.json $(1)/app/config
	$(INSTALL_BIN) ./files/fastzigbee_cfg_4.json $(1)/app/config
endef

$(eval $(call BuildPackage,$(PKG_NAME)))

