$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r83688 - in trunk/tools/build/v2: build tools
From: steven_at_[hidden]
Date: 2013-04-01 16:39:07
Author: steven_watanabe
Date: 2013-04-01 16:39:06 EDT (Mon, 01 Apr 2013)
New Revision: 83688
URL: http://svn.boost.org/trac/boost/changeset/83688
Log:
Redo the zlib module so that it actually works.
Text files modified: 
   trunk/tools/build/v2/build/ac.jam      |   323 +++++++++++++++++++++++---------------- 
   trunk/tools/build/v2/build/project.jam |    12 +                                       
   trunk/tools/build/v2/build/targets.jam |    21 ++                                      
   trunk/tools/build/v2/tools/builtin.jam |    11 +                                       
   trunk/tools/build/v2/tools/zlib.jam    |   274 ++++++++++++++++++++++++++-------       
   5 files changed, 444 insertions(+), 197 deletions(-)
Modified: trunk/tools/build/v2/build/ac.jam
==============================================================================
--- trunk/tools/build/v2/build/ac.jam	(original)
+++ trunk/tools/build/v2/build/ac.jam	2013-04-01 16:39:06 EDT (Mon, 01 Apr 2013)
@@ -1,4 +1,5 @@
 # Copyright (c) 2010 Vladimir Prus.
+# Copyright (c) 2013 Steven Watanabe
 #
 # Use, modification and distribution is subject to the Boost Software
 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
@@ -10,106 +11,102 @@
 import "class" ; 
 import errors ;
 import configure ;
+import project ;
+import virtual-target ;
+import generators ;
+import property ;
+import print ;
 
