Annotation of wikisrc/tutorials/how_to_run_matlab_r14.3_on_netbsd__92__i386.mdwn, revision 1.1

1.1     ! mspo        1: **Contents**
        !             2: 
        !             3: [[!toc levels=3]]
        !             4: 
        !             5: #  Things needed 
        !             6: 
        !             7: the latest stable NetBSD/i386 installation. The archivers/{zip,unzip} packages. The linux emulation packages suse_base and suse_compat. 
        !             8: 
        !             9: If you want to run binary modules (MEX), you also need the suse_devel-7.3 package; that is not (yet?) available as suse9.x version. Matlab 14.3 ships with a JDK 1.5 which runs nicely on netbsd-3, so no additional JRE needed. The three Matlab 7 / R14 Unix installation CDROMs. The patches listed below. A few GBytes of diskspace. 
        !            10: 
        !            11: #  Work to do 
        !            12: 
        !            13: #  A Short Cut 
        !            14: 
        !            15: While the following steps are kept for documentation and your own experiments, there is a [tar-ball](http://www.spg.tu-darmstadt.de/~hf/notes/patch_matlabcd.tar.gz) available with the patches and a shell script to apply them. 
        !            16: 
        !            17: Unpack, change to the patch_matlabcd directory, call sh patch-matlab.sh -m /path/to/cdcontent, optionally add '-v' for verbose output. 
        !            18: 
        !            19: #  Footwork 
        !            20: 
        !            21:   * Copy the three CDROMs to the harddisk (directories CD1, CD2, CD3). 
        !            22:   * mount_union(8) a scratch directory on top of the directory that contains CD[123]. This scratch directory will contain all the changes that you make to the content of the CDs. 
        !            23:   * chdir to CD1 
        !            24:   * Apply the patch 
        !            25:     
        !            26: <pre><code>    
        !            27: --- /u/software/payware/unix/matlab-r14/CD1/install     2004-09-13 14:56:28.000000000 +0200
        !            28: +++ install     2004-09-14 11:04:26.000000000 +0200
        !            29: @@ -516,6 +516,19 @@
        !            30:                                Darwin)                                 # Mac OS X
        !            31:                                         ARCH="mac"
        !            32:                                         ;;
        !            33: +               NetBSD)                                 # NetBSD (Linux emul)
        !            34: +                   case "`/usr/bin/uname -m`" in
        !            35: +                   i*86)
        !            36: +                       ARCH="glnx86"
        !            37: +                       ;;
        !            38: +                   ia64)
        !            39: +                       ARCH="glnxi64"
        !            40: +                       ;;
        !            41: +                   x86_64)
        !            42: +                       ARCH="glnxa64"
        !            43: +                       ;;
        !            44: +                   esac
        !            45: +                   ;;
        !            46:                         esac
        !            47:                 fi
        !            48:                return 0
        !            49: @@ -730,6 +743,19 @@
        !            50:                        Darwin)                                     # Mac OS X
        !            51:                                 ver=`/usr/bin/uname -r | awk '{print $1}'`
        !            52:                                 ;;
        !            53: +           NetBSD)                                     # NetBSD (Linux emul)
        !            54: +               case $Arch in
        !            55: +                   glnx86)
        !            56: +                       ver=`/emul/linux/lib/libc.so.6 | head -1 | sed -e "s/^[^0-9]*//" -e "s/[ ,].*$//"`
        !            57: +                       ;;
        !            58: +                   glnxi64)
        !            59: +                       ver=2.2.4
        !            60: +                       ;;
        !            61: +                   glnxa64)
        !            62: +                       ver=`/emul/linux/lib64/libc.so.6 | head -1 | sed -e "s/^[^0-9]*//" -e "s/[ ,].*$//"`
        !            63: +                       ;;
        !            64: +               esac
        !            65: +               ;;
        !            66:                 esac
        !            67:         fi
        !            68:  #
        !            69:     
        !            70: </code></pre>
        !            71: to the ./install script (assuming /emul/linux is a symlink to the root of the linux emulation setup). Apply equally to CD2 and CD3. Apply the patch 
        !            72:     
        !            73:     
        !            74:     --- /u/software/payware/unix/matlab-r14/CD1/update/install/arch.sh      2004-09-13 14:54:55.000000000 +0200
        !            75:     +++ update/install/arch.sh      2004-09-14 11:38:19.000000000 +0200
        !            76:     @@ -185,6 +185,19 @@
        !            77:                     Darwin)                                 # Mac OS X
        !            78:                          ARCH="mac"
        !            79:                          ;;
        !            80:     +               NetBSD)                                 # NetBSD (Linux emul)
        !            81:     +                   case "`/usr/bin/uname -m`" in
        !            82:     +                   i*86)
        !            83:     +                       ARCH="glnx86"
        !            84:     +                       ;;
        !            85:     +                   ia64)
        !            86:     +                       ARCH="glnxi64"
        !            87:     +                       ;;
        !            88:     +                   x86_64)
        !            89:     +                       ARCH="glnxa64"
        !            90:     +                       ;;
        !            91:     +                   esac
        !            92:     +                   ;;
        !            93:                  esac
        !            94:              fi
        !            95:             return 0
        !            96:     
        !            97: 
        !            98: to ./update/install/arch.sh. Apply equally to CD2 and CD3. Pick the ./update/pd/install/tar.cmp zip archive from CD1, and unpack it. 
        !            99:     
        !           100:     
        !           101:     Archive:  tar.cmp
        !           102:       Length     Date   Time    Name
        !           103:      --------    ----   ----    ----
        !           104:         41864  09-14-04 13:10   install_matlab
        !           105:             0  09-14-04 13:08   update/
        !           106:             0  09-14-04 13:08   update/install/
        !           107:             0  09-14-04 13:08   update/install/scripts/
        !           108:           676  07-10-97 05:11   update/install/scripts/abort.sh
        !           109:          2575  01-11-99 20:24   update/install/scripts/actualp.sh
        !           110:          6230  09-14-04 13:11   update/install/scripts/arch.sh
        !           111:          7329  07-27-00 21:42   update/install/scripts/batch1.sh
        !           112:          2597  01-11-99 20:24   update/install/scripts/batch4.sh
        !           113:          6985  01-29-03 21:28   update/install/scripts/bld_lbin.sh
        !           114:          9466  12-11-03 19:21   update/install/scripts/bld_sbin.sh
        !           115:           789  10-23-95 19:07   update/install/scripts/center.sh
        !           116:           530  12-11-03 19:21   update/install/scripts/cleanup.sh
        !           117:           486  01-11-99 20:24   update/install/scripts/clearsc.sh
        !           118:           848  01-11-99 20:24   update/install/scripts/cont.sh
        !           119:           449  01-11-99 20:24   update/install/scripts/echon.sh
        !           120:          2167  11-01-02 03:33   update/install/scripts/fin.sh
        !           121:          4590  03-22-04 06:07   update/install/scripts/genpathdef.sh
        !           122:          3256  12-11-03 19:21   update/install/scripts/intro_l.sh
        !           123:          5376  12-11-03 19:21   update/install/scripts/intro_s.sh
        !           124:         20832  01-09-04 18:30   update/install/scripts/lm.sh
        !           125:          6718  12-11-03 19:21   update/install/scripts/local.sh
        !           126:          3590  12-11-03 19:21   update/install/scripts/main.sh
        !           127:          1115  12-11-03 19:21   update/install/scripts/mapname.sh
        !           128:          1502  01-11-99 20:24   update/install/scripts/netruser.sh
        !           129:          1754  10-23-98 20:50   update/install/scripts/oldname.sh
        !           130:          5267  11-01-02 03:33   update/install/scripts/options.sh
        !           131:          6853  08-31-00 18:09   update/install/scripts/perm.sh
        !           132:          6585  06-12-02 22:21   update/install/scripts/ruser.sh
        !           133:           784  01-11-99 20:24   update/install/scripts/searchp.sh
        !           134:          3303  12-11-03 19:21   update/install/scripts/ucleanpe.sh
        !           135:          3295  12-11-03 19:21   update/install/scripts/update.sh
        !           136:          5395  12-11-03 19:21   update/install/scripts/util.sh
        !           137:          8565  12-11-03 19:21   update/install/scripts/verifyp.sh
        !           138:      --------                   -------
        !           139:        171771                   34 files
        !           140:     
        !           141: 
        !           142: Apply the patch 
        !           143:     
        !           144:     
        !           145:     --- install_matlab.orig    2005-08-12 10:23:52.000000000 +0200
        !           146:     +++ install_matlab 2005-09-30 14:27:23.000000000 +0200
        !           147:     @@ -552,6 +552,19 @@
        !           148:                Darwin)                                 # Mac OS X
        !           149:                          ARCH="mac"
        !           150:                          ;;
        !           151:     +          NetBSD)                                 # NetBSD (Linux emul)
        !           152:     +              case "`/usr/bin/uname -m`" in
        !           153:     +              i*86)
        !           154:     +                  ARCH="glnx86"
        !           155:     +                  ;;
        !           156:     +              ia64)
        !           157:     +                  ARCH="glnxi64"
        !           158:     +                  ;;
        !           159:     +              x86_64)
        !           160:     +                  ARCH="glnxa64"
        !           161:     +                  ;;
        !           162:     +              esac
        !           163:     +              ;;
        !           164:                  esac
        !           165:              fi
        !           166:        return 0
        !           167:     @@ -795,6 +808,19 @@
        !           168:            Darwin)                                     # Mac OS X
        !           169:                      ver=`/usr/bin/uname -r | awk '{print $1}'`
        !           170:                      ;;
        !           171:     +      NetBSD)                                     # NetBSD (Linux emul)
        !           172:     +          case $Arch in
        !           173:     +              glnx86)
        !           174:     +                  ver=`/emul/linux/lib/libc.so.6 | head -1 | sed -e "s/^[^0-9]*//" -e "s/[ ,].*$//"`
        !           175:     +                  ;;
        !           176:     +              glnxi64)
        !           177:     +                  ver=2.2.4
        !           178:     +                  ;;
        !           179:     +              glnxa64)
        !           180:     +                  ver=`/emul/linux/lib64/libc.so.6 | head -1 | sed -e "s/^[^0-9]*//" -e "s/[ ,].*$//"`
        !           181:     +                  ;;
        !           182:     +          esac
        !           183:     +          ;;
        !           184:              esac
        !           185:          fi
        !           186:      #
        !           187:     
        !           188: 
        !           189: to install_matlab, and the patch 
        !           190:     
        !           191:     
        !           192:     --- orig/update/install/scripts/arch.sh 2004-04-04 10:20:31.000000000 +0200
        !           193:     +++ update/install/scripts/arch.sh      2004-09-14 13:11:17.000000000 +0200
        !           194:     @@ -185,6 +185,19 @@
        !           195:                     Darwin)                                 # Mac OS X
        !           196:                          ARCH="mac"
        !           197:                          ;;
        !           198:     +               NetBSD)                                 # NetBSD (Linux emul)
        !           199:     +                   case "`/usr/bin/uname -m`" in
        !           200:     +                   i*86)
        !           201:     +                       ARCH="glnx86"
        !           202:     +                       ;;
        !           203:     +                   ia64)
        !           204:     +                       ARCH="glnxi64"
        !           205:     +                       ;;
        !           206:     +                   x86_64)
        !           207:     +                       ARCH="glnxa64"
        !           208:     +                       ;;
        !           209:     +                   esac
        !           210:     +                   ;;
        !           211:                  esac
        !           212:              fi
        !           213:             return 0
        !           214:     
        !           215: 
        !           216: (same as above) to update/install/scripts/arch.sh. Re-zip the contents of the archive 
        !           217:     
        !           218:     
        !           219:     [hf@venediger] /var/tmp # zip -r tar.cmp install_matlab update
        !           220:       adding: install_matlab (deflated 77%)
        !           221:       adding: update/ (stored 0%)
        !           222:       adding: update/install/ (stored 0%)
        !           223:       adding: update/install/scripts/ (stored 0%)
        !           224:       adding: update/install/scripts/abort.sh (deflated 53%)
        !           225:       adding: update/install/scripts/actualp.sh (deflated 63%)
        !           226:       adding: update/install/scripts/arch.sh (deflated 69%)
        !           227:       adding: update/install/scripts/batch1.sh (deflated 70%)
        !           228:       adding: update/install/scripts/batch4.sh (deflated 60%)
        !           229:       adding: update/install/scripts/bld_lbin.sh (deflated 75%)
        !           230:       adding: update/install/scripts/bld_sbin.sh (deflated 80%)
        !           231:       adding: update/install/scripts/center.sh (deflated 55%)
        !           232:       adding: update/install/scripts/cleanup.sh (deflated 42%)
        !           233:       adding: update/install/scripts/clearsc.sh (deflated 41%)
        !           234:       adding: update/install/scripts/cont.sh (deflated 53%)
        !           235:       adding: update/install/scripts/echon.sh (deflated 39%)
        !           236:       adding: update/install/scripts/fin.sh (deflated 78%)
        !           237:       adding: update/install/scripts/genpathdef.sh (deflated 66%)
        !           238:       adding: update/install/scripts/intro_l.sh (deflated 80%)
        !           239:       adding: update/install/scripts/intro_s.sh (deflated 85%)
        !           240:       adding: update/install/scripts/lm.sh (deflated 81%)
        !           241:       adding: update/install/scripts/local.sh (deflated 78%)
        !           242:       adding: update/install/scripts/main.sh (deflated 68%)
        !           243:       adding: update/install/scripts/mapname.sh (deflated 54%)
        !           244:       adding: update/install/scripts/netruser.sh (deflated 62%)
        !           245:       adding: update/install/scripts/oldname.sh (deflated 53%)
        !           246:       adding: update/install/scripts/options.sh (deflated 72%)
        !           247:       adding: update/install/scripts/perm.sh (deflated 74%)
        !           248:       adding: update/install/scripts/ruser.sh (deflated 82%)
        !           249:       adding: update/install/scripts/searchp.sh (deflated 47%)
        !           250:       adding: update/install/scripts/ucleanpe.sh (deflated 63%)
        !           251:       adding: update/install/scripts/update.sh (deflated 70%)
        !           252:       adding: update/install/scripts/util.sh (deflated 70%)
        !           253:       adding: update/install/scripts/verifyp.sh (deflated 78%)
        !           254:     
        !           255: 
        !           256: to the same name. Copy to CD1, CD2 and CD3. Rinse and repeat. 
        !           257: 
        !           258:   * And that's about it. Provide a proper license.dat, and you are ready for installation. chdir to the installation directory, call the /path/to/install script from CD1, and click OK a few times. 
        !           259: 
        !           260: At the end of the installation, there is a spurious rm -f with empty argument that can safely be ignored. If you find out where it hides, please tell me. 
        !           261: 
        !           262:   * OK, there's still the license manager... 
        !           263: 
        !           264: FlexLM comes with a byzantine set of shell script tools. Of course, there is one more arch.sh to patch, this time under {MATLABHOME}/etc/util/arch.sh. Then create /usr/tmp, preferably as a symlink to /var/tmp, because FlexLM and the MLM backend have that hard-coded for logs, locks, preferences. Make sure you have got a proper license file in place - the procedure is well-documented. After that, you can either start the flexlm daemon from /etc/rc.local by using {MATLABHOME}/etc/rc.lm.glnx86 start|stop, or with the following rc.d script : 
        !           265:     
        !           266:     
        !           267:     #!/bin/sh
        !           268:     #
        !           269:     # $Id$
        !           270:     #
        !           271:     # PROVIDE: flexlm
        !           272:     # REQUIRE: DAEMON
        !           273:     
        !           274:     . /etc/rc.subr
        !           275:     
        !           276:     name="flexlm"
        !           277:     rcvar=$name
        !           278:     flexlm_user="flexlm"
        !           279:     matlabroot="/path/to/matlabr14"
        !           280:     lm_license="${matlabroot}/etc/license.dat"
        !           281:     required_files="${lm_license}"
        !           282:     command="${matlabroot}/etc/glnx86/lmgrd"
        !           283:     command_args="-c ${lm_license} -2 -p -l +/var/log/flexlmlog"
        !           284:     
        !           285:     load_rc_config $name
        !           286:     run_rc_command "$1"
        !           287:     
        !           288: 
        !           289: -- you need to create a user to run flexlm as, and own the logfile to him. 
        !           290: 
        !           291: #  Other patches 
        !           292: 
        !           293: #  arch.sh 
        !           294: 
        !           295: For whatever reason there may be, a Matlab 14 installation has three instances of the arch.sh script that works out what platform Matlab is running on: 
        !           296:     
        !           297:     
        !           298:     > find . -name arch.sh -print
        !           299:     ./bin/util/arch.sh
        !           300:     ./etc/util/arch.sh
        !           301:     ./update/install/scripts/arch.sh
        !           302:     
        !           303: 
        !           304: And (of course) the one that is sourced by {MATLABROOT}/bin/matlab is the original version which you should replace by e.g. {MATLABROOT}/etc/util/arch.sh once you get tired of adding -glnx86 to every matlab invocation. 
        !           305: 
        !           306: #  MEX 
        !           307: 
        !           308: If you want to build binary modules with mex you need to make sure those modules (libraries) are linux libraries since you cannot use native NetBSD libraries with a program running in emulation. Make sure you install the suse_devel package as listed above, and apply this patch to {MATLABROOT}/toolbox/matlab/general/mex.m. It makes sure the mex shell-script (which calls the compiler) is executed by the linux shell. 
        !           309: 
        !           310: #  Sound 
        !           311: 
        !           312: Add a symlink to the native /dev/sound like 
        !           313:     
        !           314:     
        !           315:     [hf@dreispitz] /<1>linux/dev > pwd
        !           316:     /usr/pkg/emul/linux/dev
        !           317:     [hf@dreispitz] /<1>linux/dev > ll audio 
        !           318:     0 lrwx------  1 root  wheel  13 Sep 10 03:25 audio -> /../dev/sound
        !           319:     
        !           320: 
        !           321: #  Linux pthread libs 
        !           322: 
        !           323: Matlab 13, at least, expects the pthread shared library under /usr/lib whereas NetBSD's suse*_base package installs it under /lib. You need to manually add 
        !           324:     
        !           325:     
        !           326:     [hf@dreispitz] /<2>usr/lib > ll libpthread.so*
        !           327:     0 lrwxr-xr-x  1 root  wheel  25 Jul 22 17:35 libpthread.so -> ../../lib/libpthread.so.0
        !           328:     0 lrwxr-xr-x  1 root  wheel  25 Jul 22 17:35 libpthread.so.0 -> ../../lib/libpthread.so.0
        !           329:     
        !           330: 
        !           331: #  LD_LIBRARY_PATH 
        !           332: 
        !           333: As a Linux binary, Matlab makes heavy use of the LD_LIBRARY_PATH environment variable to access shared libraries. For a shell exit, it populates LD_LIBRARY_PATH like 
        !           334:     
        !           335:     
        !           336:     >> !echo $LD_LIBRARY_PATH
        !           337:     /opt/matlabr14/sys/os/glnx86:/opt/matlabr14/bin/glnx86:/opt/matlabr14/extern/lib/glnx86:/opt/matlabr14/sys/java/jre/glnx86/jre1.5.0/lib/i386/native_threads:/opt/matlabr14/sys/java/jre/glnx86/jre1.5.0/lib/i386/client:/opt/matlabr14/sys/java/jre/glnx86/jre1.5.0/lib/i386
        !           338:     >>
        !           339:     
        !           340: 
        !           341: [NetBSD ELF](http://www.netbsd.org/Documentation/elf.html) binaries do not normally use LD_LIBRARY_PATH; instead, NetBSD compiles fixed library paths into shared libraries and applications. Nevertheless, non-setuid NetBSD binaries still look at LD_LIBRARY_PATH. The above path apparently confuses complex NetBSD binaries like NEdit, XEmacs, Mozilla, which try to pick up Linux libraries instead of the native ones. As a workaround, unset LD_LIBRARY_PATH before calling the application, either with per-application wrapper scripts, or a generic wrapper script like 
        !           342: 
        !           343: 
        !           344:     #!/bin/sh
        !           345:     unset LD_LIBRARY_PATH
        !           346:     exec "$@"
        !           347:     
        !           348: 
        !           349: #  OpenGL 
        !           350: 
        !           351: Commands like bench that use OpenGL result in a [kernel panic](http://mail-index.netbsd.org/port-i386/2005/10/07/0004.html) . Christos Zoulas has provided a [kernel patch](http://www.spg.tu-darmstadt.de/~hf/notes/matlab7_opengl.patch). It is against 2005-10-10 NetBSD-current source and applies with offsets to the netbsd-3 branch; apply from within sys/arch/i386/. 
        !           352: 
        !           353: The patch avoids the panic; what functionality exactly is missing remains to be seen. 
        !           354: 
        !           355: _Workaround_: The Matlab command opengl software enforces software rendering which is slower than using hardware support - but appears to work, unlike the latter. You still need the kernel patch, though, as any OpenGL operation will panic otherwise. 
        !           356: 
        !           357: #  Issues left 
        !           358: 
        !           359: Why Mathworks duplicate their set of install scripts everywhere and still keep a zipped copy around to drop on top of the installation is beyond me. The diffs above are clean and minimal - it's just that you have to have five instances of each. 
        !           360: 
        !           361:   
        !           362: --Hauke Fath 
        !           363: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb