$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r61419 - in branches/release/tools/build/v2: . build test tools tools/types util
From: ghost_at_[hidden]
Date: 2010-04-20 08:05:16
Author: vladimir_prus
Date: 2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
New Revision: 61419
URL: http://svn.boost.org/trac/boost/changeset/61419
Log:
Merge from trunk
Added:
   branches/release/tools/build/v2/build/configure.jam
      - copied, changed from r59909, /trunk/tools/build/v2/build/configure.jam
   branches/release/tools/build/v2/tools/clang-darwin.jam
      - copied unchanged from r61380, /trunk/tools/build/v2/tools/clang-darwin.jam
   branches/release/tools/build/v2/tools/clang-unix.jam
      - copied unchanged from r61380, /trunk/tools/build/v2/tools/clang-unix.jam
   branches/release/tools/build/v2/tools/clang.jam
      - copied unchanged from r61380, /trunk/tools/build/v2/tools/clang.jam
Properties modified: 
   branches/release/tools/build/v2/   (props changed)
Text files modified: 
   branches/release/tools/build/v2/build-system.jam         |    51 +++++++++++++++++++++                   
   branches/release/tools/build/v2/build/configure.jam      |    66 +++++++++++++++++++++++++++--           
   branches/release/tools/build/v2/build/targets.jam        |    30 +++++++++++--                           
   branches/release/tools/build/v2/build/virtual-target.jam |    11 +++-                                    
   branches/release/tools/build/v2/test/BoostBuild.py       |     4 +                                       
   branches/release/tools/build/v2/test/build_dir.py        |     1                                         
   branches/release/tools/build/v2/tools/borland.jam        |     4                                         
   branches/release/tools/build/v2/tools/builtin.jam        |    82 ------------------------------------    
   branches/release/tools/build/v2/tools/common.jam         |     2                                         
   branches/release/tools/build/v2/tools/gcc.jam            |    90 ++++++++++++++++++++++----------------- 
   branches/release/tools/build/v2/tools/stage.jam          |    11 +++-                                    
   branches/release/tools/build/v2/tools/types/cpp.jam      |    90 ++++++++++++++++++++++++++++++++++++++- 
   branches/release/tools/build/v2/tools/types/lib.jam      |    56 ++++++++++++++++++++----                
   branches/release/tools/build/v2/tools/types/objc.jam     |    27 ++++++++++-                             
   branches/release/tools/build/v2/util/indirect.jam        |    12 ++++-                                   
   branches/release/tools/build/v2/util/set.jam             |    30 +++++++++++++                           
   16 files changed, 405 insertions(+), 162 deletions(-)
Modified: branches/release/tools/build/v2/build-system.jam
==============================================================================
--- branches/release/tools/build/v2/build-system.jam	(original)
+++ branches/release/tools/build/v2/build-system.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -26,6 +26,7 @@
 import version ;
 import virtual-target ;
 import generators ;
+import configure ;
 
 ################################################################################
 #
@@ -113,6 +114,15 @@
     .default-toolset-version = $(version) ;
 }
 
+rule set-pre-build-hook ( function )
+{
+    .pre-build-hook = $(function) ;
+}
+
+rule set-post-build-hook ( function )
+{
+    .post-build-hook = $(function) ;
+}
 
 ################################################################################
 #
@@ -579,6 +589,10 @@
             {
                 default-toolset = msvc ;
             }
+            else if [ os.name ] = MACOSX
+            {
+                default-toolset = darwin ;
+            }                        
         }
 
         ECHO "warning: No toolsets are configured." ;
@@ -698,6 +712,17 @@
         generators.dump ;
     }
     
+    # We wish to put config.log in the build directory corresponding
+    # to Jamroot, so that the location does not differ depending on
+    # directory where we do build.  The amount of indirection necessary
+    # here is scary.
+    local first-project = [ $(targets[0]).project ] ;
+    local first-project-root-location = [ $(first-project).get project-root ] ;
+    local first-project-root-module = [ project.load $(first-project-root-location) ] ;
+    local first-project-root = [ project.target  $(first-project-root-module) ] ;
+    local first-build-build-dir = [ $(first-project-root).build-dir ] ;
+    configure.set-log-file $(first-build-build-dir)/config.log ;
+    
     # Now that we have a set of targets to build and a set of property sets to
     # build the targets with, we can start the main build process by using each
     # property set to generate virtual targets from all of our listed targets
@@ -947,8 +972,30 @@
         UPDATE clean ;
     }
     else