-rule find-include-path ( variable : properties : header 
-    : provided-path ? )
+project.initialize $(__name__) ;
+.project = [ project.current ] ;
+project ac ;
+
+rule generate-include ( target : sources * : properties * )
 {
-    # FIXME: document which properties affect this function by
-    # default.
-    local target-os = [ $(properties).get <target-os> ] ;
-    properties = [ property-set.create <target-os>$(toolset) ] ;    
-    if $($(variable)-$(properties))
+    local header = [ property.select <include> : $(properties) ] ;
+    print.output $(target) ;
+    print.text "#include <$(header:G=)>" ;
+}
+
+rule generate-main ( target : sources * : properties * )
+{
+    print.output $(target) ;
+    print.text "int main() {}" ;
+}
+
+rule find-include-path ( properties : header : provided-path ? )
+{
+    if $(provided-path) && [ path.exists [ path.root $(header) $(provided-path) ] ]
     {
-        return $($(variable)-$(properties)) ;
+        return $(provided-path) ;
     }
     else
     {
-        provided-path ?= [ modules.peek : $(variable) ] ;
-        includes = $(provided-path) ;
-        includes += [ $(properties).get <include> ] ;
-        if [ $(properties).get <target-os> ] != windows
+        local a = [ class.new action : ac.generate-include : [ property-set.create <include>$(header) ] ] ;
+        local cpp = [ class.new file-target $(header).cpp exact : CPP : $(.project) : $(a) ] ;
+        cpp = [ virtual-target.register $(cpp) ] ;
+        local result = [ generators.construct $(.project) $(header) : OBJ : $(properties) : $(cpp) : true ] ;
+        local jam-targets ;
+        for t in $(result[2-])
         {
-            # FIXME: use sysroot
-            includes += /usr/include ;
+            jam-targets += [ $(t).actualize ] ;
         }
-        
-        local result ;
-        while ! $(result) && $(includes)
-        {            
-            local f = [ path.root $(header) $(includes[1]) ] ;
-            ECHO "Checking " $(f) ;
-            if [ path.exists $(f) ]
-            {
-                result = $(includes[1]) ;
-            }
-            else if $(provided-path)
-            {
-                errors.user-error "Could not find header" $(header)
-                  : "in the user-specified directory" $(provided-path) ;
-            }            
-            includes = $(includes[2-]) ;                
-        }        
-        $(variable)-$(properties) = $(result) ;
-        return $(result) ;
-    }        
-}
-
-rule find-library ( variable : properties : names + : provided-path ? )
-{
-    local target-os = [ $(properties).get <target-os> ] ;
-    properties = [ property-set.create <target-os>$(toolset) ] ;
-    if $($(variable)-$(properties))
+        if [ UPDATE_NOW $(jam-targets) : [ modules.peek configure : .log-fd ]
+            : ignore-minus-n : ignore-minus-q ]
+        {
+            return %default ;
+        }
+    }
+}
+
+rule find-library ( properties : names + : provided-path ? )
+{
+    local result ;
+    if ! $(.main.cpp)
     {
-        return $($(variable)-$(properties)) ;
+        local a = [ class.new action : ac.generate-main :
+                    [ property-set.empty ] ] ;
+        .main.cpp = [ virtual-target.register
+            [ class.new file-target main.cpp exact
+                : CPP : $(.project) : $(a) ] ] ;
+    }
+    if [ $(properties).get <link> ] = shared
+    {
+        link-opts = <link>shared <link>static ;
     }
     else
     {
-        provided-path ?= [ modules.peek : $(variable) ] ;
-        paths = $(provided-path) ;
-        paths += [ $(properties).get <library-path> ] ;
-        if [ $(properties).get <target-os> ] != windows
+        link-opts = <link>static <link>shared ;
+    }
+    while $(link-opts)
+    {
+        properties = [ $(properties).refine [ property-set.create $(link-opts[1]) ] ] ;
+        local names-iter = $(names) ;
+        while $(names-iter)
         {
-            paths += /usr/lib /usr/lib32 /usr/lib64 ;
+            local name = $(names-iter[1]) ;
+            local lib-props = [ $(properties).add-raw <name>$(name) <search>$(provided-path) ] ;
+            local lib = [ generators.construct $(.project) lib-$(name)
+                : SEARCHED_LIB : $(lib-props) : : true ] ;
+            local test = [ generators.construct $(.project) $(name) : EXE
+                : [ $(properties).add $(lib[1]) ] : $(.main.cpp) $(lib[2-])
+                : true ] ;
+            local jam-targets ;
+            for t in $(test[2-])
+            {
+                jam-targets += [ $(t).actualize ] ;
+            }
+            if [ UPDATE_NOW $(jam-targets) : [ modules.peek configure : .log-fd ]
+                    : ignore-minus-n : ignore-minus-q ]
+            {
+                result = $(lib) ;
+                names-iter = ; link-opts = ; # break
+            }
+            names-iter = $(names-iter[2-]) ;
         }
-        
-        local result ;               
-        while ! $(result) && $(paths)
-        {   
-            while ! $(result) && $(names)
-            {
-                local f ;
-                if $(target-os) = windows
-                {         
-                    f = $(paths[1])/$(names[1]).lib ;                
-                    if [ path.exists $(f) ] 
-                    {
-                        result = $(f) ;
-                    }
-                }
-                else
-                {
-                    # FIXME: check for .a as well, depending on
-                    # the 'link' feature.
-                    f = $(paths[1])/lib$(names[1]).so ;                
-                    ECHO "CHECKING $(f) " ;
-                    if [ path.exists $(f) ] 
-                    {
-                        result = $(f) ;
-                    }
-                }
-                if ! $(result) && $(provided-path)
-                {
-                    errors.user-error "Could not find either of: " $(names)
-                      : "in the user-specified directory" $(provided-path) ;
-                    
-                }                
-                names = $(names[2-]) ;
-            }
-            paths = $(paths[2-]) ;
-        }        
-        $(variable)-$(properties) = $(result) ;
-        return $(result) ;
+        link-opts = $(link-opts[2-]) ;
     }
+    return $(result) ;
 }
 
 class ac-library : basic-target
