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

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

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


### 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
}

### package - only collect the libraries
pkg_package() {
	rm -rf bin sbin usr/bin usr/sbin usr/include usr/share
}

### build
pkg_build() {
	cd /tmp/flex*
	
	CC="gcc ${BUILD32}" ./configure --prefix=/usr \
		--docdir=/usr/share/doc/flex-$PKGVER &&
	make $MAKEFLAGS && make install &&
	pkg_build_slackdesc
}
