Updated licence to GPL v3.
[XDGStart.git] / AppRun
blobf38def55165897d2afa7c664aaf67f519a060bf0
1 #!/bin/sh
3 PROG=XDGStart
5 APP_DIR=`dirname "$0"`
6 APP_DIR=`cd "$APP_DIR";pwd`; export APP_DIR
8 DEBUGGER=""
10 case $1 in
11 --debug) shift ; DEBUGGER=gdb ;;
12 --valgrind) shift ; DEBUGGER="valgrind --num-callers=8";;
13 --leaks) shift ; DEBUGGER="valgrind --num-callers=8 --leak-check=yes";;
14 --compile)
15 shift
16 if [ ! -d "$APP_DIR/src" ] ; then
17 echo "ERROR from $0:" >&2
18 echo "Cannot compile - source code is missing!" >&2
19 exit 1
21 echo "Compiling $APP_DIR... please wait..." >&2
22 if [ ! -x "$APP_DIR/src/configure" ]; then
23 echo "No 'configure' script! Trying to run autoconf..."
24 (cd "$APP_DIR/src"; autoconf)
26 BUILDDIR="$APP_DIR/build"
27 [ ! -d "$BUILDDIR" ] && mkdir "$BUILDDIR"
28 rm -f "$BUILDDIR/config.cache"
29 rm -f "$APP_DIR/src/config.h" # (for upgrading)
30 cd "$BUILDDIR" && "$APP_DIR/src/configure" "$@" \
31 && make clean && make && echo Done >&2 && exit 0
32 echo Compile failed >&2
33 echo Press Return... >&2
34 read WAIT
35 exit 1
36 esac
38 BIN="$APP_DIR/$PROG"
40 if [ -x "$BIN" ]; then
41 exec $DEBUGGER "$BIN" "$@"
42 else
43 echo "Message from $0:" >&2
44 echo "I cannot find an executable binary." >&2
45 echo "Trying to compile..." >&2
46 if [ -n "$DISPLAY" -a -z "$TERM" ]; then
47 xterm -e "$0" --compile
48 else
49 "$0" --compile
51 if [ -x "$BIN" ]; then
52 exec "$BIN" "$@"
54 exit 1