# Template file for 'mbedtls'
pkgname=mbedtls
version=3.6.2
revision=1
_framework_ver=d9a70c758a5a511020240bbcc86f6d647d64fe96
build_style=cmake
configure_args="-DENABLE_TESTING=1 -DUSE_SHARED_MBEDTLS_LIBRARY=1"
hostmakedepends="python3 perl"
short_desc="Portable cryptographic TLS library"
maintainer="Orphaned <orphan@voidlinux.org>"
license="Apache-2.0"
homepage="https://tls.mbed.org/"
changelog="https://raw.githubusercontent.com/ARMmbed/mbedtls/mbedtls-${version%.*}/ChangeLog"
distfiles="https://github.com/ARMmbed/mbedtls/archive/refs/tags/v${version}.tar.gz
 https://github.com/Mbed-TLS/mbedtls-framework/archive/${_framework_ver}.tar.gz>framework-${_framework_ver}.tar.gz"
checksum="f4a876b1f6921ad0aefb445f974ef62414d33928640b2c45555c5e64a196a1a8
 d46acd6cb103d00d6e545631467e36363f6fc270b2c051be94d543eb0831393b"
skip_extraction="framework-${_framework_ver}.tar.gz"

post_extract() {
	vsrcextract -C framework "framework-${_framework_ver}.tar.gz"
}

pre_configure() {
	./scripts/config.pl set MBEDTLS_THREADING_C
	./scripts/config.pl set MBEDTLS_THREADING_PTHREAD
}

mbedtls-utils_package() {
	short_desc+=" - additional utilities"
	depends="${sourcepkg}-${version}_${revision}"
	pkg_install() {
		vmove usr/bin
		rm "${PKGDESTDIR}"/usr/bin/hello
		rm "${PKGDESTDIR}"/usr/bin/query_compile_time_config
	}
}

mbedtls-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}-${version}_${revision}"
	conflicts="mbedtls2-devel>=0"
	replaces="mbedtls2-devel>=0"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.a"
		vmove "usr/lib/*.so"
		vmove usr/lib/pkgconfig
		vmove usr/lib/cmake
	}
}
