define Package/ieee1905-map-plugin
  $(call Package/ieee1905/Default)
  TITLE:=Multi-AP plugin supporting WiFi-Alliance Easymesh standard
  DEPENDS= +libubox +libuci +libubus +libeasy +libnl-genl \
	   +libjson-c +libblobmsg-json +ieee1905 +libieee1905
endef

define Package/ieee1905-map-plugin/config
	if (PACKAGE_ieee1905-map-plugin)

		menu "Configuration"

		config MULTIAP_EASYMESH_VERSION
		int "Easymesh version"
		default 6

		config MULTIAP_DYNAMIC_CNTLR_SYNC_CONFIG
		bool "Sync configuration between dynamic controllers in the network"
		default y

		config MULTIAP_FUZZ_1905_CMDUS
		bool "Include support to fuzz 1905 CMDUs for testing purpose"
		default n

		endmenu
	endif
endef

TARGET_CFLAGS += -DEASYMESH_VERSION=$(CONFIG_MULTIAP_EASYMESH_VERSION)

ifeq ($(CONFIG_MULTIAP_DYNAMIC_CNTLR_SYNC_CONFIG),y)
TARGET_CFLAGS += -DDYNAMIC_CNTLR_SYNC_CONFIG
endif

define Build/InstallDev/ieee1905-map-plugin
	$(INSTALL_DIR) $(1)/usr/lib
	$(INSTALL_DIR) $(1)/usr/include
	$(INSTALL_DIR) $(1)/usr/lib/ieee1905
	$(CP) $(PKG_BUILD_DIR)/src/extensions/map/easymesh.h $(1)/usr/include/easymesh.h
	$(CP) $(PKG_BUILD_DIR)/src/extensions/map/map_module.h $(1)/usr/include/map_module.h
	$(CP) $(PKG_BUILD_DIR)/src/extensions/map/cntlrsync.h $(1)/usr/include/cntlrsync.h
	$(CP) $(PKG_BUILD_DIR)/src/extensions/map/map.so $(1)/usr/lib/ieee1905/map.so
	$(CP) $(PKG_BUILD_DIR)/src/extensions/map/libmaputil.so $(1)/usr/lib/libmaputil.so
endef

define Package/ieee1905-map-plugin/install
	$(INSTALL_DIR) $(1)/usr/lib
	$(INSTALL_DIR) $(1)/usr/lib/ieee1905
	$(CP) $(PKG_BUILD_DIR)/src/extensions/map/libmaputil.so $(1)/usr/lib/libmaputil.so
	$(CP) $(PKG_BUILD_DIR)/src/extensions/map/map.so $(1)/usr/lib/ieee1905/map.so
endef
