#
# gccopts.sh	Shell script for configuring MEX-file creation script,
#               mex.
#
# usage:        Do not call this file directly; it is sourced by the
#               mex shell script.  Modify only if you don't like the
#               defaults after running mex.  No spaces are allowed
#               around the '=' in the variable assignment.
#
#               Note: only the gcc side of this script was tested.
#               The FORTRAN variables are lifted directly from
#               mexopts.sh; use that file for compiling FORTRAN
#               MEX-files.
#
# 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_MEX_OPT: Template Options file for building gcc MEX-files
#
# Copyright 1984-2000 The MathWorks, Inc.
# $Revision: 1.38 $  $Date: 2000/08/07 15:50:31 $
#----------------------------------------------------------------------------
#
    case "$Arch" in
        Undetermined)
#----------------------------------------------------------------------------
# Change this line if you need to specify the location of the MATLAB
# root directory.  The cmex 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.
#----------------------------------------------------------------------------
            MATLAB="$MATLAB"
#
# Determine the location of the GCC libraries
#
	    GCC_LIBDIR=`gcc -v 2>&1 | awk '/.*Reading specs.*/ {print substr($4,0,length($4)-6)}'`
            ;;
        alpha)
#----------------------------------------------------------------------------
            #
            # gcc version 2.8.1
            #
            CC='gcc'
            CFLAGS='-mieee'
            CLIBS="-L$GCC_LIBDIR -lmx -lgcc"
            COPTIMFLAGS='-O -DNDEBUG'
	    CDEBUGFLAGS='-g'
#
            FC='f77'
            FFLAGS='-shared'
            FLIBS='-L$MATLAB/bin/$Arch -lmx -lUfor -lfor -lFutil'
            FOPTIMFLAGS='-O'
            FDEBUGFLAGS='-g'
#
            LD='ld' 
            LDFLAGS="-L$MATLAB/bin/$Arch -expect_unresolved '*' -shared -hidden -exported_symbol $ENTRYPOINT -exported_symbol mexVersion"
	    LDOPTIMFLAGS=''
	    LDDEBUGFLAGS=''
#----------------------------------------------------------------------------
            ;;
        hpux)
#----------------------------------------------------------------------------
            #
            # gcc version 2.7.2.f.1
            #
#----------------------------------------------------------------------------
# Note: The GNU assembler does not fully support PIC.  From the Info
#       documentation:
#
#     The GNU assembler does not fully support PIC.  Currently, you must
#     use some other assembler in order for PIC to work.  We would
#     welcome volunteers to upgrade GAS to handle this; the first part
#     of the job is to figure out what the assembler must do differently.
#
# PIC is necessary for building shared libraries.  Therefore, we need to
# use the HP assembler.
#----------------------------------------------------------------------------
            echo ''
            echo 'Warning: Assembly code generated by gcc may not compile'
            echo 'with the HP assembler'
            echo ''
            CC='gcc'
            CFLAGS='-fPIC -mpa-risc-1-0 -D_POSIX_C_SOURCE=199506L -B/usr/ccs/bin/ -mno-gas'
            CLIBS="-L$GCC_LIBDIR -lmx -lgcc"
	    COPTIMFLAGS='-O -DNDEBUG'
	    CDEBUGFLAGS='-g'
#
            FC='f90'
            FFLAGS='+z'
            FLIBS="-L$MATLAB/bin/$Arch -lmx"
            FOPTIMFLAGS='-O'
            FDEBUGFLAGS='-g'
#
            LD='ld'
            LDFLAGS="-L$MATLAB/bin/$Arch -b +e $ENTRYPOINT +e mexVersion"
	    LDOPTIMFLAGS=''
	    LDDEBUGFLAGS=''
#----------------------------------------------------------------------------
            ;;
        hp700)
#----------------------------------------------------------------------------
            #
            # gcc version 2.7.2.f.1
            #
#----------------------------------------------------------------------------
# Note: The GNU assembler does not fully support PIC.  From the Info
#       documentation:
#
#     The GNU assembler does not fully support PIC.  Currently, you must
#     use some other assembler in order for PIC to work.  We would
#     welcome volunteers to upgrade GAS to handle this; the first part
#     of the job is to figure out what the assembler must do differently.
#
# PIC is necessary for building shared libraries.  Therefore, we need to
# use the HP assembler.
#----------------------------------------------------------------------------
            echo ''
            echo 'Warning: Assembly code generated by gcc may not compile'
            echo 'with the HP assembler'
            echo ''
            CC='gcc'
            CFLAGS='-fPIC -mpa-risc-1-0 -D_HPUX_SOURCE -B/usr/ccs/bin/ -mno-gas'
            CLIBS="-L$GCC_LIBDIR -lmx -lgcc"
	    COPTIMFLAGS='-O -DNDEBUG'
	    CDEBUGFLAGS='-g'
