#!/bin/sh
# Was /bin/ksh

if [ -r src/$1.cc ]; then
    dir=src
else
    if [ -r daquser/src/$1.cc ]; then
	dir=daquser/src
    else
	dir=records/src
    fi
fi

echo "Building bin/$1 from $dir/$1.cc"

. records/bin/setRecordsInc
. daquser/bin/setDaquserInc

g++ -Wall \
    -D CALICE_DAQ_ICC \
    -D CALICE_DAQ_TIME=`date +%s`\
    \
    -I- \
    -I inc \
    -I src \
    $CALICE_DAQUSER_INC \
    $CALICE_RECORDS_INC \
    \
    `$ROOTSYS/bin/root-config --new --cflags --glibs` \
    \
    -o bin/$1 $dir/$1.cc