@@ -120,12 +117,11 @@
     import ac ;
     import configure ;
 
-    rule __init__ ( name : project : * : * )
+    rule __init__ ( name : project : requirements * : include-path ? : library-path ? : library-name ? )
     {
-        basic-target.__init__ $(name) : $(project) : $(sources)
-          : $(requirements) ;
+        basic-target.__init__ $(name) : $(project) : : $(requirements) ;
         
-        reconfigure $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; 
+        reconfigure $(include-path) : $(library-path) : $(library-name) ; 
     }
     
     rule set-header ( header )
@@ -137,62 +133,127 @@
     {
         self.default-names = $(names) ;
     }
-        
-    rule reconfigure ( * : * )
+
+    rule reconfigure ( include-path ? : library-path ? : library-name ? )
+    {
+        if $(include-path) || $(library-path) || $(library-name)
+        {
+            check-not-configured ;
+
+            self.include-path = $(include-path) ;
+            self.library-path = $(library-path) ;
+            self.library-name = $(library-name) ;
+        }
+    }
+
+    rule set-target ( target )
+    {
+        check-not-configured ;
+        self.target = $(target) ;
+    }
+
+    rule check-not-configured ( )
     {
-        ECHO "XXX" $(1) ;
-        if ! $(1)
+        if $(self.include-path) || $(self.library-path) || $(self.library-name) || $(self.target)
         {
-            # This is 'using xxx ;'. Nothing to configure, really.
+            errors.user-error [ name ] "is already configured" ;
+        }
+    }
+    
+    rule construct ( name : sources * : property-set )
+    {
+        if $(self.target)
+        {
+            return [ $(self.target).generate $(property-set) ] ;
         }
         else
         {
-            for i in 1 2 3 4 5 6 7 8 9             
+            local use-environment ;
+            if ! $(self.library-name) && ! $(self.include-path) && ! $(self.library-path)
             {
-                # FIXME: this naming is inconsistent with XXX_INCLUDE/XXX_LIBRARY
-                if ! ( $($(i)[1]) in root include-path library-path library-name condition )
-                {
-                    errors.user-error "Invalid named parameter" $($(i)[1]) ;
-                }   
-                local name = $($(i)[1]) ;
-                local value = $($(i)[2-]) ;
-                if $($(name)) && $($(name)) != $(value)
+                use-environment = true ;
+            }
+            local libnames = $(self.library-name) ;
+            if ! $(libnames) && $(use-environment)
+            {
+                libnames = [ modules.peek : $(name:U)_NAME ] ;
+                # Backward compatibility only.
+                libnames ?= [ modules.peek : $(name:U)_BINARY ] ;
+            }
+            libnames ?= $(self.default-names) ;
+
+            local includes = $(self.include-path) ;
+            if ! $(includes) && $(use-environment)
+            {
+                includes = [ modules.peek : $(name:U)_INCLUDE ] ;
+            }
+
+            local library-path = $(self.library-path) ;
+            if ! $(library-path) && $(use-environment)
+            {
+                library-path = [ modules.peek : $(name:U)_LIBRARY_PATH ] ;
+                # Backwards compatibility only
+                library-path ?= [ modules.peek : $(name:U)_LIBPATH ] ;
+            }
+                        
+            local includes = [ ac.find-include-path $(property-set) : $(self.header) : $(include-path) ] ;
+            local library = [ ac.find-library $(property-set) : $(libnames) : $(library-path) ] ;
+            if $(includes) && $(library)
+            {
+                if $(includes) = %default
                 {
-                    errors.user-error "Attempt to change value of '$(name)'" ;
+                    includes = ;
                 }
-                $(name) = $(value) ;
+                configure.log-library-search-result $(name) : "found" ;
+                return [ $(library[1]).add-raw <include>$(includes) ] $(library[2-]) ;
             }
-            
-            include-path ?= $(root)/include ;
-            library-path ?= $(root)/lib ;            
-        }        
+            else
+            {
+                configure.log-library-search-result $(name) : "not found" ;
+                return [ property-set.empty ] ;
+            } 
+        }       
     }
