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