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