Index: itignore
===================================================================
--- .gitignore	(revision 1b896361d302aeda0145af90972aea863e28898f)
+++ 	(revision )
@@ -1,2 +1,0 @@
-*.pyc
-*~
Index: ADME
===================================================================
--- README	(revision 1b896361d302aeda0145af90972aea863e28898f)
+++ 	(revision )
@@ -1,389 +1,0 @@
-RTEMS Waf
-~~~~~~~~~
-
-RTEMS Waf is a module that supports the Waf build system and RTEMS. The module
-is integrated into a project or library proividing Waf build support to create
-RTEMS libraries or executables.
-
-RTEMS Waf provides:
-
-* Checking for a valid RTEMS installation of tools and kernel.
-
-* Support for multiple versions of RTEMS.
-
-* Support to build a number of BSPs at once.
-
-* Support for the RTEMS tools and kernel being installed under a shared or
-  separate prefixes [2].
-
-* Flexible integration that allows easy project specific specialization.
-
-* Support to check which features RTEMS is built with.
-
-* Support for BSP compiler and linker flags. The flags are separated into their
-  various types to allow flexible options management in a project.
-
-* Support to list the available architectures and BSPs.
-
-* Additional support for creating root file systems for RTEMS targets.
-
-Bugs
-----
-
-Please report issues to the RTEMS Users list mailto:users@rtems.org or raise a
-ticket in RTEMS's Trac under https://devel.rtems.org/.
-
-Feedback is always welcome.
-
-Waf
----
-
-You can find the Waf project here:
-
- https://waf.io/
-
-Waf does not come as a package in distrubitions so you need to download and
-install it.
-
-1. Waf is a Python program so you will also need to have a current Python
-   installed and accessible via your environment's path.
-
-2. Download the latest signed Waf executable file from the Waf website.
-
-3. Place the waf executable in a personal directory that is in your path, for
-   example $HOME/bin. Modify the file's permissions so it can be executed:
-
-    $ chmod +x $HOME/bin/waf
-
-Git Submodule
--------------
-
-RTEMS Waf can be used as a git submodule. This lets a number of projects share
-the common waf support.
-
-1. Add RTEMS Waf a git submodule to your project:
-
-    $ cd my_project
-    $ git submodule add git://git.rtems.org/rtems_waf.git rtems_waf
-
-2. Initialize the submodule(s) for your project:
-
-    $ git submodule init
-
-3. Update the RTEMS Waf submodule:
-
-    $ git submodule update rtems_waf
-
-   Note, the `rtems_waf` submodule name is provided as some projects may have
-   other submodules you may not wish to update.
-
-4. When submodules are added they are headless which means they are not on a
-   current branch. Switch to a branch:
-
-    $ cd rtems_waf
-    $ git checkout master
-    $ cd ..
-
-   Note, you can replace `master` in the `checkout` above with any valid branch
-   in the RTEMS Waf repo.
-
-5. Update the RTEMS Waf submodule to the latest version on the selected branch:
-
-    $ cd rtems_waf
-    $ git pull
-    $ cd ..
-
-6. Check the new submodule is part of your project and ready to be committed:
-
-    $ git status
-
-   The `rtems_waf` module will be listed as `modified`.
-
-7. Commit the change by adding it to your staged files:
-
-    $ git add rtems_waf
-
-   When ready commit:
-
-    $ git commit
-
-   Review the changes and if they are correct push them:
-
-    $ git log -p
-    $ git push
-
-The RTEMS Waf module is updated from time to time as new features are added or
-changes happen in waf. To update a project's existing RTEMS Waf submodule
-perform steps 5. to 7.
-
-Project Instructions
---------------------
-
-Create a README.waf file in your project and add the Waf installation section,
-your project specific options and the following steps. These steps are for
-RTEMS 5, change for the specific version of RTEMS your project supports.
-
-1. Build or install the tools. In this example the path is the personal prefix
-   of $HOME/development/rtems/5 [1].
-
-2. Build and install the RTEMS Board Support Packages you want to use. In this
-   example separate tools and kernel prefixes are used [2]. The kernel path is
-   $HOME/development/rtems/bsps/5.
-
-3. Unpack this package somewhere, anywhere on your disk and change into the top
-   level directory.
-
-4. Populate the git submodule:
-
-    $ git submodule init
-    $ git submodule update rtems_waf
-
-5. Configure with your specific settings. In this case the path to the tools
-   and the kernel are separate and provided on the command line. Your
-   envronment's path variable does not need to changed [3]. We limit the build
-   to 'sparc/erc32' BSP:
-
-    $ waf configure --rtems=$HOME/development/rtems/bsps/5 \
-                    --rtems-tools=$HOME/development/rtems/5 \
-                    --rtems-bsps=sparc/erc32
-
-   You can use '--rtems-archs=sparc,i386' or
-   '--rtems-bsps=sparc/erc32,i386/pc586' to build more than BSP at a time.
-
-6. Build:
-
-   $ waf
-
-An RTEMS Waf Project
---------------------
-
-RTEMS Waf provides a base to build RTEMS application.
-
-Waf provides a build system framework. You can use waf in your project by
-simply prooviding a list of files you wish to build and link to create an
-executable or you can use waf as framework which is integrated into your
-project to become is build system.
-
-Importing RTEMS Waf
-~~~~~~~~~~~~~~~~~~~
-
-Using RTEMS Waf as a submodule means it may not be present if the submodules
-have not been initialized and updated. This results in a Python error. The
-following import is recommended so a user friendly error is reported:
-
- from __future__ import print_function
-
- try:
-     import rtems_waf.rtems as rtems
- except:
-     print('error: no rtems_waf git submodule; see README.waf', file = stderr)
-     import sys
-     sys.exit(1)
-
-Initialization
-~~~~~~~~~~~~~~
-
-The `wscript` `init()` function is called early in waf's processing. The RTEMS
-Waf's `init()` call lets you provide:
-
-1. Filters
-
-2. RTEMS Version
-
-3. Long command line control
-
-4. Waf BSP initialization hook
-
-A example call to RTEMS Waf's `init()` is:
-
-  rtems_version = "5"
-
-  def init(ctx):
-      rtems.init(ctx, version = rtems_version, long_commands = True)
-
-Filters provide a way to control the tools, architectures and BSPs your project
-supports. RTEMS Waf scans and finds all installed RTEMS tool sets and BSPs and
-your project may only support a limited number of these. Filtering provides a
-way for your project to control what RTEMS Waf accepts and rejects when
-automatically scanning the installed tools and RTEMS kernels. A filter is a
-Python dictionary and the following example will accept `arm` and `sparc` tool
-chains and filtering out the `bfin` tool chain. The filter will only build the
-`arm` acrhitecture and will accept all BSPs except ones starting with `lpc` if
-they are installed:
-
-  my_filter = { 'tools': { 'in': ['arm', 'sparc'], 'out': ['bfin'] },
-                'arch':  { 'in': ['arm'],          'out': [] },
-		'bsps':  { 'in': [],               'out': ['lpc.*'] } }
-
-There are three (3) filters the `tools`, `archs` and `bsps` and each of these
-filter types has an `in` and `out` list. The `in` and `out` items are Python
-regular expressions.
-
-The RTEMS Version lets your project provide the default RTEMS version. This can
-be overridden by the configure option `--rtems-version`.
-
-Long commands is specific to Windows and provides support for tool command
-lines that are longer than the standard Windows command shell's limit. The
-support is based on the example available in Waf extra's.
-
-The Waf BSP initialization hook is a function called as part of the RTEMS Waf's
-`init()` call with the Waf environment and list of BSP contexts. This hook can
-be used to provide specialized BSP support.
-
-Options
-~~~~~~~
-
-The `wscript` `option()` function is called to collect command line options for
-Waf argument processing.
-
-A example call to RTEMS Waf's `options()` is:
-
-  def options(opt):
-      rtems.options(opt)
-
-Configure
-~~~~~~~~~
-
-The `wscript` `configure()` function is called when Waf is configuring a
-build. The RTEMS Waf's `configure()` lets you provide:
-
-1. Waf BSP configure hook
-
-A example call to RTEMS Waf's `configure()` is:
-
-  def configure(conf):
-      rtems.configure(conf)
-
-The BSP configure hook is called at end of a BSP's configuration. The BSP's
-`conf` variable and the `arch/bsp` are passed as arguments. The `arch/bsp` is
-the RTEMS standard for specifing a BSP, for example `sparc/erc32`. The BSP
-configure support can be used to check a BSP for header, check an RTEMS feature
-is present for a specific BSP or add per BSP build variant support:
-
-  def bsp_configure(conf, arch_bsp):
-      conf.check(header_name = "dlfcn.h", features = "c")
-      conf.check(header_name = "rtems/pci.h", features = "c", mandatory = False)
-      if not rtems.check_posix(conf):
-          conf.fatal("POSIX is disabled; configure RTEMS with --enable-posix")
-      env = conf.env.derive()
-      for builder in builders:
-          ab = conf.env.RTEMS_ARCH_BSP
-          variant = ab + "-" + builder
-          conf.msg('Configure variant: ', variant)
-          conf.setenv(variant, env)
-          build_variant_bsp_configure(conf, arch_bsp)
-          conf.setenv(ab)
-
-Build
-~~~~~
-
-The `wscript` `build()` function is called when Waf is asking what to
-build.
-
-A example call to RTEMS Waf's `build()` is:
-
-  def build(bld):
-      rtems.build(bld)
-      bld(features = 'c cprogram',
-          target = 'hello.exe',
-          source = ['hello.c'])
-
-In this example the C source file `hello.c` is compiled and linked to create
-the RTEMS executable `hello.exe`. The build is within the context of the BSP.
-
-Example
-~~~~~~~
-
-Save the following as `wscript`:
-
-  #
-  # Example Waf build script for RTEMS
-  #
-  # To configure, build and run:
-  #
-  # $ waf configure --rtems=$HOME/development/rtems/build/5 \
-  #                 --rtems-tools=$HOME/development/rtems/5 \
-  #                 --rtems-bsps=sparc/erc32
-  # $ waf
-  # $ $HOME/development/rtems/5/bin/sparc-rtems5-run \
-  #                             ./build/sparc-rtems5-erc32/hello.exe
-  #
-  # You can use '--rtems-archs=sparc,i386' or
-  # '--rtems-bsps=sparc/erc32,i386/pc586' to build for more than one BSP at a
-  # time.
-  #
-
-  from __future__ import print_function
-
-  rtems_version = "5"
-
-  try:
-      import rtems_waf.rtems as rtems
-  except:
-      print('error: no rtems_waf git submodule; see README.waf', file = stderr)
-      import sys
-      sys.exit(1)
-
-  def init(ctx):
-      rtems.init(ctx, version = rtems_version, long_commands = True)
-
-  def options(opt):
-      rtems.options(opt)
-
-  def configure(conf):
-      rtems.configure(conf)
-
-  def build(bld):
-      rtems.build(bld)
-      bld.env.CFLAGS += ['-O2','-g']
-      bld(features = 'c cprogram',
-          target = 'hello.exe',
-          source = ['hello.c'])
-
-Save the example C hello world as `hello.c`:
-
-  #include <rtems.h>
-  #include <stdlib.h>
-  #include <stdio.h>
-
-  rtems_task Init(rtems_task_argument ignored) {
-    printf("Hello World\n");
-    exit(0);
-  }
-
-  /* configuration information */
-  #include <bsp.h>
-  #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
-  #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
-  #define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
-  #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
-  #define CONFIGURE_MAXIMUM_TASKS 1
-  #define CONFIGURE_INIT
-  #include <rtems/confdefs.h>
-
---
-
-[1] A personal prefix is private to you and located where you have enough disk
-    space to complete an RTEMS installation. We often show this as your home
-    directory ($HOME) because it works on machines you may not have root access
-    to and cannot configure. We recommend you never work as root on a machine
-    you control.
-
-[2] RTEMS supports shared or separate tool and kernel prefixes. The prefix is
-    the path given to the tools and kernel when building and is the path the
-    tools or kernel are installed into when you run the install phase of a
-    build. A shared tools and kernel prefix is often used with releases because
-    the tools and kernel in a release are matched and do not change. Separate
-    tools and kernel paths can be used if you have a common tool set with
-    changing kernel versions. This tends to happen when you are testing kernel
-    patches or changes.
-
-[3] It is good practice to keep your environment as empty as possible. Using
-    the environment to set paths to tools or specific values to configure and
-    control builds is dangerous because settings can leak between different
-    builds and change what you expect or not been and seen and lost. The waf
-    tool used here lets you specify on the command line the tools and RTEMS
-    paths and this is embedded in waf's configuration information. If you have
-    a few source trees working at any one time with different tool sets or
-    configurations you can easly move between them safe in the knowledge that
-    one build will not affect another.
Index: __init__.py
===================================================================
--- __init__.py	(revision 1b896361d302aeda0145af90972aea863e28898f)
+++ __init__.py	(revision 993d33b3fca2e3ddfe53b75fe6434438edd1c48d)
@@ -4,3 +4,3 @@
 #
 
