build: started a library of common config tests for s3/s4
authorAndrew Tridgell <tridge@samba.org>
Wed, 24 Mar 2010 22:56:57 +0000 (16:56 -0600)
committerAndrew Tridgell <tridge@samba.org>
Tue, 6 Apr 2010 10:27:07 +0000 (20:27 +1000)
Pair-Programmed-With: Kai Blin <kai@samba.org>

buildtools/wafsamba/samba_autoconf.py
buildtools/wafsamba/samba_conftests.py [new file with mode: 0644]
buildtools/wafsamba/wafsamba.py

index 31106d7819b06872eeb199b14d74cc8a1cceb815..ec069485dae6f33e30dda132a91d0f24155d4b14 100644 (file)
@@ -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 (file)
index 0000000..347142c
--- /dev/null
@@ -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)
index ad104a2e89820aeb21e3bd818f25b0151ee89e38..cb7e1a55cea222963d7a3bf2c5a9075f74b676d4 100644 (file)
@@ -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"