# Template file for 'libressl'
pkgname=libressl
version=2.1.3
revision=1
bootstrap=yes
build_style=gnu-configure
configure_args="--enable-libtls"
short_desc="Version of the TLS/crypto stack forked from OpenSSL"
maintainer="Juan RP <xtraeme@gmail.com>"
license="OpenSSL-License, SSLeay-License, ISC"
homepage="http://www.libressl.org/"
distfiles="http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/${pkgname}-${version}.tar.gz"
checksum=eb2f370971408fb10af6453e556465c8eee728ac333bf1eb47ec1a5112304f7c

# Compat pkg that depends on the real pkgs.
depends="libcrypto30-${version}_${revision} libssl30-${version}_${revision} libtls1-${version}_${revision}"

post_build() {
	$CC -Wall $CFLAGS -DHAVE_STRNDUP -Iinclude -Lcrypto/.libs \
		$LDFLAGS ${FILESDIR}/c_rehash.c -o ${wrksrc}/c_rehash -lcrypto
}
post_install() {
	vlicense COPYING
	find ${DESTDIR}/usr/share/man/man1 -type f ! -name openssl.1 -delete
}

libcrypto30_package() {
	short_desc+=" - crypto library"
	replaces="libressl<2.1.2_3"
	pkg_install() {
		vmove usr/lib/libcrypto.so.*
	}
}
libssl30_package() {
	short_desc+=" - SSL/TLS library"
	replaces="libressl<2.1.2_3"
	pkg_install() {
		vmove usr/lib/libssl.so.*
	}
}
libtls1_package() {
	short_desc+=" - new TLS library"
	replaces="libressl<2.1.2_3"
	pkg_install() {
		vmove usr/lib/libtls.so.*
	}
}
libressl-devel_package() {
	short_desc+=" - development files"
	depends="libcrypto30-${version}_${revision} libssl30-${version}_${revision} libtls1-${version}_${revision}"
	conflicts="openssl-devel>=0"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/*.a
		vmove usr/lib/*.so
		vmove usr/lib/pkgconfig
		vmove usr/share/man/man3
	}
}
libressl-openssl_package() {
	short_desc+=" - utilities"
	provides="openssl-${version}_${revision}"
	replaces="openssl>=0"
	conf_files="/etc/ssl/openssl.cnf"
	pkg_install() {
		vinstall ${FILESDIR}/openssl.cnf 644 etc/ssl
		vmove usr/bin
		vmove usr/share/man/man1
		vbin ${wrksrc}/c_rehash
	}
}
