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