2011-07-12 18:25:27 -06:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# NOTE: This is dfhack's modification of the normal invocation script,
|
|
|
|
# changed to properly set LD_PRELOAD so as to run DFHACK.
|
2011-07-13 00:37:49 -06:00
|
|
|
#
|
|
|
|
# You can run DF under gdb by passing -g or --gdb as the first argument.
|
2011-07-17 16:50:31 -06:00
|
|
|
#
|
|
|
|
# If the file ".dfhackrc" exists in the DF directory or your home directory
|
|
|
|
# it will be sourced by this script, to let you set environmental variables.
|
|
|
|
# If it exists in both places it will first source the one in your home
|
|
|
|
# directory, then the on in the game directory.
|
|
|
|
#
|
|
|
|
# Shell variables .dfhackrc can set to affect this script:
|
|
|
|
# DF_GDB_OPTS: Options to pass to gdb, if it's being run
|
|
|
|
# DF_VALGRIND_OPTS: Options to pass to valgrind, if it's being run
|
|
|
|
# DF_HELGRIND_OPTS: Options to pass to helgrind, if it's being run
|
|
|
|
# DF_POST_CMD: Shell command to be run at very end of script
|
2011-07-12 18:25:27 -06:00
|
|
|
|
|
|
|
DF_DIR=$(dirname "$0")
|
|
|
|
cd "${DF_DIR}"
|
|
|
|
export SDL_DISABLE_LOCK_KEYS=1 # Work around for bug in Debian/Ubuntu SDL patch.
|
|
|
|
#export SDL_VIDEO_CENTERED=1 # Centre the screen. Messes up resizing.
|
|
|
|
|
2011-07-17 16:50:31 -06:00
|
|
|
# User config files
|
|
|
|
RC=".dfhackrc"
|
|
|
|
|
|
|
|
if [ -r "$HOME/$RC" ]; then
|
|
|
|
. $HOME/$RC
|
|
|
|
fi
|
|
|
|
if [ -r "./$RC" ]; then
|
|
|
|
. "./$RC"
|
|
|
|
fi
|
|
|
|
|
2012-07-12 05:00:01 -06:00
|
|
|
# Save current terminal settings
|
|
|
|
old_tty_settings=$(stty -g)
|
|
|
|
|
2011-07-17 16:50:31 -06:00
|
|
|
# Now run
|
|
|
|
|
2013-04-07 12:25:38 -06:00
|
|
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"./hack/libs":"./hack"
|
2011-08-20 05:37:14 -06:00
|
|
|
|
2011-07-13 00:37:49 -06:00
|
|
|
case "$1" in
|
|
|
|
-g | --gdb)
|
|
|
|
shift
|
2011-08-14 00:42:21 -06:00
|
|
|
echo "set environment LD_PRELOAD=./hack/libdfhack.so" > gdbcmd.tmp
|
2012-03-31 12:26:41 -06:00
|
|
|
echo "set environment MALLOC_PERTURB_=45" >> gdbcmd.tmp
|
2012-05-19 05:02:11 -06:00
|
|
|
gdb $DF_GDB_OPTS -x gdbcmd.tmp ./libs/Dwarf_Fortress "$@"
|
2011-07-15 07:55:01 -06:00
|
|
|
rm gdbcmd.tmp
|
2011-07-13 00:37:49 -06:00
|
|
|
ret=$?
|
|
|
|
;;
|
2011-07-14 00:02:29 -06:00
|
|
|
-h | --helgrind)
|
|
|
|
shift
|
2012-05-19 05:02:11 -06:00
|
|
|
LD_PRELOAD=./hack/libdfhack.so setarch i386 -R valgrind $DF_HELGRIND_OPTS --tool=helgrind --log-file=helgrind.log ./libs/Dwarf_Fortress "$@"
|
2011-07-14 00:02:29 -06:00
|
|
|
ret=$?
|
|
|
|
;;
|
|
|
|
-v | --valgrind)
|
|
|
|
shift
|
2012-05-19 05:02:11 -06:00
|
|
|
LD_PRELOAD=./hack/libdfhack.so setarch i386 -R valgrind $DF_VALGRIND_OPTS --log-file=valgrind.log ./libs/Dwarf_Fortress "$@"
|
2011-07-14 00:02:29 -06:00
|
|
|
ret=$?
|
|
|
|
;;
|
2011-07-21 03:29:26 -06:00
|
|
|
-c | --callgrind)
|
|
|
|
shift
|
2012-05-19 05:02:11 -06:00
|
|
|
LD_PRELOAD=./hack/libdfhack.so setarch i386 -R valgrind $DF_CALLGRIND_OPTS --tool=callgrind --separate-threads=yes --dump-instr=yes --instr-atstart=no --log-file=callgrind.log ./libs/Dwarf_Fortress "$@"
|
2011-07-21 03:29:26 -06:00
|
|
|
ret=$?
|
|
|
|
;;
|
2011-07-13 00:37:49 -06:00
|
|
|
*)
|
2012-05-19 05:02:11 -06:00
|
|
|
setarch i386 -R env LD_PRELOAD=./hack/libdfhack.so ./libs/Dwarf_Fortress "$@"
|
2011-07-13 00:37:49 -06:00
|
|
|
ret=$?
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-07-12 05:00:01 -06:00
|
|
|
# Restore previous terminal settings
|
|
|
|
stty "$old_tty_settings"
|
|
|
|
echo -e "\n"
|
2011-07-17 16:50:31 -06:00
|
|
|
|
|
|
|
if [ -n "$DF_POST_CMD" ]; then
|
|
|
|
eval $DF_POST_CMD
|
|
|
|
fi
|
2011-07-13 00:37:49 -06:00
|
|
|
|
|
|
|
exit $ret
|