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
75 if test -n "$DEVENV"; then
76 echo "Running debug of Scilab [$DEBUG_CMD] : " "$SCI"/libtool --mode=execute $DEBUG_CMD $SCILAB_GDB_OPT $DEBUG_ARGS "$SCILABBIN" "$@"
77 "$SCI"/libtool --mode=execute $DEBUG_CMD $SCILAB_GDB_OPT $DEBUG_ARGS "$SCILABBIN" "$@"
79 echo "Running debug of Scilab [$DEBUG_CMD] : " $DEBUG_CMD $SCILAB_GDB_OPT $DEBUG_ARGS "$SCILABBIN" "$@"
80 $DEBUG_CMD $SCILAB_GDB_OPT $DEBUG_ARGS "$SCILABBIN" "$@"
85 if test -n "$DEVENV"; then
86 echo "Running debug of Scilab [kdbg] : " "$SCI"/libtool --mode=execute kdbg "$SCILABBIN"
87 "$SCI"/libtool --mode=execute kdbg "$SCILABBIN"
89 echo "Running debug of Scilab [kdbg] : " kdbg "$SCILABBIN"
95 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"
96 if test -n "$DEVENV"; then
97 echo "Running profiling of Scilab : " "$SCI"/libtool --mode=execute valgrind $VALGRIND_OPTIONS "$SCILABBIN" "$@"
98 "$SCI"/libtool --mode=execute valgrind $VALGRIND_OPTIONS "$SCILABBIN" "$@"
100 echo "Running profiling of Scilab : " valgrind $VALGRIND_OPTIONS "$SCILABBIN" "$@"
101 valgrind $VALGRIND_OPTIONS "$SCILABBIN" "$@"
106 start_profiling_visu() {
107 VALGRIND_VISU_OPTIONS=" --tool=callgrind --trace-children=yes --smc-check=all --trace-jump=yes --dump-line=yes --separate-threads=yes $SCILAB_VALGRIND_OPT"
109 if test -n "$DEVENV"; then
110 echo "Running profiling visualization of Scilab : " "$SCI"/libtool --mode=execute valgrind $VALGRIND_VISU_OPTIONS "$SCILABBIN" "$@"
111 "$SCI"/libtool --mode=execute valgrind $VALGRIND_VISU_OPTIONS "$SCILABBIN" "$@"
113 echo "Running profiling visualization of Scilab : " valgrind $VALGRIND_VISU_OPTIONS "$SCILABBIN" "$@"
114 valgrind $VALGRIND_VISU_OPTIONS "$SCILABBIN" "$@"
118 find_docbook_path() {
119 if test -z "$DOCBOOK_ROOT"; then
120 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
121 if test -r "$dir/fo/docbook.xsl"; then
122 if test -z "$DOCBOOK_ROOT"; then
129 if test $SCIVERBOSE -ne 0; then
130 echo "DOCBOOK : $DOCBOOK_ROOT"
134 detect_type_of_scilab(){
138 SCILABBIN="scilab-bin"
140 if (echo "$progname"|grep "scilab-adv-cli$" 2>&1 > /dev/null;) || (echo "$@"|grep "\-nw" 2>&1 > /dev/null;) then
142 # We are using scilab-bin here because we are going to force the arg -nw
143 SCILABBIN="scilab-bin"
146 if (echo "$progname"|grep "scilab-cli$" 2>&1 > /dev/null;) || (echo "$@"|grep "\-nwni" 2>&1 > /dev/null;) then
148 SCILABBIN="scilab-cli-bin"
149 DISABLE_JAVA_DETECTION=1
152 if (echo "$progname"|grep "scinotes$" 2>&1 > /dev/null;) then
153 SCILAB_MODE="scinotes"
154 SCILABBIN="scilab-bin"
158 if (echo "$progname"|grep "xcos$" 2>&1 > /dev/null;) then
160 SCILABBIN="scilab-bin"
164 if test $SCIVERBOSE -ne 0; then
165 echo "SCILABBIN : $SCILABBIN"
166 echo "DISABLE_JAVA_DETECTION : $DISABLE_JAVA_DETECTION"
167 echo "SCILAB_MODE : $SCILAB_MODE"
173 if test "${OS}" = ""; then
174 OS=$(uname -s) # Retrieve the Operating System
176 if test "${MODEL}" = ""; then
177 MODEL=$(uname -m) # Retrieve the model
180 if test $SCIVERBOSE -ne 0; then
182 echo "MODEL : $MODEL"
186 detect_type_of_scilab $@
191 detect_scilab_path() {
195 # If we are running Scilab binary, it is trivial to set paths.
196 curdir=$(dirname "$progname")
198 # If the script is a symlink, it might be a symlink to the Scilab binary
199 # We could run into the bug #9125
200 if test -h "$progname"; then
201 while test -h "$progname"; do
202 bn=$(basename "$progname")
203 cd $(dirname "$progname")
205 # Browse the symlink to the real one
206 progname=$(/bin/ls -l "$bn" | sed -e 's/^.* -> //' )
208 if test ! -x "$progname"; then
212 cd $(dirname "$progname")
216 if test -d "$curdir/../thirdparty/" -a -d "$curdir/../share/scilab"; then
217 # We are in the Scilab binary
219 # export the bin directory to the PATH first (avoid to take the packaged version)
223 SCI=$SCIBINARYBASE/share/scilab
228 # Use scilab-bin in the current dir if it exists
229 # If not, then start resolving symlinks until we find scilab-bin
231 cd $(dirname "$progname")
235 progbase=$(basename "$progname")
236 run_sci="$curdir/$SCILABBIN"
237 if test -x "$run_sci"; then # scilab-bin is in the /bin/ directory
243 run_sci="$curdir/../$SCILABBIN"
244 if test -x "$run_sci"; then # scilab-bin is in the / directory
245 # which is the case in a dev env
252 while test -h "$progname"; do
253 bn=$(basename "$progname")
254 cd $(dirname "$progname")
255 # Browse the symlink to the real one
256 progname=$(/bin/ls -l "$bn" | sed -e 's/^.* -> //' )
257 if test ! -x "$progname"; then
260 curdir=$(dirname "$progname")
261 if test -x "$curdir"; then
264 SCIBIN="$curdir/$SCILABBIN"
269 # The current file ($0), probably scilab is a symlink to the
270 # real one and here, it is the dev env
271 run_sci="$curdir/../$SCILABBIN"
272 if test -x "$run_sci"; then
282 if test $SCIVERBOSE -ne 0; then
283 echo "I think I found Scilab here : $SCI"
288 if test -x "$SCI/bin/$SCILABBIN"; then
290 SCILABBIN=$SCI/bin/$SCILABBIN
291 SCI=$SCI/share/scilab/
293 if test -x "$SCI/$SCILABBIN"; then
295 SCILABBIN=$SCI/$SCILABBIN
297 # add modelica in the path
298 PATH="$PATH:$SCI/modules/scicos/"
300 echo "Cannot find $SCILABBIN ..."
309 set_macosx_java_vm () {
310 # For Mac OS X, Since path are different from the JVM normal tree,
311 # don't need to detect the CPU
312 JAVA_SHLIB="libjava.jnilib"
313 if test -z "$JAVA_HOME"; then
314 JAVA_HOME=$(/usr/libexec/java_home --arch x86_64 --failfast --version 1.8+)
316 JAVA_JVM_VERSION=$JAVA_HOME
317 export JAVA_JVM_VERSION
318 DYLD_LIBRARY_PATH="$JAVA_HOME/../Libraries${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
322 set_embedded_java_vm () {
324 # Scilab binary => no Java detection since we are using the embeded JRE
325 # Here, we are handling 3 cases: GNU/Linux 32bit, GNU/Linux 64bit,
334 # We embed java/lib/i386 with Scilab Binary
335 # force proc to i386 even if systems answer i686
339 echo "Could not find the Java configuration for the model <${MODEL}>. Please contact us on http://bugzilla.scilab.org"
343 *darwin* | *Darwin*) # MacOS X
344 # JRE is now embedded in Mac OS X binary version
346 JAVA_HOME=$SCIBINARYBASE/thirdparty/java/Contents/Home/
347 JAVA_JVM_VERSION=$JAVA_HOME
348 export JAVA_JVM_VERSION
349 DYLD_LIBRARY_PATH="$JAVA_HOME/lib/server:${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
352 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/"
353 echo "Fallback on the model <${MODEL}> found by uname -m"
357 JRE_HOME="$SCIBINARYBASE/thirdparty/java/"
361 # If enabled, disable se_linux
362 check_and_disable_selinux() {
363 if test -x /usr/sbin/selinuxenabled -a $IS_SCILAB_BINARY -eq 1; then
364 /usr/sbin/selinuxenabled
366 if test $SCIVERBOSE -ne 0; then
367 echo "Disabling SELinux on Scilab"
370 JVMLIB_32=$SCIBINARYBASE/java/lib/i386/server/libjvm.so
371 if test -f "$JVMLIB_32"; then
372 /usr/bin/chcon -t textrel_shlib_t "$JVMLIB_32"
373 if test $? != 0; then
374 echo "Error: Cannot chcon $JVMLIB_32"
377 JVMLIB_64=$SCIBINARYBASE/java/lib/amd64/server/libjvm.so
378 if test -f "$JVMLIB_64"; then
379 /usr/bin/chcon -t textrel_shlib_t "$JVMLIB_64"
380 if test $? != 0; then
381 echo "Error: Cannot chcon $JVMLIB_64"
384 /usr/bin/chcon -t execmem_exec_t "$SCIBINARYBASE/bin/scilab-bin"
385 if test $? != 0; then
386 echo "Error: Cannot chcon 'scilab-bin'"
389 /usr/bin/chcon -t execmem_exec_t "$SCIBINARYBASE/bin/scilab-cli-bin"
390 if test $? != 0; then
391 echo "Error: Cannot chcon 'scilab-cli-bin'"
400 JAVA_SHLIB="libjava.so"
402 if test $IS_SCILAB_BINARY -eq 1; then
404 else # NOT IS_SCILAB_BINARY
406 ############# JAVA DETECTION ##############
407 # Basic inspiration from Eclipse
409 # Scilab is looking for Java in various places with different ways :
410 # * if JAVA_HOME is specificed, use it
411 # * Check in 'standard' places we know Java could be installed
412 # if some are missing, please contact us
413 # * look in the PATH if there is a java binary
414 # if it is the case, resolve the symlink and set the JAVA_HOME from it
416 # Once we have JAVA_HOME, we check that native libraries (libjava.so and
417 # 2 others) are available
420 # Get the proc name matching to the one of the JVM
421 # 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
422 # For Mac OS X, we will get stuff like that:
423 # uname -s Power Macintosh
426 # If the user has the variable JAVA_HOME in the ENV
427 if test -n "$JAVA_HOME" ; then
428 if test $SCIVERBOSE -ne 0; then
429 echo "Using specified vm: $JAVA_HOME"
431 if test ! -x "$JAVA_HOME/bin/java" ; then
432 echo "Cannot find $JAVA_HOME/bin/java"
440 if test $SCIVERBOSE -ne 0; then
441 echo "Using default Mac OS X vm: $JAVA_HOME"
442 echo "And LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
443 echo "And DYLD_LIBRARY_PATH: $DYLD_LIBRARY_PATH"
450 # Browse "default directory" (if it means anything under Unix/Linux) of Java
451 # to find where it could be !
452 if test -z "$JAVA_HOME"; then
453 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-*/"
454 for DIR in $JAVA_DEFAULT_DIR ; do
455 if test $SCIVERBOSE -ne 0; then
456 echo "Trying to find Java in $DIR "
458 if test -x "${DIR}/bin/java" ; then
459 # resolve symlinked dir
465 if test $SCIVERBOSE -ne 0; then
466 echo "Java found in $JAVA_HOME"
473 # if JAVA_HOME still haven't been found. Well, we can now try to find it in the path
474 if test ! -d "$JAVA_HOME"; then
477 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
478 if test $SCIVERBOSE -ne 0; then
479 echo "Look for the java binary in the PATH. If it is a symlink, try to resolve it"
482 if test -f "$DIR/java"; then
486 # Will probably bug if a file contains -> in the name
487 while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
488 _cur=$(ls -ld "$_cur" | sed 's/.* -> //')
490 # symlink resolved to the real file
492 # Now, create JAVA_HOME
494 JAVA_HOME=$(dirname $TMP)
495 if test ! -z "$JAVA_HOME"; then
503 if test ! -z "$JAVA_HOME"; then
504 if test $SCIVERBOSE -ne 0; then
505 echo "JAVA_HOME : $JAVA_HOME"
507 # Manage JRE & JDK because libjava.so and others are stored in the JRE
508 if test -d "$JAVA_HOME/jre"; then
509 JRE_HOME=$JAVA_HOME/jre
513 # Configuring LD_LIBRARY_PATH for libjava.so libhpi.so and libxxxx.so
523 if test -d "${JRE_HOME}/lib/$(uname -m)" ; then
541 mips*) # under mipsel, uname -m is
542 # usually returning mips or mips64...
543 # but binary are in mipsel
544 if test -d "${JRE_HOME}/lib/mipsel" ; then
572 echo "Could not find the Java configuration for the model <${MODEL}>. Please contact us on http://bugzilla.scilab.org"
577 JAVA_SHLIB="libjava.sl"
578 proc="lib" # TODO : check if it is right or not ... seems not !
585 "i86pc") # solaris x86
588 # check for the 64 bits syntax
593 echo "Could not find the Java configuration for the model <${MODEL}>. Please contact us."
598 *win32* | *WIN32* | *CYGWIN_NT*)
602 *darwin* | *Darwin*) # MacOS X
609 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/"
610 echo "Fallback on the model <${MODEL}> found by uname -m"
614 fi # JAVA_HOME provided or found
615 fi # IS_SCILAB_BINARY
617 # Check if the lib exists
618 LIBJAVA="$JRE_HOME/lib/$proc/$JAVA_SHLIB"
619 if test ! -f "$LIBJAVA"; then
620 if test $SCIVERBOSE -ne 0; then
621 echo "Cannot find $LIBJAVA"
624 CLASSPATH="${CLASSPATH:+:$CLASSPATH}$SCI/modules/core/jar/org.scilab.modules.core.jar"
625 # @TODO This is the default path of the official sun JVM.
626 # It is different for other implementation of the JVM....
627 LD_LIBRARY_PATH="$JRE_HOME/lib/$proc/:$JRE_HOME/lib/$proc/server/:$JRE_HOME/lib/$proc/native_threads/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
630 # Bug http://bugzilla.scilab.org/show_bug.cgi?id=14290 -
631 # Never run headless on Mac (unless explicitly asked through
632 # the SCI_JAVA_ENABLE_HEADLESS option -- which will not work anyway)
634 *darwin* | *Darwin*) # MacOS X
635 export _JAVA_OPTIONS="-Djava.awt.headless=false"
639 ####### END OF JAVA ENV DETECTION/SETTING ######
643 if test $SCIVERBOSE -ne 0; then
644 echo "IS_SCILAB_BINARY : $IS_SCILAB_BINARY"
648 # If we are calling scilab-cli, no need to detect java.
649 if test $DISABLE_JAVA_DETECTION -ne 1; then
653 if test $IS_SCILAB_BINARY -eq 1; then
655 if test ! -d "$SCIBINARYBASE/thirdparty/tcl8.5"; then
656 # New packaging path (similar to Windows one)
657 TCL_LIBRARY="$SCIBINARYBASE/share/scilab/modules/tclsci/tcl/tcl8.5"
658 TK_LIBRARY="$SCIBINARYBASE/share/scilab/modules/tclsci/tcl/tk8.5"
661 TCL_LIBRARY="$SCIBINARYBASE/thirdparty/tcl8.5"
662 TK_LIBRARY="$SCIBINARYBASE/thirdparty/tk8.5"
664 LD_LIBRARY_PATH=$SCIBINARYBASE/lib/scilab:$SCIBINARYBASE/lib/thirdparty${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}:$SCIBINARYBASE/lib/thirdparty/redist
665 DOCBOOK_ROOT="$SCI/../../thirdparty/docbook"
666 PATH="$PATH:$SCI/modules/scicos/"
670 export LD_LIBRARY_PATH
676 DYLD_LIBRARY_PATH=$SCIBINARYBASE/lib/scilab:$SCIBINARYBASE/lib/thirdparty${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
677 export DYLD_LIBRARY_PATH
678 PATH="/sw/bin:/sw64/bin:$PATH"
684 # Scilab compiled using prerequirements
685 if test -d "$curdir/../usr"; then
686 TCL_LIBRARY="$SCI/usr/lib/tcl8.5"
687 TK_LIBRARY="$SCI/usr/lib/tk8.5"
691 PATH="$SCI:$SCI/bin:$PATH"
695 # See http://bugzilla.scilab.org/show_bug.cgi?id=3486
696 # Some Java stuff raises spurious SIGSEGV. The problem is that when bug-buddy
697 # is enabled, it catches the signal and terminate Scilab. We have to
698 # desactivate bug-buddy.
699 # See also https://bugzilla.novell.com/show_bug.cgi?id=331618
700 # and: http://bugzilla.gnome.org/show_bug.cgi?id=479929
701 GTK_MODULES=$(echo $GTK_MODULES | sed s/gnomebreakpad//g)
704 # libEGL may be partially supported by the closed-source NVIDIA driver.
705 # Until they release an EGL driver, we force the egl_glx driver.
706 # http://bugzilla.scilab.org/show_bug.cgi?id=12940
707 if test $SCILAB_MODE != "nwni" -a -x /usr/bin/glxinfo; then
708 NVIDIA_GLX_VENDOR=$(/usr/bin/glxinfo |grep "NVIDIA Corporation")
709 if test ! -z "$NVIDIA_GLX_VENDOR"; then
715 if test $SCIVERBOSE -ne 0; then
717 echo "SCIBIN : $SCIBIN"
719 echo "CLASSPATH : $CLASSPATH"
720 echo "EGL_DRIVER : $EGL_DRIVER"
723 # Returns to the original path
726 #if test "$DISPLAY" = ""; then
732 detect_macosx_version()
734 macosxVersion=`sw_vers | grep '^ProductVersion:' | grep -o '[0-9]*\.[0-9]*\.[0-9]*'`
735 if test "${macosxVersion}" = ""; then
736 macosxVersion=`sw_vers | grep '^ProductVersion:' | grep -o '[0-9]*\.[0-9]*'`
738 macosxMajorVersion=`echo $macosxVersion | cut -d . -f 1`
739 macosxMinorVersion=`echo $macosxVersion | cut -d . -f 2`
740 macosxBuildVersion=`echo $macosxVersion | cut -d . -f 3`
742 if test $SCIVERBOSE -ne 0; then
743 echo "Found MacOSX Version: $macosxVersion"
748 set_macox_specific_path()
751 PATH_TO_SPECIFIC_10_13=$SCIBINARYBASE/lib/thirdparty/10.13/
752 PATH_TO_SPECIFIC_10_12=$SCIBINARYBASE/lib/thirdparty/10.12/
753 PATH_TO_SPECIFIC_10_11=$SCIBINARYBASE/lib/thirdparty/10.11/
754 PATH_TO_SPECIFIC_10_10=$SCIBINARYBASE/lib/thirdparty/10.10/
755 PATH_TO_SPECIFIC_10_6=$SCIBINARYBASE/lib/thirdparty/10.6/
757 case $macosxMajorVersion in
759 case $macosxMinorVersion in
763 # Specific libBLAS.dylib & libz versions for 10.13
764 LD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_13${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
765 DYLD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_13${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
768 # Specific libBLAS.dylib version for 10.12
769 LD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_12${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
770 DYLD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_12${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
773 # Specific libBLAS.dylib & libLAPACK.dylib version for 10.11
774 LD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_11${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
775 DYLD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_11${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
778 # Specific libBLAS.dylib & libLAPACK.dylib version for 10.10
779 LD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_10${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
780 DYLD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_10${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
783 # Run normally on 10.7, 10.8 & 10.9
786 # the iconv lib fails under 10.7, just declare it for 10.6
787 LD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_6${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
788 DYLD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_6${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
800 # Version checks for Mac
804 osascript $BINPATH/checkmacosx.applescript "$1" || exit 128
807 fail_macosx_version()
809 dialog_try_or_exit "This version of Scilab may fail on this system ($macosxVersion): Scilab is currently supported from 10.8.3 (Mountain Lion) to 10.13 (High Sierra)."
811 check_macosx_version()
813 case $macosxMajorVersion in
815 case $macosxMinorVersion in
817 # We force to install JRE on Mavericks
818 /usr/libexec/java_home --request > /dev/null
821 # ... but not on Yosemite, El Capitan, Sierra, High Sierra or Mojave:
822 # there will be a (better) error at launch
825 if test $macosxBuildVersion -le 3; then
841 # . is used by the dynamic link. The build lib are copied into the PWD
842 SCILIB=$SCI/bin:$SCI/lib/scilab/:$SCI/lib64/scilab/:.
843 if test -d "$SCI/lib/thirdparty"; then
844 SCILIB=$SCI/lib/thirdparty:$SCILIB;
846 LD_LIBRARY_PATH=$SCILIB${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
847 if test -d "$SCI/lib/thirdparty/redist"; then
848 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SCI/lib/thirdparty/redist;
852 *darwin* | *Darwin*) # MacOS X
853 # When using some packaging tools like fink which are storing the info in /sw/lib
854 LD_LIBRARY_PATH="/sw/lib/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
855 # Export the path to the Scilab lib when Scilab has been install ...
856 # to a Mac os x specific variable used by the linker before LD_LIBRARY_PATH
857 DYLD_LIBRARY_PATH=$SCI/../../lib/scilab/${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}:
858 # Crappy workaround for the dynamic load of sundials under Mac OS X
859 # in the source tree version. This does not occur in the binary
860 # thanks to the previous declaration on ../../lib/scilab
862 if test -d "$SCI/modules/scicos_blocks/.libs/"; then
863 DYLD_LIBRARY_PATH=$SCI/modules/scicos_blocks/.libs/${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}
865 if test -d "$SCI/modules/scicos/.libs/"; then
866 DYLD_LIBRARY_PATH=$SCI/modules/scicos/.libs/${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}
868 export DYLD_LIBRARY_PATH
870 # Now, check that I can run Scilab on this version of Mac OS X and
871 # display a standard window
872 BINPATH=$(dirname $0)
873 # Do not perform the check with Scilab is started in CLI mode
875 detect_macosx_version
876 set_macox_specific_path
878 if test "$SCILAB_MODE" = "gui"; then
882 # When started as an Application, the default path was "/"
883 # It is not really useful. Changing to HOME.
884 # See bugs 8339 and 10575 for rational
885 if test "$(pwd)" = "/"; then
894 if test $SCIVERBOSE -ne 0; then
895 echo "LD_LIBRARY_PATH : $LD_LIBRARY_PATH"
896 if test ! -z "$DYLD_LIBRARY_PATH"; then
897 echo "DYLD_LIBRARY_PATH: $DYLD_LIBRARY_PATH"
900 export LD_LIBRARY_PATH
903 # Scilab does not support the LANGUAGE variable.
904 # Unset to avoid some weird issue. CF bug #10032
907 if test $IS_SCILAB_BINARY -ne 1; then
908 # We are not using the Scilab binary, find out where docbook is.
912 # Check if SELINUX is enable. If it is the case, disable it for Scilab
913 check_and_disable_selinux
918 if test $# -gt 0; then
919 # scinotes is called. We process the arguments
922 for SCIARG in "$@"; do
923 if test "$SCIARG" = "-indent"; then
924 INDENT="['indent','trailing','quote']"
926 ARGS="$ARGS '$SCIARG' "
932 if test -n "$INDENT"; then
933 # Call scinotes with the arguments
934 if test $SCIVERBOSE -ne 0; then
935 echo "Will start scinotes with: $SCILABBIN -nb -nw -e scinotes($ARGS, $INDENT);exit()"
937 "$SCILABBIN" -nb -nw -e "scinotes($ARGS, $INDENT);exit()"
939 if test $SCIVERBOSE -ne 0; then
940 echo "Will start scinotes with: $SCILABBIN -e scinotes($ARGS)"
943 # Call scinotes with no argument
944 "$SCILABBIN" -e "scinotes($ARGS)"
952 if test $# -gt 0; then
953 # xcos is called. We process the arguments
955 for SCIARG in "$@"; do
956 if test "$SCIARG" = "-simulate"; then
957 if test $# -ne 2; then
958 echo "Wrong syntax: When -simulate is used, only one file must be provided."
963 ARGS="$ARGS '$SCIARG' "
969 if test $SIMULATE -eq 1; then
970 if test $SCIVERBOSE -ne 0; then
971 echo "Will start Xcos with: $SCILABBIN -e 'importXcosDiagram($ARGS);xcos_simulate(scs_m, 4)'"
974 # Call xcos with the arguments to simulate
975 "$SCILABBIN" -e "importXcosDiagram($ARGS);xcos_simulate(scs_m, 4)"
977 if test $SCIVERBOSE -ne 0; then
978 echo "Will start Xcos with: $SCILABBIN -e xcos($ARGS)"
981 # Call xcos with the arguments
982 "$SCILABBIN" -e "xcos($ARGS)"
990 if test "$SCILAB_MODE" = "xcos"; then
993 if test "$SCILAB_MODE" = "scinotes"; then
1004 if test "$SCILAB_MODE" = "xcos"; then
1005 echo "Start Xcos, the hybrid simulator"
1007 echo "xcos [ file1.xcos, [ file2.xcos ]]"
1009 echo " Possible arguments are:"
1010 echo " -simulate : Start the simulation. Only one file will be accepted."
1013 if test "$SCILAB_MODE" = "scinotes"; then
1014 echo "Start Scinotes, the Scilab text editor"
1016 echo "scinotes [ file1.sci, [ file2.sce ]]"
1018 echo " Possible arguments are:"
1019 echo " -indent : format (indent, trailing spaces, quote mismatch) the files"
1024 echo "scilab <arguments>"
1025 echo "scilab-cli <arguments>"
1026 echo "scilab-adv-cli <arguments>"
1028 echo " Possible arguments are:"
1029 echo " -display Display: for use under Xwindow systems to set a specific X server display."
1030 echo " -d Display : equivalent to -display Display."
1031 echo " -e Instruction : execute the scilab instruction given in Instruction argument."
1032 echo " -e and -f arguments are mutually exclusive."
1033 echo " -f File : execute the scilab script given in File argument."
1034 echo " -e and -f arguments are mutually exclusive."
1035 echo " -quit : force scilab exit after execution of script from -e or -f argument."
1036 echo " this flag is ignored if it is not used with -e or -f argument."
1037 echo " -l Lang : set the current language. Lang can be equal to fr or en."
1038 echo " -nb : do not display Scilab loading on start."
1039 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)."
1040 echo " -nouserstartup : do not execute the user startup files SCIHOME/.scilab or SCIHOME/scilab.ini."
1041 echo " -noatomsautoload: do not load ATOMS installed module."
1042 echo " -nw : start Scilab without dedicated Scilab Window."
1043 echo " -nwni : start Scilab without the GUI, graphic and help features (batch mode). This argument disables the need of Java."
1044 echo " -nogui : See -nwni"
1045 echo " -nocolor : Remove the color in the cli and adv-cli modes"
1046 echo " -args : accept all extra arguments and make them available through sciargs"
1047 echo " -version : print product version and exit."
1048 echo " -h/--help : display help about this command."
1049 echo " --texmacs : reserved for TeXMacs."
1050 echo " -scihome dir : Force SCIHOME to given dir."
1053 echo "Developer arguments:"
1054 echo " -debug : Start Scilab under gdb (Unix/linux only)."
1055 echo " define the variable SCILAB_GDB_OPT to add custom arguments to gdb."
1056 echo " -debug-kdbg : Start Scilab under kdbg (Unix/linux only)."
1057 echo " -profiling : Start Scilab under valgrind (Unix/linux only)."
1058 echo " define the variable SCILAB_VALGRIND_OPT to add custom arguments to"
1059 echo " valgrind (and override the existing valgrind arguments)."
1060 echo " -profiling-visu : Start Scilab under callgrind (Unix/linux only)."
1061 echo " define the variable SCILAB_VALGRIND_OPT to add custom arguments to"
1062 echo " callgrind (and override the existing callgrind arguments)."
1063 echo " -disable-exception-catching : Disable Scilab exception catching system."
1065 echo " --parse-file File : Only parse File argument without execution and exit."
1066 echo " --parse-trace : Display bison state machine evolution."
1067 echo " --AST-trace : Display ASCII-art AST to be human readable."
1068 echo " --pretty-print : Display pretty-printed code, standard Scilab syntax."
1070 echo "Developer Timer arguments:"
1071 echo " --AST-timed : Time each AST node."
1072 echo " --timed : Time global execution."
1074 echo "Developer Debug arguments:"
1075 echo " --no-exec : Only do Lexing/parsing do not execute instructions."
1076 echo " --context-dump : Display context status."
1077 echo " --exec-verbose : Display command before execute it."
1078 echo " --timeout delay : Kill the Scilab process after a delay (s, m, h, d)."
1080 echo " All these arguments can be retrieved by the Scilab function sciargs."
1083 echo " Several environment variables can be declared:"
1084 echo " SCIVERBOSE Provides debugging information of the startup"
1085 echo " JAVA_HOME Declares which Java Virtual Machine to use"
1086 echo " SCI_DISABLE_TK Disables Tk (but not Tcl) features"
1087 echo " SCI_JAVA_ENABLE_HEADLESS Runs Java Headless VM (without GUI; Windows and Linux only)"
1088 echo " SCI_DISABLE_EXCEPTION_CATCHING Disable the catch by Scilab of exception (segfault, ...)"
1093 # under MacOS X LANG is not set when launching Scilab from its icon
1094 if test "$OS" = "Darwin"; then
1095 if test -z "$LANG"; then
1096 export LANG=`defaults read -g AppleLocale`.UTF-8
1101 if test "$SCILAB_MODE" = "nw"; then
1105 # calling Scilab with no argument or special cases of calling Scilab
1108 0) # No arg, run Scilab
1120 # really calling Scilab with arguments
1122 if test "$rest" = "yes"; then
1131 # If the previous argument needs an argument, skip current one.
1132 if test -n "$prevarg"; then
1138 -nogui|-version|-ns|-nb|-nouserstartup|-noatomsautoload|-nocolor|--texmacs)
1141 if test "$SCILAB_MODE" = "nwni"; then
1142 echo "Cannot use scilab-cli with option -nw"
1147 if test "$SCILAB_MODE" = "nw"; then
1148 echo "Cannot use scilab-adv-cli with option -nwni"
1152 --parse-trace|--pretty-print|--help|--AST-trace|--no-exec|--context-dump|--exec-verbose|--timed|--AST-timed|--serialize|-quit|--webmode)
1153 #This are Scilab6 dedicated options.
1156 #This are Scilab6 dedicated options with an argument
1160 # Under Mac OS X, .app is adding the arg -psn_0_xxxx
1161 # (psn = ProcessSerialNumber). It is not used (but could be in the future)
1163 -display|-f|-l|-e|-d|--parse-file|-scihome)
1166 -args) # Accept extra arguments
1173 DEBUG_KDBG="-debug-kdbg"
1176 PROFILING="-profiling"
1179 PROFILING_VISU="-profiling-visu"
1181 -disable-exception-catching)
1182 SCI_DISABLE_EXCEPTION_CATCHING=1
1183 export SCI_DISABLE_EXCEPTION_CATCHING
1191 # Do nothing. Gives unknown args to Scilab binaries if -args is provided
1197 # If the argument -a is not provided (extraarg) and we found unknown args
1198 # fail and provide help
1199 if test -z "$extraarg" -a -n "$foundUnknownArg"; then
1200 echo "Unknown argument: $wrongArg"
1205 if test -n "$DEBUG"; then
1206 start_debug "$@" $MORE_OPT
1208 if test -n "$DEBUG_KDBG"; then
1209 start_debug_kdbg "$@" $MORE_OPT
1211 if test -n "$PROFILING"; then
1212 start_profiling "$@" $MORE_OPT
1214 if test -n "$PROFILING_VISU"; then
1215 start_profiling_visu "$@" $MORE_OPT
1217 do_scilex "$@" $MORE_OPT
1218 fi # not profiling visu