-    {
+    {      
+        configure.print-configure-checks-summary ;        
+        
+        if $(.pre-build-hook)
+        {
+            $(.pre-build-hook) ;
+        }
+        
         DEPENDS all : $(actual-targets) ;
-        UPDATE all $(.out-xml) ;
+        if UPDATE_NOW in [ RULENAMES ]
+        {            
+            local ok = [ UPDATE_NOW all $(.out-xml) ] ;
+            if $(.post-build-hook)
+            {
+                $(.post-build-hook) $(ok) ;
+            }
+            # Prevent automatic update of the 'all' target, now that
+            # we have explicitly updated what we wanted.
+            UPDATE ;
+        }
+        else
+        {
+            UPDATE all $(.out-xml) ;
+        }            
     }
 }
+
Copied: branches/release/tools/build/v2/build/configure.jam (from r59909, /trunk/tools/build/v2/build/configure.jam)
==============================================================================
--- /trunk/tools/build/v2/build/configure.jam	(original)
+++ branches/release/tools/build/v2/build/configure.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -14,6 +14,7 @@
 import errors ;
 import targets ;
 import sequence ;
+import "class" : new ;
 
 rule log-summary ( )
 {
@@ -48,16 +49,25 @@
     .component-logs.$(component) += $(message) ;
 }
 
+
+
 rule log-check-result ( result )
 {
-    .check-results += $(result) ;
+    if ! $(.announced-checks)
+    {
+        ECHO "Performing configuration checks\n" ;
+        .announced-checks = 1 ;
+    }
+    
+    ECHO $(result) ;    
+    #.check-results += $(result) ;
 }
 
 rule print-component-configuration ( )
 {
     local c = [ sequence.unique $(.components) ] ;
     
-    ECHO "Component configuration:\n" ;
+    ECHO "\nComponent configuration:\n" ;
     for c in $(.components)
     {
         local s ;
@@ -102,11 +112,11 @@
 rule builds ( metatarget-reference : project : ps : what )
 {   
     local result ;
-    
+           
     if ! $(.$(what)-tested.$(ps))
-    {
+    {        
         .$(what)-tested.$(ps) = true ;
-
+        
         local targets = [ targets.generate-from-reference 
             $(metatarget-reference) : $(project) : $(ps) ] ;
         
@@ -155,3 +165,49 @@
     }    
 }
 
+# Frontend rules
+
+class check-target-builds-worker
+{
+    import configure ;
+    import property-set ;
+    import targets ;
+    import property ; 
+    
+    rule __init__ ( target : true-properties * : false-properties * )    
+    {
+        self.target = $(target) ;
+        self.true-properties = $(true-properties) ;
+        self.false-properties = $(false-properties) ;
+    }
+        
+    rule check ( properties * )
+    {
+        # FIXME: this should not be hardcoded. Other checks might
+        # want to consider different set of features as relevant.
+        local toolset = [ property.select <toolset> : $(properties) ] ;
+        local ps = [ property-set.create $(toolset) ] ;        
+        local t = [ targets.current ] ;
+        local p = [ $(t).project ] ;
+        if [ configure.builds $(self.target) : $(p) : $(ps) : "$(self.target) builds" ]
+        {
+            return $(self.true-properties) ;
+        }        
+        else
+        {
+            return $(self.false-properties) ;
+        }        
+    }    
+}
+
+
+rule check-target-builds ( target : true-properties * : false-properties * )
+{
+    local instance = [ new check-target-builds-worker $(target) : $(true-properties)
+      : $(false-properties) ] ;
+    return <conditional>@$(instance).check ;
+}
+
+IMPORT $(__name__) : check-target-builds :  : check-target-builds ;
+
+
Modified: branches/release/tools/build/v2/build/targets.jam
==============================================================================
--- branches/release/tools/build/v2/build/targets.jam	(original)
+++ branches/release/tools/build/v2/build/targets.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -288,7 +288,7 @@
         local self-location = [ get location ] ;
         for local pn in [ get projects-to-build ]
         {
-            result += [ find $(pn) ] ;
+            result += [ find $(pn)/ ] ;
         }
 
         return $(result) ;
@@ -968,7 +968,7 @@
     # might come from project's requirements.
 
     local unconditional = [ feature.expand [ $(requirements).non-conditional ] ] ;
-
+ 
     local raw = [ $(context).raw ] ;
     raw = [ property.refine $(raw) : $(unconditional) ] ;
 
@@ -997,7 +997,7 @@
     # <conditional> properties. So the list of indirect conditionals does not
     # change.
     local indirect = [ $(requirements).get <conditional> ] ;
-    indirect = [ MATCH @(.*) : $(indirect) ] ;
+    indirect = [ MATCH ^@(.*) : $(indirect) ] ;
 
     local ok ;
     while $(count)
@@ -1066,6 +1066,22 @@
         refined ] ;
 }
 
+rule push-target ( target )
+{
+    .targets = $(target) $(.targets) ;
+}
+
+rule pop-target ( )
+{
+    .targets = $(.targets[2-]) ;
+}
+
+# Return the metatarget that is currently being generated.
+rule current ( )
+{
+    return $(.targets[1]) ;
+}
+
 
 # Implements the most standard way of constructing main target alternative from
 # sources. Allows sources to be either file or other main target and handles
@@ -1221,6 +1237,7 @@
             ECHO [ targets.indent ] "Command line free features: " [ $(cf).raw ] ;
             ECHO [ targets.indent ] "Target requirements: " [ $(self.requirements).raw ] ;
         }
