From 2efac157b8e70e6be734caefe8a0a823e40ae4a1 Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 12 Oct 2012 07:24:42 +0000 Subject: merge revision(s) 36847,36873: [Backport #7115] * configure.in (LIBDIR_BASENAME): use configured libdir value to fix --enable-load-relative on systems where libdir is not default value, overridden in config.site files. [ruby-core:47267] [Bug #6903] * ruby.c (ruby_init_loadpath_safe): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ configure.in | 11 +++++++++-- ruby.c | 16 ++++++++++++++-- version.h | 2 +- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1e89813963..c116f4aa81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Oct 12 16:11:23 2012 Nobuyoshi Nakada + + * configure.in (LIBDIR_BASENAME): use configured libdir value to fix + --enable-load-relative on systems where libdir is not default value, + overridden in config.site files. [ruby-core:47267] [Bug #6903] + + * ruby.c (ruby_init_loadpath_safe): ditto. + Fri Oct 12 13:56:01 2012 Ayumu AIZAWA * test/rexml/test_encoding.rb: diff --git a/configure.in b/configure.in index bd6cf62bcd..1d727e4161 100644 --- a/configure.in +++ b/configure.in @@ -2355,6 +2355,13 @@ AS_CASE("$enable_shared", [yes], [ if test "$rb_cv_binary_elf" = yes; then SOLIBS='$(LIBS)' fi + # libdir can be overridden in config.site file (on OpenSUSE at least). + libdir_basename=lib + if test "$bindir" = '${exec_prefix}/bin'; then + AS_CASE(["$libdir"], ['${exec_prefix}/'*], [libdir_basename=`basename "$libdir"`]) + fi + AC_DEFINE_UNQUOTED(LIBDIR_BASENAME, ["${libdir_basename}"]) + AS_CASE(["$target_os"], [sunos4*], [ LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' @@ -2363,7 +2370,7 @@ AS_CASE("$enable_shared", [yes], [ LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)' LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' if test "$load_relative" = yes; then - LIBRUBY_RPATHFLAGS="'-Wl,-rpath,\$\${ORIGIN}/../lib'" + LIBRUBY_RPATHFLAGS="'-Wl,-rpath,\$\${ORIGIN}/../${libdir_basename}'" LIBRUBY_RELATIVE=yes fi ], @@ -2420,7 +2427,7 @@ AS_CASE("$enable_shared", [yes], [ RUBY_SO_NAME="$RUBY_SO_NAME"'.$(MAJOR).$(MINOR).$(TEENY)' LIBRUBY_LDSHARED='$(CC) -dynamiclib' if test "$load_relative" = yes; then - libprefix='@executable_path/../lib' + libprefix="@executable_path/../${libdir_basename}" LIBRUBY_RELATIVE=yes fi LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-install_name '${libprefix}'/$(LIBRUBY_SO)' diff --git a/ruby.c b/ruby.c index 3c97d01ddd..44cec06366 100644 --- a/ruby.c +++ b/ruby.c @@ -410,9 +410,21 @@ ruby_init_loadpath_safe(int safe_level) #endif p = strrchr(libpath, '/'); if (p) { + static const char bindir[] = "/bin"; +#ifdef LIBDIR_BASENAME + static const char libdir[] = "/"LIBDIR_BASENAME; +#else + static const char libdir[] = "/lib"; +#endif + const ptrdiff_t bindir_len = (ptrdiff_t)sizeof(bindir) - 1; + const ptrdiff_t libdir_len = (ptrdiff_t)sizeof(libdir) - 1; *p = 0; - if (p - libpath > 3 && !(STRCASECMP(p - 4, "/bin") && strcmp(p - 4, "/lib"))) { - p -= 4; + if (p - libpath >= bindir_len && !STRCASECMP(p - bindir_len, bindir)) { + p -= bindir_len; + *p = 0; + } + else if (p - libpath >= libdir_len && !STRCASECMP(p - libdir_len, libdir)) { + p -= libdir_len; *p = 0; } } diff --git a/version.h b/version.h index 20aec4881d..8392eeb761 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 282 +#define RUBY_PATCHLEVEL 283 #define RUBY_RELEASE_DATE "2012-10-12" #define RUBY_RELEASE_YEAR 2012 -- cgit v1.2.3