# Template file for 'gpgme-python3'
pkgname=gpgme-python3
version=2.0.0
revision=2
build_style=gnu-configure
make_build_args="-C build"
make_install_args="-C build"
hostmakedepends="python3-setuptools swig python3-packaging-bootstrap gnupg"
makedepends="python3-devel libgpg-error-devel gpgme-devel"
short_desc="GnuPG Made Easy - Python bindings"
maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
license="LGPL-2.1-or-later"
homepage="https://www.gnupg.org/software/gpgme/index.html"
changelog="https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gpgmepy.git;a=blob_plain;f=ChangeLog;hb=HEAD"
distfiles="https://www.gnupg.org/ftp/gcrypt/gpgmepy/gpgmepy-${version}.tar.bz2"
checksum=07e1265648ff51da238c9af7a18b3f1dc7b0c66b4f21a72f27c74b396cd3336d
CFLAGS="-I${XBPS_CROSS_BASE}/usr/include/python${py3_ver}"

if [ "$XBPS_TARGET_LIBC" = musl ]; then
	configure_args+=" ac_cv_sys_file_offset_bits=no"
elif [ "$XBPS_TARGET_WORDSIZE" = "32" ]; then
	export SWIG_FEATURES="-D_FILE_OFFSET_BITS=64"
	CFLAGS+=" -D_FILE_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1"
fi

post_patch() {
	if [ "$CROSS_BUILD" ]; then
		sed -i "s@'/usr/include'@'$XBPS_CROSS_BASE/usr/include'@" setup.py.in
	fi
}

do_configure() {
	mkdir -p build
	cd build
	../configure ${configure_args}
}
