summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreroen <eroen@occam.eroen.eu>2016-01-21 22:54:56 +0100
committereroen <eroen@occam.eroen.eu>2016-01-21 22:55:37 +0100
commit596b568b74628f3b7a5d0d599789f88d091e9922 (patch)
tree20a05f1691e0355f69d1e6632a279681f0f1d5f3 /games-util
parentdwarffortress-0.42.04 - Tune ebuild for dfhack (diff)
downloaderoen-596b568b74628f3b7a5d0d599789f88d091e9922.tar.gz
eroen-596b568b74628f3b7a5d0d599789f88d091e9922.tar.bz2
eroen-596b568b74628f3b7a5d0d599789f88d091e9922.zip
dfhack-0.42.04_alpha2 - initial bump
Diffstat (limited to 'games-util')
-rw-r--r--games-util/dfhack/dfhack-0.42.04_alpha2.ebuild247
-rw-r--r--games-util/dfhack/files/dfhack-0.42.04_alpha2/01-compile-static-libraries-as.patch65
-rw-r--r--games-util/dfhack/files/dfhack-0.42.04_alpha2/02-drop-strange-build-options.patch52
-rw-r--r--games-util/dfhack/files/dfhack-0.42.04_alpha2/03-configurable-install-paths.patch96
-rw-r--r--games-util/dfhack/files/dfhack-0.42.04_alpha2/04-compile-time-configurable.patch142
-rw-r--r--games-util/dfhack/files/dfhack-0.42.04_alpha2/05-compile-time-configurable-0.patch38
-rw-r--r--games-util/dfhack/files/dfhack-0.42.04_alpha2/06-compile-time-configurable-1.patch106
-rw-r--r--games-util/dfhack/files/dfhack-0.42.04_alpha2/07-startup-scripts-configurable.patch304
-rw-r--r--games-util/dfhack/files/dfhack-0.42.04_alpha2/08-ruby-plugin-configurable-paths.patch541
-rw-r--r--games-util/dfhack/files/dfhack-0.42.04_alpha2/09-eggy-remove-annoying-banner.patch22
-rw-r--r--games-util/dfhack/files/dfhack-0.42.04_alpha2/10-unbreak-egg.patch27
-rw-r--r--games-util/dfhack/files/dfhack-0.42.04_alpha2/11-dfhack-init-example.patch39
-rw-r--r--games-util/dfhack/files/dfhack-0.42.04_alpha2/series12
13 files changed, 1691 insertions, 0 deletions
diff --git a/games-util/dfhack/dfhack-0.42.04_alpha2.ebuild b/games-util/dfhack/dfhack-0.42.04_alpha2.ebuild
new file mode 100644
index 0000000..7ef7e0c
--- /dev/null
+++ b/games-util/dfhack/dfhack-0.42.04_alpha2.ebuild
@@ -0,0 +1,247 @@
+# By eroen, 2012-2016
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# $Header: $
+
+EAPI=5
+
+# games.eclass only used for compatibility with dwarffortress install paths
+inherit base games eutils multilib git-r3 cmake-utils
+
+my_PV="${PV/_/-}" # _alphaN -> -alphaN
+
+DESCRIPTION="Memory hacking library for Dwarf Fortress and a set of tools that use it"
+HOMEPAGE="http://github.com/DFHack/dfhack"
+EGIT_REPO_URI="git://github.com/DFHack/dfhack.git"
+#EGIT_BRANCH=
+EGIT_COMMIT=${my_PV}
+
+# There is no 32-bit ruby in gentoo yet
+SRC_URI="http://cloud.github.com/downloads/jjyg/dfhack/libruby187.tar.gz"
+
+KEYWORDS="-* ~amd64" # ~x86
+
+CMAKE_MIN_VERSION=2.8.9
+CMAKE_REMOVE_MODULES_LIST="FindCurses FindDoxygen CMakeVS10FindMake"
+
+LICENSE="ZLIB MIT BSD-2"
+SLOT=${PV%%_*} # drop _suffixN
+IUSE="api dfusion doc egg isoworld minimal stonesense"
+
+HDEPEND="
+ >=sys-devel/gcc-4.5[multilib]
+ dev-perl/XML-LibXML
+ dev-perl/XML-LibXSLT
+ doc? ( app-doc/doxygen )
+ "
+LIBRARY_DEPEND="
+ sys-libs/zlib[abi_x86_32]
+ stonesense? ( media-libs/fontconfig[abi_x86_32]
+ app-emulation/emul-linux-x86-baselibs[development]
+ media-libs/freetype[abi_x86_32]
+ x11-libs/libICE[abi_x86_32]
+ x11-libs/libSM[abi_x86_32]
+ x11-libs/libX11[abi_x86_32]
+ x11-libs/libXcursor[abi_x86_32]
+ x11-libs/libXext[abi_x86_32]
+ x11-libs/libXinerama[abi_x86_32]
+ x11-libs/libXrandr[abi_x86_32]
+ )
+ "
+DEPEND="${LIBRARY_DEPEND}
+ ${HDEPEND}"
+RDEPEND="${LIBRARY_DEPEND}
+ stonesense? ( app-emulation/emul-linux-x86-opengl
+ app-emulation/emul-linux-x86-xlibs
+ )
+ "
+# Circular dependency when building egg.
+PDEPEND="games-simulation/dwarffortress:$SLOT"
+
+## missing multilib
+#dev-lang/lua - binary bundled
+#dev-libs/protobuf - bundled
+
+pkg_setup() {
+ multilib_toolchain_setup x86
+
+ df_executable="dwarffortress-${SLOT}"
+ dfhack_datadir="${GAMES_DATADIR}/${P}"
+ dfhack_docdir="/usr/share/doc/${P}"
+ dfhack_statedir="${GAMES_STATEDIR}/${P}"
+
+ dfhack_libdir="$GAMES_PREFIX_OPT/dwarffortress-${SLOT}/libs"
+
+ QA_FLAGS_IGNORED=("${dfhack_libdir#/}"/libruby.so)
+ QA_PRESTRIPPED=("${dfhack_libdir#/}"/libruby.so)
+ QA_SONAME_NO_SYMLINK=("${dfhack_libdir#/}"/libruby.so)
+}
+
+src_unpack() {
+ git-r3_src_unpack
+
+ # prebuilt 32-bit libruby:
+ unpack ${A}
+ mv "${WORKDIR}"/libruby1.8.so.1.8.7 "${WORKDIR}"/libruby.so || die
+}
+
+src_prepare() {
+ # rm -r patches-master-$(date -I)/
+ # stg export -n -d patches-master-$(date -I) -e patch
+ # rm /usr/local/portage/games-util/dfhack/files/dfhack-0.40.06.9999/*
+ # cp patches-master-$(date -I)/* /usr/local/portage/games-util/dfhack/files/dfhack-0.40.06.9999/
+ epatch "${FILESDIR}"/${P}/*.patch
+
+# pushd "${S}"/depends/clsocket
+# epatch "${FILESDIR}"/clsocket/0001-Compile-static-library-as-PIC.patch
+# popd
+
+ #if use stonesense; then
+ # pushd "${S}"/plugins/stonesense
+ # epatch "${FILESDIR}"/stonesense-${PV}/01-null-isn-t-an-int32.patch
+ # epatch "${FILESDIR}"/stonesense-${PV}/02-configurable-install-paths.patch
+ # epatch "${FILESDIR}"/stonesense-${PV}/03-don-t-segfault-if-logfile-is.patch
+ # epatch "${FILESDIR}"/stonesense-${PV}/04-compile-time-configuration-of.patch
+ # epatch "${FILESDIR}"/stonesense-${PV}/05-compile-time-configurable-log.patch
+ # epatch "${FILESDIR}"/stonesense-${PV}/06-fix-b0rked-xml-file.patch
+ # epatch "${FILESDIR}"/stonesense-${PV}/07-compile-time-configurable-dump.patch
+ # epatch "${FILESDIR}"/stonesense-${PV}/08-compile-time-configurable.patch
+ # # Patches that no longer fit upstream, not updated yet.
+ # #epatch "${FILESDIR}"/stonesense/0003-screenshots-in-home-dir.patch
+ # popd
+ #fi
+ #if use isoworld; then
+ # pushd "${S}"/plugins/isoworld
+ # epatch "${FILESDIR}"/isoworld-${PV}/01-missing-include-dir.patch
+ # popd
+ # ewarn "The isoworld plugin requires agui, and will probably fail to build"
+ #fi
+
+ # Fix other scripts
+# if use dfusion; then
+# sed -f - -i plugins/Dfusion/luafiles/{init.lua,friendship/{init.lua,plugin.lua,install.lua},triggers/{plugin.lua,functions_menu.lua},friendship_civ/init.lua,common.lua,embark/{init.lua,plugin.lua},migrants/{init.lua,plugin.lua},xml_struct.lua,xml_types.lua} <<- EOF || die
+# s:("dfusion/:("${datadir}/dfusion/:
+# s:('dfusion/:('${datadir}/dfusion/:
+# EOF
+# sed -i "s:libs/Dwarf_Fortress:Dwarf_Fortress:" plugins/Dfusion/luafiles/common.lua
+# fi
+
+ ##Issues:
+ # - dfusion is strange. It's always been that, though.
+ # - prebuilt ruby
+ # - bundled lua
+ # - isoworld requires agui
+ # - prebuilt allegro for stonesense.
+ # - stonesense conf file: /usr/share/games/dfhack-9999/stonesense/init.txt
+ # Set in ./Config.cpp, installed together with the rest of the directory.
+ # - output files
+ # - - Make symlinks to (unversioned) /var
+
+# Doesn't build:
+# sed -e '/autolabor2/d' \
+# -e '/rprobe/d' \
+# -i plugins/devel/CMakeLists.txt || die
+:
+}
+
+src_configure() {
+ # cmake -Wno-dev -LA .. | grep -v '^--' | sed -e 's/:\S*=/=/' -e 's/.*/"-D&"/'
+ mycmakeargs=(
+ #"-DBUILD_DEVEL=OFF"
+ "$(cmake-utils_use_build api DEVEL)"
+ #"-DBUILD_DEV_PLUGINS=OFF"
+ "$(cmake-utils_use_build !minimal DEV_PLUGINS)"
+ #"-DBUILD_DFUSION=ON"
+ "$(cmake-utils_use_build dfusion DFUSION)"
+ #"-DBUILD_DOXYGEN=OFF"
+ "$(cmake-utils_use_build doc DOXYGEN)"
+ #"-DBUILD_DWARFEXPORT=ON"
+ "$(cmake-utils_use_build !minimal DWARFEXPORT)"
+ #"-DBUILD_EGGY=OFF"
+ "$(cmake-utils_use_build egg EGGY)"
+ #"-DBUILD_ISOWORLD=OFF"
+ "$(cmake-utils_use_build isoworld ISOWORLD)"
+ "-DBUILD_LIBRARY=ON"
+ #"-DBUILD_MAPEXPORT=ON"
+ "$(cmake-utils_use_build !minimal MAPEXPORT)"
+ "-DBUILD_PLUGINS=ON"
+ "-DBUILD_RUBY=ON"
+ "-DBUILD_SKELETON=OFF"
+ #"-DBUILD_SUPPORTED=ON"
+ "$(cmake-utils_use_build !minimal SUPPORTED)"
+ #"-DCMAKE_INSTALL_PREFIX=/usr/local"
+ "-DCMAKE_INSTALL_PREFIX=${GAMES_DATADIR}"
+ "-DCONSOLE_NO_CATCH=OFF"
+ #"-DDFHACK_BINARY_DESTINATION=."
+ "-DDFHACK_BINARY_DESTINATION=/usr/bin"
+ #"-DDFHACK_DATA_DESTINATION=hack"
+ "-DDFHACK_DATA_DESTINATION=${dfhack_datadir}"
+ #"-DDFHACK_DEVDOC_DESTINATION=hack"
+ "-DDFHACK_DEVDOC_DESTINATION=${dfhack_docdir}/dev"
+ #"-DDFHACK_EGGY_DESTINATION=libs"
+ "-DDFHACK_EGGY_DESTINATION=${dfhack_libdir}"
+ #"-DDFHACK_INCLUDES_DESTINATION=hack/include"
+ "-DDFHACK_INCLUDES_DESTINATION=${GAMES_PREFIX}/include"
+ #"-DDFHACK_LIBRARY_DESTINATION=hack"
+ "-DDFHACK_LIBRARY_DESTINATION=${dfhack_libdir}"
+ #"-DDFHACK_LUA_DESTINATION=hack/lua"
+ "-DDFHACK_LUA_DESTINATION=${dfhack_datadir}/lua"
+ #"-DDFHACK_PLUGIN_DESTINATION=hack/plugins"
+ "-DDFHACK_PLUGIN_DESTINATION=${dfhack_datadir}/plugins"
+ #"-DDFHACK_RUBY_DESTINATION=hack/ruby"
+ "-DDFHACK_RUBY_DESTINATION=${dfhack_datadir}/ruby"
+ #"-DDFHACK_STATEDIR=."
+ "-DDFHACK_STATEDIR=${GAMES_STATEDIR}/${P}"
+ #"-DDFHACK_USERDOC_DESTINATION=hack"
+ "-DDFHACK_USERDOC_DESTINATION=${dfhack_docdir}"
+ #"-DDF_EXECUTABLE=./libs/Dwarf_Fortress"
+ "-DDF_EXECUTABLE=${df_executable}"
+ "-DDL_RUBY=OFF"
+ "-DRUBYLIB=${WORKDIR}/libruby.so"
+ "-DINSTALL_NEW_LIBSTDCXX=OFF"
+ )
+
+ cmake-utils_src_configure
+}
+
+DOCS=""
+src_install() {
+ cmake-utils_src_install
+ mv "${ED%/}"/usr/bin/dfhack{,-${SLOT}} || die
+ mv "${ED%/}"/usr/bin/dfhack-run{,-${SLOT}} || die
+ ! use egg || mv "${ED%/}"/usr/bin/egghack{,-${SLOT}} || die
+ rm -f "${ED%/}/${dfhack_docdir}"/LICENSE.rst || die
+ dodir "${dfhack_statedir}"
+ if use stonesense; then
+ dodir "${GAMES_SYSCONFDIR#/}/${P}/stonesense"
+ mv "${ED%/}/${dfhack_datadir#/}/stonesense/init.txt" \
+ "${ED%/}/${GAMES_SYSCONFDIR#/}/${P}/stonesense/init.txt" || die
+ dosym "${ROOT}${GAMES_SYSCONFDIR#/}/${P}/stonesense/init.txt" \
+ "${dfhack_datadir#/}/stonesense/init.txt"
+ elog
+ elog "The Stonesense configuration file can be found at"
+ elog "${GAMES_SYSCONFDIR#/}/${P}/stonesense/init.txt"
+ fi
+
+ fperms g+w "${dfhack_statedir}"
+ # userpriv: portage user needs to be able to link:
+# fperms o+rx "${dfhack_libdir}"
+ use egg && fperms o+rx "${dfhack_libdir}"/libegg.so
+}
+
+pkg_postinst() {
+ elog "Due to Dwarf Fortress' special needs regarding working directory,"
+ elog "specifying relative paths to DFHack plugins can give unintended results."
+ elog
+ elog "Your dfhack.init should be placed in \${HOME}/.dwarffortress-${SLOT}/ ,"
+ elog "otherwise the example configuration will be used."
+ elog
+ if ! use egg; then
+ elog "To start DFHack, please run dfhack-${SLOT}"
+ else
+ elog "To start DFHack, please run dwarffortress-${SLOT}"
+ fi
+}
diff --git a/games-util/dfhack/files/dfhack-0.42.04_alpha2/01-compile-static-libraries-as.patch b/games-util/dfhack/files/dfhack-0.42.04_alpha2/01-compile-static-libraries-as.patch
new file mode 100644
index 0000000..e46454e
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.42.04_alpha2/01-compile-static-libraries-as.patch
@@ -0,0 +1,65 @@
+Compile static libraries as PIC.
+
+From: eroen <eroen@occam.eroen.eu>
+
+Otherwise, we get position dependent textrels in the shared libraries
+that link against them, which is slightly bad for performance (and very
+bad for portability).
+
+Cross-platform support for handling this was added in cmake 2.8.9.
+---
+ CMakeLists.txt | 2 +-
+ depends/md5/CMakeLists.txt | 3 ++-
+ depends/tinyxml/CMakeLists.txt | 3 ++-
+ depends/tthread/CMakeLists.txt | 3 ++-
+ 4 files changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 891a130..5a3df20 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -18,7 +18,7 @@ endif(CMAKE_CONFIGURATION_TYPES)
+ OPTION(BUILD_DOCS "Choose whether to build the documentation (requires python and Sphinx)." OFF)
+
+ ## some generic CMake magic
+-cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
++cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR)
+ project(dfhack)
+
+ macro(CHECK_GCC COMPILER_PATH)
+diff --git a/depends/md5/CMakeLists.txt b/depends/md5/CMakeLists.txt
+index 69e0cf0..df14e3c 100644
+--- a/depends/md5/CMakeLists.txt
++++ b/depends/md5/CMakeLists.txt
+@@ -1,3 +1,4 @@
+ project(dfhack-md5)
+ ADD_LIBRARY(dfhack-md5 STATIC EXCLUDE_FROM_ALL md5.cpp md5wrapper.cpp)
+-IDE_FOLDER(dfhack-md5 "Depends")
+\ No newline at end of file
++set_target_properties(dfhack-md5 PROPERTIES POSITION_INDEPENDENT_CODE True)
++IDE_FOLDER(dfhack-md5 "Depends")
+diff --git a/depends/tinyxml/CMakeLists.txt b/depends/tinyxml/CMakeLists.txt
+index 7d92492..f97f4bc 100644
+--- a/depends/tinyxml/CMakeLists.txt
++++ b/depends/tinyxml/CMakeLists.txt
+@@ -1,3 +1,4 @@
+ project(dfhack-tinyxml)
+ ADD_LIBRARY(dfhack-tinyxml STATIC EXCLUDE_FROM_ALL tinystr.cpp tinyxml.cpp tinyxmlerror.cpp tinyxmlparser.cpp)
+-IDE_FOLDER(dfhack-tinyxml "Depends")
+\ No newline at end of file
++set_target_properties(dfhack-tinyxml PROPERTIES POSITION_INDEPENDENT_CODE True)
++IDE_FOLDER(dfhack-tinyxml "Depends")
+diff --git a/depends/tthread/CMakeLists.txt b/depends/tthread/CMakeLists.txt
+index fa1a578..4c892ca 100644
+--- a/depends/tthread/CMakeLists.txt
++++ b/depends/tthread/CMakeLists.txt
+@@ -1,6 +1,7 @@
+ PROJECT(dfhack-tinythread)
+ ADD_LIBRARY(dfhack-tinythread STATIC EXCLUDE_FROM_ALL tinythread.cpp tinythread.h fast_mutex.h)
++set_target_properties(dfhack-tinythread PROPERTIES POSITION_INDEPENDENT_CODE True)
+ if(UNIX)
+ target_link_libraries(dfhack-tinythread pthread)
+ endif()
+-IDE_FOLDER(dfhack-tinythread "Depends")
+\ No newline at end of file
++IDE_FOLDER(dfhack-tinythread "Depends")
diff --git a/games-util/dfhack/files/dfhack-0.42.04_alpha2/02-drop-strange-build-options.patch b/games-util/dfhack/files/dfhack-0.42.04_alpha2/02-drop-strange-build-options.patch
new file mode 100644
index 0000000..fd74d18
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.42.04_alpha2/02-drop-strange-build-options.patch
@@ -0,0 +1,52 @@
+drop strange build options
+
+From: eroen <eroen@occam.eroen.eu>
+
+
+---
+ CMakeLists.txt | 4 ++--
+ depends/lua/CMakeLists.txt | 2 +-
+ library/CMakeLists.txt | 2 +-
+ 3 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 5a3df20..f07d454 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -149,8 +149,8 @@ IF(UNIX)
+ # enable C++11 features
+ add_definitions(-DLINUX_BUILD)
+ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -Wall -Wno-unused-variable")
+- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -m32 -march=i686 -mtune=generic -std=c++0x")
+- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -m32 -march=i686 -mtune=generic")
++ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -std=c++0x")
++ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
+ ELSEIF(MSVC)
+ # for msvc, tell it to always use 8-byte pointers to member functions to avoid confusion
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /vmg /vmm /MP")
+diff --git a/depends/lua/CMakeLists.txt b/depends/lua/CMakeLists.txt
+index b77bce6..e39eb04 100644
+--- a/depends/lua/CMakeLists.txt
++++ b/depends/lua/CMakeLists.txt
+@@ -12,7 +12,7 @@ ENDIF()
+
+ IF(UNIX)
+ add_definitions(-DLINUX_BUILD)
+- SET(CMAKE_C_FLAGS "-m32")
++ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+ ENDIF()
+
+ SET (HDR_LIBLUA
+diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
+index 5071d9e..5fb3823 100644
+--- a/library/CMakeLists.txt
++++ b/library/CMakeLists.txt
+@@ -232,7 +232,7 @@ ADD_CUSTOM_TARGET(generate_headers DEPENDS ${dfapi_SOURCE_DIR}/include/df/codege
+ IF(UNIX)
+ # Don't produce debug info for generated stubs
+ SET_SOURCE_FILES_PROPERTIES(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp
+- PROPERTIES COMPILE_FLAGS "-g0 -O1")
++ PROPERTIES COMPILE_FLAGS "-g0")
+ ELSE(WIN32)
+ SET_SOURCE_FILES_PROPERTIES(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp
+ PROPERTIES COMPILE_FLAGS "/O1 /bigobj")
diff --git a/games-util/dfhack/files/dfhack-0.42.04_alpha2/03-configurable-install-paths.patch b/games-util/dfhack/files/dfhack-0.42.04_alpha2/03-configurable-install-paths.patch
new file mode 100644
index 0000000..193c22a
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.42.04_alpha2/03-configurable-install-paths.patch
@@ -0,0 +1,96 @@
+configurable install paths
+
+From: eroen <eroen@occam.eroen.eu>
+
+
+---
+ CMakeLists.txt | 20 +++++++++++---------
+ library/CMakeLists.txt | 6 +++---
+ plugins/ruby/CMakeLists.txt | 4 ++--
+ 3 files changed, 16 insertions(+), 14 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f07d454..d53d151 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -112,30 +112,32 @@ set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")
+ # the dfhack libraries will be installed here:
+ IF(UNIX)
+ # put the lib into DF/hack
+- SET(DFHACK_LIBRARY_DESTINATION hack)
+- SET(DFHACK_EGGY_DESTINATION libs)
++ SET(DFHACK_LIBRARY_DESTINATION hack CACHE PATH "DFHACK_LIBRARY_DESTINATION")
++ SET(DFHACK_EGGY_DESTINATION libs CACHE PATH "DFHACK_EGGY_DESTINATION")
+ ELSE()
+ # windows is crap, therefore we can't do nice things with it. leave the libs on a nasty pile...
+ SET(DFHACK_LIBRARY_DESTINATION .)
+ SET(DFHACK_EGGY_DESTINATION .)
+ ENDIF()
+ # external tools will be installed here:
+-SET(DFHACK_BINARY_DESTINATION .)
++SET(DFHACK_BINARY_DESTINATION . CACHE PATH "DFHACK_BINARY_DESTINATION")
+ # dfhack data goes here:
+-SET(DFHACK_DATA_DESTINATION hack)
++SET(DFHACK_DATA_DESTINATION hack CACHE PATH "DFHACK_DATA_DESTINATION")
+ # plugin libs go here:
+-SET(DFHACK_PLUGIN_DESTINATION hack/plugins)
++SET(DFHACK_PLUGIN_DESTINATION hack/plugins CACHE PATH "DFHACK_PLUGIN_DESTINATION")
+ # dfhack header files go here:
+-SET(DFHACK_INCLUDES_DESTINATION hack/include)
++SET(DFHACK_INCLUDES_DESTINATION hack/include CACHE PATH "DFHACK_INCLUDES_DESTINATION")
+ # dfhack lua files go here:
+-SET(DFHACK_LUA_DESTINATION hack/lua)
++SET(DFHACK_LUA_DESTINATION hack/lua CACHE PATH "DFHACK_LUA_DESTINATION")
++# dfhack ruby files go here:
++SET(DFHACK_RUBY_DESTINATION hack/ruby CACHE PATH "DFHACK_RUBY_DESTINATION")
+ # the windows .lib file goes here:
+ SET(DFHACK_DEVLIB_DESTINATION hack)
+
+ # user documentation goes here:
+-SET(DFHACK_USERDOC_DESTINATION hack)
++SET(DFHACK_USERDOC_DESTINATION hack CACHE PATH "DFHACK_USERDOC_DESTINATION")
+ # developer documentation goes here:
+-SET(DFHACK_DEVDOC_DESTINATION hack)
++SET(DFHACK_DEVDOC_DESTINATION hack CACHE PATH "DFHACK_DEVDOC_DESTINATION")
+
+ ## some options for the user/developer to play with
+ OPTION(BUILD_LIBRARY "Build the library that goes into DF." ON)
+diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
+index 5fb3823..dd8c541 100644
+--- a/library/CMakeLists.txt
++++ b/library/CMakeLists.txt
+@@ -349,9 +349,9 @@ IF(UNIX)
+ else()
+ # On linux, copy our version of the df launch script which sets LD_PRELOAD
+ install(PROGRAMS ${dfhack_SOURCE_DIR}/package/linux/dfhack
+- DESTINATION .)
++ DESTINATION ${DFHACK_BINARY_DESTINATION})
+ install(PROGRAMS ${dfhack_SOURCE_DIR}/package/linux/dfhack-run
+- DESTINATION .)
++ DESTINATION ${DFHACK_BINARY_DESTINATION})
+ endif()
+ ELSE()
+ if(NOT BUILD_EGGY)
+@@ -377,7 +377,7 @@ install(FILES xml/symbols.xml
+ DESTINATION ${DFHACK_DATA_DESTINATION}) #linux: share/dfhack
+ #install the example autoexec file
+ install(FILES ../dfhack.init-example
+- DESTINATION ${DFHACK_BINARY_DESTINATION})
++ DESTINATION ${DFHACK_USERDOC_DESTINATION})
+
+ install(TARGETS dfhack-run dfhack-client binpatch
+ LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION}
+diff --git a/plugins/ruby/CMakeLists.txt b/plugins/ruby/CMakeLists.txt
+index 3aeac6d..640161a 100644
+--- a/plugins/ruby/CMakeLists.txt
++++ b/plugins/ruby/CMakeLists.txt
+@@ -38,7 +38,7 @@ ADD_DEPENDENCIES(ruby ruby-autogen-rb)
+ INSTALL(FILES ${RUBYLIB} DESTINATION ${DFHACK_LIBRARY_DESTINATION})
+
+ INSTALL(DIRECTORY .
+- DESTINATION hack/ruby
++ DESTINATION ${DFHACK_RUBY_DESTINATION}
+ FILES_MATCHING PATTERN "*.rb")
+
+-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RUBYAUTOGEN} DESTINATION hack/ruby)
++INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RUBYAUTOGEN} DESTINATION ${DFHACK_RUBY_DESTINATION})
diff --git a/games-util/dfhack/files/dfhack-0.42.04_alpha2/04-compile-time-configurable.patch b/games-util/dfhack/files/dfhack-0.42.04_alpha2/04-compile-time-configurable.patch
new file mode 100644
index 0000000..31439b1
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.42.04_alpha2/04-compile-time-configurable.patch
@@ -0,0 +1,142 @@
+compile-time configurable paths
+
+From: eroen <eroen@occam.eroen.eu>
+
+./hack/symbols.xml
+- Breaks startup
+
+./hack/lua
+./hack/ruby
+- Make noise on startup
+---
+ CMakeLists.txt | 4 ++++
+ depends/lua/include/luaconf.h | 8 ++++++++
+ library/Core.cpp | 6 +++++-
+ plugins/ruby/ruby.cpp | 8 ++++++++
+ plugins/sort.cpp | 8 ++++++++
+ 5 files changed, 33 insertions(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index d53d151..3488e95 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -113,6 +113,7 @@ set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")
+ IF(UNIX)
+ # put the lib into DF/hack
+ SET(DFHACK_LIBRARY_DESTINATION hack CACHE PATH "DFHACK_LIBRARY_DESTINATION")
++ ADD_DEFINITIONS(-DDFHACK_LIBRARY_DESTINATION="${DFHACK_LIBRARY_DESTINATION}")
+ SET(DFHACK_EGGY_DESTINATION libs CACHE PATH "DFHACK_EGGY_DESTINATION")
+ ELSE()
+ # windows is crap, therefore we can't do nice things with it. leave the libs on a nasty pile...
+@@ -123,14 +124,17 @@ ENDIF()
+ SET(DFHACK_BINARY_DESTINATION . CACHE PATH "DFHACK_BINARY_DESTINATION")
+ # dfhack data goes here:
+ SET(DFHACK_DATA_DESTINATION hack CACHE PATH "DFHACK_DATA_DESTINATION")
++ADD_DEFINITIONS(-DDFHACK_DATA_DESTINATION="${DFHACK_DATA_DESTINATION}")
+ # plugin libs go here:
+ SET(DFHACK_PLUGIN_DESTINATION hack/plugins CACHE PATH "DFHACK_PLUGIN_DESTINATION")
+ # dfhack header files go here:
+ SET(DFHACK_INCLUDES_DESTINATION hack/include CACHE PATH "DFHACK_INCLUDES_DESTINATION")
+ # dfhack lua files go here:
+ SET(DFHACK_LUA_DESTINATION hack/lua CACHE PATH "DFHACK_LUA_DESTINATION")
++ADD_DEFINITIONS(-DDFHACK_LUA_DESTINATION="${DFHACK_LUA_DESTINATION}")
+ # dfhack ruby files go here:
+ SET(DFHACK_RUBY_DESTINATION hack/ruby CACHE PATH "DFHACK_RUBY_DESTINATION")
++ADD_DEFINITIONS(-DDFHACK_RUBY_DESTINATION="${DFHACK_RUBY_DESTINATION}")
+ # the windows .lib file goes here:
+ SET(DFHACK_DEVLIB_DESTINATION hack)
+
+diff --git a/depends/lua/include/luaconf.h b/depends/lua/include/luaconf.h
+index af09ffb..b0e8a8a 100644
+--- a/depends/lua/include/luaconf.h
++++ b/depends/lua/include/luaconf.h
+@@ -98,8 +98,16 @@
+
+ #else /* }{ */
+
++#ifdef DFHACK_LUA_DESTINATION
++#define LUA_LDIR DFHACK_LUA_DESTINATION "/"
++#else
+ #define LUA_LDIR "./hack/lua/"
++#endif
++#ifdef DFHACK_DATA_DESTINATION
++#define LUA_CDIR DFHACK_DATA_DESTINATION "/"
++#else
+ #define LUA_CDIR "./hack/"
++#endif
+ #define LUA_PATH_DEFAULT \
+ LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" "./?.lua"
+ #define LUA_CPATH_DEFAULT \
+diff --git a/library/Core.cpp b/library/Core.cpp
+index 00447fe..39ec9b3 100644
+--- a/library/Core.cpp
++++ b/library/Core.cpp
+@@ -1407,7 +1407,11 @@ bool Core::Init()
+
+ // find out what we are...
+ #ifdef LINUX_BUILD
+- const char * path = "hack/symbols.xml";
++ #ifdef DFHACK_DATA_DESTINATION
++ const char * path = DFHACK_DATA_DESTINATION "/symbols.xml";
++ #else
++ const char * path = "hack/symbols.xml";
++ #endif
+ #else
+ const char * path = "hack\\symbols.xml";
+ #endif
+diff --git a/plugins/ruby/ruby.cpp b/plugins/ruby/ruby.cpp
+index af9ed3b..9ad581a 100644
+--- a/plugins/ruby/ruby.cpp
++++ b/plugins/ruby/ruby.cpp
+@@ -329,7 +329,11 @@ static int df_loadruby(void)
+ #elif defined(__APPLE__)
+ "hack/libruby.dylib";
+ #else
++ #ifdef DFHACK_LIBRARY_DESTINATION
++ DFHACK_LIBRARY_DESTINATION "/libruby.so";
++ #else
+ "hack/libruby.so";
++ #endif
+ #endif
+
+ libruby_handle = OpenPlugin(libpath);
+@@ -437,7 +441,11 @@ static void df_rubythread(void *p)
+
+ // load the default ruby-level definitions in the background
+ state=0;
++ #ifdef DFHACK_RUBY_DESTINATION
++ rb_eval_string_protect("require '" DFHACK_RUBY_DESTINATION "/ruby'", &state);
++ #else
+ rb_eval_string_protect("require './hack/ruby/ruby'", &state);
++ #endif
+ if (state)
+ dump_rb_error();
+
+diff --git a/plugins/sort.cpp b/plugins/sort.cpp
+index 7d80b4a..f7b4bce 100644
+--- a/plugins/sort.cpp
++++ b/plugins/sort.cpp
+@@ -63,7 +63,11 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
+ " The '>' prefix reverses the sort order for defined values.\n"
+ " Unit order examples:\n"
+ " name, age, arrival, squad, squad_position, profession\n"
++ #ifdef DFHACK_LUA_DESTINATION
++ "The orderings are defined in " DFHACK_LUA_DESTINATION "/plugins/sort/*.lua\n"
++ #else
+ "The orderings are defined in hack/lua/plugins/sort/*.lua\n"
++ #endif
+ ));
+ commands.push_back(PluginCommand(
+ "sort-items", "Sort the visible item list.", sort_items, item_list_hotkey,
+@@ -73,7 +77,11 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
+ " The '>' prefix reverses the sort order for defined values.\n"
+ " Item order examples:\n"
+ " description, material, wear, type, quality\n"
++ #ifdef DFHACK_LUA_DESTINATION
++ "The orderings are defined in " DFHACK_LUA_DESTINATION "/plugins/sort/*.lua\n"
++ #else
+ "The orderings are defined in hack/lua/plugins/sort/*.lua\n"
++ #endif
+ ));
+ return CR_OK;
+ }
diff --git a/games-util/dfhack/files/dfhack-0.42.04_alpha2/05-compile-time-configurable-0.patch b/games-util/dfhack/files/dfhack-0.42.04_alpha2/05-compile-time-configurable-0.patch
new file mode 100644
index 0000000..d43137f
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.42.04_alpha2/05-compile-time-configurable-0.patch
@@ -0,0 +1,38 @@
+compile-time configurable paths
+
+From: eroen <eroen@occam.eroen.eu>
+
+hack/
+./
+---
+ library/Core.cpp | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/library/Core.cpp b/library/Core.cpp
+index 39ec9b3..ecf8dde 100644
+--- a/library/Core.cpp
++++ b/library/Core.cpp
+@@ -375,7 +375,11 @@ static command_result runRubyScript(color_ostream &out, PluginManager *plug_mgr,
+ rbcmd += "'" + args[i] + "', ";
+ rbcmd += "]\n";
+
++#ifdef DFHACK_DATA_DESTINATION
++ rbcmd += "catch(:script_finished) { load '" DFHACK_DATA_DESTINATION "/scripts/" + name + ".rb' }";
++#else
+ rbcmd += "catch(:script_finished) { load './hack/scripts/" + name + ".rb' }";
++#endif
+
+ return plug_mgr->ruby->eval_ruby(out, rbcmd.c_str());
+ }
+@@ -1388,7 +1392,11 @@ void Core::fatal (std::string output)
+ std::string Core::getHackPath()
+ {
+ #ifdef LINUX_BUILD
++ #ifdef DFHACK_DATA_DESTINATION
++ return DFHACK_DATA_DESTINATION "/";
++ #else
+ return p->getPath() + "/hack/";
++ #endif
+ #else
+ return p->getPath() + "\\hack\\";
+ #endif
diff --git a/games-util/dfhack/files/dfhack-0.42.04_alpha2/06-compile-time-configurable-1.patch b/games-util/dfhack/files/dfhack-0.42.04_alpha2/06-compile-time-configurable-1.patch
new file mode 100644
index 0000000..8a65660
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.42.04_alpha2/06-compile-time-configurable-1.patch
@@ -0,0 +1,106 @@
+compile-time configurable state directory
+
+From: eroen <eroen@occam.eroen.eu>
+
+It'd be nice to write stuff somewhere writeable.
+---
+ CMakeLists.txt | 4 ++++
+ library/Console-posix.cpp | 4 ++++
+ library/Core.cpp | 8 ++++++++
+ library/Hooks-egg.cpp | 4 ++++
+ library/Hooks-linux.cpp | 5 +++++
+ 5 files changed, 25 insertions(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 3488e95..e50fbf6 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -108,6 +108,10 @@ SET(DFHACK_PRERELEASE TRUE)
+
+ set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")
+
++## where persistent things are written (and read) at runtime
++SET(DFHACK_STATEDIR "." CACHE PATH "DFHACK_STATEDIR")
++ADD_DEFINITIONS(-DDFHACK_STATEDIR="${DFHACK_STATEDIR}")
++
+ ## where to install things (after the build is done, classic 'make install' or package structure)
+ # the dfhack libraries will be installed here:
+ IF(UNIX)
+diff --git a/library/Console-posix.cpp b/library/Console-posix.cpp
+index 8ef879d..fb5da5b 100644
+--- a/library/Console-posix.cpp
++++ b/library/Console-posix.cpp
+@@ -746,7 +746,11 @@ bool Console::init(bool sharing)
+ inited = false;
+ return false;
+ }
++ #ifdef DFHACK_STATEDIR
++ if (!freopen(DFHACK_STATEDIR "/stdout.log", "w", stdout))
++ #else
+ if (!freopen("stdout.log", "w", stdout))
++ #endif
+ ;
+ d = new Private();
+ // make our own weird streams so our IO isn't redirected
+diff --git a/library/Core.cpp b/library/Core.cpp
+index ecf8dde..e8394e6 100644
+--- a/library/Core.cpp
++++ b/library/Core.cpp
+@@ -1285,7 +1285,11 @@ void fIOthread(void * iodata)
+ PluginManager * plug_mgr = ((IODATA*) iodata)->plug_mgr;
+
+ CommandHistory main_history;
++ #ifdef DFHACK_STATEDIR
++ main_history.load(DFHACK_STATEDIR "/dfhack.history");
++ #else
+ main_history.load("dfhack.history");
++ #endif
+
+ Console & con = core->getConsole();
+ if (plug_mgr == 0)
+@@ -1320,7 +1324,11 @@ void fIOthread(void * iodata)
+ {
+ // a proper, non-empty command was entered
+ main_history.add(command);
++ #ifdef DFHACK_STATEDIR
++ main_history.save(DFHACK_STATEDIR "/dfhack.history");
++ #else
+ main_history.save("dfhack.history");
++ #endif
+ }
+
+ auto rv = core->runCommand(con, command);
+diff --git a/library/Hooks-egg.cpp b/library/Hooks-egg.cpp
+index c98cf5d..90df6af 100644
+--- a/library/Hooks-egg.cpp
++++ b/library/Hooks-egg.cpp
+@@ -37,7 +37,11 @@ distribution.
+ DFhackCExport int egg_init(void)
+ {
+ // reroute stderr
++ #ifdef DFHACK_STATEDIR
++ freopen(DFHACK_STATEDIR "/stderr.log", "w", stderr);
++ #else
+ freopen("stderr.log", "w", stderr);
++ #endif
+ // we don't reroute stdout until we figure out if this should be done at all
+ // See: Console-linux.cpp
+ fprintf(stderr,"dfhack: hooking successful\n");
+diff --git a/library/Hooks-linux.cpp b/library/Hooks-linux.cpp
+index b0bf5a7..306ce00 100644
+--- a/library/Hooks-linux.cpp
++++ b/library/Hooks-linux.cpp
+@@ -114,8 +114,13 @@ static int (*_SDL_Init)(uint32_t flags) = 0;
+ DFhackCExport int SDL_Init(uint32_t flags)
+ {
+ // reroute stderr
++ #ifdef DFHACK_STATEDIR
++ if (!freopen(DFHACK_STATEDIR "stderr.log", "w", stderr))
++ fprintf(stderr, "dfhack: failed to reroute stderr\n");
++ #else
+ if (!freopen("stderr.log", "w", stderr))
+ fprintf(stderr, "dfhack: failed to reroute stderr\n");
++ #endif
+ // we don't reroute stdout until we figure out if this should be done at all
+ // See: Console-linux.cpp
+
diff --git a/games-util/dfhack/files/dfhack-0.42.04_alpha2/07-startup-scripts-configurable.patch b/games-util/dfhack/files/dfhack-0.42.04_alpha2/07-startup-scripts-configurable.patch
new file mode 100644
index 0000000..4f9a823
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.42.04_alpha2/07-startup-scripts-configurable.patch
@@ -0,0 +1,304 @@
+startup scripts - configurable paths
+
+From: eroen <eroen@occam.eroen.eu>
+
+
+---
+ CMakeLists.txt | 3 +
+ library/CMakeLists.txt | 13 ++++++
+ package/linux/dfhack | 87 -------------------------------------------
+ package/linux/dfhack-run | 8 ----
+ package/linux/dfhack-run.in | 8 ++++
+ package/linux/dfhack.in | 87 +++++++++++++++++++++++++++++++++++++++++++
+ package/linux/egghack | 7 ---
+ package/linux/egghack.in | 7 +++
+ 8 files changed, 118 insertions(+), 102 deletions(-)
+ delete mode 100755 package/linux/dfhack
+ delete mode 100755 package/linux/dfhack-run
+ create mode 100755 package/linux/dfhack-run.in
+ create mode 100755 package/linux/dfhack.in
+ delete mode 100755 package/linux/egghack
+ create mode 100755 package/linux/egghack.in
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index e50fbf6..ba33229 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -112,6 +112,9 @@ set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")
+ SET(DFHACK_STATEDIR "." CACHE PATH "DFHACK_STATEDIR")
+ ADD_DEFINITIONS(-DDFHACK_STATEDIR="${DFHACK_STATEDIR}")
+
++## what to call to start DF, configured into startup scripts
++SET(DF_EXECUTABLE "./libs/Dwarf_Fortress" CACHE STRING "DF_EXECUTABLE")
++
+ ## where to install things (after the build is done, classic 'make install' or package structure)
+ # the dfhack libraries will be installed here:
+ IF(UNIX)
+diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
+index dd8c541..0d82c04 100644
+--- a/library/CMakeLists.txt
++++ b/library/CMakeLists.txt
+@@ -348,10 +348,23 @@ IF(UNIX)
+ ENDIF(INSTALL_NEW_LIBSTDCXX)
+ else()
+ # On linux, copy our version of the df launch script which sets LD_PRELOAD
++ configure_file(${dfhack_SOURCE_DIR}/package/linux/dfhack.in
++ ${dfhack_SOURCE_DIR}/package/linux/dfhack
++ @ONLY)
++ configure_file(${dfhack_SOURCE_DIR}/package/linux/dfhack-run.in
++ ${dfhack_SOURCE_DIR}/package/linux/dfhack-run
++ @ONLY)
++ configure_file(${dfhack_SOURCE_DIR}/package/linux/egghack.in
++ ${dfhack_SOURCE_DIR}/package/linux/egghack
++ @ONLY)
+ install(PROGRAMS ${dfhack_SOURCE_DIR}/package/linux/dfhack
+ DESTINATION ${DFHACK_BINARY_DESTINATION})
+ install(PROGRAMS ${dfhack_SOURCE_DIR}/package/linux/dfhack-run
+ DESTINATION ${DFHACK_BINARY_DESTINATION})
++ if(BUILD_EGGY)
++ install(PROGRAMS ${dfhack_SOURCE_DIR}/package/linux/egghack
++ DESTINATION ${DFHACK_BINARY_DESTINATION})
++ endif()
+ endif()
+ ELSE()
+ if(NOT BUILD_EGGY)
+diff --git a/package/linux/dfhack b/package/linux/dfhack
+deleted file mode 100755
+index c756200..0000000
+--- a/package/linux/dfhack
++++ /dev/null
+@@ -1,87 +0,0 @@
+-#!/bin/sh
+-
+-# NOTE: This is dfhack's modification of the normal invocation script,
+-# changed to properly set LD_PRELOAD so as to run DFHACK.
+-#
+-# You can run DF under gdb by passing -g or --gdb as the first argument.
+-#
+-# 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
+-
+-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.
+-
+-# User config files
+-RC=".dfhackrc"
+-
+-if [ -r "$HOME/$RC" ]; then
+- . $HOME/$RC
+-fi
+-if [ -r "./$RC" ]; then
+- . "./$RC"
+-fi
+-
+-# Save current terminal settings
+-old_tty_settings=$(stty -g)
+-
+-# Use distro_fixes.sh from LNP if it exists
+-DISTROFIXES="distro_fixes.sh"
+-if [ -r "$DISTROFIXES" ]; then
+- . "./$DISTROFIXES"
+-fi
+-
+-# Now run
+-
+-export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"./hack/libs":"./hack"
+-
+-PRELOAD_LIB="${PRELOAD_LIB:+$PRELOAD_LIB:}./hack/libdfhack.so"
+-
+-case "$1" in
+- -g | --gdb)
+- shift
+- echo "set environment LD_PRELOAD=\"$PRELOAD_LIB\"" > gdbcmd.tmp
+- echo "set environment MALLOC_PERTURB_=45" >> gdbcmd.tmp
+- gdb $DF_GDB_OPTS -x gdbcmd.tmp ./libs/Dwarf_Fortress "$@"
+- rm gdbcmd.tmp
+- ret=$?
+- ;;
+- -h | --helgrind)
+- shift
+- LD_PRELOAD="$PRELOAD_LIB" setarch i386 -R valgrind $DF_HELGRIND_OPTS --tool=helgrind --log-file=helgrind.log ./libs/Dwarf_Fortress "$@"
+- ret=$?
+- ;;
+- -v | --valgrind)
+- shift
+- LD_PRELOAD="$PRELOAD_LIB" setarch i386 -R valgrind $DF_VALGRIND_OPTS --log-file=valgrind.log ./libs/Dwarf_Fortress "$@"
+- ret=$?
+- ;;
+- -c | --callgrind)
+- shift
+- LD_PRELOAD="$PRELOAD_LIB" 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 "$@"
+- ret=$?
+- ;;
+- *)
+- setarch i386 -R env LD_PRELOAD="$PRELOAD_LIB" ./libs/Dwarf_Fortress "$@"
+- ret=$?
+- ;;
+-esac
+-
+-# Restore previous terminal settings
+-stty "$old_tty_settings"
+-echo
+-
+-if [ -n "$DF_POST_CMD" ]; then
+- eval $DF_POST_CMD
+-fi
+-
+-exit $ret
+diff --git a/package/linux/dfhack-run b/package/linux/dfhack-run
+deleted file mode 100755
+index 55001cf..0000000
+--- a/package/linux/dfhack-run
++++ /dev/null
+@@ -1,8 +0,0 @@
+-#!/bin/sh
+-
+-DF_DIR=$(dirname "$0")
+-cd "${DF_DIR}"
+-
+-export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"./hack/libs":"./hack"
+-
+-exec hack/dfhack-run "$@"
+diff --git a/package/linux/dfhack-run.in b/package/linux/dfhack-run.in
+new file mode 100755
+index 0000000..f013053
+--- /dev/null
++++ b/package/linux/dfhack-run.in
+@@ -0,0 +1,8 @@
++#!/bin/sh
++
++DF_DIR=$(dirname "$0")
++cd "${DF_DIR}"
++
++export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}":"@DFHACK_LIBRARY_DESTINATION@"/libs:"@DFHACK_LIBRARY_DESTINATION@"
++
++exec "@DFHACK_LIBRARY_DESTINATION@"/dfhack-run "${@}"
+diff --git a/package/linux/dfhack.in b/package/linux/dfhack.in
+new file mode 100755
+index 0000000..6957151
+--- /dev/null
++++ b/package/linux/dfhack.in
+@@ -0,0 +1,87 @@
++#!/bin/sh
++
++# NOTE: This is dfhack's modification of the normal invocation script,
++# changed to properly set LD_PRELOAD so as to run DFHACK.
++#
++# You can run DF under gdb by passing -g or --gdb as the first argument.
++#
++# 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
++
++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.
++
++# User config files
++RC=".dfhackrc"
++
++if [ -r "$HOME/$RC" ]; then
++ . $HOME/$RC
++fi
++if [ -r "./$RC" ]; then
++ . "./$RC"
++fi
++
++# Save current terminal settings
++old_tty_settings=$(stty -g)
++
++# Use distro_fixes.sh from LNP if it exists
++DISTROFIXES="distro_fixes.sh"
++if [ -r "$DISTROFIXES" ]; then
++ . "./$DISTROFIXES"
++fi
++
++# Now run
++
++export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}":"@DFHACK_LIBRARY_DESTINATION@"/libs:"@DFHACK_LIBRARY_DESTINATION@"
++
++PRELOAD_LIB="${PRELOAD_LIB:+$PRELOAD_LIB:}@DFHACK_LIBRARY_DESTINATION@/libdfhack.so"
++
++case "$1" in
++ -g | --gdb)
++ shift
++ echo "set environment LD_PRELOAD=\"@DFHACK_LIBRARY_DESTINATION@/libdfhack.so\"" > gdbcmd.tmp
++ echo "set environment MALLOC_PERTURB_=45" >> gdbcmd.tmp
++ gdb ${DF_GDB_OPTS} -x gdbcmd.tmp "@DF_EXECUTABLE@" "${@}"
++ rm gdbcmd.tmp
++ ret=$?
++ ;;
++ -h | --helgrind)
++ shift
++ LD_PRELOAD="$PRELOAD_LIB" setarch i386 -R valgrind $DF_HELGRIND_OPTS --tool=helgrind --log-file=helgrind.log "@DF_EXECUTABLE@" "$@"
++ ret=$?
++ ;;
++ -v | --valgrind)
++ shift
++ LD_PRELOAD="$PRELOAD_LIB" setarch i386 -R valgrind $DF_VALGRIND_OPTS --log-file=valgrind.log "@DF_EXECUTABLE@" "$@"
++ ret=$?
++ ;;
++ -c | --callgrind)
++ shift
++ LD_PRELOAD="$PRELOAD_LIB" setarch i386 -R valgrind $DF_CALLGRIND_OPTS --tool=callgrind --separate-threads=yes --dump-instr=yes --instr-atstart=no --log-file=callgrind.log "@DF_EXECUTABLE@" "$@"
++ ret=$?
++ ;;
++ *)
++ setarch i386 -R env LD_PRELOAD="$PRELOAD_LIB" "@DF_EXECUTABLE@" "$@"
++ ret=$?
++ ;;
++esac
++
++# Restore previous terminal settings
++stty "$old_tty_settings"
++echo
++
++if [ -n "$DF_POST_CMD" ]; then
++ eval $DF_POST_CMD
++fi
++
++exit $ret
+diff --git a/package/linux/egghack b/package/linux/egghack
+deleted file mode 100755
+index 5b3b03b..0000000
+--- a/package/linux/egghack
++++ /dev/null
+@@ -1,7 +0,0 @@
+-#!/bin/sh
+-DF_DIR=$(dirname "$0")
+-cd "${DF_DIR}"
+-export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"./hack/libs":"./hack"
+-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.
+-./libs/Dwarf_Fortress $* # Go, go, go! :)
+diff --git a/package/linux/egghack.in b/package/linux/egghack.in
+new file mode 100755
+index 0000000..4bf4c9d
+--- /dev/null
++++ b/package/linux/egghack.in
+@@ -0,0 +1,7 @@
++#!/bin/sh
++DF_DIR=$(dirname "$0")
++cd "${DF_DIR}"
++export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}":"@DFHACK_LIBRARY_DESTINATION@"/libs:"@DFHACK_LIBRARY_DESTINATION@"
++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.
++"@DF_EXECUTABLE@" ${*} # Go, go, go! :)
diff --git a/games-util/dfhack/files/dfhack-0.42.04_alpha2/08-ruby-plugin-configurable-paths.patch b/games-util/dfhack/files/dfhack-0.42.04_alpha2/08-ruby-plugin-configurable-paths.patch
new file mode 100644
index 0000000..ae5cd2b
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.42.04_alpha2/08-ruby-plugin-configurable-paths.patch
@@ -0,0 +1,541 @@
+ruby plugin - configurable paths
+
+From: eroen <eroen@occam.eroen.eu>
+
+
+---
+ plugins/ruby/CMakeLists.txt | 4 +
+ plugins/ruby/ruby.rb | 247 -------------------------------------------
+ plugins/ruby/ruby.rb.in | 247 +++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 251 insertions(+), 247 deletions(-)
+ delete mode 100644 plugins/ruby/ruby.rb
+ create mode 100644 plugins/ruby/ruby.rb.in
+
+diff --git a/plugins/ruby/CMakeLists.txt b/plugins/ruby/CMakeLists.txt
+index 640161a..c4077be 100644
+--- a/plugins/ruby/CMakeLists.txt
++++ b/plugins/ruby/CMakeLists.txt
+@@ -30,6 +30,8 @@ ADD_CUSTOM_COMMAND(
+ )
+ ADD_CUSTOM_TARGET(ruby-autogen-rb DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${RUBYAUTOGEN})
+
++CONFIGURE_FILE(ruby.rb.in ruby.rb @ONLY)
++
+ INCLUDE_DIRECTORIES("${dfhack_SOURCE_DIR}/depends/tthread")
+
+ DFHACK_PLUGIN(ruby ruby.cpp LINK_LIBRARIES dfhack-tinythread)
+@@ -37,6 +39,8 @@ ADD_DEPENDENCIES(ruby ruby-autogen-rb)
+
+ INSTALL(FILES ${RUBYLIB} DESTINATION ${DFHACK_LIBRARY_DESTINATION})
+
++INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ruby.rb DESTINATION ${DFHACK_RUBY_DESTINATION})
++
+ INSTALL(DIRECTORY .
+ DESTINATION ${DFHACK_RUBY_DESTINATION}
+ FILES_MATCHING PATTERN "*.rb")
+diff --git a/plugins/ruby/ruby.rb b/plugins/ruby/ruby.rb
+deleted file mode 100644
+index 850ca09..0000000
+--- a/plugins/ruby/ruby.rb
++++ /dev/null
+@@ -1,247 +0,0 @@
+-# redefine standard i/o methods to use the dfhack console
+-module Kernel
+- def puts(*a)
+- a.flatten.each { |l|
+- DFHack.print_str(l.to_s.chomp + "\n")
+- }
+- nil
+- end
+-
+- def puts_err(*a)
+- a.flatten.each { |l|
+- DFHack.print_err(l.to_s.chomp + "\n")
+- }
+- nil
+- end
+-
+- def p(*a)
+- a.each { |e|
+- puts_err e.inspect
+- }
+- nil
+- end
+-end
+-
+-module DFHack
+- VERSION = version
+-
+- class OnupdateCallback
+- attr_accessor :callback, :timelimit, :minyear, :minyeartick, :description
+- def initialize(descr, cb, tl, initdelay=0)
+- @description = descr
+- @callback = cb
+- @ticklimit = tl
+- @minyear = (tl ? df.cur_year : 0)
+- @minyeartick = (tl ? df.cur_year_tick+initdelay : 0)
+- end
+-
+- # run callback if timedout
+- def check_run(year, yeartick, yearlen)
+- if @ticklimit
+- return unless year > @minyear or (year == @minyear and yeartick >= @minyeartick)
+- @minyear = year
+- @minyeartick = yeartick + @ticklimit
+- if @minyeartick > yearlen
+- @minyear += 1
+- @minyeartick -= yearlen
+- end
+- end
+- # t0 = Time.now
+- @callback.call
+- # dt = Time.now - t0 ; puts "rb cb #@description took #{'%.02f' % dt}s" if dt > 0.1
+- rescue Exception
+- df.onupdate_unregister self
+- puts_err "onupdate #@description unregistered: #$!", $!.backtrace
+- end
+-
+- def <=>(o)
+- [@minyear, @minyeartick] <=> [o.minyear, o.minyeartick]
+- end
+- end
+-
+- class << self
+- attr_accessor :onupdate_list, :onstatechange_list
+-
+- # register a callback to be called every gframe or more
+- # ex: DFHack.onupdate_register('fastdwarf') { DFHack.world.units[0].counters.job_counter = 0 }
+- # if ticklimit is given, do not call unless this much game ticks have passed. Handles advmode time stretching.
+- def onupdate_register(descr, ticklimit=nil, initialtickdelay=0, &b)
+- raise ArgumentError, 'need a description as 1st arg' unless descr.kind_of?(::String)
+- @onupdate_list ||= []
+- @onupdate_list << OnupdateCallback.new(descr, b, ticklimit, initialtickdelay)
+- DFHack.onupdate_active = true
+- if onext = @onupdate_list.sort.first
+- DFHack.onupdate_minyear = onext.minyear
+- DFHack.onupdate_minyeartick = onext.minyeartick
+- end
+- @onupdate_list.last
+- end
+-
+- # delete the callback for onupdate ; use the value returned by onupdate_register or the description
+- def onupdate_unregister(b)
+- b = @onupdate_list.find { |bb| bb.description == b } if b.kind_of?(String)
+- @onupdate_list.delete b
+- if @onupdate_list.empty?
+- DFHack.onupdate_active = false
+- DFHack.onupdate_minyear = DFHack.onupdate_minyeartick = DFHack.onupdate_minyeartickadv = -1
+- end
+- end
+-
+- # same as onupdate_register, but remove the callback once it returns true
+- def onupdate_register_once(*a)
+- handle = onupdate_register(*a) {
+- onupdate_unregister(handle) if yield
+- }
+- end
+-
+- TICKS_PER_YEAR = 1200*28*12
+- # this method is called by ruby.cpp if df.onupdate_active is true
+- def onupdate
+- @onupdate_list ||= []
+-
+- y = cur_year
+- ytmax = TICKS_PER_YEAR
+- if df.gamemode == :ADVENTURE and df.respond_to?(:cur_year_tick_advmode)
+- yt = cur_year_tick_advmode
+- ytmax *= 144
+- else
+- yt = cur_year_tick
+- end
+-
+- @onupdate_list.each { |o|
+- o.check_run(y, yt, ytmax)
+- }
+-
+- if onext = @onupdate_list.sort.first
+- DFHack.onupdate_minyear = onext.minyear
+- if ytmax > TICKS_PER_YEAR
+- DFHack.onupdate_minyeartick = -1
+- DFHack.onupdate_minyeartickadv = onext.minyeartick
+- else
+- DFHack.onupdate_minyeartick = onext.minyeartick
+- DFHack.onupdate_minyeartickadv = -1
+- end
+- end
+- end
+-
+- # register a callback to be called every gframe or more
+- # ex: DFHack.onstatechange_register { |newstate| puts "state changed to #{newstate}" }
+- def onstatechange_register(&b)
+- @onstatechange_list ||= []
+- @onstatechange_list << b
+- @onstatechange_list.last
+- end
+-
+- # delete the callback for onstatechange ; use the value returned by onstatechange_register
+- def onstatechange_unregister(b)
+- @onstatechange_list.delete b
+- end
+-
+- # same as onstatechange_register, but auto-unregisters if the block returns true
+- def onstatechange_register_once
+- handle = onstatechange_register { |st|
+- onstatechange_unregister(handle) if yield(st)
+- }
+- end
+-
+-
+- # this method is called by dfhack every 'onstatechange'
+- def onstatechange(newstate)
+- @onstatechange_list ||= []
+- @onstatechange_list.each { |cb| cb.call(newstate) }
+- end
+-
+- # return true if the argument is under the cursor
+- def at_cursor?(obj)
+- same_pos?(obj, cursor)
+- end
+-
+- # returns true if both arguments are at the same x/y/z
+- def same_pos?(pos1, pos2)
+- pos1 = pos1.pos if pos1.respond_to?(:pos)
+- pos2 = pos2.pos if pos2.respond_to?(:pos)
+- pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z
+- end
+-
+- # try to match a user-specified name to one from the raws
+- # uses case-switching and substring matching
+- # eg match_rawname('coal', ['COAL_BITUMINOUS', 'BAUXITE']) => 'COAL_BITUMINOUS'
+- def match_rawname(name, rawlist)
+- rawlist.each { |r| return r if name == r }
+- rawlist.each { |r| return r if name.downcase == r.downcase }
+- may = rawlist.find_all { |r| r.downcase.index(name.downcase) }
+- may.first if may.length == 1
+- end
+-
+- def translate_name(name, english=true, onlylastpart=false)
+- out = []
+-
+- if not onlylastpart
+- out << name.first_name if name.first_name != ''
+- if name.nickname != ''
+- case respond_to?(:d_init) && d_init.nickname[gametype]
+- when :REPLACE_ALL; return "`#{name.nickname}'"
+- when :REPLACE_FIRST; out.pop
+- end
+- out << "`#{name.nickname}'"
+- end
+- end
+- return out.join(' ') unless name.words.find { |w| w >= 0 }
+-
+- if not english
+- tsl = world.raws.language.translations[name.language]
+- if name.words[0] >= 0 or name.words[1] >= 0
+- out << ''
+- out.last << tsl.words[name.words[0]] if name.words[0] >= 0
+- out.last << tsl.words[name.words[1]] if name.words[1] >= 0
+- end
+- if name.words[5] >= 0
+- out << ''
+- (2..5).each { |i| out.last << tsl.words[name.words[i]] if name.words[i] >= 0 }
+- end
+- if name.words[6] >= 0
+- out << tsl.words[name.words[6]]
+- end
+- else
+- wl = world.raws.language
+- if name.words[0] >= 0 or name.words[1] >= 0
+- out << ''
+- out.last << wl.words[name.words[0]].forms[name.parts_of_speech[0]] if name.words[0] >= 0
+- out.last << wl.words[name.words[1]].forms[name.parts_of_speech[1]] if name.words[1] >= 0
+- end
+- if name.words[5] >= 0
+- out << 'the'
+- out.last.capitalize! if out.length == 1
+- out << wl.words[name.words[2]].forms[name.parts_of_speech[2]] if name.words[2] >= 0
+- out << wl.words[name.words[3]].forms[name.parts_of_speech[3]] if name.words[3] >= 0
+- if name.words[4] >= 0
+- out << wl.words[name.words[4]].forms[name.parts_of_speech[4]]
+- out.last << '-'
+- else
+- out << ''
+- end
+- out.last << wl.words[name.words[5]].forms[name.parts_of_speech[5]]
+- end
+- if name.words[6] >= 0
+- out << 'of'
+- out.last.capitalize! if out.length == 1
+- out << wl.words[name.words[6]].forms[name.parts_of_speech[6]]
+- end
+- end
+-
+- out.join(' ')
+- end
+- end
+-end
+-
+-# global alias so we can write 'df.world.units.all[0]'
+-def df
+- DFHack
+-end
+-
+-# load autogenned file
+-require './hack/ruby/ruby-autogen-defs'
+-require(RUBY_PLATFORM =~ /mswin|mingw|cygwin/i ? './hack/ruby/ruby-autogen-win' : './hack/ruby/ruby-autogen-gcc')
+-
+-# load all modules
+-Dir['./hack/ruby/*.rb'].each { |m| require m.chomp('.rb') if m !~ /ruby-autogen/ }
+diff --git a/plugins/ruby/ruby.rb.in b/plugins/ruby/ruby.rb.in
+new file mode 100644
+index 0000000..c458e19
+--- /dev/null
++++ b/plugins/ruby/ruby.rb.in
+@@ -0,0 +1,247 @@
++# redefine standard i/o methods to use the dfhack console
++module Kernel
++ def puts(*a)
++ a.flatten.each { |l|
++ DFHack.print_str(l.to_s.chomp + "\n")
++ }
++ nil
++ end
++
++ def puts_err(*a)
++ a.flatten.each { |l|
++ DFHack.print_err(l.to_s.chomp + "\n")
++ }
++ nil
++ end
++
++ def p(*a)
++ a.each { |e|
++ puts_err e.inspect
++ }
++ nil
++ end
++end
++
++module DFHack
++ VERSION = version
++
++ class OnupdateCallback
++ attr_accessor :callback, :timelimit, :minyear, :minyeartick, :description
++ def initialize(descr, cb, tl, initdelay=0)
++ @description = descr
++ @callback = cb
++ @ticklimit = tl
++ @minyear = (tl ? df.cur_year : 0)
++ @minyeartick = (tl ? df.cur_year_tick+initdelay : 0)
++ end
++
++ # run callback if timedout
++ def check_run(year, yeartick, yearlen)
++ if @ticklimit
++ return unless year > @minyear or (year == @minyear and yeartick >= @minyeartick)
++ @minyear = year
++ @minyeartick = yeartick + @ticklimit
++ if @minyeartick > yearlen
++ @minyear += 1
++ @minyeartick -= yearlen
++ end
++ end
++ # t0 = Time.now
++ @callback.call
++ # dt = Time.now - t0 ; puts "rb cb #@description took #{'%.02f' % dt}s" if dt > 0.1
++ rescue Exception
++ df.onupdate_unregister self
++ puts_err "onupdate #@description unregistered: #$!", $!.backtrace
++ end
++
++ def <=>(o)
++ [@minyear, @minyeartick] <=> [o.minyear, o.minyeartick]
++ end
++ end
++
++ class << self
++ attr_accessor :onupdate_list, :onstatechange_list
++
++ # register a callback to be called every gframe or more
++ # ex: DFHack.onupdate_register('fastdwarf') { DFHack.world.units[0].counters.job_counter = 0 }
++ # if ticklimit is given, do not call unless this much game ticks have passed. Handles advmode time stretching.
++ def onupdate_register(descr, ticklimit=nil, initialtickdelay=0, &b)
++ raise ArgumentError, 'need a description as 1st arg' unless descr.kind_of?(::String)
++ @onupdate_list ||= []
++ @onupdate_list << OnupdateCallback.new(descr, b, ticklimit, initialtickdelay)
++ DFHack.onupdate_active = true
++ if onext = @onupdate_list.sort.first
++ DFHack.onupdate_minyear = onext.minyear
++ DFHack.onupdate_minyeartick = onext.minyeartick
++ end
++ @onupdate_list.last
++ end
++
++ # delete the callback for onupdate ; use the value returned by onupdate_register or the description
++ def onupdate_unregister(b)
++ b = @onupdate_list.find { |bb| bb.description == b } if b.kind_of?(String)
++ @onupdate_list.delete b
++ if @onupdate_list.empty?
++ DFHack.onupdate_active = false
++ DFHack.onupdate_minyear = DFHack.onupdate_minyeartick = DFHack.onupdate_minyeartickadv = -1
++ end
++ end
++
++ # same as onupdate_register, but remove the callback once it returns true
++ def onupdate_register_once(*a)
++ handle = onupdate_register(*a) {
++ onupdate_unregister(handle) if yield
++ }
++ end
++
++ TICKS_PER_YEAR = 1200*28*12
++ # this method is called by ruby.cpp if df.onupdate_active is true
++ def onupdate
++ @onupdate_list ||= []
++
++ y = cur_year
++ ytmax = TICKS_PER_YEAR
++ if df.gamemode == :ADVENTURE and df.respond_to?(:cur_year_tick_advmode)
++ yt = cur_year_tick_advmode
++ ytmax *= 144
++ else
++ yt = cur_year_tick
++ end
++
++ @onupdate_list.each { |o|
++ o.check_run(y, yt, ytmax)
++ }
++
++ if onext = @onupdate_list.sort.first
++ DFHack.onupdate_minyear = onext.minyear
++ if ytmax > TICKS_PER_YEAR
++ DFHack.onupdate_minyeartick = -1
++ DFHack.onupdate_minyeartickadv = onext.minyeartick
++ else
++ DFHack.onupdate_minyeartick = onext.minyeartick
++ DFHack.onupdate_minyeartickadv = -1
++ end
++ end
++ end
++
++ # register a callback to be called every gframe or more
++ # ex: DFHack.onstatechange_register { |newstate| puts "state changed to #{newstate}" }
++ def onstatechange_register(&b)
++ @onstatechange_list ||= []
++ @onstatechange_list << b
++ @onstatechange_list.last
++ end
++
++ # delete the callback for onstatechange ; use the value returned by onstatechange_register
++ def onstatechange_unregister(b)
++ @onstatechange_list.delete b
++ end
++
++ # same as onstatechange_register, but auto-unregisters if the block returns true
++ def onstatechange_register_once
++ handle = onstatechange_register { |st|
++ onstatechange_unregister(handle) if yield(st)
++ }
++ end
++
++
++ # this method is called by dfhack every 'onstatechange'
++ def onstatechange(newstate)
++ @onstatechange_list ||= []
++ @onstatechange_list.each { |cb| cb.call(newstate) }
++ end
++
++ # return true if the argument is under the cursor
++ def at_cursor?(obj)
++ same_pos?(obj, cursor)
++ end
++
++ # returns true if both arguments are at the same x/y/z
++ def same_pos?(pos1, pos2)
++ pos1 = pos1.pos if pos1.respond_to?(:pos)
++ pos2 = pos2.pos if pos2.respond_to?(:pos)
++ pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z
++ end
++
++ # try to match a user-specified name to one from the raws
++ # uses case-switching and substring matching
++ # eg match_rawname('coal', ['COAL_BITUMINOUS', 'BAUXITE']) => 'COAL_BITUMINOUS'
++ def match_rawname(name, rawlist)
++ rawlist.each { |r| return r if name == r }
++ rawlist.each { |r| return r if name.downcase == r.downcase }
++ may = rawlist.find_all { |r| r.downcase.index(name.downcase) }
++ may.first if may.length == 1
++ end
++
++ def translate_name(name, english=true, onlylastpart=false)
++ out = []
++
++ if not onlylastpart
++ out << name.first_name if name.first_name != ''
++ if name.nickname != ''
++ case respond_to?(:d_init) && d_init.nickname[gametype]
++ when :REPLACE_ALL; return "`#{name.nickname}'"
++ when :REPLACE_FIRST; out.pop
++ end
++ out << "`#{name.nickname}'"
++ end
++ end
++ return out.join(' ') unless name.words.find { |w| w >= 0 }
++
++ if not english
++ tsl = world.raws.language.translations[name.language]
++ if name.words[0] >= 0 or name.words[1] >= 0
++ out << ''
++ out.last << tsl.words[name.words[0]] if name.words[0] >= 0
++ out.last << tsl.words[name.words[1]] if name.words[1] >= 0
++ end
++ if name.words[5] >= 0
++ out << ''
++ (2..5).each { |i| out.last << tsl.words[name.words[i]] if name.words[i] >= 0 }
++ end
++ if name.words[6] >= 0
++ out << tsl.words[name.words[6]]
++ end
++ else
++ wl = world.raws.language
++ if name.words[0] >= 0 or name.words[1] >= 0
++ out << ''
++ out.last << wl.words[name.words[0]].forms[name.parts_of_speech[0]] if name.words[0] >= 0
++ out.last << wl.words[name.words[1]].forms[name.parts_of_speech[1]] if name.words[1] >= 0
++ end
++ if name.words[5] >= 0
++ out << 'the'
++ out.last.capitalize! if out.length == 1
++ out << wl.words[name.words[2]].forms[name.parts_of_speech[2]] if name.words[2] >= 0
++ out << wl.words[name.words[3]].forms[name.parts_of_speech[3]] if name.words[3] >= 0
++ if name.words[4] >= 0
++ out << wl.words[name.words[4]].forms[name.parts_of_speech[4]]
++ out.last << '-'
++ else
++ out << ''
++ end
++ out.last << wl.words[name.words[5]].forms[name.parts_of_speech[5]]
++ end
++ if name.words[6] >= 0
++ out << 'of'
++ out.last.capitalize! if out.length == 1
++ out << wl.words[name.words[6]].forms[name.parts_of_speech[6]]
++ end
++ end
++
++ out.join(' ')
++ end
++ end
++end
++
++# global alias so we can write 'df.world.units.all[0]'
++def df
++ DFHack
++end
++
++# load autogenned file
++require '@DFHACK_RUBY_DESTINATION@/ruby-autogen-defs'
++require(RUBY_PLATFORM =~ /mswin|mingw|cygwin/i ? '@DFHACK_RUBY_DESTINATION@/ruby-autogen-win' : '@DFHACK_RUBY_DESTINATION@/ruby-autogen-gcc')
++
++# load all modules
++Dir['@DFHACK_RUBY_DESTINATION@/*.rb'].each { |m| require m.chomp('.rb') if m !~ /ruby-autogen/ }
diff --git a/games-util/dfhack/files/dfhack-0.42.04_alpha2/09-eggy-remove-annoying-banner.patch b/games-util/dfhack/files/dfhack-0.42.04_alpha2/09-eggy-remove-annoying-banner.patch
new file mode 100644
index 0000000..94c5a96
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.42.04_alpha2/09-eggy-remove-annoying-banner.patch
@@ -0,0 +1,22 @@
+eggy - remove annoying banner
+
+From: eroen <eroen@occam.eroen.eu>
+
+
+---
+ library/Core.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/library/Core.cpp b/library/Core.cpp
+index e8394e6..89be713 100644
+--- a/library/Core.cpp
++++ b/library/Core.cpp
+@@ -1561,7 +1561,7 @@ bool Core::Init()
+ // set up hotkey capture
+ thread * HK = new thread(fHKthread, (void *) temp);
+ screen_window = new Windows::top_level_window();
+- screen_window->addChild(new Windows::dfhack_dummy(5,10));
++ //screen_window->addChild(new Windows::dfhack_dummy(5,10));
+ started = true;
+ modstate = 0;
+
diff --git a/games-util/dfhack/files/dfhack-0.42.04_alpha2/10-unbreak-egg.patch b/games-util/dfhack/files/dfhack-0.42.04_alpha2/10-unbreak-egg.patch
new file mode 100644
index 0000000..cc99648
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.42.04_alpha2/10-unbreak-egg.patch
@@ -0,0 +1,27 @@
+Unbreak egg
+
+From: eroen <eroen@occam.eroen.eu>
+
+See:
+ commit fc24d24ccc2147fff61e309bcb2167b9709249b6
+ Merge Console-linux and Console-darwin into Console-posix
+---
+ library/CMakeLists.txt | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
+index 0d82c04..294a452 100644
+--- a/library/CMakeLists.txt
++++ b/library/CMakeLists.txt
+@@ -105,9 +105,9 @@ Process-darwin.cpp
+ )
+
+ SET(MAIN_SOURCES_LINUX_EGGY
+-Console-linux.cpp
++Console-posix.cpp
+ Hooks-egg.cpp
+-PlugLoad-linux.cpp
++PlugLoad-posix.cpp
+ Process-linux.cpp
+ )
+
diff --git a/games-util/dfhack/files/dfhack-0.42.04_alpha2/11-dfhack-init-example.patch b/games-util/dfhack/files/dfhack-0.42.04_alpha2/11-dfhack-init-example.patch
new file mode 100644
index 0000000..70f9a04
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.42.04_alpha2/11-dfhack-init-example.patch
@@ -0,0 +1,39 @@
+dfhack.init.example
+
+From: eroen <eroen@occam.eroen.eu>
+
+
+---
+ library/CMakeLists.txt | 2 +-
+ library/Core.cpp | 4 ++++
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
+index 294a452..a323a40 100644
+--- a/library/CMakeLists.txt
++++ b/library/CMakeLists.txt
+@@ -390,7 +390,7 @@ install(FILES xml/symbols.xml
+ DESTINATION ${DFHACK_DATA_DESTINATION}) #linux: share/dfhack
+ #install the example autoexec file
+ install(FILES ../dfhack.init-example
+- DESTINATION ${DFHACK_USERDOC_DESTINATION})
++ DESTINATION ${DFHACK_DATA_DESTINATION})
+
+ install(TARGETS dfhack-run dfhack-client binpatch
+ LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION}
+diff --git a/library/Core.cpp b/library/Core.cpp
+index 89be713..5ab28ae 100644
+--- a/library/Core.cpp
++++ b/library/Core.cpp
+@@ -1263,7 +1263,11 @@ static void run_dfhack_init(color_ostream &out, Core *core)
+ if (!count || !Filesystem::isfile("dfhack.init"))
+ {
+ core->runCommand(out, "gui/no-dfhack-init");
++#ifdef DFHACK_DATA_DESTINATION
++ core->loadScriptFile(out, DFHACK_DATA_DESTINATION "/dfhack.init-example", true);
++#else
+ core->loadScriptFile(out, "dfhack.init-example", true);
++#endif
+ }
+ }
+
diff --git a/games-util/dfhack/files/dfhack-0.42.04_alpha2/series b/games-util/dfhack/files/dfhack-0.42.04_alpha2/series
new file mode 100644
index 0000000..de90337
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.42.04_alpha2/series
@@ -0,0 +1,12 @@
+# This series applies on GIT commit b62a8673bc5cf678051d56fb6a94f41a6cf3fdcf
+01-compile-static-libraries-as.patch
+02-drop-strange-build-options.patch
+03-configurable-install-paths.patch
+04-compile-time-configurable.patch
+05-compile-time-configurable-0.patch
+06-compile-time-configurable-1.patch
+07-startup-scripts-configurable.patch
+08-ruby-plugin-configurable-paths.patch
+09-eggy-remove-annoying-banner.patch
+10-unbreak-egg.patch
+11-dfhack-init-example.patch