| 1 | #!/bin/sh |
| 2 | if [ -z "$1" ] |
| 3 | then |
| 4 | echo "usage: $0 [TOOL] <example> [args...]" |
| 5 | echo |
| 6 | echo " Runs the given example, using the library in the current directory" |
| 7 | echo " instead of using the system library search mechanism. Accepts an " |
| 8 | echo " arbitrary number of arguments." |
| 9 | echo |
| 10 | echo " TOOL can be 'valgrind', 'gdb', or 'ldd', which causes exrun to" |
| 11 | echo " run the example program under the given tool." |
| 12 | echo |
| 13 | exit 1 |
| 14 | fi |
| 15 | |
| 16 | TOOL= |
| 17 | PROG=$1 |
| 18 | if [ "$PROG" = 'valgrind' ] |
| 19 | then |
| 20 | TOOL='valgrind' |
| 21 | shift |
| 22 | PROG=$1 |
| 23 | elif [ "$PROG" = 'gdb' ] |
| 24 | then |
| 25 | TOOL='gdb --args' |
| 26 | shift |
| 27 | PROG=$1 |
| 28 | elif [ "$PROG" = 'ldd' ] |
| 29 | then |
| 30 | TOOL='ldd' |
| 31 | shift |
| 32 | PROG=$1 |
| 33 | fi |
| 34 | |
| 35 | shift |
| 36 | if [ -e "$PROG" ] |
| 37 | then |
| 38 | if [ `uname -s` = 'Darwin' ] |
| 39 | then |
| 40 | DYLD_LIBRARY_PATH=. $TOOL ./$PROG $* |
| 41 | elif [ `uname -o` = 'Cygwin' ] |
| 42 | then |
| 43 | # Cygwin build case; see below for bash-as-DOS-shell case |
| 44 | PATH=. $TOOL ./$PROG $* |
| 45 | elif [ -e /usr/bin/ldd ] |
| 46 | then |
| 47 | if [ `uname -s` = 'SunOS' ] |
| 48 | then |
| 49 | LD_LIBRARY_PATH=.:/usr/mysql/lib/mysql $TOOL ./$PROG $* |
| 50 | else |
| 51 | LD_LIBRARY_PATH=. $TOOL ./$PROG $* |
| 52 | fi |
| 53 | else |
| 54 | echo "ERROR: I don't grok this system's dynamic linkage system." |
| 55 | fi |
| 56 | elif [ `uname -o` = 'Cygwin' ] |
| 57 | then |
| 58 | # VC++ build, but using Cygwin's bash as shell to run programs |
| 59 | cmd.exe /c exrun.bat $PROG $* |
| 60 | else |
| 61 | echo "usage: $0 [TOOL] <example> [args...]" |
| 62 | echo |
| 63 | echo " Run $0 without arguments for more detailed usage info." |
| 64 | echo |
| 65 | exit 1 |
| 66 | fi |