#
            FC='f90'
            FFLAGS='+z'
            FLIBS="-L$MATLAB/bin/$Arch -lmx"
            FOPTIMFLAGS='-O'
            FDEBUGFLAGS='-g'
#
            LD='ld'
            LDFLAGS="-L$MATLAB/bin/$Arch -b +e $ENTRYPOINT +e mexVersion"
	    LDOPTIMFLAGS=''
	    LDDEBUGFLAGS=''
#----------------------------------------------------------------------------
            ;;
        ibm_rs)
#----------------------------------------------------------------------------
            #
            # gcc version 2.7.2.f.1
            #
            CC='gcc'
            CFLAGS=''
            CLIBS="-L$MATLAB/bin/$Arch -lmatlbmx -lmx -lmex -lm"
	    COPTIMFLAGS='-O -DNDEBUG'
	    CDEBUGFLAGS='-g'
#
            FC='f77'
            FFLAGS=''
            FLIBS="-L$MATLAB/bin/$Arch -lmx -lmex $MATLAB/extern/lib/ibm_rs/fmex1.o -lm"
            FOPTIMFLAGS='-O'
            FDEBUGFLAGS='-g'
#
            LD='gcc'
            LDFLAGS="-L$MATLAB/bin/$Arch -shared -B/usr/bin/ -Wl,-e$ENTRYPOINT,-bM:SRE,-bI:$MATLAB/extern/lib/ibm_rs/exp.ibm_rs,-bE:$MATLAB/extern/lib/ibm_rs/$MAPFILE"
            LDOPTIMFLAGS='-Wl,-s'
	    LDDEBUGFLAGS=''
#----------------------------------------------------------------------------
            ;;
        glnx86)
#----------------------------------------------------------------------------
            CC='gcc'
            CFLAGS='-fPIC'
            CLIBS='-lmx'
	    COPTIMFLAGS='-O -DNDEBUG'
	    CDEBUGFLAGS='-g'
#
            FC='g77'
            FFLAGS='-fPIC'
            FLIBS='-L$MATLAB/bin/$Arch -lmx -lf2c'
            FOPTIMFLAGS='-O'
            FDEBUGFLAGS='-g'
#
            LD=$CC
            LDFLAGS='-L$MATLAB/bin/$Arch -shared'
            LDOPTIMFLAGS=''
            LDDEBUGFLAGS=''
#----------------------------------------------------------------------------
            ;;
        sgi)
#----------------------------------------------------------------------------
            #
            # gcc version 2.95.1
            #
            CC='gcc'
            CFLAGS=''
            CLIBS="-L$GCC_LIBDIR -lmx -lgcc"
	    COPTIMFLAGS='-O -DNDEBUG'
	    CDEBUGFLAGS='-g'
#
            FC='f77'
            FFLAGS=''
            FLIBS='-L$MATLAB/bin/$Arch -lmx'
            FOPTIMFLAGS='-O'
            FDEBUGFLAGS='-g'
#
            LD='ld'
            LDFLAGS="-L$MATLAB/bin/$Arch -shared -exported_symbol $ENTRYPOINT -exported_symbol mexVersion"
	    LDOPTIMFLAGS=''
	    LDDEBUGFLAGS=''
#----------------------------------------------------------------------------
            ;;
        sol2)
#----------------------------------------------------------------------------
            #
            # gcc version 2.7.2.f.1
            #
            CC='gcc'
            CFLAGS='-fPIC'
            CLIBS="-L$GCC_LIBDIR -lmx -lgcc"
	    COPTIMFLAGS='-O -DNDEBUG'
	    CDEBUGFLAGS='-g'
#
            FC='f77'
            FFLAGS='-G'
            FLIBS='-L$MATLAB/bin/$Arch -lmx'
            FOPTIMFLAGS='-O'
            FDEBUGFLAGS='-g'
#
            LD='/usr/ccs/bin/ld'
            LDFLAGS="-L$MATLAB/bin/$Arch -G -M $MATLAB/extern/lib/sol2/$MAPFILE"
	    LDOPTIMFLAGS=''
	    LDDEBUGFLAGS=''
#----------------------------------------------------------------------------
            ;;
    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"
#
#           FC="$FC"
#           FFLAGS="$FFLAGS"
#           FOPTIMFLAGS="$FOPTIMFLAGS"
#           FDEBUGFLAGS="$FDEBUGFLAGS"
#           FLIBS="$FLIBS"
#
#           LD="$LD"
#           LDFLAGS="$LDFLAGS"
#           LDOPTIMFLAGS="$LDOPTIMFLAGS"
#           LDDEBUGFLAGS="$LDDEBUGFLAGS"
#----------------------------------------------------------------------------
#############################################################################
