ef51c4
From e24d97c938c481450ed80ec83e5399595946c1ae Mon Sep 17 00:00:00 2001
ef51c4
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
ef51c4
Date: Fri, 8 Feb 2013 22:48:41 +0100
ef51c4
Subject: [PATCH] Prevent duplicated paths when empty version string is
ef51c4
 configured.
ef51c4
ef51c4
---
ef51c4
 configure.ac     |  3 ++-
ef51c4
 loadpath.c       | 12 ++++++++++++
ef51c4
 tool/mkconfig.rb |  2 +-
ef51c4
 3 files changed, 15 insertions(+), 2 deletions(-)
ef51c4
ef51c4
diff --git a/configure.ac b/configure.ac
ef51c4
index c42436c23d..d261ea57b5 100644
ef51c4
--- a/configure.ac
ef51c4
+++ b/configure.ac
ef51c4
@@ -3881,7 +3881,8 @@ AS_CASE(["$ruby_version_dir_name"],
ef51c4
 ruby_version_dir=/'${ruby_version_dir_name}'
ef51c4
 
ef51c4
 if test -z "${ruby_version_dir_name}"; then
ef51c4
-    AC_MSG_ERROR([No ruby version, No place for bundled libraries])
ef51c4
+    unset ruby_version_dir
ef51c4
+    AC_DEFINE(RUBY_LIB_VERSION_BLANK, 1)
ef51c4
 fi
ef51c4
 
ef51c4
 rubylibdir='${rubylibprefix}'${ruby_version_dir}
ef51c4
diff --git a/loadpath.c b/loadpath.c
ef51c4
index 9160031..0d4d953 100644
ef51c4
--- a/loadpath.c
ef51c4
+++ b/loadpath.c
ef51c4
@@ -65,21 +65,33 @@ const char ruby_initial_load_paths[] =
ef51c4
     RUBY_SEARCH_PATH "\0"
ef51c4
 #endif
ef51c4
 #ifndef NO_RUBY_SITE_LIB
ef51c4
+#ifdef RUBY_LIB_VERSION_BLANK
ef51c4
+    RUBY_SITE_LIB "\0"
ef51c4
+#else
ef51c4
     RUBY_SITE_LIB2 "\0"
ef51c4
+#endif
ef51c4
 #ifdef RUBY_THINARCH
ef51c4
     RUBY_SITE_ARCH_LIB_FOR(RUBY_THINARCH) "\0"
ef51c4
 #endif
ef51c4
     RUBY_SITE_ARCH_LIB_FOR(RUBY_SITEARCH) "\0"
ef51c4
+#ifndef RUBY_LIB_VERSION_BLANK
ef51c4
     RUBY_SITE_LIB "\0"
ef51c4
 #endif
ef51c4
+#endif
ef51c4
 
ef51c4
 #ifndef NO_RUBY_VENDOR_LIB
ef51c4
+#ifdef RUBY_LIB_VERSION_BLANK
ef51c4
+    RUBY_VENDOR_LIB "\0"
ef51c4
+#else
ef51c4
     RUBY_VENDOR_LIB2 "\0"
ef51c4
+#endif
ef51c4
 #ifdef RUBY_THINARCH
ef51c4
     RUBY_VENDOR_ARCH_LIB_FOR(RUBY_THINARCH) "\0"
ef51c4
 #endif
ef51c4
     RUBY_VENDOR_ARCH_LIB_FOR(RUBY_SITEARCH) "\0"
ef51c4
+#ifndef RUBY_LIB_VERSION_BLANK
ef51c4
     RUBY_VENDOR_LIB "\0"
ef51c4
+#endif
ef51c4
 #endif
ef51c4
 
ef51c4
     RUBY_LIB "\0"
ef51c4
diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb
ef51c4
index 07076d4..35e6c3c 100755
ef51c4
--- a/tool/mkconfig.rb
ef51c4
+++ b/tool/mkconfig.rb
ef51c4
@@ -114,7 +114,7 @@
ef51c4
     val = val.gsub(/\$(?:\$|\{?(\w+)\}?)/) {$1 ? "$(#{$1})" : $&}.dump
ef51c4
     case name
ef51c4
     when /^prefix$/
ef51c4
-      val = "(TOPDIR || DESTDIR + #{val})"
ef51c4
+      val = "(((TOPDIR && TOPDIR.empty?) ? nil : TOPDIR) || DESTDIR + #{val})"
ef51c4
     when /^ARCH_FLAG$/
ef51c4
       val = "arch_flag || #{val}" if universal
ef51c4
     when /^UNIVERSAL_ARCHNAMES$/
ef51c4
-- 
ef51c4
1.9.0
ef51c4