Index: rtems/config/rtems-bsp.cfg
===================================================================
--- rtems/config/rtems-bsp.cfg	(revision fba2549d5c06a4a3f6f36ec1672a98371f55a916)
+++ rtems/config/rtems-bsp.cfg	(revision 7385feb2748b9b722a41b23f908daa6f40725bad)
@@ -4,19 +4,23 @@
 
 #
-# The RTEMS BSP support requires the host turple, the RTEMS BSP
-# and the path to the tools. The prefix is set to an installed
-# RTEMS. The built package is installed into the prefix.
+# The RTEMS BSP support requires the host turple, the RTEMS BSP and the path to
+# the tools. The prefix is set to an installed RTEMS. The built package is
+# installed into the prefix.
 #
-# Keeping the package's installed path in the RTEMS install path
-# and separate to the tools lets the tools version vary
-# independently. If --with-tools is not provided use the prefix.
+# Keeping the package's installed path in the RTEMS install path and separate
+# to the tools lets the tools version vary independently. If --rtems-tools
+# (--with-tools) is not provided use the prefix.
 #
 
-%if %{_host} == %{nil}
- %error No RTEMS target specified: --host=host
+%if %{_target} == %{nil}
+ %error No RTEMS target specified: --rtems-bsp=arch/bsp (or --target=target)
+%endif
+
+%if %{_host} != %{_build}
+ %error Canadian cross building for BSP is not supported.
 %endif
 
 %ifn %{defined with_rtems_bsp}
- %error No RTEMS BSP specified: --with-rtems-bsp=bsp
+ %error No RTEMS BSP specified: --rtems-bsp=arch/bsp (or --with-rtems-bsp=bsp)
 %endif
 
@@ -24,4 +28,9 @@
  %define with_tools %{_prefix}
 %endif
+
+#
+# Set the host to the target.
+#
+%define _host %{_target}
 
 #
@@ -47,4 +56,8 @@
 %define rtems_bsp_ldflags   %{pkgconfig ldflags %{_host}-%{rtems_bsp}}
 %define rtems_bsp_libs      %{pkgconfig libs    %{_host}-%{rtems_bsp}}
+
+%if %{rtems_bsp_cflags} == %{nil}
+ %error No RTEMS target CFLAGS found; Please check the --rtems-bsp option.
+%endif
 
 %if %{rtems_bsp_ccflags} == %{nil}
Index: rtems/config/tools/rtems-autoconf-2.69-1.cfg
===================================================================
--- rtems/config/tools/rtems-autoconf-2.69-1.cfg	(revision fba2549d5c06a4a3f6f36ec1672a98371f55a916)
+++ rtems/config/tools/rtems-autoconf-2.69-1.cfg	(revision 7385feb2748b9b722a41b23f908daa6f40725bad)
@@ -2,4 +2,8 @@
 # Autoconf 2.69.
 #
+
+%if %{rtems_arch} == none
+ %define _target %{_host}
+%endif
 
 %include %{_configdir}/checks.cfg
Index: rtems/config/tools/rtems-automake-1.12.6-1.cfg
===================================================================
--- rtems/config/tools/rtems-automake-1.12.6-1.cfg	(revision fba2549d5c06a4a3f6f36ec1672a98371f55a916)
+++ rtems/config/tools/rtems-automake-1.12.6-1.cfg	(revision 7385feb2748b9b722a41b23f908daa6f40725bad)
@@ -2,4 +2,8 @@
 # Automake 1.12.6
 #
+
+%if %{rtems_arch} == none
+ %define _target %{_host}
+%endif
 
 %include %{_configdir}/checks.cfg
Index: source-builder/defaults.mc
===================================================================
--- source-builder/defaults.mc	(revision fba2549d5c06a4a3f6f36ec1672a98371f55a916)
+++ source-builder/defaults.mc	(revision 7385feb2748b9b722a41b23f908daa6f40725bad)
@@ -80,4 +80,5 @@
 _builddir:           dir,     optional, '%{_topdir}/build/%{buildname}'
 _buildcxcdir:        dir,     optional, '%{_topdir}/build/%{buildname}-cxc'
+_buildxcdir:         dir,     optional, '%{_topdir}/build/%{buildname}-xc'
 _docdir:             dir,     none,     '%{_defaultdocdir}'
 _tmppath:            dir,     none,     '%{_topdir}/build/tmp'
