#
# mbuildopts.sh Shell script for configuring mbuild, the C/C++ stand alone 
#		applications creation script.
#
# usage:        Do not call this file directly; it is sourced by the
#               mbuild shell script.  Modify only if you don't like the
#               defaults after running mbuild.  No spaces are allowed
#               around the '=' in the variable assignment.
#
# SELECTION_TAGs occur in template option files and are used by MATLAB
# tools, such as mex and mbuild, to determine the purpose of the contents
# of an option file. These tags are only interpreted when preceded by '#'
# and followed by ':'.
#
#SELECTION_TAG_ML_OPT: Build and link with MATLAB C-API or MATLAB Compiler-generated library via the system ANSI C/C++ compiler
#
# Copyright 1984-2004 The MathWorks, Inc.
# $Revision: 1.51.4.11 $  $Date: 2004/11/13 18:23:17 $
#----------------------------------------------------------------------------
#
    MLIBS="-L$TMW_ROOT/bin/$Arch $OTHER_LIBS"
#   Link against the old set of libraries for HPUX only. For all other 
#   Unix platforms, link against mclmcrrt
    MLIBS="$MLIBS -lmwmclmcrrt"
    MFLAGS="-I$TMW_ROOT/extern/include -DUNIX -DX11"
    MCXXFLAGS="-I$TMW_ROOT/extern/include/cpp $MFLAGS"
    MCXXLIBS="$MLIBS"
    case "$Arch" in
        Undetermined)
#----------------------------------------------------------------------------
# Change this line if you need to specify the location of the TMW_ROOT
# root directory.  The mbuild script needs to know where to find utility
# routines so that it can determine the architecture; therefore, this
# assignment needs to be done while the architecture is still
# undetermined.
#----------------------------------------------------------------------------
            TMW_ROOT="$TMW_ROOT"
            ;;
        hpux)
#----------------------------------------------------------------------------
#           what `which cc`
#           HP92453-01 B.11.11.06 HP C Compiler
            CC='cc'
            COMPFLAGS='-z +Z +DA2.0 -mt -Bhidden_def'
            CFLAGS="-Ae $COMPFLAGS $MFLAGS -Wp,-H65535"
            CLIBS="$MLIBS -lm"
            COPTIMFLAGS='-O -DNDEBUG'
            CDEBUGFLAGS='-g'
#
            SHLCFLAGS="+Z $CFLAGS"
#
#           what `which aCC`
#           HP aC++ B3910B A.03.37
#           HP aC++ B3910B A.03.30 Language Support Library
            CXX='aCC'
            CXXFLAGS="$MCXXFLAGS -AA -D_HPUX_SOURCE $COMPFLAGS"
            CXXLIBS="$MLIBS -lm"
            CXXOPTIMFLAGS='-O -DNDEBUG +Oconservative'
            CXXDEBUGFLAGS='-g'
#
            SHLCXXFLAGS="+Z $CXXFLAGS"
#
            LD="$COMPILER"
            LDFLAGS="-Wl,+s $COMPFLAGS"
            LDOPTIMFLAGS='-O'
            LDDEBUGFLAGS='-g'
#
            SHLLD="$COMPILER"
            SHLLDFLAGS="-b $COMPFLAGS"
            SHLCXXLDFLAGS="$SHLLDFLAGS"
            SHLMAKEDEF="awk '{printf \"+e %s\\n\", \$0;}'"
            SHLPOSTLINK_CMDS=':'
#
            POSTLINK_CMDS=':'
#----------------------------------------------------------------------------
            ;;
        glnx86)
#----------------------------------------------------------------------------
            RPATH="-Wl,-rpath-link,$TMW_ROOT/bin/$Arch"
#           gcc -v
#           gcc version 3.2.3
            CC='gcc'
            CFLAGS="$MFLAGS -ansi -D_GNU_SOURCE -pthread -fexceptions"
            CLIBS="$RPATH $MLIBS -lm -lstdc++"
            COPTIMFLAGS='-O -DNDEBUG'
            CDEBUGFLAGS='-g'
#
            SHLCFLAGS="-fPIC $CFLAGS"
#           
#           g++ -v
#           gcc version 3.2.3
            CXX='g++'
            CXXFLAGS="$MCXXFLAGS -ansi -D_GNU_SOURCE -pthread -DGLNX86 -DGCC"
            CXXLIBS="$RPATH $MCXXLIBS -lm"
            CXXOPTIMFLAGS='-O -DNDEBUG'
            CXXDEBUGFLAGS='-g'
            CXXLDFLAGS='-pthread'
#
            SHLCXXFLAGS="-fPIC $CXXFLAGS"
#
            LD="$COMPILER"
            LDFLAGS='-pthread'
            LDOPTIMFLAGS='-O'
            LDDEBUGFLAGS='-g'
#
            SHLLD="$COMPILER"
            SHLLDFLAGS='-pthread -shared'
            SHLCXXLDFLAGS="$SHLLDFLAGS"
            SHLMAKEDEF="cat"
            SHLPOSTLINK_CMDS=':'
#
            POSTLINK_CMDS=':'
#----------------------------------------------------------------------------
            ;;
        glnxa64)
#----------------------------------------------------------------------------
            RPATH="-Wl,-rpath-link,$TMW_ROOT/bin/$Arch"
#           gcc -v
#           gcc version 3.2.3
            CC='gcc'
            CFLAGS="$MFLAGS -ansi -D_GNU_SOURCE -pthread -fexceptions"
            CLIBS="$RPATH $MLIBS -lm -lstdc++"
            COPTIMFLAGS='-O -DNDEBUG'
            CDEBUGFLAGS='-g'
#
            SHLCFLAGS="-fPIC $CFLAGS"
