#
# Copyright (C) 2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=mqtt_forward
PKG_RELEASE:=1
VERSION_YEAR=$(shell date +%Y)
VERSION_MAJOR=$(shell expr $(VERSION_YEAR) - 2018)
VERSION_MINOR=$(shell date +%V%u)
VERSION_REVISION=0000
PKG_VERSION:=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION)

# PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

define Package/mqtt_forward/Default
  SECTION:=DYIOT
  CATEGORY:=DYIOT Software
endef

define Package/mqtt_forward
$(call Package/mqtt_forward/Default)
  TITLE:=cloud MQTT forward to data/property (python2)
  DEPENDS:=+paho-mqtt-py
endef

define Package/mqtt_forward3
$(call Package/mqtt_forward/Default)
  TITLE:=cloud MQTT forward to data/property (python3)
  DEPENDS:=+paho-mqtt-py3
endef

define Build/Configure
endef

define Build/Compile
	@echo "Nothing to do to compile mqtt_forward" ; exit 0
endef

define Package/mqtt_forward/install
	$(INSTALL_DIR) $(1)/app $(1)/etc/init.d
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/mqtt_forward.py $(1)/app/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/mqtt_forward.init $(1)/etc/init.d/mqtt_forward
endef
define Package/mqtt_forward3/install
	$(call Package/mqtt_forward/install,$(1))
endef

$(eval $(call BuildPackage,mqtt_forward))
$(eval $(call BuildPackage,mqtt_forward3))
