1#!@KAWA_SHELL@
2
3kawadir=`readlink -f "$(dirname "$0")/.."`
4
5if [ "$#" -eq 0 ]
6then
7   command_line="$0"
8else
9   command_line="$0 $*"
10fi
11test -t 0 || no_console="--no-console"
12
13# If configured with --enable-kawa-frontend then kawa.sh is
14# only used for pre-install testing.  In that case
15# we don't need to set KAWALIB, since kawapath.c looks for it in "..".
16@ENABLE_KAWA_FRONTEND_TRUE@  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$kawadir/bin
17@ENABLE_KAWA_FRONTEND_TRUE@  export LD_LIBRARY_PATH
18@ENABLE_KAWA_FRONTEND_TRUE@  exec $kawadir/bin/kawa "$@"
19
20KAWALIB=${KAWALIB-"`@CYGPATH_W@ $kawadir/lib/kawa.jar`"}
21# MSYS: KAWALIB=${KAWALIB-"`cd $kawadir/lib/; pwd -W`@CLASSPATH_SEPARATOR@kawa.jar`"}
22CLASSPATH="${KAWALIB}@CLASSPATH_SEPARATOR@@run_classpath@${CLASSPATH}"
23export CLASSPATH
24
25if test -n "$JAVA_HOME"; then
26    JAVA="${JAVA_HOME}/bin/java"
27else
28    JAVA=${JAVA-java}
29fi
30
31@WITH_JAVAFX_MODULE_TRUE@ JAVAFX_HOME=${JAVAFX_HOME:=@WITH_JAVAFX_ARG@}
32JVM_FLAGS=${JAVAFX_HOME:+"--module-path=${JAVAFX_HOME}/lib" --add-modules=javafx.web}
33
34# This ugly duplication is so we only have to use arrays and substrings
35# (which are non-Posix and non-portable) if there is a -D or -J option.
36case "$1" in
37    -D* | -J*)
38        i=0
39        for arg in "$@"; do
40            case "$arg" in
41                -D*)
42                    jvm_args[i++]="$arg"
43                    shift
44                ;;
45                -J*)
46                    jvm_args[i++]="${arg:2}"
47                    shift
48                ;;
49                *) break
50                ;;
51            esac
52        done
53        exec ${JAVA} ${JVM_FLAGS} -Dkawa.command.line="${command_line}" -Dkawa.command.pid="$$" -Dkawa.home="${kawadir}" "${jvm_args[@]}" kawa.repl ${no_console} "$@"
54        ;;
55    *)
56        exec ${JAVA} ${JVM_FLAGS} -Dkawa.command.line="${command_line}" -Dkawa.command.pid="$$" -Dkawa.home="${kawadir}" kawa.repl ${no_console} "$@"
57        ;;
58esac
59