+        targets.push-target $(__name__) ;
 
         if ! $(self.generated.$(property-set))
         {
@@ -1320,8 +1337,10 @@
                 }
                 else if [ $(rproperties).get <build> ] = no
                 {
-                    ECHO [ targets.indent ] "Skipping build of: " [ full-name ]
-                        " <build>no in common properties" ;
+                    # If we just see <build>no, we cannot produce any reasonable
+                    # diagnostics. The code that adds this property is expected
+                    # to explain why a target is not built, for example using
+                    # the configure.log-component-configuration function.
                 }
                 else
                 {
@@ -1359,6 +1378,7 @@
             }
         }
 
+        targets.pop-target ;
         targets.decrease-indent ;
         return $(self.generated.$(property-set)) ;
     }
Modified: branches/release/tools/build/v2/build/virtual-target.jam
==============================================================================
--- branches/release/tools/build/v2/build/virtual-target.jam	(original)
+++ branches/release/tools/build/v2/build/virtual-target.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -1218,7 +1218,7 @@
     # referred to using the dependency property are returned as properties, not
     # targets.
     #
-    rule all-referenced-targets ( )
+    rule all-referenced-targets ( theset )
     {
         # Find directly referenced targets.
         local deps = [ $(self.build-properties).dependency ] ;
@@ -1228,17 +1228,20 @@
         local r ;
         for local t in $(all-targets)
         {
-            r += [ $(t:G=).creating-subvariant ] ;
+            if ! [ $(theset).contains $(t) ]
+            {
+                $(theset).add $(t) ;
+                r += [ $(t:G=).creating-subvariant ] ;
+            }            
         }
         r = [ sequence.unique $(r) ] ;
         for local s in $(r)
         {
             if $(s) != $(__name__)
             {
-                all-targets += [ $(s).all-referenced-targets ] ;
+                $(s).all-referenced-targets $(theset) ;
             }
         }
-        return $(all-targets) ;
     }
 
     # Returns the properties specifying implicit include paths to generated
Modified: branches/release/tools/build/v2/test/BoostBuild.py
==============================================================================
--- branches/release/tools/build/v2/test/BoostBuild.py	(original)
+++ branches/release/tools/build/v2/test/BoostBuild.py	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -660,12 +660,14 @@
             self.ignore('*.pdb')       # MSVC program database files.
             self.ignore('*.rsp')       # Response files.
             self.ignore('*.tds')       # Borland debug symbols.
-            self.ignore('*.manifest')  # MSVC DLL manifests.
+            self.ignore('*.manifest')  # MSVC DLL manifests.            
 
         # Debug builds of bjam built with gcc produce this profiling data.
         self.ignore('gmon.out')
         self.ignore('*/gmon.out')
 
+        self.ignore("bin/config.log")
+
         if not self.unexpected_difference.empty():
             annotation('failure', 'Unexpected changes found')
             output = StringIO.StringIO()
Modified: branches/release/tools/build/v2/test/build_dir.py
==============================================================================
--- branches/release/tools/build/v2/test/build_dir.py	(original)
+++ branches/release/tools/build/v2/test/build_dir.py	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -36,6 +36,7 @@
 
 # Test that building from child projects work.
 t.run_build_system(subdir='src')
+t.ignore("build/config.log")
 t.expect_nothing_more()
 
 # Test that project can override build dir.
Modified: branches/release/tools/build/v2/tools/borland.jam
==============================================================================
--- branches/release/tools/build/v2/tools/borland.jam	(original)
+++ branches/release/tools/build/v2/tools/borland.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -117,13 +117,13 @@
 
 actions compile.c++
 {
-    "$(CONFIG_COMMAND)" -j5 -g255 -q -c -P -a8 -b- $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -I"$(STDHDRS)" -o"$(<)" "$(>)"
+    "$(CONFIG_COMMAND)" -j5 -g255 -q -c -P -a8 -Vx- -Ve- -b- $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -I"$(STDHDRS)" -o"$(<)" "$(>)"
 }
 
 # For C, we don't pass -P flag
 actions compile.c
 {
-    "$(CONFIG_COMMAND)" -j5 -g255 -q -c -a8 -b- $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -I"$(STDHDRS)" -o"$(<)" "$(>)"
+    "$(CONFIG_COMMAND)" -j5 -g255 -q -c -a8 -Vx- -Ve- -b- $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -I"$(STDHDRS)" -o"$(<)" "$(>)"
 }
 
 
