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