include $(TOPDIR)/rules.mk

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)

PKG_NAME:=proto_forward

include $(INCLUDE_DIR)/package.mk

define Package/proto_forward
	SECTION:=DYIOT
	CATEGORY:=DYIOT Software
	TITLE:=proto_forward support
	DEPENDS:=+libuci +libdyutils +libipc_session +open62541 +libsqlite3 +lib60870 +liblz4
endef

define Package/proto_forward/description
	proto_forward support
endef

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

define Package/proto_forward/conffiles
/app/config/*
/app/template/*
endef


define Package/proto_forward/install
	$(INSTALL_DIR) $(1)/app/
	$(INSTALL_DIR) $(1)/app/config/
	$(INSTALL_DIR) $(1)/app/cert/
	$(INSTALL_DIR) $(1)/app/template/
	$(INSTALL_DIR) $(1)/etc/
	$(INSTALL_DIR) $(1)/etc/init.d/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/proto_forward $(1)/app/
	$(INSTALL_CONF) ./config/* 		$(1)/app/config/
	$(INSTALL_CONF) ./cert/* 		$(1)/app/cert/
	$(INSTALL_CONF) ./template/* 		$(1)/app/template/
	$(INSTALL_BIN) ./files/emsd.init $(1)/etc/init.d/emsd
	$(INSTALL_BIN) ./src/*.sh $(1)/app/
endef


$(eval $(call BuildPackage,proto_forward))

