#
# 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:=openopc
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/openopc/Default
  SECTION:=DYIOT
  CATEGORY:=DYIOT Software
endef

define Package/openopc
$(call Package/openopc/Default)
  TITLE:=OPC DA client based upon OpenOPC
  DEPENDS:=python-openopc paho-mqtt-py
endef

define Package/openopc3
$(call Package/openopc/Default)
  TITLE:=OPC DA client based upon OpenOPC3
  DEPENDS:=+python-openopc3 +paho-mqtt-py3
endef

define Build/Configure
endef

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

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

$(eval $(call BuildPackage,openopc))
$(eval $(call BuildPackage,openopc3))
