#! /bin/csh -f

# 1 = mex script filepath
# 2 = mex include path
# 3 = script path (containing this file)
# 4 = setup script filepath
# 5 = input filepath
# 6 = option
# 7 = output filepath

source $4

if (! -e $5) then
    echo cannot find $5
    exit 1
endif

if ($6 == compile) then
    $1 -output $7 $5
else if ($6 == preprocess) then
    gcc -E -I $2 $5 > $7
endif

if (-e $7) then
    echo CPU compilation successful
    exit 0
else
    echo CPU compilation failed
    exit 1
endif