-__all__ = ['rtems', 'pkgconfig']
+__all__ = ['rtems']
Index: pkgconfig.py
===================================================================
--- pkgconfig.py	(revision 1b896361d302aeda0145af90972aea863e28898f)
+++ pkgconfig.py	(revision 993d33b3fca2e3ddfe53b75fe6434438edd1c48d)
@@ -75,5 +75,5 @@
             expanded = False
             if tm:
-                print('pc:get: "' + s + '"')
+                print 'pc:get: "' + s + '"'
             ms = mre.findall(s)
             for m in ms:
Index: otfs.py
===================================================================
--- rootfs.py	(revision 1b896361d302aeda0145af90972aea863e28898f)
+++ 	(revision )
@@ -1,54 +1,0 @@
-#
-# RTEMS Project (https://www.rtems.org/)
-#
-# Copyright (c) 2017 Chris Johns <chrisj@rtems.org>. All rights reserved.
-#
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-def tar(ctx, name, target, root):
-    top = ctx.path.get_src().find_node(root)
-    source = ctx.path.get_src().ant_glob(root + '/**')
-    ctx(rule = 'tar -C %s -cf ${TGT} .' % (top),
-        name = name,
-        target = target,
-        source = source,
-        root = root,
-        color = 'CYAN')
-
-def bin2c(ctx, name, target, source):
-    ctx(rule = '${RTEMS_BIN2C} ${SRC} ${TGT}',
-        name = name,
-        target = target,
-        source = source,
-        color = 'PINK')
-
-def build(bld, name, root):
-    """ The source is the C file that includes the header file."""
-    tar(bld,
-        name = name + '-tar',
-        target = name + '.tar',
-        root = root)
-    bin2c(bld,
-          name = name,
-          target = name + '-tar.c',
-          source = name + '.tar')
-    bld.add_group()
Index: rtems.py
===================================================================
--- rtems.py	(revision 1b896361d302aeda0145af90972aea863e28898f)
+++ rtems.py	(revision 993d33b3fca2e3ddfe53b75fe6434438edd1c48d)
@@ -1,4 +1,4 @@
-
-# Copyright 2012-2016 Chris Johns (chrisj@rtems.org)
+#
+# Copyright 2012, 2013 Chris Johns (chrisj@rtems.org)
 #
 # Redistribution and use in source and binary forms, with or without
