b6b438
From 2958016c30a8d9f80a45b64e91a20d8ebf995d85 Mon Sep 17 00:00:00 2001
b6b438
From: Andreas Schneider <asn@samba.org>
b6b438
Date: Mon, 21 Oct 2019 17:08:08 +0200
b6b438
Subject: [PATCH] replace: Only link libnsl and libsocket if requrired
b6b438
b6b438
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14168
b6b438
b6b438
Signed-off-by: Andreas Schneider <asn@samba.org>
b6b438
Reviewed-by: Alexander Bokovoy <ab@samba.org>
b6b438
b6b438
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
b6b438
Autobuild-Date(master): Wed Oct 23 08:23:13 UTC 2019 on sn-devel-184
b6b438
b6b438
(cherry picked from commit 263bec1b8d0744da73dd92e4a361fb7430289ab3)
b6b438
b6b438
Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org>
b6b438
Autobuild-Date(v4-11-test): Mon Nov  4 09:31:23 UTC 2019 on sn-devel-184
b6b438
---
b6b438
 lib/replace/wscript | 36 +++++++++++++++++++++++++++++++-----
b6b438
 1 file changed, 31 insertions(+), 5 deletions(-)
b6b438
b6b438
diff --git a/lib/replace/wscript b/lib/replace/wscript
b6b438
index 240d730cbee..56e2a22de49 100644
b6b438
--- a/lib/replace/wscript
b6b438
+++ b/lib/replace/wscript
b6b438
@@ -190,10 +190,35 @@ def configure(conf):
b6b438
     conf.CHECK_TYPE_IN('sig_atomic_t', 'signal.h', define='HAVE_SIG_ATOMIC_T_TYPE')
b6b438
     conf.CHECK_FUNCS('sigsetmask siggetmask sigprocmask sigblock sigaction sigset')
b6b438
 
b6b438
-    conf.CHECK_FUNCS_IN('''inet_ntoa inet_aton inet_ntop inet_pton connect gethostbyname
b6b438
-                           getaddrinfo getnameinfo freeaddrinfo gai_strerror socketpair''',
b6b438
-                        'socket nsl', checklibc=True,
b6b438
-                        headers='sys/socket.h netinet/in.h arpa/inet.h netdb.h')
b6b438
+    # Those functions are normally available in libc
b6b438
+    if not conf.CHECK_FUNCS('''
b6b438
+                            inet_ntoa
b6b438
+                            inet_aton
b6b438
+                            inet_ntop
b6b438
+                            inet_pton
b6b438
+                            connect
b6b438
+                            gethostbyname
b6b438
+                            getaddrinfo
b6b438
+                            getnameinfo
b6b438
+                            freeaddrinfo
b6b438
+                            gai_strerror
b6b438
+                            socketpair''',
b6b438
+                            headers='sys/socket.h netinet/in.h arpa/inet.h netdb.h'):
b6b438
+        conf.CHECK_FUNCS_IN('''
b6b438
+                            inet_ntoa
b6b438
+                            inet_aton
b6b438
+                            inet_ntop
b6b438
+                            inet_pton
b6b438
+                            connect
b6b438
+                            gethostbyname
b6b438
+                            getaddrinfo
b6b438
+                            getnameinfo
b6b438
+                            freeaddrinfo
b6b438
+                            gai_strerror
b6b438
+                            socketpair''',
b6b438
+                            'socket nsl',
b6b438
+                            headers='sys/socket.h netinet/in.h arpa/inet.h netdb.h')
b6b438
+        conf.DEFINE('REPLACE_REQUIRES_LIBSOCKET_LIBNSL', 1)
b6b438
 
b6b438
     conf.CHECK_FUNCS('memset_s memset_explicit')
b6b438
 
b6b438
@@ -836,6 +861,7 @@ def build(bld):
b6b438
     extra_libs = ''
b6b438
     if bld.CONFIG_SET('HAVE_LIBBSD'): extra_libs += ' bsd'
b6b438
     if bld.CONFIG_SET('HAVE_LIBRT'): extra_libs += ' rt'
b6b438
+    if bld.CONFIG_SET('REPLACE_REQUIRES_LIBSOCKET_LIBNSL'): extra_libs += ' socket nsl'
b6b438
 
b6b438
     bld.SAMBA_SUBSYSTEM('LIBREPLACE_HOSTCC',
b6b438
         REPLACE_HOSTCC_SOURCE,
b6b438
@@ -876,7 +902,7 @@ def build(bld):
b6b438
                       # at the moment:
b6b438
                       # hide_symbols=bld.BUILTIN_LIBRARY('replace'),
b6b438
                       private_library=True,
b6b438
-                      deps='crypt dl nsl socket attr' + extra_libs)
b6b438
+                      deps='crypt dl attr' + extra_libs)
b6b438
 
b6b438
     replace_test_cflags = ''
b6b438
     if bld.CONFIG_SET('HAVE_WNO_FORMAT_TRUNCATION'):
b6b438
-- 
b6b438
2.23.0
b6b438