-    
-    rule construct ( name : sources * : property-set )
+}
+
+class check-library-worker
+{
+    import property-set ;
+    import targets ;
+    import property ;
+
+    rule __init__ ( target : true-properties * : false-properties * )
     {
-        # FIXME: log results.
-        local libnames = $(library-name) ;
-        if ! $(libnames) && ! $(include-path) && ! $(library-path)
-        {
-            libnames = [ modules.peek : $(name:U)_NAME ] ;
-            # Backward compatibility only.
-            libnames ?= [ modules.peek : $(name:U)_BINARY ] ;
-        }
-        libnames ?= $(self.default-names) ;
-                        
-        local includes = [ 
-          ac.find-include-path $(name:U)_INCLUDE : $(property-set) : $(self.header) : $(include-path) ] ;
-        local library = [ ac.find-library $(name:U)_LIBRARY : $(property-set) : $(libnames) : $(library-path) ] ;
-        if $(includes) && $(library)
-        {
-            library = [ virtual-target.from-file $(library) : . : $(self.project) ] ;
-            configure.log-library-search-result $(name) : "found" ;
-            return [ property-set.create <include>$(includes) <source>$(library) ] ;
+        self.target = $(target) ;
+        self.true-properties = $(true-properties) ;
+        self.false-properties = $(false-properties) ;
+    }
+
+    rule check ( properties * )
+    {
+        local choosen ;
+        local t = [ targets.current ] ;
+        local p =  [ $(t).project ] ;
+        local ps = [ property-set.create $(properties) ] ;
+        ps = [ $(ps).propagated ] ;
+        local generated =
+            [ targets.generate-from-reference $(self.target) : $(p) : $(ps) ] ;
+        if $(generated[2])
+        {
+            choosen = $(self.true-properties) ;
         }
         else
         {
-            configure.log-library-search-result $(name) : "no found" ;
-        }        
+            choosen = $(self.false-properties) ;
+        }
+        return [ property.evaluate-conditionals-in-context $(choosen) :
+            $(properties) ] ;
     }
 }
 
+rule check-library ( target : true-properties * : false-properties * )
+{
+    local instance = [ class.new check-library-worker $(target) :
+        $(true-properties) : $(false-properties) ] ;
+    return <conditional>@$(instance).check ;
+}
Modified: trunk/tools/build/v2/build/project.jam
==============================================================================
--- trunk/tools/build/v2/build/project.jam	(original)
+++ trunk/tools/build/v2/build/project.jam	2013-04-01 16:39:06 EDT (Mon, 01 Apr 2013)
@@ -523,6 +523,10 @@
         if $(jamroot)
         {
             $(attributes).set project-root : $(location) : exact ;
+            if ! $(.first-project-root)
+            {
+                .first-project-root = $(module-name) ;
+            }
         }
 
         local parent ;
@@ -789,6 +793,14 @@
 }
 
 
+# Returns the build directory for standalone projects
+#
+rule standalone-build-dir ( )
+{
+    project = [ target $(.first-project-root) ] ;
+    return [ path.join [ $(project).build-dir ] standalone ] ;
+}
+
 # Returns the project which is currently being loaded.
 #
 rule current ( )
