Browse Source

Fix up build.ck files.

I haven't tested all the platforms yet, but x86 and ARM on Qemu work so
far. This is run using the new mingen2 and new Chalk interpreter.
Evan Green 7 years ago
parent
commit
653147af49
100 changed files with 2338 additions and 1137 deletions
  1. 33 24
      apps/build.ck
  2. 84 0
      apps/ck/app/build.ck
  3. 45 0
      apps/ck/build.ck
  4. 208 0
      apps/ck/lib/build.ck
  5. 59 0
      apps/ck/modules/app/build.ck
  6. 118 0
      apps/ck/modules/build.ck
  7. 61 0
      apps/ck/modules/bundle/build.ck
  8. 121 0
      apps/ck/modules/os/build.ck
  9. 20 15
      apps/debug/build.ck
  10. 85 59
      apps/debug/client/build.ck
  11. 24 19
      apps/debug/client/tdwarf/build.ck
  12. 20 15
      apps/debug/client/testdisa/build.ck
  13. 19 14
      apps/debug/client/teststab/build.ck
  14. 11 5
      apps/debug/dbgext/build.ck
  15. 19 11
      apps/debug/kexts/build.ck
  16. 18 8
      apps/efiboot/build.ck
  17. 11 6
      apps/lib/chalk/build.ck
  18. 9 4
      apps/libc/crypt/build.ck
  19. 48 30
      apps/libc/dynamic/build.ck
  20. 9 3
      apps/libc/dynamic/pthread/static/build.ck
  21. 15 9
      apps/libc/dynamic/testc/build.ck
  22. 15 7
      apps/libc/static/build.ck
  23. 27 13
      apps/mingen/build.ck
  24. 17 3
      apps/mingen2/mingen.ck
  25. 19 6
      apps/mingen2/ninja.ck
  26. 10 3
      apps/mount/build.ck
  27. 11 4
      apps/netcon/build.ck
  28. 12 6
      apps/netlink/build.ck
  29. 30 20
      apps/osbase/build.ck
  30. 7 2
      apps/osbase/urtl/build.ck
  31. 76 28
      apps/posix/build.ck
  32. 10 3
      apps/profile/build.ck
  33. 82 55
      apps/setup/build.ck
  34. 66 46
      apps/swiss/build.ck
  35. 1 0
      apps/swiss/sh/parser.c
  36. 11 6
      apps/testapps/build.ck
  37. 10 3
      apps/testapps/dbgtest/build.ck
  38. 10 3
      apps/testapps/filetest/build.ck
  39. 19 9
      apps/testapps/ktest/build.ck
  40. 10 3
      apps/testapps/mmaptest/build.ck
  41. 10 3
      apps/testapps/mnttest/build.ck
  42. 10 3
      apps/testapps/pathtest/build.ck
  43. 16 7
      apps/testapps/perftest/build.ck
  44. 10 3
      apps/testapps/sigtest/build.ck
  45. 10 3
      apps/testapps/socktest/build.ck
  46. 10 3
      apps/testapps/utmrtest/build.ck
  47. 36 25
      apps/tzcomp/build.ck
  48. 10 3
      apps/unmount/build.ck
  49. 10 3
      apps/vmstat/build.ck
  50. 82 57
      boot/bootman/build.ck
  51. 15 10
      boot/build.ck
  52. 22 13
      boot/fatboot/build.ck
  53. 45 30
      boot/lib/build.ck
  54. 73 50
      boot/loader/build.ck
  55. 16 8
      boot/mbr/build.ck
  56. 2 294
      build.ck
  57. 7 1
      drivers/acpi/build.ck
  58. 49 0
      drivers/ahci/build.ck
  59. 7 2
      drivers/ata/build.ck
  60. 28 22
      drivers/build.ck
  61. 7 2
      drivers/devrem/build.ck
  62. 9 3
      drivers/dma/bcm2709/build.ck
  63. 12 6
      drivers/dma/build.ck
  64. 7 2
      drivers/dma/core/build.ck
  65. 9 3
      drivers/dma/edma3/build.ck
  66. 9 3
      drivers/fat/build.ck
  67. 9 3
      drivers/gpio/broadcom/bc27/build.ck
  68. 15 9
      drivers/gpio/build.ck
  69. 7 2
      drivers/gpio/core/build.ck
  70. 9 3
      drivers/gpio/rockchip/rk32/build.ck
  71. 9 3
      drivers/gpio/ti/omap4/build.ck
  72. 9 3
      drivers/i8042/build.ck
  73. 10 4
      drivers/i8042/pl050/build.ck
  74. 24 17
      drivers/net/build.ck
  75. 9 3
      drivers/net/ethernet/am3eth/build.ck
  76. 9 3
      drivers/net/ethernet/atl1c/build.ck
  77. 9 3
      drivers/net/ethernet/dwceth/build.ck
  78. 9 3
      drivers/net/ethernet/e100/build.ck
  79. 8 3
      drivers/net/ethernet/e1000/build.ck
  80. 9 3
      drivers/net/ethernet/pcnet32/build.ck
  81. 9 3
      drivers/net/ethernet/rtl81xx/build.ck
  82. 9 3
      drivers/net/ethernet/smsc91c1/build.ck
  83. 10 4
      drivers/net/ethernet/smsc95xx/build.ck
  84. 9 3
      drivers/net/net80211/build.ck
  85. 7 2
      drivers/net/netcore/build.ck
  86. 19 12
      drivers/net/wireless/rtlw81xx/build.ck
  87. 7 2
      drivers/null/build.ck
  88. 9 3
      drivers/part/build.ck
  89. 7 2
      drivers/pci/build.ck
  90. 14 9
      drivers/plat/build.ck
  91. 9 3
      drivers/plat/goec/build.ck
  92. 7 2
      drivers/plat/quark/qrkhostb/build.ck
  93. 7 2
      drivers/plat/rockchip/rk808/build.ck
  94. 16 3
      drivers/plat/ti/am3soc/build.ck
  95. 7 2
      drivers/plat/ti/tps65217/build.ck
  96. 7 2
      drivers/ramdisk/build.ck
  97. 9 3
      drivers/sd/bcm2709/build.ck
  98. 14 9
      drivers/sd/build.ck
  99. 7 2
      drivers/sd/core/build.ck
  100. 9 3
      drivers/sd/omap4/build.ck

+ 33 - 24
apps/build.ck

@@ -25,41 +25,50 @@ Environment:
 
 --*/
 
