#! /bin/bash

cd preprocess
make || exit 1
cd ..

cd search
make STATE_VAR_BYTES=1 || exit 1
make STATE_VAR_BYTES=2 || exit 1
make STATE_VAR_BYTES=4 || exit 1
cd ..

if [ ! -e VAL ]; then
    # Skip building validator if it isn't present.
    exit
fi

type flex >& /dev/null
if [ $? != 0 ]; then
    echo cannot build validator: flex not found
    exit 1
fi

type bison >& /dev/null
if [ $? != 0 ]; then
    echo cannot build validator: bison not found
    exit 1
fi

cd VAL
make validate || exit 1
cp validate ../
cd ..
