replace: Link to -lbsd when building replace.c by hand
authorAndrew Bartlett <abartlet@samba.org>
Sat, 14 Oct 2017 09:38:18 +0000 (22:38 +1300)
committerKarolin Seeger <kseeger@samba.org>
Wed, 1 Nov 2017 09:49:25 +0000 (10:49 +0100)
This ensures that we correctly detect HAVE_IFACE_GETIFADDRS
et al, which are based on a "build the source" style test.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13087

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
(cherry picked from commit 593dacd274a22583cac4e091a08bf2ded0ae9703)

lib/replace/wscript

index 7c50e1daf8579d705abfc56a30e6247ab63537f5..7357eeabc2b62bfa2fd905ef7e2739bd662d7424 100644 (file)
@@ -251,10 +251,13 @@ def configure(conf):
 
     conf.CHECK_FUNCS('prctl dirname basename')
 
+    strlcpy_in_bsd = False
+
     # libbsd on some platforms provides strlcpy and strlcat
     if not conf.CHECK_FUNCS('strlcpy strlcat'):
-        conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h',
-                checklibc=True)
+        if conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h',
+                               checklibc=True):
+            strlcpy_in_bsd = True
     if not conf.CHECK_FUNCS('getpeereid'):
         conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h')
     if not conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h'):
@@ -611,6 +614,9 @@ removeea setea
 
     # look for a method of finding the list of network interfaces
     for method in ['HAVE_IFACE_GETIFADDRS', 'HAVE_IFACE_AIX', 'HAVE_IFACE_IFCONF', 'HAVE_IFACE_IFREQ']:
+        bsd_for_strlcpy = ''
+        if strlcpy_in_bsd:
+            bsd_for_strlcpy = ' bsd'
         if conf.CHECK_CODE('''
                            #define %s 1
                            #define NO_CONFIG_H 1
@@ -623,7 +629,7 @@ removeea setea
                            #include "test/getifaddrs.c"
                            ''' % method,
                            method,
-                           lib='nsl socket',
+                           lib='nsl socket' + bsd_for_strlcpy,
                            addmain=False,
                            execute=True):
             break