+from menv import group;
+
 function build() {
-    test_apps = [
-        "//apps/libc/dynamic/testc:build_testc",
-        "//apps/testapps:testapps",
+    var allApps;
+    var apps;
+    var entries;
+    var libc;
+    var mingenBuild;
+    var testApps;
+
+    testApps = [
+        "apps/libc/dynamic/testc:build_testc",
+        "apps/testapps:testapps",
     ];
 
     libc = [
-        "//apps/libc/crypt:libcrypt",
-        "//apps/libc/dynamic/pthread/static:libpthread_nonshared",
-        "//apps/libc/static:libc_nonshared",
+        "apps/libc/crypt:libcrypt",
+        "apps/libc/dynamic/pthread/static:libpthread_nonshared",
+        "apps/libc/static:libc_nonshared",
     ];
 
-    mingen_build = [
-        "//apps/mingen:build_mingen"
+    mingenBuild = [
+        "apps/mingen:build_mingen"
     ];
 
     apps = [
-        "//apps/debug:debug",
-        "//apps/efiboot:efiboot",
-        "//apps/mingen:mingen",
-        "//apps/mount:mount",
-        "//apps/netcon:netcon",
-        "//apps/profile:profile",
-        "//apps/setup:msetup",
-        "//apps/setup:build_msetup",
-        "//apps/swiss:swiss",
-        "//apps/swiss:build_swiss",
-        "//apps/tzcomp:tz_files",
-        "//apps/unmount:umount",
-        "//apps/vmstat:vmstat",
+        "apps/ck:chalk",
+        "apps/debug:debug",
+        "apps/efiboot:efiboot",
+        "apps/mingen:mingen",
+        "apps/mount:mount",
+        "apps/netcon:netcon",
+        "apps/profile:profile",
+        "apps/setup:msetup",
+        "apps/setup:build_msetup",
+        "apps/swiss:swiss",
+        "apps/swiss:build_swiss",
+        "apps/tzcomp:tz_files",
+        "apps/unmount:umount",
+        "apps/vmstat:vmstat",
     ];
 
-    all_apps = test_apps + libc + mingen_build + apps;
-    entries = group("all_apps", all_apps);
+    allApps = testApps + libc + mingenBuild + apps;
+    entries = group("all_apps", allApps);
     return entries;
 }
 
-return build();

+ 84 - 0
apps/ck/app/build.ck

@@ -0,0 +1,84 @@
+/*++
+
+Copyright (c) 2017 Minoca Corp.
+
+    This file is licensed under the terms of the GNU General Public License
+    version 3. Alternative licensing terms are available. Contact
+    info@minocacorp.com for details. See the LICENSE file at the root of this
+    project for complete licensing information.
+
+Module Name:
+
+    Chalk
+
+Abstract:
+
+    This executable implements the Chalk interactive interpreter.
+
+Author:
+
+    Evan Green 14-Feb-2017
+
+Environment:
+
+    C
+
+--*/
+
+from menv import application, mconfig;
+
+function build() {
+    var app;
+    var buildLibs;
+    var buildOs = mconfig.build_os;
+    var buildSources;
+    var commonSources;
+    var entries;
+    var libs;
+    var sources;
+
+    commonSources = [
+        "chalk.c",
+    ];
+
+    sources = commonSources + [
+        "ckunix.c"
+    ];
+
+    buildSources = sources;
+    if (buildOs == "Windows") {
+        buildSources = commonSources + [
+            "ckwin32.c"
+        ];
+    }
+
+    libs = [
+        "apps/ck/lib:libchalk_dynamic",
+        "apps/ck/modules/app:app",
+        "apps/ck/modules/bundle:bundle"
+    ];
+
+    buildLibs = [
+        "apps/ck/lib:build_libchalk_dynamic",
+        "apps/ck/modules/app:build_app",
+        "apps/ck/modules/bundle:build_bundle"
+    ];
+
+    app = {
+        "label": "chalk",
+        "inputs": sources + libs
+    };
+
+    entries = application(app);
+    app = {
+        "label": "build_chalk",
+        "output": "chalk",
+        "inputs": buildSources + buildLibs,
+        "build": true,
+        "prefix": "build"
+    };
+
+    entries += application(app);
+    return entries;
+}
+

+ 45 - 0
apps/ck/build.ck

@@ -0,0 +1,45 @@
+/*++
+
+Copyright (c) 2017 Minoca Corp.
+
+    This file is licensed under the terms of the GNU General Public License
+    version 3. Alternative licensing terms are available. Contact
+    info@minocacorp.com for details. See the LICENSE file at the root of this
+    project for complete licensing information.
+
+Module Name:
+
+    Chalk
+
+Abstract:
+
+    This directory contains Chalk language.
+
+Author:
+
+    Evan Green 14-Feb-2017
+
+Environment:
+
+    Any
+
+--*/
+
+from menv import group;
+
+function build() {
+    var chalk;
+    var entries;
+
+    chalk = [
+        "apps/ck/lib:libchalk_dynamic",
+        "apps/ck/lib:build_libchalk_dynamic",
+        "apps/ck/app:chalk",
+        "apps/ck/app:build_chalk",
+        "apps/ck/modules:modules",
+    ];
+
+    entries = group("chalk", chalk);
+    return entries;
+}
+

+ 208 - 0
apps/ck/lib/build.ck

@@ -0,0 +1,208 @@
+/*++
+
+Copyright (c) 2017 Minoca Corp.
+
+    This file is licensed under the terms of the GNU General Public License
+    version 3. Alternative licensing terms are available. Contact
+    info@minocacorp.com for details. See the LICENSE file at the root of this
+    project for complete licensing information.
+
+Module Name:
+
+    Chalk Library
+
+Abstract:
+
+    This module contains the Chalk language interpreter library. It is built
+    for both the build machine as well as Minoca, and comes in both static and
+    dynamic flavors.
+
+Author:
+
+    Evan Green 14-Feb-2017
+
+Environment:
+
+    C
+
+--*/
+
+from menv import addConfig, application, compiledSources, mconfig,
+    sharedLibrary, staticLibrary;
+
+function build() {
+    var buildLibs;
+    var buildObjs;
+    var buildSources;
+    var buildOs = mconfig.build_os;
+    var entries;
+    var gen;
+    var genSources;
+    var genTool;
+    var grammar;
+    var includes;
+    var libConfig;
+    var lib;
+    var libs;
+    var majorVersion = "1";
+    var objs;
+    var posixSources;
+    var sources;
+
+    sources = [
+        "capi.c",
+        "capilib.c",
+        "cdump.c",
+        "ckcore.S",
+        "compexpr.c",
+        "compiler.c",
+        "compio.c",
+        "compvar.c",
+        "core.c",
+        "debug.c",
+        "dict.c",
+        "except.c",
+        "fiber.c",
+        "gc.c",
+        ":gram.c",
+        "int.c",
+        "lex.c",
+        "list.c",
+        "module.c",
+        "string.c",
+        "utils.c",
+        "value.c",
+        "vm.c",
+        "vmsys.c"
+    ];
+
+    posixSources = [
+        "dlopen.c"
+    ];
+
+    if (buildOs == "Windows") {
+        buildSources = sources + ["dynwin32.c"];
+
+    } else {
+        buildSources = sources + posixSources;
+    }
+
+    sources += posixSources;
+    libs = [
+        "lib/yy:yy",
+        "lib/rtl/base:basertl",
+        "lib/rtl/rtlc:rtlc"
+    ];
+
+    buildLibs = [
+        "lib/yy:build_yy",
+        "lib/rtl/base:build_basertl",
+        "lib/rtl/rtlc:build_rtlc"
+    ];
+
+    //
+    // Create the gramgen tool, which is used to build gram.c.
+    //
+
+    genSources = [
+        "gram/gramgen.c",
+        "lib/rtl/base:build_basertl",
+        "lib/rtl/rtlc:build_rtlc",
+        "lib/yy/gen:build_yygen"
+    ];
+
+    gen = {
+        "label": "gramgen",
+        "inputs": genSources,
+        "build": true
+    };
+
+    entries = application(gen);
+    genTool = {
+        "type": "tool",
+        "name": "ckgramgen",
+        "command": "$O/apps/ck/lib/gramgen $OUT",
+        "description": "Generating Grammar - $OUT"
+    };
+
+    entries += [genTool];
+
+    //
+    // Create the entry for gram.c, which is created by running the gramgen
+    // tool.
+    //
+
+    grammar = {
+        "type": "target",
+        "output": "gram.c",
+        "inputs": [":gramgen"],
+        "tool": "ckgramgen"
+    };
+
+    entries += [grammar];
+
+    //
+    // Create the static libraries, both for the build machine and targeted at
+    // Minoca.
+    //
+
+    lib = {
+        "label": "libchalk_static",
+        "output": "libchalk",
+        "inputs": sources
+    };
+
+    objs = compiledSources(lib);
+    entries += staticLibrary(lib);
+    lib = {
+        "label": "build_libchalk_static",
+        "output": "libchalk",
+        "inputs": buildSources,
+        "build": true,
+        "prefix": "build"
+    };
+
+    buildObjs = compiledSources(lib);
+    entries += staticLibrary(lib);
+
+    //
+    // Create the dynamic libraries.
+    //
+
+    lib = {
+        "label": "libchalk_dynamic",
+        "output": "libchalk",
+        "inputs": objs[0] + libs,
+        "major_version": majorVersion
+    };
+
+    entries += sharedLibrary(lib);
+    lib = {
+        "label": "build_libchalk_dynamic",
+        "output": "libchalk",
+        "inputs": buildObjs[0] + buildLibs,
+        "major_version": majorVersion,
+        "build": true,
+        "prefix": "build"
+    };
+
+    if (buildOs == "Windows") {
+        lib.output = "chalk";
+    }
+
+    entries += sharedLibrary(lib);
+
+    //
+    // ckcore.o depends on ckcore.ck.
+    //
+
+    for (entry in entries) {
+        if ((entry.get("output")) && (entry.output.endsWith("ckcore.o"))) {
+            entry["implicits"] = ["ckcore.ck"];
+            addConfig(entry, "CPPFLAGS", "-I$S/apps/ck/lib");
+        }
+    }
+
+    return entries;
+}
+

+ 59 - 0
apps/ck/modules/app/build.ck

@@ -0,0 +1,59 @@
+/*++
+
+Copyright (c) 2017 Minoca Corp.
+
+    This file is licensed under the terms of the GNU General Public License
+    version 3. Alternative licensing terms are available. Contact
+    info@minocacorp.com for details. See the LICENSE file at the root of this
+    project for complete licensing information.
+
+Module Name:
+
+    App Module
+
+Abstract:
+
+    This directory builds the app module, a static-only module that must be
+    built into the app, and can provide application-level details.
+
+Author:
+
+    Evan Green 14-Feb-2017
+
+Environment:
+
+    C
+
+--*/
+
+from menv import group, staticLibrary;
+
+function build() {
+    var all;
+    var entries;
+    var lib;
+    var sources;
+
+    sources = [
+        "app.c"
+    ];
+
+    lib = {
+        "label": "app",
+        "inputs": sources
+    };
+
+    entries = staticLibrary(lib);
+    lib = {
+        "label": "build_app",
+        "inputs": sources,
+        "build": true,
+        "prefix": "build"
+    };
+
+    entries += staticLibrary(lib);
+    all = [":app", ":build_app"];
+    entries += group("all", all);
+    return entries;
+}
+

+ 118 - 0
apps/ck/modules/build.ck

@@ -0,0 +1,118 @@
+/*++
+
+Copyright (c) 2017 Minoca Corp.
+
+    This file is licensed under the terms of the GNU General Public License
+    version 3. Alternative licensing terms are available. Contact
+    info@minocacorp.com for details. See the LICENSE file at the root of this
+    project for complete licensing information.
+
+Module Name:
+
+    Chalk
+
+Abstract:
+
+    This directory builds the Chalk modules.
+
+Author:
+
+    Evan Green 14-Feb-2017
+
+Environment:
+
+    C
+
+--*/
+
+from menv import copy, group, mconfig, sharedLibrary;
+
+var libPath = mconfig.binroot + "/chalk1/";
+var buildLibPath = mconfig.outroot + "/tools/lib/chalk1/";
+
+function chalkSharedModule(params) {
+    var destinationPath;
+    var newLabel;
+    var result;
+
+    //
+    // Add the Chalk library dependency, and figure out the destination copy
+    // path.
+    //
+
+    if (params.get("build")) {
+        params.inputs.append("apps/ck/lib:build_libchalk_dynamic");
+        destinationPath = buildLibPath;
+
+    } else {
+        params.inputs.append("apps/ck/lib:libchalk_dynamic");
+        destinationPath = libPath;
+    }
+
+    params.binplace = false;
+    result = sharedLibrary(params);
+
+    //
+    // Copy the file to the destination, then rename the label so that the copy
+    // result gets linked into the dependency chain.
+    //
+
+    newLabel = params.label + "_orig";
+    result += copy(":" + newLabel,
+                   destinationPath + params.output,
+                   params.label,
+                   null,
+                   null);
+
+    params.label = newLabel;
+    return result;
+}
+
+function build() {
+    var all = [];
+    var chalkModules;
+    var entries = [];
+    var foreignModules;
+
+    chalkModules = [
+        "bufferedio.ck",
+        "fileio.ck",
+        "getopt.ck",
+        "io.ck",
+        "iobase.ck"
+    ];
+
+    foreignModules = [
+        "app",
+        "bundle",
+        "os"
+    ];
+
+    //
+    // The chalk modules are just a straight copy.
+    //
+
+    for (module in chalkModules) {
+        entries += copy(module, libPath + module, module, null, null);
+        entries += copy(module,
+                        buildLibPath + module,
+                        "build_" + module,
+                        null,
+                        null);
+
+        all.append(":" + module);
+        all.append(":build_" + module);
+    }
+
+    //
+    // Add all the foreign modules to the all group.
+    //
+
+    for (module in foreignModules) {
+        all.append("apps/ck/modules/" + module + ":all");
+    }
+
+    entries += group("modules", all);
+    return entries;
+}
+

+ 61 - 0
apps/ck/modules/bundle/build.ck

@@ -0,0 +1,61 @@
+/*++
+
+Copyright (c) 2017 Minoca Corp.
+
+    This file is licensed under the terms of the GNU General Public License
+    version 3. Alternative licensing terms are available. Contact
+    info@minocacorp.com for details. See the LICENSE file at the root of this
+    project for complete licensing information.
+
+Module Name:
+
+    Bundle Module
+
+Abstract:
+
+    This directory builds the bundle module, a static-only module that must be
+    built into the app, and can provide executable repackaging functionality.
+    This allows Chalk to create single-executable programs that execute an
+    embedded script.
+
+Author:
+
+    Evan Green 14-Feb-2017
+
+Environment:
+
+    C
+
+--*/
+
+from menv import group, staticLibrary;
+
+function build() {
+    var all;
+    var entries;
+    var lib;
+    var sources;
+
+    sources = [
+        "bundle.c"
+    ];
+
+    lib = {
+        "label": "bundle",
+        "inputs": sources
+    };
+
+    entries = staticLibrary(lib);
+    lib = {
+        "label": "build_bundle",
+        "inputs": sources,
+        "build": true,
+        "prefix": "build"
+    };
+
+    entries += staticLibrary(lib);
+    all = [":bundle", ":build_bundle"];
+    entries += group("all", all);
+    return entries;
+}
+

+ 121 - 0
apps/ck/modules/os/build.ck

@@ -0,0 +1,121 @@
+/*++
+
+Copyright (c) 2017 Minoca Corp.
+
+    This file is licensed under the terms of the GNU General Public License
+    version 3. Alternative licensing terms are available. Contact
+    info@minocacorp.com for details. See the LICENSE file at the root of this
+    project for complete licensing information.
+
+Module Name:
+
+    OS Module
+
+Abstract:
+
+    This directory builds the OS module, which is a module that exposes the
+    functionality of the underlying operating system to Chalk modules.
+
+Author:
+
+    Evan Green 14-Feb-2017
+
+Environment:
+
+    C
+
+--*/
+
+from menv import compiledSources, group, mconfig, staticLibrary;
+from apps.ck.modules.build import chalkSharedModule;
+
+function build() {
+    var all;
+    var buildOs = mconfig.build_os;
+    var buildSources;
+    var commonSources;
+    var lib;
+    var entries;
+    var objs;
+    var posixSources;
+    var win32Sources;
+
+    commonSources = [
+        "entry.c",
+        "errno.c",
+        "io.c",
+        "os.c"
+    ];
+
+    posixSources = [
+        "osinfo.c"
+    ];
+
+    win32Sources = [
+        "oswin32.c",
+        "wininfo.c"
+    ];
+
+    //
+    // Create the static and dynamic versions of the module targeted at Minoca.
+    //
+
+    lib = {
+        "label": "os_static",
+        "output": "os",
+        "inputs": commonSources + posixSources
+    };
+
+    objs = compiledSources(lib);
+    entries = staticLibrary(lib);
+    lib = {
+        "label": "os_dynamic",
+        "output": "os",
+        "inputs": objs[0]
+    };
+
+    entries += chalkSharedModule(lib);
+
+    //
+    // Create the static and dynamic versions of the module for the build
+    // machine.
+    //
+
+    if (buildOs == "Windows") {
+        buildSources = commonSources + win32Sources;
+
+    } else {
+        buildSources = commonSources + posixSources;
+    }
+
+    lib = {
+        "label": "build_os_static",
+        "output": "os",
+        "inputs": buildSources,
+        "build": true,
+        "prefix": "build"
+    };
+
+    objs = compiledSources(lib);
+    entries += staticLibrary(lib);
+    lib = {
+        "label": "build_os_dynamic",
+        "output": "os",
+        "inputs": objs[0],
+        "build": true,
+        "prefix": "build"
+    };
+
+    entries += chalkSharedModule(lib);
+
+    all = [
+        ":os_static",
+        ":os_dynamic",
+        ":build_os_static",
+        ":build_os_dynamic"
+    ];
+
+    entries += group("all", all);
+    return entries;
+}
+

+ 20 - 15
apps/debug/build.ck

@@ -25,30 +25,35 @@ Environment:
 
 --*/
 
+from menv import group, mconfig;
+
 function build() {
-    debug_binaries = [
-        "//apps/debug/client:debug",
-        "//apps/debug/kexts:kexts",
-        "//apps/debug/kexts:build_kexts"
+    var buildOs = mconfig.build_os;
+    var debugBinaries;
+    var entries;
+
+    debugBinaries = [
+        "apps/debug/client:debug",
+        "apps/debug/kexts:kexts",
+        "apps/debug/kexts:build_kexts"
     ];
 
-    if ((build_os == "Windows") || (build_os == "Minoca")) {
-        debug_binaries += [
-            "//apps/debug/client:build_debug",
-            "//apps/debug/client/tdwarf:build_tdwarf",
-            "//apps/debug/client/testdisa:build_testdisa",
-            "//apps/debug/client/teststab:build_teststab",
+    if ((buildOs == "Windows") || (buildOs == "Minoca")) {
+        debugBinaries += [
+            "apps/debug/client:build_debug",
+            "apps/debug/client/tdwarf:build_tdwarf",
+            "apps/debug/client/testdisa:build_testdisa",
+            "apps/debug/client/teststab:build_teststab",
         ];
     }
 
-    if (build_os == "Windows") {
-        debug_binaries += [
-            "//apps/debug/client:build_debugui"
+    if (buildOs == "Windows") {
+        debugBinaries += [
+            "apps/debug/client:build_debugui"
         ];
     }
 
-    entries = group("debug", debug_binaries);
+    entries = group("debug", debugBinaries);
     return entries;
 }
 
-return build();

+ 85 - 59
apps/debug/client/build.ck

@@ -26,8 +26,37 @@ Environment:
 
 --*/
 
+from menv import application, mconfig;
+
 function build() {
-    common_sources = [
+    var arch = mconfig.arch;
+    var archSources;
+    var armSources;
+    var buildApp;
+    var buildArch = mconfig.build_arch;
+    var buildArchSources;
+    var buildConfig;
+    var buildGuiApp;
+    var buildGuiConfig;
+    var buildGuiSources;
+    var buildOs = mconfig.build_os;
+    var buildLibs;
+    var buildSources;
+    var commonSources;
+    var entries;
+    var includes;
+    var minocaSources;
+    var targetApp;
+    var targetDynlibs;
+    var targetLibs;
+    var targetSources;
+    var win32CmdSources;
+    var win32CommonSources;
+    var win32GuiSources;
+    var win32Sources;
+    var x86Sources;
+
+    commonSources = [
         "armdis.c",
         "cmdtab.c",
         "coff.c",
@@ -56,21 +85,21 @@ function build() {
         "x86dis.c"
     ];
 
-    x86_sources = [
+    x86Sources = [
         "x86/dbgarch.c"
     ];
 
-    arm_sources = [
+    armSources = [
         "armv7/dbgarch.c"
     ];
 
-    minoca_sources = [
+    minocaSources = [
         "minoca/cmdln.c",
         "minoca/extsup.c",
         "minoca/sock.c"
     ];
 
-    win32_sources = [
+    win32Sources = [
         "win32/ntcomm.c",
         "win32/ntextsup.c",
         "win32/ntsock.c",
@@ -78,125 +107,122 @@ function build() {
         "win32/ntusrsup.c"
     ];
 
-    win32_cmd_sources = [
+    win32CmdSources = [
         "win32/cmdln/ntcmdln.c",
     ];
 
-    win32_gui_sources = [
+    win32GuiSources = [
         "win32/ui/debugres.rc",
         "win32/ui/ntdbgui.c"
     ];
 
-    target_libs = [
-        "//lib/im:im"
+    targetLibs = [
+        "lib/im:im"
     ];
 
-    build_libs = [
-        "//lib/im:build_im",
-        "//lib/rtl/base:build_basertl",
-        "//lib/rtl/rtlc:build_rtlc"
+    buildLibs = [
+        "lib/im:build_im",
+        "lib/rtl/base:build_basertl",
+        "lib/rtl/rtlc:build_rtlc"
     ];
 
-    target_dynlibs = [
-        "//apps/osbase:libminocaos"
+    targetDynlibs = [
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//lib/im",
-        "$//apps/debug/client",
+        "$S/lib/im",
+        "$S/apps/debug/client",
     ];
 
     if (arch == "x86") {
-        arch_sources = x86_sources;
+        archSources = x86Sources;
 
     } else if ((arch == "armv7") || (arch == "armv6")) {
-        arch_sources = arm_sources;
+        archSources = armSources;
 
     } else {
-
-        assert(0, "Unknown architecture");
+        Core.raise(ValueError("Unknown architecture"));
     }
 
-    target_sources = common_sources + minoca_sources + target_libs +
-                     target_dynlibs + arch_sources;
+    targetSources = commonSources + minocaSources + targetLibs +
+                     targetDynlibs + archSources;
 
-    if (build_arch == "x86") {
-        build_arch_sources = x86_sources;
+    if (buildArch == "x86") {
+        buildArchSources = x86Sources;
 
-    } else if ((build_arch == "armv7") || (build_arch == "armv6")) {
-        build_arch_sources = arm_sources;
+    } else if ((buildArch == "armv7") || (buildArch == "armv6")) {
+        buildArchSources = armSources;
 
     } else {
-
-        assert(0, "Unknown architecture");
+        Core.raise(ValueError("Unknown architecture"));
     }
 
-    build_config = {};
-    build_gui_config = {};
-    if (build_os == "Windows") {
-        win32_common_sources = common_sources + build_arch_sources +
-                               win32_sources;
+    buildConfig = {};
+    buildGuiConfig = {};
+    if (buildOs == "Windows") {
+        win32CommonSources = commonSources + buildArchSources +
+                               win32Sources;
 
-        build_sources = win32_common_sources + win32_cmd_sources;
-        build_gui_sources = win32_common_sources + win32_gui_sources;
-        build_config["DYNLIBS"] = [
+        buildSources = win32CommonSources + win32CmdSources;
+        buildGuiSources = win32CommonSources + win32GuiSources;
+        buildConfig["DYNLIBS"] = [
             "-lpsapi",
             "-lws2_32",
             "-lmswsock",
             "-ladvapi32"
         ];
 
-        build_gui_config["DYNLIBS"] = build_config["DYNLIBS"] + ["-lshlwapi"];
-        build_gui_config["LDFLAGS"] = ["-mwindows"];
+        buildGuiConfig["DYNLIBS"] = buildConfig["DYNLIBS"] + ["-lshlwapi"];
+        buildGuiConfig["LDFLAGS"] = ["-mwindows"];
 
-    } else if (build_os == "Minoca") {
-        build_sources = common_sources + minoca_sources + target_libs;
-        build_config["DYNLIBS"] = ["-lminocaos"];
+    } else if (buildOs == "Minoca") {
+        buildSources = commonSources + minocaSources + targetLibs;
+        buildConfig["DYNLIBS"] = ["-lminocaos"];
 
     } else {
-        build_sources = null;
+        buildSources = null;
     }
 
-    target_app = {
+    targetApp = {
         "label": "debug",
-        "inputs": target_sources,
+        "inputs": targetSources,
         "includes": includes
     };
 
-    entries = application(target_app);
-    if (build_sources) {
-        build_app = {
+    entries = application(targetApp);
+    if (buildSources) {
+        buildApp = {
             "label": "build_debug",
             "output": "debug",
-            "inputs": build_sources + build_libs,
+            "inputs": buildSources + buildLibs,
             "includes": includes,
-            "config": build_config,
-            "build": TRUE,
+            "config": buildConfig,
+            "build": true,
             "prefix": "build"
         };
 
-        entries += application(build_app);
+        entries += application(buildApp);
     }
 
     //
     // Build the Windows GUI application if applicable.
     //
 
-    if (build_os == "Windows") {
-        build_gui_app = {
+    if (buildOs == "Windows") {
+        buildGuiApp = {
             "label": "build_debugui",
             "output": "debugui",
-            "inputs": build_gui_sources + build_libs,
+            "inputs": buildGuiSources + buildLibs,
             "includes": includes,
-            "config": build_gui_config,
-            "build": TRUE,
+            "config": buildGuiConfig,
+            "build": true,
             "prefix": "buildui"
         };
 
-        entries += application(build_gui_app);
+        entries += application(buildGuiApp);
     }
 
     return entries;
 }
 
-return build();

+ 24 - 19
apps/debug/client/tdwarf/build.ck

@@ -25,36 +25,41 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var buildApp;
+    var buildLibs;
+    var entries;
+    var sources;
+
     sources = [
         "tdwarf.c",
-        "//apps/debug/client:build/coff.o",
-        "//apps/debug/client:build/elf.o",
-        "//apps/debug/client:build/dwarf.o",
-        "//apps/debug/client:build/dwexpr.o",
-        "//apps/debug/client:build/dwframe.o",
-        "//apps/debug/client:build/dwline.o",
-        "//apps/debug/client:build/dwread.o",
-        "//apps/debug/client:build/stabs.o",
-        "//apps/debug/client:build/symbols.o"
+        "apps/debug/client:build/coff.o",
+        "apps/debug/client:build/elf.o",
+        "apps/debug/client:build/dwarf.o",
+        "apps/debug/client:build/dwexpr.o",
+        "apps/debug/client:build/dwframe.o",
+        "apps/debug/client:build/dwline.o",
+        "apps/debug/client:build/dwread.o",
+        "apps/debug/client:build/stabs.o",
+        "apps/debug/client:build/symbols.o"
     ];
 
-    build_libs = [
-        "//lib/im:build_im",
-        "//lib/rtl/base:build_basertl",
-        "//lib/rtl/rtlc:build_rtlc",
+    buildLibs = [
+        "lib/im:build_im",
+        "lib/rtl/base:build_basertl",
+        "lib/rtl/rtlc:build_rtlc",
     ];
 
-    build_app = {
+    buildApp = {
         "label": "build_tdwarf",
         "output": "tdwarf",
-        "inputs": sources + build_libs,
-        "build": TRUE
+        "inputs": sources + buildLibs,
+        "build": true
     };
 
-    entries = application(build_app);
+    entries = application(buildApp);
     return entries;
 }
 
-return build();
-

+ 20 - 15
apps/debug/client/testdisa/build.ck

@@ -25,32 +25,37 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var buildApp;
+    var buildLibs;
+    var entries;
+    var sources;
+
     sources = [
         "testdisa.c",
-        "//apps/debug/client:build/x86dis.o",
-        "//apps/debug/client:build/armdis.o",
-        "//apps/debug/client:build/disasm.o",
-        "//apps/debug/client:build/thmdis.o",
-        "//apps/debug/client:build/thm32dis.o",
+        "apps/debug/client:build/x86dis.o",
+        "apps/debug/client:build/armdis.o",
+        "apps/debug/client:build/disasm.o",
+        "apps/debug/client:build/thmdis.o",
+        "apps/debug/client:build/thm32dis.o",
     ];
 
-    build_libs = [
-        "//lib/im:build_im",
-        "//lib/rtl/base:build_basertl",
-        "//lib/rtl/rtlc:build_rtlc",
+    buildLibs = [
+        "lib/im:build_im",
+        "lib/rtl/base:build_basertl",
+        "lib/rtl/rtlc:build_rtlc",
     ];
 
-    build_app = {
+    buildApp = {
         "label": "build_testdisa",
         "output": "testdisa",
-        "inputs": sources + build_libs,
-        "build": TRUE
+        "inputs": sources + buildLibs,
+        "build": true
     };
 
-    entries = application(build_app);
+    entries = application(buildApp);
     return entries;
 }
 
-return build();
-

+ 19 - 14
apps/debug/client/teststab/build.ck

@@ -25,31 +25,36 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var buildApp;
+    var buildLibs;
+    var entries;
+    var sources;
+
     sources = [
         "teststab.c",
-        "//apps/debug/client:build/stabs.o",
-        "//apps/debug/client:build/coff.o",
-        "//apps/debug/client:build/elf.o",
-        "//apps/debug/client:build/symbols.o"
+        "apps/debug/client:build/stabs.o",
+        "apps/debug/client:build/coff.o",
+        "apps/debug/client:build/elf.o",
+        "apps/debug/client:build/symbols.o"
     ];
 
-    build_libs = [
-        "//lib/im:build_im",
-        "//lib/rtl/base:build_basertl",
-        "//lib/rtl/rtlc:build_rtlc",
+    buildLibs = [
+        "lib/im:build_im",
+        "lib/rtl/base:build_basertl",
+        "lib/rtl/rtlc:build_rtlc",
     ];
 
-    build_app = {
+    buildApp = {
         "label": "build_teststab",
         "output": "teststab",
-        "inputs": sources + build_libs,
-        "build": TRUE
+        "inputs": sources + buildLibs,
+        "build": true
     };
 
-    entries = application(build_app);
+    entries = application(buildApp);
     return entries;
 }
 
-return build();
-

+ 11 - 5
apps/debug/dbgext/build.ck

@@ -26,7 +26,14 @@ Environment:
 
 --*/
 
+from menv import staticLibrary;
+
 function build() {
+    var buildLib;
+    var entries;
+    var lib;
+    var sources;
+
     sources = [
         "extimp.c",
     ];
@@ -36,17 +43,16 @@ function build() {
         "inputs": sources,
     };
 
-    build_lib = {
+    buildLib = {
         "label": "build_dbgext",
         "output": "dbgext",
         "inputs": sources,
-        "build": TRUE,
+        "build": true,
         "prefix": "build"
     };
 
-    entries = static_library(lib);
-    entries += static_library(build_lib);
+    entries = staticLibrary(lib);
+    entries += staticLibrary(buildLib);
     return entries;
 }
 
-return build();

+ 19 - 11
apps/debug/kexts/build.ck

@@ -25,7 +25,16 @@ Environment:
 
 --*/
 
+from menv import sharedLibrary;
+
 function build() {
+    var buildLib;
+    var buildLibs;
+    var entries;
+    var lib;
+    var sources;
+    var targetLibs;
+
     sources = [
         "acpiext.c",
         "kexts.c",
@@ -35,30 +44,29 @@ function build() {
         "threads.c"
     ];
 
-    target_libs = [
-        "//apps/debug/dbgext:dbgext"
+    targetLibs = [
+        "apps/debug/dbgext:dbgext"
     ];
 
-    build_libs = [
-        "//apps/debug/dbgext:build_dbgext"
+    buildLibs = [
+        "apps/debug/dbgext:build_dbgext"
     ];
 
     lib = {
         "label": "kexts",
-        "inputs": sources + target_libs,
+        "inputs": sources + targetLibs,
     };
 
-    build_lib = {
+    buildLib = {
         "label": "build_kexts",
         "output": "kexts",
-        "inputs": sources + build_libs,
-        "build": TRUE,
+        "inputs": sources + buildLibs,
+        "build": true,
         "prefix": "build"
     };
 
-    entries = shared_library(lib);
-    entries += shared_library(build_lib);
+    entries = sharedLibrary(lib);
+    entries += sharedLibrary(buildLib);
     return entries;
 }
 
-return build();

+ 18 - 8
apps/efiboot/build.ck

@@ -26,38 +26,48 @@ Environment:
 
 --*/
 
+from menv import application, mconfig;
+
 function build() {
+    var app;
+    var arch = mconfig.arch;
+    var dynlibs;
+    var entries;
+    var includes;
+    var linkConfig;
+    var sources;
+    var sourcesConfig;
+
     sources = [
         "efiboot.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$Sapps/libc/include"
     ];
 
-    sources_config = {
+    sourcesConfig = {
         "CFLAGS": ["-fshort-wchar"]
     };
 
-    link_config = {};
+    linkConfig = {};
     if ((arch == "armv6") || (arch == "armv7")) {
-        link_config["LDFLAGS"] = ["-Wl,--no-wchar-size-warning"];
+        linkConfig["LDFLAGS"] = ["-Wl,--no-wchar-size-warning"];
     }
 
     app = {
         "label": "efiboot",
         "inputs": sources + dynlibs,
-        "sources_config": sources_config,
+        "sources_config": sourcesConfig,
         "includes": includes,
-        "config": link_config
+        "config": linkConfig
     };
 
     entries = application(app);
     return entries;
 }
 
-return build();

+ 11 - 6
apps/lib/chalk/build.ck

@@ -27,7 +27,14 @@ Environment:
 
 --*/
 
+from menv import staticLibrary;
+
 function build() {
+    var buildLib;
+    var entries;
+    var lib;
+    var sources;
+
     sources = [
         "cflow.c",
         "cif.c",
@@ -44,18 +51,16 @@ function build() {
         "inputs": sources,
     };
 
-    build_lib = {
+    buildLib = {
         "label": "build_chalk",
         "output": "chalk",
         "inputs": sources,
-        "build": TRUE,
+        "build": true,
         "prefix": "build"
     };
 
-    entries = static_library(lib);
-    entries += static_library(build_lib);
+    entries = staticLibrary(lib);
+    entries += staticLibrary(buildLib);
     return entries;
 }
 
-return build();
-

+ 9 - 4
apps/libc/crypt/build.ck

@@ -26,13 +26,20 @@ Environment:
 
 --*/
 
+from menv import sharedLibrary;
+
 function build() {
+    var dynlibs;
+    var entries;
+    var so;
+    var sources;
+
     sources = [
         "crypt.c"
     ];
 
     dynlibs = [
-        "//apps/libc/dynamic:libc"
+        "apps/libc/dynamic:libc"
     ];
 
     so = {
@@ -41,9 +48,7 @@ function build() {
         "major_version": "1"
     };
 
-    entries = shared_library(so);
+    entries = sharedLibrary(so);
     return entries;
 }
 
-return build();
-

+ 48 - 30
apps/libc/dynamic/build.ck

@@ -29,8 +29,28 @@ Environment:
 
 --*/
 
+from menv import mconfig, sharedLibrary, staticLibrary;
+
 function build() {
-    math_sources = [
+    var arch = mconfig.arch;
+    var arch_sources;
+    var buildLib;
+    var buildSources;
+    var dynlibs;
+    var entries;
+    var libs;
+    var linkConfig;
+    var linkLdflags;
+    var mathSources;
+    var so;
+    var sources;
+    var sourcesConfig;
+    var sourcesIncludes;
+    var wincsup;
+    var wincsupIncludes;
+    var wincsupSources;
+
+    mathSources = [
         "math/abs.c",
         "math/ceil.c",
         "math/ceilf.c",
@@ -156,7 +176,7 @@ function build() {
         "wstring.c",
     ];
 
-    build_sources = [
+    buildSources = [
         "bsearch.c",
         "getopt.c",
         "qsort.c",
@@ -164,7 +184,7 @@ function build() {
         "regexexe.c"
     ];
 
-    wincsup_sources = [
+    wincsupSources = [
         "regexcmp.c",
         "regexexe.c",
         "wincsup/strftime.c"
@@ -200,68 +220,66 @@ function build() {
         ];
     }
 
-    sources_includes = [
-        "$//apps/libc/include"
+    sourcesIncludes = [
+        "$S/apps/libc/include"
     ];
 
-    sources_config = {
+    sourcesConfig = {
         "CFLAGS": ["-ftls-model=initial-exec"]
     };
 
-    link_ldflags = [
+    linkLdflags = [
         "-nostdlib",
         "-Wl,--whole-archive"
     ];
 
-    link_config = {
-        "LDFLAGS": link_ldflags
+    linkConfig = {
+        "LDFLAGS": linkLdflags
     };
 
     libs = [
-        "//lib/rtl/base:intrins",
+        "lib/rtl/base:intrins",
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
-    wincsup_includes = [
-        "$//apps/libc/dynamic/wincsup/include"
+    wincsupIncludes = [
+        "$S/apps/libc/dynamic/wincsup/include"
     ];
 
     so = {
         "label": "libc",
-        "inputs": sources + math_sources + arch_sources + libs + dynlibs,
-        "sources_config": sources_config,
-        "includes": sources_includes,
+        "inputs": sources + mathSources + arch_sources + libs + dynlibs,
+        "sources_config": sourcesConfig,
+        "includes": sourcesIncludes,
         "entry": "ClInitialize",
-        "config": link_config,
+        "config": linkConfig,
         "major_version": "1"
     };
 
-    build_lib = {
+    buildLib = {
         "label": "build_libc",
         "output": "build_libc",
-        "inputs": build_sources + math_sources,
-        "sources_config": sources_config,
-        "includes": sources_includes,
-        "build": TRUE,
+        "inputs": buildSources + mathSources,
+        "sources_config": sourcesConfig,
+        "includes": sourcesIncludes,
+        "build": true,
         "prefix": "build"
     };
 
     wincsup = {
         "label": "wincsup",
-        "inputs": wincsup_sources,
-        "includes": wincsup_includes,
-        "build": TRUE,
+        "inputs": wincsupSources,
+        "includes": wincsupIncludes,
+        "build": true,
         "prefix": "wincsup"
     };
 
-    entries = shared_library(so);
-    entries += static_library(build_lib);
-    entries += static_library(wincsup);
+    entries = sharedLibrary(so);
+    entries += staticLibrary(buildLib);
+    entries += staticLibrary(wincsup);
     return entries;
 }
 
-return build();
-

+ 9 - 3
apps/libc/dynamic/pthread/static/build.ck

@@ -26,13 +26,20 @@ Environment:
 
 --*/
 
+from menv import staticLibrary;
+
 function build() {
+    var entries;
+    var includes;
+    var lib;
+    var sources;
+
     sources = [
         "ptatfork.c",
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     lib = {
@@ -41,8 +48,7 @@ function build() {
         "includes": includes,
     };
 
-    entries = static_library(lib);
+    entries = staticLibrary(lib);
     return entries;
 }
 
-return build();

+ 15 - 9
apps/libc/dynamic/testc/build.ck

@@ -25,7 +25,15 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var buildApp;
+    var buildLibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "bsrchtst.c",
         "getoptst.c",
@@ -36,26 +44,24 @@ function build() {
         "testc.c"
     ];
 
-    build_libs = [
-        "//apps/libc/dynamic:build_libc",
+    buildLibs = [
+        "apps/libc/dynamic:build_libc",
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
-    build_app = {
+    buildApp = {
         "label": "build_testc",
         "output": "testc",
-        "inputs": sources + build_libs,
+        "inputs": sources + buildLibs,
         "includes": includes,
-        "build": TRUE,
+        "build": true,
         "prefix": "build"
     };
 
-    entries = application(build_app);
+    entries = application(buildApp);
     return entries;
 }
 
-return build();
-

+ 15 - 7
apps/libc/static/build.ck

@@ -27,41 +27,49 @@ Environment:
 
 --*/
 
+from menv import mconfig, staticLibrary;
+
 function build() {
+    var arch = mconfig.arch;
+    var archSources;
+    var entries;
+    var includes;
+    var lib;
+    var sources;
+
     sources = [
         "init.c",
         "atexit.c"
     ];
 
     if ((arch == "armv7") || (arch == "armv6")) {
-        arch_sources = [
+        archSources = [
             "armv7/aatexit.c",
             "armv7/crt0.S"
         ];
 
     } else if (arch == "x86") {
-        arch_sources = [
+        archSources = [
             "x86/crt0.S"
         ];
 
     } else if (arch == "x64") {
-        arch_sources = [
+        archSources = [
             "x64/crt0.S"
         ];
     }
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     lib = {
         "label": "libc_nonshared",
-        "inputs": arch_sources + sources,
+        "inputs": archSources + sources,
         "includes": includes
     };
 
-    entries = static_library(lib);
+    entries = staticLibrary(lib);
     return entries;
 }
 
-return build();

+ 27 - 13
apps/mingen/build.ck

@@ -25,7 +25,23 @@ Environment:
 
 --*/
 
+from menv import application, mconfig;
+
 function build() {
+    var app;
+    var base_sources;
+    var build_app;
+    var build_includes;
+    var build_libs;
+    var build_sources;
+    var build_os = mconfig.build_os;
+    var entries;
+    var includes;
+    var libs;
+    var sources;
+    var uos_sources;
+    var win32_sources;
+
     base_sources = [
         "chkfuncs.c",
         "make.c",
@@ -50,25 +66,25 @@ function build() {
     }
 
     libs = [
-        "//apps/lib/chalk:chalk",
-        "//lib/yy:yy",
-        "//lib/rtl/rtlc:rtlc",
-        "//lib/rtl/base/:basertl"
+        "apps/lib/chalk:chalk",
+        "lib/yy:yy",
+        "lib/rtl/rtlc:rtlc",
+        "lib/rtl/base:basertl"
     ];
 
     build_libs = [
-        "//apps/lib/chalk:build_chalk",
-        "//lib/yy:build_yy",
-        "//lib/rtl/rtlc:build_rtlc",
-        "//lib/rtl/base:build_basertl"
+        "apps/lib/chalk:build_chalk",
+        "lib/yy:build_yy",
+        "lib/rtl/rtlc:build_rtlc",
+        "lib/rtl/base:build_basertl"
     ];
 
     build_includes = [
-        "$//apps/lib/chalk"
+        "$S/apps/lib/chalk"
     ];
 
     includes = build_includes + [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -82,7 +98,7 @@ function build() {
         "output": "mingen",
         "inputs": build_sources + build_libs,
         "includes": build_includes,
-        "build": TRUE,
+        "build": true,
         "prefix": "build"
     };
 
@@ -91,5 +107,3 @@ function build() {
     return entries;
 }
 
-return build();
-

+ 17 - 3
apps/mingen2/mingen.ck

@@ -585,11 +585,25 @@ Return Value:
 
     for (entry in entries) {
         if (!(entry is Dict)) {
-            Core.raise(TypeError("Expected a dict, got a %s: %s" %
-                                 [entry.type().name(), entry.__str()]));
+            Core.raise(TypeError("In %s: Expected a dict, got a %s: %s" %
+                                 [moduleName,
+                                  entry.type().name(),
+                                  entry.__str()]));
+        }
+
+        try {
+            entryType = entry.type;
+
+        } except KeyError {
+            Core.print("In entry:");
+            for (key in entry) {
+                Core.print("  %s: %s" % [key, entry[key].__str()]);
+            }
+
+            Core.raise(ValueError("In %s: Dict must have a 'type' member" %
+                                  moduleName));
         }
 
-        entryType = entry.type;
         if (entryType == "target") {
             _validateTargetEntry(moduleName, entry);
 

+ 19 - 6
apps/mingen2/ninja.ck

@@ -31,6 +31,7 @@ Environment:
 //
 
 from io import open;
+from os import OsError, EEXIST, dirname, mkdir;
 
 //
 // --------------------------------------------------------------------- Macros
@@ -216,6 +217,8 @@ Return Value:
     var module;
     var ninjaPath;
     var pools;
+    var pool;
+    var skippedNewline = false;
     var targetsList = entries.targetsList;
     var tools;
     var totalInputs;
@@ -226,12 +229,16 @@ Return Value:
         Core.print("Creating %s" % ninjaPath);
     }
 
-    file = open(ninjaPath, "wb");
+    try {
+        mkdir(dirname(ninjaPath), 0775);
 
-    //
-    // TODO: Put the current time in the file.
-    //
+    } except OsError as error {
+        if (error.errno != EEXIST) {
+            Core.raise(error);
+        }
+    }
 
+    file = open(ninjaPath, "wb");
     file.write("# Ninja build automatically generated by Minoca mingen\n");
     file.write("# Define high level variables\n");
     file.write("%s = %s\n" % [config.input_variable, config.input]);
@@ -279,7 +286,8 @@ Return Value:
     pools = entries.pools;
     if (pools.length()) {
         file.write("# Define pools");
-        for (pool in pools) {
+        for (key in pools) {
+            pool = pools[key];
             if (!pool.active) {
                 continue;
             }
@@ -303,6 +311,10 @@ Return Value:
 
         if (target.module != module) {
             module = target.module;
+            if (skippedNewline) {
+                file.write("\n");
+            }
+
             if (module == "") {
                 file.write("# Define root targets\n");
 
@@ -339,12 +351,13 @@ Return Value:
         totalInputs = target.inputs.length() + target.implicit.length() +
                       target.orderonly.length();
 
-
+        skippedNewline = true;
         if ((totalInputs > 1) ||
             (target.config.length()) ||
             (target.get("pool"))) {
 
             file.write("\n");
+            skippedNewline = false;
         }
     }
 

+ 10 - 3
apps/mount/build.ck

@@ -27,17 +27,25 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "mount.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -50,4 +58,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 11 - 4
apps/netcon/build.ck

@@ -25,18 +25,26 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "netcon.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos",
-        "//apps/netlink:libnetlink"
+        "apps/osbase:libminocaos",
+        "apps/netlink:libnetlink"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -49,4 +57,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 12 - 6
apps/netlink/build.ck

@@ -27,17 +27,25 @@ Environment:
 
 --*/
 
+from menv import sharedLibrary;
+
 function build() {
+    var entries;
+    var libConfig;
+    var lib;
+    var includes;
+    var sources;
+
     sources = [
         "generic.c",
         "netlink.c",
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
-    lib_config = {
+    libConfig = {
         "LDFLAGS": ["-nostdlib"]
     };
 
@@ -46,13 +54,11 @@ function build() {
         "inputs": sources,
         "entry": "NlInitialize",
         "includes": includes,
-        "config": lib_config,
+        "config": libConfig,
         "major_version": "1",
     };
 
-    entries = shared_library(lib);
+    entries = sharedLibrary(lib);
     return entries;
 }
 
-return build();
-

+ 30 - 20
apps/osbase/build.ck

@@ -33,7 +33,19 @@ Environment:
 
 --*/
 
+from menv import sharedLibrary, mconfig;
+
 function build() {
+    var arch = mconfig.arch;
+    var archSources;
+    var entries;
+    var ldflags;
+    var libs;
+    var linkConfig;
+    var so;
+    var sources;
+    var textAddress;
+
     sources = [
         "env.c",
         "heap.c",
@@ -47,59 +59,57 @@ function build() {
     ];
 
     if ((arch == "armv7") || (arch == "armv6")) {
-        text_base = "0x10000000";
-        arch_sources = [
+        textAddress = "0x10000000";
+        archSources = [
             "armv7/features.c",
             "armv7/osbasea.S",
             "armv7/syscall.c"
         ];
 
     } else if (arch == "x86") {
-        text_base = "0x200000";
-        arch_sources = [
+        textAddress = "0x200000";
+        archSources = [
             "x86/features.c",
             "x86/osbasea.S",
             "x86/syscall.c"
         ];
 
     } else if (arch == "x64") {
-        text_base = "0x200000";
-        arch_sources = [
+        textAddress = "0x200000";
+        archSources = [
             "x64/osbasea.S",
             "x64/syscall.c"
         ];
     }
 
-    link_ldflags = [
+    ldflags = [
         "-Wl,-Bsymbolic",
         "-nostdlib",
         "-Wl,--whole-archive",
-        "-Wl,-Ttext-segment=" + text_base,
+        "-Wl,-Ttext-segment=" + textAddress,
     ];
 
-    link_config = {
-        "LDFLAGS": link_ldflags
+    linkConfig = {
+        "LDFLAGS": ldflags
     };
 
     libs = [
-        "//lib/rtl/base:basertl",
-        "//lib/rtl/base:basertlw",
-        "//lib/im:im",
-        "//apps/osbase/urtl:urtl",
-        "//lib/crypto:crypto"
+        "lib/rtl/base:basertl",
+        "lib/rtl/base:basertlw",
+        "lib/im:im",
+        "apps/osbase/urtl:urtl",
+        "lib/crypto:crypto"
     ];
 
     so = {
         "label": "libminocaos",
-        "inputs": sources + arch_sources + libs,
+        "inputs": sources + archSources + libs,
         "entry": "OsDynamicLoaderMain",
-        "config": link_config,
+        "config": linkConfig,
         "major_version": "1"
     };
 
-    entries = shared_library(so);
+    entries = sharedLibrary(so);
     return entries;
 }
 
-return build();
-

+ 7 - 2
apps/osbase/urtl/build.ck

@@ -26,7 +26,13 @@ Environment:
 
 --*/
 
+from menv import staticLibrary;
+
 function build() {
+    var entries;
+    var lib;
+    var sources;
+
     sources = [
         "assert.c",
         "uprint.c"
@@ -37,8 +43,7 @@ function build() {
         "inputs": sources,
     };
 
-    entries = static_library(lib);
+    entries = staticLibrary(lib);
     return entries;
 }
 
-return build();

+ 76 - 28
apps/posix/build.ck

@@ -25,28 +25,40 @@ Environment:
 
 --*/
 
+from menv import copy, group, makedir, mconfig, strip, touch;
+
 function build() {
-    skel = binroot + "/skel";
-    skelbin = skel + "/bin";
-    skellib = skel + "/lib";
-    skeletc = skel + "/etc";
+    var all;
+    var binfiles;
+    var emptydirs;
+    var emptyfiles;
+    var entries;
+    var entry;
+    var libfiles;
+    var posixfiles;
+    var skel = mconfig.binroot + "/skel";
+    var skelbin = skel + "/bin";
+    var skeletc = skel + "/etc";
+    var skellib = skel + "/lib";
+    var updateRcCommand;
+    var updateRcTool;
 
     binfiles = [
-        ["//apps/efiboot:efiboot", "efiboot"],
-        ["//apps/mount:mount", "mount"],
-        ["//apps/netcon:netcon", "netcon"],
-        ["//apps/profile:profile", "profile"],
-        ["//apps/setup:msetup", "msetup"],
-        ["//apps/swiss:swiss", "swiss"],
-        ["//apps/unmount:umount", "umount"],
-        ["//apps/debug/client:debug", "debug"]
+        ["apps/efiboot:efiboot", "efiboot"],
+        ["apps/mount:mount", "mount"],
+        ["apps/netcon:netcon", "netcon"],
+        ["apps/profile:profile", "profile"],
+        ["apps/setup:msetup", "msetup"],
+        ["apps/swiss:swiss", "sh"],
+        ["apps/unmount:umount", "umount"],
+        ["apps/debug/client:debug", "debug"]
     ];
 
     libfiles = [
-        ["//apps/libc/crypt:libcrypt", "libcrypt.so.1"],
-        ["//apps/libc/dynamic:libc", "libc.so.1"],
-        ["//apps/netlink:libnetlink", "libnetlink.so.1"],
-        ["//apps/osbase:libminocaos", "libminocaos.so.1"],
+        ["apps/libc/crypt:libcrypt", "libcrypt.so.1"],
+        ["apps/libc/dynamic:libc", "libc.so.1"],
+        ["apps/netlink:libnetlink", "libnetlink.so.1"],
+        ["apps/osbase:libminocaos", "libminocaos.so.1"],
     ];
 
     posixfiles = [
@@ -57,7 +69,19 @@ function build() {
         [skeletc, "inittab", "0644"],
         [skeletc, "issue", "0644"],
         [skeletc, "init.d/rc", "0755"],
-        [skeletc, "init.d/init-functions", "0755"]
+        [skeletc, "init.d/init-functions", "0755"],
+        [skeletc, "init.d/hostname.sh", "0755"]
+    ];
+
+    emptyfiles = [
+        [skel + "/var/run", "utmp", "0664"],
+        [skel + "/var/log", "wtmp", "0664"]
+    ];
+
+    emptydirs = [
+        [skel + "/root", "root"],
+        [skel + "/home", "home"],
+        [skel + "/tmp", "tmp"]
     ];
 
     all = [];
@@ -95,26 +119,50 @@ function build() {
                         null,
                         file[2]);
 
-        all += [file[1]];
+        all += [":" + file[1]];
+    }
+
+    //
+    // Create empty files and directories.
+    //
+
+    for (file in emptyfiles) {
+        entries += touch(file[0] + "/" + file[1], file[1], file[2]);
+        all += [":" + file[1]];
+    }
+
+    for (dir in emptydirs) {
+        entries += makedir(dir[0], dir[1]);
+        all += [":" + dir[1]];
     }
 
     //
-    // Create a symlink to swiss at /bin/sh.
+    // Define a tool for using update-rc.d.
     //
 
+    updateRcCommand = "$SHELL -c \"SYSROOT=" + skel +
+                      " sh $S/apps/posix/update-rc.d $UPDATERC_ARGS\"";
+
+    updateRcTool = {
+        "type": "tool",
+        "name": "updaterc",
+        "command": updateRcCommand,
+        "description": "mkdir $OUT"
+    };
+
+    entries.append(updateRcTool);
     entry = {
-        "label": "sh",
-        "output": skelbin + "/sh",
-        "inputs": [":swiss"],
-        "tool": "symlink",
-        "config": {"SYMLINK_IN": "swiss"}
+        "type": "target",
+        "inputs": [":init.d/hostname.sh"],
+        "output": skeletc + "/rc2.d/S10hostname.sh",
+        "label": "init_hostname",
+        "tool": "updaterc",
+        "config": {"UPDATERC_ARGS": "-f hostname.sh defaults 10"}
     };
 
-    entries += [entry];
-    all += [":sh"];
+    entries.append(entry);
+    all += [":init_hostname"];
     entries += group("skel", all);
     return entries;
 }
 
-return build();
-

+ 10 - 3
apps/profile/build.ck

@@ -26,17 +26,25 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "profile.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -49,4 +57,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 82 - 55
apps/setup/build.ck

@@ -25,14 +25,34 @@ Environment:
 
 --*/
 
+from menv import application, copy, mconfig;
+
 function build() {
-    common_sources = [
+    var app;
+    var buildApp;
+    var buildConfig;
+    var buildIncludes;
+    var buildLibs;
+    var buildOs = mconfig.build_os;
+    var buildSources;
+    var commonSources;
+    var entries;
+    var imagePool;
+    var minocaSources;
+    var setupTool;
+    var targetDynlibs;
+    var targetIncludes;
+    var targetLibs;
+    var targetSources;
+    var uosSources;
+    var win32Sources;
+
+    commonSources = [
         "cache.c",
-        "config.S",
+        "config.c",
         "disk.c",
         "fatdev.c",
         "fileio.c",
-        "indat.c",
         "partio.c",
         "plat.c",
         "setup.c",
@@ -40,19 +60,19 @@ function build() {
         "util.c"
     ];
 
-    minoca_sources = [
+    minocaSources = [
         "minoca/io.c",
         "minoca/misc.c",
         "minoca/part.c"
     ];
 
-    uos_sources = [
+    uosSources = [
         "uos/io.c",
         "uos/misc.c",
         "uos/part.c"
     ];
 
-    win32_sources = [
+    win32Sources = [
         "win32/io.c",
         "win32/misc.c",
         "win32/msetuprc.rc",
@@ -60,89 +80,96 @@ function build() {
         "win32/win32sup.c"
     ];
 
-    target_libs = [
-        "//lib/partlib:partlib",
-        "//lib/fatlib:fat",
-        "//lib/bconflib:bconf",
-        "//lib/rtl/base:basertl",
-        "//apps/osbase/urtl:urtl",
-        "//apps/lib/chalk:chalk",
-        "//lib/yy:yy"
-    ];
-
-    build_libs = [
-        "//lib/partlib:build_partlib",
-        "//lib/fatlib:build_fat",
-        "//lib/bconflib:build_bconf",
-        "//lib/rtl/base:build_basertl",
-        "//lib/rtl/rtlc:build_rtlc",
-        "//apps/lib/chalk:build_chalk",
-        "//lib/yy:build_yy"
+    targetLibs = [
+        "lib/partlib:partlib",
+        "lib/fatlib:fat",
+        "lib/bconflib:bconf",
+        "lib/rtl/base:basertl",
+        "apps/osbase/urtl:urtl",
+        "apps/ck/lib:libchalk_static",
+        "lib/yy:yy"
     ];
 
-    target_dynlibs = [
-        "//apps/osbase:libminocaos"
+    buildLibs = [
+        "lib/partlib:build_partlib",
+        "lib/fatlib:build_fat",
+        "lib/bconflib:build_bconf",
+        "lib/rtl/base:build_basertl",
+        "lib/rtl/rtlc:build_rtlc",
+        "apps/ck/lib:build_libchalk_static",
+        "lib/yy:build_yy"
     ];
 
-    build_includes = [
-        "$//apps/lib/chalk",
-        "$//apps/setup/config"
+    targetDynlibs = [
+        "apps/osbase:libminocaos"
     ];
 
-    target_includes = build_includes + [
-        "$//apps/libc/include",
+    buildIncludes = [];
+    targetIncludes = [
+        "$S/apps/libc/include",
     ];
 
-    target_sources = common_sources + minoca_sources + target_libs +
-                     target_dynlibs;
+    targetSources = commonSources + minocaSources + targetLibs +
+                     targetDynlibs;
 
-    build_config = {};
-    if (build_os == "Windows") {
-        build_sources = common_sources + win32_sources;
-        build_config["DYNLIBS"] = ["-lsetupapi"];
+    buildConfig = {};
+    if (buildOs == "Windows") {
+        buildSources = commonSources + win32Sources;
+        buildConfig["DYNLIBS"] = ["-lsetupapi"];
 
-    } else if (build_os == "Minoca") {
-        build_sources = common_sources + minoca_sources + target_dynlibs;
-        build_includes = target_includes;
+    } else if (buildOs == "Minoca") {
+        buildSources = commonSources + minocaSources + targetDynlibs;
+        buildIncludes = targetIncludes;
 
     } else {
-        build_sources = common_sources + uos_sources;
+        buildSources = commonSources + uosSources;
     }
 
     app = {
         "label": "msetup",
-        "inputs": target_sources,
-        "includes": target_includes
+        "inputs": targetSources,
+        "includes": targetIncludes
     };
 
-    build_app = {
+    entries = application(app);
+    buildApp = {
         "label": "build_msetup",
         "output": "msetup",
-        "inputs": build_sources + build_libs,
-        "includes": build_includes,
-        "config": build_config,
-        "build": TRUE,
+        "inputs": buildSources + buildLibs,
+        "implicit": [":install.ck"],
+        "includes": buildIncludes,
+        "config": buildConfig,
+        "build": true,
         "prefix": "build"
     };
 
-    entries = application(app);
-    entries += application(build_app);
-    setup_tool = {
+    entries += application(buildApp);
+    setupTool = {
         "type": "tool",
         "name": "msetup_image",
-        "command": "$^/apps/setup/build/msetup $MSETUP_FLAGS -d $OUT",
+        "command": "$O/apps/setup/build/msetup $MSETUP_FLAGS -d $OUT",
         "description": "Building Image - $OUT",
         "pool": "image"
     };
 
-    image_pool = {
+    imagePool = {
         "type": "pool",
         "name": "image",
         "depth": 1
     };
 
-    entries += [setup_tool, image_pool];
+    entries += [setupTool, imagePool];
+
+    //
+    // Add the copy of install.ck to the bin root.
+    //
+
+    entries += copy("install.ck",
+                    mconfig.binroot + "/install.ck",
+                    "install.ck",
+                    null,
+                    null);
+
     return entries;
 }
 
-return build();

+ 66 - 46
apps/swiss/build.ck

@@ -26,8 +26,29 @@ Environment:
 
 --*/
 
+from menv import application, createVersionHeader, mconfig;
+
 function build() {
-    base_sources = [
+    var app;
+    var baseSources;
+    var buildApp;
+    var buildConfig;
+    var buildLibs;
+    var buildIncludes;
+    var buildOs = mconfig.build_os;
+    var buildSources;
+    var buildSourcesConfig;
+    var entries;
+    var minocaSources;
+    var sourcesConfig;
+    var targetIncludes;
+    var targetLibs;
+    var targetSources;
+    var uosOnlyCommands;
+    var uosSources;
+    var win32Sources;
+
+    baseSources = [
         "basename.c",
         "cat.c",
         "cecho.c",
@@ -109,8 +130,9 @@ function build() {
         "xargs.c",
     ];
 
-    uos_only_commands = [
+    uosOnlyCommands = [
         "chown.c",
+        "hostname.c",
         "init.c",
         "login/chpasswd.c",
         "login/getty.c",
@@ -135,20 +157,20 @@ function build() {
         "telnetd.c",
     ];
 
-    minoca_sources = [
+    minocaSources = [
         "cmds.c",
         "dw.c",
         "swlib/minocaos.c"
     ];
 
-    uos_sources = [
+    uosSources = [
         "dw.c",
         "hostname.c",
         "swlib/linux.c",
         "uos/uoscmds.c",
     ];
 
-    win32_sources = [
+    win32Sources = [
         "dw.c",
         "sh/shntos.c",
         "swlib/ntos.c",
@@ -156,76 +178,76 @@ function build() {
         "win32/w32cmds.c"
     ];
 
-    target_libs = [
-        "//lib/termlib:termlib",
-        "//apps/osbase:libminocaos"
+    targetLibs = [
+        "lib/termlib:termlib",
+        "apps/osbase:libminocaos"
     ];
 
-    build_libs = [
-        "//lib/termlib:build_termlib",
-        "//lib/rtl/base:build_basertl",
-        "//lib/rtl/rtlc:build_rtlc"
+    buildLibs = [
+        "lib/termlib:build_termlib",
+        "lib/rtl/base:build_basertl",
+        "lib/rtl/rtlc:build_rtlc"
     ];
 
-    build_includes = [];
-    target_includes = build_includes + [
-        "$//apps/libc/include"
+    buildIncludes = [];
+    targetIncludes = buildIncludes + [
+        "$S/apps/libc/include"
     ];
 
-    target_sources = base_sources + uos_only_commands + minoca_sources;
-    build_config = {
+    targetSources = baseSources + uosOnlyCommands + minocaSources;
+    buildConfig = {
         "LDFLAGS": [],
         "DYNLIBS": []
     };
 
-    sources_config = {
+    sourcesConfig = {
         "CFLAGS": ["-ftls-model=initial-exec"],
     };
 
-    build_sources_config = sources_config + {};
-    if (build_os == "Minoca") {
-        build_sources = target_sources;
-        build_config["DYNLIBS"] += ["-lminocaos"];
+    buildSourcesConfig = sourcesConfig.copy();
+    if (buildOs == "Minoca") {
+        buildSources = targetSources;
+        buildConfig["DYNLIBS"] += ["-lminocaos"];
 
-    } else if (build_os == "Windows") {
-        build_sources = base_sources + win32_sources;
-        build_libs = ["//apps/libc/dynamic:wincsup"] + build_libs;
-        build_includes += ["$//apps/libc/dynamic/wincsup/include"];
-        build_config["DYNLIBS"] += ["-lpsapi", "-lws2_32"];
+    } else if (buildOs == "Windows") {
+        buildSources = baseSources + win32Sources;
+        buildLibs = ["apps/libc/dynamic:wincsup"] + buildLibs;
+        buildIncludes += ["$S/apps/libc/dynamic/wincsup/include"];
+        buildConfig["DYNLIBS"] += ["-lpsapi", "-lws2_32"];
 
     } else {
-        build_sources = base_sources + uos_only_commands + uos_sources;
-        if (build_os == "Linux") {
-            build_config["DYNLIBS"] += ["-ldl", "-lutil"];
+        buildSources = baseSources + uosOnlyCommands + uosSources;
+        if (buildOs == "Linux") {
+            buildConfig["DYNLIBS"] += ["-ldl", "-lutil"];
         }
     }
 
     app = {
         "label": "swiss",
-        "inputs": target_sources + target_libs,
-        "sources_config": sources_config,
-        "includes": target_includes
+        "inputs": targetSources + targetLibs,
+        "sources_config": sourcesConfig,
+        "includes": targetIncludes
     };
 
-    build_app = {
+    buildApp = {
         "label": "build_swiss",
         "output": "swiss",
-        "inputs": build_sources + build_libs,
-        "sources_config": build_sources_config,
-        "includes": build_includes,
-        "config": build_config,
-        "build": TRUE,
+        "inputs": buildSources + buildLibs,
+        "sources_config": buildSourcesConfig,
+        "includes": buildIncludes,
+        "config": buildConfig,
+        "build": true,
         "prefix": "build"
     };
 
     entries = application(app);
-    entries += application(build_app);
+    entries += application(buildApp);
 
     //
     // Create the version header.
     //
 
-    entries += create_version_header("0", "0", "0");
+    entries += createVersionHeader("0", "0", "0");
 
     //
     // Add the include and dependency for version.c.
@@ -233,16 +255,14 @@ function build() {
 
     for (entry in entries) {
         if (entry["inputs"][0] == "swlib/userio.c") {
-            entry["config"] = entry["config"] + {};
+            entry["config"] = entry["config"].copy();
             entry["config"]["CPPFLAGS"] = entry["config"]["CPPFLAGS"] +
-                                          ["-I$^/apps/swiss"];
+                                          ["-I$O/apps/swiss"];
 
-            entry["implicit"] = [":version.h", "//.git/HEAD"];
+            entry["implicit"] = [":version.h"];
         }
     }
 
     return entries;
 }
 
-return build();
-

+ 1 - 0
apps/swiss/sh/parser.c

@@ -3105,6 +3105,7 @@ Return Value:
         return Result;
     }
 
+    *Separator = 0;
     return FALSE;
 }
 

+ 11 - 6
apps/testapps/build.ck

@@ -26,8 +26,14 @@ Environment:
 
 --*/
 
+from menv import group;
+
 function build() {
-    app_names = [
+    var appNames;
+    var apps;
+    var testappsGroup;
+
+    appNames = [
         "dbgtest",
         "filetest",
         "ktest",
@@ -41,12 +47,11 @@ function build() {
     ];
 
     apps = [];
-    for (app in app_names) {
-        apps += ["//apps/testapps/" + app + ":" + app];
+    for (app in appNames) {
+        apps += ["apps/testapps/" + app + ":" + app];
     }
 
-    testapps_group = group("testapps", apps);
-    return testapps_group;
+    testappsGroup = group("testapps", apps);
+    return testappsGroup;
 }
 
-return build();

+ 10 - 3
apps/testapps/dbgtest/build.ck

@@ -25,17 +25,25 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "dbgtest.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -48,4 +56,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 10 - 3
apps/testapps/filetest/build.ck

@@ -25,17 +25,25 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "filetest.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -48,4 +56,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 19 - 9
apps/testapps/ktest/build.ck

@@ -27,25 +27,36 @@ Environment:
 
 --*/
 
+from menv import application, driver;
+
 function build() {
+    var app;
+    var driverDynlibs;
+    var driverSources;
+    var dynlibs;
+    var entries;
+    var includes;
+    var ktestDriver;
+    var sources;
+
     sources = [
         "ktest.c"
     ];
 
-    driver_sources = [
+    driverSources = [
         "driver/ktestdrv.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
-    driver_dynlibs = [
-        "//kernel:kernel"
+    driverDynlibs = [
+        "kernel:kernel"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -55,15 +66,14 @@ function build() {
         "includes": includes
     };
 
-    ktest_driver = {
+    ktestDriver = {
         "label": "ktestdrv",
-        "inputs": driver_sources + driver_dynlibs,
+        "inputs": driverSources + driverDynlibs,
         "includes": includes
     };
 
     entries = application(app);
-    entries += driver(ktest_driver);
+    entries += driver(ktestDriver);
     return entries;
 }
 
-return build();

+ 10 - 3
apps/testapps/mmaptest/build.ck

@@ -25,17 +25,25 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "mmaptest.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -48,4 +56,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 10 - 3
apps/testapps/mnttest/build.ck

@@ -25,17 +25,25 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "mnttest.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -48,4 +56,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 10 - 3
apps/testapps/pathtest/build.ck

@@ -25,17 +25,25 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "pathtest.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -48,4 +56,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 16 - 7
apps/testapps/perftest/build.ck

@@ -25,7 +25,17 @@ Environment:
 
 --*/
 
+from menv import application, sharedLibrary;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var libSources;
+    var perfLib;
+    var sources;
+
     sources = [
         "copy.c",
         "create.c",
@@ -48,16 +58,16 @@ function build() {
         "write.c"
     ];
 
-    lib_sources = [
+    libSources = [
         "perflib/perflib.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -67,15 +77,14 @@ function build() {
         "includes": includes
     };
 
-    perf_lib = {
+    perfLib = {
         "label": "perflib",
-        "inputs": lib_sources,
+        "inputs": libSources,
         "includes": includes
     };
 
     entries = application(app);
-    entries += shared_library(perf_lib);
+    entries += sharedLibrary(perfLib);
     return entries;
 }
 
-return build();

+ 10 - 3
apps/testapps/sigtest/build.ck

@@ -25,17 +25,25 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "sigtest.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -48,4 +56,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 10 - 3
apps/testapps/socktest/build.ck

@@ -25,17 +25,25 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "socktest.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -48,4 +56,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 10 - 3
apps/testapps/utmrtest/build.ck

@@ -25,17 +25,25 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "utmrtest.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -48,4 +56,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 36 - 25
apps/tzcomp/build.ck

@@ -25,14 +25,27 @@ Environment:
 
 --*/
 
+from menv import application, binplace, group;
+
 function build() {
-    tz_default = "America/Los_Angeles";
+    var almanac;
+    var buildApp;
+    var entries;
+    var sources;
+    var tzcompTool;
+    var tzDataDir = "data/";
+    var tzDataFiles;
+    var tzDefault = "America/Los_Angeles";
+    var tzDefaultConfig;
+    var tzDefaultData;
+    var tzFiles;
+    var tzSourceFiles;
+
     sources = [
         "tzcomp.c",
     ];
 
-    tz_data_dir = "//tzcomp/data/";
-    tz_source_files = [
+    tzSourceFiles = [
         "africa",
         "antarctica",
         "asia",
@@ -44,32 +57,32 @@ function build() {
         "southamerica"
     ];
 
-    tz_files = [];
-    for (file in tz_source_files) {
-        tz_files += [tz_data_dir + file];
+    tzFiles = [];
+    for (file in tzSourceFiles) {
+        tzFiles += [tzDataDir + file];
     }
 
-    build_app = {
+    buildApp = {
         "label": "build_tzcomp",
         "output": "tzcomp",
         "inputs": sources,
-        "build": TRUE
+        "build": true
     };
 
-    entries = application(build_app);
+    entries = application(buildApp);
 
     //
     // Add the tzcomp tool.
     //
 
-    tzcomp_tool = {
+    tzcompTool = {
         "type": "tool",
         "name": "tzcomp",
-        "command": "$^//apps/tzcomp/tzcomp $TZCOMP_FLAGS -o $OUT $IN",
+        "command": "$O/apps/tzcomp/tzcomp $TZCOMP_FLAGS -o $OUT $IN",
         "description": "Compiling Time Zone Data - $OUT"
     };
 
-    entries += [tzcomp_tool];
+    entries += [tzcompTool];
 
     //
     // Add entries for the time zone almanac and time zone default.
@@ -78,37 +91,35 @@ function build() {
     almanac = {
         "type": "target",
         "label": "tzdata",
-        "inputs": tz_files,
+        "inputs": tzFiles,
         "implicit": [":build_tzcomp"],
         "tool": "tzcomp",
-        "nostrip": TRUE
+        "nostrip": true
     };
 
-    tz_default_config = {
-        "TZCOMP_FLAGS": ["-f " + tz_default]
+    tzDefaultConfig = {
+        "TZCOMP_FLAGS": ["-f " + tzDefault]
     };
 
-    tz_default_data = {
+    tzDefaultData = {
         "type": "target",
         "label": "tzdflt",
-        "inputs": tz_files,
+        "inputs": tzFiles,
         "implicit": [":build_tzcomp"],
         "tool": "tzcomp",
-        "config": tz_default_config,
-        "nostrip": TRUE
+        "config": tzDefaultConfig,
+        "nostrip": true
     };
 
     entries += binplace(almanac);
-    entries += binplace(tz_default_data);
+    entries += binplace(tzDefaultData);
 
     //
     // Create a group for the data files.
     //
 
-    tz_data_files = [":tzdata", ":tzdflt"];
-    entries += group("tz_files", tz_data_files);
+    tzDataFiles = [":tzdata", ":tzdflt"];
+    entries += group("tz_files", tzDataFiles);
     return entries;
 }
 
-return build();
-

+ 10 - 3
apps/unmount/build.ck

@@ -25,17 +25,25 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "unmount.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -48,4 +56,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 10 - 3
apps/vmstat/build.ck

@@ -26,17 +26,25 @@ Environment:
 
 --*/
 
+from menv import application;
+
 function build() {
+    var app;
+    var dynlibs;
+    var entries;
+    var includes;
+    var sources;
+
     sources = [
         "vmstat.c"
     ];
 
     dynlibs = [
-        "//apps/osbase:libminocaos"
+        "apps/osbase:libminocaos"
     ];
 
     includes = [
-        "$//apps/libc/include"
+        "$S/apps/libc/include"
     ];
 
     app = {
@@ -49,4 +57,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 82 - 57
boot/bootman/build.ck

@@ -27,13 +27,39 @@ Environment:
 
 --*/
 
+from menv import application, binplace, executable, flattenedBinary, mconfig;
+
 function build() {
-    common_sources = [
+    var arch = mconfig.arch;
+    var baseLibs;
+    var bootmanPe;
+    var commonLibs;
+    var commonSources;
+    var efiApp;
+    var efiAppLibs;
+    var efiLibs;
+    var efiLinkConfig;
+    var efiLinkLdflags;
+    var efiSources;
+    var elfconvConfig;
+    var entries;
+    var flattened;
+    var includes;
+    var linkerScript;
+    var pcatApp;
+    var pcatAppLibs;
+    var pcatLibs;
+    var pcatLinkConfig;
+    var pcatLinkLdflags;
+    var pcatSources;
+    var sourcesConfig;
+
+    commonSources = [
         "bootman.c",
         "bootim.c"
     ];
 
-    pcat_sources = [
+    pcatSources = [
         "pcat/x86/entry.S",
         ":bootman.o",
         ":bootim.o",
@@ -41,53 +67,53 @@ function build() {
         "pcat/main.c",
     ];
 
-    efi_sources = [
+    efiSources = [
         "efi/bootxfr.c",
         "efi/main.c"
     ];
 
     includes = [
-        "$//boot/lib/include",
-        "$//boot/bootman"
+        "$S/boot/lib/include",
+        "$S/boot/bootman"
     ];
 
-    sources_config = {
+    sourcesConfig = {
         "CFLAGS": ["-fshort-wchar"],
     };
 
-    efi_link_ldflags = [
+    efiLinkLdflags = [
         "-nostdlib",
         "-pie",
         "-static",
     ];
 
-    pcat_link_ldflags = [
+    pcatLinkLdflags = [
         "-nostdlib",
         "-static"
     ];
 
-    efi_libs = [
-        "//boot/lib:bootefi",
+    efiLibs = [
+        "boot/lib:bootefi",
     ];
 
     if ((arch == "armv7") || (arch == "armv6")) {
-        linker_script = "$//uefi/include/link_arm.x";
-        efi_link_ldflags += [
+        linkerScript = "$S/uefi/include/link_arm.x";
+        efiLinkLdflags += [
             "-Wl,--no-wchar-size-warning"
         ];
 
-        efi_libs = ["//kernel:archboot"] + efi_libs;
+        efiLibs = ["kernel:archboot"] + efiLibs;
 
     } else if (arch == "x86") {
-        linker_script = "$//uefi/include/link_x86.x";
+        linkerScript = "$S/uefi/include/link_x86.x";
     }
 
-    efi_link_config = {
-        "LDFLAGS": efi_link_ldflags
+    efiLinkConfig = {
+        "LDFLAGS": efiLinkLdflags
     };
 
-    pcat_link_config = {
-        "LDFLAGS": pcat_link_ldflags
+    pcatLinkConfig = {
+        "LDFLAGS": pcatLinkLdflags
     };
 
     //
@@ -95,77 +121,77 @@ function build() {
     // must go after the boot library.
     //
 
-    base_libs = [
-        "//lib/basevid:basevid",
-        "//lib/fatlib:fat",
-        "//kernel/mm:mmboot",
-        "//lib/rtl/kmode:krtl",
-        "//lib/rtl/base:basertlb"
+    baseLibs = [
+        "lib/basevid:basevid",
+        "lib/fatlib:fat",
+        "kernel/mm:mmboot",
+        "lib/rtl/kmode:krtl",
+        "lib/rtl/base:basertlb"
     ];
 
-    common_libs = [
-        "//kernel/kd:kdboot",
-        "//kernel/hl:hlboot",
-        "//lib/im:im",
-        "//lib/bconflib:bconf",
-        "//kernel/kd/kdusb:kdnousb"
+    commonLibs = [
+        "kernel/kd:kdboot",
+        "kernel/hl:hlboot",
+        "lib/im:im",
+        "lib/bconflib:bconf",
+        "kernel/kd/kdusb:kdnousb"
     ];
 
-    pcat_libs = [
-        "//boot/lib:bootpcat",
-        "//lib/partlib:partlib"
+    pcatLibs = [
+        "boot/lib:bootpcat",
+        "lib/partlib:partlib"
     ];
 
-    efi_app_libs = common_libs + efi_libs + base_libs;
-    efi_app = {
+    efiAppLibs = commonLibs + efiLibs + baseLibs;
+    efiApp = {
         "label": "bootmefi.elf",
-        "inputs": common_sources + efi_sources + efi_app_libs,
-        "sources_config": sources_config,
+        "inputs": commonSources + efiSources + efiAppLibs,
+        "sources_config": sourcesConfig,
         "includes": includes,
-        "config": efi_link_config,
+        "config": efiLinkConfig,
         "entry": "BmEfiApplicationMain",
-        "linker_script": linker_script
+        "linker_script": linkerScript
     };
 
-    entries = application(efi_app);
+    entries = application(efiApp);
 
     //
     // Convert the ELF image into an EFI PE image.
     //
 
-    elfconv_config = {
+    elfconvConfig = {
         "ELFCONV_FLAGS": "-t efiapp"
     };
 
-    bootman_pe = {
+    bootmanPe = {
         "type": "target",
         "label": "bootmefi.efi",
         "inputs": [":bootmefi.elf"],
-        "implicit": ["//uefi/tools/elfconv:elfconv"],
+        "implicit": ["uefi/tools/elfconv:elfconv"],
         "tool": "elfconv",
-        "config": elfconv_config,
-        "nostrip": TRUE
+        "config": elfconvConfig,
+        "nostrip": true
     };
 
-    entries += binplace(bootman_pe);
+    entries += binplace(bootmanPe);
 
     //
     // On PC machines, build the BIOS library as well.
     //
 
     if (arch == "x86") {
-        pcat_app_libs = common_libs + pcat_libs + base_libs;
-        pcat_app = {
+        pcatAppLibs = commonLibs + pcatLibs + baseLibs;
+        pcatApp = {
             "label": "bootman.elf",
-            "inputs": pcat_sources + pcat_app_libs,
-            "sources_config": sources_config,
+            "inputs": pcatSources + pcatAppLibs,
+            "sources_config": sourcesConfig,
             "includes": includes,
-            "config": pcat_link_config,
+            "config": pcatLinkConfig,
             "text_address": "0x100000",
-            "binplace": TRUE
+            "binplace": true
         };
 
-        entries += executable(pcat_app);
+        entries += executable(pcatApp);
 
         //
         // Flatten the image so the VBR can load it directly into memory.
@@ -174,15 +200,14 @@ function build() {
         flattened = {
             "label": "bootman.bin",
             "inputs": [":bootman.elf"],
-            "binplace": TRUE,
-            "nostrip": TRUE
+            "binplace": true,
+            "nostrip": true
         };
 
-        flattened = flattened_binary(flattened);
+        flattened = flattenedBinary(flattened);
         entries += flattened;
     }
 
     return entries;
 }
 
-return build();

+ 15 - 10
boot/build.ck

@@ -28,23 +28,28 @@ Environment:
 
 --*/
 
+from menv import group, mconfig;
+
 function build() {
-    boot_apps = [
-        "//boot/bootman:bootmefi.efi",
-        "//boot/loader:loadefi"
+    var arch = mconfig.arch;
+    var bootApps;
+    var entries;
+
+    bootApps = [
+        "boot/bootman:bootmefi.efi",
+        "boot/loader:loadefi"
     ];
 
     if (arch == "x86") {
-        boot_apps += [
-            "//boot/bootman:bootman.bin",
-            "//boot/fatboot:fatboot.bin",
-            "//boot/loader:loader",
-            "//boot/mbr:mbr.bin"
+        bootApps += [
+            "boot/bootman:bootman.bin",
+            "boot/fatboot:fatboot.bin",
+            "boot/loader:loader",
+            "boot/mbr:mbr.bin"
         ];
     }
 
-    entries = group("boot_apps", boot_apps);
+    entries = group("boot_apps", bootApps);
     return entries;
 }
 
-return build();

+ 22 - 13
boot/fatboot/build.ck

@@ -28,36 +28,46 @@ Environment:
 
 --*/
 
+from menv import executable, flattenedBinary;
+
 function build() {
+    var entries;
+    var flattened;
+    var image;
+    var linkConfig;
+    var linkLdflags;
+    var includes;
+    var sources;
+
     sources = [
         "vbr.S",
         "fatboot.c",
         "prochw.c",
-        "//boot/lib:x86/archsup.o",
-        "//boot/lib:pcat/realmode.o",
-        "//boot/lib:pcat/realmexe.o"
+        "boot/lib:x86/archsup.o",
+        "boot/lib:pcat/realmode.o",
+        "boot/lib:pcat/realmexe.o"
     ];
 
     includes = [
-        "$//boot/lib/include",
-        "$//boot/lib/pcat"
+        "$S/boot/lib/include",
+        "$S/boot/lib/pcat"
     ];
 
-    link_ldflags = [
+    linkLdflags = [
         "-nostdlib",
         "-Wl,-zmax-page-size=1",
         "-static"
     ];
 
-    link_config = {
-        "LDFLAGS": link_ldflags
+    linkConfig = {
+        "LDFLAGS": linkLdflags
     };
 
     image = {
         "label": "fatboot.elf",
         "inputs": sources,
         "includes": includes,
-        "config": link_config,
+        "config": linkConfig,
         "text_address": "0x7C00",
     };
 
@@ -71,13 +81,12 @@ function build() {
     flattened = {
         "label": "fatboot.bin",
         "inputs": [":fatboot.elf"],
-        "binplace": TRUE,
-        "nostrip": TRUE
+        "binplace": true,
+        "nostrip": true
     };
 
-    flattened = flattened_binary(flattened);
+    flattened = flattenedBinary(flattened);
     entries += flattened;
     return entries;
 }
 
-return build();

+ 45 - 30
boot/lib/build.ck

@@ -25,8 +25,24 @@ Environment:
 
 --*/
 
+from menv import addConfig, compiledSources, mconfig, staticLibrary;
+
 function build() {
-    common_sources = [
+    var arch = mconfig.arch;
+    var commonArmEfiSources;
+    var commonArmSources;
+    var commonLib;
+    var commonList;
+    var commonSources;
+    var entries;
+    var includes;
+    var efiLib;
+    var efiSources;
+    var pcatLib;
+    var pcatSources;
+    var sourcesConfig;
+
+    commonSources = [
         "bootfat.c",
         "bootmem.c",
         "file.c",
@@ -34,7 +50,7 @@ function build() {
         "version.c"
     ];
 
-    pcat_sources = [
+    pcatSources = [
         "pcat/fwapi.c",
         "pcat/int10.c",
         "pcat/int13.c",
@@ -46,7 +62,7 @@ function build() {
         "pcat/time.c"
     ];
 
-    efi_sources = [
+    efiSources = [
         "efi/dbgser.c",
         "efi/disk.c",
         "efi/fwapi.c",
@@ -56,60 +72,60 @@ function build() {
         "efi/video.c"
     ];
 
-    common_arm_sources = [
+    commonArmSources = [
         "armv7/commsup.S",
         "armv7/inttable.S",
         "armv7/prochw.c"
     ];
 
-    common_arm_efi_sources = [
+    commonArmEfiSources = [
         "efi/armv7/efia.S",
         "efi/armv7/efiarch.c"
     ];
 
     if (arch == "armv7") {
-        common_sources += common_arm_sources + [
+        commonSources += commonArmSources + [
             "armv7/archsup.S"
         ];
 
-        efi_sources += common_arm_efi_sources;
+        efiSources += commonArmEfiSources;
 
     } else if (arch == "armv6") {
-        common_sources += common_arm_sources + [
+        commonSources += commonArmSources + [
             "armv6/archsup.S"
         ];
 
-        efi_sources += common_arm_efi_sources;
+        efiSources += commonArmEfiSources;
 
     } else if (arch == "x86") {
-        common_sources += [
+        commonSources += [
             "x86/archsup.S",
             "x86/prochw.c"
         ];
 
-        efi_sources += [
+        efiSources += [
             "efi/x86/efia.S",
             "efi/x86/efiarch.c"
         ];
     }
 
     includes = [
-        "$//boot/lib/include",
-        "$//boot/lib"
+        "$S/boot/lib/include",
+        "$S/boot/lib"
     ];
 
-    sources_config = {
+    sourcesConfig = {
         "CFLAGS": ["-fshort-wchar"],
     };
 
-    common_lib = {
-        "inputs": common_sources,
-        "sources_config": sources_config,
+    commonLib = {
+        "inputs": commonSources,
+        "sources_config": sourcesConfig,
         "includes": includes
     };
 
-    common_list = compiled_sources(common_lib);
-    entries = common_list[1];
+    commonList = compiledSources(commonLib);
+    entries = commonList[1];
 
     //
     // Add the include and dependency for version.c, which uses the kernel's
@@ -118,36 +134,35 @@ function build() {
 
     for (entry in entries) {
         if (entry["output"] == "version.o") {
-            add_config(entry, "CPPFLAGS", "-I$^/kernel");
-            entry["implicit"] = ["//kernel:version.h"];
+            addConfig(entry, "CPPFLAGS", "-I$O/kernel");
+            entry["implicit"] = ["kernel:version.h"];
             break;
         }
     }
 
-    efi_lib = {
+    efiLib = {
         "label": "bootefi",
-        "inputs": common_list[0] + efi_sources,
-        "sources_config": sources_config
+        "inputs": commonList[0] + efiSources,
+        "sources_config": sourcesConfig
     };
 
-    entries += static_library(efi_lib);
+    entries += staticLibrary(efiLib);
 
     //
     // On PC machines, build the BIOS library as well.
     //
 
     if (arch == "x86") {
-        pcat_lib = {
+        pcatLib = {
             "label": "bootpcat",
-            "inputs": common_list[0] + pcat_sources,
-            "sources_config": sources_config,
+            "inputs": commonList[0] + pcatSources,
+            "sources_config": sourcesConfig,
             "includes": includes
         };
 
-        entries += static_library(pcat_lib);
+        entries += staticLibrary(pcatLib);
     }
 
     return entries;
 }
 
-return build();

+ 73 - 50
boot/loader/build.ck

@@ -27,67 +27,91 @@ Environment:
 
 --*/
 
+from menv import application, mconfig;
+
 function build() {
-    common_sources = [
+    var arch = mconfig.arch;
+    var baseLibs;
+    var commonArmSources;
+    var commonLibs;
+    var commonSources;
+    var efiApp;
+    var efiAppLibs;
+    var efiLibs;
+    var efiLinkConfig;
+    var efiLinkLdflags;
+    var efiSources;
+    var entries;
+    var includes;
+    var linkLdflags;
+    var pcatApp;
+    var pcatAppLibs;
+    var pcatLibs;
+    var pcatLinkConfig;
+    var pcatLinkLdflags;
+    var pcatSources;
+    var sourcesConfig;
+
+    commonSources = [
         "bootim.c",
         "dbgport.c",
         "loader.c"
     ];
 
-    pcat_sources = [
+    pcatSources = [
         "pcat/memory.c",
     ];
 
-    efi_sources = [
+    efiSources = [
         "efi/memory.c",
     ];
 
     includes = [
-        "$//boot/lib/include",
-        "$//boot/loader"
+        "$S/boot/lib/include",
+        "$S/boot/loader"
     ];
 
-    sources_config = {
+    sourcesConfig = {
         "CFLAGS": ["-fshort-wchar"],
     };
 
-    link_ldflags = [
+    linkLdflags = [
         "-nostdlib",
         "-pie",
         "-static"
     ];
 
-    efi_libs = [
-        "//boot/lib:bootefi"
+    efiLibs = [
+        "boot/lib:bootefi"
     ];
 
     if ((arch == "armv7") || (arch == "armv6")) {
-        common_arm_sources = [
+        commonArmSources = [
             "armv7/dbgparch.c",
             "armv7/paging.c",
             "armv7/kernxfr.S"
         ];
 
         if (arch == "armv7") {
-            common_sources += common_arm_sources + [
+            commonSources += commonArmSources + [
                 "armv7/archsupc.c"
             ];
 
         } else {
-            common_sources += common_arm_sources + [
+            commonSources += commonArmSources + [
                 "armv6/archsupc.c"
             ];
         }
 
-        efi_link_ldflags = link_ldflags + [
+        efiLinkLdflags = linkLdflags + [
             "-Wl,--no-wchar-size-warning"
         ];
 
-        efi_libs = ["//kernel:archboot"] + efi_libs;
+        efiLibs = ["kernel:archboot"] + efiLibs;
 
     } else if (arch == "x86") {
-        efi_link_ldflags = link_ldflags;
-        common_sources += [
+        efiLinkLdflags = linkLdflags;
+        commonSources += [
             "x86/archsupc.c",
             "x86/dbgparch.c",
             "x86/entry.S",
@@ -96,12 +120,12 @@ function build() {
         ];
     }
 
-    efi_link_config = {
-        "LDFLAGS": efi_link_ldflags
+    efiLinkConfig = {
+        "LDFLAGS": efiLinkLdflags
     };
 
-    pcat_link_config = {
-        "LDFLAGS": link_ldflags
+    pcatLinkConfig = {
+        "LDFLAGS": linkLdflags
     };
 
     //
@@ -109,61 +133,60 @@ function build() {
     // must go after the boot library.
     //
 
-    base_libs = [
-        "//lib/basevid:basevid",
-        "//lib/fatlib:fat",
-        "//kernel/mm:mmboot",
-        "//lib/rtl/kmode:krtl",
-        "//lib/rtl/base:basertlb"
+    baseLibs = [
+        "lib/basevid:basevid",
+        "lib/fatlib:fat",
+        "kernel/mm:mmboot",
+        "lib/rtl/kmode:krtl",
+        "lib/rtl/base:basertlb"
     ];
 
-    common_libs = [
-        "//kernel/kd:kdboot",
-        "//kernel/hl:hlboot",
-        "//lib/im:im",
-        "//lib/bconflib:bconf",
-        "//kernel/kd/kdusb:kdnousb"
+    commonLibs = [
+        "kernel/kd:kdboot",
+        "kernel/hl:hlboot",
+        "lib/im:im",
+        "lib/bconflib:bconf",
+        "kernel/kd/kdusb:kdnousb"
     ];
 
-    pcat_libs = [
-        "//boot/lib:bootpcat",
-        "//lib/partlib:partlib"
+    pcatLibs = [
+        "boot/lib:bootpcat",
+        "lib/partlib:partlib"
     ];
 
-    efi_app_libs = common_libs + efi_libs + base_libs;
-    efi_app = {
+    efiAppLibs = commonLibs + efiLibs + baseLibs;
+    efiApp = {
         "label": "loadefi",
-        "inputs": common_sources + efi_sources + efi_app_libs,
-        "sources_config": sources_config,
+        "inputs": commonSources + efiSources + efiAppLibs,
+        "sources_config": sourcesConfig,
         "includes": includes,
-        "config": efi_link_config,
+        "config": efiLinkConfig,
         "entry": "BoMain",
-        "binplace": TRUE
+        "binplace": true
     };
 
-    entries = application(efi_app);
+    entries = application(efiApp);
 
     //
     // On PC machines, build the BIOS loader as well.
     //
 
     if (arch == "x86") {
-        pcat_app_libs = common_libs + pcat_libs + base_libs;
-        pcat_app = {
+        pcatAppLibs = commonLibs + pcatLibs + baseLibs;
+        pcatApp = {
             "label": "loader",
-            "inputs": common_sources + pcat_sources + pcat_app_libs,
-            "sources_config": sources_config,
+            "inputs": commonSources + pcatSources + pcatAppLibs,
+            "sources_config": sourcesConfig,
             "includes": includes,
-            "config": pcat_link_config,
+            "config": pcatLinkConfig,
             "entry": "BoMain",
             "prefix": "pcat",
-            "binplace": TRUE
+            "binplace": true
         };
 
-        entries += application(pcat_app);
+        entries += application(pcatApp);
     }
 
     return entries;
 }
 
-return build();

+ 16 - 8
boot/mbr/build.ck

@@ -26,25 +26,34 @@ Environment:
 
 --*/
 
+from menv import executable, flattenedBinary;
+
 function build() {
+    var entries;
+    var flattened;
+    var image;
+    var linkConfig;
+    var linkLdFlags;
+    var sources;
+
     sources = [
         "mbr.S"
     ];
 
-    link_ldflags = [
+    linkLdFlags = [
         "-nostdlib",
         "-Wl,-zmax-page-size=1",
         "-static"
     ];
 
-    link_config = {
-        "LDFLAGS": link_ldflags
+    linkConfig = {
+        "LDFLAGS": linkLdFlags
     };
 
     image = {
         "label": "mbr.elf",
         "inputs": sources,
-        "config": link_config,
+        "config": linkConfig,
         "text_address": "0x600",
     };
 
@@ -58,13 +67,12 @@ function build() {
     flattened = {
         "label": "mbr.bin",
         "inputs": [":mbr.elf"],
-        "binplace": TRUE,
-        "nostrip": TRUE
+        "binplace": true,
+        "nostrip": true
     };
 
-    flattened = flattened_binary(flattened);
+    flattened = flattenedBinary(flattened);
     entries += flattened;
     return entries;
 }
 
-return build();

+ 2 - 294
build.ck

@@ -30,305 +30,13 @@ from menv import setupEnv, group;
 
 function build() {
     var allGroup;
-    var buildCflagsLine = "$BUILD_BASE_CPPFLAGS $CPPFLAGS " +
-                          "$BUILD_BASE_CFLAGS $CFLAGS -MMD -MF $OUT.d ";
-
-    var buildAsflagsLine = buildCflagsLine +
-                           "$BUILD_BASE_ASFLAGS $ASFLAGS ";
-
-    var buildLdflagsLine = "-Wl,-Map=$OUT.map $BUILD_BASE_LDFLAGS $LDFLAGS ";
-    var cflagsLine = "$BASE_CPPFLAGS $CPPFLAGS $BASE_CFLAGS $CFLAGS "
-                     "-MMD -MF $OUT.d ";
-
-    var asflagsLine = cflagsLine + "$BASE_ASFLAGS $ASFLAGS ";
     var entries;
-    var ldflagsLine = "-Wl,-Map=$OUT.map $BASE_LDFLAGS $LDFLAGS ";
-    var mconfig;
-    var symlinkCommand = "ln -sf $SYMLINK_IN $OUT";
-    var buildLdLine = "$BUILD_CC " + buildLdflagsLine +
-                      "-o $OUT $IN -Bdynamic $DYNLIBS";
-
     var tools;
 
-    setupEnv();
-    mconfig = menv.mconfig;
-    if (mconfig.build_os == "Windows") {
-        symlinkCommand = "cp $IN $OUT";
-    }
-
-    //
-    // On Mac OS there shouldn't be a -Bdynamic flag to indicate the start of
-    // the dynamic libraries section.
-    //
-
-    if (mconfig.build_os == "Darwin") {
-        buildLdLine = "$BUILD_CC " + buildLdflagsLine +
-                      "-o $OUT $IN $DYNLIBS";
-    }
-
-    //
-    // Define the tools used.
-    //
-
-    tools = [
-
-    //
-    // C compiler for target binaries.
-    //
-
-    {
-        "type": "tool",
-        "name": "cc",
-        "command": "$CC " + cflagsLine + "-c -o $OUT $IN",
-        "description": "Compiling - $IN",
-        "depsformat": "gcc",
-        "depfile": "$OUT.d"
-    },
-
-    //
-    // C++ compiler for target binaries.
-    //
-
-    {
-        "type": "tool",
-        "name": "cxx",
-        "command": "$CXX " + cflagsLine + "-c -o $OUT $IN",
-        "description": "Compiling - $IN",
-        "depsformat": "gcc",
-        "depfile": "$OUT.d"
-    },
-
-    //
-    // Linker for target binaries.
-    //
-
-    {
-        "type": "tool",
-        "name": "ld",
-        "command": "$CC " + ldflagsLine + "-o $OUT $IN -Bdynamic $DYNLIBS",
-        "description": "Linking - $OUT",
-    },
-
-    //
-    // Static archiver for target binaries.
-    //
-
-    {
-        "type": "tool",
-        "name": "ar",
-        "command": "$AR rcs $OUT $IN",
-        "description": "Building Library - $OUT",
-    },
-
-    //
-    // Assembler for target binaries.
-    //
-
-    {
-        "type": "tool",
-        "name": "as",
-        "command": "$CC " + asflagsLine + "-c -o $OUT $IN",
-        "description": "Assembling - $IN",
-        "depsformat": "gcc",
-        "depfile": "$OUT.d"
-    },
-
-    //
-    // Objcopy for target binaries.
-    //
-
-    {
-        "type": "tool",
-        "name": "objcopy",
-        "command": "$SHELL -c \"cd `dirname $IN` && $OBJCOPY $OBJCOPY_FLAGS `basename $IN` $OUT\"",
-        "description": "Objectifying - $IN"
-    },
-
-    //
-    // Strip for target binaries.
-    //
-
-    {
-        "type": "tool",
-        "name": "strip",
-        "command": "$STRIP $STRIP_FLAGS -o $OUT $IN",
-        "description": "Stripping - $OUT",
-    },
-
-    //
-    // C compiler for the build machine.
-    //
-
-    {
-        "type": "tool",
-        "name": "build_cc",
-        "command": "$BUILD_CC " + buildCflagsLine + "-c -o $OUT $IN",
-        "description": "Compiling - $IN",
-        "depsformat": "gcc",
-        "depfile": "$OUT.d"
-    },
-
-    //
-    // C++ compiler for the build machine.
-    //
-
-    {
-        "type": "tool",
-        "name": "build_cxx",
-        "command": "$BUILD_CXX " + buildCflagsLine + "-c -o $OUT $IN",
-        "description": "Compiling - $IN",
-        "depsformat": "gcc",
-        "depfile": "$OUT.d"
-    },
-
-    //
-    // Linker for the build machine.
-    //
-
-    {
-        "type": "tool",
-        "name": "build_ld",
-        "command": "$BUILD_CC " + buildLdflagsLine + "-o $OUT $IN -Bdynamic $DYNLIBS",
-        "description": "Linking - $OUT",
-    },
-
-    //
-    // Static archiver for the build machine.
-    //
-
-    {
-        "type": "tool",
-        "name": "build_ar",
-        "command": "$BUILD_AR rcs $OUT $IN",
-        "description": "Building Library - $OUT",
-    },
-
-    //
-    // Assembler for the build machine.
-    //
-
-    {
-        "type": "tool",
-        "name": "build_as",
-        "command": "$BUILD_CC " + buildAsflagsLine + "-c -o $OUT $IN",
-        "description": "Assembling - $IN",
-        "depsformat": "gcc",
-        "depfile": "$OUT.d"
-    },
-
-    //
-    // Strip for the build machine.
-    //
-
-    {
-        "type": "tool",
-        "name": "build_strip",
-        "command": "$BUILD_STRIP $STRIP_FLAGS -o $OUT $IN",
-        "description": "Stripping - $OUT",
-    },
-
-    //
-    // Windows resource compiler for the build machine.
-    //
-
-    {
-        "type": "tool",
-        "name": "build_rcc",
-        "command": "$RCC -o $OUT $IN",
-        "description": "Compiling Resource - $IN",
-    },
-
-    //
-    // ACPI assembler used to build firmware images.
-    //
-
-    {
-        "type": "tool",
-        "name": "iasl",
-        "command": "$SHELL -c \"$IASL $IASL_FLAGS -p $OUT $IN > $OUT.stdout\"",
-        "description": "Compiling ASL - $IN"
-    },
-
-    //
-    // Copy files from one location to another.
-    //
-
-    {
-        "type": "tool",
-        "name": "copy",
-        "command": "$SHELL -c \"cp $CPFLAGS $IN $OUT && [ -z $CHMOD_FLAGS ] || chmod $CHMOD_FLAGS $OUT\"",
-        "description": "Copying - $IN -> $OUT"
-    },
-
-    //
-    // Create symbolic links (or just copy on Windows).
-    //
-
-    {
-        "type": "tool",
-        "name": "symlink",
-        "command": symlinkCommand,
-        "description": "Symlinking - $OUT"
-    },
-
-    //
-    // Touch a file with the date.
-    //
-
-    {
-        "type": "tool",
-        "name": "stamp",
-        "command": "$SHELL -c \"date > $OUT\"",
-        "description": "Stamp - $OUT"
-    },
-
-    //
-    // Touch to create a timestamped empty file.
-    //
-
-    {
-        "type": "tool",
-        "name": "touch",
-        "command": "touch $OUT",
-        "description": "Touch - $OUT"
-    },
-
-    //
-    // Generate a version.h.
-    //
-
-    {
-        "type": "tool",
-        "name": "gen_version",
-        "command": "$SHELL $S/tasks/build/print_version.sh $OUT $FORM $MAJOR $MINOR $REVISION $RELEASE $SERIAL $BUILD_STRING",
-        "description": "Versioning - $OUT"
-    }];
-
+    tools = setupEnv();
     entries = [
-        "lib/basevid:basevid",
-        "lib/basevid:build_basevid",
-        "lib/bconflib:bconf",
-        "lib/bconflib:build_bconf",
-        "lib/crypto:crypto",
-        "lib/crypto:build_crypto",
-        "lib/crypto/ssl:ssl",
-        "lib/crypto/testcryp:build_testcryp",
-        "lib/rtl/testrtl:build_testrtl",
-        "lib/fatlib:fat",
-        "lib/fatlib/fattest:build_fattest",
-        "lib/im:im",
-        "lib/im:build_im",
-        "lib/partlib:partlib",
-        "lib/partlib:build_partlib",
-        "lib/termlib:termlib",
-        "lib/termlib:build_termlib",
-        "lib/yy:yy",
-        "lib/yy:build_yy",
-        "lib/yy/yytest:build_yytest",
-        "lib/yy/gen:yygen",
-        "lib/yy/gen:build_yygen",
         "lib:test_apps",
-        "kernel:kernel"
+        "images:"
     ];
 
     allGroup = group("all", entries);

+ 7 - 1
drivers/acpi/build.ck

@@ -29,7 +29,14 @@ Environment:
 
 --*/
 
+from menv import driver, mconfig;
+
 function build() {
+    var arch = mconfig.arch;
+    var drv;
+    var entries;
+    var sources;
+
     sources = [
         "acpidrv.c",
         "aml.c",
@@ -67,4 +74,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 49 - 0
drivers/ahci/build.ck

@@ -0,0 +1,49 @@
+/*++
+
+Copyright (c) 2017 Minoca Corp.
+
+    This file is licensed under the terms of the GNU General Public License
+    version 3. Alternative licensing terms are available. Contact
+    info@minocacorp.com for details. See the LICENSE file at the root of this
+    project for complete licensing information.
+
+Module Name:
+
+    AHCI
+
+Abstract:
+
+    This module implements the driver for AHCI storage controller.
+
+Author:
+
+    Evan Green 15-Feb-2016
+
+Environment:
+
+    Kernel
+
+--*/
+
+from menv import driver;
+
+function build() {
+    var drv;
+    var entries;
+    var name = "ahci";
+    var sources;
+
+    sources = [
+        "ahci.c",
+        "ahcihw.c"
+    ];
+
+    drv = {
+        "label": name,
+        "inputs": sources,
+    };
+
+    entries = driver(drv);
+    return entries;
+}
+

+ 7 - 2
drivers/ata/build.ck

@@ -25,8 +25,14 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "ata";
+    var drv;
+    var entries;
+    var name = "ata";
+    var sources;
+
     sources = [
         "ata.c"
     ];
@@ -40,4 +46,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 28 - 22
drivers/build.ck

@@ -22,36 +22,43 @@ Author:
 
 Environment:
 
-    Debug
+    Build
 
 --*/
 
+from menv import group, mconfig;
+
 function build() {
+    var arch = mconfig.arch;
+    var drivers;
+    var entries;
+
     drivers = [
-        "//drivers/acpi:acpi",
-        "//drivers/ata:ata",
-        "//drivers/devrem:devrem",
-        "//drivers/fat:fat",
-        "//drivers/i8042:i8042",
-        "//drivers/net:net_drivers",
-        "//drivers/null:null",
-        "//drivers/part:part",
-        "//drivers/pci:pci",
-        "//drivers/plat:platform_drivers",
-        "//drivers/ramdisk:ramdisk",
-        "//drivers/sd:sd_drivers",
-        "//drivers/special:special",
-        "//drivers/term/ser16550:ser16550",
-        "//drivers/usb:usb_drivers",
-        "//drivers/videocon:videocon"
+        "drivers/acpi:acpi",
+        "drivers/ahci:ahci",
+        "drivers/ata:ata",
+        "drivers/devrem:devrem",
+        "drivers/fat:fat",
+        "drivers/i8042:i8042",
+        "drivers/net:net_drivers",
+        "drivers/null:null",
+        "drivers/part:part",
+        "drivers/pci:pci",
+        "drivers/plat:platform_drivers",
+        "drivers/ramdisk:ramdisk",
+        "drivers/sd:sd_drivers",
+        "drivers/special:special",
+        "drivers/term/ser16550:ser16550",
+        "drivers/usb:usb_drivers",
+        "drivers/videocon:videocon"
     ];
 
     if ((arch == "armv7") || (arch == "armv6")) {
         drivers += [
-            "//drivers/dma:dma_drivers",
-            "//drivers/gpio:gpio_drivers",
-            "//drivers/i8042/pl050:pl050",
-            "//drivers/spb:spb_drivers"
+            "drivers/dma:dma_drivers",
+            "drivers/gpio:gpio_drivers",
+            "drivers/i8042/pl050:pl050",
+            "drivers/spb:spb_drivers"
         ];
     }
 
@@ -59,4 +66,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 7 - 2
drivers/devrem/build.ck

@@ -25,8 +25,14 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "devrem";
+    var drv;
+    var entries;
+    var name = "devrem";
+    var sources;
+
     sources = [
         "devrem.c"
     ];
@@ -40,4 +46,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/dma/bcm2709/build.ck

@@ -25,14 +25,21 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "dmab2709";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "dmab2709";
+    var sources;
+
     sources = [
         "dmab2709.c"
     ];
 
     dynlibs = [
-        "//drivers/dma/core:dma"
+        "drivers/dma/core:dma"
     ];
 
     drv = {
@@ -44,4 +51,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 12 - 6
drivers/dma/build.ck

@@ -25,17 +25,23 @@ Environment:
 
 --*/
 
+from menv import group, mconfig;
+
 function build() {
+    var arch = mconfig.arch;
+    var dmaDrivers;
+    var entries;
 
-    assert(((arch == "armv7") || (arch == "armv6")), "Unexpected architecture");
+    if (!(["armv7", "armv6"].contains(arch))) {
+        Core.raise(ValueError("Unexpected Architecture"));
+    }
 
-    dma_drivers = [
-        "//drivers/dma/bcm2709:dmab2709",
-        "//drivers/dma/edma3:edma3",
+    dmaDrivers = [
+        "drivers/dma/bcm2709:dmab2709",
+        "drivers/dma/edma3:edma3",
     ];
 
-    entries = group("dma_drivers", dma_drivers);
+    entries = group("dma_drivers", dmaDrivers);
     return entries;
 }
 
-return build();

+ 7 - 2
drivers/dma/core/build.ck

@@ -26,8 +26,14 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "dma";
+    var drv;
+    var entries;
+    var name = "dma";
+    var sources;
+
     sources = [
         "dma.c"
     ];
@@ -41,4 +47,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/dma/edma3/build.ck

@@ -25,14 +25,21 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "edma3";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "edma3";
+    var sources;
+
     sources = [
         "edma3.c"
     ];
 
     dynlibs = [
-        "//drivers/dma/core:dma"
+        "drivers/dma/core:dma"
     ];
 
     drv = {
@@ -44,4 +51,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/fat/build.ck

@@ -26,15 +26,22 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "fat";
+    var drv;
+    var entries;
+    var libs;
+    var name = "fat";
+    var sources;
+
     sources = [
         "fatfs.c",
         "fatio.c"
     ];
 
     libs = [
-        "//lib/fatlib:fat"
+        "lib/fatlib:fat"
     ];
 
     drv = {
@@ -46,4 +53,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/gpio/broadcom/bc27/build.ck

@@ -26,14 +26,21 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "bc27gpio";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "bc27gpio";
+    var sources;
+
     sources = [
         "bc27gpio.c"
     ];
 
     dynlibs = [
-        "//drivers/gpio/core:gpio"
+        "drivers/gpio/core:gpio"
     ];
 
     drv = {
@@ -45,4 +52,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 15 - 9
drivers/gpio/build.ck

@@ -25,18 +25,24 @@ Environment:
 
 --*/
 
-function build() {
-
-    assert(((arch == "armv7") || (arch == "armv6")), "Unexpected architecture");
+from menv import group, mconfig;
 
-    gpio_drivers = [
-        "//drivers/gpio/broadcom/bc27:bc27gpio",
-        "//drivers/gpio/rockchip/rk32:rk32gpio",
-        "//drivers/gpio/ti/omap4:om4gpio",
+function build() {
+    var arch = mconfig.arch;
+    var entries;
+    var gpioDrivers;
+
+    if ((arch != "armv7") && (arch != "armv6")) {
+        Core.raise(ValueError("UnexpectedArchitecture"));
+    }
+
+    gpioDrivers = [
+        "drivers/gpio/broadcom/bc27:bc27gpio",
+        "drivers/gpio/rockchip/rk32:rk32gpio",
+        "drivers/gpio/ti/omap4:om4gpio",
     ];
 
-    entries = group("gpio_drivers", gpio_drivers);
+    entries = group("gpio_drivers", gpioDrivers);
     return entries;
 }
 
-return build();

+ 7 - 2
drivers/gpio/core/build.ck

@@ -26,8 +26,14 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "gpio";
+    var drv;
+    var entries;
+    var name = "gpio";
+    var sources;
+
     sources = [
         "gpio.c"
     ];
@@ -41,4 +47,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/gpio/rockchip/rk32/build.ck

@@ -26,14 +26,21 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "rk32gpio";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "rk32gpio";
+    var sources;
+
     sources = [
         "rk32gpio.c"
     ];
 
     dynlibs = [
-        "//drivers/gpio/core:gpio"
+        "drivers/gpio/core:gpio"
     ];
 
     drv = {
@@ -45,4 +52,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/gpio/ti/omap4/build.ck

@@ -26,14 +26,21 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "om4gpio";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "om4gpio";
+    var sources;
+
     sources = [
         "om4gpio.c"
     ];
 
     dynlibs = [
-        "//drivers/gpio/core:gpio"
+        "drivers/gpio/core:gpio"
     ];
 
     drv = {
@@ -45,4 +52,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/i8042/build.ck

@@ -26,15 +26,22 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "i8042";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "i8042";
+    var sources;
+
     sources = [
         "i8042.c",
         "scancode.c"
     ];
 
     dynlibs = [
-        "//drivers/usrinput:usrinput"
+        "drivers/usrinput:usrinput"
     ];
 
     drv = {
@@ -46,4 +53,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 10 - 4
drivers/i8042/pl050/build.ck

@@ -26,15 +26,22 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "pl050";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "pl050";
+    var sources;
+
     sources = [
         "pl050.c",
-        "//drivers/i8042:scancode.o"
+        "drivers/i8042:scancode.o"
     ];
 
     dynlibs = [
-        "//drivers/usrinput:usrinput"
+        "drivers/usrinput:usrinput"
     ];
 
     drv = {
@@ -46,4 +53,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 24 - 17
drivers/net/build.ck

@@ -26,35 +26,42 @@ Environment:
 
 --*/
 
+from menv import group, mconfig;
+
 function build() {
-    ethernet_drivers = [
-        "//drivers/net/ethernet/smsc95xx:smsc95xx",
+    var arch = mconfig.arch;
+    var entries;
+    var ethernetDrivers;
+    var netDrivers;
+    var wirelessDrivers;
+
+    ethernetDrivers = [
+        "drivers/net/ethernet/smsc95xx:smsc95xx",
     ];
 
-    wireless_drivers = [
-        "//drivers/net/wireless/rtlw81xx:rtlw81xx",
+    wirelessDrivers = [
+        "drivers/net/wireless/rtlw81xx:rtlw81xx",
     ];
 
     if ((arch == "armv7") || (arch == "armv6")) {
-        ethernet_drivers += [
-            "//drivers/net/ethernet/smsc91c1:smsc91c1",
-            "//drivers/net/ethernet/am3eth:am3eth"
+        ethernetDrivers += [
+            "drivers/net/ethernet/smsc91c1:smsc91c1",
+            "drivers/net/ethernet/am3eth:am3eth"
         ];
 
     } else if (arch == "x86") {
-        ethernet_drivers += [
-            "//drivers/net/ethernet/atl1c:atl1c",
-            "//drivers/net/ethernet/dwceth:dwceth",
-            "//drivers/net/ethernet/e100:e100",
-            "//drivers/net/ethernet/e1000:e1000",
-            "//drivers/net/ethernet/pcnet32:pcnet32",
-            "//drivers/net/ethernet/rtl81xx:rtl81xx",
+        ethernetDrivers += [
+            "drivers/net/ethernet/atl1c:atl1c",
+            "drivers/net/ethernet/dwceth:dwceth",
+            "drivers/net/ethernet/e100:e100",
+            "drivers/net/ethernet/e1000:e1000",
+            "drivers/net/ethernet/pcnet32:pcnet32",
+            "drivers/net/ethernet/rtl81xx:rtl81xx",
         ];
     }
 
-    net_drivers = ethernet_drivers + wireless_drivers;
-    entries = group("net_drivers", net_drivers);
+    netDrivers = ethernetDrivers + wirelessDrivers;
+    entries = group("net_drivers", netDrivers);
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/net/ethernet/am3eth/build.ck

@@ -26,15 +26,22 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "am3eth";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "am3eth";
+    var sources;
+
     sources = [
         "am3eth.c",
         "am3ethhw.c"
     ];
 
     dynlibs = [
-        "//drivers/net/netcore:netcore"
+        "drivers/net/netcore:netcore"
     ];
 
     drv = {
@@ -46,4 +53,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/net/ethernet/atl1c/build.ck

@@ -26,15 +26,22 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "atl1c";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "atl1c";
+    var sources;
+
     sources = [
         "atl1c.c",
         "atl1chw.c"
     ];
 
     dynlibs = [
-        "//drivers/net/netcore:netcore"
+        "drivers/net/netcore:netcore"
     ];
 
     drv = {
@@ -46,4 +53,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/net/ethernet/dwceth/build.ck

@@ -25,15 +25,22 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "dwceth";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "dwceth";
+    var sources;
+
     sources = [
         "dwceth.c",
         "dwcethhw.c"
     ];
 
     dynlibs = [
-        "//drivers/net/netcore:netcore"
+        "drivers/net/netcore:netcore"
     ];
 
     drv = {
@@ -45,4 +52,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/net/ethernet/e100/build.ck

@@ -26,15 +26,22 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "e100";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "e100";
+    var sources;
+
     sources = [
         "e100.c",
         "e100hw.c"
     ];
 
     dynlibs = [
-        "//drivers/net/netcore:netcore"
+        "drivers/net/netcore:netcore"
     ];
 
     drv = {
@@ -46,4 +53,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 8 - 3
drivers/net/ethernet/e1000/build.ck

@@ -26,15 +26,21 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "e1000";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "e1000";
+    var sources;
     sources = [
         "e1000.c",
         "e1000hw.c"
     ];
 
     dynlibs = [
-        "//drivers/net/netcore:netcore"
+        "drivers/net/netcore:netcore"
     ];
 
     drv = {
@@ -46,4 +52,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/net/ethernet/pcnet32/build.ck

@@ -25,15 +25,22 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "pcnet32";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "pcnet32";
+    var sources;
+
     sources = [
         "pcnet.c",
         "pcnethw.c"
     ];
 
     dynlibs = [
-        "//drivers/net/netcore:netcore"
+        "drivers/net/netcore:netcore"
     ];
 
     drv = {
@@ -45,4 +52,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/net/ethernet/rtl81xx/build.ck

@@ -26,15 +26,22 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "rtl81xx";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "rtl81xx";
+    var sources;
+
     sources = [
         "rtl81.c",
         "rtl81hw.c"
     ];
 
     dynlibs = [
-        "//drivers/net/netcore:netcore"
+        "drivers/net/netcore:netcore"
     ];
 
     drv = {
@@ -46,4 +53,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/net/ethernet/smsc91c1/build.ck

@@ -25,15 +25,22 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "smsc91c1";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "smsc91c1";
+    var sources;
+
     sources = [
         "sm91c1.c",
         "sm91c1hw.c"
     ];
 
     dynlibs = [
-        "//drivers/net/netcore:netcore"
+        "drivers/net/netcore:netcore"
     ];
 
     drv = {
@@ -45,4 +52,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 10 - 4
drivers/net/ethernet/smsc95xx/build.ck

@@ -26,16 +26,23 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "smsc95xx";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "smsc95xx";
+    var sources;
+
     sources = [
         "smsc95.c",
         "smsc95hw.c"
     ];
 
     dynlibs = [
-        "//drivers/net/netcore:netcore",
-        "//drivers/usb/usbcore:usbcore"
+        "drivers/net/netcore:netcore",
+        "drivers/usb/usbcore:usbcore"
     ];
 
     drv = {
@@ -47,4 +54,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/net/net80211/build.ck

@@ -26,8 +26,15 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "net80211";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "net80211";
+    var sources;
+
     sources = [
         "control.c",
         "crypto.c",
@@ -39,7 +46,7 @@ function build() {
     ];
 
     dynlibs = [
-        "//drivers/net/netcore:netcore"
+        "drivers/net/netcore:netcore"
     ];
 
     drv = {
@@ -51,4 +58,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 7 - 2
drivers/net/netcore/build.ck

@@ -27,8 +27,14 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "netcore";
+    var drv;
+    var entries;
+    var name = "netcore";
+    var sources;
+
     sources = [
         "addr.c",
         "arp.c",
@@ -55,4 +61,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 19 - 12
drivers/net/wireless/rtlw81xx/build.ck

@@ -26,35 +26,43 @@ Environment:
 
 --*/
 
+from menv import copy, driver, mconfig;
+
 function build() {
-    name = "rtlw81xx";
+    var drv;
+    var dynlibs;
+    var entries = [];
+    var firmwareFiles;
+    var implicits = [];
+    var name = "rtlw81xx";
+    var sources;
+
     sources = [
         "rtlw81.c",
         "rtlw81hw.c"
     ];
 
     dynlibs = [
-        "//drivers/net/netcore:netcore",
-        "//drivers/net/net80211:net80211",
-        "//drivers/usb/usbcore:usbcore"
+        "drivers/net/netcore:netcore",
+        "drivers/net/net80211:net80211",
+        "drivers/usb/usbcore:usbcore"
     ];
 
-    fw_files = [
+    firmwareFiles = [
         "rtlw8188cufwUMC.bin",
         "rtlw8188eufw.bin",
         "rtlw8192cufw.bin"
     ];
 
-    entries = [];
     implicits = [];
-    for (fw_file in fw_files) {
-        entries += copy("firmware/" + fw_file,
-                        binroot + "/" + fw_file,
-                        fw_file,
+    for (fwFile in firmwareFiles) {
+        entries += copy("firmware/" + fwFile,
+                        mconfig.binroot + "/" + fwFile,
+                        fwFile,
                         null,
                         null);
 
-        implicits += [":" + fw_file];
+        implicits += [":" + fwFile];
     }
 
     drv = {
@@ -67,4 +75,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 7 - 2
drivers/null/build.ck

@@ -28,8 +28,14 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "null";
+    var drv;
+    var entries;
+    var name = "null";
+    var sources;
+
     sources = [
         "null.c"
     ];
@@ -43,4 +49,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/part/build.ck

@@ -25,14 +25,21 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "part";
+    var drv;
+    var entries;
+    var libs;
+    var name = "part";
+    var sources;
+
     sources = [
         "part.c"
     ];
 
     libs = [
-        "//lib/partlib:partlib"
+        "lib/partlib:partlib"
     ];
 
     drv = {
@@ -44,4 +51,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 7 - 2
drivers/pci/build.ck

@@ -26,8 +26,14 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "pci";
+    var drv;
+    var entries;
+    var name = "pci";
+    var sources;
+
     sources = [
         "msi.c",
         "pci.c",
@@ -43,4 +49,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 14 - 9
drivers/plat/build.ck

@@ -25,23 +25,28 @@ Environment:
 
 --*/
 
+from menv import group, mconfig;
+
 function build() {
+    var arch = mconfig.arch;
+    var entries;
+    var platformDrivers;
+
     if ((arch == "armv7") || (arch == "armv6")) {
-        platform_drivers = [
-            "//drivers/plat/goec:goec",
-            "//drivers/plat/rockchip/rk808:rk808",
-            "//drivers/plat/ti/am3soc:am3soc",
-            "//drivers/plat/ti/tps65217:tps65217"
+        platformDrivers = [
+            "drivers/plat/goec:goec",
+            "drivers/plat/rockchip/rk808:rk808",
+            "drivers/plat/ti/am3soc:am3soc",
+            "drivers/plat/ti/tps65217:tps65217"
         ];
 
     } else if (arch == "x86") {
-        platform_drivers = [
-            "//drivers/plat/quark/qrkhostb:qrkhostb"
+        platformDrivers = [
+            "drivers/plat/quark/qrkhostb:qrkhostb"
         ];
     }
 
-    entries = group("platform_drivers", platform_drivers);
+    entries = group("platform_drivers", platformDrivers);
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/plat/goec/build.ck

@@ -25,15 +25,22 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "goec";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "goec";
+    var sources;
+
     sources = [
         "goec.c",
         "keymap.c"
     ];
 
     dynlibs = [
-        "//drivers/usrinput:usrinput"
+        "drivers/usrinput:usrinput"
     ];
 
     drv = {
@@ -45,4 +52,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 7 - 2
drivers/plat/quark/qrkhostb/build.ck

@@ -26,8 +26,14 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "qrkhostb";
+    var drv;
+    var entries;
+    var name = "qrkhostb";
+    var sources;
+
     sources = [
         "qrkhostb.c"
     ];
@@ -41,4 +47,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 7 - 2
drivers/plat/rockchip/rk808/build.ck

@@ -26,8 +26,14 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "rk808";
+    var drv;
+    var entries;
+    var name = "rk808";
+    var sources;
+
     sources = [
         "rk808.c"
     ];
@@ -41,4 +47,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 16 - 3
drivers/plat/ti/am3soc/build.ck

@@ -25,9 +25,16 @@ Environment:
 
 --*/
 
+from menv import addConfig, driver;
+
 function build() {
-    name = "am3soc";
-    fw_name = "am3cm3fw";
+    var drv;
+    var entries;
+    var fwName;
+    var name = "am3soc";
+    var sources;
+
+    fwName = "am3cm3fw";
     sources = [
         "am3soc.c",
         "am3cm3fw.S",
@@ -41,7 +48,13 @@ function build() {
     };
 
     entries = driver(drv);
+    for (entry in entries) {
+        if ((entry.get("output")) && (entry.output.endsWith("am3cm3fw.o"))) {
+            addConfig(entry, "CPPFLAGS", "-I$S/drivers/plat/ti/am3soc");
+            break;
+        }
+    }
+
     return entries;
 }
 
-return build();

+ 7 - 2
drivers/plat/ti/tps65217/build.ck

@@ -26,8 +26,14 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "tps65217";
+    var drv;
+    var entries;
+    var name = "tps65217";
+    var sources;
+
     sources = [
         "tps65217.c"
     ];
@@ -41,4 +47,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 7 - 2
drivers/ramdisk/build.ck

@@ -25,8 +25,14 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "ramdisk";
+    var drv;
+    var entries;
+    var name = "ramdisk";
+    var sources;
+
     sources = [
         "ramdisk.c"
     ];
@@ -40,4 +46,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/sd/bcm2709/build.ck

@@ -25,15 +25,22 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "sdbm2709";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "sdbm2709";
+    var sources;
+
     sources = [
         "emmc.c",
         "sdbm2709.c"
     ];
 
     dynlibs = [
-        "//drivers/sd/core:sd"
+        "drivers/sd/core:sd"
     ];
 
     drv = {
@@ -45,4 +52,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 14 - 9
drivers/sd/build.ck

@@ -26,23 +26,28 @@ Environment:
 
 --*/
 
+from menv import group, mconfig;
+
 function build() {
+    var arch = mconfig.arch;
+    var entries;
+    var sdDrivers;
+
     if ((arch == "armv7") || (arch == "armv6")) {
-        sd_drivers = [
-            "//drivers/sd/bcm2709:sdbm2709",
-            "//drivers/sd/omap4:sdomap4",
-            "//drivers/sd/rk32xx:sdrk32xx",
-            "//drivers/plat/ti/tps65217:tps65217"
+        sdDrivers = [
+            "drivers/sd/bcm2709:sdbm2709",
+            "drivers/sd/omap4:sdomap4",
+            "drivers/sd/rk32xx:sdrk32xx",
+            "drivers/plat/ti/tps65217:tps65217"
         ];
 
     } else if (arch == "x86") {
-        sd_drivers = [
-            "//drivers/sd/core:sd"
+        sdDrivers = [
+            "drivers/sd/core:sd"
         ];
     }
 
-    entries = group("sd_drivers", sd_drivers);
+    entries = group("sd_drivers", sdDrivers);
     return entries;
 }
 
-return build();

+ 7 - 2
drivers/sd/core/build.ck

@@ -26,8 +26,14 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "sd";
+    var drv;
+    var entries;
+    var name = "sd";
+    var sources;
+
     sources = [
         "sd.c",
         "sdlib.c",
@@ -43,4 +49,3 @@ function build() {
     return entries;
 }
 
-return build();

+ 9 - 3
drivers/sd/omap4/build.ck

@@ -25,8 +25,15 @@ Environment:
 
 --*/
 
+from menv import driver;
+
 function build() {
-    name = "sdomap4";
+    var drv;
+    var dynlibs;
+    var entries;
+    var name = "sdomap4";
+    var sources;
+
     sources = [
         "i2c.c",
         "pmic.c",
@@ -34,7 +41,7 @@ function build() {
     ];
 
     dynlibs = [
-        "//drivers/sd/core:sd"
+        "drivers/sd/core:sd"
     ];
 
     drv = {
@@ -46,4 +53,3 @@ function build() {
     return entries;
 }
 
-return build();

Some files were not shown because too many files changed in this diff