Modified: trunk/tools/build/v2/build/targets.jam
==============================================================================
--- trunk/tools/build/v2/build/targets.jam	(original)
+++ trunk/tools/build/v2/build/targets.jam	2013-04-01 16:39:06 EDT (Mon, 01 Apr 2013)
@@ -229,8 +229,25 @@
             self.build-dir = [ get build-dir ] ;
             if ! $(self.build-dir)
             {
-                self.build-dir = [ path.join [ $(self.project).get location ]
-                    bin ] ;
+                local location = [ $(self.project).get location ] ;
+                if $(location)
+                {
+                    self.build-dir = [ path.join $(location) bin ] ;
+                }
+                else
+                {
+                    local id = [ get id  ] ;
+                    if $(id)
+                    {
+                        local rid = [ MATCH /(.*) : $(id) ] ;
+                        self.build-dir = [ path.join [ project.standalone-build-dir ] $(rid) ] ;
+                    }
+                    else
+                    {
+                        errors.error "Could not create build-dir for standalone project $(self.project-module:E=)."
+                                   : "Missing project id" ;
+                    }
+                }
             }
         }
         return $(self.build-dir) ;
Modified: trunk/tools/build/v2/tools/builtin.jam
==============================================================================
--- trunk/tools/build/v2/tools/builtin.jam	(original)
+++ trunk/tools/build/v2/tools/builtin.jam	2013-04-01 16:39:06 EDT (Mon, 01 Apr 2013)
@@ -668,8 +668,15 @@
     rule adjust-properties ( property-set )
     {
         local s = [ $(self.targets[1]).creating-subvariant ] ;
-        return [ $(property-set).add-raw
-          [ $(s).implicit-includes "include" : H ] ] ;
+        if $(s)
+        {
+            return [ $(property-set).add-raw
+              [ $(s).implicit-includes "include" : H ] ] ;
+        }
+        else
+        {
+            return $(property-set) ;
+        }
     }
 }
 
Modified: trunk/tools/build/v2/tools/zlib.jam
==============================================================================
--- trunk/tools/build/v2/tools/zlib.jam	(original)
+++ trunk/tools/build/v2/tools/zlib.jam	2013-04-01 16:39:06 EDT (Mon, 01 Apr 2013)
@@ -10,83 +10,233 @@
 #
 # /zlib//zlib -- The zlib library
 
-
-# In addition to direct purpose of supporting zlib, this module also
-# serves as canonical example of how third-party condiguration works
-# in Boost.Build. The operation is as follows
-#
-# - For each 'using zlib : condition ... : ...' we create a target alternative
-#   for zlib, with the specified condition.
-# - There's one target alternative for 'zlib' with no specific condition
-#   properties. 
-#
-# Two invocations of 'using zlib' with the same condition but different
-# properties are not permitted, e.g.:
-#
-#   using zlib : condition <target-os>windows : include foo ;
-#   using zlib : condition <target-os>windows : include bar ;
-#
-# is in error. One exception is for empty condition, 'using' without any
-# parameters is overridable. That is:
-#
-#   using zlib ;
-#   using zlib : include foo ;
-# 
-# Is OK then the first 'using' is ignored. Likewise if the order of the statements
-# is reversed.
-#
-# When 'zlib' target is built, a target alternative is selected as usual for
-# Boost.Build. The selected alternative is a custom target class, which:
-#
-# - calls ac.find-include-path to find header path. If explicit path is provided
-#   in 'using', only that path is checked, and if no header is found there, error
-#   is emitted. Otherwise, we check a directory specified using ZLIB_INCLUDE
-#   environment variable, and failing that, in standard directories.
-#   [TODO: document sysroot handling]
-# - calls ac.find-library to find the library, in an identical fashion.
-#
-
 import project ;
 import ac ;
 import errors ;
 import "class" : new ;
 import targets ; 
-
-project.initialize $(__name__) ;
-project = [ project.current ] ;
-project zlib ;
+import path ;
+import modules ;
+import errors ;
+import indirect ;
+import property ;
 
 header = zlib.h ;
 names = z zlib zll zdll ;
 
-.default-alternative = [ new ac-library zlib : $(project) ] ;
-$(.default-alternative).set-header $(header) ;
-$(.default-alternative).set-default-names $(names) ;
-targets.main-target-alternative $(.default-alternative) ;
+sources = adler32.c compress.c
+     crc32.c deflate.c gzclose.c gzio.c gzlib.c gzread.c gzwrite.c
+     infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c ;
 
