r3535: Fix portability of new build system and ensure configure can find the version...
[rox-filer/dt.git] / ROX-Filer / AppRun
blob9419fff204bb25c37988f758ba294bb833d8fd34
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 [ ! -d $HOME/build ] && mkdir $HOME/build
42 [ ! -d $HOME/build/"$PROG" ] && mkdir $HOME/build/"$PROG"
43 cd $HOME/build/"$PROG" && "$APP_DIR/src/configure" --enable-rox \
44 --with-platform="$PLATFORM" \
45 "$@" \
46 && make clean && make && echo Done >&2 && exit 0
47 echo Compile failed >&2
48 echo Press Return... >&2
49 read WAIT
50 exit 1
51 esac
53 if [ -z "$XDG_DATA_DIRS" -a -d /uri/0install/zero-install.sourceforge.net ]; then
54 # Try to get MIME database through Zero Install, if possible
55 0refresh zero-install.sourceforge.net/share/mime 2003-08-07
56 XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/uri/0install/zero-install.sourceforge.net/share
57 export XDG_DATA_DIRS
60 BIN="$APP_DIR/$PLATFORM/$PROG"
62 if [ -x "$BIN" ]; then
63 exec $DEBUGGER "$BIN" $DEBUG_OPTIONS "$@"
64 else
65 echo "ERROR from $0:" >&2
66 echo "I cannot find an executable file for your host type ($PLATFORM)." >&2
67 echo "Trying to compile..." >&2
68 if [ -n "$DISPLAY" ]; then
69 xterm -e "$0" --compile
70 else
71 "$0" --compile
73 if [ -x "$BIN" ]; then
74 exec "$BIN" "$@"
76 exit 1