#
# Copyright (C) 2015-2016 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:=paho-mqtt-py
VERSION_MAJOR:=1.5
VERSION_REVISION:=1
PKG_VERSION:=$(VERSION_MAJOR).$(VERSION_REVISION)

PKG_SOURCE:=v1.5.1.tar.gz
PKG_SOURCE_URL:=https://github.com/eclipse/paho.mqtt.python/archive/refs/tags/
PKG_MD5SUM:=360cb82bf4164fcd145adfce5aec13fa
PKG_BUILD_DIR:=$(BUILD_DIR)/paho.mqtt.python-$(PKG_VERSION)


PKG_BUILD_DEPENDS:=python python-setuptools

PKG_LICENSE:=BSD-3-Clause
PKG_LICENSE_FILES:=LICENSE.rst
PKG_MAINTAINER:=Jeffery To <jeffery.to@gmail.com>

include $(INCLUDE_DIR)/package.mk
$(call include_mk,python-package.mk)
$(call include_mk,python3-package.mk)

PY3_VERSION :=$(PYTHON3_VERSION)
ifeq ($(PY3_VERSION),)
PY3_VERSION :=3
endif

define Package/paho-mqtt-py/Default
	SECTION:=lang
	CATEGORY:=Languages
	SUBMENU:=Python
	TITLE:=paho.mqtt.python
	URL:=https://github.com/kjd/crcmod
endef

define Package/paho-mqtt-py
$(call Package/paho-mqtt-py/Default)
	DEPENDS:=+python +python-light
endef

define Package/paho-mqtt-py3
$(call Package/paho-mqtt-py/Default)
	DEPENDS:=+python3
endef

define Package/paho-mqtt-py/description
paho mqtt python
endef

define Package/paho-mqtt-py3/description
paho mqtt python3
endef

define Build/Compile
	$(call Build/Compile/PyMod,,install --prefix=/usr --root=$(PKG_INSTALL_DIR))
endef

define Package/paho-mqtt-py/install
	$(INSTALL_DIR) $(1)/usr/lib/python2.7/site-packages
	$(CP) $(PKG_BUILD_DIR)/src/paho $(1)/usr/lib/python2.7/site-packages/
endef

define Package/paho-mqtt-py3/install
	$(INSTALL_DIR) $(1)/usr/lib/python$(PY3_VERSION)/site-packages
	$(CP) $(PKG_BUILD_DIR)/src/paho $(1)/usr/lib/python$(PY3_VERSION)/site-packages/
endef

$(eval $(call PyPackage,python-openopc))
$(eval $(call BuildPackage,paho-mqtt-py))

$(eval $(call Py3Package,python3-openopc))
$(eval $(call BuildPackage,paho-mqtt-py3))
