#
# Copyright (C) 2020-2024 iopsys
#

include $(TOPDIR)/rules.mk

PKG_NAME:=tr471
PKG_VERSION:=1.0.7

LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/tr471d.git
PKG_SOURCE_VERSION:=589c71e07a5e8044bdd03d3d5b161d9ef1270a6d
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif

PKG_LICENSE:=BSD-3-Clause
PKG_LICENSE_FILES:=LICENSE

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

define Package/tr471
 CATEGORY:=Utilities
 TITLE:=TR-471 Data Model Support
 DEPENDS:=+obudpst +libuci +libubox +libubus +libblobmsg-json
 DEPENDS+=+libbbfdm-api +libbbfdm-ubus +dm-service +netmngr
endef

define Package/tr471/description
	Package to add Device.IP.Diagnostics.IPLayerCapacityMetrics. data model support.
endef

MAKE_PATH:=src

define Package/tr471/install
	$(BBFDM_INSTALL_MS_PLUGIN) $(PKG_BUILD_DIR)/src/libtr471d.so $(1) netmngr 13
	$(BBFDM_INSTALL_SCRIPT) $(PKG_BUILD_DIR)/scripts/iplayercap $(1)
endef

ifeq ($(LOCAL_DEV),1)
define Build/Prepare
	$(CP) ~/git/tr471/* $(PKG_BUILD_DIR)/
endef
endif

$(eval $(call BuildPackage,tr471))
