#! /bin/sh
#------------------------------------------------------------------------
#------------------------------------------------------------------------
# Global Variables
#------------------------------------------------------------------------
ldas_repository_dir_="${HOME}/Sources"
ldas_prefix_="${HOME}/`uname`-`uname -m`"
ldas_ospace_dir_="${HOME}/`uname`-`uname -m`/stow_pkgs/ospace-head"
ldas_tcl_config_="/usr/lib64/tclConfig.sh"
ldas_optimization_="high"
ldas_ticket_prefix_="ldas-ticket-"
ldas_env_=""
ldas_with_ldcg_inclusion="no"
ldas_with_metadata_api_="no"
ldas_inlining_="yes"
ldas_with_doxygen="yes"
ldas_extra_options_=""
ldas_enable_64bit_="yes"
#------------------------------------------------------------------------
# Read user's customization
#------------------------------------------------------------------------
ldas_configure_resource_file_="${HOME}/.ldas-configure.rc"
if test -f ${ldas_configure_resource_file_}
then
  . ${ldas_configure_resource_file_}
fi
#------------------------------------------------------------------------
# Nothing needs modification below this line.
#------------------------------------------------------------------------
case $# in
2)
    SOURCEDIR=$1
    TICKET=$2
    ;;
*)
    echo "USAGE: $0 <source-dir> <ticket-number>"
    exit 1
    ;;
esac
#------------------------------------------------------------------------
# Setup the options
#------------------------------------------------------------------------
opts_="${opts_} --without-stlport"
case "x${ldas_with_ldcg_inclusion}" in
"xyes")
  opts_="${opts_} --enable-auto-ldcg-inclusion"
  ;;
*)
  opts_="${opts_} --disable-auto-ldcg-inclusion"
  ;;
esac
case "x${ldas_with_metadata_api_}" in
"xyes")
  opts_="${opts_} --enable-metadata-api"
  ;;
*)
  opts_="${opts_} --disable-metadata-api"
  ;;
esac
opts_="${opts_} --with-ilwd"
opts_="${opts_} --with-threads"
opts_="${opts_} --with-ospace=${ldas_ospace_dir_}"
opts_="${opts_} --with-tcl-config=${ldas_tcl_config_}"
opts_="${opts_} --with-doxygen=${ldas_with_doxygen_}"
opts_="${opts_} --without-dot"
opts_="${opts_} --with-optimization=${ldas_optimization_}"
opts_="${opts_} --enable-64bit=${ldas_enable_64bit_}"
case "x${ldas_inlining_}" in
"xno")
  opts_="${opts_} --disable-inlining"
  ;;
*)
  opts_="${opts_} --enable-inlining"
  ;;
esac
opts_="${opts_} ${ldas_extra_options_}"
#------------------------------------------------------------------------
#------------------------------------------------------------------------
eval ${ldas_repository_dir_}/${SOURCEDIR}/configure ${ldas_env_} \
    --prefix=${ldas_prefix_}/stow_pkgs/${ldas_ticket_prefix_}${TICKET} \
    --docdir='\${datarootdir}/doc/\${LDAS_PACKAGE_NAME}-\${LDAS_PACKAGE_VERSION}' \
    --cache-file=`pwd`/ldas.cache \
    ${opts_}
