r3458: --leaks option for checking memory leaks
[rox-filer.git] / ROX-Filer / AppRun
bloba338afea491729544a730756c7a6e13bc90b4a44
1 #!/bin/sh
3 PROG=ROX-Filer
5 APP_DIR=`dirname "$0"`
6 APP_DIR=`cd "$APP_DIR";pwd`; export APP_DIR
8 if [ "x$PLATFORM" = x ]; then
9 ARCH=`uname -m`
10 case "$ARCH" in
11 i?86) ARCH=ix86 ;;
12 esac
14 PLATFORM=`uname -s`-"$ARCH" export PLATFORM
17 DEBUGGER=""
19 case $1 in
20 --debug) shift ;
21 if [ "$#" = 0 ] ; then
22 DEBUGGER="gdb --args" ; DEBUG_OPTIONS="-n --g-fatal-warnings"
23 else
24 DEBUGGER="gdb"
25 fi ;;
26 --valgrind) shift ; DEBUGGER="valgrind --num-callers=8";;
27 --leaks) shift ; DEBUGGER="valgrind --num-callers=8 --leak-check=yes";;
28 --compile)
29 shift
30 if [ ! -d "$APP_DIR/src" ] ; then
31 echo "ERROR from $0:" >&2
32 echo "Cannot compile - source code is missing!" >&2
33 exit 1
35 echo "Compiling $APP_DIR... please wait..." >&2
36 if [ ! -x "$APP_DIR/src/configure" ]; then
37 echo "No 'configure' script! Trying to run autoconf..."
38 (cd "$APP_DIR/src"; autoconf)
40 rm -f "$APP_DIR/src/config.cache"
41 cd "$APP_DIR/src" && ./configure --enable-rox \
42 --with-platform="$PLATFORM" \
43 "$@" \
44 && make clean && make && echo Done >&2 && exit 0
45 echo Compile failed >&2
46 echo Press Return... >&2
47 read WAIT
48 exit 1
49 esac
51 if [ -z "$XDG_DATA_DIRS" -a -d /uri/0install/zero-install.sourceforge.net ]; then
52 # Try to get MIME database through Zero Install, if possible
53 0refresh zero-install.sourceforge.net/share/mime 2003-08-07
54 XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/uri/0install/zero-install.sourceforge.net/share
55 export XDG_DATA_DIRS
58 BIN="$APP_DIR/$PLATFORM/$PROG"
60 if [ -x "$BIN" ]; then
61 exec $DEBUGGER "$BIN" $DEBUG_OPTIONS "$@"
62 else
63 echo "ERROR from $0:" >&2
64 echo "I cannot find an executable file for your host type ($PLATFORM)." >&2
65 echo "Trying to compile..." >&2
66 if [ -n "$DISPLAY" ]; then
67 xterm -e "$0" --compile
68 else
69 "$0" --compile
71 if [ -x "$BIN" ]; then
72 exec "$BIN" "$@"
74 exit 1