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