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