File: AppRun

package info (click to toggle)
rox 1%3A2.11-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 9,080 kB
  • ctags: 3,776
  • sloc: ansic: 41,146; xml: 9,669; sh: 142; makefile: 129; perl: 30; python: 29
file content (66 lines) | stat: -rwxr-xr-x 1,721 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh

PROG=ROX-Filer

APP_DIR=`dirname "$0"`
APP_DIR=`cd "$APP_DIR";pwd`; export APP_DIR

DEBUGGER=""

if [ "x$MAKE" = x ]; then
  MAKE=make export MAKE
fi

case $1 in
	--debug) shift ;
		if [ "$#" = 0 ] ; then
		  DEBUGGER="gdb --args" ; DEBUG_OPTIONS="-n --g-fatal-warnings"
		else
		  DEBUGGER="gdb"
		fi ;;
	--valgrind) shift ; DEBUGGER="valgrind --num-callers=8";;
	--massif) shift ; DEBUGGER="valgrind --tool=massif --alloc-fn=g_malloc --alloc-fn=g_realloc --alloc-fn=g_malloc0 --alloc-fn=g_try_malloc --alloc-fn=g_mem_chunk_alloc";;
	--calltree) shift ; DEBUGGER="calltree";;
	--leaks) shift ; DEBUGGER="valgrind --num-callers=8 --leak-check=yes";;
	--compile)
		shift
		if [ ! -d "$APP_DIR/src" ] ; then
			echo "ERROR from $0:" >&2
			echo "Cannot compile - source code is missing!" >&2
			exit 1
		fi
		echo "Compiling $APP_DIR... please wait..." >&2
		if [ ! -x "$APP_DIR/src/configure" ]; then
		  echo "No 'configure' script! Trying to run autoconf..."
		  (cd "$APP_DIR/src"; autoconf)
		fi
		BUILDDIR="$APP_DIR/build"
		[ ! -d "$BUILDDIR" ] && mkdir "$BUILDDIR"
		rm -f "$BUILDDIR/config.cache"
		rm -f "$APP_DIR/src/config.h"	# (for upgrading)
		cd "$BUILDDIR" && "$APP_DIR/src/configure" "$@" \
			&& $MAKE clean && $MAKE && echo Done >&2 && exit 0
		echo Compile failed >&2
		echo Press Return... >&2
		read WAIT
		exit 1
esac

BIN="$APP_DIR/$PROG"

if [ -x "$BIN" ]; then
  exec $DEBUGGER "$BIN" $DEBUG_OPTIONS "$@"
else
  echo "ERROR from $0:" >&2
  echo "I cannot find an executable binary." >&2
  echo "Trying to compile..." >&2
  if [ -n "$DISPLAY" ]; then
    x-terminal-emulator -e "$0" --compile
  else
    "$0" --compile
  fi
  if [ -x "$BIN" ]; then
    exec "$BIN" "$@"
  fi
  exit 1
fi