Modified: branches/release/tools/build/v2/tools/builtin.jam
==============================================================================
--- branches/release/tools/build/v2/tools/builtin.jam	(original)
+++ branches/release/tools/build/v2/tools/builtin.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -1,5 +1,5 @@
 # Copyright 2002, 2003, 2004, 2005 Dave Abrahams
-# Copyright 2002, 2005, 2006, 2007 Rene Rivera
+# Copyright 2002, 2005, 2006, 2007, 2010 Rene Rivera
 # Copyright 2006 Juergen Hunold
 # Copyright 2005 Toon Knapen
 # Copyright 2002, 2003, 2004, 2005, 2006 Vladimir Prus
@@ -429,86 +429,6 @@
 }
 
 
-class c-scanner : scanner
-{
-    import path ;
-    import regex ;
-    import scanner ;
-    import sequence ;
-    import virtual-target ;
-
-    rule __init__ ( includes * )
-    {
-        scanner.__init__ ;
-
-        for local i in $(includes)
-        {
-            self.includes += [ sequence.transform path.native
-                                : [ regex.split $(i:G=) "&&" ] ] ;
-        }
-    }
-
-    rule pattern ( )
-    {
-        return "#[ \t]*include[ ]*(<(.*)>|\"(.*)\")" ;
-    }
-
-    rule process ( target : matches * : binding )
-    {
-        local angle  = [ regex.transform $(matches) : "<(.*)>"   ] ;
-        angle = [ sequence.transform path.native : $(angle) ] ;
-        local quoted = [ regex.transform $(matches) : "\"(.*)\"" ] ;
-        quoted = [ sequence.transform path.native : $(quoted) ] ;
-
-        # CONSIDER: the new scoping rule seem to defeat "on target" variables.
-        local g = [ on $(target) return $(HDRGRIST) ] ;
-        local b = [ NORMALIZE_PATH $(binding:D) ] ;
-
-        # Attach binding of including file to included targets. When a target is
-        # directly created from virtual target this extra information is
-        # unnecessary. But in other cases, it allows us to distinguish between
-        # two headers of the same name included from different places. We do not
-        # need this extra information for angle includes, since they should not
-        # depend on including file (we can not get literal "." in include path).
-        local g2 = $(g)"#"$(b) ;
-
-        angle = $(angle:G=$(g)) ;
-        quoted = $(quoted:G=$(g2)) ;
-
-        local all = $(angle) $(quoted) ;
-
-        INCLUDES $(target) : $(all) ;
-        NOCARE $(all) ;
-        SEARCH on $(angle) = $(self.includes:G=) ;
-        SEARCH on $(quoted) = $(b) $(self.includes:G=) ;
-
-        # Just propagate the current scanner to includes in hope that includes
-        # do not change scanners.
-        scanner.propagate $(__name__) : $(angle) $(quoted) : $(target) ;
-
-        ISFILE $(angle) $(quoted) ;
-    }
-}
-
-
-type.register H   : h ;
-type.register HPP : hpp : H ;
-type.register C   : c ;
-
-scanner.register c-scanner : include ;
-
-# It most cases where a CPP file or a H file is a source of some action, we
-# should rebuild the result if any of files included by CPP/H are changed. One
-# case when this is not needed is installation, which is handled specifically.
-type.set-scanner CPP : c-scanner ;
-type.set-scanner C   : c-scanner ;
-# One case where scanning of H/HPP files is necessary is PCH generation -- if
-# any header included by HPP being precompiled changes, we need to recompile the
-# header.
-type.set-scanner H   : c-scanner ;
-type.set-scanner HPP : c-scanner ;
-
-
 # The generator class for libraries (target type LIB). Depending on properties
 # it will request building of the appropriate specific library type --
 # -- SHARED_LIB, STATIC_LIB or SHARED_LIB.
