3 # Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 # Copyright (C) INRIA - 2006-2008 - Sylvestre Ledru
5 # Copyright (C) INRIA - 2008 - Simon Lipp
6 # Copyright (C) DIGITEO - 2009-2011 - Sylvestre Ledru
7 # Copyright (C) DIGITEO - 2010-2011 - Bruno JOFRET
8 # Copyright (C) 2012 - 2016 - Scilab Enterprises
10 # This file is hereby licensed under the terms of the GNU GPL v2.0,
11 # pursuant to article 5.3.4 of the CeCILL v.2.1.
12 # This file was originally licensed under the terms of the CeCILL v2.1,
13 # and continues to be available under such terms.
14 # For more information, see the COPYING file which you should have received
15 # along with this program.
19 # Scilab can be installed/used in different ways :
20 # * ./configure; make install
21 # => will install Scilab into /usr/local/ and split files to
22 # /usr/local/bin, /usr/local/share/scilab/, /usr/local/lib/scilab/,
23 # /usr/local/include/scilab/
24 # * ./configure --prefix=/my/dir/; make install
25 # => will install Scilab into /my/dir/ and split files to
26 # /my/dir/bin/, /my/dir/share/scilab/, /my/dir/lib/scilab/
27 # /my/dir/include/scilab/
28 # Scilab official binary uses this arch
29 # * ./configure; make install prefix=$(DESTDIR)/usr \
30 # bindir=$(DESTDIR)/usr/bin \
31 # datadir=$(DESTDIR)/usr/share/scilab ...
32 # Solution used mainly by Linux packagers
34 ## First, this script will look for scilab-bin in :
35 # * If specified, in the $SCI variable
36 # * Into the scilab/bin/ directory
37 # * Into the scilab/ directory (if the user is using a source version and
38 # scilab has been compiled in this directory)
39 # * if this file is a symlink to the real one. We browse symlink(s) until we
40 # find the real "scilab" script file and consider that it is the right
42 # * That is all. Don't hesitate to contact us if you see one missing.
46 if test ! -z "$SCIVERBOSE"; then
52 if test -n "$SCI"; then
53 if test ! -d "$SCI/modules"; then
54 echo "Cannot find directory $SCI/modules/ !"
55 echo "SCI should point to the root data directory of Scilab"
60 DISABLE_JAVA_DETECTION=0
64 if test -n "$DEVENV"; then
65 echo "Running debug of Scilab [gdb] : " "$SCI"/libtool --mode=execute gdb $SCILAB_GDB_OPT --args "$SCILABBIN" "$@"
66 "$SCI"/libtool --mode=execute gdb $SCILAB_GDB_OPT --args "$SCILABBIN" "$@"
68 echo "Running debug of Scilab [gdb] : " gdb $SCILAB_GDB_OPT --args "$SCILABBIN" "$@"
69 gdb $SCILAB_GDB_OPT --args "$SCILABBIN" "$@"
74 if test -n "$DEVENV"; then
75 echo "Running debug of Scilab [kdbg] : " "$SCI"/libtool --mode=execute kdbg "$SCILABBIN"
76 "$SCI"/libtool --mode=execute kdbg "$SCILABBIN"
78 echo "Running debug of Scilab [kdbg] : " kdbg "$SCILABBIN"
84 VALGRIND_OPTIONS=" --show-below-main=yes --num-callers=16 --demangle=yes --leak-check=full --show-reachable=yes --smc-check=all --show-below-main=yes --track-origins=yes --suppressions=$SCI/tools/profiling/valgrind.supp $SCILAB_VALGRIND_OPT"
85 if test -n "$DEVENV"; then
86 echo "Running profiling of Scilab : " "$SCI"/libtool --mode=execute valgrind $VALGRIND_OPTIONS "$SCILABBIN" "$@"
87 "$SCI"/libtool --mode=execute valgrind $VALGRIND_OPTIONS "$SCILABBIN" "$@"
89 echo "Running profiling of Scilab : " valgrind $VALGRIND_OPTIONS "$SCILABBIN" "$@"
90 valgrind $VALGRIND_OPTIONS "$SCILABBIN" "$@"
95 start_profiling_visu() {
96 VALGRIND_VISU_OPTIONS=" --tool=callgrind --trace-children=yes --smc-check=all --trace-jump=yes --dump-line=yes --separate-threads=yes $SCILAB_VALGRIND_OPT"
98 if test -n "$DEVENV"; then
99 echo "Running profiling visualization of Scilab : " "$SCI"/libtool --mode=execute valgrind $VALGRIND_VISU_OPTIONS "$SCILABBIN" "$@"
100 "$SCI"/libtool --mode=execute valgrind $VALGRIND_VISU_OPTIONS "$SCILABBIN" "$@"
102 echo "Running profiling visualization of Scilab : " valgrind $VALGRIND_VISU_OPTIONS "$SCILABBIN" "$@"
103 valgrind $VALGRIND_VISU_OPTIONS "$SCILABBIN" "$@"
107 find_docbook_path() {
108 if test -z "$DOCBOOK_ROOT"; then
109 for dir in $SCI/thirdparty/docbook /usr/share/sgml/docbook/stylesheet/xsl/nwalsh /usr/share/docbook2X/xslt/man/ /usr/share/xml/docbook/stylesheet/nwalsh/ /usr/share/xml/docbook/stylesheet/nwalsh/current/ /sw/share/xml/xsl/docbook-xsl /usr/share/xml/docbook/xsl-stylesheets-*/ /usr/share/sgml/docbook/xsl-stylesheets-*/ /usr/share/sgml/docbook/xsl-stylesheets /usr/share/sgml/docbook/xsl-ns-stylesheets-*/ /usr/share/xml/docbook/stylesheet/docbook-xsl /opt/local/share/xsl/docbook-xsl; do
110 if test -r "$dir/fo/docbook.xsl"; then
111 if test -z "$DOCBOOK_ROOT"; then
118 if test $SCIVERBOSE -ne 0; then
119 echo "DOCBOOK : $DOCBOOK_ROOT"
123 detect_type_of_scilab(){
127 SCILABBIN="scilab-bin"
129 if (echo "$progname"|grep "scilab-adv-cli$" 2>&1 > /dev/null;) || (echo "$@"|grep "\-nw" 2>&1 > /dev/null;) then
131 # We are using scilab-bin here because we are going to force the arg -nw
132 SCILABBIN="scilab-bin"
135 if (echo "$progname"|grep "scilab-cli$" 2>&1 > /dev/null;) || (echo "$@"|grep "\-nwni" 2>&1 > /dev/null;) then
137 SCILABBIN="scilab-cli-bin"
138 DISABLE_JAVA_DETECTION=1
141 if (echo "$progname"|grep "scinotes$" 2>&1 > /dev/null;) then
142 SCILAB_MODE="scinotes"
143 SCILABBIN="scilab-bin"
147 if (echo "$progname"|grep "xcos$" 2>&1 > /dev/null;) then
149 SCILABBIN="scilab-bin"
153 if test $SCIVERBOSE -ne 0; then
154 echo "SCILABBIN : $SCILABBIN"
155 echo "DISABLE_JAVA_DETECTION : $DISABLE_JAVA_DETECTION"
156 echo "SCILAB_MODE : $SCILAB_MODE"
162 if test "${OS}" = ""; then
163 OS=$(uname -s) # Retrieve the Operating System
165 if test "${MODEL}" = ""; then
166 MODEL=$(uname -m) # Retrieve the model
169 if test $SCIVERBOSE -ne 0; then
171 echo "MODEL : $MODEL"
175 detect_type_of_scilab $@
179 detect_scilab_path() {
183 # If we are running Scilab binary, it is trivial to set paths.
184 curdir=$(dirname "$progname")
186 # If the script is a symlink, it might be a symlink to the Scilab binary
187 # We could run into the bug #9125
188 if test -h $progname; then
189 while test -h "$progname"; do
190 bn=$(basename "$progname")
191 cd $(dirname "$progname")
193 # Browse the symlink to the real one
194 progname=$(/bin/ls -l "$bn" | sed -e 's/^.* -> //' )
196 if test ! -x "$progname"; then
200 cd $(dirname "$progname")
204 if test -d $curdir/../thirdparty/ -a -d $curdir/../share/scilab; then
205 # We are in the Scilab binary
207 # export the bin directory to the PATH first (avoid to take the packaged version)
211 SCI=$SCIBINARYBASE/share/scilab
216 # Use scilab-bin in the current dir if it exists
217 # If not, then start resolving symlinks until we find scilab-bin
219 cd $(dirname "$progname")
223 progbase=$(basename "$progname")
224 run_sci="$curdir/$SCILABBIN"
225 if test -x "$run_sci"; then # scilab-bin is in the /bin/ directory
231 run_sci="$curdir/../$SCILABBIN"
232 if test -x "$run_sci"; then # scilab-bin is in the / directory
233 # which is the case in a dev env
240 while test -h "$progname"; do
241 bn=$(basename "$progname")
242 cd $(dirname "$progname")
243 # Browse the symlink to the real one
244 progname=$(/bin/ls -l "$bn" | sed -e 's/^.* -> //' )
245 if test ! -x "$progname"; then
248 curdir=$(dirname "$progname")
249 if test -x "$curdir"; then
252 SCIBIN="$curdir/$SCILABBIN"
257 # The current file ($0), probably scilab is a symlink to the
258 # real one and here, it is the dev env
259 run_sci="$curdir/../$SCILABBIN"
260 if test -x "$run_sci"; then
270 if test $SCIVERBOSE -ne 0; then
271 echo "I think I found Scilab here : $SCI"
276 if test -x "$SCI/bin/$SCILABBIN"; then
278 SCILABBIN=$SCI/bin/$SCILABBIN
279 SCI=$SCI/share/scilab/
281 if test -x "$SCI/$SCILABBIN"; then
283 SCILABBIN=$SCI/$SCILABBIN
285 # add modelica in the path
286 PATH="$PATH:$SCI/modules/scicos/"
288 echo "Cannot find $SCILABBIN ..."
297 set_macosx_java_vm () {
298 # For Mac OS X, Since path are different from the JVM normal tree,
299 # don't need to detect the CPU
300 JAVA_SHLIB="libjava.jnilib"
301 if test -z "$JAVA_HOME"; then
302 JAVA_HOME=$(/usr/libexec/java_home --arch x86_64 --failfast --version 1.8+)
304 JAVA_JVM_VERSION=$JAVA_HOME
305 export JAVA_JVM_VERSION
306 DYLD_LIBRARY_PATH="$JAVA_HOME/../Libraries${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
310 set_embedded_java_vm () {
312 # Scilab binary => no Java detection since we are using the embeded JRE
313 # Here, we are handling 3 cases: GNU/Linux 32bit, GNU/Linux 64bit,
322 # We embed java/lib/i386 with Scilab Binary
323 # force proc to i386 even if systems answer i686
327 echo "Could not find the Java configuration for the model <${MODEL}>. Please contact us on http://bugzilla.scilab.org"
331 *darwin* | *Darwin*) # MacOS X
332 # JRE is now embedded in Mac OS X binary version
334 JAVA_HOME=$SCIBINARYBASE/thirdparty/java/Contents/Home/
335 JAVA_JVM_VERSION=$JAVA_HOME
336 export JAVA_JVM_VERSION
337 DYLD_LIBRARY_PATH="$JAVA_HOME/lib/server:${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
340 echo "Could not find the Java configuration for the OS <${OS}>. Please contact us or submit a bug report with your detailed configuration http://bugzilla.scilab.org/"
341 echo "Fallback on the model <${MODEL}> found by uname -m"
345 JRE_HOME="$SCIBINARYBASE/thirdparty/java/"
349 # If enabled, disable se_linux
350 check_and_disable_selinux() {
351 if test -x /usr/sbin/selinuxenabled -a $IS_SCILAB_BINARY -eq 1; then
352 /usr/sbin/selinuxenabled
354 if test $SCIVERBOSE -ne 0; then
355 echo "Disabling SELinux on Scilab"
358 JVMLIB_32=$SCIBINARYBASE/java/lib/i386/server/libjvm.so
359 if test -f $JVMLIB_32; then
360 /usr/bin/chcon -t textrel_shlib_t "$JVMLIB_32"
361 if test $? != 0; then
362 echo "Error: Cannot chcon $JVMLIB_32"
365 JVMLIB_64=$SCIBINARYBASE/java/lib/amd64/server/libjvm.so
366 if test -f $JVMLIB_64; then
367 /usr/bin/chcon -t textrel_shlib_t "$JVMLIB_64"
368 if test $? != 0; then
369 echo "Error: Cannot chcon $JVMLIB_64"
372 /usr/bin/chcon -t execmem_exec_t "$SCIBINARYBASE/bin/scilab-bin"
373 if test $? != 0; then
374 echo "Error: Cannot chcon 'scilab-bin'"
377 /usr/bin/chcon -t execmem_exec_t "$SCIBINARYBASE/bin/scilab-cli-bin"
378 if test $? != 0; then
379 echo "Error: Cannot chcon 'scilab-cli-bin'"
388 JAVA_SHLIB="libjava.so"
390 if test $IS_SCILAB_BINARY -eq 1; then
392 else # NOT IS_SCILAB_BINARY
394 ############# JAVA DETECTION ##############
395 # Basic inspiration from Eclipse
397 # Scilab is looking for Java in various places with different ways :
398 # * if JAVA_HOME is specificed, use it
399 # * Check in 'standard' places we know Java could be installed
400 # if some are missing, please contact us
401 # * look in the PATH if there is a java binary
402 # if it is the case, resolve the symlink and set the JAVA_HOME from it
404 # Once we have JAVA_HOME, we check that native libraries (libjava.so and
405 # 2 others) are available
408 # Get the proc name matching to the one of the JVM
409 # Inspiration and data are from http://www.google.com/codesearch?hl=en&q=+java+ppc+libjava.so+show:a78sz0SP41k:zxNozD-vc0A:FWiIy7Hinmg&sa=N&cd=2&ct=rc&cs_p=http://fresh.t-systems-sfr.com/unix/src/misc/tclBlendSrc1.2.5.tar.gz&cs_f=tclBlend1.2.5/configure.in#a0
410 # For Mac OS X, we will get stuff like that:
411 # uname -s Power Macintosh
414 # If the user has the variable JAVA_HOME in the ENV
415 if test -n "$JAVA_HOME" ; then
416 if test $SCIVERBOSE -ne 0; then
417 echo "Using specified vm: $JAVA_HOME"
419 if test ! -x "$JAVA_HOME/bin/java" ; then
420 echo "Cannot find $JAVA_HOME/bin/java"
428 if test $SCIVERBOSE -ne 0; then
429 echo "Using default Mac OS X vm: $JAVA_HOME"
430 echo "And LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
431 echo "And DYLD_LIBRARY_PATH: $DYLD_LIBRARY_PATH"
438 # Browse "default directory" (if it means anything under Unix/Linux) of Java
439 # to find where it could be !
440 if test -z "$JAVA_HOME"; then
441 JAVA_DEFAULT_DIR="/usr/java/jdk1.8.*/ /usr/lib/jvm/java-1.8.0-*/ /usr/lib/jvm/java-8-*/ /etc/alternatives/java_sdk /etc/alternatives/jre /usr/java/jdk*/ /usr/lib/jvm/java-*/"
442 for DIR in $JAVA_DEFAULT_DIR ; do
443 if test $SCIVERBOSE -ne 0; then
444 echo "Trying to find Java in $DIR "
446 if test -x "${DIR}/bin/java" ; then
447 # resolve symlinked dir
453 if test $SCIVERBOSE -ne 0; then
454 echo "Java found in $JAVA_HOME"
461 # if JAVA_HOME still haven't been found. Well, we can now try to find it in the path
462 if test ! -d "$JAVA_HOME"; then
465 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
466 if test $SCIVERBOSE -ne 0; then
467 echo "Look for the java binary in the PATH. If it is a symlink, try to resolve it"
470 if test -f $DIR/java; then
474 # Will probably bug if a file contains -> in the name
475 while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
476 _cur=$(ls -ld "$_cur" | sed 's/.* -> //')
478 # symlink resolved to the real file
480 # Now, create JAVA_HOME
482 JAVA_HOME=$(dirname $TMP)
483 if test ! -z "$JAVA_HOME"; then
491 if test ! -z "$JAVA_HOME"; then
492 if test $SCIVERBOSE -ne 0; then
493 echo "JAVA_HOME : $JAVA_HOME"
495 # Manage JRE & JDK because libjava.so and others are stored in the JRE
496 if test -d $JAVA_HOME/jre; then
497 JRE_HOME=$JAVA_HOME/jre
501 # Configuring LD_LIBRARY_PATH for libjava.so libhpi.so and libxxxx.so
511 if test -d ${JRE_HOME}/lib/$(uname -m) ; then
529 mips*) # under mipsel, uname -m is
530 # usually returning mips or mips64...
531 # but binary are in mipsel
532 if test -d ${JRE_HOME}/lib/mipsel ; then
557 echo "Could not find the Java configuration for the model <${MODEL}>. Please contact us on http://bugzilla.scilab.org"
562 JAVA_SHLIB="libjava.sl"
563 proc="lib" # TODO : check if it is right or not ... seems not !
570 "i86pc") # solaris x86
573 # check for the 64 bits syntax
578 echo "Could not find the Java configuration for the model <${MODEL}>. Please contact us."
583 *win32* | *WIN32* | *CYGWIN_NT*)
587 *darwin* | *Darwin*) # MacOS X
594 echo "Could not find the Java configuration for the OS <${OS}>. Please contact us or submit a bug report with your detailed configuration http://bugzilla.scilab.org/"
595 echo "Fallback on the model <${MODEL}> found by uname -m"
599 fi # JAVA_HOME provided or found
600 fi # IS_SCILAB_BINARY
602 # Check if the lib exists
603 LIBJAVA="$JRE_HOME/lib/$proc/$JAVA_SHLIB"
604 if test ! -f $LIBJAVA; then
605 if test $SCIVERBOSE -ne 0; then
606 echo "Cannot find $LIBJAVA"
609 CLASSPATH="${CLASSPATH:+:$CLASSPATH}$SCI/modules/core/jar/org.scilab.modules.core.jar"
610 # @TODO This is the default path of the official sun JVM.
611 # It is different for other implementation of the JVM....
612 LD_LIBRARY_PATH="$JRE_HOME/lib/$proc/:$JRE_HOME/lib/$proc/server/:$JRE_HOME/lib/$proc/native_threads/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
615 # Bug http://bugzilla.scilab.org/show_bug.cgi?id=14290 -
616 # Never run headless on Mac (unless explicitly asked through
617 # the SCI_JAVA_ENABLE_HEADLESS option -- which will not work anyway)
619 *darwin* | *Darwin*) # MacOS X
620 export _JAVA_OPTIONS="-Djava.awt.headless=false"
624 ####### END OF JAVA ENV DETECTION/SETTING ######
628 if test $SCIVERBOSE -ne 0; then
629 echo "IS_SCILAB_BINARY : $IS_SCILAB_BINARY"
633 # If we are calling scilab-cli, no need to detect java.
634 if test $DISABLE_JAVA_DETECTION -ne 1; then
638 if test $IS_SCILAB_BINARY -eq 1; then
640 if test ! -d "$SCIBINARYBASE/thirdparty/tcl8.5"; then
641 # New packaging path (similar to Windows one)
642 TCL_LIBRARY="$SCIBINARYBASE/share/scilab/modules/tclsci/tcl/tcl8.5"
643 TK_LIBRARY="$SCIBINARYBASE/share/scilab/modules/tclsci/tcl/tk8.5"
646 TCL_LIBRARY="$SCIBINARYBASE/thirdparty/tcl8.5"
647 TK_LIBRARY="$SCIBINARYBASE/thirdparty/tk8.5"
649 LD_LIBRARY_PATH=$SCIBINARYBASE/lib/scilab:$SCIBINARYBASE/lib/thirdparty${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}:$SCIBINARYBASE/lib/thirdparty/redist
650 DOCBOOK_ROOT="$SCI/../../thirdparty/docbook"
651 PATH="$PATH:$SCI/modules/scicos/"
655 export LD_LIBRARY_PATH
661 DYLD_LIBRARY_PATH=$SCIBINARYBASE/lib/scilab:$SCIBINARYBASE/lib/thirdparty${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
662 export DYLD_LIBRARY_PATH
663 PATH="/sw/bin:/sw64/bin:$PATH"
669 # Scilab compiled using prerequirements
670 if test -d $curdir/../usr; then
671 TCL_LIBRARY="$SCI/usr/lib/tcl8.5"
672 TK_LIBRARY="$SCI/usr/lib/tk8.5"
676 PATH="$SCI:$SCI/bin:$PATH"
680 # See http://bugzilla.scilab.org/show_bug.cgi?id=3486
681 # Some Java stuff raises spurious SIGSEGV. The problem is that when bug-buddy
682 # is enabled, it catches the signal and terminate Scilab. We have to
683 # desactivate bug-buddy.
684 # See also https://bugzilla.novell.com/show_bug.cgi?id=331618
685 # and: http://bugzilla.gnome.org/show_bug.cgi?id=479929
686 GTK_MODULES=$(echo $GTK_MODULES | sed s/gnomebreakpad//g)
689 # libEGL may be partially supported by the closed-source NVIDIA driver.
690 # Until they release an EGL driver, we force the egl_glx driver.
691 # http://bugzilla.scilab.org/show_bug.cgi?id=12940
692 if test $SCILAB_MODE != "nwni" -a -x /usr/bin/glxinfo; then
693 NVIDIA_GLX_VENDOR=$(/usr/bin/glxinfo |grep "NVIDIA Corporation")
694 if test ! -z "$NVIDIA_GLX_VENDOR"; then
700 if test $SCIVERBOSE -ne 0; then
702 echo "SCIBIN : $SCIBIN"
704 echo "CLASSPATH : $CLASSPATH"
705 echo "EGL_DRIVER : $EGL_DRIVER"
708 # Returns to the original path
711 #if test "$DISPLAY" = ""; then
717 detect_macosx_version()
719 macosxVersion=`sw_vers | grep '^ProductVersion:' | grep -o '[0-9]*\.[0-9]*\.[0-9]*'`
720 if test "${macosxVersion}" = ""; then
721 macosxVersion=`sw_vers | grep '^ProductVersion:' | grep -o '[0-9]*\.[0-9]*'`
723 macosxMajorVersion=`echo $macosxVersion | cut -d . -f 1`
724 macosxMinorVersion=`echo $macosxVersion | cut -d . -f 2`
725 macosxBuildVersion=`echo $macosxVersion | cut -d . -f 3`
727 if test $SCIVERBOSE -ne 0; then
728 echo "Found MacOSX Version: $macosxVersion"
733 set_macox_specific_path()
736 PATH_TO_SPECIFIC_10_11=$SCIBINARYBASE/lib/thirdparty/10.11/
737 PATH_TO_SPECIFIC_10_10=$SCIBINARYBASE/lib/thirdparty/10.10/
738 PATH_TO_SPECIFIC_10_6=$SCIBINARYBASE/lib/thirdparty/10.6/
740 case $macosxMajorVersion in
742 case $macosxMinorVersion in
745 LD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_11${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
746 DYLD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_11${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
749 # Specific libBLAS.dylib & libLAPACK.dylib version for 10.10
750 LD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_10${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
751 DYLD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_10${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
754 # the iconv lib fails under 10.7, just declare it for 10.6
755 LD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_6${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
756 DYLD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_6${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
765 # Version checks for Mac
769 osascript $BINPATH/checkmacosx.applescript "$1" || exit 128
772 fail_macosx_too_old()
774 dialog_try_or_exit "This version of Scilab will probably fail on this system ($macosxVersion): Scilab requires 10.8.3 (Mountain Lion) or newer system."
776 check_macosx_version()
778 case $macosxMajorVersion in
780 case $macosxMinorVersion in
782 # We force to install JRE on Mavericks
783 /usr/libexec/java_home --request > /dev/null
786 # ... but not on Yosemite or El Capitan:
787 # there will be a (better) error at launch
790 if test $macosxBuildVersion -le 3; then
806 # . is used by the dynamic link. The build lib are copied into the PWD
807 SCILIB=$SCI/bin:$SCI/lib/scilab/:$SCI/lib64/scilab/:.
808 if test -d $SCI/lib/thirdparty; then
809 SCILIB=$SCI/lib/thirdparty:$SCILIB;
811 LD_LIBRARY_PATH=$SCILIB${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
814 *darwin* | *Darwin*) # MacOS X
815 # When using some packaging tools like fink which are storing the info in /sw/lib
816 LD_LIBRARY_PATH="/sw/lib/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
817 # Export the path to the Scilab lib when Scilab has been install ...
818 # to a Mac os x specific variable used by the linker before LD_LIBRARY_PATH
819 DYLD_LIBRARY_PATH=$SCI/../../lib/scilab/${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}:
820 # Crappy workaround for the dynamic load of sundials under Mac OS X
821 # in the source tree version. This does not occur in the binary
822 # thanks to the previous declaration on ../../lib/scilab
824 if test -d "$SCI/modules/scicos_blocks/.libs/"; then
825 DYLD_LIBRARY_PATH=$SCI/modules/scicos_blocks/.libs/${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}
827 if test -d "$SCI/modules/scicos/.libs/"; then
828 DYLD_LIBRARY_PATH=$SCI/modules/scicos/.libs/${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}
830 export DYLD_LIBRARY_PATH
832 # Now, check that I can run Scilab on this version of Mac OS X and
833 # display a standard window
834 BINPATH=$(dirname $0)
835 # Do not perform the check with Scilab is started in CLI mode
837 detect_macosx_version
838 set_macox_specific_path
840 if test "$SCILAB_MODE" = "gui"; then
844 # When started as an Application, the default path was "/"
845 # It is not really useful. Changing to HOME.
846 # See bugs 8339 and 10575 for rational
847 if test "$(pwd)" = "/"; then
856 if test $SCIVERBOSE -ne 0; then
857 echo "LD_LIBRARY_PATH : $LD_LIBRARY_PATH"
858 if test ! -z "$DYLD_LIBRARY_PATH"; then
859 echo "DYLD_LIBRARY_PATH: $DYLD_LIBRARY_PATH"
862 export LD_LIBRARY_PATH
865 # Scilab does not support the LANGUAGE variable.
866 # Unset to avoid some weird issue. CF bug #10032
869 if test $IS_SCILAB_BINARY -ne 1; then
870 # We are not using the Scilab binary, find out where docbook is.
874 # Check if SELINUX is enable. If it is the case, disable it for Scilab
875 check_and_disable_selinux
880 if test $# -gt 0; then
881 # scinotes is called. We process the arguments
884 for SCIARG in "$@"; do
885 if test "$SCIARG" = "-indent"; then
886 INDENT="['indent','trailing','quote']"
888 ARGS="$ARGS '$SCIARG' "
894 if test -n "$INDENT"; then
895 # Call scinotes with the arguments
896 if test $SCIVERBOSE -ne 0; then
897 echo "Will start scinotes with: $SCILABBIN -nb -nw -e scinotes($ARGS, $INDENT);exit()"
899 "$SCILABBIN" -nb -nw -e "scinotes($ARGS, $INDENT);exit()"
901 if test $SCIVERBOSE -ne 0; then
902 echo "Will start scinotes with: $SCILABBIN -e scinotes($ARGS)"
905 # Call scinotes with no argument
906 "$SCILABBIN" -e "scinotes($ARGS)"
914 if test $# -gt 0; then
915 # xcos is called. We process the arguments
917 for SCIARG in "$@"; do
918 if test "$SCIARG" = "-simulate"; then
919 if test $# -ne 2; then
920 echo "Wrong syntax: When -simulate is used, only one file must be provided."
925 ARGS="$ARGS '$SCIARG' "
931 if test $SIMULATE -eq 1; then
932 if test $SCIVERBOSE -ne 0; then
933 echo "Will start Xcos with: $SCILABBIN -e 'importXcosDiagram($ARGS);xcos_simulate(scs_m, 4)'"
936 # Call xcos with the arguments to simulate
937 "$SCILABBIN" -e "importXcosDiagram($ARGS);xcos_simulate(scs_m, 4)"
939 if test $SCIVERBOSE -ne 0; then
940 echo "Will start Xcos with: $SCILABBIN -e xcos($ARGS)"
943 # Call xcos with the arguments
944 "$SCILABBIN" -e "xcos($ARGS)"
952 if test "$SCILAB_MODE" = "xcos"; then
955 if test "$SCILAB_MODE" = "scinotes"; then
966 if test "$SCILAB_MODE" = "xcos"; then
967 echo "Start Xcos, the hybrid simulator"
969 echo "xcos [ file1.xcos, [ file2.xcos ]]"
971 echo " Possible arguments are:"
972 echo " -simulate : Start the simulation. Only one file will be accepted."
975 if test "$SCILAB_MODE" = "scinotes"; then
976 echo "Start Scinotes, the Scilab text editor"
978 echo "scinotes [ file1.sci, [ file2.sce ]]"
980 echo " Possible arguments are:"
981 echo " -indent : format (indent, trailing spaces, quote mismatch) the files"
986 echo "scilab <arguments>"
987 echo "scilab-cli <arguments>"
988 echo "scilab-adv-cli <arguments>"
990 echo " Possible arguments are:"
991 echo " -display Display: for use under Xwindow systems to set a specific X server display."
992 echo " -d Display : equivalent to -display Display."
993 echo " -e Instruction : execute the scilab instruction given in Instruction argument."
994 echo " -e and -f arguments are mutually exclusive."
995 echo " -f File : execute the scilab script given in File argument."
996 echo " -e and -f arguments are mutually exclusive."
997 echo " -quit : force scilab exit after execution of script from -e or -f argument."
998 echo " this flag is ignored if it is not used with -e or -f argument."
999 echo " -l Lang : set the current language. Lang can be equal to fr or en."
1000 echo " -nb : do not display Scilab loading on start."
1001 echo " -ns : do not execute scilab.start startup file. This argument will disable many features in Scilab (Only use if you know what you are doing)."
1002 echo " -nouserstartup : do not execute the user startup files SCIHOME/.scilab or SCIHOME/scilab.ini."
1003 echo " -noatomsautoload: do not load ATOMS installed module."
1004 echo " -nw : start Scilab without dedicated Scilab Window."
1005 echo " -nwni : start Scilab without the GUI, graphic and help features (batch mode). This argument disables the need of Java."
1006 echo " -nogui : See -nwni"
1007 echo " -nocolor : Remove the color in the cli and adv-cli modes"
1008 echo " -args : accept all extra arguments and make them available through sciargs"
1009 echo " -version : print product version and exit."
1010 echo " -h/--help : display help about this command."
1011 echo " --texmacs : reserved for TeXMacs."
1014 echo "Developer arguments:"
1015 echo " -debug : Start Scilab under gdb (Unix/linux only)."
1016 echo " define the variable SCILAB_GDB_OPT to add custom arguments to gdb."
1017 echo " -debug-kdbg : Start Scilab under kdbg (Unix/linux only)."
1018 echo " -profiling : Start Scilab under valgrind (Unix/linux only)."
1019 echo " define the variable SCILAB_VALGRIND_OPT to add custom arguments to"
1020 echo " valgrind (and override the existing valgrind arguments)."
1021 echo " -profiling-visu : Start Scilab under callgrind (Unix/linux only)."
1022 echo " define the variable SCILAB_VALGRIND_OPT to add custom arguments to"
1023 echo " callgrind (and override the existing callgrind arguments)."
1024 echo " -disable-exception-catching : Disable Scilab exception catching system."
1026 echo " --parse-file File : Only parse File argument without execution and exit."
1027 echo " --parse-trace : Display bison state machine evolution."
1028 echo " --AST-trace : Display ASCII-art AST to be human readable."
1029 echo " --pretty-print : Display pretty-printed code, standard Scilab syntax."
1031 echo "Developer Timer arguments:"
1032 echo " --AST-timed : Time each AST node."
1033 echo " --timed : Time global execution."
1035 echo "Developer Debug arguments:"
1036 echo " --no-exec : Only do Lexing/parsing do not execute instructions."
1037 echo " --context-dump : Display context status."
1038 echo " --exec-verbose : Display command before execute it."
1039 echo " --timeout delay : Kill the Scilab process after a delay (s, m, h, d)."
1041 echo " All these arguments can be retrieved by the Scilab function sciargs."
1044 echo " Several environment variables can be declared:"
1045 echo " SCIVERBOSE Provides debugging information of the startup"
1046 echo " JAVA_HOME Declares which Java Virtual Machine to use"
1047 echo " SCI_DISABLE_TK Disables Tk (but not Tcl) features"
1048 echo " SCI_JAVA_ENABLE_HEADLESS Runs Java Headless VM (without GUI; Windows and Linux only)"
1049 echo " SCI_DISABLE_EXCEPTION_CATCHING Disable the catch by Scilab of exception (segfault, ...)"
1055 if test "$SCILAB_MODE" = "nw"; then
1059 # calling Scilab with no argument or special cases of calling Scilab
1062 0) # No arg, run Scilab
1074 # really calling Scilab with arguments
1076 if test "$rest" = "yes"; then
1085 # If the previous argument needs an argument, skip current one.
1086 if test -n "$prevarg"; then
1092 -nogui|-version|-ns|-nb|-nouserstartup|-noatomsautoload|-nocolor|--texmacs)
1095 if test "$SCILAB_MODE" = "nwni"; then
1096 echo "Cannot use scilab-cli with option -nw"
1101 if test "$SCILAB_MODE" = "nw"; then
1102 echo "Cannot use scilab-adv-cli with option -nwni"
1106 --parse-trace|--pretty-print|--help|--AST-trace|--no-exec|--context-dump|--exec-verbose|--timed|--AST-timed|--serialize|-quit)
1107 #This are Scilab6 dedicated options.
1110 #This are Scilab6 dedicated options with an argument
1114 # Under Mac OS X, .app is adding the arg -psn_0_xxxx
1115 # (psn = ProcessSerialNumber). It is not used (but could be in the future)
1117 -display|-f|-l|-e|-d|--parse-file)
1120 -args) # Accept extra arguments
1127 DEBUG_KDBG="-debug-kdbg"
1130 PROFILING="-profiling"
1133 PROFILING_VISU="-profiling-visu"
1135 -disable-exception-catching)
1136 SCI_DISABLE_EXCEPTION_CATCHING=1
1137 export SCI_DISABLE_EXCEPTION_CATCHING
1145 # Do nothing. Gives unknown args to Scilab binaries if -args is provided
1151 # If the argument -a is not provided (extraarg) and we found unknown args
1152 # fail and provide help
1153 if test -z "$extraarg" -a -n "$foundUnknownArg"; then
1154 echo "Unknown argument: $wrongArg"
1159 if test -n "$DEBUG"; then
1160 start_debug "$@" $MORE_OPT
1162 if test -n "$DEBUG_KDBG"; then
1163 start_debug_kdbg "$@" $MORE_OPT
1165 if test -n "$PROFILING"; then
1166 start_profiling "$@" $MORE_OPT
1168 if test -n "$PROFILING_VISU"; then
1169 start_profiling_visu "$@" $MORE_OPT
1171 do_scilex "$@" $MORE_OPT
1172 fi # not profiling visu