include $(TOPDIR)/rules.mk

PKG_NAME:=cloud_conn_dayun
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)

ifneq ($(CONFIG_SUPPORT_LED),)
  PKG_MFLAGS+= SUPPORT_LED=1
endif

include $(INCLUDE_DIR)/package.mk

define Package/cloud_conn_dayun
	SECTION:=DYIOT
	CATEGORY:=DYIOT Software
	TITLE:=reporter for DaYun IOT platform
	DEPENDS:=+libuci +libdyutils +libubox +libipc_session
endef

define Package/cloud_conn_dayun/description
	Connect to dayun platform
endef

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

define Build/Compile
	CC="$(TARGET_CC)" \
	CFLAGS="$(TARGET_CFLAGS)" \
	LDFLAGS="$(TARGET_LDFLAGS)" \
	$(MAKE) $(PKG_MFLAGS) -C $(PKG_BUILD_DIR) \
		$(TARGET_CONFIGURE_OPTS) \
		all
endef

define Package/cloud_conn_dayun/install
	$(INSTALL_DIR) $(1)/app/
	$(INSTALL_DIR) $(1)/etc/
	$(INSTALL_DIR) $(1)/etc/init.d/
	$(INSTALL_DIR) $(1)/app/config/mqtt_tls/config_mqtt/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/cloud_conn_dayun $(1)/app/
	$(INSTALL_BIN) ./files/cloud_conn_dayun $(1)/etc/init.d/
endef


$(eval $(call BuildPackage,cloud_conn_dayun))