@@ -23,6 +23,4 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-from __future__ import print_function
-
 #
 # RTEMS support for applications.
@@ -32,28 +30,28 @@
 import os
 import os.path
-from . import pkgconfig
+import pkgconfig
 import re
 import subprocess
-import sys
-
-rtems_default_version = None
+
+default_version = '4.11'
+default_label = 'rtems-' + default_version
+default_path = '/opt/' + default_label
+default_postfix = 'rtems' + default_version
+
 rtems_filters = None
-rtems_long_commands = False
-
-windows = os.name == 'nt' or sys.platform in ['msys', 'cygwin']
 
 def options(opt):
     opt.add_option('--rtems',
-                   default = None,
+                   default = default_path,
                    dest = 'rtems_path',
-                   help = 'Path to an installed RTEMS (defaults to prefix).')
+                   help = 'Path to an installed RTEMS.')
     opt.add_option('--rtems-tools',
                    default = None,
                    dest = 'rtems_tools',
-                   help = 'Path to RTEMS tools (defaults to path to installed RTEMS).')
+                   help = 'Path to RTEMS tools.')
     opt.add_option('--rtems-version',
-                   default = None,
+                   default = default_version,
                    dest = 'rtems_version',
-                   help = 'RTEMS version (default is derived from prefix).')
+                   help = 'RTEMS version (default ' + default_version + ').')
     opt.add_option('--rtems-archs',
                    default = 'all',
@@ -70,26 +68,7 @@
                    help = 'Print the commands as strings.')
 
