diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-03-24 04:48:32 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-04-06 20:27:01 +1000 |
commit | 0632fac52ea1ab36c42a479bb43893929493b7a9 (patch) | |
tree | 184978d3c2ee5695c6ef588a9a6036aac5ba34e5 | |
parent | 3b87d36c2bc598f32eec2d7b50f9118d7e3d063c (diff) | |
download | samba-0632fac52ea1ab36c42a479bb43893929493b7a9.tar.gz samba-0632fac52ea1ab36c42a479bb43893929493b7a9.tar.bz2 samba-0632fac52ea1ab36c42a479bb43893929493b7a9.zip |
build: add cflags from pkg_config results to header/function tests
When we find a package with pkg_config we may need to use the
resulting ccflags and ldflags in later tests.
Support this by adding lib= options to CHECK_FUNC and CHECK_HEADER
This gets gnutls on FreeBSD working
-rw-r--r-- | buildtools/wafsamba/samba_autoconf.py | 83 | ||||
-rw-r--r-- | buildtools/wafsamba/samba_utils.py | 2 | ||||
-rw-r--r-- | lib/replace/wscript | 37 | ||||
-rw-r--r-- | source4/lib/tls/wscript | 12 |
4 files changed, 90 insertions, 44 deletions
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index fa24109363..aafa4c8c6b 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -40,7 +40,7 @@ def nolink(self): pass -def CHECK_HEADER(conf, h, add_headers=False): +def CHECK_HEADER(conf, h, add_headers=False, lib=None): '''check for a header''' if h in missing_headers: return False @@ -53,10 +53,13 @@ def CHECK_HEADER(conf, h, add_headers=False): conf.env.hlist.append(h) return True + (ccflags, ldflags) = library_flags(conf, lib) + hdrs = hlist_to_string(conf, headers=h) ret = conf.check(fragment='%s\nint main(void) { return 0; }' % hdrs, type='nolink', execute=0, + ccflags=ccflags, msg="Checking for header %s" % h) if not ret: missing_headers.add(h) @@ -69,7 +72,7 @@ def CHECK_HEADER(conf, h, add_headers=False): @conf -def CHECK_HEADERS(conf, headers, add_headers=False, together=False): +def CHECK_HEADERS(conf, headers, add_headers=False, together=False, lib=None): '''check for a list of headers when together==True, then the headers accumulate within this test. @@ -82,25 +85,25 @@ def CHECK_HEADERS(conf, headers, add_headers=False, together=False): else: set_add_headers = add_headers for hdr in TO_LIST(headers): - if not CHECK_HEADER(conf, hdr, set_add_headers): + if not CHECK_HEADER(conf, hdr, set_add_headers, lib=lib): ret = False if not add_headers and together: conf.env.hlist = saved_hlist return ret -def header_list(conf, headers=None): +def header_list(conf, headers=None, lib=None): '''form a list of headers which exist, as a string''' hlist=[] if headers is not None: for h in TO_LIST(headers): - if CHECK_HEADER(conf, h, add_headers=False): + if CHECK_HEADER(conf, h, add_headers=False, lib=lib): hlist.append(h) return hlist_to_string(conf, headers=hlist) @conf -def CHECK_TYPE(conf, t, alternate=None, headers=None, define=None): +def CHECK_TYPE(conf, t, alternate=None, headers=None, define=None, lib=None): '''check for a single type''' if define is None: define = 'HAVE_' + t.upper().replace(' ', '_') @@ -110,6 +113,7 @@ def CHECK_TYPE(conf, t, alternate=None, headers=None, define=None): headers=headers, msg='Checking for %s' % t, local_include=False, + lib=lib, link=False) if not ret and alternate: conf.DEFINE(t, alternate) @@ -117,11 +121,12 @@ def CHECK_TYPE(conf, t, alternate=None, headers=None, define=None): @conf -def CHECK_TYPES(conf, list, headers=None, define=None, alternate=None): +def CHECK_TYPES(conf, list, headers=None, define=None, alternate=None, lib=None): '''check for a list of types''' ret = True for t in TO_LIST(list): - if not CHECK_TYPE(conf, t, headers=headers, define=define, alternate=alternate): + if not CHECK_TYPE(conf, t, headers=headers, + define=define, alternate=alternate, lib=lib): ret = False return ret @@ -133,7 +138,8 @@ def CHECK_TYPE_IN(conf, t, headers=None, alternate=None, define=None): @conf -def CHECK_VARIABLE(conf, v, define=None, always=False, headers=None, msg=None): +def CHECK_VARIABLE(conf, v, define=None, always=False, + headers=None, msg=None, lib=None): '''check for a variable declaration (or define)''' if define is None: define = 'HAVE_%s' % v.upper() @@ -152,6 +158,7 @@ def CHECK_VARIABLE(conf, v, define=None, always=False, headers=None, msg=None): link=False, msg=msg, local_include=False, + lib=lib, headers=headers, define=define, always=always) @@ -261,10 +268,10 @@ def CHECK_CODE(conf, code, define, return True if headers is not None: - CHECK_HEADERS(conf, headers=headers) + CHECK_HEADERS(conf, headers=headers, lib=lib) if add_headers: - hdrs = header_list(conf, headers=headers) + hdrs = header_list(conf, headers=headers, lib=lib) else: hdrs = '' if execute: @@ -293,16 +300,19 @@ def CHECK_CODE(conf, code, define, else: type='cprogram' - if lib is not None: - uselib = TO_LIST(lib) - else: - uselib = [] + uselib = TO_LIST(lib) + + (ccflags, ldflags) = library_flags(conf, uselib) + + cflags = TO_LIST(cflags) + cflags.extend(ccflags) ret = conf.check(fragment=fragment, execute=execute, define_name = define, mandatory = mandatory, - ccflags=TO_LIST(cflags), + ccflags=cflags, + ldflags=ldflags, includes=includes, uselib=uselib, type=type, @@ -359,16 +369,34 @@ def CONFIG_SET(conf, option): Build.BuildContext.CONFIG_SET = CONFIG_SET +def library_flags(conf, libs): + '''work out flags from pkg_config''' + ccflags = [] + ldflags = [] + for lib in TO_LIST(libs): + inc_path = None + inc_path = getattr(conf.env, 'CPPPATH_%s' % lib.upper(), []) + lib_path = getattr(conf.env, 'LIBPATH_%s' % lib.upper(), []) + for i in inc_path: + ccflags.append('-I%s' % i) + for l in lib_path: + ldflags.append('-L%s' % l) + return (ccflags, ldflags) + + @conf -def CHECK_LIB(conf, libs): +def CHECK_LIB(conf, libs, mandatory=False): '''check if a set of libraries exist''' - liblist = TO_LIST(library) + liblist = TO_LIST(libs) ret = True for lib in liblist[:]: if GET_TARGET_TYPE(conf, lib): continue - if not conf.check(lib=lib, uselib_store=lib): + + (ccflags, ldflags) = library_flags(conf, lib) + + if not conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags): conf.ASSERT(not mandatory, "Mandatory library '%s' not found for functions '%s'" % (lib, list)) # if it isn't a mandatory library, then remove it from dependency lists @@ -416,23 +444,14 @@ def CHECK_FUNCS_IN(conf, list, library, mandatory=False, checklibc=False, header SET_TARGET_TYPE(conf, lib, 'EMPTY') return True - ret = True + conf.CHECK_LIB(liblist) for lib in liblist[:]: - if GET_TARGET_TYPE(conf, lib): - continue - if not conf.check(lib=lib, uselib_store=lib): + if not GET_TARGET_TYPE(conf, lib) == 'SYSLIB': conf.ASSERT(not mandatory, "Mandatory library '%s' not found for functions '%s'" % (lib, list)) # if it isn't a mandatory library, then remove it from dependency lists - SET_TARGET_TYPE(conf, lib, 'EMPTY') - ret = False - else: - conf.define('HAVE_LIB%s' % lib.upper().replace('-','_'), 1) - conf.env['LIB_' + lib.upper()] = lib - LOCAL_CACHE_SET(conf, 'TARGET_TYPE', lib, 'SYSLIB') - - if not ret: - return ret + liblist.remove(lib) + continue ret = True for f in remaining: diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py index 8bd913f720..fe290a33e1 100644 --- a/buildtools/wafsamba/samba_utils.py +++ b/buildtools/wafsamba/samba_utils.py @@ -236,6 +236,8 @@ def unique_list(seq): def TO_LIST(str): '''Split a list, preserving quoted strings and existing lists''' + if str is None: + return [] if isinstance(str, list): return str lst = str.split() diff --git a/lib/replace/wscript b/lib/replace/wscript index 63f96313dd..6be8257016 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -112,7 +112,7 @@ def configure(conf): conf.CHECK_HEADERS('crypt.h locale.h acl/libacl.h compat.h') conf.CHECK_HEADERS('acl/libacl.h attr/xattr.h compat.h ctype.h dustat.h') conf.CHECK_HEADERS('fcntl.h fnmatch.h glob.h history.h krb5.h langinfo.h') - conf.CHECK_HEADERS('libaio.h locale.h ndir.h net/if.h pwd.h') + conf.CHECK_HEADERS('libaio.h locale.h ndir.h pwd.h') conf.CHECK_HEADERS('shadow.h sys/acl.h') conf.CHECK_HEADERS('sys/attributes.h sys/capability.h sys/dir.h sys/epoll.h') conf.CHECK_HEADERS('sys/fcntl.h sys/filio.h sys/filsys.h sys/fs/s5param.h sys/fs/vx/quota.h') @@ -123,11 +123,12 @@ def configure(conf): conf.CHECK_HEADERS('sys/select.h setjmp.h utime.h sys/syslog.h syslog.h') conf.CHECK_HEADERS('sys/time.h time.h stdarg.h vararg.h sys/mount.h mntent.h') conf.CHECK_HEADERS('stropts.h unix.h string.h strings.h sys/param.h limits.h') - conf.CHECK_HEADERS('sys/socket.h netinet/in.h netdb.h arpa/inet.h netinet/in_systm.h') - conf.CHECK_HEADERS('netinet/ip.h netinet/tcp.h netinet/in_ip.h sys/sockio.h sys/un.h') + conf.CHECK_HEADERS('''sys/socket.h netinet/in.h netdb.h arpa/inet.h netinet/in_systm.h + netinet/ip.h netinet/tcp.h netinet/in_ip.h + sys/sockio.h sys/un.h''', together=True) conf.CHECK_HEADERS('sys/uio.h ifaddrs.h direct.h dirent.h') conf.CHECK_HEADERS('windows.h winsock2.h ws2tcpip.h') - conf.CHECK_HEADERS('resolv.h libintl.h errno.h') + conf.CHECK_HEADERS('libintl.h errno.h') conf.CHECK_HEADERS('gcrypt.h getopt.h iconv.h') conf.CHECK_HEADERS('sys/inotify.h memory.h nss.h popt.h sasl/sasl.h') conf.CHECK_HEADERS('security/pam_appl.h sys/inotify.h zlib.h asm/unistd.h') @@ -231,10 +232,16 @@ def configure(conf): conf.CHECK_FUNCS('getgrent_r getgrgid_r getgrnam_r getgrouplist getpagesize') conf.CHECK_FUNCS('getpwent_r getpwnam_r getpwuid_r epoll_create') - conf.CHECK_FUNCS_IN('dlopen dlsym dlerror dlclose', 'dl', checklibc=True, headers='dlfcn.h dl.h') + conf.CHECK_FUNCS_IN('dlopen dlsym dlerror dlclose', 'dl', + checklibc=True, headers='dlfcn.h dl.h') conf.CHECK_FUNCS_IN('poptGetContext', 'popt') + + # these headers need to be tested as a group on freebsd + conf.CHECK_HEADERS(headers='sys/socket.h net/if.h', together=True) + conf.CHECK_HEADERS(headers='netinet/in.h arpa/nameser.h resolv.h', together=True) conf.CHECK_FUNCS_IN('res_search', 'resolv', checklibc=True, headers='netinet/in.h arpa/nameser.h resolv.h') + conf.CHECK_FUNCS_IN('gettext', 'intl', checklibc=True, headers='libintl.h') conf.CHECK_FUNCS_IN('pthread_create', 'pthread', checklibc=True, headers='pthread.h') @@ -329,10 +336,24 @@ def configure(conf): conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec', define='HAVE_STAT_TV_NSEC', headers='sys/stat.h') # we need the st_rdev test under two names - conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_rdev', define='HAVE_STRUCT_STAT_ST_RDEV', + conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_rdev', + define='HAVE_STRUCT_STAT_ST_RDEV', + headers='sys/stat.h') + conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_rdev', define='HAVE_ST_RDEV', headers='sys/stat.h') - conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_rdev', define='HAVE_ST_RDEV', headers='sys/stat.h') - conf.CHECK_STRUCTURE_MEMBER('struct sockaddr_storage', 'ss_family', headers='sys/socket.h netinet/in.h') + conf.CHECK_STRUCTURE_MEMBER('struct sockaddr_storage', 'ss_family', + headers='sys/socket.h netinet/in.h') + + + if conf.CHECK_STRUCTURE_MEMBER('struct sockaddr', 'sa_len', + headers='sys/socket.h netinet/in.h', + define='HAVE_SOCKADDR_SA_LEN'): + # the old build system produced both defines + conf.DEFINE('HAVE_STRUCT_SOCKADDR_SA_LEN', 1) + + conf.CHECK_STRUCTURE_MEMBER('struct sockaddr_in', 'sin_len', + headers='sys/socket.h netinet/in.h', + define='HAVE_SOCK_SIN_LEN') conf.CHECK_CODE('struct sockaddr_un sunaddr; sunaddr.sun_family = AF_UNIX;', define='HAVE_UNIXSOCKET', headers='sys/socket.h sys/un.h') diff --git a/source4/lib/tls/wscript b/source4/lib/tls/wscript index 66cc762b98..4fbbd0deaa 100644 --- a/source4/lib/tls/wscript +++ b/source4/lib/tls/wscript @@ -15,17 +15,21 @@ def configure(conf): if 'HAVE_GNUTLS' in conf.env and not Options.options.disable_gnutls: conf.DEFINE('ENABLE_GNUTLS', 1) - conf.CHECK_FUNCS_IN('gnutls_global_init', 'gnutls', headers='gnutls/gnutls.h') + conf.CHECK_FUNCS_IN('gnutls_global_init', 'gnutls', + headers='gnutls/gnutls.h') conf.CHECK_VARIABLE('gnutls_x509_crt_set_version', headers='gnutls/gnutls.h gnutls/x509.h', - define='HAVE_GNUTLS_X509_CRT_SET_VERSION') + define='HAVE_GNUTLS_X509_CRT_SET_VERSION', + lib='gnutls') conf.CHECK_VARIABLE('gnutls_x509_crt_set_subject_key_id', headers='gnutls/gnutls.h gnutls/x509.h', - define='HAVE_GNUTLS_X509_CRT_SET_SUBJECT_KEY_ID') + define='HAVE_GNUTLS_X509_CRT_SET_SUBJECT_KEY_ID', + lib='gnutls') # check for gnutls_datum types - conf.CHECK_TYPES('gnutls_datum gnutls_datum_t', headers='gnutls/gnutls.h') + conf.CHECK_TYPES('gnutls_datum gnutls_datum_t', + headers='gnutls/gnutls.h', lib='gnutls') conf.CHECK_FUNCS_IN('gcry_control', 'gcrypt', headers='gcrypt.h') conf.CHECK_FUNCS_IN('gpg_err_code_from_errno', 'gpg-error') |