# Template file for 'libssl1.1'
pkgname=libssl1.1
version=1.1.1w
revision=1
build_style=configure
configure_script="./Configure"
configure_args="--prefix=/usr --openssldir=/etc/ssl --libdir=lib
 shared no-ssl3-method $(vopt_if asm ' ' 'no-asm')
 -Wa,--noexecstack"
make_build_args='MAKEDEPPROG="$(CC)'
make_check_target=test
make_install_target="install_sw"
hostmakedepends="perl"
short_desc="Toolkit for Secure Sockets Layer and Transport Layer Security"
maintainer="classabbyamp <void@placeviolette.net>"
license="OpenSSL"
homepage="https://www.openssl.org"
distfiles="https://www.openssl.org/source/openssl-${version}.tar.gz"
checksum=cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8

short_desc+=" (version 1.1) - SSL/TLS library"

CFLAGS="-D_FILE_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1"

build_options="asm"
build_options_default="asm"

case $XBPS_TARGET_MACHINE in
	x86_64*) configure_args+=" enable-ec_nistp_64_gcc_128 linux-x86_64";;
	i686*) configure_args+=" linux-elf";;
	aarch64*) configure_args+=" linux-aarch64";;
	ppc64le*) configure_args+=" linux-ppc64le";;
	ppc64*) configure_args+=" linux-ppc64";;
	ppcle*) configure_args+=" linux-ppcle";;
	ppc*) configure_args+=" linux-ppc";;
	arm*) configure_args+=" linux-armv4";;
	mips*) configure_args+=" linux-mips32 -mips32";;
	*) broken="$XBPS_TARGET_MACHINE";;
esac

pre_configure() {
	configure_args+=" ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}"
}

pre_check() {
	# developer test, fails due to different nm output
	rm -f test/recipes/01-test_symbol_presence.t
}

post_install() {
	for d in usr/bin usr/include usr/lib/pkgconfig; do
		rm -r "${DESTDIR}/${d}"
	done
	rm "${DESTDIR}"/usr/lib/*.a
	rm "${DESTDIR}"/usr/lib/*.so
}

libcrypto1.1_package() {
	short_desc="${short_desc/SSL\/TLS/crypto}"
	pkg_install() {
		vmove "usr/lib/libcrypto.so.*"
		vmove usr/lib/engines-1.1
	}
}