-def init(ctx, filters = None, version = None, long_commands = False, bsp_init = None):
+def init(ctx, filters = None):
     global rtems_filters
-    global rtems_default_version
-    global rtems_long_commands
-
-    #
-    # Set the RTEMS filter to the context.
-    #
-    rtems_filters = filters
-
-    #
-    # Set the default version, can be overridden.
-    #
-    rtems_default_version = version
-
-    #
-    # Set the long commands option.
-    #
-    rtems_long_commands = long_commands
-
-    env = None
-    contexts = []
+
     try:
         import waflib.Options
@@ -103,17 +82,20 @@
 
         #
+        # Set the RTEMS filter to the context.
+        #
+        rtems_filters = filters
+
+        #
         # Check the tools, architectures and bsps.
         #
-        rtems_version, rtems_path, rtems_tools, archs, arch_bsps = \
-            check_options(ctx,
-                          env.options['prefix'],
-                          env.options['rtems_tools'],
-                          env.options['rtems_path'],
-                          env.options['rtems_version'],
-                          env.options['rtems_archs'],
-                          env.options['rtems_bsps'])
-
-        #
-        # Update the contexts for all the bsps.
+        rtems_path, rtems_tools, archs, arch_bsps = check_options(ctx,
+                                                                  env.options['rtems_tools'],
+                                                                  env.options['rtems_path'],
+                                                                  env.options['rtems_version'],
+                                                                  env.options['rtems_archs'],
+                                                                  env.options['rtems_bsps'])
+
+        #
+        # Update the contextes for all the bsps.
         #
         from waflib.Build import BuildContext, CleanContext, \
@@ -125,46 +107,19 @@
                     cmd = name + '-' + x
                     variant = x
-                contexts += [context]
-
-        #
-        # Transform the command to per BSP commands.
-        #
-        commands = []
-        for cmd in waflib.Options.commands:
-            if cmd in ['build', 'clean', 'install']:
+
+        #
+        # Add the various commands.
+        #
+        for cmd in ['build', 'clean', 'install']:
+            if cmd in waflib.Options.commands:
+                waflib.Options.commands.remove(cmd)
                 for x in arch_bsps:
-                    commands += [cmd + '-' + x]
-            else:
-                commands += [cmd]
-        waflib.Options.commands = commands
+                    waflib.Options.commands.insert(0, cmd + '-' + x)
     except:
         pass
 
-    if bsp_init:
-        bsp_init(ctx, env, contexts)
-
-def test_application(more = []):
-    code =  ['#include <rtems.h>']
-    code += more
-    code += ['void Init(rtems_task_argument arg) { (void)arg; }']
-    code += ['#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER']
-    code += ['#define CONFIGURE_MAXIMUM_TASKS 1']
-    code += ['#define CONFIGURE_RTEMS_INIT_TASKS_TABLE']
-    code += ['#define CONFIGURE_INIT']
-    code += ['#include <rtems/confdefs.h>']
-    return os.linesep.join(code)
-
-def configure(conf, bsp_configure = None):
-    #
-    # Check the environment for any flags.
-    #
-    for f in ['CC', 'CXX', 'AS', 'LD', 'AR', 'LINK_CC', 'LINK_CXX',
-              'CPPFLAGS', 'CFLAGS', 'CXXFLAGS', 'ASFLAGS', 'LINKFLAGS', 'LIB'
-              'WFLAGS', 'RFLAGS', 'MFLAGS', 'IFLAGS']:
-        if f in os.environ:
-            conf.msg('Environment variable set', f, color = 'RED')
-
-    #
-    # Handle the configurable commands options.
+def configure(conf):
+    #
+    # Handle the show commands option.
     #
     if conf.options.show_commands:
@@ -172,17 +127,11 @@
     else:
         show_commands = 'no'
-    if rtems_long_commands and windows:
-        long_commands = 'yes'
-    else:
-        long_commands = 'no'
-
-    rtems_version, rtems_path, rtems_tools, archs, arch_bsps = \
-        check_options(conf,
-                      conf.options.prefix,
-                      conf.options.rtems_tools,
-                      conf.options.rtems_path,
-                      conf.options.rtems_version,
-                      conf.options.rtems_archs,
-                      conf.options.rtems_bsps)
+
+    rtems_path, rtems_tools, archs, arch_bsps = check_options(conf,
+                                                              conf.options.rtems_tools,
+                                                              conf.options.rtems_path,
+                                                              conf.options.rtems_version,
+                                                              conf.options.rtems_archs,
+                                                              conf.options.rtems_bsps)
 
     if rtems_tools is None:
