# Template file for 'mbedtls'
pkgname=mbedtls
version=1.3.11
revision=1
replaces="polarssl>=0 libpolarssl>=0"
short_desc="Portable cryptographic TLS library"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="GPL-2"
homepage="https://tls.mbed.org/"
distfiles="https://tls.mbed.org/download/mbedtls-${version}-gpl.tgz"
checksum=67a593027b6a442a4fa5b6c224c4ac8cdae5be721f5a28a11d34f10dcda441cb

do_build() {
	sed -i -e 's|//\(#define POLARSSL_THREADING_C\)|\1|' \
		-e 's|//\(#define POLARSSL_THREADING_PTHREAD\)|\1|' \
		include/polarssl/config.h
	make CC=$CC SHARED=1 ${makejobs} no_test
}
do_install() {
	make DESTDIR=${DESTDIR}/usr install
	rm ${DESTDIR}/usr/lib/libmbedtls.so
	rm ${DESTDIR}/usr/lib/libpolarssl.so
	ln -s libmbedtls.so.8 ${DESTDIR}/usr/lib/libmedtls.so
	ln -s libmbedtls.so.8 ${DESTDIR}/usr/lib/libpolarssl.so
}

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