# Template file for 'mod_wsgi'
pkgname=mod_wsgi
version=4.9.4
revision=4
build_style=gnu-configure
configure_args="--with-python=python3"
hostmakedepends="python3 perl automake libtool"
makedepends="apache-devel python3-devel apr-devel"
short_desc="Python WSGI adapter module for Apache"
maintainer="Orphaned <orphan@voidlinux.org>"
license="Apache-2.0"
homepage="https://modwsgi.readthedocs.io/en/develop/"
changelog="https://modwsgi.readthedocs.io/en/latest/release-notes/version-${version}.html"
distfiles="https://github.com/GrahamDumpleton/mod_wsgi/archive/${version}.tar.gz"
checksum=ee926a3fd5675890b908ebc23db1f8f7f03dc3459241abdcf35d46c68e1be29b
lib32disabled=yes

pre_configure() {
	if [ "$CROSS_BUILD" ]; then
		cp -a ${XBPS_CROSS_BASE}/usr/bin/apxs ${wrksrc}
		cp -a "$("${XBPS_CROSS_BASE}/usr/bin/apr-1-config" --apr-libtool)" \
			./libtool

		# Use the modified apxs
		configure_args+=" --with-apxs=${wrksrc}/apxs"
		configure_args+=" PYTHON_VERSION=$py3_ver PYTHON_LDVERSION=$py3_ver"

		# Modify libtool to use the right compiler and linker
		vsed -i libtool \
			-e "s/^CC=.*/CC='${CC}'/" \
			-e "s/^LD=.*/LD='${LD}'/" \
			-e "s/^LTCC=.*/LTCC='${CC}'/"

		vsed -i apxs \
			-e 's|my \$libtool =.*|my $libtool = "./libtool";|' \
			-e '/my [$]ltflags /s/=.*/= "--tag=CC";/' \
			-e "/my [$]destdir/s%=.*%= \"$XBPS_CROSS_BASE\";%"
	fi
	autoreconf -fi
}
