FAQ_CompiledMatlab: patchrunscript.sh

File patchrunscript.sh, 1.6 KB (added by dkearney, 2 years ago)

This script modifies run_*.sh to include Rappture in the PATH and adjusts the MCRROOT environment variable. The script was written for MATLAB 7.12 and should work for 7.10 as well.

Line 
1#!/bin/sh
2#Add Rappture path to LD_LIBRARY_PATH
3#Fix MCR at build time
4
5if [ $# -lt 2 ] ; then
6   echo "Usage:"
7   echo "   $0 scriptIn scriptOut [useRappture]"
8   exit 1
9fi
10
11if   [ $# -eq 2 ] ; then
12   cat $1 | sed -e 's/`echo /`ECHO /g' \
13                -e "/echo /d" \
14                -e 's/`ECHO /`echo /g' \
15                -e "/^if/d" \
16                -e "/^fi/d" \
17                -e "/^else/d" \
18                -e "s/^  //" \
19                -e "s/^ //" \
20                -e "s/^    /   /" \
21                -e "s/\`dirname \"\$0\"\`/\$\(readlink -f \`dirname \$0\`)/" \
22                -e "s;LD_LIBRARY_PATH=\.:;LD_LIBRARY_PATH=;" \
23                -e "/shift 1/d" \
24                -e "s:MCRROOT=\"\$1\":if \[ \"\${MATLAB_MCR}\" != \"\" \] ; then\n   MCRROOT=\${MATLAB_MCR}\nelse\n   MCRROOT=/apps/matlab/${MATLAB_VERSION=current}/mcr\nfi:" > tmp.$$
25   mv tmp.$$ $2
26elif [ $# -eq 3 ] ; then
27   cat $1 | sed -e 's/`echo /`ECHO /g' \
28                -e "/echo /d" \
29                -e 's/`ECHO /`echo /g' \
30                -e "/^if/d" \
31                -e "/^fi/d" \
32                -e "/^else/d" \
33                -e "s/^  //" \
34                -e "s/^ //" \
35                -e "s/^    /   /" \
36                -e "s/\`dirname \"\$0\"\`/\$\(readlink -f \`dirname \$0\`)/" \
37                -e "s;LD_LIBRARY_PATH=\.;LD_LIBRARY_PATH=/apps/rappture/current/lib;" \
38                -e "/shift 1/d" \
39                -e "s:MCRROOT=\"\$1\":if \[ \"\${MATLAB_MCR}\" != \"\" \] ; then\n   MCRROOT=\${MATLAB_MCR}\nelse\n   MCRROOT=/apps/matlab/${MATLAB_VERSION=current}/mcr\nfi:" > tmp.$$
40   mv tmp.$$ $2
41fi