@@ -191,5 +140,4 @@
     _log_header(conf)
 
-    conf.msg('RTEMS Version', rtems_version, 'YELLOW')
     conf.msg('Architectures', ', '.join(archs), 'YELLOW')
 
@@ -200,28 +148,16 @@
         conf.setenv(ab, env)
 
-        conf.msg('Board Support Package (BSP)', ab, 'YELLOW')
-
-        #
-        # Show and long commands support.
-        #
-        conf.env.SHOW_COMMANDS = show_commands
-        conf.env.LONG_COMMANDS = long_commands
-
-        conf.msg('Show commands', show_commands)
-        conf.msg('Long commands', long_commands)
+        conf.msg('Board Support Package', ab, 'YELLOW')
 
         arch = _arch_from_arch_bsp(ab)
-        bsp  = _bsp_from_arch_bsp(ab)
-
-        conf.env.ARCH_BSP = '%s/%s' % (arch.split('-')[0], bsp)
-
-        conf.env.RTEMS_PATH = rtems_path
-        conf.env.RTEMS_VERSION = rtems_version
+
+        conf.env.RTEMS_PATH = conf.options.rtems_path
+        conf.env.RTEMS_VERSION = conf.options.rtems_version
         conf.env.RTEMS_ARCH_BSP = ab
         conf.env.RTEMS_ARCH = arch.split('-')[0]
         conf.env.RTEMS_ARCH_RTEMS = arch
-        conf.env.RTEMS_BSP = bsp
-
-        tools = _find_tools(conf, arch, rtems_tools, tools)
+        conf.env.RTEMS_BSP = _bsp_from_arch_bsp(ab)
+
+        tools = _find_tools(conf, arch, [rtems_path] + rtems_tools, tools)
         for t in tools[arch]:
             conf.env[t] = tools[arch][t]
@@ -231,30 +167,13 @@
         conf.load('gas')
 
-        #
-        # Get the version of the tools being used.
-        #
-        rtems_cc = conf.env.CC[0]
-        try:
-            import waflib.Context
-            out = conf.cmd_and_log([rtems_cc, '--version'],
-                                   output = waflib.Context.STDOUT)
-        except Exception as e:
-            conf.fatal('CC version not found: %s' % (e.stderr))
-        #
-        # First line is the version
-        #
-        vline = out.split('\n')[0]
-        conf.msg('Compiler version (%s)' % (os.path.basename(rtems_cc)),
-                                            ' '.join(vline.split()[2:]))
-
-        flags = _load_flags(conf, ab, rtems_path)
+        flags = _load_flags(conf, ab, conf.options.rtems_path)
 
         cflags = _filter_flags('cflags', flags['CFLAGS'],
-                               arch, rtems_path)
+                               arch, conf.options.rtems_path)
         ldflags = _filter_flags('ldflags', flags['LDFLAGS'],
-                               arch, rtems_path)
+                               arch, conf.options.rtems_path)
 
         conf.env.CFLAGS    = cflags['cflags']
-        conf.env.CXXFLAGS  = cflags['cflags']
+        conf.env.CXXFLAGS  = conf.env.CFLAGS
         conf.env.ASFLAGS   = cflags['cflags']
         conf.env.WFLAGS    = cflags['warnings']
@@ -264,15 +183,13 @@
         conf.env.LINKFLAGS = cflags['cflags'] + ldflags['ldflags']
         conf.env.LIB       = flags['LIB']
-        conf.env.LIBPATH   = ldflags['libpath']
-
-        conf.env.RTRACE_WRAPPER_ST = '-W %s'
 
         #
         # Checks for various RTEMS features.
         #
-        conf.check_cc(fragment = test_application(),
-                      execute = False,
-                      msg = 'Checking for a valid RTEMS BSP installation')
-        load_cpuopts(conf)
+        conf.multicheck({ 'header_name': 'rtems.h'},
+                        { 'header_name': 'rtems/score/cpuopts.h'},
+                        msg = 'Checking for RTEMS headers',
+                        mandatory = True)
+        load_cpuopts(conf, ab, conf.options.rtems_path)
 
         #
@@ -282,9 +199,7 @@
 
         #
-        # If the user has supplied a BSP specific configure function
-        # call it.
-        #
-        if bsp_configure:
-            bsp_configure(conf, ab)
+        # Show commands support the user can supply.
+        #
+        conf.env.SHOW_COMMANDS = show_commands
 
         conf.setenv('', env)
@@ -295,13 +210,10 @@
 
     conf.env.SHOW_COMMANDS = show_commands
-    conf.env.LONG_COMMANDS = long_commands
 
 def build(bld):
     if bld.env.SHOW_COMMANDS == 'yes':
         output_command_line()
-    if bld.env.LONG_COMMANDS == 'yes':
-        long_command_line()
-
-def load_cpuopts(conf):
+
+def load_cpuopts(conf, arch_bsp, rtems_path):
     options = ['RTEMS_DEBUG',
                'RTEMS_MULTIPROCESSING',
@@ -309,7 +221,8 @@
                'RTEMS_POSIX_API',
                'RTEMS_SMP',
-               'RTEMS_NETWORKING']
+               'RTEMS_NETWORKING',
+               'RTEMS_ATOMIC']
     for opt in options:
