update credits
[LibreOffice.git] / desktop / scripts / soffice.sh
blobd34f1c38298cfcc2755778792ac8c3f6b0be3d4b
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 .
21 # STAR_PROFILE_LOCKING_DISABLED=1
22 # export STAR_PROFILE_LOCKING_DISABLED
25 # file locking now enabled by default
26 SAL_ENABLE_FILE_LOCKING=1
27 export SAL_ENABLE_FILE_LOCKING
29 # Uncomment the line below if you suspect that OpenGL is not
30 # working on your system.
31 # SAL_NOOPENGL=true; export SAL_NOOPENGL
33 # uncomment line below to disable anti aliasing of fonts
34 # SAL_ANTIALIAS_DISABLE=true; export SAL_ANTIALIAS_DISABLE
36 # uncomment line below if you encounter problems starting soffice on your system
37 # SAL_NO_XINITTHREADS=true; export SAL_NO_XINITTHREADS
39 #@JITC_PROCESSOR_TYPE_EXPORT@
41 # resolve installation directory
42 sd_cwd=`pwd`
43 sd_res=$0
44 while [ -h "$sd_res" ] ; do
45 cd "`dirname "$sd_res"`"
46 sd_basename=`basename "$sd_res"`
47 sd_res=`ls -l "$sd_basename" | sed "s/.*$sd_basename -> //g"`
48 done
49 cd "`dirname "$sd_res"`"
50 sd_prog=`pwd`
51 cd "$sd_cwd"
53 # linked build needs additional settings
54 if [ -e $sd_prog/ooenv ] ; then
55 . $sd_prog/ooenv
58 # try to get some debug output?
59 GDBTRACECHECK=
60 STRACECHECK=
61 VALGRINDCHECK=
63 # count number of selected checks; only one is allowed
64 checks=
65 # force the --valgrind option if the VALGRIND variable is set
66 test -n "$VALGRIND" && VALGRINDOPT="--valgrind" || VALGRINDOPT=
68 for arg in $@ $VALGRINDOPT ; do
69 case "$arg" in
70 --backtrace)
71 if which gdb >/dev/null 2>&1 ; then
72 GDBTRACECHECK="gdb -nx --command=$sd_prog/gdbtrace --args"
73 checks="c$checks"
74 else
75 echo "Error: Can't find the tool \"gdb\", --backtrace option will be ignored."
76 exit 1
79 --strace)
80 if which strace >/dev/null 2>&1 ; then
81 STRACECHECK="strace -o strace.log -f -tt -s 256"
82 checks="c$checks"
83 else
84 echo "Error: Can't find the tool \"strace\", --strace option will be ignored."
85 exit 1;
88 --valgrind)
89 test -n "$VALGRINDCHECK" && continue;
90 if which valgrind >/dev/null 2>&1 ; then
91 # another valgrind tool might be forced via the environment variable
92 test -z "$VALGRIND" && VALGRIND="memcheck"
93 # --trace-children-skip is pretty useful but supported only with valgrind >= 3.6.0
94 valgrind_ver=`valgrind --version | sed -e "s/valgrind-//"`
95 valgrind_ver_maj=`echo $valgrind_ver | awk -F. '{ print \$1 }'`
96 valgrind_ver_min=`echo $valgrind_ver | awk -F. '{ print \$2 }'`
97 valgrind_skip=
98 if [ "$valgrind_ver_maj" -gt 3 -o \( "$valgrind_ver_maj" -eq 3 -a "$valgrind_ver_min" -ge 6 \) ] ; then
99 valgrind_skip='--trace-children-skip=*/java'
101 # finally set the valgrind check
102 VALGRINDCHECK="valgrind --tool=$VALGRIND --trace-children=yes $valgrind_skip --num-callers=50 --error-limit=no"
103 echo "use kill -SIGUSR2 pid to dump traces of active allocations"
104 checks="c$checks"
105 if [ "$VALGRIND" = "memcheck" ] ; then
106 export G_SLICE=always-malloc
107 export GLIBCXX_FORCE_NEW=1
109 else
110 echo "Error: Can't find the tool \"valgrind\", --valgrind option will be ignored"
111 exit 1
114 esac
115 done
117 if echo "$checks" | grep -q "cc" ; then
118 echo "Error: The debug options --backtrace, --strace, and --valgrind cannot be used together."
119 echo " Please, use them one by one."
120 exit 1;
123 case "`uname -s`" in
124 NetBSD|OpenBSD|FreeBSD|DragonFly)
125 # this is a temporary hack until we can live with the default search paths
126 sd_prog1="$sd_prog"
127 sd_prog2="$sd_prog/../ure-link/lib"
128 LD_LIBRARY_PATH=$sd_prog1:$sd_prog2${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
129 JAVA_HOME=$(javaPathHelper -h libreoffice-java 2> /dev/null)
130 export LD_LIBRARY_PATH
131 if [ -n "${JAVA_HOME}" ]; then
132 export JAVA_HOME
135 AIX)
136 LIBPATH=$sd_prog:$sd_prog/../ure-link/lib${LIBPATH:+:$LIBPATH}
137 export LIBPATH
139 esac
141 # run soffice.bin directly when you want to get the backtrace
142 if [ -n "$GDBTRACECHECK" ] ; then
143 exec $GDBTRACECHECK "$sd_prog/soffice.bin" "$@"
146 # valgrind --log-file=valgrind.log does not work well with --trace-children=yes
147 if [ -n "$VALGRINDCHECK" -a -z "$VALGRIND" ] ; then
148 echo "redirecting the standard and the error output to valgrind.log"
149 exec > valgrind.log 2>&1
152 # oosplash does the rest: forcing pages in, javaldx etc. are
153 exec $VALGRINDCHECK $STRACECHECK "$sd_prog/oosplash" "$@"