Modified: branches/release/tools/build/v2/tools/common.jam
==============================================================================
--- branches/release/tools/build/v2/tools/common.jam	(original)
+++ branches/release/tools/build/v2/tools/common.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -825,6 +825,8 @@
     switch [ $(property-set).get <toolset> ]
     {
         case borland* : tag += bcb ;
+        case clang-unix* : tag += gcc ;
+        case clang-darwin* : tag += xgcc ;
         case como* : tag += como ;
         case cw : tag += cw ;
         case darwin* : tag += xgcc ;
Modified: branches/release/tools/build/v2/tools/gcc.jam
==============================================================================
--- branches/release/tools/build/v2/tools/gcc.jam	(original)
+++ branches/release/tools/build/v2/tools/gcc.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -44,39 +44,11 @@
 generators.override gcc.prebuilt : builtin.prebuilt ;
 generators.override gcc.searched-lib-generator : searched-lib-generator ;
 
-# Target naming is determined by types/lib.jam and the settings below this
-# comment.
-#
-# On *nix:
-#     libxxx.a     static library
-#     libxxx.so    shared library
-#
-# On windows (mingw):
-#     libxxx.lib   static library
-#     xxx.dll      DLL
-#     xxx.lib      import library
-#
-# On windows (cygwin) i.e. <target-os>cygwin
-#     libxxx.a     static library
-#     xxx.dll      DLL
-#     libxxx.dll.a import library
-#
-# Implementation notes:
-#   * User can always override this by using the <tag>@rule.
-#   * These settings have been chosen so that mingw is in line with msvc naming
-#     conventions.
-#   * For cygwin the cygwin naming convention has been chosen.
-
 # Make gcc toolset object files use the "o" suffix on all platforms.
 type.set-generated-target-suffix OBJ : <toolset>gcc : o ;
 type.set-generated-target-suffix OBJ : <toolset>gcc <target-os>windows : o ;
 type.set-generated-target-suffix OBJ : <toolset>gcc <target-os>cygwin : o ;
 
-type.set-generated-target-suffix STATIC_LIB : <toolset>gcc <target-os>cygwin : a ;
-type.set-generated-target-suffix IMPORT_LIB : <toolset>gcc <target-os>cygwin : dll.a ;
-type.set-generated-target-prefix IMPORT_LIB : <toolset>gcc <target-os>cygwin : lib ;
-
-
 # Initializes the gcc toolset for the given version. If necessary, command may
 # be used to specify where the compiler is located. The parameter 'options' is a
 # space-delimited list of options, each one specified as
@@ -103,12 +75,12 @@
         bin ?= [ common.get-absolute-tool-path $(command[-1]) ] ;
         root ?= $(bin:D) ;
     }
+    # The 'command' variable can have multiple elements. When calling
+    # the SHELL builtin we need a single string.
+    local command-string = $(command:J=" ") ;
     #   Autodetect the version and flavor if not given.
     if $(command)
