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