Receipt for: openssl10-dev

# SliTaz package receipt.

PACKAGE="openssl10-dev"
VERSION="1.0.2u"
CATEGORY="development"
SHORT_DESC="Open source Secure Sockets Layer devel files."
MAINTAINER="pascal.bellard@slitaz.org"
LICENSE="BSD"
WEB_SITE="https://www.openssl.org/"
HOST_ARCH="i486 arm x86_64"

WANTED="openssl10"
DEPENDS="libcrypto10-dev libssl10 pkg-config"

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	# OpenSSL 1.0 dev files live in an ISOLATED tree so they never clobber the
	# system OpenSSL 3 headers/libs/pkgconfig. Consumers opt in with
	#   PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig
	# which yields  -I/usr/include/openssl-1.0 -L/usr/lib/openssl-1.0 -lssl -lcrypto,
	# the local .so dev symlinks resolving to the 1.0 sonames in /usr/lib (shipped
	# by libssl10/libcrypto10). Nothing generic is touched -> 3.x stays default.
	# Crypto side (libcrypto.a, libcrypto.pc, libcrypto.so) ships in libcrypto10-dev,
	# into this same isolated tree.
	mkdir -p $fs/usr/lib/openssl-1.0 $fs/usr/include/openssl-1.0

	# Headers -> /usr/include/openssl-1.0/openssl/
	cp -a $install/usr/include/openssl $fs/usr/include/openssl-1.0

	# libssl: static lib + dev symlink to the versioned soname in /usr/lib
	cp -a $install/usr/lib/openssl-1.0/*.a $fs/usr/lib/openssl-1.0
	ln -s ../libssl.so.1.0.0 $fs/usr/lib/openssl-1.0/libssl.so.1.0.0
	# plain dev name so a bare -lssl links the 1.0 shared lib
	ln -s ../libssl.so.1.0.0 $fs/usr/lib/openssl-1.0/libssl.so

	# pkg-config openssl.pc + libssl.pc, repathed to the isolated tree.
	# Link the exact 1.0 sonames (-l:libssl.so.1.0.0) instead of -lssl: the
	# bare -lssl resolves via the dev symlink, but openssl10-dev and
	# libcrypto10-dev share /usr/lib/openssl-1.0/ and the tazpkg-remove bug
	# sweeps each other's symlinks -> ld then falls through to the generic
	# /usr/lib/libssl.so (OpenSSL 3) and consumers get undefined 1.0 symbols
	# (SSLv23_client_method...). -l:soname is immune (resolves in /usr/lib).
	for pc in openssl libssl; do
		sed -e 's|^libdir=.*|libdir=/usr/lib/openssl-1.0|' \
		    -e 's|^includedir=.*|includedir=/usr/include/openssl-1.0|' \
		    -e 's|-lssl|-l:libssl.so.1.0.0|g' \
		    -e 's|-lcrypto|-l:libcrypto.so.1.0.0|g' \
		    $install/usr/lib/pkgconfig/$pc.pc \
		    > $fs/usr/lib/openssl-1.0/pkgconfig/$pc.pc
	done

	cp -a $install/usr/lib/openssl-1.0/pkgconfig $fs/usr/lib/openssl-1.0
	# libcrypto* have moved to a specific package
	rm -f $fs/usr/lib/openssl-1.0/libcrypto*
	rm -f $fs/usr/lib/openssl-1.0/pkgconfig/libcrypto*
}