-rule init ( * : * )
+library-id = 0 ;
+
+if --debug-configuration in [ modules.peek : ARGV ]
 {
-    if ! $(condition)
-    {
-        # Special case the no-condition case so that 'using' without parameters
-        # can mix with more specific 'using'.
-        $(.default-alternative).reconfigure $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
-    }
-    else                    
-    {
-        # FIXME: consider if we should allow overriding definitions for a given
-        # condition -- e.g. project-config.jam might want to override whatever is
-        # in user-config.jam. 
-        local mt = [ new ac-library zlib : $(project)
-          : $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ] ;
-        $(mt).set-header $(header) ;
-        $(mt).set-default-names $(names) ;
-        targets.main-target-alternative $(mt) ;
-    }    
+    .debug =  true ;
 }
 
+# Initializes the zlib library.
+#
+# zlib can be configured either to use pre-existing binaries
+# or to build the library from source.
+#
+# Options for configuring a prebuilt zlib::
+#
+#   <search>
+#       The directory containing the zlib binaries.
+#   <name>
+#       Overrides the default library name.
+#   <include>
+#       The directory containing the zlib headers.
+#
+# If none of these options is specified, then the environmental
+# variables ZLIB_LIBRARY_PATH, ZLIB_NAME, and ZLIB_INCLUDE will
+# be used instead.
+#
+# Options for building zlib from source::
+#
+#   <source>
+#       The zlib source directory.  Defaults to the environmental variable
+#       ZLIB_SOURCE.
+#   <tag>
+#       A rule which computes the actual name of the compiled
+#       libraries based on the build properties.  Ignored
+#       when using precompiled binaries.
+#   <build-name>
+#       The base name to use for the compiled library.  Ignored
+#       when using precompiled binaries.
+#
+# Examples::
+#
+#   # Find zlib in the default system location
+#   using zlib ;
+#   # Build zlib from source
+#   using zlib : 1.2.7 : <source>/home/steven/zlib-1.2.7 ;
+#   # Find zlib in /usr/local
+#   using zlib : 1.2.7
+#     : <include>/usr/local/include <search>/usr/local/lib ;
+#   # Build zlib from source for msvc and find
+#   # prebuilt binaries for gcc.
+#   using zlib : 1.2.7 : <source>C:/Devel/src/zlib-1.2.7 : <toolset>msvc ;
+#   using zlib : 1.2.7 : : <toolset>gcc ;
+#
+rule init (
+    version ?
+    # The zlib version (currently ignored)
+
+    : options *
+    # A list of the options to use
+
+    : condition *
+    # A list of properties specifying when this configuration will be used.
+    # It is an error to initialize zlib more than once with the
+    # same condition.
+
+    : is-default ?
+    # Default configurations are only used when zlib
+    # has not yet been configured.
+    )
+{
+    local caller = [ project.current ] ;
 
+    if ! $(.initialized)
+    {
+        .initialized = true ;
 
+        project.initialize $(__name__) ;
+        .project = [ project.current ] ;
+        project zlib ;
+
+        .default-alternative = [ new ac-library zlib : $(.project) ] ;
+        $(.default-alternative).set-header $(header) ;
+        $(.default-alternative).set-default-names $(names) ;
+        targets.main-target-alternative $(.default-alternative) ;
+    }
 
+    local library-path = [ property.select <search> : $(options) ] ;
+    library-path = $(library-path:G=) ;
+    local include-path = [ property.select <include> : $(options) ] ;
+    include-path = $(include-path:G=) ;
+    local source-path = [ property.select <source> : $(options) ] ;
+    source-path = $(source-path:G=) ;
+    local library-name = [ property.select <name> : $(options) ] ;
+    library-name = $(library-name:G=) ;
+    local tag = [ property.select <tag> : $(options) ] ;
+    tag = $(tag:G=) ;
+    local build-name = [ property.select <build-name> : $(options) ] ;
+    build-name = $(build-name:G=) ;
+
+    local no-build-from-source ;
+    # Ignore environmental ZLIB_SOURCE if this initialization
+    # requested to search for a specific pre-built library.
+    if $(library-path) || $(include-path) || $(library-name)
+    {
+        if $(source-path) || $(tag) || $(build-name)
+        {
+            errors.user-error "incompatible options for zlib:"
+                [ property.select <search> <include> <name> : $(options) ] "and"
+                [ property.select <source> <tag> <build-name> : $(options) ] ;
+        }
+        else
+        {
+            no-build-from-source = true ;
+        }
+    }
 
+    source-path ?= [ modules.peek : ZLIB_SOURCE ] ;
 
+    if ! $(condition) && $(is-default) && $(.configured)
+    {
+        if $(.debug)
+        {
+            ECHO "notice: [zlib] zlib is already configured" ;
+        }
+        return ;
+    }
+    else if $(source-path) && ! $(no-build-from-source)
+    {
+        library-name ?= z ;
+        library-id = [ CALC $(library-id) + 1 ] ;
+        tag = [ MATCH ^@?(.*)$ : $(tag) ] ;
+        if $(tag) && ! [ MATCH ^([^%]*)%([^%]+)$ : $(tag) ]
+        {
+            tag = [ indirect.make $(tag) : [ $(caller).project-module ] ] ;
+        }
+        sources = [ path.glob $(source-path) : $(sources) ] ;
+        if $(.debug)
+        {
+            ECHO "notice: [zlib] Building zlib from source as $(build-name)" ;
+            if $(condition)
+            {
+                ECHO "notice: [zlib] Condition $(condition)" ;
+            }
+            if $(sources)
+            {
+                ECHO "notice: [zlib] found zlib source in $(source-path)" ;
+            }
+            else
+            {
+                ECHO "warning: [zlib] could not find zlib source in $(source-path)" ;
+            }
+        }
+        local target ;
+        if $(sources) {
+            target = [ targets.create-typed-target LIB : $(.project)
+              : $(build-name).$(library-id)
+              : $(sources)
+              : $(condition)
+                <tag>@$(tag)
+                <include>$(source-path)
+                <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
+                <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
+                <link>shared:<define>ZLIB_DLL
+              :
+              : <include>$(source-path) ] ;
+       }
+
+        if ! $(condition)
+        {
+            .configured = true ;
+            if $(target)
+            {
+                $(.default-alternative).set-target $(target) ;
+            }
+        }
+        else
+        {
+            local mt = [ new ac-library zlib : $(.project) : $(condition) ] ;
+            $(mt).set-header $(header) ;
+            $(mt).set-default-names $(names) ;
+            if $(target)
+            {
+                $(mt).set-target $(target) ;
+            }
+            targets.main-target-alternative $(mt) ;
+        }
+    } else {
+        if $(.debug)
+        {
+            ECHO "notice: [zlib] Using pre-installed library" ;
+            if $(condition)
+            {
+                ECHO "notice: [zlib] Condition $(condition)" ;
+            }
+        }
+        if ! $(condition)
+        {
+            .configured = true ;
+            # Special case the no-condition case so that 'using' without parameters
+            # can mix with more specific 'using'.
+            $(.default-alternative).reconfigure
+                $(include-path) : $(library-path) : $(library-name) : $(root) ;
+        }
+        else                    
+        {
+            local mt = [ new ac-library zlib : $(.project) : $(condition) :
+                $(include-path) : $(library-path) : $(library-name) : $(root) ] ;
+            $(mt).set-header $(header) ;
+            $(mt).set-default-names $(names) ;
+            targets.main-target-alternative $(mt) ;
+        }
+    }
+}