### this file is sourced not run
PKGVER=2.6.4
PKGBUILD=1

TARBALL=flex-$PKGVER.tar.gz
MD5SUM=2882e3179748cc9f9c23ec593d6adc8d
BUNDLE=fatdog-base-8.2.tar
SRC_URL=http://distro.ibiblio.org/fatdog/source/800/$BUNDLE

SLACKREQ=
SLACKDESC="flex: flex $PKGVER (Fast lexical generator)  
flex:  
flex: The Flex package contains a utility for generating programs that 
flex: recognize patterns in text.  
flex: 
flex: This is the 32-bit version of flex.
flex: 
flex: 
flex: 
flex: 
flex:
"


### override download for LFS sources bundle
# $1-src-dir $2-tarball 
pkg_download() {
	echo downloading $BUNDLE for $TARBALL
	wget -P $1 $SRC_URL
	tar -xf $1/$BUNDLE --strip-components=1 -C $1 
	rm $1/$BUNDLE
}

### prepare
pkg_prepare() {
	# LFS 8.1 / 8.2 patch for glibc 2.26 onwards
	pkg_prepare_default &&
	cd tmp/flex* &&
	sed -i "/math.h/a #include <malloc.h>" src/flexdef.h
	true
}

### default pkg_package
### build
pkg_build() {
	cd /tmp/flex*

	CC="gcc ${BUILD64}" ./configure --prefix=/usr \
		--libdir=/usr/lib64 --docdir=/usr/share/doc/flex-$PKGVER &&
	make $MAKEFLAGS && make install &&
	pkg_build_slackdesc &&
	ln -sv flex /usr/bin/lex
	
#
#	# Note: LFS 8.1 replaces this script with a simple symlink. We keep the old way
#	# create wrapper
#	cat << "EOF" > /usr/bin/lex &&
##!/bin/sh
## Begin /usr/bin/lex
#
#exec /usr/bin/flex -l "$@"
#
## End /usr/bin/lex
#EOF
#	chmod -v 755 /usr/bin/lex
}
