include $(TOPDIR)/rules.mk

PKG_NAME:=Ra06
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:=Ai-Thinker-Ra06
	DEPENDS:=+libuci +libdyutils +libubox +uart_tool +libipc_session
endef

define Package/$(PKG_NAME)/description
	Ai-Thinker-Ra06
endef

define Package/$(PKG_NAME)/conffiles
	/app/config/ra06.json
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)/ra06 $(1)/app/
	$(INSTALL_BIN) ./files/ra06_1.initd $(1)/etc/init.d/ra06_1
	$(INSTALL_BIN) ./files/ra06_2.initd $(1)/etc/init.d/ra06_2
	$(INSTALL_BIN) ./files/ra06_3.initd $(1)/etc/init.d/ra06_3
	$(INSTALL_BIN) ./files/ra06_4.initd $(1)/etc/init.d/ra06_4
	$(INSTALL_BIN) ./files/lora_cfg_1.json $(1)/app/config
	$(INSTALL_BIN) ./files/lora_cfg_2.json $(1)/app/config
	$(INSTALL_BIN) ./files/lora_cfg_3.json $(1)/app/config
	$(INSTALL_BIN) ./files/lora_cfg_4.json $(1)/app/config

endef

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

