Bump version to 6.0-36
[LibreOffice.git] / desktop / scripts / soffice.sh
blob5c76b6e2211de494790fd9d3bff9c8a823bd0534
1 #!/bin/sh
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # use POSIX locale for well-defined tool output
21 LO_SAVE_LC_ALL="$LC_ALL"
22 LC_ALL=C
23 export LC_ALL
26 # STAR_PROFILE_LOCKING_DISABLED=1
27 # export STAR_PROFILE_LOCKING_DISABLED
30 # file locking now enabled by default
31 SAL_ENABLE_FILE_LOCKING=1
32 export SAL_ENABLE_FILE_LOCKING
34 # uncomment line below to disable anti aliasing of fonts
35 # SAL_ANTIALIAS_DISABLE=true; export SAL_ANTIALIAS_DISABLE
37 # uncomment line below if you encounter problems starting soffice on your system
38 # SAL_NO_XINITTHREADS=true; export SAL_NO_XINITTHREADS
40 #@JITC_PROCESSOR_TYPE_EXPORT@
42 # resolve installation directory
43 sd_cwd=$(pwd)
44 sd_res="$0"
45 while [ -h "$sd_res" ] ; do
46 sd_dirname=$(dirname "$sd_res")
47 cd "$sd_dirname" || exit $?
48 sd_basename=$(basename "$sd_res")
49 sd_res=$(ls -l "$sd_basename" | sed "s/.*$sd_basename -> //g")
50 done
51 sd_dirname=$(dirname "$sd_res")
52 cd "$sd_dirname" || exit $?
53 sd_prog=$(pwd)
54 cd "$sd_cwd" || exit $?
56 # linked build needs additional settings
57 if [ -e "${sd_prog}/ooenv" ] ; then
58 # shellcheck source=../../instsetoo_native/ooenv
59 . "${sd_prog}/ooenv"
62 # try to get some debug output?
63 GDBTRACECHECK=
64 STRACECHECK=
65 VALGRINDCHECK=
66 RRCHECK=
68 # count number of selected checks; only one is allowed
69 checks=
70 EXTRAOPT=
71 # force the --valgrind option if the VALGRIND variable is set
72 test -n "$VALGRIND" && EXTRAOPT="--valgrind"
74 # force the --record option if the RR variable is set
75 test -n "$RR" && EXTRAOPT="--record"
77 for arg in "$@" $EXTRAOPT ; do
78 case "$arg" in
79 --record)
80 if which rr >/dev/null 2>&1 ; then
81 RRCHECK="rr record"
82 checks="c$checks"
83 else
84 echo "Error: Can't find the tool \"rr\", --record option will be ignored."
85 exit 1
88 --backtrace)
89 if which gdb >/dev/null 2>&1 ; then
90 GDBTRACECHECK="gdb -nx --command=$sd_prog/gdbtrace --args"
91 checks="c$checks"
92 else
93 echo "Error: Can't find the tool \"gdb\", --backtrace option will be ignored."
94 exit 1
97 --strace)
98 if which strace >/dev/null 2>&1 ; then
99 STRACECHECK="strace -o strace.log -f -tt -s 256"
100 checks="c$checks"
101 else
102 echo "Error: Can't find the tool \"strace\", --strace option will be ignored."
103 exit 1;
106 --valgrind)
107 test -n "$VALGRINDCHECK" && continue;
108 if which valgrind >/dev/null 2>&1 ; then
109 # another valgrind tool might be forced via the environment variable
110 test -z "$VALGRIND" && VALGRIND="memcheck"
111 # --trace-children-skip is pretty useful but supported only with valgrind >= 3.6.0
112 valgrind_ver=$(valgrind --version | sed -e "s/valgrind-//")
113 valgrind_ver_maj=$(echo "$valgrind_ver" | awk -F. '{ print $1 }')
114 valgrind_ver_min=$(echo "$valgrind_ver" | awk -F. '{ print $2 }')
115 valgrind_skip=
116 if [ "$valgrind_ver_maj" -gt 3 ] || ( [ "$valgrind_ver_maj" -eq 3 ] && [ "$valgrind_ver_min" -ge 6 ] ) ; then
117 valgrind_skip='--trace-children-skip=*/java,*/gij'
119 # finally set the valgrind check
120 VALGRINDCHECK="valgrind --tool=$VALGRIND --trace-children=yes $valgrind_skip --num-callers=50 --error-limit=no"
121 echo "use kill -SIGUSR2 pid to dump traces of active allocations"
122 checks="c$checks"
123 case "$VALGRIND" in
124 helgrind|memcheck|massif|exp-dhat)
125 export G_SLICE=always-malloc
126 export GLIBCXX_FORCE_NEW=1
128 esac
129 else
130 echo "Error: Can't find the tool \"valgrind\", --valgrind option will be ignored"
131 exit 1
134 esac
135 done
137 if echo "$checks" | grep -q "cc" ; then
138 echo "Error: The debug options --record, --backtrace, --strace, and --valgrind cannot be used together."
139 echo " Please, use them one by one."
140 exit 1;
143 case "$(uname -s)" in
144 NetBSD|OpenBSD|DragonFly)
145 # this is a temporary hack until we can live with the default search paths
146 LD_LIBRARY_PATH="$sd_prog${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
147 JAVA_HOME=$(javaPathHelper -h libreoffice-java 2> /dev/null)
148 export LD_LIBRARY_PATH
149 if [ -n "${JAVA_HOME}" ]; then
150 export JAVA_HOME
153 AIX)
154 LIBPATH="$sd_prog${LIBPATH:+:$LIBPATH}"
155 export LIBPATH
157 esac
159 # restore locale setting
160 LC_ALL="$LO_SAVE_LC_ALL"
162 # run soffice.bin directly when you want to get the backtrace
163 if [ -n "$GDBTRACECHECK" ] ; then
164 exec $GDBTRACECHECK "$sd_prog/soffice.bin" "$@"
167 # valgrind --log-file=valgrind.log does not work well with --trace-children=yes
168 if [ -n "$VALGRINDCHECK" ] && [ -z "$VALGRIND" ] ; then
169 echo "redirecting the standard and the error output to valgrind.log"
170 exec > valgrind.log 2>&1
173 # oosplash does the rest: forcing pages in, javaldx etc. are
174 exec $RRCHECK $VALGRINDCHECK $STRACECHECK "$sd_prog/oosplash" "$@"