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

include $(TOPDIR)/rules.mk

PKG_NAME:=netmode
PKG_VERSION:=1.1.9
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=GPL-2.0-only
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/iopsys/bbfdm/bbfdm.mk

define Package/netmode
  CATEGORY:=Utilities
  TITLE:=Network Modes and Utils
  DEPENDS:=+dm-service
endef

define Package/netmode/description
	Network Modes and Utils
endef

define Package/$(PKG_NAME)/config
	config NETMODE_VENDOR_PREFIX
		depends on PACKAGE_netmode
		string "Vendor Extension used for netmode datamodel"
		default ""
endef

ifeq ($(CONFIG_NETMODE_VENDOR_PREFIX),"")
VENDOR_PREFIX = $(CONFIG_BBF_VENDOR_PREFIX)
else
VENDOR_PREFIX = $(CONFIG_NETMODE_VENDOR_PREFIX)
endif

define Build/Compile
endef

define Package/netmode/install
	$(INSTALL_DIR) $(1)/etc
	$(INSTALL_DIR) $(1)/lib
	$(CP) ./files/etc/* $(1)/etc/
	$(CP) ./files/lib/* $(1)/lib/
	$(BBFDM_REGISTER_SERVICES) -v ${VENDOR_PREFIX} ./bbfdm_service.json $(1) $(PKG_NAME)
	$(BBFDM_INSTALL_MS_DM) -v ${VENDOR_PREFIX} ./files/datamodel.json $(1) $(PKG_NAME)
endef

$(eval $(call BuildPackage,netmode))
