summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreroen <eroen-overlay@occam.eroen.eu>2017-07-16 22:55:19 +0200
committereroen <eroen-overlay@occam.eroen.eu>2017-07-16 22:55:19 +0200
commit142d368abb0fc8a6e381993a9ec0caf9617a595d (patch)
tree3fb1a69c9966a33613eccc81568ff70cfda2c177
parentvte-0.46.2 - bump (diff)
downloaderoen-142d368abb0fc8a6e381993a9ec0caf9617a595d.tar.gz
eroen-142d368abb0fc8a6e381993a9ec0caf9617a595d.tar.bz2
eroen-142d368abb0fc8a6e381993a9ec0caf9617a595d.zip
dfhack-0.43.05.2 - bump
-rw-r--r--games-util/dfhack/dfhack-0.43.05.2.ebuild113
-rw-r--r--games-util/dfhack/files/dfhack-0.43.05.2/0001-Respect-DFHACK_DATA_DESTINATION.patch86
-rw-r--r--games-util/dfhack/files/dfhack-0.43.05.2/0002-respect-DFHACK_LUA_DESTINATION.patch89
-rw-r--r--games-util/dfhack/files/dfhack-0.43.05.2/0003-respect-DFHACK_PLUGIN_DESTINATION.patch67
-rw-r--r--games-util/dfhack/files/dfhack-0.43.05.2/0004-respect-DFHACK_LIBRARY_DESTINATION.patch65
-rw-r--r--games-util/dfhack/files/dfhack-0.43.05.2/0005-introduce-DFHACK_RUBY_DESTINATION.patch88
-rw-r--r--games-util/dfhack/files/dfhack-r139
7 files changed, 547 insertions, 0 deletions
diff --git a/games-util/dfhack/dfhack-0.43.05.2.ebuild b/games-util/dfhack/dfhack-0.43.05.2.ebuild
new file mode 100644
index 0000000..ad4f060
--- /dev/null
+++ b/games-util/dfhack/dfhack-0.43.05.2.ebuild
@@ -0,0 +1,113 @@
+# By eroen <eroen-overlay@occam.eroen.eu>, 2012 - 2017
+# 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.
+
+EAPI=6
+
+inherit versionator git-r3 cmake-utils
+
+df_PV=$(get_version_component_range 1-3)
+
+DESCRIPTION="Memory hacking library for Dwarf Fortress and a set of tools that use it"
+HOMEPAGE="http://github.com/DFHack/dfhack"
+EGIT_REPO_URI="https://github.com/DFHack/dfhack.git"
+if [[ $PV == *.9999 ]]; then
+ EGIT_BRANCH="develop"
+elif [[ $PV == *_alpha* || $PV == *_beta* ]]; then
+ EGIT_MIN_CLONE="single"
+ EGIT_COMMIT="${PV/_alpha/-alpha}"
+ EGIT_COMMIT="${EGIT_COMMIT/_beta/-beta}"
+elif [[ $PV == *_pre* ]]; then
+ EGIT_MIN_CLONE_TYPE=mirror
+ EGIT_COMMIT="X"
+ xml_EGIT_COMMIT="X"
+else
+ EGIT_COMMIT="${PV%.*}-r${PV##*.}"
+fi
+
+KEYWORDS="-* ~amd64" # ~x86
+
+CMAKE_MIN_VERSION=2.8.0
+CMAKE_REMOVE_MODULES_LIST="FindCurses FindDoxygen CMakeVS10FindMake"
+
+LICENSE="ZLIB MIT BSD-2 BSD CC-BY-SA-3.0"
+SLOT="0"
+IUSE="ruby"
+
+# dfhack bundles lua (5.3 as of 0.43.05-alpha1)
+HDEPEND="
+ >=sys-devel/gcc-4.5
+ dev-lang/perl
+ dev-perl/XML-LibXML
+ dev-perl/XML-LibXSLT
+ "
+LIBRARY_DEPEND="
+ sys-libs/zlib
+ "
+DEPEND="${LIBRARY_DEPEND}
+ ${HDEPEND}"
+RDEPEND="${LIBRARY_DEPEND}
+ ruby? ( dev-lang/ruby:2.2 )
+ ~games-roguelike/dwarf-fortress-$df_PV"
+
+PATCHES=( "$FILESDIR"/dfhack-$PV )
+
+src_unpack() {
+ git-r3_src_unpack
+ if [[ -n $xml_EGIT_COMMIT ]]; then
+ cd "$S/library/xml" || die
+ git checkout "$xml_EGIT_COMMIT" || die
+ fi
+}
+
+src_prepare() {
+ default
+ sed -e "s:libruby\.so:libruby22.so:" \
+ -i plugins/ruby/ruby.cpp || die
+
+ local install="\${HOME}/.dwarf-fortress-${df_PV}_dfhack" exe="./libs/Dwarf_Fortress"
+ sed -e "s:^install=.*:install=${install}:" \
+ -e "s:^exe=.*:exe=\"${exe}\":" \
+ "$FILESDIR"/dfhack-r1 > "$T"/dfhack || die
+ cp "$FILESDIR"/dfhack-run "$T" || die
+
+ sed -e '/Could not find git index file/s/FATAL_ERROR/WARNING/' \
+ -i library/git-describe.cmake || die
+}
+
+src_configure() {
+ local mycmakeargs=(
+ -DDFHACK_BUILD_ARCH=$(usex amd64 64 "")$(usex x86 32 "")
+ -DEXTERNAL_TINYXML=NO # https://bugs.gentoo.org/show_bug.cgi?id=592696
+ -DCMAKE_INSTALL_PREFIX=/opt/dfhack
+ -DDFHACK_DATA_DESTINATION=/opt/dfhack/hack
+ -DDFHACK_LUA_DESTINATION=/opt/dfhack/hack/lua
+ -DDFHACK_PLUGIN_DESTINATION=/opt/dfhack/hack/plugins
+ -DDFHACK_LIBRARY_DESTINATION=/opt/dfhack/hack
+ -DDFHACK_RUBY_DESTINATION=/opt/dfhack/hack/ruby
+ -DBUILD_RUBY=$(usex ruby)
+ -DDOWNLOAD_RUBY=OFF
+ -DBUILD_DEV_PLUGINS=ON
+ -DBUILD_SKELETON=OFF
+ )
+
+ cmake-utils_src_configure
+}
+
+DOCS=( )
+src_install() {
+ cmake-utils_src_install
+
+ dobin "$T"/dfhack{,-run}
+}
+
+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}/.dwarf-fortress-${df_PV}_dfhack/ ,"
+ elog "otherwise the example configuration will be used."
+ elog
+ elog "To start DFHack, please run dfhack"
+}
diff --git a/games-util/dfhack/files/dfhack-0.43.05.2/0001-Respect-DFHACK_DATA_DESTINATION.patch b/games-util/dfhack/files/dfhack-0.43.05.2/0001-Respect-DFHACK_DATA_DESTINATION.patch
new file mode 100644
index 0000000..c84100b
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.43.05.2/0001-Respect-DFHACK_DATA_DESTINATION.patch
@@ -0,0 +1,86 @@
+From 535e526ec838dae0d28290d22f57caa376ae3fa8 Mon Sep 17 00:00:00 2001
+From: eroen <dfhack@occam.eroen.eu>
+Date: Sun, 16 Jul 2017 22:33:38 +0200
+Subject: [PATCH 1/5] Respect DFHACK_DATA_DESTINATION
+
+---
+ CMakeLists.txt | 2 +-
+ library/CMakeLists.txt | 3 +++
+ library/Core.cpp | 12 +++++++++---
+ 3 files changed, 13 insertions(+), 4 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 7e78340d..e22cea0b 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -158,7 +158,7 @@ ENDIF()
+ # external tools will be installed here:
+ SET(DFHACK_BINARY_DESTINATION .)
+ # dfhack data goes here:
+-SET(DFHACK_DATA_DESTINATION hack)
++SET(DFHACK_DATA_DESTINATION hack CACHE INTERNAL "")
+ # plugin libs go here:
+ SET(DFHACK_PLUGIN_DESTINATION hack/plugins)
+ # dfhack header files go here:
+diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
+index 40c122de..e71eb888 100644
+--- a/library/CMakeLists.txt
++++ b/library/CMakeLists.txt
+@@ -75,6 +75,9 @@ RemoteServer.cpp
+ RemoteTools.cpp
+ )
+
++set_property( SOURCE "Core.cpp" APPEND PROPERTY COMPILE_DEFINITIONS
++ "DFHACK_DATA_DESTINATION=\"${DFHACK_DATA_DESTINATION}\"" )
++
+ SET(MAIN_SOURCES_WINDOWS
+ Console-windows.cpp
+ Hooks-windows.cpp
+diff --git a/library/Core.cpp b/library/Core.cpp
+index fccf7f46..77c4021a 100644
+--- a/library/Core.cpp
++++ b/library/Core.cpp
+@@ -75,6 +75,7 @@ using namespace DFHack;
+ #include <stdio.h>
+ #include <iomanip>
+ #include <stdlib.h>
++#include <string.h>
+ #include <fstream>
+ #include "tinythread.h"
+ #include "md5wrapper.h"
+@@ -511,6 +512,7 @@ void Core::getScriptPaths(std::vector<std::string> *dest)
+ }
+ dest->push_back(df_path + "/raw/scripts");
+ dest->push_back(df_path + "/hack/scripts");
++ dest->push_back(DFHACK_DATA_DESTINATION "/scripts");
+ for (auto it = script_paths[1].begin(); it != script_paths[1].end(); ++it)
+ dest->push_back(*it);
+ }
+@@ -1507,7 +1509,11 @@ void Core::fatal (std::string output)
+ std::string Core::getHackPath()
+ {
+ #ifdef LINUX_BUILD
+- return p->getPath() + "/hack/";
++ if(strncmp(DFHACK_DATA_DESTINATION, "hack", 5) == 0)
++ // This is the default value
++ return p->getPath() + "/hack/";
++ else
++ return DFHACK_DATA_DESTINATION "/";
+ #else
+ return p->getPath() + "\\hack\\";
+ #endif
+@@ -1537,9 +1543,9 @@ bool Core::Init()
+
+ // find out what we are...
+ #ifdef LINUX_BUILD
+- const char * path = "hack/symbols.xml";
++ const char * path = DFHACK_DATA_DESTINATION "/symbols.xml";
+ #else
+- const char * path = "hack\\symbols.xml";
++ const char * path = DFHACK_DATA_DESTINATION "\\symbols.xml";
+ #endif
+ vif = new DFHack::VersionInfoFactory();
+ cerr << "Identifying DF version.\n";
+--
+2.13.0
+
diff --git a/games-util/dfhack/files/dfhack-0.43.05.2/0002-respect-DFHACK_LUA_DESTINATION.patch b/games-util/dfhack/files/dfhack-0.43.05.2/0002-respect-DFHACK_LUA_DESTINATION.patch
new file mode 100644
index 0000000..47ba84b
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.43.05.2/0002-respect-DFHACK_LUA_DESTINATION.patch
@@ -0,0 +1,89 @@
+From 2a162094bf064b540229376f92e6cf578cb1b39a Mon Sep 17 00:00:00 2001
+From: eroen <dfhack@occam.eroen.eu>
+Date: Mon, 29 May 2017 21:09:45 +0200
+Subject: [PATCH 2/5] respect DFHACK_LUA_DESTINATION
+
+---
+ CMakeLists.txt | 3 ++-
+ depends/lua/CMakeLists.txt | 5 ++++-
+ depends/lua/include/{luaconf.h => luaconf.h.in} | 2 +-
+ library/CMakeLists.txt | 2 +-
+ 4 files changed, 8 insertions(+), 4 deletions(-)
+ rename depends/lua/include/{luaconf.h => luaconf.h.in} (99%)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index e22cea0b..06251b45 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -164,7 +164,7 @@ SET(DFHACK_PLUGIN_DESTINATION hack/plugins)
+ # dfhack header files go here:
+ SET(DFHACK_INCLUDES_DESTINATION hack/include)
+ # dfhack lua files go here:
+-SET(DFHACK_LUA_DESTINATION hack/lua)
++SET(DFHACK_LUA_DESTINATION hack/lua CACHE INTERNAL "")
+ # the windows .lib file goes here:
+ SET(DFHACK_DEVLIB_DESTINATION hack)
+
+@@ -299,6 +299,7 @@ endif()
+
+ find_package(ZLIB REQUIRED)
+ include_directories(depends/protobuf)
++include_directories("${CMAKE_CURRENT_BINARY_DIR}/depends/lua/include")
+ include_directories(depends/lua/include)
+ include_directories(depends/md5)
+ include_directories(depends/jsoncpp)
+diff --git a/depends/lua/CMakeLists.txt b/depends/lua/CMakeLists.txt
+index 8b9ce8e2..ad7a209e 100644
+--- a/depends/lua/CMakeLists.txt
++++ b/depends/lua/CMakeLists.txt
+@@ -22,6 +22,10 @@ IF(UNIX)
+ ENDIF()
+ ENDIF()
+
++configure_file("include/luaconf.h.in" "include/luaconf.h" @ONLY)
++SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/include" PROPERTIES HEADER_FILE_ONLY TRUE)
++include_directories("${CMAKE_CURRENT_BINARY_DIR}/include")
++
+ SET (HDR_LIBLUA
+ include/lapi.h
+ include/lauxlib.h
+@@ -42,7 +46,6 @@ include/lstring.h
+ include/ltable.h
+ include/ltm.h
+ include/lua.h
+-include/luaconf.h
+ include/lualib.h
+ include/lundump.h
+ include/lvm.h
+diff --git a/depends/lua/include/luaconf.h b/depends/lua/include/luaconf.h.in
+similarity index 99%
+rename from depends/lua/include/luaconf.h
+rename to depends/lua/include/luaconf.h.in
+index 051d2a94..9d50d5ea 100644
+--- a/depends/lua/include/luaconf.h
++++ b/depends/lua/include/luaconf.h.in
+@@ -192,7 +192,7 @@
+
+ #else /* }{ */
+
+-#define LUA_LDIR "./hack/lua/"
++#define LUA_LDIR "@DFHACK_LUA_DESTINATION@" "/"
+ #define LUA_CDIR "./hack/"
+ #define LUA_PATH_DEFAULT \
+ LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" "./?.lua"
+diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
+index e71eb888..6ca16c4b 100644
+--- a/library/CMakeLists.txt
++++ b/library/CMakeLists.txt
+@@ -76,7 +76,7 @@ RemoteTools.cpp
+ )
+
+ set_property( SOURCE "Core.cpp" APPEND PROPERTY COMPILE_DEFINITIONS
+- "DFHACK_DATA_DESTINATION=\"${DFHACK_DATA_DESTINATION}\"" )
++ "DFHACK_DATA_DESTINATION=\"${DFHACK_DATA_DESTINATION}\"")
+
+ SET(MAIN_SOURCES_WINDOWS
+ Console-windows.cpp
+--
+2.13.0
+
diff --git a/games-util/dfhack/files/dfhack-0.43.05.2/0003-respect-DFHACK_PLUGIN_DESTINATION.patch b/games-util/dfhack/files/dfhack-0.43.05.2/0003-respect-DFHACK_PLUGIN_DESTINATION.patch
new file mode 100644
index 0000000..0a6b55c
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.43.05.2/0003-respect-DFHACK_PLUGIN_DESTINATION.patch
@@ -0,0 +1,67 @@
+From 809669d18946ca219b9f0e1c6a26900167c77660 Mon Sep 17 00:00:00 2001
+From: eroen <dfhack@occam.eroen.eu>
+Date: Mon, 17 Jul 2017 00:35:32 +0200
+Subject: [PATCH 3/5] respect DFHACK_PLUGIN_DESTINATION
+
+---
+ CMakeLists.txt | 2 +-
+ library/CMakeLists.txt | 4 +++-
+ library/PluginManager.cpp | 7 ++++++-
+ 3 files changed, 10 insertions(+), 3 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 06251b45..8be3c971 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -160,7 +160,7 @@ SET(DFHACK_BINARY_DESTINATION .)
+ # dfhack data goes here:
+ SET(DFHACK_DATA_DESTINATION hack CACHE INTERNAL "")
+ # plugin libs go here:
+-SET(DFHACK_PLUGIN_DESTINATION hack/plugins)
++SET(DFHACK_PLUGIN_DESTINATION hack/plugins CACHE INTERNAL "")
+ # dfhack header files go here:
+ SET(DFHACK_INCLUDES_DESTINATION hack/include)
+ # dfhack lua files go here:
+diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
+index 6ca16c4b..f9f35700 100644
+--- a/library/CMakeLists.txt
++++ b/library/CMakeLists.txt
+@@ -76,7 +76,9 @@ RemoteTools.cpp
+ )
+
+ set_property( SOURCE "Core.cpp" APPEND PROPERTY COMPILE_DEFINITIONS
+- "DFHACK_DATA_DESTINATION=\"${DFHACK_DATA_DESTINATION}\"")
++ "DFHACK_DATA_DESTINATION=\"${DFHACK_DATA_DESTINATION}\"" )
++set_property( SOURCE "PluginManager.cpp" APPEND PROPERTY COMPILE_DEFINITIONS
++ "DFHACK_PLUGIN_DESTINATION=\"${DFHACK_PLUGIN_DESTINATION}\"" )
+
+ SET(MAIN_SOURCES_WINDOWS
+ Console-windows.cpp
+diff --git a/library/PluginManager.cpp b/library/PluginManager.cpp
+index a4927a75..a4cefb13 100644
+--- a/library/PluginManager.cpp
++++ b/library/PluginManager.cpp
+@@ -52,6 +52,7 @@ using namespace std;
+ using namespace tthread;
+
+ #include <assert.h>
++#include <string.h>
+
+ #define MUTEX_GUARD(lock) auto lock_##__LINE__ = make_mutex_guard(lock);
+ template <typename T>
+@@ -70,7 +71,11 @@ tthread::lock_guard<T> make_mutex_guard (T *mutex)
+
+ static string getPluginPath()
+ {
+- return Core::getInstance().getHackPath() + "plugins/";
++ if(strncmp(DFHACK_PLUGIN_DESTINATION, "hack/plugins", 13) == 0)
++ // This is the default value
++ return Core::getInstance().getHackPath() + "plugins/";
++ else
++ return DFHACK_PLUGIN_DESTINATION "/";
+ }
+
+ static string getPluginPath (std::string name)
+--
+2.13.0
+
diff --git a/games-util/dfhack/files/dfhack-0.43.05.2/0004-respect-DFHACK_LIBRARY_DESTINATION.patch b/games-util/dfhack/files/dfhack-0.43.05.2/0004-respect-DFHACK_LIBRARY_DESTINATION.patch
new file mode 100644
index 0000000..f6455de
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.43.05.2/0004-respect-DFHACK_LIBRARY_DESTINATION.patch
@@ -0,0 +1,65 @@
+From 0775887bc1c2cb0d6f39ff61c5f9cff35bc96d31 Mon Sep 17 00:00:00 2001
+From: eroen <dfhack@occam.eroen.eu>
+Date: Mon, 29 May 2017 21:09:45 +0200
+Subject: [PATCH 4/5] respect DFHACK_LIBRARY_DESTINATION
+
+---
+ CMakeLists.txt | 4 ++--
+ plugins/ruby/CMakeLists.txt | 2 ++
+ plugins/ruby/ruby.cpp | 6 +++---
+ 3 files changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 8be3c971..9fd8c422 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -148,11 +148,11 @@ 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_LIBRARY_DESTINATION hack CACHE INTERNAL "")
+ SET(DFHACK_EGGY_DESTINATION libs)
+ 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_LIBRARY_DESTINATION . CACHE INTERNAL "")
+ SET(DFHACK_EGGY_DESTINATION .)
+ ENDIF()
+ # external tools will be installed here:
+diff --git a/plugins/ruby/CMakeLists.txt b/plugins/ruby/CMakeLists.txt
+index f1ef12ac..8272b5dd 100644
+--- a/plugins/ruby/CMakeLists.txt
++++ b/plugins/ruby/CMakeLists.txt
+@@ -76,6 +76,8 @@ INCLUDE_DIRECTORIES("${dfhack_SOURCE_DIR}/depends/tthread")
+
+ DFHACK_PLUGIN(ruby ruby.cpp LINK_LIBRARIES dfhack-tinythread)
+ ADD_DEPENDENCIES(ruby ruby-autogen-rb)
++set_property( SOURCE "ruby.cpp" APPEND PROPERTY COMPILE_DEFINITIONS
++ "DFHACK_LIBRARY_DESTINATION=\"${DFHACK_LIBRARY_DESTINATION}\"" )
+
+ IF(EXISTS ${RUBYLIB})
+ INSTALL(FILES ${RUBYLIB} DESTINATION ${DFHACK_LIBRARY_DESTINATION} RENAME ${RUBYLIB_INSTALL_NAME})
+diff --git a/plugins/ruby/ruby.cpp b/plugins/ruby/ruby.cpp
+index 15f61ac3..2624d7c9 100644
+--- a/plugins/ruby/ruby.cpp
++++ b/plugins/ruby/ruby.cpp
+@@ -322,12 +322,12 @@ static int df_loadruby(void)
+ {
+ const char *libpaths[] = {
+ #if defined(WIN32)
+- "./libruby.dll",
++ DFHACK_LIBRARY_DESTINATION "./libruby.dll",
+ #elif defined(__APPLE__)
+- "hack/libruby.dylib",
++ DFHACK_LIBRARY_DESTINATION "/libruby.dylib",
+ "/System/Library/Frameworks/Ruby.framework/Ruby",
+ #else
+- "hack/libruby.so",
++ DFHACK_LIBRARY_DESTINATION "hack/libruby.so",
+ "libruby.so",
+ #endif
+ NULL
+--
+2.13.0
+
diff --git a/games-util/dfhack/files/dfhack-0.43.05.2/0005-introduce-DFHACK_RUBY_DESTINATION.patch b/games-util/dfhack/files/dfhack-0.43.05.2/0005-introduce-DFHACK_RUBY_DESTINATION.patch
new file mode 100644
index 0000000..24b14c5
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-0.43.05.2/0005-introduce-DFHACK_RUBY_DESTINATION.patch
@@ -0,0 +1,88 @@
+From 9a9b0a6661b7bf0d1f05922881292447f67e4bc4 Mon Sep 17 00:00:00 2001
+From: eroen <dfhack@occam.eroen.eu>
+Date: Mon, 29 May 2017 21:09:45 +0200
+Subject: [PATCH 5/5] introduce DFHACK_RUBY_DESTINATION
+
+---
+ CMakeLists.txt | 2 ++
+ plugins/ruby/CMakeLists.txt | 8 ++++++--
+ plugins/ruby/ruby.cpp | 2 +-
+ plugins/ruby/{ruby.rb => ruby.rb.in} | 6 +++---
+ 4 files changed, 12 insertions(+), 6 deletions(-)
+ rename plugins/ruby/{ruby.rb => ruby.rb.in} (97%)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 9fd8c422..63595f1c 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -165,6 +165,8 @@ SET(DFHACK_PLUGIN_DESTINATION hack/plugins CACHE INTERNAL "")
+ SET(DFHACK_INCLUDES_DESTINATION hack/include)
+ # dfhack lua files go here:
+ SET(DFHACK_LUA_DESTINATION hack/lua CACHE INTERNAL "")
++# dfhack ruby files go here:
++SET(DFHACK_RUBY_DESTINATION hack/ruby CACHE INTERNAL "")
+ # the windows .lib file goes here:
+ SET(DFHACK_DEVLIB_DESTINATION hack)
+
+diff --git a/plugins/ruby/CMakeLists.txt b/plugins/ruby/CMakeLists.txt
+index 8272b5dd..ac8820f2 100644
+--- a/plugins/ruby/CMakeLists.txt
++++ b/plugins/ruby/CMakeLists.txt
+@@ -77,7 +77,8 @@ INCLUDE_DIRECTORIES("${dfhack_SOURCE_DIR}/depends/tthread")
+ DFHACK_PLUGIN(ruby ruby.cpp LINK_LIBRARIES dfhack-tinythread)
+ ADD_DEPENDENCIES(ruby ruby-autogen-rb)
+ set_property( SOURCE "ruby.cpp" APPEND PROPERTY COMPILE_DEFINITIONS
+- "DFHACK_LIBRARY_DESTINATION=\"${DFHACK_LIBRARY_DESTINATION}\"" )
++ "DFHACK_LIBRARY_DESTINATION=\"${DFHACK_LIBRARY_DESTINATION}\""
++ "DFHACK_RUBY_DESTINATION=\"${DFHACK_RUBY_DESTINATION}\"")
+
+ IF(EXISTS ${RUBYLIB})
+ INSTALL(FILES ${RUBYLIB} DESTINATION ${DFHACK_LIBRARY_DESTINATION} RENAME ${RUBYLIB_INSTALL_NAME})
+@@ -88,8 +89,11 @@ ELSE()
+ ENDIF()
+ ENDIF()
+
++configure_file( ruby.rb.in ruby.rb @ONLY )
+ INSTALL(DIRECTORY .
+- DESTINATION hack/ruby
++ DESTINATION ${DFHACK_RUBY_DESTINATION}
+ FILES_MATCHING PATTERN "*.rb")
++INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ruby.rb
++ DESTINATION ${DFHACK_RUBY_DESTINATION})
+
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RUBYAUTOGEN} DESTINATION hack/ruby)
+diff --git a/plugins/ruby/ruby.cpp b/plugins/ruby/ruby.cpp
+index 2624d7c9..afe12071 100644
+--- a/plugins/ruby/ruby.cpp
++++ b/plugins/ruby/ruby.cpp
+@@ -459,7 +459,7 @@ static void df_rubythread(void *p)
+
+ // load the default ruby-level definitions in the background
+ state=0;
+- rb_eval_string_protect("require './hack/ruby/ruby'", &state);
++ rb_eval_string_protect("require '" DFHACK_RUBY_DESTINATION "/ruby'", &state);
+ if (state)
+ dump_rb_error();
+
+diff --git a/plugins/ruby/ruby.rb b/plugins/ruby/ruby.rb.in
+similarity index 97%
+rename from plugins/ruby/ruby.rb
+rename to plugins/ruby/ruby.rb.in
+index c696c23e..62be24c5 100644
+--- a/plugins/ruby/ruby.rb
++++ b/plugins/ruby/ruby.rb.in
+@@ -251,8 +251,8 @@ def df
+ 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')
++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['./hack/ruby/*.rb'].each { |m| require m.chomp('.rb') if m !~ /ruby-autogen/ }
++Dir['@DFHACK_RUBY_DESTINATION@/*.rb'].each { |m| require m.chomp('.rb') if m !~ /ruby-autogen/ }
+--
+2.13.0
+
diff --git a/games-util/dfhack/files/dfhack-r1 b/games-util/dfhack/files/dfhack-r1
new file mode 100644
index 0000000..cd54852
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-r1
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+gamesdir=/opt/dwarf-fortress
+dfhackdir=/opt/dfhack
+install="$HOME/.dwarf-fortress"
+exe="./libs/Dwarf_Fortress"
+
+do_install() {
+ # -n switch requires GNU cp 7.1
+ cp -rn "$gamesdir"/data "$install"/
+ # DF gets unhappy when this is out of sync
+ cp -f "$gamesdir"/data/index "$install"/data/
+ cp -rsn "$gamesdir"/* "$install"/
+}
+
+do_dfhack_install() {
+ cp -sn "$dfhackdir"/hack/raw/* "$install"/raw
+
+ cp -rn "$dfhackdir"/dfhack-config "$install"/
+ cp -ns "$dfhackdir"/dfhack.init-example "$install"/
+ cp -ns "$dfhackdir"/onLoad.init-example "$install"/
+}
+
+if [ -d "$install" ]; then
+ # delete dangling symlinks
+ find -L "$install/" -type l -delete
+ # ignore "are the same file" errors
+ do_install 2>/dev/null
+ do_dfhack_install 2>/dev/null
+else
+ mkdir "$install" || exit
+ do_install || exit
+ do_dfhack_install || exit
+fi
+
+cd "$install" || exit
+export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$dfhackdir/hack/lib:$dfhackdir/hack"
+export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dfhackdir/hack/libdfhack.so"
+exec "$exe" "$@"