# SliTaz package receipt.

PACKED_SIZE="124.0K"
UNPACKED_SIZE="540.0K"
PACKAGE="flex"
VERSION="2.6.4"
CATEGORY="development"
SHORT_DESC="Flex is a fast lexical analyser generator."
MAINTAINER="pankso@slitaz.org"
LICENSE="BSD"
WEB_SITE="https://github.com/westes/flex"

TARBALL="$PACKAGE-$VERSION.tar.gz"
WGET_URL="https://github.com/westes/$PACKAGE/releases/download/v$VERSION/$TARBALL"

DEPENDS="bison"
BUILD_DEPENDS="bison"
HOST_ARCH="i486 arm x86_64"

# What is the latest version available today?
current_version()
{
	wget -O - ${WGET_URL%/down*} 2>/dev/null | \
	sed '/tag\//!d;s|.*tag/v*||;s|".*||;q'
}

# Rules to configure and make the package.
compile_rules()
{
	case "$ARCH" in
		arm*)
			export ac_cv_func_malloc_0_nonnull=yes
			export ac_cv_func_realloc_0_nonnull=yes
	esac

	./configure $CONFIGURE_ARGS &&
	make -j 1 &&
	make install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr
	cp -a $install/usr/bin $fs/usr
	ln -s flex $fs/usr/bin/lex
	cp -a $install/usr/lib $fs/usr
	cp -a $install/usr/include $fs/usr

	# locales
	mkdir -p $fs/usr/share/locale
	LOCALES="da de es fr pt_BR ro ro zh_CN zh_TW"
	for locale in $LOCALES
		do
		cp -a $install/usr/share/locale/$locale $fs/usr/share/locale 
		done

	# Ensure remove *.la files
	find $fs -name "*.la" -delete
}
