Subject says it all
From 5d3623986a1dac95ce517cee0048520eec10800f Mon Sep 17 00:00:00 2001
From: Mono DHS <mono...@arcor.de>
Date: Sun, 19 Jul 2020 16:57:38 +0200
Subject: [PATCH] Add support for DT_R(UN)PATH in ELF executables.

---
 configure.ac | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/configure.ac b/configure.ac
index 
7906ce35b66d07845495377fd6bb767375a9bd88..a0554460f77938c26ba99e63078b4b5d72e0e5d2
 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,6 +119,11 @@ AH_BOTTOM([/* fseeko portability defines */
 MUTT_C99_INTTYPES
 AC_TYPE_LONG_LONG_INT
 
+AC_ARG_ENABLE(rpath,
+        AS_HELP_STRING([--enable-rpath],[Set DT_R(UN)PATH in the ELF 
executable]),
+        [],
+        [enable_rpath=no])
+
 ac_aux_path_sendmail=/usr/sbin:/usr/lib
 AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, 
$PATH:$ac_aux_path_sendmail)
 AC_DEFINE_UNQUOTED(SENDMAIL,"$ac_cv_path_SENDMAIL", [Where to find sendmail on 
your system.])
@@ -133,6 +138,11 @@ AC_ARG_WITH(sqlite3,
 if test x$with_sqlite3 != xno; then
   if test x$with_sqlite3 != xyes; then
     LDFLAGS="$LDFLAGS -L$with_sqlite3/lib"
+    if test x${enable_rpath} = xyes; then
+      if test x${with_sqlite3} != x/usr; then
+        LDFLAGS="${LDFLAGS} -Wl,-rpath,${with_sqlite3}/lib"
+      fi
+    fi
     CPPFLAGS="$CPPFLAGS -I$with_sqlite3/include"
   fi
   saved_LIBS="$LIBS"
@@ -299,6 +309,11 @@ main ()
                                 CPPFLAGS="$CPPFLAGS -I${withval}/include"
                         fi
                         LDFLAGS="$LDFLAGS -L${withval}/lib"
+                        if test x${enable_rpath} = xyes; then
+                          if test x${withval} != x/usr; then
+                            LDFLAGS="${LDFLAGS} -Wl,-rpath,${withval}/lib"
+                          fi
+                        fi
                 fi
         fi
         AC_MSG_RESULT($mutt_cv_slang)
@@ -325,6 +340,9 @@ main ()
                 fi
                 if test x$mutt_cv_curses != x/usr; then
                         LDFLAGS="$LDFLAGS -L${mutt_cv_curses}/lib"
+                        if test x${enable_rpath} = xyes; then
+                          LDFLAGS="${LDFLAGS} -Wl,-rpath,${mutt_cv_curses}/lib"
+                        fi
                         CPPFLAGS="$CPPFLAGS -I${mutt_cv_curses}/include"
                 fi])
 
@@ -767,6 +785,11 @@ then
        if test "$zlib_prefix" != "yes" -a "$zlib_prefix" != "auto"
        then
          LDFLAGS="$LDFLAGS -L$zlib_prefix/lib"
+         if test x${enable_rpath} = xyes; then
+           if test x${zlib_prefix} != x/usr; then
+             LDFLAGS="${LDFLAGS} -Wl,-rpath,${zlib_prefix}/lib"
+           fi
+         fi
           CPPFLAGS="$CPPFLAGS -I$zlib_prefix/include"
        fi
         saved_LIBS="$LIBS"