-    {
-        # The 'command' variable can have multiple elements. When calling
-        # the SHELL builtin we need a single string.
-        local command-string = $(command:J=" ") ;
+    {    
         local machine = [ MATCH "^([^ ]+)"
             : [ SHELL "$(command-string) -dumpmachine" ] ] ;
         version ?= [ MATCH "^([0-9.]+)"
@@ -185,17 +157,35 @@
     # If it's not a system gcc install we should adjust the various programs as
     # needed to prefer using the install specific versions. This is essential
     # for correct use of MinGW and for cross-compiling.
+    
+    local nl = "
+" ;
 
     # - The archive builder.
-    local archiver =
-        [ common.get-invocation-command gcc
-            : ar : [ feature.get-values <archiver> : $(options) ] : $(bin) : search-path ] ;
+    local archiver = [ common.get-invocation-command gcc
+            : [ NORMALIZE_PATH [ MATCH "(.*)[$(nl)]+" : [ SHELL "$(command-string) -print-prog-name=ar" ] ] ]
+            : [ feature.get-values <archiver> : $(options) ] 
+            : $(bin) 
+            : search-path ] ;
     toolset.flags gcc.archive .AR $(condition) : $(archiver[1]) ;
     if $(.debug-configuration)
     {
         ECHO notice: using gcc archiver :: $(condition) :: $(archiver[1]) ;
     }
 
+    # - Ranlib
+    local ranlib = [ common.get-invocation-command gcc
+            : [ NORMALIZE_PATH [ MATCH "(.*)[$(nl)]+" : [ SHELL "$(command-string) -print-prog-name=ranlib" ] ] ]
+            : [ feature.get-values <ranlib> : $(options) ] 
+            : $(bin) 
+            : search-path ] ;
+    toolset.flags gcc.archive .RANLIB $(condition) : $(ranlib[1]) ;
+    if $(.debug-configuration)
+    {
+        ECHO notice: using gcc ranlib :: $(condition) :: $(ranlib[1]) ;
+    }
+
+
     # - The resource compiler.
     local rc =
         [ common.get-invocation-command-nodefault gcc
@@ -480,8 +470,11 @@
     DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
 }
 
-rule compile.fortran
+rule compile.fortran ( targets * : sources * : properties * )
 {
+    setup-threading $(targets) : $(sources) : $(properties) ;
+    setup-fpic $(targets) : $(sources) : $(properties) ;
+    setup-address-model $(targets) : $(sources) : $(properties) ;
 }
 
 actions compile.c++ bind PCH_FILE
@@ -799,6 +792,22 @@
     }
 }
 
+# Enclose the RPATH variable on 'targets' in (double) quotes,
+# unless it's already enclosed in single quotes.
+# This special casing is done because it's common to pass
+# '$ORIGIN' to linker -- and it has to have single quotes
+# to prevent expansion by shell -- and if we add double
+# quotes then preventing properties of single quotes disappear.
+rule quote-rpath ( targets * )
+{
+    local r = [ on $(targets[1]) return $(RPATH) ] ;
+    if ! [ MATCH "('.*')" : $(r) ] 
+    {
+        r = "\"$(r)\"" ;
+    }
+    RPATH on $(targets) = $(r) ;
+}
+
 # Declare actions for linking.
 rule link ( targets * : sources * : properties * )
 {
@@ -809,11 +818,12 @@
     # parallel is just slower. For now, serialize only gcc links, it might be a
     # good idea to serialize all links.
     JAM_SEMAPHORE on $(targets) = <s>gcc-link-semaphore ;
+    quote-rpath $(targets) ;
 }
 
 actions link bind LIBRARIES
 {
-    "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
+    "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,$(RPATH) -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
 
 }
 
@@ -822,6 +832,7 @@
 # logic in intel-linux, but that's hardly worth the trouble as on Linux, 'ar' is
 # always available.
 .AR = ar ;
+.RANLIB = ranlib ;
 
 toolset.flags gcc.archive AROPTIONS <archiveflags> ;
 
@@ -862,21 +873,22 @@
 actions piecemeal archive
 {
     "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)"
+    "$(.RANLIB)" "$(<)"
 }
 
-
 rule link.dll ( targets * : sources * : properties * )
 {
     setup-threading $(targets) : $(sources) : $(properties) ;
     setup-address-model $(targets) : $(sources) : $(properties) ;
     SPACE on $(targets) = " " ;
     JAM_SEMAPHORE on $(targets) = <s>gcc-link-semaphore ;
+    quote-rpath $(targets) ;
 }
 
 # Differs from 'link' above only by -shared.
 actions link.dll bind LIBRARIES
 {
-    "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" "$(.IMPLIB-COMMAND)$(<[1])" -o "$(<[-1])" $(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) -shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
+    "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,$(RPATH) "$(.IMPLIB-COMMAND)$(<[1])" -o "$(<[-1])" $(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) -shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
 }
 
 rule setup-threading ( targets * : sources * : properties * )
Modified: branches/release/tools/build/v2/tools/stage.jam
==============================================================================
--- branches/release/tools/build/v2/tools/stage.jam	(original)
+++ branches/release/tools/build/v2/tools/stage.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -246,20 +246,23 @@
             s += [ $(t).creating-subvariant ] ;
         }
         s = [ sequence.unique $(s) ] ;
-
-        local result = $(targets) ;
+        
+        local result = [ new set ] ;
+        $(result).add $(targets) ;
+        
         for local i in $(s)
         {
-            result += [ $(i).all-referenced-targets ] ;
+            $(i).all-referenced-targets $(result) ;
         }
         local result2 ;
-        for local r in $(result)
+        for local r in [ $(result).list ]
         {
             if $(r:G) != <use>
             {
                 result2 += $(r:G=) ;
             }
         }
+        DELETE_MODULE $(result) ;
         result = [ sequence.unique $(result2) ] ;
     }
 
