#!/bin/bash

cd $BLDDIR
rm -rf flex-$FLEX_VER
tar -xf $SRCDIR/flex-2.5.35.tar.bz2
cd flex-$FLEX_VER

patch -Np1 -i $SRCDIR/patches/flex-$FLEX_VER/flex-2.5.35-gcc44.patch

cp -v Makefile.in{,.orig}
sed "s/-I@includedir@//g" Makefile.in.orig > Makefile.in
cat > config.cache << EOF
ac_cv_func_malloc_0_nonnull=yes
ac_cv_func_realloc_0_nonnull=yes
EOF
./configure --prefix=/tools \
    --build=${CHFS_HOST} --host=${CHFS_TARGET} \
    --cache-file=config.cache
make
make install

cd $ROOT