@@ -800,6 +823,11 @@ AC_ARG_WITH(ssl, 
AS_HELP_STRING([--with-ssl@<:@=PFX@:>@],[Enable TLS support usi
             if test "$with_ssl" != "yes"
             then
              LDFLAGS="$LDFLAGS -L$withval/lib"
+             if test x${enable_rpath} = xyes; then
+              if test x${withval} != x/usr; then
+               LDFLAGS="${LDFLAGS} -Wl,-rpath,${withval}/lib"
+              fi
+             fi
              CPPFLAGS="$CPPFLAGS -I$withval/include"
             fi
             saved_LIBS="$LIBS"
@@ -843,6 +871,11 @@ then
     if test "$gnutls_prefix" != "yes"
     then
       LDFLAGS="$LDFLAGS -L$gnutls_prefix/lib"
+      if test x${enable_rpath} = xyes; then
+        if test x${gnutls_prefix} != x/usr; then
+          LDFLAGS="${LDFLAGS} -Wl,-rpath,${gnutls_prefix}/lib"
+        fi
+      fi
       CPPFLAGS="$CPPFLAGS -I$gnutls_prefix/include"
     fi
     saved_LIBS="$LIBS"
@@ -889,6 +922,11 @@ AC_ARG_WITH(sasl, 
AS_HELP_STRING([--with-sasl@<:@=PFX@:>@],[Use SASL network sec
           then
             CPPFLAGS="$CPPFLAGS -I$with_sasl/include"
             LDFLAGS="$LDFLAGS -L$with_sasl/lib"
+            if test x${enable_rpath} = xyes; then
+              if test x${with_sasl} != x/usr; then
+                LDFLAGS="${LDFLAGS} -Wl,-rpath,${with_sasl}/lib"
+              fi
+            fi
           fi
 
           saved_LIBS="$LIBS"
@@ -1083,6 +1121,11 @@ then
       then
         CPPFLAGS="$CPPFLAGS -I$with_tokyocabinet/include"
         LDFLAGS="$LDFLAGS -L$with_tokyocabinet/lib"
+        if test x${enable_rpath} = xyes; then
+          if test x${with_tokyocabinet} != x/usr; then
+            LDFLAGS="${LDFLAGS} -Wl,-rpath,${with_tokyocabinet}/lib"
+          fi
+        fi
       fi
 
       AC_CHECK_HEADER(tcbdb.h,
@@ -1110,6 +1153,11 @@ then
           CPPFLAGS="$CPPFLAGS -I$with_qdbm/include"
        fi
         LDFLAGS="$LDFLAGS -L$with_qdbm/lib"
+        if test x${enable_rpath} = xyes; then
+          if test x${with_qdbm} != x/usr; then
+            LDFLAGS="${LDFLAGS} -Wl,-rpath,${with_qdbm}/lib"
+          fi
+        fi
       else
          if test -d /usr/include/qdbm; then
            CPPFLAGS="$CPPFLAGS -I/usr/include/qdbm"
@@ -1139,6 +1187,11 @@ then
         then
           CPPFLAGS="$CPPFLAGS -I$with_gdbm/include"
           LDFLAGS="$LDFLAGS -L$with_gdbm/lib"
+          if test x${enable_rpath} = xyes; then
+            if test x${with_gdbm} != x/usr; then
+              LDFLAGS="${LDFLAGS} -Wl,-rpath,${with_gdbm}/lib"
+            fi
+          fi
         fi
         saved_LIBS="$LIBS"
         LIBS="$LIBS -lgdbm"
@@ -1226,6 +1279,11 @@ then
         then
           CPPFLAGS="$CPPFLAGS -I$with_lmdb/include"
           LDFLAGS="$LDFLAGS -L$with_lmdb/lib"
+          if test x${enable_rpath} = xyes; then
+            if test x${with_lmdb} != x/usr; then
+              LDFLAGS="${LDFLAGS} -Wl,-rpath,${with_lmdb}/lib"
+            fi
+          fi
         fi
         saved_LIBS="$LIBS"
         LIBS="$LIBS -llmdb"
@@ -1254,6 +1312,11 @@ then
       then
         CPPFLAGS="$CPPFLAGS -I$with_kyotocabinet/include"
         LDFLAGS="$LDFLAGS -L$with_kyotocabinet/lib"
+        if test x${enable_rpath} = xyes; then
+          if test x${with_kyotocabinet} != x/usr; then
+            LDFLAGS="${LDFLAGS} -Wl,-rpath,${with_kyotocabinet}/lib"
+          fi
+        fi
       fi
 
       AC_CHECK_HEADER(kclangc.h,
@@ -1399,6 +1462,11 @@ AC_ARG_WITH(idn, 
AS_HELP_STRING([--with-idn=@<:@PFX@:>@],[Use GNU libidn for int
                        if test "$with_idn" != "yes" ; then
                           CPPFLAGS="$CPPFLAGS -I$with_idn/include"
                           LDFLAGS="$LDFLAGS -L$with_idn/lib"
+                          if test x${enable_rpath} = xyes; then
+                            if test x${with_idn} != x/usr; then
+                              LDFLAGS="${LDFLAGS} -Wl,-rpath,${with_idn}/lib"
+                            fi
+                          fi
                        fi
                  fi
                 ],
@@ -1418,6 +1486,11 @@ AC_ARG_WITH(idn2, 
AS_HELP_STRING([--with-idn2=@<:@PFX@:>@],[Use GNU libidn2 for
             if test "$with_idn2" != "yes" ; then
               CPPFLAGS="$CPPFLAGS -I$with_idn2/include"
               LDFLAGS="$LDFLAGS -L$with_idn2/lib"
+              if test x${enable_rpath} = xyes; then
+                if test x${with_idn2} != x/usr; then
+                  LDFLAGS="${LDFLAGS} -Wl,-rpath,${with_idn2}/lib"
+                fi
+              fi
             fi
           fi
         ],
-- 
2.11.0

Attachment: signature.asc
Description: PGP signature

Reply via email to