#! /bin/bash

cd preprocess
make "$@" || exit 1
cd ..

cd search
make "$@" || 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 "$@" || exit 1
strip validate
cp validate ../
cd ..
