From 3e462da5c1c48c43f6da95cba6237e24452b2d6c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Sun, 5 Apr 2015 01:17:30 +0200
Subject: [PATCH] gnu: openssl: Set appropriate RUNPATH on shared libraries.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixes <http://bugs.gnu.org/20041>.
Reported by taylanbayirli@gmail.com (Taylan Ulrich Bayırlı/Kammer).

* gnu/packages/patches/openssl-runpath.patch: New file.
* gnu/packages/openssl.scm (openssl)[source]: Use it.
* gnu-system.am (dist_patch_DATA): Add it.
---
 gnu-system.am                              |  1 +
 gnu/packages/openssl.scm                   |  3 ++-
 gnu/packages/patches/openssl-runpath.patch | 15 +++++++++++++++
 3 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/openssl-runpath.patch

diff --git a/gnu-system.am b/gnu-system.am
index d3e4dafc4e9..bb2bef33d09 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -489,6 +489,7 @@ dist_patch_DATA =						\
   gnu/packages/patches/nvi-dbpagesize-binpower.patch		\
   gnu/packages/patches/nvi-db4.patch				\
   gnu/packages/patches/openexr-missing-samples.patch		\
+  gnu/packages/patches/openssl-runpath.patch			\
   gnu/packages/patches/orpheus-cast-errors-and-includes.patch	\
   gnu/packages/patches/ots-no-include-missing-file.patch	\
   gnu/packages/patches/patchelf-page-size.patch			\
diff --git a/gnu/packages/openssl.scm b/gnu/packages/openssl.scm
index 6acbb12737f..1ed7a7a1f22 100644
--- a/gnu/packages/openssl.scm
+++ b/gnu/packages/openssl.scm
@@ -36,7 +36,8 @@ (define-public openssl
                                 ".tar.gz"))
             (sha256
              (base32
-              "0jijgzf72659pikms2bc5w31h78xrd1h5zp2r01an2h340y3kdhm"))))
+              "0jijgzf72659pikms2bc5w31h78xrd1h5zp2r01an2h340y3kdhm"))
+            (patches (list (search-patch "openssl-runpath.patch")))))
    (build-system gnu-build-system)
    (native-inputs `(("perl" ,perl)))
    (arguments
diff --git a/gnu/packages/patches/openssl-runpath.patch b/gnu/packages/patches/openssl-runpath.patch
new file mode 100644
index 00000000000..fa7c0b99625
--- /dev/null
+++ b/gnu/packages/patches/openssl-runpath.patch
@@ -0,0 +1,15 @@
+This patch makes the build system pass -Wl,-rpath=$out/lib even for
+libraries (it already does so for executables, thanks to 'DO_GNU_APP'
+in 'Makefile.shared'.)
+
+--- openssl-1.0.2a/Makefile.shared	2015-04-05 01:07:35.357602454 +0200
++++ openssl-1.0.2a/Makefile.shared	2015-04-05 01:09:50.474513303 +0200
+@@ -106,7 +106,7 @@ LINK_SO=	\
+     LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
+     LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
+     LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
+-    $${SHAREDCMD} $${SHAREDFLAGS} \
++    $${SHAREDCMD} $${SHAREDFLAGS} -Wl,-rpath,$(LIBRPATH) \
+ 	-o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
+ 	$$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \
+   ) && $(SYMLINK_SO)
-- 
GitLab