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