0320791858f4e68aeee44f4b2f30561e97dda6fa
[scilab.git] / scilab / bin / scilab
1 #!/bin/sh
2 #
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
9 #
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.
16
17 ####
18 #
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
33 #
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
41 # directory
42 # * That is all. Don't hesitate to contact us if you see one missing.
43 #
44 ###
45
46 if test ! -z "$SCIVERBOSE"; then
47     SCIVERBOSE=1
48 else
49     SCIVERBOSE=0
50 fi
51
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"
56         exit 255
57     fi
58 fi
59
60 DISABLE_JAVA_DETECTION=0
61 IS_SCILAB_BINARY=0
62
63 start_debug() {
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" "$@"
67     else
68         echo "Running debug of Scilab [gdb]  : " gdb $SCILAB_GDB_OPT --args "$SCILABBIN" "$@"
69         gdb $SCILAB_GDB_OPT --args "$SCILABBIN" "$@"
70     fi
71 }
72
73 start_debug_kdbg() {
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"
77     else
78         echo "Running debug of Scilab [kdbg]  : " kdbg "$SCILABBIN"
79         kdbg "$SCILABBIN"
80     fi
81 }
82
83 start_profiling() {
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" "$@"
88     else
89         echo "Running profiling of Scilab  : " valgrind $VALGRIND_OPTIONS "$SCILABBIN" "$@"
90         valgrind $VALGRIND_OPTIONS "$SCILABBIN" "$@"
91     fi
92
93 }
94
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"
97 #--dump-instr=yes
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" "$@"
101     else
102         echo "Running profiling visualization of Scilab  : " valgrind $VALGRIND_VISU_OPTIONS "$SCILABBIN" "$@"
103         valgrind $VALGRIND_VISU_OPTIONS "$SCILABBIN" "$@"
104     fi
105 }
106
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
112                     DOCBOOK_ROOT=$dir
113                     export DOCBOOK_ROOT
114                 fi
115             fi
116         done
117     fi
118     if test $SCIVERBOSE -ne 0; then
119         echo "DOCBOOK : $DOCBOOK_ROOT"
120     fi
121 }
122
123 detect_type_of_scilab(){
124
125     progname="$0"
126     SCILAB_MODE="gui"
127     SCILABBIN="scilab-bin"
128
129     if (echo "$progname"|grep "scilab-adv-cli$" 2>&1 > /dev/null;) || (echo "$@"|grep "\-nw" 2>&1 > /dev/null;) then
130         SCILAB_MODE="nw"
131         # We are using scilab-bin here because we are going to force the arg -nw
132         SCILABBIN="scilab-bin"
133     fi
134
135     if (echo "$progname"|grep "scilab-cli$" 2>&1 > /dev/null;) || (echo "$@"|grep "\-nwni" 2>&1 > /dev/null;) then
136         SCILAB_MODE="nwni"
137         SCILABBIN="scilab-cli-bin"
138         DISABLE_JAVA_DETECTION=1
139     fi
140
141     if (echo "$progname"|grep "scinotes$" 2>&1 > /dev/null;) then
142         SCILAB_MODE="scinotes"
143         SCILABBIN="scilab-bin"
144         extraarg=1
145     fi
146
147     if (echo "$progname"|grep "xcos$" 2>&1 > /dev/null;) then
148         SCILAB_MODE="xcos"
149         SCILABBIN="scilab-bin"
150         extraarg=1
151     fi
152
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"
157     fi
158 }
159
160 detect_os() {
161
162     if test "${OS}" = ""; then
163         OS=$(uname -s) # Retrieve the Operating System
164     fi
165     if test "${MODEL}" = ""; then
166         MODEL=$(uname -m) # Retrieve the model
167     fi
168
169     if test $SCIVERBOSE -ne 0; then
170         echo "OS : $OS"
171         echo "MODEL : $MODEL"
172     fi
173 }
174
175 detect_type_of_scilab $@
176
177 detect_os
178
179 detect_scilab_path() {
180
181     LOCALOLDPWD=$(pwd)
182
183     # If we are running Scilab binary, it is trivial to set paths.
184     curdir=$(dirname "$progname")
185
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")
192
193             # Browse the symlink to the real one
194             progname=$(/bin/ls -l "$bn" | sed -e 's/^.* -> //' )
195
196             if test ! -x "$progname"; then
197                 break
198             fi
199         done
200         cd $(dirname "$progname")
201         curdir=$(pwd)
202     fi
203
204     if test -d $curdir/../thirdparty/ -a -d $curdir/../share/scilab; then
205         # We are in the Scilab binary
206         IS_SCILAB_BINARY=1
207         # export the bin directory to the PATH first (avoid to take the packaged version)
208         PATH="$curdir:$PATH"
209         cd "$curdir/../"
210         SCIBINARYBASE=$(pwd)
211         SCI=$SCIBINARYBASE/share/scilab
212         export SCI
213         return
214     fi
215
216     # Use scilab-bin in the current dir if it exists
217     # If not, then start resolving symlinks until we find scilab-bin
218     found=0
219     cd $(dirname "$progname")
220     curdir=$(pwd -P)
221     PATH="$curdir:$PATH"
222
223     progbase=$(basename "$progname")
224     run_sci="$curdir/$SCILABBIN"
225     if test -x "$run_sci"; then # scilab-bin is in the /bin/ directory
226         cd "$curdir/../"
227         SCI=$(pwd)
228         SCIBIN=$run_sci
229         found=1
230     else
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
234             cd "$curdir/../"
235             SCI=$(pwd)
236             SCIBIN=$run_sci
237             found=1
238         else
239             here=$(/bin/pwd)
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
246                     break
247                 fi
248                 curdir=$(dirname "$progname")
249                 if test -x "$curdir"; then
250                     cd "$curdir/../"
251                     SCI=$(pwd)
252                     SCIBIN="$curdir/$SCILABBIN"
253                     found=1
254
255                     break
256                 fi
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
261                     cd "$curdir/../"
262                     SCI=$(pwd)
263                     SCIBIN=$run_sci
264                     found=1
265                     break
266                 fi
267             done
268             cd "$here"
269         fi
270         if test $SCIVERBOSE -ne 0; then
271             echo "I think I found Scilab here : $SCI"
272         fi
273     fi
274
275
276     if test -x "$SCI/bin/$SCILABBIN"; then
277 # real env
278         SCILABBIN=$SCI/bin/$SCILABBIN
279         SCI=$SCI/share/scilab/
280     else
281         if test -x "$SCI/$SCILABBIN"; then
282         # dev env
283             SCILABBIN=$SCI/$SCILABBIN
284             DEVENV=1
285         # add modelica in the path
286             PATH="$PATH:$SCI/modules/scicos/"
287         else
288             echo "Cannot find $SCILABBIN ..."
289             exit 1
290         fi
291     fi
292
293     export SCI
294 }
295
296
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+)
303     fi
304     JAVA_JVM_VERSION=$JAVA_HOME
305     export JAVA_JVM_VERSION
306     DYLD_LIBRARY_PATH="$JAVA_HOME/../Libraries${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
307
308 }
309
310 set_embedded_java_vm () {
311
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,
314         # Mac OS X
315         case $OS in
316             "Linux")
317                 case $MODEL in
318                     "x86_64")
319                         proc="amd64"
320                         ;;
321                     i?86)
322                         # We embed java/lib/i386 with Scilab Binary
323                         # force proc to i386 even if systems answer i686
324                         proc="i386"
325                         ;;
326                     *)
327                         echo "Could not find the Java configuration for the model <${MODEL}>. Please contact us on http://bugzilla.scilab.org"
328                         ;;
329                 esac
330                 ;;
331             *darwin* | *Darwin*) # MacOS X
332                 # JRE is now embedded in Mac OS X binary version
333                 #set_macosx_java_vm
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}"
338                 ;;
339             *)
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"
342             proc=$MODEL
343             ;;
344     esac
345     JRE_HOME="$SCIBINARYBASE/thirdparty/java/"
346
347 }
348
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
353         if test $? = 0; then
354             if test $SCIVERBOSE -ne 0; then
355                 echo "Disabling SELinux on Scilab"
356             fi
357
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"
363                 fi
364             fi
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"
370                 fi
371             fi
372             /usr/bin/chcon -t execmem_exec_t "$SCIBINARYBASE/bin/scilab-bin"
373             if test $? != 0; then
374                 echo "Error: Cannot chcon 'scilab-bin'"
375             fi
376
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'"
380             fi
381
382         fi
383     fi
384 }
385
386 detect_java_vm() {
387
388     JAVA_SHLIB="libjava.so"
389
390     if test $IS_SCILAB_BINARY -eq 1; then
391         set_embedded_java_vm
392     else  # NOT IS_SCILAB_BINARY
393
394 ############# JAVA DETECTION ##############
395 # Basic inspiration from Eclipse
396 #
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
403 #
404 # Once we have JAVA_HOME, we check that native libraries (libjava.so and
405 # 2 others) are available
406 ###
407
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
412 # uname -m Darwin
413
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"
418                 fi
419                 if test ! -x "$JAVA_HOME/bin/java" ; then
420                     echo "Cannot find $JAVA_HOME/bin/java"
421                     exit 1
422                 fi
423         else
424
425             case $OS in
426                 *darwin* | *Darwin*)
427                     set_macosx_java_vm
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"
432                     fi
433                     ;;
434                 *)
435                     ;;
436             esac
437
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 "
445                     fi
446                     if test -x "${DIR}/bin/java" ; then
447                         # resolve symlinked dir
448                         cd $DIR
449                         JAVA_HOME=$(pwd -P)
450                         cd $OLDPWD
451
452                         export JAVA_HOME
453                         if test $SCIVERBOSE -ne 0; then
454                             echo "Java found in $JAVA_HOME"
455                         fi
456                         break
457                     fi
458                 done
459             fi
460
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
463
464                 PATH_SEPARATOR=:
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"
468                 fi
469                 for DIR in $PATH; do
470                     if test -f $DIR/java; then
471
472                         _cur=$DIR/java
473                 # resolve symlink
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/.* -> //')
477                         done
478                 # symlink resolved to the real file
479
480                 # Now, create JAVA_HOME
481                         TMP=$(dirname $_cur)
482                         JAVA_HOME=$(dirname $TMP)
483                         if test ! -z "$JAVA_HOME"; then
484                             break;
485                         fi
486                     fi
487                 done
488                 IFS=$as_save_IFS
489             fi
490         fi
491         if test ! -z "$JAVA_HOME"; then
492             if test $SCIVERBOSE -ne 0; then
493                 echo "JAVA_HOME : $JAVA_HOME"
494             fi
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
498             else
499                 JRE_HOME=$JAVA_HOME
500             fi
501 # Configuring LD_LIBRARY_PATH for libjava.so libhpi.so and libxxxx.so
502
503             case $OS in
504                 "Linux")
505                     case $MODEL in
506                         "x86_64")
507                             proc="amd64"
508                             ;;
509                         i?86)
510
511                             if test -d ${JRE_HOME}/lib/$(uname -m) ; then
512                                 proc=$(uname -m)
513                             else
514                                 proc="i386"
515                             fi
516                             ;;
517                         "alpha")
518                             proc="alpha"
519                             ;;
520                         "sparc"|"sparc64")
521                             proc="sparc"
522                             ;;
523                         sh*)
524                             proc="sh"
525                             ;;
526                         "ia64")
527                             proc="ia64"
528                             ;;
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
533                                 proc="mipsel"
534                             else
535                                 proc="mips"
536                             fi
537                             ;;
538                         "ppc"|"powerpc")
539                             proc="ppc"
540                             ;;
541                         "ppc64"|"ppc64el")
542                             proc="ppc64"
543                             ;;
544                         "s390")
545                             proc="s390"
546                             ;;
547                         "s390x")
548                             proc="s390x"
549                             ;;
550                         armv*)
551                             proc="arm"
552                             ;;
553                         aarch64)
554                             proc="aarch64"
555                             ;;
556                         *)
557                             echo "Could not find the Java configuration for the model <${MODEL}>. Please contact us on http://bugzilla.scilab.org"
558                             ;;
559                     esac
560                     ;;
561                 "HP-UX")
562                     JAVA_SHLIB="libjava.sl"
563                     proc="lib" # TODO : check if it is right or not ... seems not !
564                     ;;
565                 "IRIX")
566                     proc="lib32"
567                     ;;
568                 "SunOS")
569                     case $MODEL in
570                         "i86pc") # solaris x86
571                             proc="i386"
572                             ;;
573                 # check for the 64 bits syntax
574                         "sparc"|"sparc64")
575                             proc="sparc"
576                             ;;
577                         *)
578                             echo "Could not find the Java configuration for the model <${MODEL}>. Please contact us."
579                             ;;
580                     esac
581                     ;;
582
583                 *win32* | *WIN32* | *CYGWIN_NT*)
584                     proc="win32"
585                     JAVA_SHLIB="jvm.dll"
586                     ;;
587                 *darwin* | *Darwin*) # MacOS X
588                     set_macosx_java_vm
589                     ;;
590                 *FreeBSD*)
591                     proc=$MODEL
592                     ;;
593                 *)
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"
596                     proc=$MODEL
597                     ;;
598             esac
599         fi # JAVA_HOME provided or found
600     fi # IS_SCILAB_BINARY
601
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"
607         fi
608     else
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}"
613     fi
614
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)
618     case $OS in
619         *darwin* | *Darwin*) # MacOS X
620             export _JAVA_OPTIONS="-Djava.awt.headless=false"
621     ;;
622     esac
623
624 ####### END OF JAVA ENV DETECTION/SETTING ######
625 }
626
627 detect_scilab_path
628 if test $SCIVERBOSE -ne 0; then
629     echo "IS_SCILAB_BINARY : $IS_SCILAB_BINARY"
630 fi
631
632
633 # If we are calling scilab-cli, no need to detect java.
634 if test $DISABLE_JAVA_DETECTION -ne 1; then
635     detect_java_vm
636 fi
637
638 if test $IS_SCILAB_BINARY -eq 1; then
639
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"
644     else
645         # Old packaging path
646         TCL_LIBRARY="$SCIBINARYBASE/thirdparty/tcl8.5"
647         TK_LIBRARY="$SCIBINARYBASE/thirdparty/tk8.5"
648     fi
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/"
652
653     export DOCBOOK_ROOT
654     export PATH
655     export LD_LIBRARY_PATH
656     export TCL_LIBRARY
657     export TK_LIBRARY
658
659     case $OS in
660         *darwin* | *Darwin*)
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"
664             export PATH
665             ;;
666     esac
667
668 else
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"
673         export TCL_LIBRARY
674         export TK_LIBRARY
675     fi
676     PATH="$SCI:$SCI/bin:$PATH"
677 fi
678
679
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)
687 export GTK_MODULES
688
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
695         EGL_DRIVER=egl_glx
696         export EGL_DRIVER
697     fi
698 fi
699
700 if test $SCIVERBOSE -ne 0; then
701     echo "SCI : $SCI"
702     echo "SCIBIN : $SCIBIN"
703     echo "PATH : $PATH"
704     echo "CLASSPATH : $CLASSPATH"
705     echo "EGL_DRIVER : $EGL_DRIVER"
706 fi
707
708 # Returns to the original path
709 cd "$LOCALOLDPWD"
710
711 #if test "$DISPLAY" = ""; then
712 #  DISPLAY="unix:0.0"
713 #fi
714 #export DISPLAY
715
716
717 detect_macosx_version()
718 {
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]*'`
722     fi
723     macosxMajorVersion=`echo $macosxVersion | cut -d . -f 1`
724     macosxMinorVersion=`echo $macosxVersion | cut -d . -f 2`
725     macosxBuildVersion=`echo $macosxVersion | cut -d . -f 3`
726
727     if test $SCIVERBOSE -ne 0; then
728         echo "Found MacOSX Version: $macosxVersion"
729     fi
730
731 }
732
733 set_macox_specific_path()
734 {
735
736     PATH_TO_SPECIFIC_10_13=$SCIBINARYBASE/lib/thirdparty/10.13/
737     PATH_TO_SPECIFIC_10_12=$SCIBINARYBASE/lib/thirdparty/10.12/
738     PATH_TO_SPECIFIC_10_11=$SCIBINARYBASE/lib/thirdparty/10.11/
739     PATH_TO_SPECIFIC_10_10=$SCIBINARYBASE/lib/thirdparty/10.10/
740     PATH_TO_SPECIFIC_10_6=$SCIBINARYBASE/lib/thirdparty/10.6/
741
742     case $macosxMajorVersion in
743         10)
744             case $macosxMinorVersion in
745                 13)
746                     # Specific libBLAS.dylib & libz versions for 10.13
747                     LD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_13${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
748                     DYLD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_13${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
749                     ;;
750                 12)
751                     # Specific libBLAS.dylib version for 10.12
752                     LD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_12${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
753                     DYLD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_12${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
754                     ;;
755                 11)
756                     # Specific libBLAS.dylib & libLAPACK.dylib version for 10.11
757                     LD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_11${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
758                     DYLD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_11${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
759                     ;;
760                 10)
761                     # Specific libBLAS.dylib & libLAPACK.dylib version for 10.10
762                     LD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_10${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
763                     DYLD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_10${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
764                     ;;
765                 6)
766                     # the iconv lib fails under 10.7, just declare it for 10.6
767                     LD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_6${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
768                     DYLD_LIBRARY_PATH=$PATH_TO_SPECIFIC_10_6${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}
769                     ;;
770                 *)
771                     fail_macosx_version
772                     ;;
773             esac
774             ;;
775     esac
776
777 }
778
779 #
780 # Version checks for Mac
781 #
782 dialog_try_or_exit()
783 {
784     osascript $BINPATH/checkmacosx.applescript "$1" || exit 128
785 }
786
787 fail_macosx_version()
788 {
789     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)."
790 }
791 check_macosx_version()
792 {
793     case $macosxMajorVersion in
794         10)
795             case $macosxMinorVersion in
796                 9)
797                    # We force to install JRE on Mavericks
798                    /usr/libexec/java_home --request > /dev/null
799                    ;;
800                 10|11|12|13)
801                    # ... but not on Yosemite, El Capitan, Sierra or High Sierra:
802                    # there will be a (better) error at launch
803                    ;;
804                 8)
805                     if test $macosxBuildVersion -le 3; then
806                         # Version <= 10.8.3
807                         fail_macosx_version
808                     fi
809                     ;;
810                 *)
811                     fail_macosx_version
812                     ;;
813             esac
814             ;;
815         *)
816             fail_macosx_version
817             ;;
818     esac
819 }
820
821 # . is used by the dynamic link. The build lib are copied into the PWD
822 SCILIB=$SCI/bin:$SCI/lib/scilab/:$SCI/lib64/scilab/:.
823 if test -d $SCI/lib/thirdparty; then
824     SCILIB=$SCI/lib/thirdparty:$SCILIB;
825 fi
826 LD_LIBRARY_PATH=$SCILIB${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
827
828 case $OS in
829     *darwin* | *Darwin*) # MacOS X
830         # When using some packaging tools like fink which are storing the info in /sw/lib
831         LD_LIBRARY_PATH="/sw/lib/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
832     # Export the path to the Scilab lib when Scilab has been install ...
833     # to a Mac os x specific variable used by the linker before LD_LIBRARY_PATH
834         DYLD_LIBRARY_PATH=$SCI/../../lib/scilab/${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}:
835         # Crappy workaround for the dynamic load of sundials under Mac OS X
836         # in the source tree version. This does not occur in the binary
837         # thanks to the previous declaration on ../../lib/scilab
838         # See bug #4949
839         if test -d "$SCI/modules/scicos_blocks/.libs/"; then
840             DYLD_LIBRARY_PATH=$SCI/modules/scicos_blocks/.libs/${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}
841         fi
842         if test -d "$SCI/modules/scicos/.libs/"; then
843             DYLD_LIBRARY_PATH=$SCI/modules/scicos/.libs/${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}
844         fi
845         export DYLD_LIBRARY_PATH
846
847         # Now, check that I can run Scilab on this version of Mac OS X and
848         # display a standard window
849         BINPATH=$(dirname $0)
850         # Do not perform the check with Scilab is started in CLI mode
851
852         detect_macosx_version
853         set_macox_specific_path
854
855         if test "$SCILAB_MODE" = "gui"; then
856             check_macosx_version
857         fi
858
859         # When started as an Application, the default path was "/"
860         # It is not really useful. Changing to HOME.
861         # See bugs 8339 and 10575 for rational
862         if test "$(pwd)" = "/"; then
863             cd $HOME
864         fi
865
866         ;;
867     *)
868 esac
869
870
871 if test $SCIVERBOSE -ne 0; then
872     echo "LD_LIBRARY_PATH : $LD_LIBRARY_PATH"
873     if test ! -z "$DYLD_LIBRARY_PATH"; then
874         echo "DYLD_LIBRARY_PATH: $DYLD_LIBRARY_PATH"
875     fi
876 fi
877 export LD_LIBRARY_PATH
878 export PATH
879
880 # Scilab does not support the LANGUAGE variable.
881 # Unset to avoid some weird issue. CF bug #10032
882 unset LANGUAGE
883
884 if test $IS_SCILAB_BINARY -ne 1; then
885 # We are not using the Scilab binary, find out where docbook is.
886     find_docbook_path
887 fi
888
889 # Check if SELINUX is enable. If it is the case, disable it for Scilab
890 check_and_disable_selinux
891
892 do_scinotes()
893 {
894     INDENT=""
895     if test $# -gt 0; then
896     # scinotes is called. We process the arguments
897     ARGS="["
898
899     for SCIARG in "$@"; do
900         if test "$SCIARG" = "-indent"; then
901             INDENT="['indent','trailing','quote']"
902         else
903             ARGS="$ARGS '$SCIARG' "
904         fi
905     done
906     ARGS="$ARGS]"
907     fi
908
909     if test -n "$INDENT"; then
910     # Call scinotes with the arguments
911         if test $SCIVERBOSE -ne 0; then
912             echo "Will start scinotes with: $SCILABBIN -nb -nw -e scinotes($ARGS, $INDENT);exit()"
913         fi
914         "$SCILABBIN" -nb -nw -e "scinotes($ARGS, $INDENT);exit()"
915     else
916         if test $SCIVERBOSE -ne 0; then
917             echo "Will start scinotes with: $SCILABBIN -e scinotes($ARGS)"
918         fi
919
920     # Call scinotes with no argument
921         "$SCILABBIN" -e "scinotes($ARGS)"
922         exit $?
923     fi
924 }
925
926 do_xcos()
927 {
928     SIMULATE=0
929     if test $# -gt 0; then
930     # xcos is called. We process the arguments
931         ARGS="["
932         for SCIARG in "$@"; do
933             if test "$SCIARG" = "-simulate"; then
934                 if test $# -ne 2; then
935                     echo "Wrong syntax: When -simulate is used, only one file must be provided."
936                     exit 43
937                 fi
938                 SIMULATE=1
939             else
940                 ARGS="$ARGS '$SCIARG' "
941             fi
942         done
943         ARGS="$ARGS ]"
944     fi
945
946     if test $SIMULATE -eq 1; then
947         if test $SCIVERBOSE -ne 0; then
948             echo "Will start Xcos with: $SCILABBIN -e 'importXcosDiagram($ARGS);xcos_simulate(scs_m, 4)'"
949         fi
950
951     # Call xcos with the arguments to simulate
952         "$SCILABBIN" -e "importXcosDiagram($ARGS);xcos_simulate(scs_m, 4)"
953     else
954         if test $SCIVERBOSE -ne 0; then
955             echo "Will start Xcos with: $SCILABBIN -e xcos($ARGS)"
956         fi
957
958     # Call xcos with the arguments
959         "$SCILABBIN" -e "xcos($ARGS)"
960         exit $?
961     fi
962
963 }
964
965 do_scilex()
966 {
967     if test "$SCILAB_MODE" = "xcos"; then
968         do_xcos "$@"
969     else
970         if test "$SCILAB_MODE" = "scinotes"; then
971             do_scinotes "$@"
972         else
973             "$SCILABBIN" "$@"
974             exit $?
975         fi
976     fi
977 }
978
979 do_help()
980 {
981     if test "$SCILAB_MODE" = "xcos"; then
982         echo "Start Xcos, the hybrid simulator"
983         echo "Usage:"
984         echo "xcos [ file1.xcos, [ file2.xcos ]]"
985         echo     " "
986         echo     "  Possible arguments are:"
987         echo     "  -simulate : Start the simulation. Only one file will be accepted."
988         exit
989     fi
990     if test "$SCILAB_MODE" = "scinotes"; then
991         echo "Start Scinotes, the Scilab text editor"
992         echo "Usage:"
993         echo     "scinotes [ file1.sci, [ file2.sce ]]"
994         echo     " "
995         echo     "  Possible arguments are:"
996         echo     "  -indent : format (indent, trailing spaces, quote mismatch) the files"
997         exit
998     fi
999
1000     echo "Usage:"
1001     echo     "scilab <arguments>"
1002     echo     "scilab-cli <arguments>"
1003     echo     "scilab-adv-cli <arguments>"
1004     echo     " "
1005     echo     "  Possible arguments are:"
1006     echo     "  -display Display: for use under Xwindow systems to set a specific X server display."
1007     echo     "  -d Display      : equivalent to -display Display."
1008     echo     "  -e Instruction  : execute the scilab instruction given in Instruction argument."
1009     echo     "                    -e and -f arguments are mutually exclusive."
1010     echo     "  -f File         : execute the scilab script given in File argument."
1011     echo     "                    -e and -f arguments are mutually exclusive."
1012     echo     "  -quit           : force scilab exit after execution of script from -e or -f argument."
1013     echo     "                    this flag is ignored if it is not used with -e or -f argument."
1014     echo     "  -l Lang         : set the current language. Lang can be equal to fr or en."
1015     echo     "  -nb             : do not display Scilab loading on start."
1016     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)."
1017     echo     "  -nouserstartup  : do not execute the user startup files SCIHOME/.scilab or SCIHOME/scilab.ini."
1018     echo     "  -noatomsautoload: do not load ATOMS installed module."
1019     echo     "  -nw             : start Scilab without dedicated Scilab Window."
1020     echo     "  -nwni           : start Scilab without the GUI, graphic and help features (batch mode). This argument disables the need of Java."
1021     echo     "  -nogui          : See -nwni"
1022     echo     "  -nocolor        : Remove the color in the cli and adv-cli modes"
1023     echo     "  -args           : accept all extra arguments and make them available through sciargs"
1024     echo     "  -version        : print product version and exit."
1025     echo     "  -h/--help       : display help about this command."
1026     echo     "  --texmacs       : reserved for TeXMacs."
1027     echo     "  -scihome dir    : Force SCIHOME to given dir."
1028     echo     " "
1029
1030     echo     "Developer arguments:"
1031     echo     "  -debug          : Start Scilab under gdb (Unix/linux only)."
1032     echo     "                    define the variable SCILAB_GDB_OPT to add custom arguments to gdb."
1033     echo     "  -debug-kdbg     : Start Scilab under kdbg (Unix/linux only)."
1034     echo     "  -profiling      : Start Scilab under valgrind (Unix/linux only)."
1035     echo     "                    define the variable SCILAB_VALGRIND_OPT to add custom arguments to"
1036     echo     "                    valgrind (and override the existing valgrind arguments)."
1037     echo     "  -profiling-visu : Start Scilab under callgrind (Unix/linux only)."
1038     echo     "                    define the variable SCILAB_VALGRIND_OPT to add custom arguments to"
1039     echo     "                    callgrind (and override the existing callgrind arguments)."
1040     echo     "  -disable-exception-catching : Disable Scilab exception catching system."
1041     echo     " "
1042     echo     "  --parse-file File : Only parse File argument without execution and exit."
1043     echo     "  --parse-trace     : Display bison state machine evolution."
1044     echo     "  --AST-trace       : Display ASCII-art AST to be human readable."
1045     echo     "  --pretty-print    : Display pretty-printed code, standard Scilab syntax."
1046     echo     " "
1047     echo     "Developer Timer arguments:"
1048     echo     "  --AST-timed      : Time each AST node."
1049     echo     "  --timed          : Time global execution."
1050     echo     " "
1051     echo     "Developer Debug arguments:"
1052     echo     "  --no-exec        : Only do Lexing/parsing do not execute instructions."
1053     echo     "  --context-dump   : Display context status."
1054     echo     "  --exec-verbose   : Display command before execute it."
1055     echo     "  --timeout delay  : Kill the Scilab process after a delay (s, m, h, d)."
1056     echo     " "
1057     echo     "      All these arguments can be retrieved by the Scilab function sciargs."
1058     echo     " "
1059
1060     echo     "  Several environment variables can be declared:"
1061     echo     "  SCIVERBOSE               Provides debugging information of the startup"
1062     echo     "  JAVA_HOME                Declares which Java Virtual Machine to use"
1063     echo     "  SCI_DISABLE_TK           Disables Tk (but not Tcl) features"
1064     echo     "  SCI_JAVA_ENABLE_HEADLESS Runs Java Headless VM (without GUI; Windows and Linux only)"
1065     echo     "  SCI_DISABLE_EXCEPTION_CATCHING Disable the catch by Scilab of exception (segfault, ...)"
1066
1067     exit
1068 }
1069
1070 MORE_OPT=""
1071 if test "$SCILAB_MODE" = "nw"; then
1072     MORE_OPT="-nw"
1073 fi
1074
1075 # calling Scilab with no argument or special cases of calling Scilab
1076 rest="no"
1077 case $# in
1078     0) # No arg, run Scilab
1079         do_scilex $MORE_OPT
1080         ;;
1081     *)
1082         case $1 in
1083             *)
1084                 rest="yes"
1085                 ;;
1086         esac
1087         ;;
1088 esac
1089
1090 # really calling Scilab with arguments
1091
1092 if test "$rest" = "yes"; then
1093     debug=
1094     debug_kdbg=
1095     profiling=
1096     profiling_visu=
1097     prevarg=
1098     for sciarg in "$@"
1099     do
1100
1101     # If the previous argument needs an argument, skip current one.
1102         if test -n "$prevarg"; then
1103             prevarg=
1104             continue
1105         fi
1106
1107         case $sciarg in
1108             -nogui|-version|-ns|-nb|-nouserstartup|-noatomsautoload|-nocolor|--texmacs)
1109                 ;;
1110             -nw)
1111                 if test "$SCILAB_MODE" = "nwni"; then
1112                     echo "Cannot use scilab-cli with option -nw"
1113                     exit 5
1114                 fi
1115                 ;;
1116             -nwni)
1117                 if test "$SCILAB_MODE" = "nw"; then
1118                     echo "Cannot use scilab-adv-cli with option -nwni"
1119                     exit 5
1120                 fi
1121                 ;;
1122             --parse-trace|--pretty-print|--help|--AST-trace|--no-exec|--context-dump|--exec-verbose|--timed|--AST-timed|--serialize|-quit|--webmode)
1123             #This are Scilab6 dedicated options.
1124                     ;;
1125             --timeout)
1126             #This are Scilab6 dedicated options with an argument
1127                 prevarg=1
1128                 ;;
1129             -psn_*)
1130             # Under Mac OS X, .app is adding the arg -psn_0_xxxx
1131             # (psn = ProcessSerialNumber). It is not used (but could be in the future)
1132                 ;;
1133             -display|-f|-l|-e|-d|--parse-file|-scihome)
1134                 prevarg=1
1135                 ;;
1136             -args) # Accept extra arguments
1137                 extraarg=1
1138                 ;;
1139             -debug)
1140                 DEBUG="-debug"
1141                 ;;
1142             -debug-kdbg)
1143                 DEBUG_KDBG="-debug-kdbg"
1144                 ;;
1145             -profiling)
1146                 PROFILING="-profiling"
1147                 ;;
1148             -profiling-visu)
1149                 PROFILING_VISU="-profiling-visu"
1150                 ;;
1151             -disable-exception-catching)
1152                 SCI_DISABLE_EXCEPTION_CATCHING=1
1153                 export SCI_DISABLE_EXCEPTION_CATCHING
1154                 ;;
1155             -h|--help)
1156                 do_help
1157                 ;;
1158             *)
1159                 foundUnknownArg=1
1160                 wrongArg=$sciarg
1161                 # Do nothing. Gives unknown args to Scilab binaries if -args is provided
1162                 ;;
1163         esac
1164     done
1165
1166
1167 # If the argument -a is not provided (extraarg) and we found unknown args
1168 # fail and provide help
1169     if test -z "$extraarg" -a -n "$foundUnknownArg"; then
1170         echo "Unknown argument: $wrongArg"
1171         echo ""
1172         do_help
1173     fi
1174
1175     if test -n "$DEBUG"; then
1176         start_debug "$@" $MORE_OPT
1177     else
1178         if test -n "$DEBUG_KDBG"; then
1179             start_debug_kdbg "$@" $MORE_OPT
1180         else
1181             if test -n "$PROFILING"; then
1182                 start_profiling "$@" $MORE_OPT
1183             else
1184                 if test -n "$PROFILING_VISU"; then
1185                     start_profiling_visu "$@" $MORE_OPT
1186                 else
1187                     do_scilex "$@" $MORE_OPT
1188                 fi # not profiling visu
1189             fi # not profiling
1190         fi # not debug kdbg
1191     fi # not debug
1192 fi # if rest