From 2cac0c27cf5b8606fce53ca02fe0d47504e57514 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 24 Mar 2010 16:56:57 -0600 Subject: [PATCH] build: started a library of common config tests for s3/s4 Pair-Programmed-With: Kai Blin --- buildtools/wafsamba/samba_autoconf.py | 31 ------------- buildtools/wafsamba/samba_conftests.py | 64 ++++++++++++++++++++++++++ buildtools/wafsamba/wafsamba.py | 1 + 3 files changed, 65 insertions(+), 31 deletions(-) create mode 100644 buildtools/wafsamba/samba_conftests.py diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index 31106d7819b..ec069485dae 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -463,37 +463,6 @@ def CHECK_FUNCS_IN(conf, list, library, mandatory=False, checklibc=False, header return ret -@conf -def CHECK_C_PROTOTYPE(conf, function, prototype, define, headers=None): - '''verify that a C prototype matches the one on the current system''' - if not conf.CHECK_DECLS(function, headers=headers): - return False - return conf.CHECK_CODE('%s; void *_x = (void *)%s' % (prototype, function), - define=define, - local_include=False, - headers=headers, - msg='Checking C prototype for %s' % function) - - -@conf -def CHECK_LARGEFILE(conf): - '''see what we need for largefile support''' - if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)', - 'HAVE_LARGEFILE', - execute=True, - msg='Checking for large file support'): - return True - if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)', - 'HAVE_LARGEFILE', - execute=True, - cflags='-D_FILE_OFFSET_BITS=64', - msg='Checking for -D_FILE_OFFSET_BITS=64'): - conf.DEFINE('_FILE_OFFSET_BITS', 64) - return True - return False - - - ################################################# # write out config.h in the right directory @conf diff --git a/buildtools/wafsamba/samba_conftests.py b/buildtools/wafsamba/samba_conftests.py new file mode 100644 index 00000000000..347142c76c9 --- /dev/null +++ b/buildtools/wafsamba/samba_conftests.py @@ -0,0 +1,64 @@ +# a set of config tests that use the samba_autoconf functions +# to test for commonly needed configuration options + + +@conf +def CHECK_ICONV(conf, define='HAVE_NATIVE_ICONV'): + '''check if the iconv library is installed + optionally pass a define''' + if conf.CHECK_FUNCS_IN('iconv_open', 'iconv', checklibc=True, headers='iconv.h'): + conf.DEFINE(define, 1) + return True + return False + + +@conf +def CHECK_LARGEFILE(conf, define='HAVE_LARGEFILE'): + '''see what we need for largefile support''' + if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)', + define, + execute=True, + msg='Checking for large file support'): + return True + if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)', + define, + execute=True, + cflags='-D_FILE_OFFSET_BITS=64', + msg='Checking for -D_FILE_OFFSET_BITS=64'): + conf.DEFINE('_FILE_OFFSET_BITS', 64) + return True + return False + + +@conf +def CHECK_C_PROTOTYPE(conf, function, prototype, define, headers=None): + '''verify that a C prototype matches the one on the current system''' + if not conf.CHECK_DECLS(function, headers=headers): + return False + return conf.CHECK_CODE('%s; void *_x = (void *)%s' % (prototype, function), + define=define, + local_include=False, + headers=headers, + msg='Checking C prototype for %s' % function) + + +@conf +def CHECK_CHARSET_EXISTS(conf, charset, outcharset='UCS2-LE', libs=None, headers=None, define=None): + '''check that a named charset is able to be used with iconv_open() for conversion + to a target charset + ''' + msg = 'Checking if can we convert from %s to %s' % (charset, outcharset) + if define is None: + define = 'HAVE_CHARSET_%s' % charset.upper().replace('-','_') + return conf.CHECK_CODE(''' + iconv_t cd = iconv_open("%s", "%s"); + if (cd == 0 || cd == (iconv_t)-1) { + return -1; + } + return 0; + ''' % (charset, outcharset), + define=define, + execute=True, + libs=libs, + msg=msg, + headers=headers) diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index ad104a2e898..cb7e1a55cea 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -17,6 +17,7 @@ from samba_asn1 import * from samba_autoproto import * from samba_python import * from samba_deps import * +import samba_conftests LIB_PATH="shared" -- 2.34.1