#!/bin/sh
USAGE="usage=$0 <name_of_c_file1> ... <name_of_c_fileN>"

# This is a Bourne Shell script that builds MATLAB "external applications."
# from input C source code files.  This script does not compile M-files
# into C files; you can only invoke the MATLAB Compiler from inside the
# MATLAB interpreter. 

# Edit the definition of MATLABROOT to specify the pathname of the top-level 
# directory on which MATLAB is installed. 

MATLABROOT=/usr/local/matlab

# Edit the definition of ARCH to specify the flavor of UNIX 
# on which you are building.  Possible values for ARCH are:
#   * alpha
#   * hp700
#   * ibm_rs
#   * sgi
#   * sol2
#   * sun4

#sun 4
ARCH=sun4
CC=gcc
CPPFLAGS=-Dsparc
CFLAGS="-O -ansi"
SYSLIBS=-lm

#sol2
#ARCH=sol2
#CC=cc
#CPPFLAGS=
#CFLAGS="-O -Xa -xlibmieee -xlibmil"
#SYSLIBS=-lm

#hp700
#ARCH=hp700
#CC=cc
#CPPFLAGS="-Aa -D_HPUX_SOURCE"
#CFLAGS=-O
#SYSLIBS=-lm

#sgi
#ARCH=sgi
#CC=cc
#CPPFLAGS=
#CFLAGS=-O
#SYSLIBS="-lblas -lm"

#ibm_rs
#ARCH=ibm_rs
#CC=cc
#CPPFLAGS="-qlanglvl=ansi -D_ALL_SOURCE"
#CFLAGS="-O -qfloat=nomaf"
#SYSLIBS=-lm

#alpha
#ARCH=alpha
#CC=cc
#CPPFLAGS=-std1
#CFLAGS="-O -ieee_with_no_inexact -assume noaccuracy_sensitive"
#SYSLIBS="-lots -lm"

# List of libraries to link against.
INSTALLDIR=$MATLABROOT/extern  
LIBDIR=$INSTALLDIR/lib/$ARCH
MATLAB_TOOLBOX_LIBRARY=$LIBDIR/libtbx.a
MATLAB_COMPILER_LIBRARY=$LIBDIR/libmcc.a
MATLAB_MATH_LIBRARY=$LIBDIR/libmatlb.a
MATLAB_INCLUDE_DIRECTORY=$INSTALLDIR/include

# Edit the definition of TARGET_APPLICATION to specify the name
# of the resulting external application.
TARGET_APPLICATION=a.out

# Compile and link.
$CC -o $TARGET_APPLICATION -I$MATLAB_INCLUDE_DIRECTORY $CPPFLAGS $CFLAGS $* \
                   $MATLAB_TOOLBOX_LIBRARY  \
                   $MATLAB_COMPILER_LIBRARY \
                   $MATLAB_MATH_LIBRARY     \
                   $SYSLIBS


