#! /bin/sh
######################################
##### Model Transformation Tools #####
######################################
# Bourne shell script: mttrc - sets up paths etc for mtt
# Usage: mttrc
# Copyright (c) P.J.Gawthrop 1996,1977.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.44 2006/04/25 23:24:29 geraint
## Reverted to simple g++ for MTT_CXX. Trying to force the version causes library problems.
##
## Revision 1.43 2006/02/09 23:49:40 geraint
## added rtxi build flags
##
## Revision 1.42 2005/11/16 00:43:15 geraint
## rtxi
##
## Revision 1.41 2004/02/17 17:53:34 geraint
## Fixed [ 898739 ] libhdf5 dependency breaks -cc reps.
## Now uses mkoctfile to determine include and library flags.
##
## Revision 1.40 2003/09/23 15:57:18 gawthrop
## And back to gv
##
## Revision 1.39 2003/09/22 17:38:56 gawthrop
## gv --> ghostview
##
## Revision 1.38 2003/07/13 21:53:24 geraint
## Updated to conform to latest Octave (tested with 2.1.49).
## - the pathsearch library was merged into liboctave last year
## - static_cast no longer seems to work between Matrix and ColumnVector
##
## Revision 1.37 2002/09/19 08:08:15 gawthrop
## Updated documentation documentation
##
## Revision 1.36 2002/08/28 15:48:00 geraint
## Updated mttrc to make standalone C++ compilation configuration clearer.
##
## Revision 1.35 2002/08/06 09:56:54 geraint
## Updated to work with changes in unstable version of Octave 2.1.36.
## Tested with 2.0.17 (ok) but will break earlier unstables (2.1.(<=35)).
##
## Revision 1.34 2002/05/08 14:51:03 geraint
## Moved matlab/octave data type conversion functions to a separate file.
##
## Revision 1.33 2002/05/08 11:39:36 gawthrop
## Added MTT_REP to PATH
##
## Revision 1.32 2002/05/07 23:50:34 geraint
## Preliminary support for Matlab dynamically linked shared objects:
## invoke with: mtt -cc sys rep mexglx
## ode2odes support is not yet included.
##
## Revision 1.31 2002/05/02 20:12:45 geraint
## Added -Wl,--rpath to MTT_CXXLIBS. Sets the runtime linker path so that the
## sys-admin does not have to ldconfig the octave directory for -cc to work.
##
## Revision 1.30 2002/05/02 11:10:11 geraint
## s/loctave/loctinterp/
##
## Revision 1.29 2002/05/02 11:03:46 geraint
## Reinstated -liboctinterp and -lncurses; needed by xleftdiv.
##
## Revision 1.28 2002/05/01 12:21:29 geraint
## No longer uses save_ascii_data_for_plotting function to write data
## - eliminates dependence on liboctinterp (and libncurses) for .cc.
##
## Revision 1.27 2002/04/28 18:41:26 geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.26 2002/04/26 16:16:33 geraint
## Removed unnecessary variables PLAT and GCCVERS.
##
## Revision 1.25 2002/04/02 09:16:39 geraint
## Tidied up library search paths, now assumes that system libraries are set up correctly.
## For Debian, this means installing the following: blas-dev, fftw-dev, lapack-dev, libncurses5-dev, libkpathsea-dev, libreadline-dev
## It may also be necessary to run /sbin/ldconfig on the relevant directories (especially Octave's).
##
## Revision 1.24 2001/10/15 14:28:35 gawthrop
## Now has . at start of components library path $MTT_COMPONENTS
##
## Revision 1.23 2001/07/24 22:32:49 gawthrop
## Use gv, not ghostview
##
## Revision 1.22 2001/04/12 03:08:00 geraint
## Improved sh->csh conversion, reduces environment namespace pollution.
## Still need to do proper if [ -z $MTT_BASE ] ... else ... fi conversion.
##
## Revision 1.21 2001/04/10 13:56:13 gawthrop
## Uses standard mkoctfile
##
## Revision 1.20 2001/04/10 13:08:19 gawthrop
## Smoother translation to .cs using sh2csh
##
## Revision 1.19 2001/03/30 15:13:49 gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.18 2001/03/19 02:28:52 geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.17.2.4 2001/03/06 03:48:43 geraint
## Print additional environment variable for "mtt -p".
## MTT_LDFLAGS defaults to " " to avoid installation warning.
##
## Revision 1.17.2.3 2001/03/01 05:05:53 geraint
## Minor revisions.
##
## Revision 1.17.2.2 2001/02/23 03:53:53 geraint
## Minor revisions. (ode2odes.exe works on GNU/Linux and ~GNU/Irix)
##
## Revision 1.17.2.1 2001/02/22 06:41:40 geraint
## Initial merge of ode2odes.exe into main mtt.
## standalone_rep.make deleted: rules moved to mtt, variables to mttrc.
##
## Revision 1.17 2000/12/27 16:46:13 peterg
## Stripped the mtt- from paths
##
## Revision 1.16 2000/12/27 15:16:44 peterg
## If then else format
##
## Revision 1.15 2000/12/27 14:57:43 peterg
## Now takes the base path as an argument
##
## Revision 1.14 2000/12/27 13:11:43 peterg
## *** empty log message ***
##
## Revision 1.13 2000/10/03 12:12:14 peterg
## New path structure to account for three way split in mtt tree
##
## Revision 1.12 2000/09/18 12:17:07 peterg
## Now includes to control system toolbox in OCTAVE_PATH
## Don't use -path stuff - use :: instead.
##
## Revision 1.11 2000/05/21 17:55:15 peterg
## New rep path
##
## Revision 1.10 2000/05/16 11:41:23 peterg
## *** empty log message ***
##
## Revision 1.9 1999/03/11 04:02:19 peterg
## Revised so that sh2csh does its stuff.
##
## Revision 1.8 1998/07/17 19:48:46 peterg
## *** empty log message ***
##
## Revision 1.7 1998/03/24 09:11:49 peterg
## Compatible with .csh version
##
## Revision 1.6 1998/03/13 11:53:29 peterg
## reduce --> reduce 64
##
## Revision 1.5 1998/01/16 08:55:01 peterg
## MAKE=make
##
## Revision 1.4 1998/01/06 09:14:51 peterg
## Added latex2html to setup
##
# Revision 1.3 1998/01/06 09:11:26 peterg
# Removed matlab from the setup
#
# Revision 1.2 1997/12/04 10:49:16 peterg
# Put under RCS at last
# Added CC variable
#
###############################################################
## When using csh, replace $1 by the mtt base path, eg /usr/share/mtt/latest
export MTT_BASE=$1
if [ -z "$MTT_BASE" ]; then
echo mttrc requires one argument: eg mttrc /usr/share/mtt/latest
else
echo Setting paths with base $MTT_BASE
# The following line sets up the make to use -- gmake is the standard
# but you may wish to use lsmake for parallelism
export MAKE='make'
# The following sets up the c compiler
export CC='gcc'
# Setup the paths
export MTTPATH=$MTT_BASE/bin
export MTT_LIB=$MTT_BASE/lib
export MTT_DOC=$MTT_BASE/doc
export MTT_CC=$MTT_BASE/cc
export MTT_COMPONENTS=.:$MTT_LIB/comp
export MTT_CRS=$MTT_LIB/cr
export MTT_EXAMPLES=$MTT_LIB/examples
export MTT_REP=$MTT_LIB/rep
export PATH=$PATH\:$MTTPATH\:$MTTPATH/trans\:$MTT_CC\:$MTT_REP
#Setup octave
MATRIX="octave"
#MATRIX_PATH1=$(echo "genpath('$MTTPATH/trans/m')" |$MATRIX -q | awk '{print $3}')
#MATRIX_PATH2=$(echo "genpath('$MTT_LIB/comp/simple')" |$MATRIX -q | awk '{print $3}')
#MATRIX_PATH3=$(echo "genpath('$MTT_LIB/control')" |$MATRIX -q | awk '{print $3}')
#MATRIX_PATH4=$(echo "genpath('$MTT_LIB/octave')" |$MATRIX -q | awk '{print $3}')
#export MATRIX_PATH=$MATRIX_PATH1:$MATRIX_PATH2:$MATRIX_PATH3:$MATRIX_PATH4
MATRIX_PATH1=$(find $MTTPATH/trans/m -type d|grep -v CVS|awk '{printf ":%s", $0}')
MATRIX_PATH2=$(find $MTT_LIB/comp/simple -type d|grep -v CVS|awk '{printf ":%s", $0}')
MATRIX_PATH3=$(find $MTT_LIB/control -type d|grep -v CVS|awk '{printf ":%s", $0}')
MATRIX_PATH4=$(find $MTT_LIB/octave -type d|grep -v CVS|awk '{printf ":%s", $0}')
export MATRIX_PATH=$MATRIX_PATH1:$MATRIX_PATH2:$MATRIX_PATH3:$MATRIX_PATH4
export OCTAVE_PATH=.\:$MATRIX_PATH
export MATRIX="$MATRIX --path $OCTAVE_PATH"
# Setup the symbolic stuff
export SYMBOLIC='reduce 64'
# Setup xfig
export FIG="xfig \
-startfontsize 20 \
-metric \
-portrait \
-startgridmode 2 \
-pheight 21 \
-pwidth 30 \
-library_dir $MTT_LIB/xfig/\
"
# Setup ps viewer
export PSVIEW='evince'
# Setup pdf viewer
export PDFVIEW='acroread'
# Setup html viewer
export HTMLVIEW='firefox'
# Setup dvi viewer
export DVIVIEW='xdvi'
# Setup latex2html
export LATEX2HTML="latex2html -contents_in_navigation -index_in_navigation -address http://mtt.sourceforge.net"
# Ascend stuff
export ASCENDLIBRARY=$MTTPATH/ascend/lib
# Oct file generation - use version with no optimisation.
#export MKOCTFILE=$MTT_LIB/octave/mkoctfile # This for no optimisation
export MKOCTFILE=mkoctfile
#########################################################################################
##
## Configure environment for standalone compilation of files linked with Octave libraries
## (required for ode2odes.exe only)
# location of Octave directories on local system (usually /usr, /usr/local or /opt)
OCTAVEPREFIX="/usr"
# include paths for Octave
IOCTAVE="-I${OCTAVEPREFIX}/include/octave/ -I${OCTAVEPREFIX}/include/octave/octave"
# include and library paths for Octave
if [ -z `which ${MKOCTFILE}` ]; then
# Octave development stuff not installed
# C++ and .oct representations will not work
OCTAVE_INC_FLAGS=" "
OCTAVE_LIB_FLAGS=" "
else
OCTAVE_INC_FLAGS="`${MKOCTFILE} --print INCFLAGS`"
OCTAVE_LIB_FLAGS="\
`${MKOCTFILE} --print LFLAGS` \
`${MKOCTFILE} --print LIBOCTAVE` \
`${MKOCTFILE} --print LIBCRUFT` \
`${MKOCTFILE} --print LIBOCTINTERP` \
`${MKOCTFILE} --print BLAS_LIBS` \
`${MKOCTFILE} --print FFTW_LIBS` \
`${MKOCTFILE} --print LIBS` \
`${MKOCTFILE} --print FLIBS` \
`${MKOCTFILE} --print RLD_FLAG`"
fi
# C++ compiler options
DEBUG="-g"
OPTIM="-O3"
FLAGS="-fno-rtti -fno-exceptions -fno-implicit-templates"
# exported variables
export MTT_CXX="g++"
export MTT_CXXFLAGS="${DEBUG} ${OPTIM} ${FLAGS}"
export MTT_CXXLIBS="${OCTAVE_LIB_FLAGS}"
export MTT_CXXINCS="-I. -I${MTT_LIB}/cc ${OCTAVE_INC_FLAGS}"
export MTT_LDFLAGS=" "
## End of Octave environment configuration
##
#########################################################################################
############################################################
##
## Configure environment for compilation of Matlab mex files
MATLAB_ARCH="glnx86"
MATLAB_ROOT="/usr/local/matlab6p1"
MATLAB_FLAGS="-shared -fPIC -ansi -D_GNU_SOURCE -pthread"
MATLAB_INCS="-I${MATLAB_ROOT}/extern/include"
MATLAB_LIBS="-Wl,--rpath-link,${MATLAB_ROOT}/extern/lib/${MATLAB_ARCH},--rpath-link,${MATLAB_ROOT}/bin/${MATLAB_ARCH} -L${MATLAB_ROOT}/bin/${MATLAB_ARCH} -lmx -lmex -lm"
# exported variables
export MTT_MATLAB_FLAGS="${MATLAB_FLAGS} ${MATLAB_INCS} ${MATLAB_LIBS}"
## End of Matlab environment configuration
##
#############################################################
#######################################################
##
## Configure environment for compilation of RTXI module
ROOT="/usr/local/rtxi-knoppix"
RTXI_LIBTOOL="${ROOT}/usr/local/lib/rtxi/libtool"
RTXI_CXX="g++-3.3"
RTXI_CXXLD="g++-3.3"
RTXI_CXXCOMPILE="${RTXI_LIBTOOL} --mode=compile --tag CXX ${RTXI_CXX}"
RTXI_CXXLINK="${RTXI_LIBTOOL} --mode=link --tag CXX ${RTXI_CXXLD}"
RTXI_INCS=""
RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/share/qt3/include"
RTXI_INCS="${RTXI_INCS} -I."
RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/realtime/include"
RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/share/qt3/include"
RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/src/comedi/include"
RTXI_INCS="${RTXI_INCS} -I${ROOT}/usr/src/rtxi/include"
RTXI_DEFS="-D_REENTRANT -DQT_THREAD_SUPPORT"
RTXI_CXXFLAGS="-g -O2 ${RTXI_INCS} ${RTXI_DEFS}"
RTXI_LIBS="-L${ROOT}/usr/share/qt3/lib -lqt-mt"
RTXI_FLAGS="-DHAVE_CONFIG_H -D_REENTRANT -DQT_THREAD_SUPPORT"
RTXI_LDFLAGS="-L${ROOT}/usr/realtime/lib -lpthread -module -avoid-version"
RTXI_RPATH="${ROOT}/usr/local/lib/rtxi/models/"
export MTT_RTXI_CXXCOMPILE="${RTXI_CXXCOMPILE}"
export MTT_RTXI_CXXLINK="${RTXI_CXXLINK}"
export MTT_RTXI_LIBTOOL="${RTXI_LIBTOOL}"
export MTT_RTXI_CXXFLAGS="${RTXI_CXXFLAGS}"
export MTT_RTXI_LIBS="${RTXI_LIBS}"
export MTT_RTXI_FLAGS="${RTXI_RTXI_FLAGS}"
export MTT_RTXI_LDFLAGS="${RTXI_LDFLAGS}"
export MTT_RTXI_RPATH="${RTXI_RPATH}"
## End of RTXI environment configuration
##
#############################################################
fi