-        enabled = check_cpuopt(conf, opt)
+        enabled = check_opt(conf, opt, 'rtems/score/cpuopts.h', arch_bsp, rtems_path)
         if enabled:
             conf.env[opt] = 'Yes'
@@ -317,16 +230,19 @@
             conf.env[opt] = 'No'
 
-def check_cpuopt(conf, opt):
-    code =  ['#ifndef %s' % (opt)]
-    code += ['  #error %s is not defined' % (opt)]
-    code += ['#endif']
-    code += ['#if %s' % (opt)]
-    code += ['  /* %s is true */' % (opt)]
-    code += ['#else']
-    code += ['  #error %s is false' % (opt)]
-    code += ['#endif']
+def check_opt(conf, opt, header, arch_bsp, rtems_path):
+    code  = '#include <%s>%s' % (header, os.linesep)
+    code += '#ifndef %s%s' % (opt, os.linesep)
+    code += ' #error %s is not defined%s' % (opt, os.linesep)
+    code += '#endif%s' % (os.linesep)
+    code += '#if %s%s' % (opt, os.linesep)
+    code += ' /* %s is true */%s' % (opt, os.linesep)
+    code += '#else%s' % (os.linesep)
+    code += ' #error %s is false%s' % (opt, os.linesep)
+    code += '#endif%s' % (os.linesep)
+    code += 'int main() { return 0; }%s' % (os.linesep)
     try:
