# SliTaz package receipt.

PACKED_SIZE="332.0K"
UNPACKED_SIZE="972.0K"
PACKAGE="libgcrypt"
VERSION="1.9.4"
CATEGORY="security"
SHORT_DESC="Cryptographic library based on GnuPG."
MAINTAINER="erjo@slitaz.org"
LICENSE="GPL2 LGPL2.1"
WEB_SITE="https://www.gnupg.org/related_software/libgcrypt/"

TARBALL="$PACKAGE-$VERSION.tar.bz2"
WGET_URL="https://www.gnupg.org/ftp/gcrypt/libgcrypt/$TARBALL"

DEPENDS="libgpg-error"
BUILD_DEPENDS="libgpg-error-dev"

HOST_ARCH="i486 arm"

current_version()
{
	wget -O - $(dirname $WGET_URL) 2>/dev/null | \
	sed "/$PACKAGE-[0-9]/!d;/tar/!d;s|.*$PACKAGE-\\(.*\\).tar.*\".*|\\1|" | sort -Vr | sed q
}

# Rules to configure and make the package.
compile_rules()
{
	# Integrity check: https://www.gnupg.org/download/integrity_check.html
	echo "1bccc8393482fa1953323ff429c6b5ba5676eb1a  $SRC/$TARBALL" | sha1sum -c || exit 1

	case "$ARCH" in
		(arm)
			#LIBS="-L/cross/arm/sysroot/usr/lib -lgpg-error"
			./configure \
				--build=i486-slitaz-linux \
				--host=arm-slitaz-linux-gnueabi ;;
		(*)
			export LDFLAGS="$LDFLAGS -Wl,--copy-dt-needed-entries -lgpg-error"
			./configure			\
				--build=$HOST_SYSTEM	\
				--host=$HOST_SYSTEM
			;;
	esac &&
	make &&
	make install

	find $install/usr/share/man -type f -exec gzip -9 \{\} \;
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr/bin
	mkdir -p $fs/usr/lib

	cp -a $install/usr/bin/dumpsexp	$fs/usr/bin
	cp -a $install/usr/bin/hmac256	$fs/usr/bin
	cp -a $install/usr/lib/*.so*	$fs/usr/lib
}
