## ---------------------------------------------------------------------
##
## Copyright (C) 2014 - 2018 by the deal.II authors
##
## This file is part of the deal.II library. It is a modified version
## of the file FEniCS terminal from the FEniCS project.
##
## This library is free software; you can redistribute it and/or
## modify it under the terms of the GNU Lesser General Public
## License as published by the Free Software Foundation; either
## version 2.1 of the License, or (at your option) any later version.
##
## ---------------------------------------------------------------------

# Make sure DEAL_II_BUNDLE is set correctly
if [ -z "$DEAL_II_BUNDLE" ]; then
    export DEAL_II_BUNDLE=/Applications/@DEAL_II_CPACK_BUNDLE_NAME@.app
    if [ ! -d $DEAL_II_BUNDLE ]; then
    cat << EOF
*** Warning: I did not find the deal.II installation in $DEAL_II_BUNDLE.
    Could not set the environment to work with deal.II. Either reinstall
    or set the environment variable DEAL_II_BUNDLE to the correct value.
    Things may not work as you expect if you continue.
EOF
    fi
fi

# Check if DEAL_II_RESOURCES is set, otherwise set it to the default
if [ -z "$DEAL_II_RESOURCES" ]; then
    export DEAL_II_RESOURCES=$DEAL_II_BUNDLE/Contents/Resources
fi

# Start with default compilers libraries
export PATH=$DEAL_II_RESOURCES/bin:$PATH
export DEAL_II_DIR=$DEAL_II_RESOURCES


if [ -z "$DEAL_II_CONF_SILENT" ]; then
    # Clear screen
    clear

    # Set prompt
    # export PS1="\[\033[01;32m\]\u@\h:\[\033[01;34m\]\W\$ \[\033[00m\]"

    # Set terminal title
    # echo -n -e "\033]0;deal.II - an open source finite element library DEAL_II \007"

    cat << EOF
        ______           _  _____ _____
        |  _  \         | ||_   _|_   _|
        | | | |___  __ _| |  | |   | |
        | | | / _ \/ _| | |  | |   | |
        | |/ /  __/ (_| | |__| |_ _| |_
        |___/ \___|\__,_|_(_)___/ \___/

This is a shell with PATHs and \${EXTERNAL_LIB}_DIR setup to work with Deal.II.
All external libraries are located in 

    $DEAL_II_RESOURCES/@DEAL_II_CPACK_EXTERNAL_LIBS@/

If you are new to Deal.II you probably want to have a look at

    $DEAL_II_RESOURCES/examples/

For more information please visit the project website:

http://www.dealii.org

If you want to set up your daily Terminal to work with deal.II, add
these lines to your ~/.profile file (the first line turns off this message):

   export DEAL_II_CONF_SILENT=ON
   . $DEAL_II_RESOURCES/@DEAL_II_SHARE_RELDIR@/dealii.conf

EOF
fi

if ! [[ -x /usr/bin/xcodebuild ]]; then
    cat << EOF
*** Warning: This package requires XCode to be installed in order to run.
    Please install XCode before you continue.

EOF
fi

# Lastly, do whatever the external library installation tells us to
if [ -f $DEAL_II_RESOURCES/@DEAL_II_CPACK_EXTERNAL_LIBS@/external.conf ]; then
    . $DEAL_II_RESOURCES/@DEAL_II_CPACK_EXTERNAL_LIBS@/external.conf
fi
