From 34ff6fa1182e22fcd3fa400b52e4e7573d7278fc Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Date: Mon, 21 Jun 2021 21:09:40 -0400
Subject: [PATCH] libring: Specify LDFLAGS for the shared library.

This avoids the error:

   ld: /home/mcournoyer/src/ring-project/daemon/contrib/x86_64-unknown-linux-gnu/lib/libswscale.a(swscale.o): relocation R_X86_64_PC32 against symbol `ff_M24A' can not be used when making a shared object; recompile with -fPIC
   ld: final link failed: bad value

caused by the missing '-Wl,-Bsymbolic' linker directive (which is
documented as required by ffmpeg when a shared library is built
against a static ffmpeg object).

* src/Makefile.am (libring_la_LDFLAGS): Set to AM_LDFLAGS.
[HAVE_WIN32]: Append using the += operator.
[HAVE_OSX]: Likewise.
[HAVE_LINUX]: Remove; it was not necessary.

Change-Id: Id2af9ea5812b2d1fd3b4f7f893108bb94671ffc6
GitLab: https://git.jami.net/savoirfairelinux/jami-packaging/-/issues/101
---
 src/Makefile.am | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index a6e9a88e4e..06149b80c7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -90,19 +90,18 @@ libring_la_LIBADD += \
 endif
 endif
 
+# XXX: It seems this should be the default value when otherwise left
+# unspecified, but for some reason this is required otherwise the
+# shared object fails to link against ffmpeg's libswscale.a.
+libring_la_LDFLAGS = $(AM_LDFLAGS)
 
 if HAVE_WIN32
-libring_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -avoid-version
+libring_la_LDFLAGS += -no-undefined -avoid-version
 endif
 
 if HAVE_OSX
 #FIXME necessary for -lintl
-libring_la_LDFLAGS = $(AM_LDFLAGS) -L/usr/local/opt/gettext/lib
-endif
-
-if HAVE_LINUX
-#needed to compile the .so
-libring_la_CXXFLAGS = $(AM_CXXFLAGS) -fPIC
+libring_la_LDFLAGS += -L/usr/local/opt/gettext/lib
 endif
 
 libring_la_SOURCES = \
-- 
GitLab