Modified: branches/release/tools/build/v2/tools/types/cpp.jam
==============================================================================
--- branches/release/tools/build/v2/tools/types/cpp.jam	(original)
+++ branches/release/tools/build/v2/tools/types/cpp.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -1,4 +1,86 @@
-# Copyright David Abrahams 2004. Distributed under the Boost
-# Software License, Version 1.0. (See accompanying
-# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-type CPP : cpp cxx cc ;
+# Copyright David Abrahams 2004.
+# Copyright 2002, 2003, 2004, 2005, 2006 Vladimir Prus
+# Copyright 2010 Rene Rivera
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+import type ;
+import scanner ;
+
+class c-scanner : scanner
+{
+    import path ;
+    import regex ;
+    import scanner ;
+    import sequence ;
+    import virtual-target ;
+
+    rule __init__ ( includes * )
+    {
+        scanner.__init__ ;
+
+        for local i in $(includes)
+        {
+            self.includes += [ sequence.transform path.native
+                                : [ regex.split $(i:G=) "&&" ] ] ;
+        }
+    }
+
+    rule pattern ( )
+    {
+        return "#[ \t]*include[ ]*(<(.*)>|\"(.*)\")" ;
+    }
+
+    rule process ( target : matches * : binding )
+    {
+        local angle  = [ regex.transform $(matches) : "<(.*)>"   ] ;
+        angle = [ sequence.transform path.native : $(angle) ] ;
+        local quoted = [ regex.transform $(matches) : "\"(.*)\"" ] ;
+        quoted = [ sequence.transform path.native : $(quoted) ] ;
+
+        # CONSIDER: the new scoping rule seem to defeat "on target" variables.
+        local g = [ on $(target) return $(HDRGRIST) ] ;
+        local b = [ NORMALIZE_PATH $(binding:D) ] ;
+
+        # Attach binding of including file to included targets. When a target is
+        # directly created from virtual target this extra information is
+        # unnecessary. But in other cases, it allows us to distinguish between
+        # two headers of the same name included from different places. We do not
+        # need this extra information for angle includes, since they should not
+        # depend on including file (we can not get literal "." in include path).
+        local g2 = $(g)"#"$(b) ;
+
+        angle = $(angle:G=$(g)) ;
+        quoted = $(quoted:G=$(g2)) ;
+
+        local all = $(angle) $(quoted) ;
+
+        INCLUDES $(target) : $(all) ;
+        NOCARE $(all) ;
+        SEARCH on $(angle) = $(self.includes:G=) ;
+        SEARCH on $(quoted) = $(b) $(self.includes:G=) ;
+
+        # Just propagate the current scanner to includes in hope that includes
+        # do not change scanners.
+        scanner.propagate $(__name__) : $(angle) $(quoted) : $(target) ;
+
+        ISFILE $(angle) $(quoted) ;
+    }
+}
+
+scanner.register c-scanner : include ;
+
+type.register CPP : cpp cxx cc ;
+type.register H   : h ;
+type.register HPP : hpp : H ;
+type.register C   : c ;
+
+# It most cases where a CPP file or a H file is a source of some action, we
+# should rebuild the result if any of files included by CPP/H are changed. One
+# case when this is not needed is installation, which is handled specifically.
+type.set-scanner CPP : c-scanner ;
+type.set-scanner C   : c-scanner ;
+# One case where scanning of H/HPP files is necessary is PCH generation -- if
+# any header included by HPP being precompiled changes, we need to recompile the
+# header.
+type.set-scanner H   : c-scanner ;
+type.set-scanner HPP : c-scanner ;
Modified: branches/release/tools/build/v2/tools/types/lib.jam
==============================================================================
--- branches/release/tools/build/v2/tools/types/lib.jam	(original)
+++ branches/release/tools/build/v2/tools/types/lib.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -5,26 +5,64 @@
 import type ; # for set-generated-target-suffix
 import os ;
 
-type.register LIB ;
+# The following naming scheme is used for libraries.
+#
+# On *nix:
+#     libxxx.a       static library
+#     libxxx.so      shared library
+#
+# On windows (msvc)
+#     libxxx.lib     static library
+#     xxx.dll        DLL
+#     xxx.lib        import library
+#
+# On windows (mingw):
+#     libxxx.a       static library
+#     libxxx.dll     DLL
+#     libxxx.dll.a   import library
+#
+# On cygwin i.e. <target-os>cygwin
+#     libxxx.a       static library
+#     cygxxx.dll     DLL
+#     libxxx.dll.a   import library
+#
 
-type.set-generated-target-prefix LIB : : "lib" ;
-type.set-generated-target-prefix LIB : <target-os>windows : "" ;
-type.set-generated-target-prefix LIB : <target-os>cygwin : "cyg" ;
+type.register LIB ;
 
-# FIXME: should not register both extensions on both
-# platforms.
+# FIXME: should not register both extensions on both platforms.
 type.register STATIC_LIB : a lib : LIB ;
 
+# The 'lib' prefix is used everywhere
+type.set-generated-target-prefix STATIC_LIB : : lib ;
+
+# Use '.lib' suffix for windows
 type.set-generated-target-suffix STATIC_LIB : <target-os>windows : lib ;
+
+# Except with gcc.
 type.set-generated-target-suffix STATIC_LIB : <toolset>gcc <target-os>windows : a ;
-type.set-generated-target-suffix STATIC_LIB : <target-os>cygwin : lib ;
-type.set-generated-target-prefix STATIC_LIB : : lib ;
 
+# Use xxx.lib for import libs
 type IMPORT_LIB : : STATIC_LIB ;