-        conf.check_cc(fragment = test_application(code),
+        conf.check_cc(fragment = code,
                       execute = False,
+                      define_ret = False,
                       msg = 'Checking for %s' % (opt))
     except conf.errors.WafError:
@@ -354,22 +270,5 @@
       conf.env.LINKFLAGS += ['-Wl,--gc-sections']
 
-def check_options(ctx, prefix, rtems_tools, rtems_path, rtems_version, rtems_archs, rtems_bsps):
-    #
-    # Set defaults
-    #
-    if rtems_version is None:
-        if rtems_default_version is None:
-            m = re.compile('[^0-9.]*([0-9.]+)$').match(prefix)
-            if m:
-                rtems_version = m.group(1)
-            else:
-                ctx.fatal('RTEMS version cannot derived from prefix: ' + prefix)
-        else:
-            rtems_version = rtems_default_version
-    if rtems_path is None:
-        rtems_path = prefix
-    if rtems_tools is None:
-        rtems_tools = rtems_path
-
+def check_options(ctx, rtems_tools, rtems_path, rtems_version, rtems_archs, rtems_bsps):
     #
     # Check the paths are valid.
@@ -383,7 +282,8 @@
     else:
         ctx.fatal('RTEMS path is not valid. No lib/pkgconfig or rtems-config found.')
-    rtems_share_rtems_version = os.path.join(rtems_path, 'share', 'rtems' + rtems_version)
-    if not os.path.exists(os.path.join(rtems_share_rtems_version)):
-        ctx.fatal('RTEMS path is not valid, "%s" not found.' % (rtems_share_rtems_version))
+    if os.path.exists(os.path.join(rtems_path, 'bin')):
+        rtems_bin = os.path.join(rtems_path, 'bin')
+    else:
+        ctx.fatal('RTEMS path is not valid. No bin directory found.')
 
     #
@@ -391,12 +291,15 @@
     # versions.
     #
-    rt = rtems_tools.split(',')
-    tools = []
-    for path in rt:
-        if not os.path.exists(path):
-            ctx.fatal('RTEMS tools path not found: ' + path)
-        if not os.path.exists(os.path.join(path, 'bin')):
-            ctx.fatal('RTEMS tools path does not contain a \'bin\' directory: ' + path)
-        tools += [os.path.join(path, 'bin')]
+    if rtems_tools is not None:
+        rt = rtems_tools.split(',')
+        tools = []
+        for path in rt:
+            if not os.path.exists(path):
+                ctx.fatal('RTEMS tools path not found: ' + path)
+            if not os.path.exists(os.path.join(path, 'bin')):
+                ctx.fatal('RTEMS tools path does not contain a \'bin\' directory: ' + path)
+            tools += [os.path.join(path, 'bin')]
+    else:
+        tools = None
 
     #
@@ -442,10 +345,5 @@
     arch_bsps = filter(ctx, 'bsps', arch_bsps)
 
-    return rtems_version, rtems_path, tools, archs, arch_bsps
-
-def check_env(ctx, var):
-    if var in ctx.env and len(ctx.env[var]) != 0:
-        return True
-    return False
+    return rtems_bin, tools, archs, arch_bsps
 
 def check(ctx, option):
@@ -471,4 +369,7 @@
 def check_networking(ctx):
     return check(ctx, 'RTEMS_NETWORKING')
+
+def check_atomic(ctx):
+    return check(ctx, 'RTEMS_ATOMIC')
 
 def arch(arch_bsp):
@@ -522,19 +423,19 @@
     return sorted(filtered_items)
 
-def arch_rtems_version(version, arch):
+def arch_rtems_version(arch):
     """ Return the RTEMS architecture path, ie sparc-rtems4.11."""
-    return '%s-rtems%s' % (arch, version)
-
-def arch_bsp_path(version, arch_bsp):
+    return '%s-%s' % (arch, default_postfix)
+
+def arch_bsp_path(arch_bsp):
     """ Return the BSP path."""
-    return '%s/%s' % (arch_rtems_version(version, arch(arch_bsp)), bsp(arch_bsp))
-
-def arch_bsp_include_path(version, arch_bsp):
+    return '%s/%s' % (arch_rtems_version(arch(arch_bsp)), bsp(arch_bsp))
+
+def arch_bsp_include_path(arch_bsp):
     """ Return the BSP include path."""
-    return '%s/lib/include' % (arch_bsp_path(version, arch_bsp))
-
-def arch_bsp_lib_path(version, arch_bsp):
+    return '%s/lib/include' % (arch_bsp_path(arch_bsp))
+
+def arch_bsp_lib_path(arch_bsp):
     """ Return the BSP library path. """
-    return '%s/lib' % (arch_bsp_path(version, arch_bsp))
+    return '%s/lib' % (arch_bsp_path(arch_bsp))
 
 def library_path(library, cc, cflags):
@@ -545,17 +446,4 @@
         return os.path.dirname(lib)
     return None
-
-def root_filesystem(bld, name, files, tar, obj):
-    tar_rule = 'tar -cf ${TGT} --format=ustar -C ../.. $(echo "${SRC}" | sed -e \'s/\.\.\/\.\.\///g\')'
-    if windows:
-        tar_rule = 'sh -c "%s"' % (tar_rule)
-    bld(name = name + '_tar',
-        target = tar,
-        source = files,
-        rule = tar_rule)
-    bld.objects(name = name,
-                target = obj,
-                source = tar,
-                rule = '${OBJCOPY} -I binary -B ${RTEMS_ARCH} ${OBJCOPY_FLAGS} ${SRC} ${TGT}')
 
 def clone_tasks(bld):
@@ -582,8 +470,5 @@
             Logs.info('%s' % cmd)
         else:
-            cmdstr = ' '.join(cmd)
-            Logs.info('(%d) %s' % (len(cmdstr), cmdstr)) # here is the change
-        if not isinstance(kw['cwd'], str):
-            kw['cwd'] = str(kw['cwd'])
+            Logs.info('%s' % ' '.join(cmd)) # here is the change
         Logs.debug('runner_env: kw=%s' % kw)
         try:
@@ -612,38 +497,4 @@
     Task.__str__ = display
 
-#
-# From the extras. Use this to support long command lines.
-#
-def long_command_line():
-    def exec_command(self, cmd, **kw):
-        # workaround for command line length limit:
-        # http://support.microsoft.com/kb/830473
-        import tempfile
-        tmp = None
-        try:
-            if not isinstance(cmd, str) and len(str(cmd)) > 8192:
-                (fd, tmp) = tempfile.mkstemp(dir=self.generator.bld.bldnode.abspath())
-                flat = ['"%s"' % x.replace('\\', '\\\\').replace('"', '\\"') for x in cmd[1:]]
-                try:
-                    os.write(fd, ' '.join(flat).encode())
-                finally:
-                    if tmp:
-                        os.close(fd)
-                # Line may be very long:
-                # Logs.debug('runner:' + ' '.join(flat))
-                cmd = [cmd[0], '@' + tmp]
-            ret = super(self.__class__, self).exec_command(cmd, **kw)
-        finally:
-            if tmp:
-                os.remove(tmp)
-        return ret
-    for k in 'c cxx cprogram cxxprogram cshlib cxxshlib cstlib cxxstlib'.split():
-        cls = Task.classes.get(k)
-        if cls:
-            derived_class = type(k, (cls,), {})
-            derived_class.exec_command = exec_command
-            if hasattr(cls, 'hcode'):
-                derived_class.hcode = cls.hcode
-
 def _find_tools(conf, arch, paths, tools):
     if arch not in tools:
@@ -651,9 +502,11 @@
         arch_tools['CC']          = conf.find_program([arch + '-gcc'], path_list = paths)
         arch_tools['CXX']         = conf.find_program([arch + '-g++'], path_list = paths)
+        arch_tools['AS']          = conf.find_program([arch + '-gcc'], path_list = paths)
+        arch_tools['LD']          = conf.find_program([arch + '-ld'],  path_list = paths)
+        arch_tools['AR']          = conf.find_program([arch + '-ar'],  path_list = paths)
         arch_tools['LINK_CC']     = arch_tools['CC']
         arch_tools['LINK_CXX']    = arch_tools['CXX']
-        arch_tools['AS']          = conf.find_program([arch + '-gcc'], path_list = paths)
-        arch_tools['LD']          = conf.find_program([arch + '-ld'],  path_list = paths)
         arch_tools['AR']          = conf.find_program([arch + '-ar'], path_list = paths)
+        arch_tools['LD']          = conf.find_program([arch + '-ld'], path_list = paths)
         arch_tools['NM']          = conf.find_program([arch + '-nm'], path_list = paths)
         arch_tools['OBJDUMP']     = conf.find_program([arch + '-objdump'], path_list = paths)
@@ -663,6 +516,4 @@
         arch_tools['RTEMS_LD']    = conf.find_program(['rtems-ld'], path_list = paths,
                                                       mandatory = False)
-        arch_tools['RTEMS_TLD']   = conf.find_program(['rtems-tld'], path_list = paths,
-                                                      mandatory = False)
         arch_tools['RTEMS_BIN2C'] = conf.find_program(['rtems-bin2c'], path_list = paths,
                                                       mandatory = False)
@@ -681,5 +532,5 @@
         a = a[:-1].replace('"', '')
         archs = set(a.split())
-        archs = ['%s-rtems%s' % (x, version) for x in archs]
+        archs = ['%s-rtems4.11' % (x) for x in archs]
     archs.sort()
     return archs
@@ -796,6 +647,5 @@
         [ { 'key': 'warnings', 'path': False, 'flags': { '-W': 1 }, 'cflags': False, 'lflags': False },
           { 'key': 'includes', 'path': True,  'flags': { '-I': 1, '-isystem': 2, '-sysroot': 2 } },
-          { 'key': 'libpath',  'path': True,  'flags': { '-L': 1 } },
-          { 'key': 'machines', 'path': True,  'flags': { '-O': 1, '-m': 1, '-f': 1, '-G':1, '-E':1 } },
+          { 'key': 'machines', 'path': True,  'flags': { '-O': 1, '-m': 1, '-f': 1 } },
           { 'key': 'specs',    'path': True,  'flags': { '-q': 1, '-B': 2, '--specs': 2 } } ]
 
@@ -855,8 +705,6 @@
 from waflib import Node
 from waflib.Tools.ccroot import link_task, USELIB_VARS
-
 USELIB_VARS['rap'] = set(['RTEMS_LINKFLAGS'])
-USELIB_VARS['rtrace'] = set(['RTRACE_FLAGS', 'RTRACE_CFG', 'RTRACE_WRAPPER', 'RTRACE_LINKCMDS'])
-
+@TaskGen.extension('.c')
 class rap(link_task):
     "Link object files into a RTEMS application"
@@ -865,10 +713,2 @@
     vars    = ['RTEMS_LINKFLAGS', 'LINKDEPS']
     inst_to = '${BINDIR}'
-
-class rtrace(link_task):
-    "Link object files into a RTEMS trace application"
-    run_str = '${RTEMS_TLD} ${RTACE_FLAGS} ${RTRACE_WRAPPER_ST:RTRACE_WRAPPER} -C ${RTRACE_CFG} -r ${RTEMS_PATH} -B ${ARCH_BSP} -c ${CC} -l ${CC} -- ${SRC} ${LINKFLAGS} ${RTRACE_LINKFLAGS} -o ${TGT[0].abspath()} ${STLIB_MARKER} ${STLIBPATH_ST:STLIBPATH} ${STLIB_ST:STLIB} ${LIBPATH_ST:LIBPATH} ${LIB_ST:LIB}'
-    ext_out = ['.texe']
-    vars    = ['RTRACE_FLAGS', 'RTRACE_CFG', 'RTRACE_WRAPER', 'RTRACE_LINKFLAGS', 'LINKDEPS']
-    inst_to = '${BINDIR}'
-    color = 'PINK'
Index: ems_bsd.py
===================================================================
--- rtems_bsd.py	(revision 1b896361d302aeda0145af90972aea863e28898f)
+++ 	(revision )
@@ -1,77 +1,0 @@
-#
-# RTEMS Project (https://www.rtems.org/)
-#
-# Copyright (c) 2016 Chris Johns <chrisj@rtems.org>. All rights reserved.
-#
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-from __future__ import print_function
-
-import os.path
-
-try:
-    import rtems_waf.rtems as rtems
-except:
-    print("error: no rtems_waf module")
-    import sys
-    sys.exit(1)
-
-def init(ctx):
-    pass
-
-def options(opt):
-    opt.add_option('--net-test-config',
-                   default = 'config.inc',
-                   dest = 'net_config',
-                   help = 'Network test configuration.')
-    opt.add_option('--rtems-libbsd',
-                   action = 'store',
-                   default = None,
-                   dest = 'rtems_libbsd',
-                   help = 'Path to install RTEMS LibBSD (defauls to prefix).')
-
-def bsp_configure(conf, arch_bsp):
-    conf.check(header_name = 'dlfcn.h', features = 'c')
-    if not rtems.check_posix(conf):
-        conf.fatal("RTEMS kernel POSIX support is disabled; configure RTEMS with --enable-posix")
-    if rtems.check_networking(conf):
-        conf.fatal("RTEMS kernel contains the old network support; configure RTEMS with --disable-networking")
-    if conf.options.rtems_libbsd is None:
-        rtems_libbsd_path = conf.env.PREFIX
-    else:
-        if not os.path.exists(conf.options.rtems_libbsd):
-            conf.fatal('RTEMS LibBSD not found')
-        rtems_libbsd_path = conf.options.rtems_libbsd
-
-    rtems_libbsd_inc_path = os.path.join(rtems_libbsd_path,
-                                         rtems.arch_bsp_include_path(conf.env.RTEMS_VERSION,
-                                                                     conf.env.RTEMS_ARCH_BSP))
-    rtems_libbsd_lib_path = os.path.join(rtems_libbsd_path,
-                                         rtems.arch_bsp_lib_path(conf.env.RTEMS_VERSION,
-                                                                 conf.env.RTEMS_ARCH_BSP))
-
-    conf.env.IFLAGS += [rtems_libbsd_inc_path]
-    conf.check(header_name = 'machine/rtems-bsd-sysinit.h', features = 'c', includes = conf.env.IFLAGS)
-
-    conf.env.INCLUDES = conf.env.IFLAGS
-    conf.env.LIBPATH += [rtems_libbsd_lib_path]
-    conf.env.LIB += ['bsd', 'z', 'm']
