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