source: firefox-esr.old/trunk/fuentes/firefox-esr-amd64/run-mozilla.sh @ 6471

Last change on this file since 6471 was 6471, checked in by Juanma, 21 months ago

deprecated firefox-esr

  • Property svn:executable set to *
File size: 8.7 KB
Line 
1#!/bin/sh
2#
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/.
6cmdname=`basename "$0"`
7MOZ_DIST_BIN=`dirname "$0"`
8MOZ_DEFAULT_NAME="./${cmdname}-bin"
9MOZ_APPRUNNER_NAME="./mozilla-bin"
10MOZ_PROGRAM=""
11
12exitcode=1
13#
14##
15## Functions
16##
17##########################################################################
18moz_usage()
19{
20echo "Usage:  ${cmdname} [options] [program]"
21echo ""
22echo "  options:"
23echo ""
24echo "    -g                   Run in debugger."
25echo "    --debug"
26echo ""
27echo "    -d debugger          Debugger to use."
28echo "    --debugger debugger"
29echo ""
30echo "    -a debugger_args     Arguments passed to [debugger]."
31echo "    --debugger-args debugger_args"
32echo ""
33echo "  Examples:"
34echo ""
35echo "  Run the mozilla-bin binary"
36echo ""
37echo "    ${cmdname} mozilla-bin"
38echo ""
39echo "  Debug the mozilla-bin binary in gdb"
40echo ""
41echo "    ${cmdname} -g mozilla-bin -d gdb"
42echo ""
43echo "  Run mozilla-bin under valgrind with arguments"
44echo ""
45echo "    ${cmdname} -g -d valgrind -a '--tool=memcheck --leak-check=full' mozilla-bin"
46echo ""
47        return 0
48}
49##########################################################################
50moz_bail()
51{
52        message=$1
53        echo
54        echo "$cmdname: $message"
55        echo
56        exit 1
57}
58##########################################################################
59moz_test_binary()
60{
61        binary=$1
62        if [ -f "$binary" ]
63        then
64                if [ -x "$binary" ]
65                then
66                        return 1
67                fi
68        fi
69        return 0
70}
71##########################################################################
72moz_get_debugger()
73{
74        debuggers="ddd gdb dbx bdb native-gdb"
75        debugger="notfound"
76        done="no"
77        for d in $debuggers
78        do
79                moz_test_binary /bin/which
80                if [ $? -eq 1 ]
81                then
82                        dpath=`which ${d}`     
83                else   
84                        dpath=`LC_MESSAGES=C type ${d} | awk '{print $3;}' | sed -e 's/\.$//'` 
85                fi
86                if [ -x "$dpath" ]
87                then
88                        debugger=$dpath
89                        break
90                fi
91        done
92        echo $debugger
93        return 0
94}
95##########################################################################
96moz_run_program()
97{
98        prog=$MOZ_PROGRAM
99        ##
100        ## Make sure the program is executable
101        ##
102        if [ ! -x "$prog" ]
103        then
104                moz_bail "Cannot execute $prog."
105        fi
106        ##
107        ## Run the program
108        ##
109        exec "$prog" ${1+"$@"}
110        exitcode=$?
111}
112##########################################################################
113moz_debug_program()
114{
115        prog=$MOZ_PROGRAM
116        ##
117        ## Make sure the program is executable
118        ##
119        if [ ! -x "$prog" ]
120        then
121                moz_bail "Cannot execute $prog."
122        fi
123        if [ -n "$moz_debugger" ]
124        then
125                moz_test_binary /bin/which
126                if [ $? -eq 1 ]
127                then   
128                        debugger=`which $moz_debugger` 
129                else
130                        debugger=`LC_MESSAGES=C type $moz_debugger | awk '{print $3;}' | sed -e 's/\.$//'` 
131                fi     
132        else
133                debugger=`moz_get_debugger`
134        fi
135    if [ -x "$debugger" ] 
136    then
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+"$@"}
142                exitcode=$?
143                ;;
144            gdb) echo "$debugger $moz_debugger_args --args $prog" ${1+"$@"}
145                exec "$debugger" $moz_debugger_args --args "$prog" ${1+"$@"}
146                exitcode=$?
147                ;;
148            ddd) echo "$debugger $moz_debugger_args --gdb -- --args $prog" ${1+"$@"}
149                exec "$debugger" $moz_debugger_args --gdb -- --args "$prog" ${1+"$@"}
150                exitcode=$?
151                ;;
152            *) echo "$debugger $moz_debugger_args $prog ${1+"$@"}"
153                exec $debugger $moz_debugger_args "$prog" ${1+"$@"}
154                exitcode=$?
155                ;;
156        esac
157    else
158        moz_bail "Could not find a debugger on your system."
159    fi
160}
161##########################################################################
162##
163## Command line arg defaults
164##
165moz_debug=0
166moz_debugger=""
167moz_debugger_args=""
168#
169##
170## Parse the command line
171##
172while [ $# -gt 0 ]
173do
174  case $1 in
175    -g | --debug)
176      moz_debug=1
177      shift
178      ;;
179    -d | --debugger)
180      moz_debugger=$2;
181      if [ "${moz_debugger}" != "" ]; then
182        shift 2
183      else
184        echo "-d requires an argument"
185        exit 1
186      fi
187      ;;
188    -a | --debugger-args)
189      moz_debugger_args=$2;
190      if [ "${moz_debugger_args}" != "" ]; then
191        shift 2
192      else
193        echo "-a requires an argument"
194        exit 1
195      fi
196      ;;
197    *)
198      break;
199      ;;
200  esac
201done
202#
203##
204## Program name given in $1
205##
206if [ $# -gt 0 ]
207then
208        MOZ_PROGRAM=$1
209        shift
210fi
211##
212## Program not given, try to guess a default
213##
214if [ -z "$MOZ_PROGRAM" ]
215then
216        ##
217        ## Try this script's name with '-bin' appended
218        ##
219        if [ -x "$MOZ_DEFAULT_NAME" ]
220        then
221                MOZ_PROGRAM=$MOZ_DEFAULT_NAME
222        ##
223        ## Try mozilla-bin
224        ##
225        elif [ -x "$MOZ_APPRUNNER_NAME" ]
226        then
227                MOZ_PROGRAM=$MOZ_APPRUNNER_NAME
228        fi
229fi
230#
231#
232##
233## Make sure the program is executable
234##
235if [ ! -x "$MOZ_PROGRAM" ]
236then
237        moz_bail "Cannot execute $MOZ_PROGRAM."
238fi
239#
240##
241## Set MOZILLA_FIVE_HOME
242##
243MOZILLA_FIVE_HOME=$MOZ_DIST_BIN
244
245if [ -z "$MRE_HOME" ]; then
246    MRE_HOME=$MOZILLA_FIVE_HOME
247fi
248##
249## Set LD_LIBRARY_PATH
250##
251## On Solaris we use $ORIGIN (set in RUNPATH) instead of LD_LIBRARY_PATH
252## to locate shared libraries.
253##
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.
263##
264## Note:
265##  We test $MOZ_DIST_BIN/*.so. If any of them is a symbolic link,
266##  we need to set LD_LIBRARY_PATH.
267##########################################################################
268moz_should_set_ld_library_path()
269{
270        [ `uname -s` != "SunOS" ] && return 0
271        for sharedlib in $MOZ_DIST_BIN/*.so
272        do
273                [ -h $sharedlib ] && return 0
274        done
275        return 1
276}
277if moz_should_set_ld_library_path
278then
279        LD_LIBRARY_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARY_PATH:+":$LD_LIBRARY_PATH"}
280fi
281
282if [ -n "$LD_LIBRARYN32_PATH" ]
283then
284        LD_LIBRARYN32_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARYN32_PATH:+":$LD_LIBRARYN32_PATH"}
285fi
286if [ -n "$LD_LIBRARYN64_PATH" ]
287then
288        LD_LIBRARYN64_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARYN64_PATH:+":$LD_LIBRARYN64_PATH"}
289fi
290if [ -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"}
292fi
293#
294#
295## Set SHLIB_PATH for HPUX
296SHLIB_PATH=${MOZ_DIST_BIN}:${MRE_HOME}${SHLIB_PATH:+":$SHLIB_PATH"}
297#
298## Set LIBPATH for AIX
299LIBPATH=${MOZ_DIST_BIN}:${MRE_HOME}${LIBPATH:+":$LIBPATH"}
300#
301## Set DYLD_LIBRARY_PATH for Mac OS X (Darwin)
302DYLD_LIBRARY_PATH=${MOZ_DIST_BIN}:${MRE_HOME}${DYLD_LIBRARY_PATH:+":$DYLD_LIBRARY_PATH"}
303#
304## Solaris Xserver(Xsun) tuning - use shared memory transport if available
305if [ "$XSUNTRANSPORT" = "" ]
306then
307        XSUNTRANSPORT="shmem" 
308        XSUNSMESIZE="512"
309        export XSUNTRANSPORT XSUNSMESIZE
310fi
311
312# Disable Gnome crash dialog
313GNOME_DISABLE_CRASH_DIALOG=1
314export GNOME_DISABLE_CRASH_DIALOG
315
316if [ "$moz_debug" -eq 1 ]
317then
318  echo "MOZILLA_FIVE_HOME=$MOZILLA_FIVE_HOME"
319  echo "  LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
320  if [ -n "$LD_LIBRARYN32_PATH" ]
321  then
322        echo "LD_LIBRARYN32_PATH=$LD_LIBRARYN32_PATH"
323  fi
324  if [ -n "$LD_LIBRARYN64_PATH" ]
325  then
326        echo "LD_LIBRARYN64_PATH=$LD_LIBRARYN64_PATH"
327  fi
328  if [ -n "$LD_LIBRARY_PATH_64" ]; then
329        echo "LD_LIBRARY_PATH_64=$LD_LIBRARY_PATH_64"
330  fi
331  if [ -n "$DISPLAY" ]; then
332       echo "DISPLAY=$DISPLAY"
333  fi
334  if [ -n "$FONTCONFIG_PATH" ]; then
335        echo "FONTCONFIG_PATH=$FONTCONFIG_PATH"
336  fi
337  if [ -n "$MOZILLA_POSTSCRIPT_PRINTER_LIST" ]; then
338       echo "MOZILLA_POSTSCRIPT_PRINTER_LIST=$MOZILLA_POSTSCRIPT_PRINTER_LIST"
339  fi
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"
350fi
351#
352export MOZILLA_FIVE_HOME LD_LIBRARY_PATH
353export SHLIB_PATH LIBPATH LIBRARY_PATH ADDON_PATH DYLD_LIBRARY_PATH
354
355if [ $moz_debug -eq 1 ]
356then
357        moz_debug_program ${1+"$@"}
358else
359        moz_run_program ${1+"$@"}
360fi
361
362exit $exitcode
Note: See TracBrowser for help on using the repository browser.