@@ -86,4 +87,5 @@
 buildroot:           dir,     none,     '%{_tmppath}/%{buildname}-%{_uid}'
 buildcxcroot:        dir,     none,     '%{_tmppath}/%{buildname}-%{_uid}-cxc'
+buildxcroot:         dir,     none,     '%{_tmppath}/%{buildname}-%{_uid}-xx'
 _datadir:            dir,     none,     '%{_prefix}/share'
 _defaultdocdir:      dir,     none,     '%{_prefix}/share/doc'
@@ -302,5 +304,5 @@
 host_build_flags:    none,    none,     '''
 # Host and build flags, Cross build if host and build are different and
-# Cxc build idf target is deifned and also different.
+# Cxc build if target is deifned and also different.
 # Note, gcc is not ready to be compiled with -std=gnu99 (this needs to be checked).
 if test "%{_build}" != "%{_host}" ; then
Index: source-builder/sb/build.py
===================================================================
--- source-builder/sb/build.py	(revision fba2549d5c06a4a3f6f36ec1672a98371f55a916)
+++ source-builder/sb/build.py	(revision 7385feb2748b9b722a41b23f908daa6f40725bad)
@@ -23,4 +23,5 @@
 #
 
+import copy
 import getopt
 import glob
@@ -117,10 +118,10 @@
         try:
             self.opts = opts
-            if macros is None:
-                self.macros = opts.defaults
-            else:
-                self.macros = macros
+            self.init_name = name
+            self.init_macros = macros
+            self.config = None
             self.create_tar_files = create_tar_files
             log.notice('config: ' + name)
+            self.set_macros(macros)
             self.config = config.file(name, opts, self.macros)
             self.script = script()
@@ -137,4 +138,18 @@
             raise
 
+    def copy_init_macros(self):
+        return copy.copy(self.init_macros)
+
+    def copy_macros(self):
+        return copy.copy(self.macros)
+
+    def set_macros(self, macros):
+        if macros is None:
+            self.macros = copy.copy(opts.defaults)
+        else:
+            self.macros = copy.copy(macros)
+        if self.config:
+            self.config.set_macros(self.macros)
+
     def rmdir(self, rmpath):
         log.output('removing: %s' % (path.host(rmpath)))
@@ -152,7 +167,28 @@
         _build = self.config.expand('%{_build}')
         _target = self.config.expand('%{_target}')
-        return self.config.defined('%{allow_cxc}') and \
-            len(_host) and len(_build) and (_target) and \
-            _host != _build and _host != _target
+        _allowed = self.config.defined('%{allow_cxc}')
+        if len(_host) and len(_build) and (_target) and \
+           _allowed and _host != _build and _host != _target:
+            return True
+        return False
+
+    def installable(self):
+        _host = self.config.expand('%{_host}')
+        _build = self.config.expand('%{_build}')
+        _canadian_cross = self.canadian_cross()
+        if self.macros.get('_disable_installing') and \
+           self.config.expand('%{_disable_installing}') == 'yes':
+            _disable_installing = True
+        else:
+            _disable_installing = False
+        _no_install = self.opts.no_install()
+        log.trace('_build: installable: host=%s build=%s ' \
+                  'no-install=%r Cxc=%r disable_installing=%r disabled=%r' % \
+                  (_host, _build, _no_install, _canadian_cross, _disable_installing, \
+                   self.disabled()))
+        return len(_host) and len(_build) and \
+            not self.disabled() and \
+            not _disable_installing and \
+            not _canadian_cross
 
     def source(self, name):
@@ -314,5 +350,6 @@
                     if args[0] == '%setup':
                         if len(args) == 1:
-                            raise error.general('invalid %%setup directive: %s' % (' '.join(args)))
+                            raise error.general('invalid %%setup directive: %s' % \
+                                                (' '.join(args)))
                         if args[1] == 'source':
                             self.source_setup(package, args[1:])
@@ -372,4 +409,6 @@
     def build_package(self, package):
         if self.canadian_cross():
+            if not self.config.defined('%{allow_cxc}'):
+                raise error.general('Canadian Cross is not allowed')
             self.script.append('echo "==> Candian-cross build/target:"')
             self.script.append('SB_CXC="yes"')
@@ -403,4 +442,7 @@
         return packages['main']
 
+    def reload(self):
+        self.config.load(self.init_name)
+
     def make(self):
         package = self.main_package()
@@ -411,10 +453,11 @@
                 name = package.name()
                 if self.canadian_cross():
-                    log.notice('package: (Cxc) %s' % (name))
+                    cxc_label = '(Cxc) '
                 else:
-                    log.notice('package: %s' % (name))
-                    log.trace('---- macro maps %s' % ('-' * 55))
-                    log.trace('%s' % (str(self.config.macros)))
-                    log.trace('-' * 70)
+                    cxc_label = ''
+                log.notice('package: %s%s' % (cxc_label, name))
+                log.trace('---- macro maps %s' % ('-' * 55))
+                log.trace('%s' % (str(self.config.macros)))
+                log.trace('-' * 70)
                 self.script.reset()
                 self.script.append(self.config.expand('%{___build_template}'))
@@ -427,8 +470,5 @@
                     log.output('write script: ' + sn)
                     self.script.write(sn)
-                    if self.canadian_cross():
-                        log.notice('building: (Cxc) %s' % (name))
-                    else:
-                        log.notice('building: %s' % (name))
+                    log.notice('building: %s%s' % (cxc_label, name))
                     self.run(sn)
             except error.general, gerr:
Index: source-builder/sb/config.py
===================================================================
--- source-builder/sb/config.py	(revision fba2549d5c06a4a3f6f36ec1672a98371f55a916)
+++ source-builder/sb/config.py	(revision 7385feb2748b9b722a41b23f908daa6f40725bad)
@@ -237,33 +237,12 @@
 
     def __init__(self, name, opts, macros = None):
+        log.trace('config: %s: initialising' % (name))
         self.opts = opts
-        if macros is None:
-            self.macros = opts.defaults
-        else:
-            self.macros = macros
         self.init_name = name
-        log.trace('config: %s' % (name))
-        self.disable_macro_reassign = False
-        self.configpath = []
         self.wss = re.compile(r'\s+')
         self.tags = re.compile(r':+')
         self.sf = re.compile(r'%\([^\)]+\)')
-        for arg in self.opts.args:
-            if arg.startswith('--with-') or arg.startswith('--without-'):
-                if '=' in arg:
-                    label, value = arg.split('=', 1)
-                else:
-                    label = arg
-                    value = None
-                label = label[2:].lower().replace('-', '_')
-                if value:
-                    self.macros.define(label, value)
-                else:
-                    self.macros.define(label)
-        self._includes = []
-        self.load_depth = 0
-        self.pkgconfig_prefix = None
-        self.pkgconfig_crosscompile = False
-        self.pkgconfig_filter_flags = False
+        self.set_macros(macros)
+        self._reset(name)
         self.load(name)
 
@@ -286,4 +265,32 @@
             s += str(self._packages[_package])
         return s
+
+    def _reset(self, name):
+        self.name = name
+        self.load_depth = 0
+        self.configpath = []
+        self._includes = []
+        self._packages = {}
+        self.in_error = False
+        self.lc = 0
+        self.conditionals = {}
+        self._packages = {}
+        self.package = 'main'
+        self.disable_macro_reassign = False
+        self.pkgconfig_prefix = None
+        self.pkgconfig_crosscompile = False
+        self.pkgconfig_filter_flags = False
+        for arg in self.opts.args:
+            if arg.startswith('--with-') or arg.startswith('--without-'):
+                if '=' in arg:
+                    label, value = arg.split('=', 1)
+                else:
+                    label = arg
+                    value = None
+                label = label[2:].lower().replace('-', '_')
+                if value:
+                    self.macros.define(label, value)
+                else:
+                    self.macros.define(label)
 
     def _relative_path(self, p):
@@ -1054,4 +1061,10 @@
         self._packages[self.package].info_append(info, data)
 
+    def set_macros(self, macros):
+        if macros is None:
+            self.macros = opts.defaults
+        else:
+            self.macros = macros
+
     def load(self, name):
 
@@ -1067,10 +1080,5 @@
 
         if self.load_depth == 0:
-            self.in_error = False
-            self.lc = 0
-            self.name = name
-            self.conditionals = {}
-            self._packages = {}
-            self.package = 'main'
+            self._reset(name)
             self._packages[self.package] = package(self.package,
                                                    self.define('%{_arch}'),
Index: source-builder/sb/options.py
===================================================================
--- source-builder/sb/options.py	(revision fba2549d5c06a4a3f6f36ec1672a98371f55a916)
+++ source-builder/sb/options.py	(revision 7385feb2748b9b722a41b23f908daa6f40725bad)
@@ -222,4 +222,7 @@
         print '--with-<label>         : Add the --with-<label> to the build'
         print '--without-<label>      : Add the --without-<label> to the build'
+        print '--rtems-tools path     : Path to an install RTEMS tool set'
+        print '--rtems-bsp arc/bsp    : Standard RTEMS architecure and BSP specifier'
+        print '--rtems-version ver    : The RTEMS major/minor version string'
         if self.optargs:
             for a in self.optargs:
@@ -298,8 +301,4 @@
             if path.exists(rsb_macros):
                 self.defaults.load(rsb_macros)
-        # If a Cxc build disable installing.
-        if self.canadian_cross():
-            self.opts['no-install'] = '1'
-            self.defaults['_no_install'] = '1'
 
     def sb_git(self):
@@ -451,5 +450,5 @@
     def get_arg(self, arg):
         if self.optargs is None or arg not in self.optargs:
-            raise error.internal('bad arg: %s' % (arg))
+            return None
         return self.parse_args(arg)
 
@@ -517,4 +516,7 @@
         return self.opts['no-download'] != '0'
 
+    def disable_install(self):
+        self.opts['no-install'] = '1'
+
     def info(self):
         s = ' Command Line: %s%s' % (' '.join(self.argv), os.linesep)
@@ -524,4 +526,26 @@
     def log_info(self):
         log.output(self.info())
+
+    def rtems_options(self):
+        # Check for RTEMS specific helper options.
+        rtems_tools = self.parse_args('--rtems-tools')
+        if rtems_tools is not None:
+            if self.get_arg('--with-tools') is not None:
+                raise error.general('--rtems-tools and --with-tools cannot be used together')
+            self.args.append('--with-tools=%s' % (rtems_tools[1]))
+        rtems_arch_bsp = self.parse_args('--rtems-bsp')
+        if rtems_arch_bsp is not None:
+            if self.get_arg('--target') is not None:
+                raise error.general('--rtems-bsp and --target cannot be used together')
+            ab = rtems_arch_bsp[1].split('/')
+            if len(ab) != 2:
+                raise error.general('invalid --rtems-bsp option')
+            rtems_version = self.parse_args('--rtems-version')
+            if rtems_version is None:
+                rtems_version = '%d.%d' % (version.major, version.minor)
+            else:
+                rtems_version = rtems_version[1]
+            self.args.append('--target=%s-rtems%s' % (ab[0], rtems_version))
+            self.args.append('--with-rtems-bsp=%s' % (ab[1]))
 
 def load(args, optargs = None, defaults = '%{_sbdir}/defaults.mc'):
@@ -591,4 +615,5 @@
 
     o.sb_git()
+    o.rtems_options()
     o.process()
     o.post_process()
Index: source-builder/sb/path.py
===================================================================
--- source-builder/sb/path.py	(revision fba2549d5c06a4a3f6f36ec1672a98371f55a916)
+++ source-builder/sb/path.py	(revision 7385feb2748b9b722a41b23f908daa6f40725bad)
@@ -202,5 +202,9 @@
         if trace:
             print ' mkdir: %s' % (hdst)
-        os.makedirs(hdst)
+        try:
+            os.makedirs(hdst)
+        except OSError, why:
+            raise error.general('copying tree: cannot create target directory %s: %s' % \
+                                (hdst, str(why)))
 
     for name in names:
Index: source-builder/sb/setbuilder.py
===================================================================
--- source-builder/sb/setbuilder.py	(revision fba2549d5c06a4a3f6f36ec1672a98371f55a916)
+++ source-builder/sb/setbuilder.py	(revision 7385feb2748b9b722a41b23f908daa6f40725bad)
@@ -100,5 +100,6 @@
                 if format is not None:
                     if len(format) != 2:
-                        raise error.general('invalid report format option: %s' % ('='.join(format)))
+                        raise error.general('invalid report format option: %s' % \
+                                            ('='.join(format)))
                     format = format[1]
             if format is None:
@@ -157,25 +158,26 @@
 
     def canadian_cross(self, _build):
-        # @fixme Switch to using a private macros map.
-        macros_to_save = ['%{_prefix}',
-                          '%{_tmproot}',
-                          '%{buildroot}',
-                          '%{_builddir}',
-                          '%{_host}']
-        macros_to_copy = [('%{_host}',     '%{_build}'),
-                          ('%{_tmproot}',  '%{_tmpcxcroot}'),
-                          ('%{buildroot}', '%{buildcxcroot}'),
-                          ('%{_builddir}', '%{_buildcxcdir}')]
-        orig_macros = {}
-        for m in macros_to_save:
-            orig_macros[m] = _build.config.macro(m)
+        log.trace('_bset: Cxc for build machine: _build => _host')
+        macros_to_copy = [('%{_host}',        '%{_build}'),
+                          ('%{_host_alias}',  '%{_build_alias}'),
+                          ('%{_host_arch}',   '%{_build_arch}'),
+                          ('%{_host_cpu}',    '%{_build_cpu}'),
+                          ('%{_host_os}',     '%{_build_os}'),
+                          ('%{_host_vendor}', '%{_build_vendor}'),
+                          ('%{_tmproot}',     '%{_tmpcxcroot}'),
+                          ('%{buildroot}',    '%{buildcxcroot}'),
+                          ('%{_builddir}',    '%{_buildcxcdir}')]
+        cxc_macros = _build.copy_init_macros()
         for m in macros_to_copy:
-            _build.config.set_define(m[0], _build.config.macro(m[1]))
+            log.trace('_bset: Cxc: %s <= %s' % (m[0], cxc_macros[m[1]]))
+            cxc_macros[m[0]] = cxc_macros[m[1]]
+        _build.set_macros(cxc_macros)
+        _build.reload()
         _build.make()
-        for m in macros_to_save:
-            _build.config.set_define(m, orig_macros[m])
         if not _build.macros.get('%{_disable_collecting}'):
-            self.root_copy(_build.config.expand('%{buildcxcroot}'),
-                           _build.config.expand('%{_tmpcxcroot}'))
+            self.root_copy(_build.config.expand('%{buildroot}'),
+                           _build.config.expand('%{_tmproot}'))
+        _build.set_macros(_build.copy_init_macros())
+        _build.reload()
 
     def build_package(self, _config, _build):
@@ -190,5 +192,5 @@
     def bset_tar(self, _build):
         tardir = _build.config.expand('%{_tardir}')
-        if self.opts.get_arg('--bset-tar-file') \
+        if (self.opts.get_arg('--bset-tar-file') or self.opts.canadian_cross()) \
            and not _build.macros.get('%{_disable_packaging}'):
             path.mkdir(tardir)
@@ -381,14 +383,19 @@
                     else:
                         raise
+            #
+            # Installing ...
+            #
+            log.trace('_bset: installing: deps:%r no-install:%r' % \
+                      (deps is None, self.opts.no_install()))
             if deps is None \
                and not self.opts.no_install() \
                and not have_errors:
                 for b in builds:
-                    if not b.canadian_cross() \
-                       and not b.disabled() \
-                       and not b.macros.get('%{_disable_installing}'):
+                    log.trace('_bset: installing: %r' % b.installable())
+                    if b.installable():
                         self.install(b.name(),
                                      b.config.expand('%{buildroot}'),
                                      b.config.expand('%{_prefix}'))
+
             if deps is None and \
                     (not self.opts.no_clean() or self.opts.always_clean()):
@@ -473,4 +480,7 @@
         if not list_bset_cfg_files(opts, configs):
             prefix = opts.defaults.expand('%{_prefix}')
+            if opts.canadian_cross():
+                opts.disable_install()
+
             if not opts.dry_run() and \
                not opts.canadian_cross() and \
Index: source-builder/sb/version.py
===================================================================
--- source-builder/sb/version.py	(revision fba2549d5c06a4a3f6f36ec1672a98371f55a916)
+++ source-builder/sb/version.py	(revision 7385feb2748b9b722a41b23f908daa6f40725bad)
@@ -24,6 +24,6 @@
 #
 
-major = 0
-minor = 5
+major = 4
+minor = 11
 revision = 0
 
