3
# This Source Code Form is subject to the terms of the Mozilla Public
4
# License, v. 2.0. If a copy of the MPL was not distributed with this
5
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
cmdname=`basename "$0"`
7
MOZ_DIST_BIN=`dirname "$0"`
8
MOZ_DEFAULT_NAME="./${cmdname}-bin"
9
MOZ_APPRUNNER_NAME="./mozilla-bin"
17
##########################################################################
20
echo "Usage: ${cmdname} [options] [program]"
24
echo " -g Run in debugger."
27
echo " -d debugger Debugger to use."
28
echo " --debugger debugger"
30
echo " -a debugger_args Arguments passed to [debugger]."
31
echo " --debugger-args debugger_args"
35
echo " Run the mozilla-bin binary"
37
echo " ${cmdname} mozilla-bin"
39
echo " Debug the mozilla-bin binary in gdb"
41
echo " ${cmdname} -g mozilla-bin -d gdb"
43
echo " Run mozilla-bin under valgrind with arguments"
45
echo " ${cmdname} -g -d valgrind -a '--tool=memcheck --leak-check=full' mozilla-bin"
49
##########################################################################
54
echo "$cmdname: $message"
58
##########################################################################
71
##########################################################################
74
debuggers="ddd gdb dbx bdb native-gdb"
79
moz_test_binary /bin/which
84
dpath=`LC_MESSAGES=C type ${d} | awk '{print $3;}' | sed -e 's/\.$//'`
95
##########################################################################
100
## Make sure the program is executable
104
moz_bail "Cannot execute $prog."
109
exec "$prog" ${1+"$@"}
112
##########################################################################
117
## Make sure the program is executable
121
moz_bail "Cannot execute $prog."
123
if [ -n "$moz_debugger" ]
125
moz_test_binary /bin/which
128
debugger=`which $moz_debugger`
130
debugger=`LC_MESSAGES=C type $moz_debugger | awk '{print $3;}' | sed -e 's/\.$//'`
133
debugger=`moz_get_debugger`
135
if [ -x "$debugger" ]
137
# If you are not using ddd, gdb and know of a way to convey the arguments
138
# over to the prog then add that here- Gagan Saksena 03/15/00
139
case `basename $debugger` in
140
native-gdb) echo "$debugger $moz_debugger_args --args $prog" ${1+"$@"}
141
exec "$debugger" $moz_debugger_args --args "$prog" ${1+"$@"}
144
gdb) echo "$debugger $moz_debugger_args --args $prog" ${1+"$@"}
145
exec "$debugger" $moz_debugger_args --args "$prog" ${1+"$@"}
148
ddd) echo "$debugger $moz_debugger_args --gdb -- --args $prog" ${1+"$@"}
149
exec "$debugger" $moz_debugger_args --gdb -- --args "$prog" ${1+"$@"}
152
*) echo "$debugger $moz_debugger_args $prog ${1+"$@"}"
153
exec $debugger $moz_debugger_args "$prog" ${1+"$@"}
158
moz_bail "Could not find a debugger on your system."
161
##########################################################################
163
## Command line arg defaults
170
## Parse the command line
181
if [ "${moz_debugger}" != "" ]; then
184
echo "-d requires an argument"
188
-a | --debugger-args)
189
moz_debugger_args=$2;
190
if [ "${moz_debugger_args}" != "" ]; then
193
echo "-a requires an argument"
204
## Program name given in $1
212
## Program not given, try to guess a default
214
if [ -z "$MOZ_PROGRAM" ]
217
## Try this script's name with '-bin' appended
219
if [ -x "$MOZ_DEFAULT_NAME" ]
221
MOZ_PROGRAM=$MOZ_DEFAULT_NAME
225
elif [ -x "$MOZ_APPRUNNER_NAME" ]
227
MOZ_PROGRAM=$MOZ_APPRUNNER_NAME
233
## Make sure the program is executable
235
if [ ! -x "$MOZ_PROGRAM" ]
237
moz_bail "Cannot execute $MOZ_PROGRAM."
241
## Set MOZILLA_FIVE_HOME
243
MOZILLA_FIVE_HOME=$MOZ_DIST_BIN
245
if [ -z "$MRE_HOME" ]; then
246
MRE_HOME=$MOZILLA_FIVE_HOME
249
## Set LD_LIBRARY_PATH
251
## On Solaris we use $ORIGIN (set in RUNPATH) instead of LD_LIBRARY_PATH
252
## to locate shared libraries.
254
## When a shared library is a symbolic link, $ORIGIN will be replaced with
255
## the real path (i.e., what the symbolic link points to) by the runtime
256
## linker. For example, if dist/bin/libxul.so is a symbolic link to
257
## toolkit/library/libxul.so, $ORIGIN will be "toolkit/library" instead of "dist/bin".
258
## So the runtime linker will use "toolkit/library" NOT "dist/bin" to locate the
259
## other shared libraries that libxul.so depends on. This only happens
260
## when a user (developer) tries to start firefox, thunderbird, or seamonkey
261
## under dist/bin. To solve the problem, we should rely on LD_LIBRARY_PATH
262
## to locate shared libraries.
265
## We test $MOZ_DIST_BIN/*.so. If any of them is a symbolic link,
266
## we need to set LD_LIBRARY_PATH.
267
##########################################################################
268
moz_should_set_ld_library_path()
270
[ `uname -s` != "SunOS" ] && return 0
271
for sharedlib in $MOZ_DIST_BIN/*.so
273
[ -h $sharedlib ] && return 0
277
if moz_should_set_ld_library_path
279
LD_LIBRARY_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARY_PATH:+":$LD_LIBRARY_PATH"}
282
if [ -n "$LD_LIBRARYN32_PATH" ]
284
LD_LIBRARYN32_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARYN32_PATH:+":$LD_LIBRARYN32_PATH"}
286
if [ -n "$LD_LIBRARYN64_PATH" ]
288
LD_LIBRARYN64_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARYN64_PATH:+":$LD_LIBRARYN64_PATH"}
290
if [ -n "$LD_LIBRARY_PATH_64" ]; then
291
LD_LIBRARY_PATH_64=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARY_PATH_64:+":$LD_LIBRARY_PATH_64"}
295
## Set SHLIB_PATH for HPUX
296
SHLIB_PATH=${MOZ_DIST_BIN}:${MRE_HOME}${SHLIB_PATH:+":$SHLIB_PATH"}
298
## Set LIBPATH for AIX
299
LIBPATH=${MOZ_DIST_BIN}:${MRE_HOME}${LIBPATH:+":$LIBPATH"}
301
## Set DYLD_LIBRARY_PATH for Mac OS X (Darwin)
302
DYLD_LIBRARY_PATH=${MOZ_DIST_BIN}:${MRE_HOME}${DYLD_LIBRARY_PATH:+":$DYLD_LIBRARY_PATH"}
304
## Solaris Xserver(Xsun) tuning - use shared memory transport if available
305
if [ "$XSUNTRANSPORT" = "" ]
307
XSUNTRANSPORT="shmem"
309
export XSUNTRANSPORT XSUNSMESIZE
312
# Disable Gnome crash dialog
313
GNOME_DISABLE_CRASH_DIALOG=1
314
export GNOME_DISABLE_CRASH_DIALOG
316
if [ "$moz_debug" -eq 1 ]
318
echo "MOZILLA_FIVE_HOME=$MOZILLA_FIVE_HOME"
319
echo " LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
320
if [ -n "$LD_LIBRARYN32_PATH" ]
322
echo "LD_LIBRARYN32_PATH=$LD_LIBRARYN32_PATH"
324
if [ -n "$LD_LIBRARYN64_PATH" ]
326
echo "LD_LIBRARYN64_PATH=$LD_LIBRARYN64_PATH"
328
if [ -n "$LD_LIBRARY_PATH_64" ]; then
329
echo "LD_LIBRARY_PATH_64=$LD_LIBRARY_PATH_64"
331
if [ -n "$DISPLAY" ]; then
332
echo "DISPLAY=$DISPLAY"
334
if [ -n "$FONTCONFIG_PATH" ]; then
335
echo "FONTCONFIG_PATH=$FONTCONFIG_PATH"
337
if [ -n "$MOZILLA_POSTSCRIPT_PRINTER_LIST" ]; then
338
echo "MOZILLA_POSTSCRIPT_PRINTER_LIST=$MOZILLA_POSTSCRIPT_PRINTER_LIST"
340
echo "DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH"
341
echo " LIBRARY_PATH=$LIBRARY_PATH"
342
echo " SHLIB_PATH=$SHLIB_PATH"
343
echo " LIBPATH=$LIBPATH"
344
echo " ADDON_PATH=$ADDON_PATH"
345
echo " MOZ_PROGRAM=$MOZ_PROGRAM"
346
echo " MOZ_TOOLKIT=$MOZ_TOOLKIT"
347
echo " moz_debug=$moz_debug"
348
echo " moz_debugger=$moz_debugger"
349
echo "moz_debugger_args=$moz_debugger_args"
352
export MOZILLA_FIVE_HOME LD_LIBRARY_PATH
353
export SHLIB_PATH LIBPATH LIBRARY_PATH ADDON_PATH DYLD_LIBRARY_PATH
355
if [ $moz_debug -eq 1 ]
357
moz_debug_program ${1+"$@"}
359
moz_run_program ${1+"$@"}