-type.set-generated-target-suffix IMPORT_LIB : : lib ;
 type.set-generated-target-prefix IMPORT_LIB : : "" ;
+type.set-generated-target-suffix IMPORT_LIB : : lib ;
+
+# Except with gcc (mingw or cygwin), where use libxxx.dll.a
+type.set-generated-target-prefix IMPORT_LIB : <toolset>gcc : lib ;
+type.set-generated-target-suffix IMPORT_LIB : <toolset>gcc : dll.a ;
 
 type.register SHARED_LIB : so dll dylib : LIB ;
+
+# Both mingw and cygwin use libxxx.dll naming scheme.
+# On Linux, use "lib" prefix
+type.set-generated-target-prefix SHARED_LIB : : lib ;
+# But don't use it on windows
+type.set-generated-target-prefix SHARED_LIB : <target-os>windows : "" ;
+# But use it again on mingw
+type.set-generated-target-prefix SHARED_LIB : <toolset>gcc <target-os>windows : lib ;
+# And use 'cyg' on cygwin
+type.set-generated-target-prefix SHARED_LIB : <target-os>cygwin : cyg ;
+
+
 type.set-generated-target-suffix SHARED_LIB : <target-os>windows : dll ;
 type.set-generated-target-suffix SHARED_LIB : <target-os>cygwin : dll ;
 type.set-generated-target-suffix SHARED_LIB : <target-os>darwin : dylib ;
Modified: branches/release/tools/build/v2/tools/types/objc.jam
==============================================================================
--- branches/release/tools/build/v2/tools/types/objc.jam	(original)
+++ branches/release/tools/build/v2/tools/types/objc.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -1,5 +1,26 @@
-# Copyright Rene Rivera 2008.
+# Copyright Rene Rivera 2008, 2010.
 # Distributed under the Boost Software License, Version 1.0. (See accompanying
 # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-type OBJECTIVE_C : m ;
-type OBJECTIVE_CPP : mm ;
+import type ;
+import scanner ;
+import types/cpp ;
+
+class objc-scanner : c-scanner
+{
+    rule __init__ ( includes * )
+    {
+        c-scanner.__init__ $(includes) ;
+    }
+
+    rule pattern ( )
+    {
+        return "#[ \t]*include|import[ ]*(<(.*)>|\"(.*)\")" ;
+    }
+}
+
+scanner.register objc-scanner : include ;
+
+type.register OBJECTIVE_C : m ;
+type.register OBJECTIVE_CPP : mm ;
+type.set-scanner OBJECTIVE_C : objc-scanner ;
+type.set-scanner OBJECTIVE_CPP : objc-scanner ;
Modified: branches/release/tools/build/v2/util/indirect.jam
==============================================================================
--- branches/release/tools/build/v2/util/indirect.jam	(original)
+++ branches/release/tools/build/v2/util/indirect.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -51,9 +51,15 @@
     else
     {
         frames ?= 1 ;
-        # Take the first dot-separated element as module name. This disallows
-        # module names with dots, but allows rule names with dots.
-        local module-context = [ MATCH ^([^.]*)\\..* : $(rulename) ] ;
+        # If the rule name includes a Jamfile module, grab it.
+        local module-context = [ MATCH ^(Jamfile<[^>]*>)\\..* : $(rulename) ] ;
+        
+        if ! $(module-context)
+        {                    
+            # Take the first dot-separated element as module name. This disallows
+            # module names with dots, but allows rule names with dots.
+            module-context = [ MATCH ^([^.]*)\\..* : $(rulename) ] ;
+        }        
         module-context ?= [ CALLER_MODULE $(frames) ] ;
         return [ make $(rulename) $(bound-args) : $(module-context) ] ;
     }
Modified: branches/release/tools/build/v2/util/set.jam
==============================================================================
--- branches/release/tools/build/v2/util/set.jam	(original)
+++ branches/release/tools/build/v2/util/set.jam	2010-04-20 08:05:14 EDT (Tue, 20 Apr 2010)
@@ -3,6 +3,36 @@
 # Distributed under the Boost Software License, Version 1.0.
 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
 
+class set
+{
+    rule __init__ ( )
+    {
+    }  
+    
+    rule add ( elements * )
+    {
+        for local e in $(elements)
+        {
+            if ! $($(e))
+            {
+                $(e) = 1 ;
+                self.result += $(e) ;
+            }            
+        }        
+    }    
+    
+    rule contains ( element )
+    {
+        return $($(element)) ;
+    }
+    
+    rule list ( )
+    {
+        return $(self.result) ;
+    }            
+}
+
+
 
 # Returns the elements of set1 that are not in set2.
 #