#!/bin/sh
# ----------------------------------------------------------------------------
# Generic script for building Trilinos and Sundance on Linux machines with 
# configurations similar to gibbon.math.ttu.edu
#
# Run this script as 
# <kevin@gibbon> ./gibbon-linux-sundance-base [flags]
# where the possible flags are listed by running
# <kevin@gibbon> ./gibbon-linux-sundance-base --help
#
# This isn't meant as a completely general configuration script; rather, it
# allows streamlined setting of the several options I most commonly vary in
# my own work. You'll probably want to tweak this script for your own system
# and your own selection of packages. In particular, I've assumed we're 
# always building Sundance and that the directory layout is identical to 
# that on my development machines gibbon and chimera. 
#
# 22 March 2009
# Kevin Long (kevin.long@ttu.edu)
#
#-----------------------------------------------------------------------------

# Decide whether to build the Meros block preconditioning package.
# Default is no. 
#
ENABLE_MEROS=OFF



# ----------------------------------------------------------------------------
# Set the location of the compilers and libraries. On a simple out-of-the-box
# Linux system, COMPILER_ROOT will probably be someplace like /usr/local. 
# On Kevin's TTU machines, there are multiple compiler versions located
# in directories /usr/local/${COMPILER_VERSION}, e.g., /usr/local/gcc-4.3.2.
# If your system isn't organized this way, you can copy this script
# and modify as per your system.
#

COMPILER_ROOT=/usr/local
BIN_PATH=${COMPILER_ROOT}/bin
LIB_PATH=${COMPILER_ROOT}/lib
INC_PATH=${COMPILER_ROOT}/include

# ----------------------------------------------------------------------------
# Set the fortran library name. On older Linux systems this will 
# need to be changed to -lg2c. 
#
FORTRAN_LIBS="-lgfortran"


# ----------------------------------------------------------------------------
# Set variables that control the type of build
#
# Whether to build shared libraries. Default=no.
BUILD_SHARED=OFF
# Whether to build with MPI. Default=yes.
ENABLE_MPI=OFF
# Whether to build optimized or debug. Default=debug. Set to RELEASE or leave
# blank to enable an optimized build.
BUILD_TYPE=RELEASE
# Whether to enable a paranoid level of compiler warnings. This can cause
# problems with Python. Default: on. 
PARANOID_COMPILER=OFF

# ----------------------------------------------------------------------------
# Set variables controlling which third-party libraries are available and
# should be linked in. 
#
# Whether the exodus mesh database libraries are available. Default=yes.
HAVE_EXODUS=ON

# ----------------------------------------------------------------------------
# Specify directories for the Trilinos source and Trilnos data, and for
# the installation of this build.

# Set the installation path
INSTALL_PREFIX=$PWD

# Set the path to the Trilinos source distribution
TRILINOS_SRC_DIR=${HOME}/Code/Trilinos

# Set the path to the Trilinos data files. Some of the Sundance tests require
# large mesh files stored in TrilinosData. If the TrilinosData directory
# cannot be found, these tests will be disabled.
TRILINOS_DATA_DIR=${HOME}/Code/TrilinosData


PYTHON_INC_PATH=${INC_PATH}/python2.6
PYTHON_INC_STRING="-I${PYTHON_INC_PATH}"

# ---------------------------------------------------------------------------
#
# Now run cmake!!
#
# ---------------------------------------------------------------------------

cmake \
-D CMAKE_BUILD_TYPE:STRING=${BUILD_TYPE} \
-D CMAKE_SYSTEM_LIBRARY_PATH:FILEPATH="$LIB_PATH" \
-D CMAKE_SYSTEM_INCLUDE_PATH:FILEPATH="$INC_PATH" \
 -D CMAKE_CXX_FLAGS:STRING="${PYTHON_INC_STRING} ${OPT_STRING} ${EXTRA_CXX_FLAGS}" \
-D CMAKE_C_FLAGS:STRING="${PYTHON_INC_STRING} ${EXTRA_C_FLAGS}" \
-D BUILD_SHARED_LIBS:BOOL=${BUILD_SHARED} \
-D TPL_ENABLE_ExodusII:BOOL=${HAVE_EXODUS} \
-D TPL_ENABLE_MPI:BOOL=${ENABLE_MPI} \
-D Trilinos_EXTRA_LINK_FLAGS:STRING=${FORTRAN_LIBS} \
-D Trilinos_ENABLE_SHADOW_WARNINGS:BOOL=OFF \
-D Trilinos_ENABLE_STRONG_CXX_COMPILE_WARNINGS:BOOL=${PARANOID_COMPILER} \
-D Trilinos_ENABLE_TESTS:BOOL=ON \
-D Trilinos_ENABLE_Sundance:BOOL=ON \
-D Trilinos_ENABLE_Meros:BOOL=${ENABLE_MEROS} \
-D Sundance_ENABLE_BROKEN_CODE:BOOL=OFF \
-D Sundance_ENABLE_Python:BOOL=OFF \
-D Trilinos_ENABLE_Stokhos:BOOL=ON \
-D Trilinos_ENABLE_Sacado:BOOL=ON \
-D Trilinos_DATA_DIR:FILEPATH="${TRILINOS_DATA_DIR}" \
-D NOX_ENABLE_LOCA:BOOL=OFF \
-D CMAKE_INSTALL_PREFIX:PATH=${INSTALL_PREFIX} \
${TRILINOS_SRC_DIR}

exit 0
