lib/zlib: make use of conf.CHECK_BUNDLED_SYSTEM()
authorStefan Metzmacher <metze@samba.org>
Fri, 14 Mar 2014 09:34:00 +0000 (10:34 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 2 Apr 2014 07:03:42 +0000 (09:03 +0200)
This way --bundled-libraries=ALL will use the internal zlib version.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/zlib/wscript

index 42d6f76f149e52244ae8ef9c1213f4467cb14081..aa300a8eff6ac5aa82e142e633dfe2853842c960 100644 (file)
@@ -1,34 +1,29 @@
 #!/usr/bin/env python
 
 def configure(conf):
-    conf.CHECK_HEADERS('zlib.h')
-    conf.CHECK_FUNCS_IN('zlibVersion', 'z')
+    version_check='''
+        #if (ZLIB_VERNUM >= 0x1230)
+        #else
+        #error "ZLIB_VERNUM < 0x1230"
+        #endif
+        z_stream *z;
+        inflateInit2(z, -15);
+        '''
 
-    conf.CHECK_CODE('''
-                    #if (ZLIB_VERNUM >= 0x1230)
-                    #else
-                    #error "ZLIB_VERNUM < 0x1230"
-                    #endif
-                    z_stream *z;
-                    inflateInit2(z, -15);
-                    ''',
-                    headers='zlib.h',
-                    lib='z',
-                    local_include=False,
-                    msg='Checking for ZLIB_VERNUM >= 0x1230 and working link to zlib',
-                    define='HAVE_ZLIB')
-
-    # If we don't do this then we will receive an error that lib 'z'
-    # is already declared as a system lib (for the cases where zlibVersion
-    # is defined
-    if not conf.env['HAVE_ZLIB']:
-                conf.LOCAL_CACHE_SET('TARGET_TYPE', 'z', 'EMPTY')
+    if conf.CHECK_BUNDLED_SYSTEM('z', minversion='1.2.3', pkg='zlib',
+                                 checkfunctions='zlibVersion',
+                                 headers='zlib.h',
+                                 checkcode=version_check,
+                                 implied_deps='replace'):
+        conf.define('USING_SYSTEM_ZLIB', 1)
 
 def build(bld):
-    if not bld.CONFIG_SET('HAVE_ZLIB'):
-        bld.SAMBA_LIBRARY('z',
-                          private_library=True,
-                          deps='replace',
-                          source='''adler32.c compress.c crc32.c gzio.c
-                                    uncompr.c deflate.c trees.c zutil.c
-                                    inflate.c infback.c inftrees.c inffast.c''')
+    if bld.CONFIG_SET('USING_SYSTEM_ZLIB'):
+        return
+
+    bld.SAMBA_LIBRARY('z',
+                      private_library=True,
+                      deps='replace',
+                      source='''adler32.c compress.c crc32.c gzio.c
+                                uncompr.c deflate.c trees.c zutil.c
+                                inflate.c infback.c inftrees.c inffast.c''')