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