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