include $(TOPDIR)/rules.mk

PKG_NAME:=nng
PKG_VERSION:=1.11
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/nanomsg/nng.git
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
PKG_MIRROR_HASH:=skip

PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE.txt

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

define Package/nng
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE:=NNG - nanomsg-next-gen
  URL:=https://github.com/nanomsg/nng
  DEPENDS:=+libpthread +libatomic
endef

define Package/nng/description
  NNG is a lightweight messaging library, a successor to nanomsg.
endef

CMAKE_OPTIONS += \
	-DBUILD_SHARED_LIBS=ON \
	-DNNG_ENABLE_EXAMPLES=OFF \
	-DNNG_ENABLE_TESTS=OFF

define Package/nng/install
	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnng.so* $(1)/usr/lib/
endef

$(eval $(call BuildPackage,nng))
