pvalena / rpms / ruby

Forked from rpms/ruby 2 years ago
Clone
dcd292
From bb3db69e2a0c210cc3a63940622db96a97eb7947 Mon Sep 17 00:00:00 2001
dcd292
From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
dcd292
Date: Fri, 2 Mar 2018 01:37:53 +0000
dcd292
Subject: [PATCH] configure.ac: library options to MAINLIBS
dcd292
dcd292
* configure.ac (MAINLIBS): moved library options for main program
dcd292
  and static libruby, and append MAINLIBS to LIBRUBYARG_STATIC, as
dcd292
  these libraries are not needed for linking to shared libruby.
dcd292
  [ruby-core:85882] [Bug #14422]
dcd292
dcd292
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
dcd292
---
dcd292
 configure.ac        | 33 +++++++++++++++------------------
dcd292
 template/ruby.pc.in |  1 +
dcd292
 win32/Makefile.sub  |  6 ++++--
dcd292
 3 files changed, 20 insertions(+), 20 deletions(-)
dcd292
dcd292
diff --git a/configure.ac b/configure.ac
dcd292
index aebbae1969a5..733a0c992fd7 100644
dcd292
--- a/configure.ac
dcd292
+++ b/configure.ac
dcd292
@@ -10,6 +10,7 @@ AC_DISABLE_OPTION_CHECKING
dcd292
 AC_ARG_VAR([cflags], [additional CFLAGS])
dcd292
 AC_ARG_VAR([cppflags], [additional CPPFLAGS])
dcd292
 AC_ARG_VAR([cxxflags], [additional CXXFLAGS])
dcd292
+ORIG_LIBS=$LIBS
dcd292
 
dcd292
 AC_DEFUN([RUBY_RM_RECURSIVE], [
dcd292
 m4_version_prereq([2.70], [-1], [
793a1c
@@ -2938,13 +2939,11 @@ AS_IF([test x"$enable_pthread" = xyes], [
dcd292
 	AC_DEFINE(_THREAD_SAFE)
dcd292
 	AC_DEFINE(HAVE_LIBPTHREAD)
dcd292
 	AC_CHECK_HEADERS(pthread_np.h, [], [], [@%:@include <pthread.h>])
dcd292
-	AS_CASE([$pthread_lib],
dcd292
-	[c],    [],
dcd292
-	[root], [],
dcd292
-	[c_r],  [MAINLIBS="-pthread $MAINLIBS"],
dcd292
-	        [AS_CASE(["$target_os"],
dcd292
-		    [openbsd*|mirbsd*], [LIBS="-pthread $LIBS"],
dcd292
-		    [LIBS="-l$pthread_lib $LIBS"])])
dcd292
+	AS_CASE(["$pthread_lib:$target_os"],
dcd292
+		[c:*], [],
dcd292
+		[root:*], [],
dcd292
+		[c_r:*|*:openbsd*|*:mirbsd*],  [LIBS="-pthread $LIBS"],
dcd292
+		[LIBS="-l$pthread_lib $LIBS"])
dcd292
     ], [
dcd292
 	AC_MSG_WARN("Don't know how to find pthread library on your system -- thread support disabled")
dcd292
     ])
793a1c
@@ -3623,7 +3622,7 @@ LIBRUBY_A='lib$(RUBY_SO_NAME)-static.a'
dcd292
 LIBRUBY='$(LIBRUBY_A)'
dcd292
 LIBRUBYARG_STATIC='-l$(RUBY_SO_NAME)-static'
dcd292
 LIBRUBYARG='$(LIBRUBYARG_STATIC)'
dcd292
-SOLIBS=
dcd292
+SOLIBS='$(MAINLIBS)'
dcd292
 
dcd292
 AS_CASE(["$target_os"],
dcd292
   [cygwin*|mingw*|haiku*|darwin*], [
793a1c
@@ -3689,9 +3688,6 @@ AS_CASE("$enable_shared", [yes], [
dcd292
   LIBRUBY_RELATIVE=no
dcd292
   test -z "$CCDLFLAGS" || CFLAGS="$CFLAGS $CCDLFLAGS"
dcd292
   ENABLE_SHARED=yes
dcd292
-  AS_IF([test "$rb_cv_binary_elf" = yes], [
dcd292
-    SOLIBS='$(LIBS)'
dcd292
-  ])
dcd292
 
dcd292
   # libdir can be overridden in config.site file (on OpenSUSE at least).
dcd292
   libdir_basename=lib
793a1c
@@ -3726,7 +3722,6 @@ AS_CASE("$enable_shared", [yes], [
dcd292
 	])
dcd292
 	],
dcd292
     [freebsd*|dragonfly*], [
dcd292
-	SOLIBS='$(LIBS)'
dcd292
 	LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR)$(MINOR)'
dcd292
 	LIBRUBY_SONAME='$(LIBRUBY_SO)'
dcd292
 	AS_IF([test "$rb_cv_binary_elf" != "yes" ], [
793a1c
@@ -3735,7 +3730,6 @@ AS_CASE("$enable_shared", [yes], [
dcd292
 	])
dcd292
 	],
dcd292
     [netbsd*], [
dcd292
-	SOLIBS='$(LIBS)'
dcd292
 	LIBRUBY_SONAME='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR)$(MINOR)'
dcd292
 	LIBRUBY_SO="${LIBRUBY_SONAME}"'.$(TEENY)'
dcd292
 	RUBY_APPEND_OPTIONS(LIBRUBY_DLDFLAGS, ['-Wl,-soname,$(LIBRUBY_SONAME)' "$LDFLAGS_OPTDIR"])
793a1c
@@ -3746,11 +3740,9 @@ AS_CASE("$enable_shared", [yes], [
dcd292
 	])
dcd292
 	],
dcd292
     [openbsd*|mirbsd*], [
dcd292
-	SOLIBS='$(LIBS)'
dcd292
 	LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR).'`expr ${MINOR} \* 10 + ${TEENY}`
dcd292
 	],
dcd292
     [solaris*], [
dcd292
-	SOLIBS='$(LIBS)'
dcd292
 	LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR)'
dcd292
 	LIBRUBY_SONAME='lib$(RUBY_SO_NAME).$(SOEXT).$(RUBY_PROGRAM_VERSION)'
dcd292
 	LIBRUBY_ALIASES='$(LIBRUBY_SONAME) lib$(RUBY_SO_NAME).$(SOEXT)'
793a1c
@@ -3768,7 +3760,7 @@ AS_CASE("$enable_shared", [yes], [
dcd292
     [aix*], [
dcd292
 	RUBY_APPEND_OPTIONS(LIBRUBY_DLDFLAGS, ["${linker_flag}-bnoentry" "$XLDFLAGS" "$LDFLAGS_OPTDIR"])
dcd292
 	LIBRUBYARG_SHARED='-L${libdir} -l${RUBY_SO_NAME}'
dcd292
-	SOLIBS='-lm -lc'
dcd292
+	LIBS="$LIBS -lm -lc"
dcd292
 	],
dcd292
     [darwin*], [
dcd292
 	LIBRUBY_LDSHARED='$(CC) -dynamiclib'
793a1c
@@ -3788,7 +3780,6 @@ AS_CASE("$enable_shared", [yes], [
dcd292
 	LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT)'
dcd292
 	LIBRUBY_SONAME='lib$(RUBY_BASE_NAME).$(RUBY_API_VERSION).$(SOEXT)'
dcd292
 	LIBRUBY_ALIASES='$(LIBRUBY_SONAME) lib$(RUBY_INSTALL_NAME).$(SOEXT)'
dcd292
-	SOLIBS='$(LIBS)'
dcd292
 	],
dcd292
     [interix*], [
dcd292
 	LIBRUBYARG_SHARED='-L. -L${libdir} -l$(RUBY_SO_NAME)'
793a1c
@@ -4031,7 +4022,6 @@ AS_CASE(["$target_os"],
dcd292
 	    ])
dcd292
 	LIBRUBY_ALIASES=''
dcd292
 	FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in
dcd292
-	SOLIBS='$(LIBS)'
dcd292
 	AS_IF([test x"$enable_shared" = xyes], [
dcd292
 	    LIBRUBY='lib$(RUBY_SO_NAME).dll.a'
dcd292
 	], [
793a1c
@@ -4131,6 +4121,13 @@ AS_IF([test "${universal_binary-no}" = yes ], [
dcd292
 		[rb_cv_architecture_available=yes], [rb_cv_architecture_available=no]))
dcd292
 ])
dcd292
 
dcd292
+MAINLIBS="$LIBS"
dcd292
+LIBS=$ORIG_LIBS
dcd292
+AS_IF([test -n "${LIBS}"], [
dcd292
+    libspat=`echo "${LIBS}" | sed 's/[[][|.*$^]]/\\&/;;s/^  */ /;s/^  *$/ /'`
dcd292
+    MAINFLAGS=`echo " $MAINLIBS " | sed "s|$libspat"'||;s/^ *//;s/ *$//'`
dcd292
+])
dcd292
+LIBRUBYARG_STATIC="${LIBRUBYARG_STATIC} \$(MAINLIBS)"
dcd292
 CPPFLAGS="$CPPFLAGS "'$(DEFS)'
dcd292
 test -z "$CPPFLAGS" || CPPFLAGS="$CPPFLAGS "; CPPFLAGS="$CPPFLAGS"'${cppflags}'
dcd292
 AS_IF([test -n "${cflags+set}"], [
dcd292
diff --git a/template/ruby.pc.in b/template/ruby.pc.in
dcd292
index d874f92c3b20..7ce4461c05df 100644
dcd292
--- a/template/ruby.pc.in
dcd292
+++ b/template/ruby.pc.in
dcd292
@@ -39,6 +39,7 @@ sitehdrdir=@sitehdrdir@
dcd292
 rubyarchhdrdir=@rubyarchhdrdir@
dcd292
 vendorarchhdrdir=@vendorarchhdrdir@
dcd292
 sitearchhdrdir=@sitearchhdrdir@
dcd292
+MAINLIBS=@MAINLIBS@
dcd292
 SOEXT=@SOEXT@
dcd292
 LIBPATH=@LIBPATH@
dcd292
 LIBRUBY_A=@LIBRUBY_A@
dcd292
diff --git a/win32/Makefile.sub b/win32/Makefile.sub
dcd292
index 8673c121641e..f8316cccb68e 100644
dcd292
--- a/win32/Makefile.sub
dcd292
+++ b/win32/Makefile.sub
dcd292
@@ -279,6 +279,7 @@ MJIT_DEBUGFLAGS = $(DEBUGFLAGS)
dcd292
 CPPFLAGS = $(DEFS) $(ARCHDEFS) $(CPPFLAGS)
dcd292
 
dcd292
 DLDFLAGS = $(LDFLAGS) -dll
dcd292
+MAINLIBS = $(LIBS)
dcd292
 SOLIBS =
dcd292
 RCFILES = $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc
dcd292
 !ifndef RCFLAGS
dcd292
@@ -821,7 +822,8 @@ s,@CPPFLAGS@,$(CPPFLAGS),;t t
dcd292
 s,@CXXFLAGS@,$(CXXFLAGS),;t t
dcd292
 s,@FFLAGS@,$(FFLAGS),;t t
dcd292
 s,@LDFLAGS@,$(LDFLAGS),;t t
dcd292
-s,@LIBS@,$(LIBS),;t t
dcd292
+s,@LIBS@,,;t t
dcd292
+s,@MAINLIBS@,$(MAINLIBS),;t t
dcd292
 s,@exec_prefix@,$${prefix},;t t
dcd292
 s,@prefix@,$(prefix),;t t
dcd292
 s,@program_transform_name@,s,.*,$(PROGRAM_PREFIX)&$(PROGRAM_SUFFIX),,;t t
dcd292
@@ -909,7 +911,7 @@ s,@LIBRUBY_SO@,$$(RUBY_SO_NAME).dll,;t t
dcd292
 s,@LIBRUBY_ALIASES@,$(LIBRUBY_ALIASES),;t t
dcd292
 s,@LIBRUBY@,$$(RUBY_SO_NAME).lib,;t t
dcd292
 s,@LIBRUBYARG@,$$(LIBRUBYARG_SHARED),;t t
dcd292
-s,@LIBRUBYARG_STATIC@,$$(LIBRUBY_A),;t t
dcd292
+s,@LIBRUBYARG_STATIC@,$$(LIBRUBY_A) $$(MAINLIBS),;t t
dcd292
 s,@LIBRUBYARG_SHARED@,$$(LIBRUBY),;t t
dcd292
 s,@SOLIBS@,$(SOLIBS),;t t
dcd292
 s,@DLDLIBS@,$(DLDLIBS),;t t