#!/bin/sh

cd /Volumes/case/work/new/libxo/build

targ=$1 ; shift

if [ "$targ" = full ]; then
    targ="clean all"
fi

if [ "$targ" = test ]; then
    dir=$1
    if [ ! -z "$dir" ]; then
        if [ ! -d $dir ]; then
            dir="tests/$dir"
        fi
        dir="-C $dir"
    fi
    targ=
    test=test
fi

make CFLAGS='-g -O0 -DXO_XPARSE_DEBUG -DLIBXO_DEBUG -DSLAX_DEBUG' $targ \
  && make install

if [ $? -eq 0 ]; then
    if [ ! -z "$test" ]; then
        make test $dir
    fi
fi

if [ $? -ne 0 ]; then
    echo "make has failed: $?"
fi

exit $?