#           
#           g++ -v
#           gcc version 3.2.3
            CXX='g++'
            CXXFLAGS="$MCXXFLAGS -ansi -D_GNU_SOURCE -pthread -DGLNX86 -DGCC"
            CXXLIBS="$RPATH $MCXXLIBS -lm"
            CXXOPTIMFLAGS='-O -DNDEBUG'
            CXXDEBUGFLAGS='-g'
            CXXLDFLAGS='-pthread'
#
            SHLCXXFLAGS="-fPIC $CXXFLAGS"
#
            LD="$COMPILER"
            LDFLAGS='-pthread'
            LDOPTIMFLAGS='-O'
            LDDEBUGFLAGS='-g'
#
            SHLLD="$COMPILER"
            SHLLDFLAGS='-pthread -shared'
            SHLCXXLDFLAGS="$SHLLDFLAGS"
            SHLMAKEDEF="cat"
            SHLPOSTLINK_CMDS=':'
#
            POSTLINK_CMDS=':'
#----------------------------------------------------------------------------
            ;;
        glnxi64)
#----------------------------------------------------------------------------
echo "Error: Did not imbed 'options.sh' code"; exit 1 #imbed options.sh glnxi64 12
#----------------------------------------------------------------------------
            ;;
        sol2)
#----------------------------------------------------------------------------
#           cc -V
#           Sun C 5.5 Patch 112760-06 2004/01/13
            CC='cc'
            CFLAGS="$MFLAGS -dalign -xlibmieee -D__EXTENSIONS__ -D_POSIX_C_SOURCE=199506L -mt"
            CLIBS="$MLIBS -lm"
            COPTIMFLAGS='-xO3 -xlibmil -DNDEBUG'
            CDEBUGFLAGS='-g'  
#
            SHLCFLAGS="-KPIC $CFLAGS"
#           
#           CC -V
#           Sun C++ 5.5 Patch 113817-05 2004/01/13
            CXX='CC -compat=5'
            CCV=`CC -V 2>&1`
            version=`expr "$CCV" : '.*\([0-9][0-9]*\)\.'`
            if [ "$version" = "4" ]; then
                    echo "SC5.0 or later C++ compiler is required"
            fi
            CXXFLAGS="$MCXXFLAGS -dalign -xlibmieee -D__EXTENSIONS__ -D_POSIX_C_SOURCE=199506L -mt -DSOL2 +d"
            CXXLIBS="$MCXXLIBS -lm"
            CXXOPTIMFLAGS='-xO3 -xlibmil -DNDEBUG'
            CXXDEBUGFLAGS='-g'
            CXXLDFLAGS='-mt'
#
            SHLCXXFLAGS="-KPIC $CXXFLAGS -xldscope=hidden -xregs=no%appl"
#
            LD="$COMPILER"
            LDFLAGS='-mt'
            LDOPTIMFLAGS='-O'
            LDDEBUGFLAGS='-g'  
#
            SHLLD="$COMPILER"
            SHLLDFLAGS="-G -mt -xldscope=hidden -xregs=no%appl"
            SHLCXXLDFLAGS="$SHLLDFLAGS"
            SHLMAKEDEF="cat"
            SHLPOSTLINK_CMDS=':'
#
            POSTLINK_CMDS=':'
#----------------------------------------------------------------------------
            ;;
        mac)
#----------------------------------------------------------------------------
#           gcc-3.3 -v
#           gcc version 3.3 20030304 (Apple Computer, Inc. build 1435)
            CC='gcc-3.3'
            CFLAGS="$MFLAGS -fno-common -no-cpp-precomp -fexceptions"
            CLIBS="$MLIBS -lstdc++"
            COPTIMFLAGS='-O3 -DNDEBUG'
            CDEBUGFLAGS='-g'
#
            SHLCFLAGS="$CFLAGS"
#           
#           g++-3.3 -v
#           gcc version 3.3 20030304 (Apple Computer, Inc. build 1435)
            CXX=g++-3.3
            CXXFLAGS='$MCXXFLAGS -fno-common -no-cpp-precomp -DMAC -fexceptions'
            CXXLIBS="$MCXXLIBS"
            CXXOPTIMFLAGS='-O3 -DNDEBUG'
            CXXDEBUGFLAGS='-g'
            CXXLDFLAGS='-Wl,-flat_namespace -undefined suppress'
#
            SHLCXXFLAGS="$CXXFLAGS"
#
            LD="$COMPILER"
            LDFLAGS='-Wl,-flat_namespace -undefined suppress -bind_at_load'
            LDOPTIMFLAGS='-O'
            LDDEBUGFLAGS='-g'
#
            SHLLD='$COMPILER'
            SHLLDFLAGS="-Wl,-flat_namespace -undefined suppress -Wl,-exported_symbols_list,$EXPFILE -dynamiclib"
            SHLCXXLDFLAGS="$SHLLDFLAGS"
            SHLMAKEDEF="awk '{printf \"_%s\\n\", \$0;}'"
            SHLPOSTLINK_CMDS=':'
#
            POSTLINK_CMDS=':'
#----------------------------------------------------------------------------
            ;;
    esac
#############################################################################
#
# Architecture independent lines:
#
#     Set and uncomment any lines which will apply to all architectures.
#
#----------------------------------------------------------------------------
#           CC="$CC"
#           CFLAGS="$CFLAGS"
#           COPTIMFLAGS="$COPTIMFLAGS"
#           CDEBUGFLAGS="$CDEBUGFLAGS"
#           CLIBS="$CLIBS"
#
#           LD="$LD"
#           LDFLAGS="$LDFLAGS"
#           LDOPTIMFLAGS="$LDOPTIMFLAGS"
#           LDDEBUGFLAGS="$LDDEBUGFLAGS"
#----------------------------------------------------------------------------
#############################################################################
