#!/bin/sh

set -x 
set -e

# NOTICE: This file is parsed by cmake to create a shell script. Not all syntax
# will play well with cmake. CMAKE replaces @FOO@ and ${FOO} with cmake variable
# values.
if [ -z $MAKEOPTS ]; then
    export MAKEOPTS="-j`nproc`"
fi

echo "Building pymoose and creating bdist."
export GSL_ROOT_DIR=@GSL_ROOT_DIR@
export HDF5_ROOT=@HDF5_ROOT@
cd @PYMOOSE_BUILD_DIR@
cmake -DCMAKE_INSTALL_PREFIX=@PYMOOSE_INSTALL_DIR@ \
    -DCMAKE_BUILD_TYPE=Release \
    -DWITH_BOOST=@WITH_BOOST@ \
    -DPYTHON_EXECUTABLE=@PYTHON_EXECUTABLE@ \
    -DVERSION_MOOSE=@VERSION_MOOSE@ \
    @CMAKE_PYMOOSE_ARGS@ \
    @PYMOOSE_SOURCE_DIR@ 
make $MAKEOPTS
ctest --output-on-failure 
make bdist

