#
# Copyright (C) 2021-2023 IOPSYS
#

include $(TOPDIR)/rules.mk

PKG_NAME:=capiagent
PKG_VERSION:=2.1.1

LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=136cab3a9f1eec0132db9fa3f7bb1c8748ce1449
PKG_SOURCE_URL:=https://dev.iopsys.eu/multi-ap/capiagent.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
PKG_LICENSE:=PROPRIETARY IOPSYS
PKG_LICENSE_FILES:=LICENSE

include $(INCLUDE_DIR)/package.mk


#define Package/capiagent/config
#  source "$(SOURCE)/Config.in"
#endef

define Package/capiagent
  TITLE+= capiagent (daemon implementing Wi-Fi Alliance's CAPI commands)
  DEPENDS= +libubox +libuci +libubus +libnl-genl +libeasy +libwifi \
	   +libjson-c +libblobmsg-json +ubus +libieee1905 +libwifiutils
endef

define Package/capiagent/description
 This package provides agent for the WiFi Alliance's CAPI specification.
endef

TARGET_CFLAGS += \
	-I$(STAGING_DIR)/usr/include \
	-I$(STAGING_DIR)/usr/include/libnl3 \
	-D_GNU_SOURCE

MAKE_PATH:=src


define Package/capiagent/install
	$(CP) ./files/* $(1)/
	$(INSTALL_DIR) $(1)/usr/sbin
	$(INSTALL_DIR) $(1)/lib/wifi/capi
	$(CP) $(PKG_BUILD_DIR)/src/capiagent $(1)/usr/sbin
	$(CP) $(PKG_BUILD_DIR)/src/scripts/* $(1)/lib/wifi/capi
endef

$(eval $(call BuildPackage,capiagent))
