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

include $(TOPDIR)/rules.mk

PKG_NAME:=openssl-fips-ext
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

define Package/openssl-fips-ext
	CATEGORY:=MTK Properties
	SECTION:=MTK Properties
	SUBMENU:=Applications
	TITLE:=openssl-fips-ext -- simple tool for gcm and ccm based on openssl api
	DEPENDS:= libopenssl
endef

define Package/openssl-fips-ext/description
	Simple tool for gcm and ccm
endef

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	mkdir -p $(PKG_BUILD_DIR)/src
	$(CP) ./src/* $(PKG_BUILD_DIR)/src
endef

define Build/Compile
	make -C ./src \
		CC="$(TARGET_CC)" \
		OPENSSL_INCS_LOCATION=-I$(STAGING_DIR)/usr/include/openssl \
		OPENSSL_LIBS_LOCATION=-L$(STAGING_DIR)/usr/lib
endef

define Package/openssl-fips-ext/install
	$(INSTALL_DIR) $(1)/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/openssl-fips-ext $(1)/bin/
endef

$(eval $(call BuildPackage,openssl-fips-ext))

