chore(foundation): remove foundation from labs

This commit is contained in:
Jake Hamilton 2025-03-30 06:55:20 -07:00
parent 5bec48ef8a
commit 85e3fea0d4
Signed by: jakehamilton
GPG key ID: 9762169A1B35EA68
143 changed files with 20 additions and 14587 deletions
README.md
foundation

View file

@ -27,5 +27,4 @@ may collaborate.
| Name | Phase | Description |
| ------------------------------ | --------- | ------------------------------------------------------------------------------------ |
| [Aux Foundation](./foundation) | Iteration | Foundational packages which allow for bootstrapping a greater package set. |
| [Aux Tidepool](./tidepool) | Idea | An initial package set built on top of Aux Foundation using Aux Lib's module system. |

View file

@ -1,23 +0,0 @@
MIT License
Copyright (c) 2003-2023 Eelco Dolstra and the Nixpkgs/NixOS contributors
Copyright (c) 2024 Aux Contributors
Permission is hereby granted, free
of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice
(including the next paragraph) shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -1,111 +0,0 @@
# Aux Foundation
Aux Foundation provides a set of foundational packages which are required for bootstrapping
a larger package set.
## Usage
Packages can be imported both with and without Nix Flakes. To import them using Nix Flakes,
add this repository as an input.
```nix
inputs.foundation.url = "https://git.auxolotl.org/auxolotl/labs/archive/main.tar.gz?dir=foundation";
```
To import this library without using Nix Flakes, you will need to use `fetchTarball` and
import the library entrypoint.
```nix
let
labs = builtins.fetchTarball {
url = "https://git.auxolotl.org/auxolotl/labs/archive/main.tar.gz";
sha256 = "<sha256>";
};
foundation = import "${labs}/foundation" {
# Specifying a system is optional. By default it will use the current system.
system = "i686-linux";
};
in
# ...
```
## Development
This foundational package set is created using modules. Each builder and package is separated
accordingly and can be found in their respective directories. In addition, packages are grouped
into the different stages of the bootstrapping process.
### Inputs
Due to the fundamental nature of this project, the only accepted input is `lib` which itself
has no dependencies. _Everything_ else must be built from scratch in the package set.
### Formatting
> **Note**
> To keep this flake light and keep its inputs empty we do not include a package
> set which would provide a formatter. Instead please run `nix run nixpkgs#nixfmt-rfc-style`
> until an improved solution is available.
All code in this project must be formatted using the provided formatter in the `flake.nix`
file. You can run this formatter using the command `nix fmt` (not currently available).
### Code Quality
In order to keep the project approachable and easy to maintain, certain patterns are not allowed.
In particular, the use of `with` and `rec` are not allowed. Additionally, you should prefer the
fully qualified name of a variable rather than creating intermediate ones using `inherit`.
### Builders
Builders are wrappers around `builtins.derivation` and provide additional functionality via
abstraction. They can be found in [`./src/builders`](./src/builders). Each builder specifies
its own `build` function which can be called elsewhere in the package set to construct packages.
For example, here is a module that makes use of the `kaem` builder:
```nix
{config}: let
builders = config.aux.foundation.builders;
stage0 = config.aux.foundation.stages.stage0;
package = builders.kaem.build {
name = "my-package";
deps.build.host = [
stage0.mescc-tools.package
stage0.mescc-tools-extra.package
];
script = ''
mkdir ''${out}/bin
cp ${./my-binary} ''${out}/bin/my-package
chmod 555 ''${out}/bin/my-package
'';
};
in
# ...
```
### Stages
The bootstrapping process is broken up into different stages which focus on different goals.
Each stage can be found in [`./src/stages`](./src/stages).
#### Stage 0
This stage is responsible for starting with a single binary seed and producing the tools
necessary to compile (simple) C code. This stage will then compile the original tools it
used from C sources.
#### Stage 1
This stage is responsible for building up to a recent version of `gcc`. Along with the
compiler, this stage provides things like `bash`, `coreutils`, `gnumake`, and several
other important tools.
#### Stage 2
This stage refines the existing packages by building static binaries as well as the most recent
versions of the tools. In addition, certain load-bearing packages such as `patchelf` and `glibc`
are built.

View file

@ -1,14 +0,0 @@
{
system ? builtins.currentSystem,
}:
let
pins = import ./npins;
lib = import pins.lib;
modules = import ./src;
result = lib.modules.run {
modules = (builtins.attrValues modules) ++ [ { config.aux.system = system; } ];
};
in
result.config.exports.resolved.packages

7
foundation/flake.lock generated
View file

@ -1,7 +0,0 @@
{
"nodes": {
"root": {}
},
"root": "root",
"version": 7
}

View file

@ -1,33 +0,0 @@
{
description = "A set of foundational packages required for bootstrapping a larger package set.";
inputs = { };
outputs =
_:
let
pins = import ./npins;
lib = import pins.lib;
modules = import ./src;
forEachSystem = lib.attrs.generate [ "i686-linux" ];
in
{
extras =
let
result = lib.modules.run { modules = builtins.attrValues modules; };
in
result.config.exports.resolved.extras;
packages = forEachSystem (
system:
let
result = lib.modules.run {
modules = (builtins.attrValues modules) ++ [{ config.aux.system = system; }];
};
in
result.config.exports.resolved.packages
);
};
}

View file

@ -1,80 +0,0 @@
# Generated by npins. Do not modify; will be overwritten regularly
let
data = builtins.fromJSON (builtins.readFile ./sources.json);
version = data.version;
mkSource =
spec:
assert spec ? type;
let
path =
if spec.type == "Git" then
mkGitSource spec
else if spec.type == "GitRelease" then
mkGitSource spec
else if spec.type == "PyPi" then
mkPyPiSource spec
else if spec.type == "Channel" then
mkChannelSource spec
else
builtins.throw "Unknown source type ${spec.type}";
in
spec // { outPath = path; };
mkGitSource =
{
repository,
revision,
url ? null,
hash,
branch ? null,
...
}:
assert repository ? type;
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
# In the latter case, there we will always be an url to the tarball
if url != null then
(builtins.fetchTarball {
inherit url;
sha256 = hash; # FIXME: check nix version & use SRI hashes
})
else
assert repository.type == "Git";
let
urlToName =
url: rev:
let
matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url;
short = builtins.substring 0 7 rev;
appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
in
"${if matched == null then "source" else builtins.head matched}${appendShort}";
name = urlToName repository.url revision;
in
builtins.fetchGit {
url = repository.url;
rev = revision;
inherit name;
# hash = hash;
};
mkPyPiSource =
{ url, hash, ... }:
builtins.fetchurl {
inherit url;
sha256 = hash;
};
mkChannelSource =
{ url, hash, ... }:
builtins.fetchTarball {
inherit url;
sha256 = hash;
};
in
if version == 3 then
builtins.mapAttrs (_: mkSource) data.pins
else
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"

View file

@ -1,16 +0,0 @@
{
"pins": {
"lib": {
"type": "Git",
"repository": {
"type": "Git",
"url": "git+ssh://forgejo@git.auxolotl.org/auxolotl/lib.git"
},
"branch": "main",
"revision": "7552ab48bb394d59d2bf1f7a558d28ce59da524d",
"url": null,
"hash": "0705fm00k9f95b6idf5qnfvqm4qf1a0cv966ghgd48kd1qy4il5c"
}
},
"version": 3
}

View file

@ -1,82 +0,0 @@
{ lib, config }:
let
system = config.aux.system;
builders = config.aux.foundation.builders;
stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.builders.bash.boot = {
build = lib.options.create {
type = lib.types.function lib.types.derivation;
description = "Builds a package using the kaem builder.";
};
};
config = {
aux.foundation.builders.bash.boot = {
build =
settings@{
name,
script,
meta ? { },
extras ? { },
env ? { },
deps ? { },
...
}:
let
package = builtins.derivation (
(builtins.removeAttrs settings [
"meta"
"extras"
"executable"
"env"
"deps"
"script"
])
// env
// {
inherit name system script;
passAsFile = [ "script" ];
builder = "${stage1.bash.boot.package}/bin/bash";
args = [
"-e"
(builtins.toFile "bash-builder.sh" ''
export CONFIG_SHELL=$SHELL
# Normalize the NIX_BUILD_CORES variable. The value might be 0, which
# means that we're supposed to try and auto-detect the number of
# available CPU cores at run-time. We don't have nproc to detect the
# number of available CPU cores so default to 1 if not set.
NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}"
if [ $NIX_BUILD_CORES -le 0 ]; then
NIX_BUILD_CORES=1
fi
export NIX_BUILD_CORES
bash -eux $scriptPath
'')
];
SHELL = "${stage1.bash.boot.package}/bin/bash";
PATH = lib.paths.bin (
(deps.build.host or [ ])
++ [
stage1.bash.boot.package
stage1.coreutils.boot.package
stage0.mescc-tools-extra.package
]
);
}
);
in
package // { inherit meta extras; };
};
};
}

View file

@ -1,82 +0,0 @@
{ lib, config }:
let
system = config.aux.system;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
includes = [ ./boot.nix ];
options.aux.foundation.builders.bash = {
build = lib.options.create {
type = lib.types.function lib.types.derivation;
description = "Builds a package using the bash builder.";
};
};
config = {
aux.foundation.builders.bash = {
build =
settings@{
name,
script,
meta ? { },
extras ? { },
env ? { },
deps ? { },
...
}:
let
package = builtins.derivation (
(builtins.removeAttrs settings [
"meta"
"extras"
"executable"
"env"
"deps"
"script"
])
// env
// {
inherit name system script;
passAsFile = [ "script" ];
builder = "${stage1.bash.package}/bin/bash";
args = [
"-e"
(builtins.toFile "bash-builder.sh" ''
export CONFIG_SHELL=$SHELL
# Normalize the NIX_BUILD_CORES variable. The value might be 0, which
# means that we're supposed to try and auto-detect the number of
# available CPU cores at run-time.
NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}"
if ((NIX_BUILD_CORES <= 0)); then
guess=$(nproc 2>/dev/null || true)
((NIX_BUILD_CORES = guess <= 0 ? 1 : guess))
fi
export NIX_BUILD_CORES
bash -eux $scriptPath
'')
];
SHELL = "${stage1.bash.package}/bin/bash";
PATH = lib.paths.bin (
(deps.build.host or [ ])
++ [
stage1.bash.package
stage1.coreutils.package
]
);
}
);
in
package // { inherit meta extras; };
};
};
}

View file

@ -1,75 +0,0 @@
{ lib, config }:
let
system = config.aux.system;
stage0 = config.aux.foundation.stages.stage0;
in
{
options.aux.foundation.builders.file.text = {
build = lib.options.create {
type = lib.types.function lib.types.derivation;
description = "Builds a package using the text file builder.";
};
};
config = {
aux.foundation.builders.file.text = {
build =
settings@{
name,
contents,
isExecutable ? false,
destination ? "",
meta ? { },
extras ? { },
...
}:
let
script =
''
target=''${out}''${destination}
''
+ lib.strings.when (builtins.dirOf destination == ".") ''
mkdir -p ''${out}''${destinationDir}
''
+ ''
cp ''${contentsPath} ''${target}
''
+ lib.strings.when isExecutable ''
chmod 555 ''${target}
'';
package = builtins.derivation (
(builtins.removeAttrs settings [
"meta"
"extras"
"executable"
"isExecutable"
])
// {
inherit
name
system
destination
contents
;
destinationDir = builtins.dirOf destination;
passAsFile = [ "contents" ];
builder = "${stage0.kaem.package}/bin/kaem";
args = [
"--verbose"
"--strict"
"--file"
(builtins.toFile "write-text-to-file.kaem" script)
];
PATH = lib.paths.bin [ stage0.mescc-tools-extra.package ];
}
);
in
package // { inherit meta extras; };
};
};
}

View file

@ -1,68 +0,0 @@
{ lib, config }:
let
system = config.aux.system;
builders = config.aux.foundation.builders;
stage0 = config.aux.foundation.stages.stage0;
in
{
options.aux.foundation.builders.kaem = {
build = lib.options.create {
type = lib.types.function lib.types.derivation;
description = "Builds a package using the kaem builder.";
};
};
config = {
aux.foundation.builders.kaem = {
build =
settings@{
name,
script,
meta ? { },
extras ? { },
env ? { },
deps ? { },
...
}:
let
package = builtins.derivation (
(builtins.removeAttrs settings [
"meta"
"extras"
"executable"
"env"
"deps"
"script"
])
// env
// {
inherit name system;
builder = "${stage0.kaem.package}/bin/kaem";
args = [
"--verbose"
"--strict"
"--file"
(builders.file.text.build {
name = "${name}-builder";
contents = script;
})
];
PATH = lib.paths.bin (
(deps.build.host or [ ])
++ [
stage0.kaem.package
stage0.mescc-tools.package
stage0.mescc-tools-extra.package
]
);
}
);
in
package // { inherit meta extras; };
};
};
}

View file

@ -1,49 +0,0 @@
{ lib, config }:
let
system = config.aux.system;
in
{
options.aux.foundation.builders.raw = {
build = lib.options.create {
type = lib.types.function lib.types.derivation;
description = "Builds a package using the raw builder.";
};
};
config = {
aux.foundation.builders.raw = {
build =
settings@{
pname,
version,
executable,
args ? [ ],
meta ? { },
extras ? { },
...
}:
let
package = builtins.derivation (
(builtins.removeAttrs settings [
"meta"
"extras"
"executable"
])
// {
inherit
version
pname
system
args
;
name = "${pname}-${version}";
builder = executable;
}
);
in
package // { inherit meta extras; };
};
};
}

View file

@ -1,16 +0,0 @@
let
modules = {
builderBash = builders/bash;
builderFileText = ./builders/file/text;
builderKaem = ./builders/kaem;
builderRaw = ./builders/raw;
mirrors = ./mirrors;
exports = ./exports;
platform = ./platform;
stage0 = ./stages/stage0;
stage1 = ./stages/stage1;
stage2 = ./stages/stage2;
system = ./system;
};
in
modules

View file

@ -1,43 +0,0 @@
{ lib, config }:
let
options = {
packages = lib.options.create {
default.value = { };
type = lib.types.attrs.of lib.types.derivation;
};
extras = lib.options.create {
default.value = { };
type = lib.types.attrs.any;
};
};
in
{
options = {
exports = {
inherit (options) packages extras;
resolved = {
inherit (options) packages extras;
};
};
};
config = {
exports.resolved = {
packages = builtins.mapAttrs (
name: value:
lib.attrs.filter (
name: value:
if value ? meta && value.meta ? platforms then
builtins.elem config.aux.system value.meta.platforms
else
true
) value
) config.exports.packages;
extras = config.exports.extras;
};
};
}

View file

@ -1,10 +0,0 @@
{ lib }:
{
options.aux.mirrors = {
gnu = lib.options.create {
type = lib.types.string;
default.value = "https://ftp.gnu.org/gnu";
description = "The GNU mirror to use";
};
};
}

View file

@ -1,346 +0,0 @@
{ lib, config }:
let
system = config.aux.system;
parts = lib.strings.split "-" system;
platform = builtins.elemAt parts 0;
target = builtins.elemAt parts 1;
platforms = {
arm = {
bits = 32;
endian = "little";
family = "arm";
};
armv5tel = {
bits = 32;
endian = "little";
family = "arm";
version = "5";
arch = "armv5t";
};
armv6m = {
bits = 32;
endian = "little";
family = "arm";
version = "6";
arch = "armv6-m";
};
armv6l = {
bits = 32;
endian = "little";
family = "arm";
version = "6";
arch = "armv6";
};
armv7a = {
bits = 32;
endian = "little";
family = "arm";
version = "7";
arch = "armv7-a";
};
armv7r = {
bits = 32;
endian = "little";
family = "arm";
version = "7";
arch = "armv7-r";
};
armv7m = {
bits = 32;
endian = "little";
family = "arm";
version = "7";
arch = "armv7-m";
};
armv7l = {
bits = 32;
endian = "little";
family = "arm";
version = "7";
arch = "armv7";
};
armv8a = {
bits = 32;
endian = "little";
family = "arm";
version = "8";
arch = "armv8-a";
};
armv8r = {
bits = 32;
endian = "little";
family = "arm";
version = "8";
arch = "armv8-a";
};
armv8m = {
bits = 32;
endian = "little";
family = "arm";
version = "8";
arch = "armv8-m";
};
aarch64 = {
bits = 64;
endian = "little";
family = "arm";
version = "8";
arch = "armv8-a";
};
aarch64_be = {
bits = 64;
endian = "big";
family = "arm";
version = "8";
arch = "armv8-a";
};
i386 = {
bits = 32;
endian = "little";
family = "x86";
arch = "i386";
};
i486 = {
bits = 32;
endian = "little";
family = "x86";
arch = "i486";
};
i586 = {
bits = 32;
endian = "little";
family = "x86";
arch = "i586";
};
i686 = {
bits = 32;
endian = "little";
family = "x86";
arch = "i686";
};
x86_64 = {
bits = 64;
endian = "little";
family = "x86";
arch = "x86-64";
};
microblaze = {
bits = 32;
endian = "big";
family = "microblaze";
};
microblazeel = {
bits = 32;
endian = "little";
family = "microblaze";
};
mips = {
bits = 32;
endian = "big";
family = "mips";
};
mipsel = {
bits = 32;
endian = "little";
family = "mips";
};
mips64 = {
bits = 64;
endian = "big";
family = "mips";
};
mips64el = {
bits = 64;
endian = "little";
family = "mips";
};
mmix = {
bits = 64;
endian = "big";
family = "mmix";
};
m68k = {
bits = 32;
endian = "big";
family = "m68k";
};
powerpc = {
bits = 32;
endian = "big";
family = "power";
};
powerpc64 = {
bits = 64;
endian = "big";
family = "power";
};
powerpc64le = {
bits = 64;
endian = "little";
family = "power";
};
powerpcle = {
bits = 32;
endian = "little";
family = "power";
};
riscv32 = {
bits = 32;
endian = "little";
family = "riscv";
};
riscv64 = {
bits = 64;
endian = "little";
family = "riscv";
};
s390 = {
bits = 32;
endian = "big";
family = "s390";
};
s390x = {
bits = 64;
endian = "big";
family = "s390";
};
sparc = {
bits = 32;
endian = "big";
family = "sparc";
};
sparc64 = {
bits = 64;
endian = "big";
family = "sparc";
};
wasm32 = {
bits = 32;
endian = "little";
family = "wasm";
};
wasm64 = {
bits = 64;
endian = "little";
family = "wasm";
};
alpha = {
bits = 64;
endian = "little";
family = "alpha";
};
rx = {
bits = 32;
endian = "little";
family = "rx";
};
msp430 = {
bits = 16;
endian = "little";
family = "msp430";
};
avr = {
bits = 8;
family = "avr";
};
vc4 = {
bits = 32;
endian = "little";
family = "vc4";
};
or1k = {
bits = 32;
endian = "big";
family = "or1k";
};
loongarch64 = {
bits = 64;
endian = "little";
family = "loongarch";
};
javascript = {
bits = 32;
endian = "little";
family = "javascript";
};
};
in
{
options.aux.platform = {
name = lib.options.create {
type = lib.types.string;
description = "Name of the platform";
};
family = lib.options.create {
type = lib.types.string;
description = "Family of the platform";
};
bits = lib.options.create {
type = lib.types.int;
description = "Number of bits in the platform";
};
endian = lib.options.create {
type = lib.types.enum [
"little"
"big"
];
default.value = "big";
description = "Endianess of the platform";
};
arch = lib.options.create {
type = lib.types.nullish lib.types.string;
default.value = null;
description = "Architecture of the platform";
};
version = lib.options.create {
type = lib.types.nullish lib.types.string;
default.value = null;
description = "Version of the platform";
};
build = lib.options.create {
type = lib.types.string;
description = "The build entry, such as x86-unknown-linux-gnu.";
};
host = lib.options.create {
type = lib.types.string;
description = "The host entry, such as x86-unknown-linux-gnu.";
};
};
config = {
aux.platform = (platforms.${platform} or (builtins.throw "Unsupported platform: ${system}")) // {
name = platform;
# These will only ever have `linux` as the target since we
# do not support darwin bootstrapping.
build = "${platform}-unknown-${target}-gnu";
host = "${platform}-unknown-${target}-gnu";
};
};
}

View file

@ -1,35 +0,0 @@
{ lib, config }:
let
system = config.aux.system;
architecture =
if system == "x86_64-linux" then
"AMD64"
else if system == "aarch64-linux" then
"AArch64"
else if system == "i686-linux" then
"x86"
else
builtins.throw "Unsupported system for stage0: ${system}";
in
{
options.aux.foundation.stages.stage0.architecture = {
base = lib.options.create {
type = lib.types.string;
description = "The architecture to use for the source.";
default = {
value = architecture;
text = ''"AMD64" or "AArch64" or "x86"'';
};
};
m2libc = lib.options.create {
type = lib.types.string;
description = "The architecture to use for the M2libc source.";
default = {
value = lib.strings.lower architecture;
text = ''"amd64" or "aarch64" or "x86"'';
};
};
};
}

View file

@ -1,79 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0;
system = config.aux.system;
builders = config.aux.foundation.builders;
architecture =
if system == "x86_64-linux" then
"AMD64"
else if system == "aarch64-linux" then
"AArch64"
else if system == "i686-linux" then
"x86"
else
builtins.throw "Unsupported system for stage0: ${system}";
in
{
includes = [
./sources
./architecture
./phases/phase00.nix
./phases/phase01.nix
./phases/phase02.nix
./phases/phase03.nix
./phases/phase04.nix
./phases/phase05.nix
./phases/phase06.nix
./phases/phase07.nix
./phases/phase08.nix
./phases/phase09.nix
./phases/phase10.nix
./phases/phase11.nix
./phases/phase12.nix
./mescc-tools
./mescc-tools-extra
./kaem
];
config = {
exports = {
packages = {
stage0-hex0 = cfg.hex0.package;
stage0-hex1 = cfg.hex1.package;
stage0-hex2-0 = cfg.hex2-0.package;
stage0-catm = cfg.catm.package;
stage0-M0 = cfg.M0.package;
stage0-cc_arch = cfg.cc_arch.package;
stage0-M2 = cfg.M2.package;
stage0-blood-elf = cfg.blood-elf.package;
stage0-M1-0 = cfg.M1-0.package;
stage0-hex2-1 = cfg.hex2-1.package;
stage0-M1 = cfg.M1.package;
stage0-hex2 = cfg.hex2.package;
stage0-kaem-unwrapped = cfg.kaem-unwrapped.package;
stage0-mescc-tools = cfg.mescc-tools.package;
stage0-mescc-tools-extra = cfg.mescc-tools-extra.package;
stage0-kaem = cfg.kaem.package;
};
};
};
}

View file

@ -1,3 +0,0 @@
mkdir -p ${out}/bin
cp ${kaemUnwrapped} ${out}/bin/kaem
chmod 555 ${out}/bin/kaem

View file

@ -1,71 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.kaem;
system = config.aux.system;
builders = config.aux.foundation.builders;
kaem-unwrapped = config.aux.foundation.stages.stage0.kaem-unwrapped;
mescc-tools = config.aux.foundation.stages.stage0.mescc-tools;
mescc-tools-extra = config.aux.foundation.stages.stage0.mescc-tools-extra;
in
{
options.aux.foundation.stages.stage0.kaem = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Minimal build tool for running scripts on systems that lack any shell.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for kaem.";
};
};
config = {
aux.foundation.stages.stage0.kaem = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "kaem";
version = "1.6.0";
meta = cfg.meta;
executable = kaem-unwrapped.package;
args = [
"--verbose"
"--strict"
"--file"
./build.kaem
];
kaemUnwrapped = kaem-unwrapped.package;
PATH = lib.paths.bin [ mescc-tools-extra.package ];
}
);
};
};
}

View file

@ -1,40 +0,0 @@
# This is a modified version of mescc-tools-extra/mescc-tools-extra.kaem
# https://github.com/oriansj/mescc-tools-extra/blob/ec53af69d6d2119b47b369cd0ec37ac806e7ad60/mescc-tools-extra.kaem
# - Paths to build inputs have been changed for nix
# - Added additional step to create $out directory
## Copyright (C) 2017 Jeremiah Orians
## This file is part of mescc-tools.
##
## mescc-tools is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## mescc-tools is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with mescc-tools. If not, see <http://www.gnu.org/licenses/>.
alias CC="${mesccTools}/bin/M2-Mesoplanet --operating-system ${m2libcOS} --architecture ${m2libcArch} -f"
cd ${src}
# Create output folder
CC mkdir.c -o ${TMP}/mkdir
${TMP}/mkdir -p ${out}/bin
CC sha256sum.c -o ${out}/bin/sha256sum
CC match.c -o ${out}/bin/match
CC mkdir.c -o ${out}/bin/mkdir
CC untar.c -o ${out}/bin/untar
CC ungz.c -o ${out}/bin/ungz
CC unbz2.c -o ${out}/bin/unbz2
CC catm.c -o ${out}/bin/catm
CC cp.c -o ${out}/bin/cp
CC chmod.c -o ${out}/bin/chmod
CC rm.c -o ${out}/bin/rm
CC replace.c -o ${out}/bin/replace

View file

@ -1,82 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.mescc-tools-extra;
hex0 = config.aux.foundation.stages.stage0.hex0;
catm = config.aux.foundation.stages.stage0.catm;
M0 = config.aux.foundation.stages.stage0.M0;
cc_arch = config.aux.foundation.stages.stage0.cc_arch;
M2 = config.aux.foundation.stages.stage0.M2;
blood-elf = config.aux.foundation.stages.stage0.blood-elf;
M1 = config.aux.foundation.stages.stage0.M1;
hex2 = config.aux.foundation.stages.stage0.hex2;
kaem-unwrapped = config.aux.foundation.stages.stage0.kaem-unwrapped;
mescc-tools = config.aux.foundation.stages.stage0.mescc-tools;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in
{
options.aux.foundation.stages.stage0.mescc-tools-extra = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for mescc-tools-extra.";
};
};
config = {
aux.foundation.stages.stage0.mescc-tools-extra = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "mescc-tools-tools";
version = "1.6.0";
meta = cfg.meta;
executable = kaem-unwrapped.package;
args = [
"--verbose"
"--strict"
"--file"
./build.kaem
];
src = sources.mescc-tools-extra;
m2libcOS = "linux";
m2libcArch = architecture.m2libc;
mesccTools = mescc-tools.package;
}
);
};
};
}

View file

@ -1,205 +0,0 @@
# This is a modified version of stage0-posix/x86/mescc-tools-full-kaem.kaem
# https://github.com/oriansj/stage0-posix-x86/blob/56e6b8df3e95f4bc04f8b420a4cd8c82c70b9efa/mescc-tools-full-kaem.kaem
# - Paths to build inputs have been changed for nix
# Mes --- Maxwell Equations of Software
# Copyright © 2017,2019 Jan Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2017,2019 Jeremiah Orians
#
# This file is part of Mes.
#
# Mes is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# Mes is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mes. If not, see <http://www.gnu.org/licenses/>.
${mkdir} -p ${out}/bin
${cp} ${M2} ${out}/bin/M2
${chmod} 0555 ${out}/bin/M2
${cp} ${M1} ${out}/bin/M1
${chmod} 0555 ${out}/bin/M1
${cp} ${hex2} ${out}/bin/hex2
${chmod} 0555 ${out}/bin/hex2
# M2-Mesoplanet searches for runtime dependencies in environment variables
# We can hardcode them with the "replace" utility from mescc-tools-extra
${replace} \
--file ${m2mesoplanet}/cc.c \
--output ./cc_patched.c \
--match-on "env_lookup(\"M2LIBC_PATH\")" \
--replace-with "\"${m2libc}\""
${replace} \
--file ${m2mesoplanet}/cc_spawn.c \
--output ./cc_spawn_patched.c \
--match-on "env_lookup(\"PATH\")" \
--replace-with "\"${out}/bin:\""
###############################################
# Phase-12 Build M2-Mesoplanet from M2-Planet #
###############################################
${M2} --architecture ${m2libcArch} \
-f ${m2libc}/sys/types.h \
-f ${m2libc}/stddef.h \
-f ${m2libc}/${m2libcArch}/linux/fcntl.c \
-f ${m2libc}/fcntl.c \
-f ${m2libc}/${m2libcArch}/linux/unistd.c \
-f ${m2libc}/${m2libcArch}/linux/sys/stat.c \
-f ${m2libc}/stdlib.c \
-f ${m2libc}/stdio.h \
-f ${m2libc}/stdio.c \
-f ${m2libc}/string.c \
-f ${m2libc}/bootstrappable.c \
-f ${m2mesoplanet}/cc.h \
-f ${m2mesoplanet}/cc_globals.c \
-f ${m2mesoplanet}/cc_env.c \
-f ${m2mesoplanet}/cc_reader.c \
-f ./cc_spawn_patched.c \
-f ${m2mesoplanet}/cc_core.c \
-f ${m2mesoplanet}/cc_macro.c \
-f ./cc_patched.c \
--debug \
-o ./M2-Mesoplanet-1.M1
${blood-elf-0} ${endianFlag} ${bloodFlag} -f ./M2-Mesoplanet-1.M1 -o ./M2-Mesoplanet-1-footer.M1
${M1} --architecture ${m2libcArch} \
${endianFlag} \
-f ${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \
-f ${m2libc}/${m2libcArch}/libc-full.M1 \
-f ./M2-Mesoplanet-1.M1 \
-f ./M2-Mesoplanet-1-footer.M1 \
-o ./M2-Mesoplanet-1.hex2
${hex2} --architecture ${m2libcArch} \
${endianFlag} \
--base-address ${baseAddress} \
-f ${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \
-f ./M2-Mesoplanet-1.hex2 \
-o ${out}/bin/M2-Mesoplanet
#################################################
# Phase-13 Build final blood-elf from C sources #
#################################################
${M2} --architecture ${m2libcArch} \
-f ${m2libc}/sys/types.h \
-f ${m2libc}/stddef.h \
-f ${m2libc}/${m2libcArch}/linux/fcntl.c \
-f ${m2libc}/fcntl.c \
-f ${m2libc}/${m2libcArch}/linux/unistd.c \
-f ${m2libc}/stdlib.c \
-f ${m2libc}/stdio.h \
-f ${m2libc}/stdio.c \
-f ${m2libc}/bootstrappable.c \
-f ${mesccTools}/stringify.c \
-f ${mesccTools}/blood-elf.c \
--debug \
-o ./blood-elf-1.M1
${blood-elf-0} ${endianFlag} ${bloodFlag} -f ./blood-elf-1.M1 -o ./blood-elf-1-footer.M1
${M1} --architecture ${m2libcArch} \
${endianFlag} \
-f ${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \
-f ${m2libc}/${m2libcArch}/libc-full.M1 \
-f ./blood-elf-1.M1 \
-f ./blood-elf-1-footer.M1 \
-o ./blood-elf-1.hex2
${hex2} --architecture ${m2libcArch} \
${endianFlag} \
--base-address ${baseAddress} \
-f ${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \
-f ./blood-elf-1.hex2 \
-o ${out}/bin/blood-elf
# Now we have our shipping debuggable blood-elf, the rest will be down hill from
# here as we have ALL of the core pieces of compiling and assembling debuggable
# programs in a debuggable form with corresponding C source code.
#############################################
# Phase-14 Build get_machine from C sources #
#############################################
${M2} --architecture ${m2libcArch} \
-f ${m2libc}/sys/types.h \
-f ${m2libc}/stddef.h \
-f ${m2libc}/${m2libcArch}/linux/unistd.c \
-f ${m2libc}/${m2libcArch}/linux/fcntl.c \
-f ${m2libc}/fcntl.c \
-f ${m2libc}/stdlib.c \
-f ${m2libc}/stdio.h \
-f ${m2libc}/stdio.c \
-f ${m2libc}/bootstrappable.c \
-f ${mesccTools}/get_machine.c \
--debug \
-o get_machine.M1
${out}/bin/blood-elf ${endianFlag} ${bloodFlag} -f ./get_machine.M1 -o ./get_machine-footer.M1
${M1} --architecture ${m2libcArch} \
${endianFlag} \
-f ${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \
-f ${m2libc}/${m2libcArch}/libc-full.M1 \
-f ./get_machine.M1 \
-f ./get_machine-footer.M1 \
-o ./get_machine.hex2
${hex2} --architecture ${m2libcArch} \
${endianFlag} \
--base-address ${baseAddress} \
-f ${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \
-f ./get_machine.hex2 \
-o ${out}/bin/get_machine
############################################
# Phase-15 Build M2-Planet from M2-Planet #
############################################
${M2} --architecture ${m2libcArch} \
-f ${m2libc}/sys/types.h \
-f ${m2libc}/stddef.h \
-f ${m2libc}/${m2libcArch}/linux/unistd.c \
-f ${m2libc}/${m2libcArch}/linux/fcntl.c \
-f ${m2libc}/fcntl.c \
-f ${m2libc}/stdlib.c \
-f ${m2libc}/stdio.h \
-f ${m2libc}/stdio.c \
-f ${m2libc}/bootstrappable.c \
-f ${m2planet}/cc.h \
-f ${m2planet}/cc_globals.c \
-f ${m2planet}/cc_reader.c \
-f ${m2planet}/cc_strings.c \
-f ${m2planet}/cc_types.c \
-f ${m2planet}/cc_core.c \
-f ${m2planet}/cc_macro.c \
-f ${m2planet}/cc.c \
--debug \
-o ./M2-1.M1
${out}/bin/blood-elf ${endianFlag} ${bloodFlag} -f ./M2-1.M1 -o ./M2-1-footer.M1
${M1} --architecture ${m2libcArch} \
${endianFlag} \
-f ${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \
-f ${m2libc}/${m2libcArch}/libc-full.M1 \
-f ./M2-1.M1 \
-f ./M2-1-footer.M1 \
-o ./M2-1.hex2
${hex2} --architecture ${m2libcArch} \
${endianFlag} \
--base-address ${baseAddress} \
-f ${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \
-f ./M2-1.hex2 \
-o ${out}/bin/M2-Planet

View file

@ -1,180 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.mescc-tools;
hex0 = config.aux.foundation.stages.stage0.hex0;
catm = config.aux.foundation.stages.stage0.catm;
M0 = config.aux.foundation.stages.stage0.M0;
cc_arch = config.aux.foundation.stages.stage0.cc_arch;
M2 = config.aux.foundation.stages.stage0.M2;
blood-elf = config.aux.foundation.stages.stage0.blood-elf;
M1 = config.aux.foundation.stages.stage0.M1;
hex2 = config.aux.foundation.stages.stage0.hex2;
kaem-unwrapped = config.aux.foundation.stages.stage0.kaem-unwrapped;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
bloodFlag = if config.aux.platform.bits == 64 then "--64" else " ";
endianFlag = if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian";
baseAddress =
if config.aux.system == "x86_64-linux" then
"0x00600000"
else if config.aux.system == "aarch64-linux" then
"0x00600000"
else if config.aux.system == "i686-linux" then
"0x08048000"
else
builtins.throw "Unsupported system: ${config.aux.system}";
getExtraUtil =
name:
let
script = builtins.toFile "build-${name}.kaem" ''
''${M2} --architecture ${architecture.m2libc} \
-f ''${m2libc}/sys/types.h \
-f ''${m2libc}/stddef.h \
-f ''${m2libc}/${architecture.m2libc}/linux/fcntl.c \
-f ''${m2libc}/fcntl.c \
-f ''${m2libc}/${architecture.m2libc}/linux/unistd.c \
-f ''${m2libc}/${architecture.m2libc}/linux/sys/stat.c \
-f ''${m2libc}/stdlib.c \
-f ''${m2libc}/stdio.h \
-f ''${m2libc}/stdio.c \
-f ''${m2libc}/string.c \
-f ''${m2libc}/bootstrappable.c \
-f ''${mesccToolsExtra}/${name}.c \
--debug \
-o ${name}.M1
''${blood-elf-0} ${endianFlag} ${bloodFlag} -f ${name}.M1 -o ${name}-footer.M1
''${M1} --architecture ${architecture.m2libc} \
${endianFlag} \
-f ''${m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1 \
-f ''${m2libc}/${architecture.m2libc}/libc-full.M1 \
-f ${name}.M1 \
-f ${name}-footer.M1 \
-o ${name}.hex2
''${hex2} --architecture ${architecture.m2libc} \
${endianFlag} \
-f ''${m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2 \
-f ${name}.hex2 \
--base-address ${baseAddress} \
-o ''${out}
'';
in
builders.raw.build {
pname = "mescc-tools-extra-${name}";
version = "1.6.0";
meta = cfg.meta;
executable = kaem-unwrapped.package;
args = [
"--verbose"
"--strict"
"--file"
script
];
src = sources.base;
M1 = M1.package;
M2 = M2.package;
blood-elf-0 = blood-elf.package;
hex2 = hex2.package;
m2libc = sources.m2libc;
m2planet = sources.m2planet;
m2mesoplanet = sources.m2mesoplanet;
mesccTools = sources.mescc-tools;
mesccToolsExtra = sources.mescc-tools-extra;
bloodFlag = bloodFlag;
endianFlag = endianFlag;
baseAddress = baseAddress;
};
in
{
options.aux.foundation.stages.stage0.mescc-tools = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for mescc-tools.";
};
};
config = {
aux.foundation.stages.stage0.mescc-tools = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "mescc-tools";
version = "1.6.0";
meta = cfg.meta;
executable = kaem-unwrapped.package;
args = [
"--verbose"
"--strict"
"--file"
./build.kaem
];
M1 = M1.package;
M2 = M2.package;
blood-elf-0 = blood-elf.package;
hex2 = hex2.package;
m2libc = sources.m2libc;
m2libcArch = architecture.m2libc;
m2planet = sources.m2planet;
m2mesoplanet = sources.m2mesoplanet;
mesccTools = sources.mescc-tools;
mesccToolsExtra = sources.mescc-tools-extra;
bloodFlag = bloodFlag;
endianFlag = endianFlag;
baseAddress = baseAddress;
mkdir = getExtraUtil "mkdir";
cp = getExtraUtil "cp";
chmod = getExtraUtil "chmod";
replace = getExtraUtil "replace";
}
);
};
};
}

View file

@ -1,110 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.hex0;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture =
if system == "x86_64-linux" then
"AMD64"
else if system == "aarch64-linux" then
"AArch64"
else if system == "i686-linux" then
"x86"
else
builtins.throw "Unsupported system for stage0: ${system}";
in
{
options.aux.foundation.stages.stage0.hex0 = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Minimal assembler for bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for hex0.";
};
hash = lib.options.create {
type = lib.types.nullish lib.types.string;
default = {
text = "<sha256 hash>";
value = null;
};
};
executable = lib.options.create {
type = lib.types.derivation;
description = "The derivation to use to build hex0.";
};
};
config = {
aux.foundation.stages.stage0.hex0 = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "hex0";
version = "1.6.0";
meta = cfg.meta;
executable = cfg.executable;
args = [
"${sources.base}/hex0_${architecture}.hex0"
(builtins.placeholder "out")
];
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = cfg.hash;
}
);
hash = lib.modules.overrides.default (
if system == "x86_64-linux" then
"sha256-RCgK9oZRDQUiWLVkcIBSR2HeoB+Bh0czthrpjFEkCaY="
else if system == "aarch64-linux" then
"sha256-XTPsoKeI6wTZAF0UwEJPzuHelWOJe//wXg4HYO0dEJo="
else if system == "i686-linux" then
"sha256-QU3RPGy51W7M2xnfFY1IqruKzusrSLU+L190ztN6JW8="
else
null
);
executable = lib.modules.overrides.default (
import <nix/fetchurl.nix> {
name = "hex0-seed";
url = "https://github.com/oriansj/bootstrap-seeds/raw/b1263ff14a17835f4d12539226208c426ced4fba/POSIX/${architecture}/hex0-seed";
executable = true;
hash = cfg.hash;
}
);
};
};
}

View file

@ -1,65 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.hex1;
hex0 = config.aux.foundation.stages.stage0.hex0;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in
{
options.aux.foundation.stages.stage0.hex1 = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for hex1.";
};
};
config = {
aux.foundation.stages.stage0.hex1 = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "hex1";
version = "1.6.0";
meta = cfg.meta;
executable = hex0.package;
args = [
"${sources.base}/hex1_${architecture.base}.hex0"
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,66 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.hex2-0;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex1 = config.aux.foundation.stages.stage0.hex1;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in
{
options.aux.foundation.stages.stage0.hex2-0 = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for hex2-0.";
};
};
config = {
aux.foundation.stages.stage0.hex2-0 = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = hex1.package;
args = [
"${sources.base}/hex2_${architecture.base}.hex1"
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,74 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.catm;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex1 = config.aux.foundation.stages.stage0.hex1;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in
{
options.aux.foundation.stages.stage0.catm = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for catm.";
};
};
config = {
aux.foundation.stages.stage0.catm = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "catm";
version = "1.6.0";
meta = cfg.meta;
executable = if architecture.base == "AArch64" then hex1.package else hex2-0.package;
args =
if architecture.base == "AArch64" then
[
"${sources.base}/catm_${architecture.base}.hex1"
(builtins.placeholder "out")
]
else
[
"${sources.base}/catm_${architecture.base}.hex2"
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,84 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.M0;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
catm = config.aux.foundation.stages.stage0.catm;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in
{
options.aux.foundation.stages.stage0.M0 = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for M0.";
};
};
config = {
aux.foundation.stages.stage0.M0 = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "M0";
version = "1.6.0";
meta = cfg.meta;
executable = hex2-0.package;
args =
let
M0_hex2-0 = builders.raw.build {
pname = "M0_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
"${sources.base}/M0_${architecture.base}.hex2"
];
};
in
[
M0_hex2-0
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,98 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.cc_arch;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
catm = config.aux.foundation.stages.stage0.catm;
M0 = config.aux.foundation.stages.stage0.M0;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in
{
options.aux.foundation.stages.stage0.cc_arch = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for cc_arch.";
};
};
config = {
aux.foundation.stages.stage0.cc_arch = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "cc_arch";
version = "1.6.0";
meta = cfg.meta;
executable = hex2-0.package;
args =
let
cc_arch0_hex2-0 = builders.raw.build {
pname = "cc_arch0_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = M0.package;
args = [
"${sources.base}/cc_${architecture.m2libc}.M1"
(builtins.placeholder "out")
];
};
cc_arch1_hex2-0 = builders.raw.build {
pname = "cc_arch1_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
cc_arch0_hex2-0
];
};
in
[
cc_arch1_hex2-0
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,149 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.M2;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
catm = config.aux.foundation.stages.stage0.catm;
M0 = config.aux.foundation.stages.stage0.M0;
cc_arch = config.aux.foundation.stages.stage0.cc_arch;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in
{
options.aux.foundation.stages.stage0.M2 = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for M2.";
};
};
config = {
aux.foundation.stages.stage0.M2 = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "M2";
version = "1.6.0";
meta = cfg.meta;
executable = hex2-0.package;
args =
let
M2_c = builders.raw.build {
pname = "M2_c";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
"${sources.m2planet}/cc.h"
"${sources.m2libc}/bootstrappable.c"
"${sources.m2planet}/cc_globals.c"
"${sources.m2planet}/cc_reader.c"
"${sources.m2planet}/cc_strings.c"
"${sources.m2planet}/cc_types.c"
"${sources.m2planet}/cc_core.c"
"${sources.m2planet}/cc_macro.c"
"${sources.m2planet}/cc.c"
];
};
M2_M1 = builders.raw.build {
pname = "M2_M1";
version = "1.6.0";
meta = cfg.meta;
executable = cc_arch.package;
args = [
M2_c
(builtins.placeholder "out")
];
};
M2_M1' = builders.raw.build {
pname = "M2_M1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
M2_M1
];
};
M2_hex2-0 = builders.raw.build {
pname = "M2_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = M0.package;
args = [
M2_M1'
(builtins.placeholder "out")
];
};
M2_hex2-0' = builders.raw.build {
pname = "M2_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
M2_hex2-0
];
};
in
[
M2_hex2-0'
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,139 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.blood-elf;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
catm = config.aux.foundation.stages.stage0.catm;
M0 = config.aux.foundation.stages.stage0.M0;
cc_arch = config.aux.foundation.stages.stage0.cc_arch;
M2 = config.aux.foundation.stages.stage0.M2;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in
{
options.aux.foundation.stages.stage0.blood-elf = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for blood-elf.";
};
};
config = {
aux.foundation.stages.stage0.blood-elf = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "blood-elf";
version = "1.6.0";
meta = cfg.meta;
executable = hex2-0.package;
args =
let
blood-elf_M1 = builders.raw.build {
pname = "blood-elf_M1";
version = "1.6.0";
meta = cfg.meta;
executable = M2.package;
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/stringify.c"
"-f"
"${sources.mescc-tools}/blood-elf.c"
"--bootstrap-mode"
"-o"
(builtins.placeholder "out")
];
};
blood-elf_M1' = builders.raw.build {
pname = "blood-elf_M1-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
blood-elf_M1
];
};
blood-elf_hex2-0 = builders.raw.build {
pname = "blood-elf_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = M0.package;
args = [
blood-elf_M1'
(builtins.placeholder "out")
];
};
blood-elf_hex2-0' = builders.raw.build {
pname = "blood-elf_hex2-0-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
blood-elf_hex2-0
];
};
in
[
blood-elf_hex2-0'
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,158 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.M1-0;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
catm = config.aux.foundation.stages.stage0.catm;
M0 = config.aux.foundation.stages.stage0.M0;
cc_arch = config.aux.foundation.stages.stage0.cc_arch;
M2 = config.aux.foundation.stages.stage0.M2;
blood-elf = config.aux.foundation.stages.stage0.blood-elf;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in
{
options.aux.foundation.stages.stage0.M1-0 = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for M1-0.";
};
};
config = {
aux.foundation.stages.stage0.M1-0 = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "M1-0";
version = "1.6.0";
meta = cfg.meta;
executable = hex2-0.package;
args =
let
M1-macro-0_M1 = builders.raw.build {
pname = "M1-macro-0_M1";
version = "1.6.0";
meta = cfg.meta;
executable = M2.package;
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/stringify.c"
"-f"
"${sources.mescc-tools}/M1-macro.c"
"--bootstrap-mode"
"--debug"
"-o"
(builtins.placeholder "out")
];
};
M1-macro-0-footer_M1 = builders.raw.build {
pname = "M1-macro-0-footer_M1";
version = "1.6.0";
meta = cfg.meta;
executable = blood-elf.package;
args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
"-f"
M1-macro-0_M1
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-o"
(builtins.placeholder "out")
];
};
M1-macro-0_M1' = builders.raw.build {
pname = "M1-macro-0_M1-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
M1-macro-0_M1
M1-macro-0-footer_M1
];
};
M1-macro-0_hex2-0 = builders.raw.build {
pname = "M1-macro-0_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = M0.package;
args = [
M1-macro-0_M1'
(builtins.placeholder "out")
];
};
M1-macro-0_hex2-0' = builders.raw.build {
pname = "M1-macro-0_hex2-0-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
M1-macro-0_hex2-0
];
};
in
[
M1-macro-0_hex2-0'
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,173 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.hex2-1;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
catm = config.aux.foundation.stages.stage0.catm;
M0 = config.aux.foundation.stages.stage0.M0;
cc_arch = config.aux.foundation.stages.stage0.cc_arch;
M2 = config.aux.foundation.stages.stage0.M2;
blood-elf = config.aux.foundation.stages.stage0.blood-elf;
M1-0 = config.aux.foundation.stages.stage0.M1-0;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in
{
options.aux.foundation.stages.stage0.hex2-1 = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for hex2-1.";
};
};
config = {
aux.foundation.stages.stage0.hex2-1 = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "hex2-1";
version = "1.6.0";
meta = cfg.meta;
executable = hex2-0.package;
args =
let
hex2_linker_M1 = builders.raw.build {
pname = "hex2_linker_M1";
version = "1.6.0";
meta = cfg.meta;
executable = M2.package;
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/sys/types.h"
"-f"
"${sources.m2libc}/stddef.h"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f"
"${sources.m2libc}/fcntl.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f"
"${sources.m2libc}/stdlib.c"
"-f"
"${sources.m2libc}/stdio.h"
"-f"
"${sources.m2libc}/stdio.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/hex2.h"
"-f"
"${sources.mescc-tools}/hex2_linker.c"
"-f"
"${sources.mescc-tools}/hex2_word.c"
"-f"
"${sources.mescc-tools}/hex2.c"
"--debug"
"-o"
(builtins.placeholder "out")
];
};
hex2_linker-footer_M1 = builders.raw.build {
pname = "hex2_linker-footer_M1";
version = "1.6.0";
meta = cfg.meta;
executable = blood-elf.package;
args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
"-f"
hex2_linker_M1
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-o"
(builtins.placeholder "out")
];
};
hex2_linker_hex2 = builders.raw.build {
pname = "hex2_linker_hex2";
version = "1.6.0";
meta = cfg.meta;
executable = M1-0.package;
args = [
"--architecture"
architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
"-f"
hex2_linker_M1
"-f"
hex2_linker-footer_M1
"-o"
(builtins.placeholder "out")
];
};
hex2_linker_hex2' = builders.raw.build {
pname = "hex2_linker_hex2-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
hex2_linker_hex2
];
};
in
[
hex2_linker_hex2'
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,176 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.M1;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
catm = config.aux.foundation.stages.stage0.catm;
M0 = config.aux.foundation.stages.stage0.M0;
cc_arch = config.aux.foundation.stages.stage0.cc_arch;
M2 = config.aux.foundation.stages.stage0.M2;
blood-elf = config.aux.foundation.stages.stage0.blood-elf;
M1-0 = config.aux.foundation.stages.stage0.M1-0;
hex2-1 = config.aux.foundation.stages.stage0.hex2-1;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in
{
options.aux.foundation.stages.stage0.M1 = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for M1.";
};
};
config = {
aux.foundation.stages.stage0.M1 = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "M1";
version = "1.6.0";
meta = cfg.meta;
executable = hex2-1.package;
args =
let
M1-macro_M1 = builders.raw.build {
pname = "M1-macro_M1";
version = "1.6.0";
meta = cfg.meta;
executable = M2.package;
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/sys/types.h"
"-f"
"${sources.m2libc}/stddef.h"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f"
"${sources.m2libc}/fcntl.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f"
"${sources.m2libc}/string.c"
"-f"
"${sources.m2libc}/stdlib.c"
"-f"
"${sources.m2libc}/stdio.h"
"-f"
"${sources.m2libc}/stdio.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/stringify.c"
"-f"
"${sources.mescc-tools}/M1-macro.c"
"--debug"
"-o"
(builtins.placeholder "out")
];
};
M1-macro-footer_M1 = builders.raw.build {
pname = "M1-macro-footer_M1";
version = "1.6.0";
meta = cfg.meta;
executable = blood-elf.package;
args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
"-f"
M1-macro_M1
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-o"
(builtins.placeholder "out")
];
};
M1-macro_hex2 = builders.raw.build {
pname = "M1-macro_hex2";
version = "1.6.0";
meta = cfg.meta;
executable = M1-0.package;
args = [
"--architecture"
architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
"-f"
M1-macro_M1
"-f"
M1-macro-footer_M1
"-o"
(builtins.placeholder "out")
];
};
in
[
"--architecture"
architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"--base-address"
(
if config.aux.system == "x86_64-linux" then
"0x00600000"
else if config.aux.system == "aarch64-linux" then
"0x00600000"
else if config.aux.system == "i686-linux" then
"0x08048000"
else
builtins.throw "Unsupported system: ${config.aux.system}"
)
"-f"
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
"-f"
M1-macro_hex2
"-o"
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,177 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.hex2;
hex0 = config.aux.foundation.stages.stage0.hex0;
catm = config.aux.foundation.stages.stage0.catm;
M0 = config.aux.foundation.stages.stage0.M0;
cc_arch = config.aux.foundation.stages.stage0.cc_arch;
M2 = config.aux.foundation.stages.stage0.M2;
blood-elf = config.aux.foundation.stages.stage0.blood-elf;
M1 = config.aux.foundation.stages.stage0.M1;
hex2-1 = config.aux.foundation.stages.stage0.hex2-1;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in
{
options.aux.foundation.stages.stage0.hex2 = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for hex2.";
};
};
config = {
aux.foundation.stages.stage0.hex2 = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "hex2";
version = "1.6.0";
meta = cfg.meta;
executable = hex2-1.package;
args =
let
hex2_linker_M1 = builders.raw.build {
pname = "hex2_linker_M1";
version = "1.6.0";
meta = cfg.meta;
executable = M2.package;
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/sys/types.h"
"-f"
"${sources.m2libc}/stddef.h"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f"
"${sources.m2libc}/fcntl.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f"
"${sources.m2libc}/stdlib.c"
"-f"
"${sources.m2libc}/stdio.h"
"-f"
"${sources.m2libc}/stdio.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/hex2.h"
"-f"
"${sources.mescc-tools}/hex2_linker.c"
"-f"
"${sources.mescc-tools}/hex2_word.c"
"-f"
"${sources.mescc-tools}/hex2.c"
"--debug"
"-o"
(builtins.placeholder "out")
];
};
hex2_linker-footer_M1 = builders.raw.build {
pname = "hex2_linker-footer_M1";
version = "1.6.0";
meta = cfg.meta;
executable = blood-elf.package;
args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
"-f"
hex2_linker_M1
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-o"
(builtins.placeholder "out")
];
};
hex2_linker_hex2 = builders.raw.build {
pname = "hex2_linker_hex2";
version = "1.6.0";
meta = cfg.meta;
executable = M1.package;
args = [
"--architecture"
architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
"-f"
hex2_linker_M1
"-f"
hex2_linker-footer_M1
"-o"
(builtins.placeholder "out")
];
};
in
[
"--architecture"
architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"--base-address"
(
if config.aux.system == "x86_64-linux" then
"0x00600000"
else if config.aux.system == "aarch64-linux" then
"0x00600000"
else if config.aux.system == "i686-linux" then
"0x08048000"
else
builtins.throw "Unsupported system: ${config.aux.system}"
)
"-f"
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
"-f"
hex2_linker_hex2
"-o"
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,179 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.kaem-unwrapped;
hex0 = config.aux.foundation.stages.stage0.hex0;
catm = config.aux.foundation.stages.stage0.catm;
M0 = config.aux.foundation.stages.stage0.M0;
cc_arch = config.aux.foundation.stages.stage0.cc_arch;
M2 = config.aux.foundation.stages.stage0.M2;
blood-elf = config.aux.foundation.stages.stage0.blood-elf;
M1 = config.aux.foundation.stages.stage0.M1;
hex2 = config.aux.foundation.stages.stage0.hex2;
system = config.aux.system;
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in
{
options.aux.foundation.stages.stage0.kaem-unwrapped = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Collection of tools for use in bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/oriansj/stage0-posix";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for kaem-unwrapped.";
};
};
config = {
aux.foundation.stages.stage0.kaem-unwrapped = {
package = lib.modules.overrides.default (
builders.raw.build {
pname = "kaem-unwrapped";
version = "1.6.0";
meta = cfg.meta;
executable = hex2.package;
args =
let
kaem_M1 = builders.raw.build {
pname = "kaem_M1";
version = "1.6.0";
meta = cfg.meta;
executable = M2.package;
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/sys/types.h"
"-f"
"${sources.m2libc}/stddef.h"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f"
"${sources.m2libc}/fcntl.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f"
"${sources.m2libc}/string.c"
"-f"
"${sources.m2libc}/stdlib.c"
"-f"
"${sources.m2libc}/stdio.h"
"-f"
"${sources.m2libc}/stdio.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/Kaem/kaem.h"
"-f"
"${sources.mescc-tools}/Kaem/variable.c"
"-f"
"${sources.mescc-tools}/Kaem/kaem_globals.c"
"-f"
"${sources.mescc-tools}/Kaem/kaem.c"
"--debug"
"-o"
(builtins.placeholder "out")
];
};
kaem-footer_M1 = builders.raw.build {
pname = "kaem-footer_M1";
version = "1.6.0";
meta = cfg.meta;
executable = blood-elf.package;
args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
"-f"
kaem_M1
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-o"
(builtins.placeholder "out")
];
};
kaem_hex2 = builders.raw.build {
pname = "kaem_hex2";
version = "1.6.0";
meta = cfg.meta;
executable = M1.package;
args = [
"--architecture"
architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
"-f"
kaem_M1
"-f"
kaem-footer_M1
"-o"
(builtins.placeholder "out")
];
};
in
[
"--architecture"
architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"--base-address"
(
if config.aux.system == "x86_64-linux" then
"0x00600000"
else if config.aux.system == "aarch64-linux" then
"0x00600000"
else if config.aux.system == "i686-linux" then
"0x08048000"
else
builtins.throw "Unsupported system: ${config.aux.system}"
)
"-f"
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
"-f"
kaem_hex2
"-o"
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,92 +0,0 @@
{ lib, config }:
let
system = config.aux.system;
architecture = config.aux.foundation.stages.stage0.architecture.base;
in
{
options.aux.foundation.stages.stage0.sources = {
base = lib.options.create {
type = lib.types.string;
description = "The source for the hex0 build files.";
};
m2libc = lib.options.create {
type = lib.types.string;
description = "The source for the M2libc build files.";
};
m2planet = lib.options.create {
type = lib.types.string;
description = "The source for the M2-Planet build files.";
};
m2mesoplanet = lib.options.create {
type = lib.types.string;
description = "The source for the M2-Mesoplanet build files.";
};
mescc-tools = lib.options.create {
type = lib.types.string;
description = "The source for the mescc-tools build files.";
};
mescc-tools-extra = lib.options.create {
type = lib.types.string;
description = "The source for the mescc-tools-extra build files.";
};
};
config = {
aux.foundation.stages.stage0.sources = {
# All sources are combined a central repository via submodules. Due to potential quirks surrounding
# fetching that, we are instead fetching each submodule directly. The central repository is located
# here: https://github.com/oriansj/stage0-posix
base =
if architecture == "AMD64" then
builtins.fetchTarball {
url = "https://github.com/oriansj/stage0-posix-amd64/archive/93fbe4c08772d8df1412e2554668e24cf604088c.tar.gz";
sha256 = "10d1xnjzqplpfip3pm89bydd501x1bcgkg7lkkadyq5bqpad5flp";
}
else if architecture == "AArch64" then
# FIXME: We may need to patch the aarch64 variant.
# https://github.com/oriansj/M2libc/pull/17
builtins.fetchTarball {
url = "https://github.com/oriansj/stage0-posix-aarch64/archive/39a43f803d572b53f95d42507202152eeda18361.tar.gz";
sha256 = "1x607hr3n5j89394d156r23igpx8hifjd14ygksx7902rlwrrry2";
}
else if architecture == "x86" then
builtins.fetchTarball {
url = "https://github.com/oriansj/stage0-posix-x86/archive/e86bf7d304bae5ce5ccc88454bb60cf0837e941f.tar.gz";
sha256 = "1c1fk793yzq8zbg60n2zd22fsmirc3zr26fj0iskap456g84nxv8";
}
else
builtins.throw "Unsupported architecture for stage0: ${architecture}";
m2libc = builtins.fetchTarball {
url = "https://github.com/oriansj/M2libc/archive/de7c75f144176c3b9be77695d9bf94440445aeae.tar.gz";
sha256 = "01k81zn8yx4jg6fbcjgkrf9rp074yikkmwqykdgi9143yfb2k3yv";
};
m2planet = builtins.fetchTarball {
url = "https://github.com/oriansj/M2-Planet/archive/51dc63b349ca13fa57b345964254cf26930c0a7d.tar.gz";
sha256 = "1kksk260dh6qd0dzgl9vgs67fs0lsxs9w0gniy0ii5fgmqxi8p65";
};
m2mesoplanet = builtins.fetchTarball {
url = "https://github.com/oriansj/M2-Mesoplanet/archive/c80645f06b035debaa08e95da3206346a9f61b97.tar.gz";
sha256 = "02vzqln38ylfnd88p87935yf26i60gkbv93ns5j7parqgyyz2kl4";
};
mescc-tools = builtins.fetchTarball {
url = "https://github.com/oriansj/mescc-tools/archive/5d37991e22d1e4147411a766f4410508ba872962.tar.gz";
sha256 = "1xgpqhc5diim3rr9a00939976svrbhfp4v5970548a137fdynl4c";
};
mescc-tools-extra = builtins.fetchTarball {
url = "https://github.com/oriansj/mescc-tools-extra/archive/c1bd4ab4c5b994d8167c1e6dfc14050dc151a911.tar.gz";
sha256 = "0v8vxn3a8rxbgi6vcw73jqkw9j5vg3qlvd4sxk2w0fpybjml8brd";
};
};
};
}

View file

@ -1,162 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.bash.boot;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.bash.boot = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU Bourne-Again Shell, the de facto standard shell on Linux";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/bash";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for bash-boot.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.bash.boot = {
version = "2.05b";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/bash/bash-${cfg.version}.tar.gz";
sha256 = "1r1z2qdw3rz668nxrzwa14vk2zcn00hw7mpjn384picck49d80xs";
};
package =
let
# Thanks to the live-bootstrap project!
# See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/bash-2.05b/bash-2.05b.kaem
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/bash-2.05b";
main_mk = builtins.fetchurl {
url = "${liveBootstrap}/mk/main.mk";
sha256 = "0hj29q3pq3370p18sxkpvv9flb7yvx2fs96xxlxqlwa8lkimd0j4";
};
common_mk = builtins.fetchurl {
url = "${liveBootstrap}/mk/common.mk";
sha256 = "09rigxxf85p2ybnq248sai1gdx95yykc8jmwi4yjx389zh09mcr8";
};
builtins_mk = builtins.fetchurl {
url = "${liveBootstrap}/mk/builtins.mk";
sha256 = "0939dy5by1xhfmsjj6w63nlgk509fjrhpb2crics3dpcv7prl8lj";
};
patches = [
# mes libc does not have locale support
(builtins.fetchurl {
url = "${liveBootstrap}/patches/mes-libc.patch";
sha256 = "0zksdjf6zbb3p4hqg6plq631y76hhhgab7kdvf7cnpk8bcykn12z";
})
# int name, namelen; is wrong for mes libc, it is char* name, so we modify tinycc
# to reflect this.
(builtins.fetchurl {
url = "${liveBootstrap}/patches/tinycc.patch";
sha256 = "042d2kr4a8klazk1hlvphxr6frn4mr53k957aq3apf6lbvrjgcj2";
})
# add ifdef's for features we don't want
(builtins.fetchurl {
url = "${liveBootstrap}/patches/missing-defines.patch";
sha256 = "1q0k1kj5mrvjkqqly7ki5575a5b3hy1ywnmvhrln318yh67qnkj4";
})
# mes libc + setting locale = not worky
(builtins.fetchurl {
url = "${liveBootstrap}/patches/locale.patch";
sha256 = "1p1q1slhafsgj8x4k0dpn9h6ryq5fwfx7dicbbxhldbw7zvnnbx9";
})
# We do not have /dev at this stage of the bootstrap, including /dev/tty
(builtins.fetchurl {
url = "${liveBootstrap}/patches/dev-tty.patch";
sha256 = "1315slv5f7ziajqyxg4jlyanf1xwd06xw14y6pq7xpm3jzjk55j9";
})
];
in
builders.kaem.build {
name = "bash-${cfg.version}";
meta = cfg.meta;
src = cfg.src;
deps.build.host = [
stage1.tinycc.mes.compiler.package
stage1.gnumake.boot.package
stage1.gnupatch.package
stage1.coreutils.boot.package
];
script = ''
# Unpack
ungz --file ${cfg.src} --output bash.tar
untar --file bash.tar
rm bash.tar
cd bash-${cfg.version}
# Patch
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
# Configure
cp ${main_mk} Makefile
cp ${builtins_mk} builtins/Makefile
cp ${common_mk} common.mk
touch config.h
touch include/version.h
touch include/pipesize.h
# Build
make \
CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib" \
mkbuiltins
cd builtins
make \
CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib" \
libbuiltins.a
cd ..
make CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib"
# Install
install -D bash ''${out}/bin/bash
ln -s bash ''${out}/bin/sh
'';
};
};
};
}

View file

@ -1,125 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.bash;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
includes = [ ./boot.nix ];
options.aux.foundation.stages.stage1.bash = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU Bourne-Again Shell, the de facto standard shell on Linux";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/bash";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {
type = lib.types.string;
description = "The main program of the package.";
default.value = "bash";
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for bash.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.bash = {
version = "5.2.15";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/bash/bash-${cfg.version}.tar.gz";
sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk";
};
package =
let
patches = [
# flush output for generated code
./patches/mksignames-flush.patch
];
in
builders.bash.boot.build {
name = "bash-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.musl.compiler.package
stage1.coreutils.package
stage1.gnumake.package
stage1.gnupatch.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gnutar.musl.package
stage1.gawk.boot.package
stage1.gzip.package
stage1.diffutils.package
];
script = ''
# Unpack
tar xzf ${cfg.src}
cd bash-${cfg.version}
# Patch
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
# Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export AR="tcc -ar"
export LD=tcc
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
--without-bash-malloc
# Build
make -j $NIX_BUILD_CORES SHELL=bash
# Install
make -j $NIX_BUILD_CORES install
ln -s bash $out/bin/sh
'';
};
};
};
}

View file

@ -1,11 +0,0 @@
--- a/support/mksignames.c
+++ b/support/mksignames.c
@@ -68,6 +68,7 @@ write_signames (stream)
fprintf (stream, "};\n\n");
fprintf (stream, "#define initialize_signames()\n\n");
#endif
+ fflush(stream);
}
int

View file

@ -1,146 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.binutils;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.binutils = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Tools for manipulating binaries (linker, assembler, etc.)";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/binutils";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for binutils.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.binutils = {
version = "2.41";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/binutils/binutils-${cfg.version}.tar.xz";
sha256 = "rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
};
package =
let
patches = [
# Make binutils output deterministic by default.
./patches/deterministic.patch
];
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build}"
"--host=${platform.host}"
"--with-sysroot=/"
"--enable-deterministic-archives"
# depends on bison
"--disable-gprofng"
# Turn on --enable-new-dtags by default to make the linker set
# RUNPATH instead of RPATH on binaries. This is important because
# RUNPATH can be overridden using LD_LIBRARY_PATH at runtime.
"--enable-new-dtags"
# By default binutils searches $libdir for libraries. This brings in
# libbfd and libopcodes into a default visibility. Drop default lib
# path to force users to declare their use of these libraries.
"--with-lib-path=:"
];
in
builders.bash.boot.build {
name = "binutils-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.musl.compiler.package
stage1.gnumake.package
stage1.gnupatch.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gnutar.musl.package
stage1.gzip.package
stage1.gawk.package
stage1.diffutils.package
stage1.xz.package
];
script = ''
# Unpack
cp ${cfg.src} binutils.tar.xz
unxz binutils.tar.xz
tar xf binutils.tar
rm binutils.tar
cd binutils-${cfg.version}
# Patch
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
sed -i 's|/bin/sh|${stage1.bash.boot.package}/bin/bash|' \
missing install-sh mkinstalldirs
# see libtool's 74c8993c178a1386ea5e2363a01d919738402f30
sed -i 's/| \$NL2SP/| sort | $NL2SP/' ltmain.sh
# alias makeinfo to true
mkdir aliases
ln -s ${stage1.coreutils.package}/bin/true aliases/makeinfo
export PATH="$(pwd)/aliases/:$PATH"
# Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export AR="tcc -ar"
export lt_cv_sys_max_cmd_len=32768
export CFLAGS="-D__LITTLE_ENDIAN__=1"
bash ./configure ${builtins.concatStringsSep " " configureFlags}
# Build
make -j $NIX_BUILD_CORES all-libiberty all-gas all-bfd all-libctf all-zlib all-gprof
make all-ld # race condition on ld/.deps/ldwrite.Po, serialize
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
'';
};
};
};
}

View file

@ -1,13 +0,0 @@
diff -ur orig/binutils-2.23.1/ld/ldlang.c binutils-2.23.1/ld/ldlang.c
--- orig/ld/ldlang.c
+++ new/ld/ldlang.c
@@ -3095,6 +3095,8 @@
ldfile_output_machine))
einfo (_("%P%F:%s: can not set architecture: %E\n"), name);
+ link_info.output_bfd->flags |= BFD_DETERMINISTIC_OUTPUT;
+
link_info.hash = bfd_link_hash_table_create (link_info.output_bfd);
if (link_info.hash == NULL)
einfo (_("%P%F: can not create hash table: %E\n"));

View file

@ -1,104 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.bison;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.bison = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Yacc-compatible parser generator.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/bison";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for bison.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.bison = {
version = "3.8.2";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/bison/bison-${cfg.version}.tar.xz";
sha256 = "m7oCFMz38QecXVkhAEUie89hlRmEDr+oDNOEnP9aW/I=";
};
package = builders.bash.build {
name = "bison-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.gcc.package
stage1.musl.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.package
stage1.diffutils.package
stage1.findutils.package
stage1.gnutar.package
stage1.xz.package
stage1.gnum4.package
];
script = ''
# Unpack
tar xf ${cfg.src}
cd bison-${cfg.version}
# Configure
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
CC=musl-gcc
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
'';
};
};
};
}

View file

@ -1,96 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.bzip2;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.bzip2 = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "High-quality data compression program";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.sourceware.org/bzip2";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.bsdOriginal;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
# TODO: Support more platforms.
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for bzip2.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.bzip2 = {
version = "1.0.8";
src = builtins.fetchurl {
url = "https://sourceware.org/pub/bzip2/bzip2-${cfg.version}.tar.gz";
sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb";
};
package = builders.bash.build {
name = "bzip2-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.musl.compiler.package
stage1.gnumake.package
stage1.gnutar.musl.package
stage1.gzip.package
];
script = ''
# Unpack
tar xzf ${cfg.src}
cd bzip2-${cfg.version}
# Build
make \
-j $NIX_BUILD_CORES \
CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" \
AR="tcc -ar" \
bzip2 bzip2recover
# Install
make install -j $NIX_BUILD_CORES PREFIX=$out
'';
};
};
};
}

View file

@ -1,138 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.coreutils.boot;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.coreutils.boot = {
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for coreutils-boot.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.coreutils.boot = {
version = "5.0";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/coreutils/coreutils-${cfg.version}.tar.gz";
sha256 = "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62";
};
package =
let
# Thanks to the live-bootstrap project!
# See https://github.com/fosslinux/live-bootstrap/blob/a8752029f60217a5c41c548b16f5cdd2a1a0e0db/sysa/coreutils-5.0/coreutils-5.0.kaem
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/a8752029f60217a5c41c548b16f5cdd2a1a0e0db/sysa/coreutils-5.0";
makefile = builtins.fetchurl {
url = "${liveBootstrap}/mk/main.mk";
sha256 = "0njg4xccxfqrslrmlb8ls7h6hlnfmdx42nvxwmca8flvczwrplfd";
};
patches = [
# modechange.h uses functions defined in sys/stat.h, so we need to move it to
# after sys/stat.h include.
(builtins.fetchurl {
url = "${liveBootstrap}/patches/modechange.patch";
sha256 = "04xa4a5w2syjs3xs6qhh8kdzqavxnrxpxwyhc3qqykpk699p3ms5";
})
# mbstate_t is a struct that is required. However, it is not defined by mes libc.
(builtins.fetchurl {
url = "${liveBootstrap}/patches/mbstate.patch";
sha256 = "0rz3c0sflgxjv445xs87b83i7gmjpl2l78jzp6nm3khdbpcc53vy";
})
# strcoll() does not exist in mes libc, change it to strcmp.
(builtins.fetchurl {
url = "${liveBootstrap}/patches/ls-strcmp.patch";
sha256 = "0lx8rz4sxq3bvncbbr6jf0kyn5bqwlfv9gxyafp0541dld6l55p6";
})
# getdate.c is pre-compiled from getdate.y
# At this point we don't have bison yet and in any case getdate.y does not
# compile when generated with modern bison.
(builtins.fetchurl {
url = "${liveBootstrap}/patches/touch-getdate.patch";
sha256 = "1xd3z57lvkj7r8vs5n0hb9cxzlyp58pji7d335snajbxzwy144ma";
})
# touch: add -h to change symlink timestamps, where supported
(builtins.fetchurl {
url = "${liveBootstrap}/patches/touch-dereference.patch";
sha256 = "0wky5r3k028xwyf6g6ycwqxzc7cscgmbymncjg948vv4qxsxlfda";
})
# strcoll() does not exist in mes libc, change it to strcmp.
(builtins.fetchurl {
url = "${liveBootstrap}/patches/expr-strcmp.patch";
sha256 = "19f31lfsm1iwqzvp2fyv97lmqg4730prfygz9zip58651jf739a9";
})
# strcoll() does not exist in mes libc, change it to strcmp.
# hard_LC_COLLATE is used but not declared when HAVE_SETLOCALE is unset.
(builtins.fetchurl {
url = "${liveBootstrap}/patches/sort-locale.patch";
sha256 = "0bdch18mpyyxyl6gyqfs0wb4pap9flr11izqdyxccx1hhz0a2i6c";
})
# don't assume fopen cannot return stdin or stdout.
(builtins.fetchurl {
url = "${liveBootstrap}/patches/uniq-fopen.patch";
sha256 = "0qs6shyxl9j4h34v5j5sgpxrr4gjfljd2hxzw416ghwc3xzv63fp";
})
];
in
builders.kaem.build {
name = "coreutils-boot-${cfg.version}";
meta = stage1.coreutils.meta;
deps.build.host = [
stage1.tinycc.mes.compiler.package
stage1.gnumake.boot.package
stage1.gnupatch.package
];
script = ''
# Unpack
ungz --file ${cfg.src} --output coreutils.tar
untar --file coreutils.tar
rm coreutils.tar
cd coreutils-${cfg.version}
# Patch
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
# Configure
catm config.h
cp lib/fnmatch_.h lib/fnmatch.h
cp lib/ftw_.h lib/ftw.h
cp lib/search_.h lib/search.h
rm src/dircolors.h
# Build
make -f ${makefile} \
CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib" \
PREFIX=''${out}
# Check
./src/echo "Hello coreutils!"
# Install
./src/mkdir -p ''${out}/bin
make -f ${makefile} install PREFIX=''${out}
'';
};
};
};
}

View file

@ -1,112 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.coreutils;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
includes = [ ./boot.nix ];
options.aux.foundation.stages.stage1.coreutils = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "The GNU Core Utilities.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/coreutils";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for coreutils.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.coreutils = {
version = "9.4";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/coreutils/coreutils-${cfg.version}.tar.gz";
sha256 = "X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
};
package =
let
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build}"
"--host=${platform.host}"
# musl 1.1.x doesn't use 64bit time_t
"--disable-year2038"
# libstdbuf.so fails in static builds
"--enable-no-install-program=stdbuf"
];
in
builders.bash.boot.build {
name = "coreutils-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.musl.compiler.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.package
stage1.gnutar.musl.package
stage1.gzip.package
];
script = ''
# Unpack
tar xzf ${cfg.src}
cd coreutils-${cfg.version}
# Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export LD=tcc
bash ./configure ${builtins.concatStringsSep " " configureFlags}
# Build
make -j $NIX_BUILD_CORES AR="tcc -ar" MAKEINFO="true"
# Install
make -j $NIX_BUILD_CORES install MAKEINFO="true"
'';
};
};
};
}

View file

@ -1,105 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1;
stage1 = config.aux.foundation.stages.stage1;
in
{
includes = [
./nyacc
./mes
./ln-boot
./tinycc
./gnupatch
./gnumake
./coreutils
./heirloom
./bash
./gnused
./gnugrep
./gnutar
./gzip
./musl
./gawk
./xz
./diffutils
./binutils
./findutils
./bzip2
./gcc
./gnum4
./bison
./linux-headers
./zlib
./python
];
config = {
exports = {
packages = {
# These packages are built using Kaem.
stage1-nyacc = stage1.nyacc.package;
stage1-mes = stage1.mes.compiler.package;
stage1-mes-libs = stage1.mes.libs.package;
stage1-ln-boot = stage1.ln-boot.package;
stage1-mes-libc = stage1.mes.libc.package;
stage1-tinycc-boot = stage1.tinycc.boot.compiler.package;
stage1-tinycc-boot-libs = stage1.tinycc.boot.libs.package;
stage1-tinycc-mes = stage1.tinycc.mes.compiler.package;
stage1-tinycc-mes-libs = stage1.tinycc.mes.libs.package;
stage1-gnupatch = stage1.gnupatch.package;
stage1-gnumake-boot = stage1.gnumake.boot.package;
stage1-coreutils-boot = stage1.coreutils.boot.package;
stage1-heirloom-devtools = stage1.heirloom.devtools.package;
stage1-bash-boot = stage1.bash.boot.package;
# These packages are built using Bash v2.
stage1-gnused-boot = stage1.gnused.boot.package;
stage1-gnugrep = stage1.gnugrep.package;
stage1-gnutar-boot = stage1.gnutar.boot.package;
stage1-gzip = stage1.gzip.package;
stage1-musl-boot = stage1.musl.boot.package;
stage1-tinycc-musl = stage1.tinycc.musl.compiler.package;
stage1-tinycc-musl-libs = stage1.tinycc.musl.libs.package;
stage1-gawk-boot = stage1.gawk.boot.package;
stage1-gnused = stage1.gnused.package;
stage1-gnumake = stage1.gnumake.package;
stage1-gnutar-musl = stage1.gnutar.musl.package;
stage1-gawk = stage1.gawk.package;
stage1-xz = stage1.xz.package;
stage1-diffutils = stage1.diffutils.package;
stage1-coreutils = stage1.coreutils.package;
stage1-binutils = stage1.binutils.package;
stage1-findutils = stage1.findutils.package;
stage1-heirloom = stage1.heirloom.package;
stage1-bash = stage1.bash.package;
# These packages are built using Bash v5
stage1-gcc-46 = stage1.gcc.v46.package;
stage1-musl = stage1.musl.package;
stage1-bzip2 = stage1.bzip2.package;
stage1-gcc-46-cxx = stage1.gcc.v46.cxx.package;
stage1-gnutar = stage1.gnutar.package;
stage1-gcc-8 = stage1.gcc.v8.package;
stage1-gcc = stage1.gcc.package;
stage1-gnum4 = stage1.gnum4.package;
stage1-bison = stage1.bison.package;
stage1-linux-headers = stage1.linux-headers.package;
stage1-zlib = stage1.zlib.package;
stage1-python = stage1.python.package;
};
extras = {
stage1 = {
mes = {
src = stage1.mes.src;
libs = {
prefix = stage1.mes.libs.prefix;
};
};
};
};
};
};
}

View file

@ -1,104 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.diffutils;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.diffutils = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Commands for showing the differences between files (diff, cmp, etc.)";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/diffutils";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Only;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for diffutils.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.diffutils = {
version = "3.8";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/diffutils/diffutils-${cfg.version}.tar.xz";
sha256 = "pr3X0bMSZtEcT03mwbdI1GB6sCMa9RiPwlM9CuJDj+w=";
};
package = builders.bash.boot.build {
name = "diffutils-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.musl.compiler.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gnutar.musl.package
stage1.gawk.package
stage1.xz.package
];
script = ''
# Unpack
cp ${cfg.src} diffutils.tar.xz
unxz diffutils.tar.xz
tar xf diffutils.tar
rm diffutils.tar
cd diffutils-${cfg.version}
# Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export LD=tcc
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host}
# Build
make -j $NIX_BUILD_CORES AR="tcc -ar"
# Install
make -j $NIX_BUILD_CORES install
'';
};
};
};
}

View file

@ -1,110 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.findutils;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.findutils = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU Find Utilities, the basic directory searching utilities of the GNU operating system";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/findutils";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for findutils.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.findutils = {
version = "4.9.0";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/findutils/findutils-${cfg.version}.tar.xz";
sha256 = "or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4=";
};
package = builders.bash.boot.build {
name = "findutils-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.musl.compiler.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gnutar.musl.package
stage1.gawk.package
stage1.xz.package
];
script = ''
# Unpack
cp ${cfg.src} findutils.tar.xz
unxz findutils.tar.xz
tar xf findutils.tar
rm findutils.tar
cd findutils-${cfg.version}
# Patch
# configure fails to accurately detect PATH_MAX support
sed -i 's/chdir_long/chdir/' gl/lib/save-cwd.c
# Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export AR="tcc -ar"
export LD=tcc
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host}
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
'';
};
};
};
}

View file

@ -1,88 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gawk.boot;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.gawk.boot = {
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gnutar-boot.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.gawk.boot = {
version = "3.0.6";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/gawk/gawk-${cfg.version}.tar.gz";
sha256 = "1z4bibjm7ldvjwq3hmyifyb429rs2d9bdwkvs0r171vv1khpdwmb";
};
package =
let
patches = [
# for reproducibility don't generate date stamp
./patches/no-stamp.patch
];
in
builders.bash.boot.build {
name = "gawk-boot-${cfg.version}";
meta = stage1.gawk.meta;
deps.build.host = [
stage1.tinycc.mes.compiler.package
stage1.gnumake.boot.package
stage1.gnused.boot.package
stage1.gnugrep.package
stage1.gnupatch.package
];
script = ''
# Unpack
ungz --file ${cfg.src} --output gawk.tar
untar --file gawk.tar
rm gawk.tar
cd gawk-${cfg.version}
# Patch
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
# Configure
export CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib"
export ac_cv_func_getpgrp_void=yes
export ac_cv_func_tzset=yes
chmod 0755 missing
bash ./configure \
--build=${platform.build} \
--host=${platform.host} \
--disable-nls \
--prefix=$out
# Build
make gawk
# Install
install -D gawk $out/bin/gawk
ln -s gawk $out/bin/awk
'';
};
};
};
}

View file

@ -1,110 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gawk;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
includes = [ ./boot.nix ];
options.aux.foundation.stages.stage1.gawk = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU implementation of the Awk programming language";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/gawk";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {
type = lib.types.string;
description = "The main program of the package.";
default.value = "awk";
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gawk.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.gawk = {
version = "5.2.2";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/gawk/gawk-${cfg.version}.tar.gz";
sha256 = "lFrvfM/xAfILIqEIArwAXplKsrjqPnJMwaGXxi9B9lA=";
};
package = builders.bash.boot.build {
name = "gawk-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.musl.compiler.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gnutar.musl.package
stage1.gzip.package
stage1.gawk.boot.package
];
script = ''
# Unpack
tar xzf ${cfg.src}
cd gawk-${cfg.version}
# Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export AR="tcc -ar"
export LD=tcc
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host}
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
'';
};
};
};
}

View file

@ -1,11 +0,0 @@
--- configure
+++ configure
@@ -3676,7 +3676,6 @@ cat >> $CONFIG_STATUS <<EOF
EOF
cat >> $CONFIG_STATUS <<\EOF
-date > stamp-h
exit 0
EOF
chmod +x $CONFIG_STATUS

View file

@ -1,222 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gcc;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
includes = [
./v4.6.nix
./v4.6.cxx.nix
./v8.nix
];
options.aux.foundation.stages.stage1.gcc = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU Compiler Collection.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://gcc.gnu.org";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gcc.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
cc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The cc source for the package.";
};
};
gmp = {
src = lib.options.create {
type = lib.types.derivation;
description = "The gmp source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
};
mpfr = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpfr source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
};
mpc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpc source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
};
isl = {
src = lib.options.create {
type = lib.types.derivation;
description = "The isl source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of isl.";
};
};
};
config = {
aux.foundation.stages.stage1.gcc = {
version = "13.2.0";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/gcc/gcc-${cfg.version}/gcc-${cfg.version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = {
version = "6.3.0";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/gmp/gmp-${cfg.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
};
mpfr = {
version = "4.2.1";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/mpfr/mpfr-${cfg.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
};
mpc = {
version = "1.3.1";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/mpc/mpc-${cfg.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
};
isl = {
version = "0.24";
src = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${cfg.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
package = builders.bash.build {
name = "gcc-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.gcc.v8.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.boot.package
stage1.diffutils.package
stage1.findutils.package
stage1.gnutar.package
stage1.gzip.package
stage1.bzip2.package
stage1.xz.package
];
script = ''
# Unpack
tar xf ${cfg.src}
tar xf ${cfg.gmp.src}
tar xf ${cfg.mpfr.src}
tar xf ${cfg.mpc.src}
tar xf ${cfg.isl.src}
cd gcc-${cfg.version}
ln -s ../gmp-${cfg.gmp.version} gmp
ln -s ../mpfr-${cfg.mpfr.version} mpfr
ln -s ../mpc-${cfg.mpc.version} mpc
ln -s ../isl-${cfg.isl.version} isl
# Patch
# force musl even if host triple is gnu
sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host
# Configure
export CC="gcc -Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export CXX="g++ -Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export LIBRARY_PATH="${stage1.musl.package}/lib"
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
--with-native-system-header-dir=/include \
--with-sysroot=${stage1.musl.package} \
--enable-languages=c,c++ \
--disable-bootstrap \
--disable-libsanitizer \
--disable-lto \
--disable-multilib \
--disable-plugin
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install-strip
'';
};
};
};
}

View file

@ -1,12 +0,0 @@
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -440,7 +440,7 @@ LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h
LTO_SYMTAB_H = $(srcdir)/../include/lto-symtab.h
# Default native SYSTEM_HEADER_DIR, to be overridden by targets.
-NATIVE_SYSTEM_HEADER_DIR = /usr/include
+# NATIVE_SYSTEM_HEADER_DIR = /usr/include
# Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@

View file

@ -1,187 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gcc.v46.cxx;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.gcc.v46.cxx = {
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gcc-cxx.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
cc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The cc source for the package.";
};
};
gmp = {
src = lib.options.create {
type = lib.types.derivation;
description = "The gmp source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
};
mpfr = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpfr source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
};
mpc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpc source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
};
};
config = {
aux.foundation.stages.stage1.gcc.v46.cxx = {
version = "4.6.4";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/gcc/gcc-${cfg.version}/gcc-core-${cfg.version}.tar.gz";
sha256 = "173kdb188qg79pcz073cj9967rs2vzanyjdjyxy9v0xb0p5sad75";
};
cc = {
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/gcc/gcc-${cfg.version}/gcc-g++-${cfg.version}.tar.gz";
sha256 = "1fqqk5zkmdg4vmqzdmip9i42q6b82i3f6yc0n86n9021cr7ms2k9";
};
};
gmp = {
version = "4.3.2";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/gmp/gmp-${cfg.gmp.version}.tar.gz";
sha256 = "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv";
};
};
mpfr = {
version = "2.4.2";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/mpfr/mpfr-${cfg.mpfr.version}.tar.gz";
sha256 = "0dxn4904dra50xa22hi047lj8kkpr41d6vb9sd4grca880c7wv94";
};
};
mpc = {
version = "1.0.3";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/mpc/mpc-${cfg.mpc.version}.tar.gz";
sha256 = "1hzci2zrrd7v3g1jk35qindq05hbl0bhjcyyisq9z209xb3fqzb1";
};
};
package =
let
patches = [
# Remove hardcoded NATIVE_SYSTEM_HEADER_DIR
./patches/no-system-headers.patch
];
in
builders.bash.build {
name = "gcc-cxx-${cfg.version}";
meta = stage1.gcc.meta;
deps.build.host = [
stage1.gcc.v46.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnupatch.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.boot.package
stage1.diffutils.package
stage1.findutils.package
stage1.gnutar.musl.package
stage1.gzip.package
];
script = ''
# Unpack
tar xzf ${cfg.src}
tar xzf ${cfg.cc.src}
tar xzf ${cfg.gmp.src}
tar xzf ${cfg.mpfr.src}
tar xzf ${cfg.mpc.src}
cd gcc-${cfg.version}
ln -s ../gmp-${cfg.gmp.version} gmp
ln -s ../mpfr-${cfg.mpfr.version} mpfr
ln -s ../mpc-${cfg.mpc.version} mpc
# Patch
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
# doesn't recognise musl
sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host
# Configure
export CC="gcc -Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export C_INCLUDE_PATH="${stage1.musl.package}/include"
export CPLUS_INCLUDE_PATH="$C_INCLUDE_PATH"
export LIBRARY_PATH="${stage1.musl.package}/lib"
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
--with-native-system-header-dir=${stage1.musl.package}/include \
--with-build-sysroot=${stage1.musl.package} \
--enable-languages=c,c++ \
--disable-bootstrap \
--disable-libmudflap \
--disable-libstdcxx-pch \
--disable-lto \
--disable-multilib
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
'';
};
};
};
}

View file

@ -1,204 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gcc.v46;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.gcc.v46 = {
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gcc.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
cc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The cc source for the package.";
};
};
gmp = {
src = lib.options.create {
type = lib.types.derivation;
description = "The gmp source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
};
mpfr = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpfr source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
};
mpc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpc source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
};
};
config = {
aux.foundation.stages.stage1.gcc.v46 = {
version = "4.6.4";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/gcc/gcc-${cfg.version}/gcc-core-${cfg.version}.tar.gz";
sha256 = "173kdb188qg79pcz073cj9967rs2vzanyjdjyxy9v0xb0p5sad75";
};
cc = {
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/gcc/gcc-${cfg.version}/gcc-g++-${cfg.version}.tar.gz";
sha256 = "1fqqk5zkmdg4vmqzdmip9i42q6b82i3f6yc0n86n9021cr7ms2k9";
};
};
gmp = {
version = "4.3.2";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/gmp/gmp-${cfg.gmp.version}.tar.gz";
sha256 = "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv";
};
};
mpfr = {
version = "2.4.2";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/mpfr/mpfr-${cfg.mpfr.version}.tar.gz";
sha256 = "0dxn4904dra50xa22hi047lj8kkpr41d6vb9sd4grca880c7wv94";
};
};
mpc = {
version = "1.0.3";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/mpc/mpc-${cfg.mpc.version}.tar.gz";
sha256 = "1hzci2zrrd7v3g1jk35qindq05hbl0bhjcyyisq9z209xb3fqzb1";
};
};
package =
let
patches = [
# Remove hardcoded NATIVE_SYSTEM_HEADER_DIR
./patches/no-system-headers.patch
];
in
builders.bash.build {
name = "gcc-${cfg.version}";
meta = stage1.gcc.meta;
deps.build.host = [
stage1.tinycc.musl.compiler.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnupatch.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.boot.package
stage1.diffutils.package
stage1.findutils.package
stage1.gnutar.musl.package
stage1.gzip.package
];
script = ''
# Unpack
tar xzf ${cfg.src}
tar xzf ${cfg.cc.src}
tar xzf ${cfg.gmp.src}
tar xzf ${cfg.mpfr.src}
tar xzf ${cfg.mpc.src}
cd gcc-${cfg.version}
ln -s ../gmp-${cfg.gmp.version} gmp
ln -s ../mpfr-${cfg.mpfr.version} mpfr
ln -s ../mpc-${cfg.mpc.version} mpc
# Patch
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
# Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export C_INCLUDE_PATH="${stage1.tinycc.musl.libs.package}/include:$(pwd)/mpfr/src"
export CPLUS_INCLUDE_PATH="$C_INCLUDE_PATH"
# Avoid "Link tests are not allowed after GCC_NO_EXECUTABLES"
export lt_cv_shlibpath_overrides_runpath=yes
export ac_cv_func_memcpy=yes
export ac_cv_func_strerror=yes
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
--with-native-system-header-dir=${stage1.tinycc.musl.libs.package}/include \
--with-build-sysroot=${stage1.tinycc.musl.libs.package}/include \
--disable-bootstrap \
--disable-decimal-float \
--disable-libatomic \
--disable-libcilkrts \
--disable-libgomp \
--disable-libitm \
--disable-libmudflap \
--disable-libquadmath \
--disable-libsanitizer \
--disable-libssp \
--disable-libvtv \
--disable-lto \
--disable-lto-plugin \
--disable-multilib \
--disable-plugin \
--disable-threads \
--enable-languages=c \
--enable-static \
--disable-shared \
--enable-threads=single \
--disable-libstdcxx-pch \
--disable-build-with-cxx
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
'';
};
};
};
}

View file

@ -1,194 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gcc.v8;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.gcc.v8 = {
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gcc.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
cc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The cc source for the package.";
};
};
gmp = {
src = lib.options.create {
type = lib.types.derivation;
description = "The gmp source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
};
mpfr = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpfr source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
};
mpc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpc source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
};
isl = {
src = lib.options.create {
type = lib.types.derivation;
description = "The isl source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of isl.";
};
};
};
config = {
aux.foundation.stages.stage1.gcc.v8 = {
version = "8.5.0";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/gcc/gcc-${cfg.version}/gcc-${cfg.version}.tar.xz";
sha256 = "0wiEGlEbuDCmEAOXsAQtskzhH2Qtq26m7kSELlMl7VA=";
};
gmp = {
# last version to compile with gcc 4.6
version = "6.2.1";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/gmp/gmp-${cfg.gmp.version}.tar.xz";
sha256 = "/UgpkSzd0S+EGBw0Ucx1K+IkZD6H+sSXtp7d2txJtPI=";
};
};
mpfr = {
version = "4.2.1";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/mpfr/mpfr-${cfg.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
};
mpc = {
version = "1.3.1";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/mpc/mpc-${cfg.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
};
isl = {
version = "0.24";
src = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${cfg.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
package = builders.bash.build {
name = "gcc-${cfg.version}";
meta = stage1.gcc.meta;
deps.build.host = [
stage1.gcc.v46.cxx.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.boot.package
stage1.diffutils.package
stage1.findutils.package
stage1.gnutar.package
stage1.gzip.package
stage1.bzip2.package
stage1.xz.package
];
script = ''
# Unpack
tar xf ${cfg.src}
tar xf ${cfg.gmp.src}
tar xf ${cfg.mpfr.src}
tar xf ${cfg.mpc.src}
tar xf ${cfg.isl.src}
cd gcc-${cfg.version}
ln -s ../gmp-${cfg.gmp.version} gmp
ln -s ../mpfr-${cfg.mpfr.version} mpfr
ln -s ../mpc-${cfg.mpc.version} mpc
ln -s ../isl-${cfg.isl.version} isl
# Patch
# doesn't recognise musl
sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host
# Configure
export CC="gcc -Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export CXX="g++ -Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export C_INCLUDE_PATH="${stage1.musl.package}/include"
export CPLUS_INCLUDE_PATH="$C_INCLUDE_PATH"
export LIBRARY_PATH="${stage1.musl.package}/lib"
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
--with-native-system-header-dir=/include \
--with-sysroot=${stage1.musl.package} \
--enable-languages=c,c++ \
--disable-bootstrap \
--disable-libmpx \
--disable-libsanitizer \
--disable-lto \
--disable-multilib \
--disable-plugin
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install-strip
'';
};
};
};
}

View file

@ -1,106 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gnugrep;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.gnugrep = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU implementation of the Unix grep command";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/grep";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {
type = lib.types.string;
description = "The main program of the package.";
default.value = "grep";
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gnugrep.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.gnugrep = {
version = "2.4";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/grep/grep-${cfg.version}.tar.gz";
sha256 = "05iayw5sfclc476vpviz67hdy03na0pz2kb5csa50232nfx34853";
};
package =
let
# Thanks to the live-bootstrap project!
# See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4
makefile = builtins.fetchurl {
url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4/mk/main.mk";
sha256 = "08an9ljlqry3p15w28hahm6swnd3jxizsd2188przvvsj093j91k";
};
in
builders.bash.boot.build {
name = "gnugrep-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.mes.compiler.package
stage1.gnumake.boot.package
];
script = ''
# Unpack
ungz --file ${cfg.src} --output grep.tar
untar --file grep.tar
rm grep.tar
cd grep-${cfg.version}
# Configure
cp ${makefile} Makefile
# Build
make CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib"
# Install
make install PREFIX=$out
'';
};
};
};
}

View file

@ -1,103 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gnum4;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.gnum4 = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU M4, a macro processor.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/m4";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gnum4.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.gnum4 = {
version = "1.4.19";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/m4/m4-${cfg.version}.tar.xz";
sha256 = "Y67eXG0zttmxNRHNC+LKwEby5w/QoHqpVzoEqCeDr5Y=";
};
package = builders.bash.build {
name = "gnum4-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.gcc.package
stage1.musl.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.package
stage1.diffutils.package
stage1.findutils.package
stage1.gnutar.package
stage1.xz.package
];
script = ''
# Unpack
tar xf ${cfg.src}
cd m4-${cfg.version}
# Configure
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
CC=musl-gcc
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
'';
};
};
};
}

View file

@ -1,219 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gnumake.boot;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.gnumake.boot = {
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gnumake.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.gnumake.boot = {
version = "4.4.1";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/make/make-${cfg.version}.tar.gz";
sha256 = "1cwgcmwdn7gqn5da2ia91gkyiqs9birr10sy5ykpkaxzcwfzn5nx";
};
package =
let
patches = [
# Replaces /bin/sh with sh, see patch file for reasoning
./patches/0001-No-impure-bin-sh.patch
# Purity: don't look for library dependencies (of the form `-lfoo') in /lib
# and /usr/lib. It's a stupid feature anyway. Likewise, when searching for
# included Makefiles, don't look in /usr/include and friends.
./patches/0002-remove-impure-dirs.patch
# Fixes for tinycc. See comments in patch file for reasoning
./patches/0003-tinycc-support.patch
];
/*
Maintenance notes:
Generated by
./configure \
--build i686-pc-linux-gnu \
--host i686-pc-linux-gnu \
CC="${tinycc.compiler}/bin/tcc -B ${tinycc.libs}/lib" \
ac_cv_func_dup=no
- `ac_cv_func_dup` disabled as mes-libc doesn't implement tmpfile()
The output src/config.h was then manually filtered, removing definitions that
didn't have uses in the source code
*/
config = [
"-DFILE_TIMESTAMP_HI_RES=0"
"-DHAVE_ALLOCA"
"-DHAVE_ALLOCA_H"
"-DHAVE_ATEXIT"
"-DHAVE_DECL_BSD_SIGNAL=0"
"-DHAVE_DECL_GETLOADAVG=0"
"-DHAVE_DECL_SYS_SIGLIST=0"
"-DHAVE_DECL__SYS_SIGLIST=0"
"-DHAVE_DECL___SYS_SIGLIST=0"
"-DHAVE_DIRENT_H"
"-DHAVE_DUP2"
"-DHAVE_FCNTL_H"
"-DHAVE_FDOPEN"
"-DHAVE_GETCWD"
"-DHAVE_GETTIMEOFDAY"
"-DHAVE_INTTYPES_H"
"-DHAVE_ISATTY"
"-DHAVE_LIMITS_H"
"-DHAVE_LOCALE_H"
"-DHAVE_MEMORY_H"
"-DHAVE_MKTEMP"
"-DHAVE_SA_RESTART"
"-DHAVE_SETVBUF"
"-DHAVE_SIGACTION"
"-DHAVE_SIGSETMASK"
"-DHAVE_STDINT_H"
"-DHAVE_STDLIB_H"
"-DHAVE_STRDUP"
"-DHAVE_STRERROR"
"-DHAVE_STRINGS_H"
"-DHAVE_STRING_H"
"-DHAVE_STRTOLL"
"-DHAVE_SYS_FILE_H"
"-DHAVE_SYS_PARAM_H"
"-DHAVE_SYS_RESOURCE_H"
"-DHAVE_SYS_SELECT_H"
"-DHAVE_SYS_STAT_H"
"-DHAVE_SYS_TIMEB_H"
"-DHAVE_SYS_TIME_H"
"-DHAVE_SYS_WAIT_H"
"-DHAVE_TTYNAME"
"-DHAVE_UMASK"
"-DHAVE_UNISTD_H"
"-DHAVE_WAITPID"
"-DMAKE_JOBSERVER"
"-DMAKE_SYMLINKS"
"-DPATH_SEPARATOR_CHAR=':'"
"-DSCCS_GET=\\\"get\\\""
"-DSTDC_HEADERS"
"-Dsig_atomic_t=int"
"-Dvfork=fork"
];
cflags = [
"-I./src"
"-I./lib"
"-DHAVE_CONFIG_H"
"-DMAKE_MAINTAINER_MODE"
"-DLIBDIR=\\\"${builtins.placeholder "out"}/lib\\\""
"-DLOCALEDIR=\\\"/fake-locale\\\""
"-DPOSIX=1"
# mes-libc doesn't implement osync_* methods
"-DNO_OUTPUT_SYNC=1"
# mes-libc doesn't define O_TMPFILE
"-DO_TMPFILE=020000000"
] ++ config;
sources = {
# Maintenance note: list of source files derived from Basic.mk
make = [
"src/ar.c"
"src/arscan.c"
"src/commands.c"
"src/default.c"
"src/dir.c"
"src/expand.c"
"src/file.c"
"src/function.c"
"src/getopt.c"
"src/getopt1.c"
"src/guile.c"
"src/hash.c"
"src/implicit.c"
"src/job.c"
"src/load.c"
"src/loadapi.c"
"src/main.c"
"src/misc.c"
"src/output.c"
"src/read.c"
"src/remake.c"
"src/rule.c"
"src/shuffle.c"
"src/signame.c"
"src/strcache.c"
"src/variable.c"
"src/version.c"
"src/vpath.c"
];
glob = [
"lib/fnmatch.c"
"lib/glob.c"
];
remote = [ "src/remote-stub.c" ];
};
files = sources.make ++ sources.glob ++ sources.remote ++ [ "src/posixos.c" ];
objects = builtins.map (
value: builtins.replaceStrings [ ".c" ] [ ".o" ] (builtins.baseNameOf value)
) files;
in
builders.kaem.build {
name = "gnumake-${cfg.version}";
meta = stage1.gnumake.meta;
deps.build.host = [
stage1.tinycc.mes.compiler.package
stage1.gnupatch.package
];
script = ''
# Unpack
ungz --file ${cfg.src} --output make.tar
untar --file make.tar
rm make.tar
cd make-${cfg.version}
# Patch
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
# Configure
catm src/config.h src/mkconfig.h src/mkcustom.h
cp lib/glob.in.h lib/glob.h
cp lib/fnmatch.in.h lib/fnmatch.h
# Compile
alias CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib ${builtins.concatStringsSep " " cflags}"
${lib.strings.concatMapSep "\n" (file: "CC -c ${file}") files}
# Link
CC -o make ${builtins.concatStringsSep " " objects}
# Check
./make --version
# Install
mkdir -p ''${out}/bin
cp ./make ''${out}/bin
chmod 555 ''${out}/bin/make
'';
};
};
};
}

View file

@ -1,118 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gnumake;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
includes = [ ./boot.nix ];
options.aux.foundation.stages.stage1.gnumake = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "A tool to control the generation of non-source files from sources";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/make";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gnumake.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.gnumake = {
version = "4.4.1";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/make/make-${cfg.version}.tar.gz";
sha256 = "3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M=";
};
package =
let
patches = [
# Replaces /bin/sh with sh, see patch file for reasoning
./patches/0001-No-impure-bin-sh.patch
# Purity: don't look for library dependencies (of the form `-lfoo') in /lib
# and /usr/lib. It's a stupid feature anyway. Likewise, when searching for
# included Makefiles, don't look in /usr/include and friends.
./patches/0002-remove-impure-dirs.patch
];
in
builders.bash.boot.build {
name = "gnumake-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.musl.compiler.package
stage1.gnumake.boot.package
stage1.gnupatch.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.boot.package
stage1.gnutar.boot.package
stage1.gzip.package
];
script = ''
# Unpack
tar xzf ${cfg.src}
cd make-${cfg.version}
# Patch
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
# Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export LD=tcc
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host}
# Build
make AR="tcc -ar"
# Install
make install
'';
};
};
};
}

View file

@ -1,36 +0,0 @@
From e00a5257a6ca5fedbf68b09eee7df3502971a057 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
Date: Sat, 24 Apr 2021 10:11:40 +0200
Subject: [PATCH 1/2] No impure bin sh
default_shell is used to populuate default shell used to execute jobs.
Unless SHELL is set to a different value this would be /bin/sh.
Our stdenv provides sh in form of bash anyway. Having this value not
hard-coded has some advantages:
- It would ensure that on all systems it uses sh from its PATH rather
than /bin/sh, which helps as different systems might have different
shells there (bash vs. dash)
- In the past I had issues with LD_PRELOAD with BEAR, where /bin/sh
used a different glibc than BEAR which came from my development shell.
---
src/job.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/job.c b/src/job.c
index ae1f18b..6b4ddb3 100644
--- a/src/job.c
+++ b/src/job.c
@@ -77,7 +77,7 @@ char * vms_strsignal (int status);
#else
-const char *default_shell = "/bin/sh";
+const char *default_shell = "sh";
int batch_mode_shell = 0;
#endif
--
2.31.1

View file

@ -1,41 +0,0 @@
From 795d63d3c8b5c0dbb7e544954f75507b371b7228 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
Date: Sat, 24 Apr 2021 10:20:16 +0200
Subject: [PATCH 2/2] remove impure dirs
---
src/read.c | 3 ---
src/remake.c | 2 --
2 files changed, 5 deletions(-)
diff --git a/src/read.c b/src/read.c
index fa197fb..defacfb 100644
--- a/src/read.c
+++ b/src/read.c
@@ -109,9 +109,6 @@ static const char *default_include_directories[] =
#endif
INCLUDEDIR,
#ifndef _AMIGA
- "/usr/gnu/include",
- "/usr/local/include",
- "/usr/include",
#endif
0
};
diff --git a/src/remake.c b/src/remake.c
index fb237c5..94bff7d 100644
--- a/src/remake.c
+++ b/src/remake.c
@@ -1601,8 +1601,6 @@ library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
static const char *dirs[] =
{
#ifndef _AMIGA
- "/lib",
- "/usr/lib",
#endif
#if defined(WINDOWS32) && !defined(LIBDIR)
/*
--
2.31.1

View file

@ -1,59 +0,0 @@
diff --git a/src/dir.c b/src/dir.c
index 3e94b98..cfaa6a2 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -1331,10 +1331,9 @@ local_stat (const char *path, struct stat *buf)
/* Similarly for lstat. */
#if !defined(lstat) && !defined(WINDOWS32) || defined(VMS)
-# ifndef VMS
-# ifndef HAVE_SYS_STAT_H
+// mes-libc implements but does not declare lstat
+# if (!defined(VMS) && !defined(HAVE_SYS_STAT_H)) || defined(__TINYC__)
int lstat (const char *path, struct stat *sbuf);
-# endif
# else
/* We are done with the fake lstat. Go back to the real lstat */
# ifdef lstat
diff --git a/src/job.c b/src/job.c
index ea88561..8388a82 100644
--- a/src/job.c
+++ b/src/job.c
@@ -2052,7 +2052,8 @@ job_next_command (struct child *child)
static int
load_too_high (void)
{
-#if defined(__MSDOS__) || defined(VMS) || defined(_AMIGA) || defined(__riscos__)
+// mes-libc does not support getloadavg
+#if defined(__MSDOS__) || defined(VMS) || defined(_AMIGA) || defined(__riscos__) || defined (__TINYC__)
return 1;
#else
static double last_sec;
diff --git a/src/main.c b/src/main.c
index a9d3a64..664d40f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2770,7 +2770,7 @@ main (int argc, char **argv, char **envp)
char *b = alloca (40);
sprintf (b, "MAKE_RESTARTS=%s%u",
OUTPUT_IS_TRACED () ? "-" : "", restarts);
- putenv (b);
+ // mes-libc does not support putenv
}
fflush (stdout);
diff --git a/src/misc.c b/src/misc.c
index eb14f40..bffca82 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -653,7 +653,8 @@ get_tmppath ()
# ifdef HAVE_MKTEMP
path = get_tmptemplate ();
- if (*mktemp (path) == '\0')
+ // tinycc: "src/misc.c:656: error: pointer expected"
+ if (!strcmp(mktemp (path), ""))
{
OSS (error, NILF,
_("cannot generate temp path from %s: %s"), path, strerror (errno));

View file

@ -1,158 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gnupatch;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.gnupatch = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU Patch, a program to apply differences to files.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/patch";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gnupatch.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.gnupatch = {
version = "2.5.9";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/patch/patch-${cfg.version}.tar.gz";
sha256 = "12nv7jx3gxfp50y11nxzlnmqqrpicjggw6pcsq0wyavkkm3cddgc";
};
package =
let
# Thanks to the live-bootstrap project!
# https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/patch-2.5.9/mk/main.mk
cflags = [
"-I."
"-DHAVE_DECL_GETENV"
"-DHAVE_DECL_MALLOC"
"-DHAVE_DIRENT_H"
"-DHAVE_LIMITS_H"
"-DHAVE_GETEUID"
"-DHAVE_MKTEMP"
"-DPACKAGE_BUGREPORT="
"-Ded_PROGRAM=\\\"/nullop\\\""
"-Dmbstate_t=int" # When HAVE_MBRTOWC is not enabled uses of mbstate_t are always a no-op
"-DRETSIGTYPE=int"
"-DHAVE_MKDIR"
"-DHAVE_RMDIR"
"-DHAVE_FCNTL_H"
"-DPACKAGE_NAME=\\\"patch\\\""
"-DPACKAGE_VERSION=\\\"${cfg.version}\\\""
"-DHAVE_MALLOC"
"-DHAVE_REALLOC"
"-DSTDC_HEADERS"
"-DHAVE_STRING_H"
"-DHAVE_STDLIB_H"
];
# Maintenance note: List of sources from Makefile.in
files = [
"addext.c"
"argmatch.c"
"backupfile.c"
"basename.c"
"dirname.c"
"getopt.c"
"getopt1.c"
"inp.c"
"maketime.c"
"partime.c"
"patch.c"
"pch.c"
"quote.c"
"quotearg.c"
"quotesys.c"
"util.c"
"version.c"
"xmalloc.c"
];
sources = files ++ [
# mes-libc doesn't implement `error()`
"error.c"
];
objects = builtins.map (
value: builtins.replaceStrings [ ".c" ] [ ".o" ] (builtins.baseNameOf value)
) sources;
in
builders.kaem.build {
name = "gnupatch-${cfg.version}";
meta = cfg.meta;
src = cfg.src;
deps.build.host = [ stage1.tinycc.mes.compiler.package ];
script = ''
# Unpack
ungz --file ${cfg.src} --output patch.tar
untar --file patch.tar
rm patch.tar
cd patch-${cfg.version}
# Configure
catm config.h
# Build
alias CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib ${builtins.concatStringsSep " " cflags}"
${lib.strings.concatMapSep "\n" (source: "CC -c ${source}") sources}
# Link
CC -o patch ${builtins.concatStringsSep " " objects}
# Check
./patch --version
# Install
mkdir -p ''${out}/bin
cp ./patch ''${out}/bin
chmod 555 ''${out}/bin/patch
'';
};
};
};
}

View file

@ -1,77 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gnused.boot;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.gnused.boot = {
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gnused-boot.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.gnused.boot = {
version = "4.0.9";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/sed/sed-${cfg.version}.tar.gz";
sha256 = "0006gk1dw2582xsvgx6y6rzs9zw8b36rhafjwm288zqqji3qfrf3";
};
package =
let
# Thanks to the live-bootstrap project!
# See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/sed-4.0.9.kaem
makefile = builtins.fetchurl {
url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/mk/main.mk";
sha256 = "0w1f5ri0g5zla31m6l6xyzbqwdvandqfnzrsw90dd6ak126w3mya";
};
in
builders.bash.boot.build {
name = "gnused-boot-${cfg.version}";
meta = stage1.gnused.meta;
deps.build.host = [
stage1.tinycc.mes.compiler.package
stage1.gnumake.boot.package
];
script = ''
# Unpack
ungz --file ${cfg.src} --output sed.tar
untar --file sed.tar
rm sed.tar
cd sed-${cfg.version}
# Configure
cp ${makefile} Makefile
catm config.h
# Build
make \
CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib" \
LIBC=mes
# Install
make install PREFIX=$out
'';
};
};
};
}

View file

@ -1,111 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gnused;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
includes = [ ./boot.nix ];
options.aux.foundation.stages.stage1.gnused = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU sed, a batch stream editor.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/sed";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {
type = lib.types.string;
description = "The main program of the package.";
default.value = "sed";
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gnused.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.gnused = {
version = "4.2";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/sed/sed-${cfg.version}.tar.gz";
sha256 = "20XNY/0BDmUFN9ZdXfznaJplJ0UjZgbl5ceCk3Jn2YM=";
};
package = builders.bash.boot.build {
name = "gnused-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.musl.compiler.package
stage1.gnumake.boot.package
stage1.gnused.boot.package
stage1.gnugrep.package
stage1.gnutar.boot.package
stage1.gzip.package
];
script = ''
# Unpack
tar xzf ${cfg.src}
cd sed-${cfg.version}
# Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export LD=tcc
./configure \
--build=${platform.build} \
--host=${platform.host} \
--disable-shared \
--disable-nls \
--disable-dependency-tracking \
--prefix=$out
# Build
make AR="tcc -ar"
# Install
make install
'';
};
};
};
}

View file

@ -1,77 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gnutar.boot;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.gnutar.boot = {
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gnutar-boot.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.gnutar.boot = {
version = "1.12";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/tar/tar-${cfg.version}.tar.gz";
sha256 = "02m6gajm647n8l9a5bnld6fnbgdpyi4i3i83p7xcwv0kif47xhy6";
};
package =
let
in
builders.bash.boot.build {
name = "gnutar-boot-${cfg.version}";
meta = stage1.gnutar.meta;
deps.build.host = [
stage1.tinycc.mes.compiler.package
stage1.gnumake.boot.package
stage1.gnused.boot.package
stage1.gnugrep.package
];
script = ''
# Unpack
ungz --file ${cfg.src} --output tar.tar
untar --file tar.tar
rm tar.tar
cd tar-${cfg.version}
# Configure
export CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib"
chmod 0755 missing
bash ./configure \
--build=${platform.build} \
--host=${platform.host} \
--disable-nls \
--prefix=$out
# Build
make AR="tcc -ar"
# Install
make install
'';
};
};
};
}

View file

@ -1,114 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gnutar;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
includes = [
./boot.nix
./musl.nix
];
options.aux.foundation.stages.stage1.gnutar = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU implementation of the `tar` archiver";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/tar";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {
type = lib.types.string;
description = "The main program of the package.";
default.value = "tar";
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gnutar.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.gnutar = {
version = "1.35";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/tar/tar-${cfg.version}.tar.gz";
sha256 = "FNVeMgY+qVJuBX+/Nfyr1TN452l4fv95GcN1WwLStX4=";
};
package = builders.bash.boot.build {
name = "gnutar-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.gcc.v46.cxx.package
stage1.musl.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.package
stage1.gzip.package
stage1.gnutar.musl.package
];
script = ''
# Unpack
tar xzf ${cfg.src}
cd tar-${cfg.version}
# Configure
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
CC=musl-gcc
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
'';
};
};
};
}

View file

@ -1,79 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gnutar.musl;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.gnutar.musl = {
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gnutar-musl.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.gnutar.musl = {
version = "1.12";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/tar/tar-${cfg.version}.tar.gz";
sha256 = "xsN+iIsTbM76uQPFEUn0t71lnWnUrqISRfYQU6V6pgo=";
};
package = builders.bash.boot.build {
name = "gnutar-musl-${cfg.version}";
meta = stage1.gnutar.meta;
deps.build.host = [
stage1.tinycc.musl.compiler.package
stage1.gnumake.boot.package
stage1.gnused.boot.package
stage1.gnugrep.package
];
script = ''
# Unpack
ungz --file ${cfg.src} --output tar.tar
untar --file tar.tar
rm tar.tar
cd tar-${cfg.version}
# Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export LD=tcc
export ac_cv_sizeof_unsigned_long=4
export ac_cv_sizeof_long_long=8
export ac_cv_header_netdb_h=no
chmod 0755 missing
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
--disable-nls
# Build
make AR="tcc -ar"
# Install
make install
'';
};
};
};
}

View file

@ -1,98 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gzip;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.gzip = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU zip compression program.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/gzip";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for gzip.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.gzip = {
version = "1.2.4";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/gzip/gzip-${cfg.version}.tar.gz";
sha256 = "0ryr5b00qz3xcdcv03qwjdfji8pasp0007ay3ppmk71wl8c1i90w";
};
package =
let
in
builders.bash.boot.build {
name = "gzip-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.mes.compiler.package
stage1.gnumake.boot.package
stage1.gnused.boot.package
stage1.gnugrep.package
];
script = ''
# Unpack
ungz --file ${cfg.src} --output gzip.tar
untar --file gzip.tar
rm gzip.tar
cd gzip-${cfg.version}
# Configure
export CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib -Dstrlwr=unused"
bash ./configure --prefix=$out
# Build
make
# Install
mkdir $out
make install
'';
};
};
};
}

View file

@ -1,166 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.heirloom;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
stage2 = config.aux.foundation.stages.stage2;
in
{
includes = [ ./devtools.nix ];
options.aux.foundation.stages.stage1.heirloom = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "The Heirloom Toolchest is a collection of standard Unix utilities.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://heirloom.sourceforge.net/tools.html";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.list.of lib.types.attrs.any;
description = "License for the package.";
default.value = [
lib.licenses.zlib
lib.licenses.caldera
lib.licenses.bsdOriginalUC
lib.licenses.cddl
lib.licenses.bsd3
lib.licenses.gpl2Plus
lib.licenses.lgpl21Plus
lib.licenses.lpl-102
lib.licenses.info-zip
];
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for heirloom.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.heirloom = {
version = "070715";
src = builtins.fetchurl {
url = "https://downloads.sourceforge.net/heirloom/heirloom/${cfg.version}/heirloom-${cfg.version}.tar.bz2";
sha256 = "6zP3C8wBmx0OCkHx11UtRcV6FicuThxIY07D5ESWow8=";
};
package =
let
patches = [
# we pre-generate nawk's proctab.c as meslibc is not capable of running maketab
# during build time (insufficient sscanf support)
./patches/proctab.patch
# disable utilities that don't build successfully
./patches/disable-programs.patch
# "tcc -ar" doesn't support creating empty archives
./patches/tcc-empty-ar.patch
# meslibc doesn't have seperate libm
./patches/dont-link-lm.patch
# meslibc's vprintf doesn't support %ll
./patches/vprintf.patch
# meslibc doesn't support sysconf()
./patches/sysconf.patch
# meslibc doesn't support locale
./patches/strcoll.patch
# meslibc doesn't support termios.h
./patches/termios.patch
# meslibc doesn't support utime.h
./patches/utime.patch
# meslibc doesn't support langinfo.h
./patches/langinfo.patch
# support building with meslibc
./patches/meslibc-support.patch
# remove socket functionality as unsupported by meslibc
./patches/cp-no-socket.patch
];
makeFlags = [
# mk.config build options
"CC='tcc -B ${stage1.tinycc.mes.libs.package}/lib -include ${./stubs.h} -include ${./musl.h}'"
"AR='tcc -ar'"
"RANLIB=true"
"STRIP=true"
"SHELL=${stage1.bash.package}/bin/sh"
"POSIX_SHELL=${stage1.bash.package}/bin/sh"
"DEFBIN=/bin"
"SV3BIN=/5bin"
"S42BIN=/5bin/s42"
"SUSBIN=/bin"
"SU3BIN=/5bin/posix2001"
"UCBBIN=/ucb"
"CCSBIN=/ccs/bin"
"DEFLIB=/lib"
"DEFSBIN=/bin"
"MANDIR=/share/man"
"LCURS=" # disable ncurses
"USE_ZLIB=0" # disable zlib
"IWCHAR='-I../libwchar'"
"LWCHAR='-L../libwchar -lwchar'"
];
in
builders.bash.boot.build {
name = "heirloom-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.mes.compiler.package
stage1.gnumake.package
stage1.gnupatch.package
stage1.heirloom.devtools.package
];
script = ''
# Unpack
unbz2 --file ${cfg.src} --output heirloom.tar
untar --file heirloom.tar
rm heirloom.tar
cd heirloom-${cfg.version}
# Patch
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
cp ${./proctab.c} nawk/proctab.c
# Build
# These tools are required during later build steps
export PATH="$PATH:$PWD/ed:$PWD/nawk:$PWD/sed"
make ${builtins.concatStringsSep " " makeFlags}
# Install
make install ROOT=$out ${builtins.concatStringsSep " " makeFlags}
'';
};
};
};
}

View file

@ -1,150 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.heirloom.devtools;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1;
stage2 = config.aux.foundation.stages.stage2;
in
{
options.aux.foundation.stages.stage1.heirloom.devtools = {
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for heirloom-devtools.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Portable yacc and lex derived from OpenSolaris";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://heirloom.sourceforge.net/devtools.html";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.list.of lib.types.attrs.any;
description = "License for the package.";
default.value = [
lib.licenses.cddl
lib.licenses.bsdOriginalUC
lib.licenses.caldera
];
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
};
config = {
aux.foundation.stages.stage1.heirloom.devtools = {
version = "070527";
src = builtins.fetchurl {
url = "https://downloads.sourceforge.net/heirloom/heirloom-devtools/heirloom-devtools-${cfg.version}.tar.bz2";
sha256 = "9f233d8b78e4351fe9dd2d50d83958a0e5af36f54e9818521458a08e058691ba";
};
package =
let
# Thanks to the live-bootstrap project!
# See https://github.com/fosslinux/live-bootstrap/blob/d918b984ad6fe4fc7680f3be060fd82f8c9fddd9/sysa/heirloom-devtools-070527/heirloom-devtools-070527.kaem
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/d918b984ad6fe4fc7680f3be060fd82f8c9fddd9/sysa/heirloom-devtools-070527";
patches = [
# Remove all kinds of wchar support. Mes Libc does not support wchar in any form
(builtins.fetchurl {
url = "${liveBootstrap}/patches/yacc_remove_wchar.patch";
sha256 = "0wgiz02bb7xzjy2gnbjp8y31qy6rc4b29v01zi32zh9lw54j68hc";
})
# Similarly to yacc, remove wchar. See yacc patch for further information
(builtins.fetchurl {
url = "${liveBootstrap}/patches/lex_remove_wchar.patch";
sha256 = "168dfngi51ljjqgd55wbvmffaq61gk48gak50ymnl1br92qkp4zh";
})
];
in
builders.kaem.build {
name = "heirloom-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.tinycc.mes.compiler.package
stage1.gnumake.package
stage1.gnupatch.package
stage1.coreutils.package
stage0.mescc-tools-extra.package
];
script = ''
# Unpack
unbz2 --file ${cfg.src} --output heirloom-devtools.tar
untar --file heirloom-devtools.tar
rm heirloom-devtools.tar
build=''${NIX_BUILD_TOP}/heirloom-devtools-${cfg.version}
cd ''${build}
# Patch
${lib.strings.concatMapSep "\n" (f: "patch -Np0 -i ${f}") patches}
# Build yacc
cd yacc
make -f Makefile.mk \
CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib" \
AR="tcc -ar" \
CFLAGS="-DMAXPATHLEN=4096 -DEILSEQ=84 -DMB_LEN_MAX=100" \
LDFLAGS="-lgetopt" \
RANLIB=true \
LIBDIR=''${out}/lib
# Install yacc
install -D yacc ''${out}/bin/yacc
install -Dm 444 liby.a ''${out}/lib/liby.a
install -Dm 444 yaccpar ''${out}/lib/yaccpar
# Make yacc available to lex
PATH="''${out}/bin:''${PATH}"
# Build lex
cd ../lex
make -f Makefile.mk \
CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib" \
AR="tcc -ar" \
CFLAGS="-DEILSEQ=84 -DMB_LEN_MAX=100" \
LDFLAGS="-lgetopt" \
RANLIB=true \
LIBDIR=''${out}/lib
# Install lex
install -D lex ''${out}/bin/lex
install -Dm 444 ncform ''${out}/lib/lex/ncform
install -Dm 444 nceucform ''${out}/lib/lex/nceucform
install -Dm 444 nrform ''${out}/lib/lex/nrform
install -Dm 444 libl.a ''${out}/lib/libl.a
'';
};
};
};
}

View file

@ -1,53 +0,0 @@
/*
Copyright © 2005-2019 Rich Felker, et al.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Additional utilities from musl 1.1.24
// include/stdlib.h
#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
#define WTERMSIG(s) ((s) & 0x7f)
#define WIFEXITED(s) (!WTERMSIG(s))
#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu)
// include/sys/sysmacros.h
#define major(x) \
((unsigned)( (((x)>>31>>1) & 0xfffff000) | (((x)>>8) & 0x00000fff) ))
#define minor(x) \
((unsigned)( (((x)>>12) & 0xffffff00) | ((x) & 0x000000ff) ))
#define makedev(x,y) ( \
(((x)&0xfffff000ULL) << 32) | \
(((x)&0x00000fffULL) << 8) | \
(((y)&0xffffff00ULL) << 12) | \
(((y)&0x000000ffULL)) )
// src/misc/basename.c
#include <string.h>
char *basename(char *s)
{
size_t i;
if (!s || !*s) return ".";
i = strlen(s)-1;
for (; i&&s[i]=='/'; i--) s[i] = 0;
for (; i&&s[i-1]!='/'; i--);
return s+i;
}

View file

@ -1,84 +0,0 @@
--- cp/cp.c
+++ cp/cp.c
@@ -42,8 +42,6 @@ static const char sccsid[] USED = "@(#)cp.sl 1.84 (gritter) 3/4/06";
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/un.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <fcntl.h>
@@ -427,6 +425,7 @@ fdcopy(const char *src, const struct stat *ssp, const int sfd,
#endif
#ifdef __linux__
+#ifdef O_DIRECT
if (!bflag && !Dflag && ssp->st_size > 0) {
long long sent;
@@ -436,6 +435,7 @@ fdcopy(const char *src, const struct stat *ssp, const int sfd,
if (sent < 0)
goto err;
}
+#endif
#endif /* __linux__ */
if (pagesize == 0)
if ((pagesize = 4096) < 0)
@@ -702,37 +702,6 @@ symlinkcopy(const char *src, const struct stat *ssp,
}
}
-static void
-socketcopy(const char *src, const struct stat *ssp,
- const char *tgt, const struct stat *dsp)
-{
- int fd, addrsz;
- struct sockaddr_un addr;
- size_t len;
-
- if (do_unlink(tgt, dsp) != OKAY)
- return;
- len = strlen(tgt);
- memset(&addr, 0, sizeof addr);
- addr.sun_family = AF_UNIX;
- addrsz = sizeof addr - sizeof addr.sun_path + len;
- if ((len >= sizeof addr.sun_path ? errno = ENAMETOOLONG, fd = -1, 1 :
- (strncpy(addr.sun_path,tgt,sizeof addr.sun_path), 0)) ||
- (fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0 ||
- bind(fd, (struct sockaddr *)&addr, addrsz) < 0) {
- fprintf(stderr, "%s: cannot create socket %s\n%s: %s\n",
- progname, tgt,
- progname, strerror(errno));
- if (fd >= 0)
- close(fd);
- errcnt |= 01;
- return;
- }
- close(fd);
- if (pflag)
- permissions(tgt, ssp);
-}
-
static void
specialcopy(const char *src, const struct stat *ssp,
const char *tgt, const struct stat *dsp)
@@ -748,9 +717,6 @@ specialcopy(const char *src, const struct stat *ssp,
case S_IFLNK:
symlinkcopy(src, ssp, tgt, dsp);
break;
- case S_IFSOCK:
- socketcopy(src, ssp, tgt, dsp);
- break;
case S_IFDOOR:
ignoring("door", src);
break;
@@ -1043,7 +1009,7 @@ ln(const char *src, const char *tgt, struct stat *dsp, int level,
errcnt |= 01;
return;
}
-#if (defined (SUS) || defined (S42)) && (defined (__linux__) || defined (__sun))
+#if (defined (SUS) || defined (S42)) && (defined (__linux__) || defined (__sun)) && !defined (__TINYC__)
if (sflag == 0) {
char *rpbuf = alloca(PATH_MAX+1);
if (realpath(src, rpbuf) == NULL) {

View file

@ -1,43 +0,0 @@
--- makefile
+++ makefile
@@ -1,21 +1,24 @@
-SHELL = /bin/sh
+SHELL = sh
-SUBDIRS = build libwchar libcommon libuxre _install \
- banner basename bc bdiff bfs \
- cal calendar cat chmod chown \
- cksum cmp col comm copy cp cpio csplit cut \
- date dc dd deroff diff diff3 dircmp dirname df du \
+SUBDIRS = libwchar libcommon libuxre _install \
+ banner basename bdiff bfs \
+ cat chmod chown \
+ cksum cmp col comm copy cp csplit cut \
+ dc dirname \
echo ed env expand expr \
- factor file find fmt fmtmsg fold \
- getconf getopt grep groups hd head hostname id join \
- kill line listusers ln logins logname ls \
- mail man mesg mkdir mkfifo mknod more mvdir \
- nawk news nice nl nohup oawk od \
- paste pathchk pg pgrep pr printenv printf priocntl ps psrinfo pwd \
- random renice rm rmdir \
- sdiff sed setpgrp shl sleep sort spell split stty su sum sync \
- tabs tail tapecntl tar tcopy tee test time touch tr true tsort tty \
- ul uname uniq units users wc what who whoami whodo xargs yes
+ file fmt fold \
+ getopt grep hd head join \
+ kill line ln logname ls \
+ mesg mkdir mknod \
+ nl nohup od \
+ paste pathchk pgrep pr printenv printf pwd \
+ random rm rmdir \
+ sed sleep sort split sum \
+ tee test touch tr true tsort tty \
+ uniq units wc what whoami xargs yes
+
+# These depend on some coreutils that we need to build first
+SUBDIRS += bc nawk build
dummy: makefiles all

View file

@ -1,44 +0,0 @@
--- csplit/Makefile.mk
+++ csplit/Makefile.mk
@@ -1,19 +1,19 @@
all: csplit csplit_sus csplit_su3
csplit: csplit.o
- $(LD) $(LDFLAGS) csplit.o $(LCOMMON) $(LWCHAR) $(LIBS) -lm -o csplit
+ $(LD) $(LDFLAGS) csplit.o $(LCOMMON) $(LWCHAR) $(LIBS) -o csplit
csplit.o: csplit.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(XO6FL) $(LARGEF) $(IWCHAR) $(ICOMMON) -c csplit.c
csplit_sus: csplit_sus.o
- $(LD) $(LDFLAGS) csplit_sus.o $(LUXRE) $(LCOMMON) $(LWCHAR) $(LIBS) -lm -o csplit_sus
+ $(LD) $(LDFLAGS) csplit_sus.o $(LUXRE) $(LCOMMON) $(LWCHAR) $(LIBS) -o csplit_sus
csplit_sus.o: csplit.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(XO6FL) $(LARGEF) $(IUXRE) $(IWCHAR) $(ICOMMON) -DSUS -c csplit.c -o csplit_sus.o
csplit_su3: csplit_su3.o
- $(LD) $(LDFLAGS) csplit_su3.o $(LUXRE) $(LCOMMON) $(LWCHAR) $(LIBS) -lm -o csplit_su3
+ $(LD) $(LDFLAGS) csplit_su3.o $(LUXRE) $(LCOMMON) $(LWCHAR) $(LIBS) -o csplit_su3
csplit_su3.o: csplit.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(XO6FL) $(LARGEF) $(IUXRE) $(IWCHAR) $(ICOMMON) -DSU3 -c csplit.c -o csplit_su3.o
--- nawk/Makefile.mk
+++ nawk/Makefile.mk
@@ -3,13 +3,13 @@ all: awk awk_sus awk_su3
OBJ = awk.lx.o b.o lib.o main.o parse.o proctab.o run.o tran.o
awk: awk.g.o $(OBJ) version.o
- $(LD) $(LDFLAGS) awk.g.o $(OBJ) version.o $(LUXRE) -lm $(LCOMMON) $(LWCHAR) $(LIBS) -o awk
+ $(LD) $(LDFLAGS) awk.g.o $(OBJ) version.o $(LUXRE) $(LCOMMON) $(LWCHAR) $(LIBS) -o awk
awk_sus: awk.g.o $(OBJ) version_sus.o
- $(LD) $(LDFLAGS) awk.g.o $(OBJ) version_sus.o $(LUXRE) -lm $(LCOMMON) $(LWCHAR) $(LIBS) -o awk_sus
+ $(LD) $(LDFLAGS) awk.g.o $(OBJ) version_sus.o $(LUXRE) $(LCOMMON) $(LWCHAR) $(LIBS) -o awk_sus
awk_su3: awk.g.2001.o $(OBJ) version_su3.o
- $(LD) $(LDFLAGS) awk.g.2001.o $(OBJ) version_su3.o $(LUXRE) -lm $(LCOMMON) $(LWCHAR) $(LIBS) -o awk_su3
+ $(LD) $(LDFLAGS) awk.g.2001.o $(OBJ) version_su3.o $(LUXRE) $(LCOMMON) $(LWCHAR) $(LIBS) -o awk_su3
awk.g.c: awk.g.y
$(YACC) -d awk.g.y

View file

@ -1,99 +0,0 @@
--- nawk/main.c
+++ nawk/main.c
@@ -35,7 +35,6 @@
#include <errno.h>
#include <string.h>
#include <locale.h>
-#include <langinfo.h>
#include <libgen.h>
#define CMDCLASS ""/*"UX:"*/ /* Command classification */
--- sort/sort.c
+++ sort/sort.c
@@ -63,7 +63,6 @@ static const char sccsid[] USED = "@(#)sort.sl 1.37 (gritter) 5/29/05";
#include <locale.h>
#include <wchar.h>
#include <wctype.h>
-#include <langinfo.h>
#include <inttypes.h>
#include <errno.h>
@@ -287,18 +286,6 @@ main(int argc, char **argv)
else
chkblank();
compare = cmpf = ccoll ? mb_cur_max > 1 ? cmpm : cmpa : cmpl;
- setlocale(LC_NUMERIC, "");
- arg = nl_langinfo(RADIXCHAR);
- if (mb_cur_max > 1)
- next(radixchar, arg, i);
- else
- radixchar = *arg & 0377;
- arg = nl_langinfo(THOUSEP);
- if (mb_cur_max > 1)
- next(thousep, arg, i);
- else
- thousep = *arg & 0377;
- setlocale(LC_TIME, "");
fields = smalloc(NF * sizeof *fields);
copyproto();
eargv = argv;
@@ -1088,8 +1075,7 @@ cmp(const char *i, const char *j)
} else {
sa = elicpy(collba, pa, la, '\n', ignore, code);
sb = elicpy(collbb, pb, lb, '\n', ignore, code);
- n = fp->Mflg ? monthcmp(collba, collbb) :
- strcoll(collba, collbb);
+ n = strcmp(collba, collbb);
if (n)
return n > 0 ? -fp->rflg : fp->rflg;
pa = &pa[sa];
@@ -1570,49 +1556,6 @@ upcdup(const char *s)
return r;
}
-static const char *months[12];
-
-#define COPY_ABMON(m) months[m-1] = upcdup(nl_langinfo(ABMON_##m))
-
-static void
-fillmonths(void)
-{
- COPY_ABMON(1);
- COPY_ABMON(2);
- COPY_ABMON(3);
- COPY_ABMON(4);
- COPY_ABMON(5);
- COPY_ABMON(6);
- COPY_ABMON(7);
- COPY_ABMON(8);
- COPY_ABMON(9);
- COPY_ABMON(10);
- COPY_ABMON(11);
- COPY_ABMON(12);
-}
-
-static int
-monthcoll(const char *s)
-{
- int i;
- char u[MB_LEN_MAX*3+1];
-
- cpcu3(u, s);
- for (i = 0; i < 12; i++)
- if (strcmp(u, months[i]) == 0)
- return i;
- return 0;
-}
-
-
-static int
-monthcmp(const char *pa, const char *pb)
-{
- if (months[0] == NULL)
- fillmonths();
- return monthcoll(pa) - monthcoll(pb);
-}
-
/*
* isblank() consumes half of execution time (in skip()) with
* glibc 2.3.1. Check if it contains only space and tab, and

View file

@ -1,322 +0,0 @@
--- _install/install_ucb.c
+++ _install/install_ucb.c
@@ -267,7 +267,7 @@ cp(const char *src, const char *tgt, struct stat *dsp)
if (check(src, tgt, dsp, &sst) != OKAY)
return;
unlink(tgt);
- if ((dfd = creat(tgt, 0700)) < 0 || fchmod(dfd, 0700) < 0 ||
+ if ((dfd = creat(tgt, 0700)) < 0 || chmod(tgt, 0700) < 0 ||
fstat(dfd, &nst) < 0) {
fprintf(stderr, "%s: %s: %s\n", progname, src,
strerror(errno));
--- libcommon/Makefile.mk
+++ libcommon/Makefile.mk
@@ -15,7 +15,7 @@ CHECK: CHECK.c
headers: CHECK
one() { \
rm -f "$$1.h"; \
- if grep "$$1_h[ ]*=[ ]*[^0][ ]*;" CHECK >/dev/null; \
+ if true; \
then \
ln -s "_$$1.h" "$$1.h"; \
fi; \
--- libcommon/atoll.h
+++ libcommon/atoll.h
@@ -1,8 +1,10 @@
/* Sccsid @(#)atoll.h 1.4 (gritter) 7/18/04 */
#if defined (__hpux) || defined (_AIX) || \
- defined (__FreeBSD__) && (__FreeBSD__) < 5
+ (defined (__FreeBSD__) && (__FreeBSD__) < 5) || defined (__TINYC__)
+#ifndef __TINYC__
extern long long strtoll(const char *nptr, char **endptr, int base);
extern unsigned long long strtoull(const char *nptr, char **endptr, int base);
+#endif
extern long long atoll(const char *nptr);
#endif /* __hpux || _AIX || __FreeBSD__ < 5 */
--- libcommon/blank.h
+++ libcommon/blank.h
@@ -5,7 +5,7 @@
*/
/* Sccsid @(#)blank.h 1.3 (gritter) 5/1/04 */
-#ifndef __dietlibc__
+#if !defined(__dietlibc__) && !defined(__TINYC__)
#ifndef LIBCOMMON_BLANK_H
#define LIBCOMMON_BLANK_H 1
--- libcommon/getdir.c
+++ libcommon/getdir.c
@@ -52,7 +52,7 @@ extern int getdents(int, struct dirent *, size_t);
#undef d_ino
#endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__
|| __APPLE__ */
-#elif defined (__dietlibc__)
+#elif defined (__dietlibc__) || defined(__TINYC__)
#include <dirent.h>
#include <unistd.h>
#else /* !__GLIBC__, !__dietlibc__ */
--- libcommon/memalign.c
+++ libcommon/memalign.c
@@ -23,7 +23,7 @@
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (_AIX) || \
defined (__NetBSD__) || defined (__OpenBSD__) || \
- defined (__DragonFly__) || defined (__APPLE__)
+ defined (__DragonFly__) || defined (__APPLE__) || defined(__TINYC__)
/*
* FreeBSD malloc(3) promises to page-align the return of malloc() calls
* if size is at least a page. This serves for a poor man's memalign()
--- libcommon/memalign.h
+++ libcommon/memalign.h
@@ -26,7 +26,7 @@
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (_AIX) || \
defined (__NetBSD__) || defined (__OpenBSD__) || \
- defined (__DragonFly__) || defined (__APPLE__)
+ defined (__DragonFly__) || defined (__APPLE__) || defined(__TINYC__)
#include <stdlib.h>
extern void *memalign(size_t, size_t);
--- libcommon/pathconf.c
+++ libcommon/pathconf.c
@@ -21,7 +21,7 @@
*/
/* Sccsid @(#)pathconf.c 1.2 (gritter) 5/1/04 */
-#ifdef __dietlibc__
+#if defined(__dietlibc__) || defined(__TINYC__)
#include <unistd.h>
#include "pathconf.h"
--- libcommon/pathconf.h
+++ libcommon/pathconf.h
@@ -21,7 +21,7 @@
*/
/* Sccsid @(#)pathconf.h 1.2 (gritter) 5/1/04 */
-#ifdef __dietlibc__
+#if defined(__dietlibc__) || defined(__TINYC__)
#include <unistd.h>
extern long fpathconf(int, int);
--- libcommon/regexp.h
+++ libcommon/regexp.h
@@ -47,7 +47,7 @@
static const char regexp_h_sccsid[] REGEXP_H_USED =
"@(#)regexp.sl 1.56 (gritter) 5/29/05";
-#if !defined (REGEXP_H_USED_FROM_VI) && !defined (__dietlibc__)
+#if !defined (REGEXP_H_USED_FROM_VI) && !defined (__dietlibc__) && !defined (__TINYC__)
#define REGEXP_H_WCHARS
#endif
--- libcommon/sfile.c
+++ libcommon/sfile.c
@@ -21,7 +21,7 @@
*/
/* Sccsid @(#)sfile.c 1.9 (gritter) 6/7/04 */
-#ifdef __linux__
+#if defined(__linux__) && !defined(__TINYC__)
#undef _FILE_OFFSET_BITS
#include <sys/types.h>
--- libcommon/sighold.c
+++ libcommon/sighold.c
@@ -22,7 +22,7 @@
/* Sccsid @(#)sighold.c 1.7 (gritter) 1/22/06 */
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (__NetBSD__) || \
- defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__)
+ defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__) || defined (__TINYC__)
#include <signal.h>
#include "sigset.h"
--- libcommon/sigignore.c
+++ libcommon/sigignore.c
@@ -22,7 +22,7 @@
/* Sccsid @(#)sigignore.c 1.6 (gritter) 1/22/06 */
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (__NetBSD__) || \
- defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__)
+ defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__) || defined (__TINYC__)
#include <signal.h>
#include "sigset.h"
--- libcommon/sigpause.c
+++ libcommon/sigpause.c
@@ -22,7 +22,7 @@
/* Sccsid @(#)sigpause.c 1.6 (gritter) 1/22/06 */
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (__NetBSD__) || \
- defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__)
+ defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__) || defined (__TINYC__)
#include <signal.h>
#include "sigset.h"
--- libcommon/sigrelse.c
+++ libcommon/sigrelse.c
@@ -22,7 +22,7 @@
/* Sccsid @(#)sigrelse.c 1.8 (gritter) 1/22/06 */
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (__NetBSD__) || \
- defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__)
+ defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__) || defined (__TINYC__)
#include <signal.h>
#include "sigset.h"
--- libcommon/sigset.c
+++ libcommon/sigset.c
@@ -22,7 +22,7 @@
/* Sccsid @(#)sigset.c 1.7 (gritter) 1/22/06 */
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (__NetBSD__) || \
- defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__)
+ defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__) || defined (__TINYC__)
#include <signal.h>
#include "sigset.h"
@@ -46,10 +46,7 @@ void (*sigset(int sig, void (*func)(int)))(int)
if (sigaction(sig, func==SIG_HOLD?(struct sigaction *)0:&nact, &oact)
== -1)
return SIG_ERR;
- if (sigismember(&oset, sig))
- return SIG_HOLD;
- else
- return (oact.sa_handler);
+ return (oact.sa_handler);
}
#endif /* __FreeBSD__ || __dietlibc__ || __NetBSD__ || __OpenBSD__ ||
__DragonFly__ || __APPLE__ */
--- libcommon/sigset.h
+++ libcommon/sigset.h
@@ -22,7 +22,7 @@
/* Sccsid @(#)sigset.h 1.9 (gritter) 1/22/06 */
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (__NetBSD__) || \
- defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__)
+ defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__) || defined (__TINYC__)
#ifndef SIG_HOLD
#define SIG_HOLD ((void (*)(int))2)
--- libcommon/strtol.c
+++ libcommon/strtol.c
@@ -1,7 +1,7 @@
/* Sccsid @(#)strtol.c 1.6 (gritter) 7/18/04 */
#if defined (__hpux) || defined (_AIX) || \
- defined (__FreeBSD__) && (__FreeBSD__) < 5
+ (defined (__FreeBSD__) && (__FreeBSD__) < 5) || defined (__TINYC__)
#include <stdlib.h>
#include <ctype.h>
@@ -97,6 +97,7 @@ out: if (pp <= bptr) {
return v * sign;
}
+#ifndef __TINYC__
long long
strtoll(const char *nptr, char **endptr, int base)
{
@@ -108,6 +109,7 @@ strtoull(const char *nptr, char **endptr, int base)
{
return (unsigned long long)internal(nptr, endptr, base, 3);
}
+#endif
long long
atoll(const char *nptr)
--- nawk/awk.h
+++ nawk/awk.h
@@ -156,7 +156,6 @@ extern Cell *rlengthloc; /* RLENGTH */
#endif
#ifndef IN_MAKETAB
-#include <wchar.h>
/*
* Get next character from string s and store it in wc; n is set to
--- nawk/awk.lx.l
+++ nawk/awk.lx.l
@@ -71,7 +71,6 @@
#include "awk.h"
#include "y.tab.h"
-#include <pfmt.h>
#include <unistd.h>
static void awk_unputstr(const char *s);
--- nawk/run.c
+++ nawk/run.c
@@ -1467,14 +1467,6 @@ Cell *bltin(Node **a, int n)
case FRAND:
u = (Awkfloat) (rand() % 32767) / 32767.0;
break;
- case FSRAND:
- u = saved_srand; /* return previous seed */
- if (x->tval & REC) /* no argument provided */
- saved_srand = time(NULL);
- else
- saved_srand = getfval(x);
- srand((int) saved_srand);
- break;
case FTOUPPER:
case FTOLOWER:
p = getsval(x);
--- pgrep/pgrep.c
+++ pgrep/pgrep.c
@@ -214,7 +214,7 @@ chdir_to_proc(void)
fprintf(stderr, "%s: cannot open %s\n", progname, PROCDIR);
exit(3);
}
- if (fchdir(fd) < 0) {
+ if (chdir(PROCDIR) < 0) {
fprintf(stderr, "%s: cannot chdir to %s\n", progname, PROCDIR);
exit(3);
}
--- rm/rm.c
+++ rm/rm.c
@@ -242,7 +242,7 @@ rm(size_t pend, const char *base, const int olddir, int ssub, int level)
}
return;
}
- if (fchdir(df) < 0) {
+ if (chdir(base) < 0) {
if (rmfile(base, &st) < 0) {
fprintf(stderr,
"%s: cannot chdir to %s\n",
@@ -270,7 +270,7 @@ rm(size_t pend, const char *base, const int olddir, int ssub, int level)
progname, path);
errcnt |= 4;
}
- if (olddir >= 0 && fchdir(olddir) < 0) {
+ if (olddir >= 0) {
fprintf(stderr, "%s: cannot change backwards\n",
progname);
exit(1);
@@ -316,24 +316,6 @@ subproc(size_t pend, const char *base, int level)
int status;
while (waitpid(pid, &status, 0) != pid);
- if (status && WIFSIGNALED(status)) {
- /*
- * If the signal was sent due to a tty keypress,
- * we should be terminated automatically and
- * never reach this point. Otherwise, we terminate
- * with the same signal, but make sure that we do
- * not overwrite a possibly generated core file.
- * This results in nearly the usual behavior except
- * that the shell never prints a 'core dumped'
- * message.
- */
- struct rlimit rl;
-
- rl.rlim_cur = rl.rlim_max = 0;
- setrlimit(RLIMIT_CORE, &rl);
- raise(WTERMSIG(status));
- pause();
- }
return status ? WEXITSTATUS(status) : 0;
}
case -1:

View file

@ -1,11 +0,0 @@
--- nawk/Makefile.mk
+++ nawk/Makefile.mk
@@ -28,8 +28,6 @@ maketab: maketab.o
$(HOSTCC) maketab.o -o maketab
./maketab > proctab.c
-proctab.c: maketab
-
awk.g.o: awk.g.c
$(CC) $(CFLAGSS) $(CPPFLAGS) $(XO5FL) $(LARGEF) $(IWCHAR) $(ICOMMON) $(IUXRE) -c awk.g.c

View file

@ -1,73 +0,0 @@
--- comm/comm.c
+++ comm/comm.c
@@ -242,7 +242,7 @@ compare(const char *a, const char *b)
return(2);
}
} else {
- n = strcoll(a, b);
+ n = strcmp(a, b);
return n ? n > 0 ? 2 : 1 : 0;
}
}
--- expr/expr.y
+++ expr/expr.y
@@ -234,7 +234,7 @@ _rel(int op, register char *r1, register char *r2)
if (numeric(r1) && numeric(r2))
i = atoll(r1) - atoll(r2);
else
- i = strcoll(r1, r2);
+ i = strcmp(r1, r2);
switch(op) {
case EQ: i = i==0; break;
case GT: i = i>0; break;
--- join/join.c
+++ join/join.c
@@ -65,7 +65,7 @@ enum {
JF = -1
};
#define ppi(f, j) ((j) >= 0 && (j) < ppisize[f] ? ppibuf[f][j] : null)
-#define comp() strcoll(ppi(F1, j1),ppi(F2, j2))
+#define comp() strcmp(ppi(F1, j1),ppi(F2, j2))
#define next(wc, s, n) (*(s) & 0200 ? ((n) = mbtowi(&(wc), (s), mb_cur_max), \
(n) = ((n) > 0 ? (n) : (n) < 0 ? (wc=WEOF, 1) : 1)) : \
--- ls/ls.c
+++ ls/ls.c
@@ -575,13 +575,13 @@ _mergesort(struct file **al)
static int
namecmp(struct file *f1, struct file *f2)
{
- return strcoll(f1->name, f2->name);
+ return strcmp(f1->name, f2->name);
}
static int
extcmp(struct file *f1, struct file *f2)
{
- return strcoll(extension(f1->name), extension(f2->name));
+ return strcmp(extension(f1->name), extension(f2->name));
}
static int
--- nawk/run.c
+++ nawk/run.c
@@ -608,7 +608,7 @@ Cell *relop(Node **a, int n)
j = x->fval - y->fval;
i = j<0? -1: (j>0? 1: 0);
} else {
- i = strcoll((char*)getsval(x), (char*)getsval(y));
+ i = strcmp((char*)getsval(x), (char*)getsval(y));
}
tempfree(x, "");
tempfree(y, "");
--- sort/sort.c
+++ sort/sort.c
@@ -1148,7 +1148,7 @@ cmpl(const char *pa, const char *pb)
ecpy(collba, pa, '\n');
ecpy(collbb, pb, '\n');
- n = strcoll(collba, collbb);
+ n = strcmp(collba, collbb);
return n ? n > 0 ? -fields[0].rflg : fields[0].rflg : 0;
}

View file

@ -1,77 +0,0 @@
--- cmp/cmp.c
+++ cmp/cmp.c
@@ -264,7 +264,7 @@ openfile(const char *fn)
struct file *f;
if (pagesize == 0)
- if ((pagesize = sysconf(_SC_PAGESIZE)) < 0)
+ if ((pagesize = 4096) < 0)
pagesize = 4096;
if ((f = memalign(pagesize, sizeof *f)) == NULL) {
write(2, "no memory\n", 10);
--- copy/copy.c
+++ copy/copy.c
@@ -362,7 +362,7 @@ fdcopy(const char *src, const struct stat *sp, int sfd,
goto err;
}
#endif /* __linux__ */
- if (pagesize == 0 && (pagesize = sysconf(_SC_PAGESIZE)) <= 0)
+ if (pagesize == 0 && (pagesize = 4096) <= 0)
pagesize = 4096;
if ((blksize = sp->st_blksize) <= 0)
blksize = 512;
--- cp/cp.c
+++ cp/cp.c
@@ -438,7 +438,7 @@ fdcopy(const char *src, const struct stat *ssp, const int sfd,
}
#endif /* __linux__ */
if (pagesize == 0)
- if ((pagesize = sysconf(_SC_PAGESIZE)) < 0)
+ if ((pagesize = 4096) < 0)
pagesize = 4096;
if (bflag)
blksize = bflag;
--- libcommon/ib_alloc.c
+++ libcommon/ib_alloc.c
@@ -41,7 +41,7 @@ ib_alloc(int fd, unsigned blksize)
struct stat st;
if (pagesize == 0)
- if ((pagesize = sysconf(_SC_PAGESIZE)) < 0)
+ if ((pagesize = 4096) < 0)
pagesize = 4096;
if (blksize == 0) {
if (fstat(fd, &st) < 0)
--- libcommon/memalign.c
+++ libcommon/memalign.c
@@ -40,7 +40,7 @@ memalign(size_t alignment, size_t size)
static long pagesize;
if (pagesize == 0)
- pagesize = sysconf(_SC_PAGESIZE);
+ pagesize = 4096;
if (alignment != pagesize)
return NULL;
if (size < pagesize)
--- libcommon/oblok.c
+++ libcommon/oblok.c
@@ -100,7 +100,7 @@ ob_alloc(int fd, enum ob_mode bf)
struct oblok *op;
if (pagesize == 0)
- if ((pagesize = sysconf(_SC_PAGESIZE)) < 0)
+ if ((pagesize = 4096) < 0)
pagesize = 4096;
if ((op = memalign(pagesize, sizeof *op)) == NULL)
return NULL;
--- xargs/xargs.c
+++ xargs/xargs.c
@@ -404,7 +404,7 @@ static void
endcmd(void)
{
a_agg = a_cnt;
- a_maxsize = sysconf(_SC_ARG_MAX) - envsz() - 2048 - a_asz;
+ a_maxsize = 65536 - envsz() - 2048 - a_asz;
if (nflag || sflag) {
long newsize = sflag ? atol(sflag) :
#ifdef WEIRD_LIMITS

View file

@ -1,11 +0,0 @@
--- libwchar/Makefile.mk
+++ libwchar/Makefile.mk
@@ -10,7 +10,7 @@ fake:
if test "x$(LWCHAR)" = x; \
then \
touch $(OBJ); \
- ar r libwchar.a $(OBJ); \
+ touch libwchar.a $(OBJ); \
fi
install:

View file

@ -1,141 +0,0 @@
--- ed/ed.c
+++ ed/ed.c
@@ -68,7 +68,6 @@ static const char sccsid[] USED = "@(#)ed.sl 1.99 (gritter) 7/27/06";
#include <stdlib.h>
#include <signal.h>
#include "sigset.h"
-#include <termios.h>
#include <setjmp.h>
#include <libgen.h>
#include <inttypes.h>
@@ -77,7 +76,6 @@ static const char sccsid[] USED = "@(#)ed.sl 1.99 (gritter) 7/27/06";
#include <ctype.h>
#include <wctype.h>
#include <limits.h>
-#include <termios.h>
static int FNSIZE;
static int LBSIZE;
static int RHSIZE;
@@ -2273,22 +2271,10 @@ sclose(int fd)
static void
fspec(const char *lp)
{
- struct termios ts;
const char *cp;
freetabs();
maxlength = 0;
- if (tcgetattr(1, &ts) < 0
-#ifdef TAB3
- || (ts.c_oflag&TAB3) == 0
-#endif
- )
- return;
- while (lp[0]) {
- if (lp[0] == '<' && lp[1] == ':')
- break;
- lp++;
- }
if (lp[0]) {
lp += 2;
while ((cp = ftok(&lp)) != NULL) {
--- ls/ls.c
+++ ls/ls.c
@@ -102,7 +102,6 @@ static char ifmt_c[] = "-pc-d-b--nl-SD--";
#include <grp.h>
#include <errno.h>
#include <fcntl.h>
-#include <termios.h>
#include <locale.h>
#include <limits.h>
#include <ctype.h>
@@ -110,14 +109,6 @@ static char ifmt_c[] = "-pc-d-b--nl-SD--";
#include <wchar.h>
#include <wctype.h>
#include "config.h"
-#ifndef USE_TERMCAP
-#ifndef sun
-#include <curses.h>
-#include <term.h>
-#endif
-#else /* USE_TERMCAP */
-#include <termcap.h>
-#endif /* USE_TERMCAP */
#ifdef _AIX
#include <sys/sysmacros.h>
@@ -989,13 +980,6 @@ printname(const char *name, struct file *f, int doit)
bold++;
}
if (color) {
-#ifndef USE_TERMCAP
- if (bold)
- vidattr(A_BOLD);
-#else /* USE_TERMCAP */
- if (Bold)
- tputs(Bold, 1, putchar);
-#endif /* USE_TERMCAP */
printf(color);
}
}
@@ -1056,13 +1040,6 @@ printname(const char *name, struct file *f, int doit)
}
}
if (doit && color) {
-#if !defined (USE_TERMCAP)
- if (bold)
- vidattr(A_NORMAL);
-#else /* USE_TERMCAP */
- if (Normal)
- tputs(Normal, 1, putchar);
-#endif /* USE_TERMCAP */
printf(fc_get(FC_NORMAL));
}
if (f)
@@ -1598,16 +1575,12 @@ main(int argc, char **argv)
{
struct file *flist = nil, **aflist = &flist;
enum depth depth;
- struct winsize ws;
int i;
char *cp;
#ifdef __GLIBC__
putenv("POSIXLY_CORRECT=1");
#endif
- setlocale(LC_COLLATE, "");
- setlocale(LC_CTYPE, "");
- setlocale(LC_TIME, "");
#ifndef UCB
if (getenv("SYSV3") != NULL)
sysv3 = 1;
@@ -1624,16 +1597,6 @@ main(int argc, char **argv)
}
if (istty || isatty(1)) {
istty = 1;
-#if !defined (USE_TERMCAP)
- setupterm(NULL, 1, &tinfostat);
-#else /* USE_TERMCAP */
- {
- char buf[2048];
- if ((cp = getenv("TERM")) != NULL)
- if (tgetent(buf, cp) > 0)
- tinfostat = 1;
- }
-#endif /* USE_TERMCAP */
field |= FL_STATUS;
}
while ((i = getopt(argc, argv, personalities[personality].per_opt))
@@ -1753,12 +1716,6 @@ main(int argc, char **argv)
if ((cp = getenv("COLUMNS")) != NULL) {
ncols = atoi(cp);
} else if ((present('C') || present('x') || present('m')) && istty) {
- if (ioctl(1, TIOCGWINSZ, &ws) == 0 && ws.ws_col > 0)
- ncols = ws.ws_col - 1;
-#if !defined (USE_TERMCAP)
- else if (tinfostat == 1 && columns > 0)
- ncols = columns;
-#endif /* !USE_TERMCAP */
}
depth = SURFACE;
if (optind == argc) {

View file

@ -1,90 +0,0 @@
--- copy/copy.c
+++ copy/copy.c
@@ -46,7 +46,6 @@ static const char sccsid[] USED = "@(#)copy.sl 1.15 (gritter) 5/29/05";
#include <libgen.h>
#include <limits.h>
#include <dirent.h>
-#include <utime.h>
#include <stdarg.h>
#include "sfile.h"
#include "memalign.h"
@@ -441,12 +440,6 @@ attribs(const char *dst, const struct stat *sp)
if (oflag && ((sp->st_mode&S_IFMT) == S_IFLNK ?
lchown:chown)(dst, sp->st_uid, sp->st_gid) < 0)
complain("Unable to chown %s", dst);
- if (mflag && (sp->st_mode&S_IFMT) != S_IFLNK) {
- struct utimbuf ut;
- ut.actime = sp->st_atime;
- ut.modtime = sp->st_mtime;
- utime(dst, &ut);
- }
}
static void
--- cp/cp.c
+++ cp/cp.c
@@ -56,7 +56,6 @@ static const char sccsid[] USED = "@(#)cp.sl 1.84 (gritter) 3/4/06";
#include <libgen.h>
#include <limits.h>
#include <dirent.h>
-#include <utime.h>
#include "sfile.h"
#include "memalign.h"
#include "alloca.h"
@@ -354,18 +353,6 @@ permissions(const char *path, const struct stat *ssp)
mode = ssp->st_mode & 07777;
if (pflag) {
- struct utimbuf ut;
- ut.actime = ssp->st_atime;
- ut.modtime = ssp->st_mtime;
- if (utime(path, &ut) < 0) {
-#if defined (SUS) || defined (S42)
- fprintf(stderr, "%s: cannot set times for %s\n%s: %s\n",
- progname, path,
- progname, strerror(errno));
-#endif /* SUS || S42 */
- if (pers != PERS_MV)
- errcnt |= 010;
- }
if (myuid == 0) {
if (chown(path, ssp->st_uid, ssp->st_gid) < 0) {
#if defined (SUS) || defined (S42)
--- touch/touch.c
+++ touch/touch.c
@@ -47,7 +47,6 @@ static const char sccsid[] USED = "@(#)touch.sl 1.21 (gritter) 5/29/05";
#include <stdlib.h>
#include <errno.h>
#include <libgen.h>
-#include <utime.h>
#include <ctype.h>
#include <time.h>
@@ -80,7 +79,6 @@ static void
touch(const char *fn)
{
struct stat st;
- struct utimbuf ut;
if (stat(fn, &st) < 0) {
if (errno == ENOENT) {
@@ -113,19 +111,6 @@ touch(const char *fn)
return;
}
}
- if (aflag)
- ut.actime = nacc;
- else
- ut.actime = st.st_atime;
- if (mflag)
- ut.modtime = nmod;
- else
- ut.modtime = st.st_mtime;
- if (utime(fn, nulltime ? NULL : &ut) < 0) {
- fprintf(stderr, "%s: cannot change times on %s\n",
- progname, fn);
- errcnt++;
- }
}
static void

View file

@ -1,128 +0,0 @@
--- cksum/cksum.c
+++ cksum/cksum.c
@@ -147,7 +147,7 @@ cksum(const char *name)
s = (s << 8) ^ crctab[(s >> 24) ^ c];
}
s = ~s;
- printf("%u %llu", (unsigned)s, nbytes);
+ printf("%u %lu", (unsigned)s, nbytes);
if(name)
printf(" %s", name);
printf("\n");
--- cmp/cmp.c
+++ cmp/cmp.c
@@ -246,8 +246,8 @@ different:
errcnt = 1;
} else {
if (sflag == 0)
- printf("%s %s differ: char %lld,"
- " line %lld\n",
+ printf("%s %s differ: char %ld,"
+ " line %ld\n",
f1->f_nam, f2->f_nam,
(long long)offset(f1),
line);
--- csplit/csplit.c
+++ csplit/csplit.c
@@ -284,7 +284,7 @@ csplit(const char *fn)
op = nextfile();
if (op) {
if (!sflag)
- printf("%lld\n", bytes);
+ printf("%ld\n", bytes);
bytes = 0;
fclose(op);
}
--- expr/expr.y
+++ expr/expr.y
@@ -140,7 +140,7 @@ expression: expr NOARG {
if (sus && numeric($1)) {
int64_t n;
n = atoll($1);
- printf("%lld\n", n);
+ printf("%ld\n", n);
exit(n == 0);
} else
puts($1);
@@ -447,10 +447,10 @@ numpr(int64_t val)
int ret;
rv = smalloc(NUMSZ);
- ret = snprintf(rv, NUMSZ, "%lld", (long long)val);
+ ret = snprintf(rv, NUMSZ, "%ld", (long long)val);
if (ret < 0 || ret >= NUMSZ) {
rv = srealloc(rv, ret + 1);
- ret = snprintf(rv, ret, "%lld", (long long)val);
+ ret = snprintf(rv, ret, "%ld", (long long)val);
if (ret < 0)
yyerror("illegal number");
}
--- grep/Makefile.mk
+++ grep/Makefile.mk
@@ -92,7 +92,7 @@ config.h:
-echo 'long long foo;' >___build$$$$.c ; \
$(CC) $(CFLAGS2) $(CPPFLAGS) $(IWCHAR) $(ICOMMON) $(IUXRE) $(LARGEF) -c ___build$$$$.c >/dev/null 2>&1 ; \
if test $$? = 0 && test -f ___build$$$$.o ; \
- then echo '#define LONGLONG' >>config.h ; \
+ then echo '' >>config.h ; \
fi ; \
rm -f ___build$$$$.o ___build$$$$.c
--- ls/Makefile.mk
+++ ls/Makefile.mk
@@ -76,7 +76,7 @@ config.h:
-echo 'long long foo;' >___build$$$$.c ; \
$(CC) $(CFLAGS) $(CPPFLAGS) $(LARGEF) $(IWCHAR) -c ___build$$$$.c >/dev/null 2>&1 ; \
if test $$? = 0 && test -f ___build$$$$.o ; \
- then echo '#define LONGLONG' >>config.h ; \
+ then echo '' >>config.h ; \
fi ; \
rm -f ___build$$$$.o ___build$$$$.c
-echo '#include <sys/types.h>' >___build$$$$.c ; \
--- pr/pr.c
+++ pr/pr.c
@@ -548,7 +548,7 @@ print(const char *fp, const char **argp)
putcs(" ");
putcs(header);
snprintf(linebuf, sizeof linebuf,
- " Page %lld\n\n\n", page);
+ " Page %ld\n\n\n", page);
putcs(linebuf);
}
c = putpage();
--- sed/sed1.c
+++ sed/sed1.c
@@ -489,7 +489,7 @@ command(struct reptr *ipc)
break;
case EQCOM:
- fprintf(stdout, "%lld\n", lnum);
+ fprintf(stdout, "%ld\n", lnum);
break;
case GCOM:
--- sum/sum.c
+++ sum/sum.c
@@ -116,7 +116,7 @@ sum(const char *name)
else {
s = (s & 0xFFFF) + (s >> 16);
s = (s & 0xFFFF) + (s >> 16);
- printf("%u %llu", (unsigned)s,
+ printf("%u %lu", (unsigned)s,
(unsigned long long)(nbytes+UNIT-1)/UNIT);
}
if(name)
--- wc/wc.c
+++ wc/wc.c
@@ -89,9 +89,9 @@ report(unsigned long long count)
#if defined (S42)
if (putspace++)
printf(" ");
- printf("%llu", count);
+ printf("%lu", count);
#else /* !S42 */
- printf("%7llu ", count);
+ printf("%7lu ", count);
#endif /* !S42 */
}

View file

@ -1,206 +0,0 @@
#include <stdio.h>
#include "awk.h"
#include "y.tab.h"
static unsigned char *printname[92] = {
(unsigned char *) "FIRSTTOKEN", /* 258 */
(unsigned char *) "PROGRAM", /* 259 */
(unsigned char *) "PASTAT", /* 260 */
(unsigned char *) "PASTAT2", /* 261 */
(unsigned char *) "XBEGIN", /* 262 */
(unsigned char *) "XEND", /* 263 */
(unsigned char *) "NL", /* 264 */
(unsigned char *) "ARRAY", /* 265 */
(unsigned char *) "MATCH", /* 266 */
(unsigned char *) "NOTMATCH", /* 267 */
(unsigned char *) "MATCHOP", /* 268 */
(unsigned char *) "FINAL", /* 269 */
(unsigned char *) "DOT", /* 270 */
(unsigned char *) "ALL", /* 271 */
(unsigned char *) "CCL", /* 272 */
(unsigned char *) "NCCL", /* 273 */
(unsigned char *) "CHAR", /* 274 */
(unsigned char *) "MCHAR", /* 275 */
(unsigned char *) "OR", /* 276 */
(unsigned char *) "STAR", /* 277 */
(unsigned char *) "QUEST", /* 278 */
(unsigned char *) "PLUS", /* 279 */
(unsigned char *) "AND", /* 280 */
(unsigned char *) "BOR", /* 281 */
(unsigned char *) "APPEND", /* 282 */
(unsigned char *) "EQ", /* 283 */
(unsigned char *) "GE", /* 284 */
(unsigned char *) "GT", /* 285 */
(unsigned char *) "LE", /* 286 */
(unsigned char *) "LT", /* 287 */
(unsigned char *) "NE", /* 288 */
(unsigned char *) "IN", /* 289 */
(unsigned char *) "ARG", /* 290 */
(unsigned char *) "BLTIN", /* 291 */
(unsigned char *) "BREAK", /* 292 */
(unsigned char *) "CONTINUE", /* 293 */
(unsigned char *) "DELETE", /* 294 */
(unsigned char *) "DO", /* 295 */
(unsigned char *) "EXIT", /* 296 */
(unsigned char *) "FOR", /* 297 */
(unsigned char *) "FUNC", /* 298 */
(unsigned char *) "SUB", /* 299 */
(unsigned char *) "GSUB", /* 300 */
(unsigned char *) "IF", /* 301 */
(unsigned char *) "INDEX", /* 302 */
(unsigned char *) "LSUBSTR", /* 303 */
(unsigned char *) "MATCHFCN", /* 304 */
(unsigned char *) "NEXT", /* 305 */
(unsigned char *) "ADD", /* 306 */
(unsigned char *) "MINUS", /* 307 */
(unsigned char *) "MULT", /* 308 */
(unsigned char *) "DIVIDE", /* 309 */
(unsigned char *) "MOD", /* 310 */
(unsigned char *) "ASSIGN", /* 311 */
(unsigned char *) "ASGNOP", /* 312 */
(unsigned char *) "ADDEQ", /* 313 */
(unsigned char *) "SUBEQ", /* 314 */
(unsigned char *) "MULTEQ", /* 315 */
(unsigned char *) "DIVEQ", /* 316 */
(unsigned char *) "MODEQ", /* 317 */
(unsigned char *) "POWEQ", /* 318 */
(unsigned char *) "PRINT", /* 319 */
(unsigned char *) "PRINTF", /* 320 */
(unsigned char *) "SPRINTF", /* 321 */
(unsigned char *) "ELSE", /* 322 */
(unsigned char *) "INTEST", /* 323 */
(unsigned char *) "CONDEXPR", /* 324 */
(unsigned char *) "POSTINCR", /* 325 */
(unsigned char *) "PREINCR", /* 326 */
(unsigned char *) "POSTDECR", /* 327 */
(unsigned char *) "PREDECR", /* 328 */
(unsigned char *) "VAR", /* 329 */
(unsigned char *) "IVAR", /* 330 */
(unsigned char *) "VARNF", /* 331 */
(unsigned char *) "CALL", /* 332 */
(unsigned char *) "NUMBER", /* 333 */
(unsigned char *) "STRING", /* 334 */
(unsigned char *) "FIELD", /* 335 */
(unsigned char *) "REGEXPR", /* 336 */
(unsigned char *) "GETLINE", /* 337 */
(unsigned char *) "RETURN", /* 338 */
(unsigned char *) "SPLIT", /* 339 */
(unsigned char *) "SUBSTR", /* 340 */
(unsigned char *) "WHILE", /* 341 */
(unsigned char *) "CAT", /* 342 */
(unsigned char *) "NOT", /* 343 */
(unsigned char *) "UMINUS", /* 344 */
(unsigned char *) "POWER", /* 345 */
(unsigned char *) "DECR", /* 346 */
(unsigned char *) "INCR", /* 347 */
(unsigned char *) "INDIRECT", /* 348 */
(unsigned char *) "LASTTOKEN", /* 349 */
};
Cell *(*proctab[92])(Node **, int) = {
nullproc, /* FIRSTTOKEN */
program, /* PROGRAM */
pastat, /* PASTAT */
dopa2, /* PASTAT2 */
nullproc, /* XBEGIN */
nullproc, /* XEND */
nullproc, /* NL */
array, /* ARRAY */
matchop, /* MATCH */
matchop, /* NOTMATCH */
nullproc, /* MATCHOP */
nullproc, /* FINAL */
nullproc, /* DOT */
nullproc, /* ALL */
nullproc, /* CCL */
nullproc, /* NCCL */
nullproc, /* CHAR */
nullproc, /* MCHAR */
nullproc, /* OR */
nullproc, /* STAR */
nullproc, /* QUEST */
nullproc, /* PLUS */
boolop, /* AND */
boolop, /* BOR */
nullproc, /* APPEND */
relop, /* EQ */
relop, /* GE */
relop, /* GT */
relop, /* LE */
relop, /* LT */
relop, /* NE */
instat, /* IN */
arg, /* ARG */
bltin, /* BLTIN */
jump, /* BREAK */
jump, /* CONTINUE */
delete, /* DELETE */
dostat, /* DO */
jump, /* EXIT */
forstat, /* FOR */
nullproc, /* FUNC */
sub, /* SUB */
gsub, /* GSUB */
ifstat, /* IF */
sindex, /* INDEX */
nullproc, /* LSUBSTR */
matchop, /* MATCHFCN */
jump, /* NEXT */
arith, /* ADD */
arith, /* MINUS */
arith, /* MULT */
arith, /* DIVIDE */
arith, /* MOD */
assign, /* ASSIGN */
nullproc, /* ASGNOP */
assign, /* ADDEQ */
assign, /* SUBEQ */
assign, /* MULTEQ */
assign, /* DIVEQ */
assign, /* MODEQ */
assign, /* POWEQ */
print, /* PRINT */
aprintf, /* PRINTF */
awsprintf, /* SPRINTF */
nullproc, /* ELSE */
intest, /* INTEST */
condexpr, /* CONDEXPR */
incrdecr, /* POSTINCR */
incrdecr, /* PREINCR */
incrdecr, /* POSTDECR */
incrdecr, /* PREDECR */
nullproc, /* VAR */
nullproc, /* IVAR */
getnf, /* VARNF */
call, /* CALL */
nullproc, /* NUMBER */
nullproc, /* STRING */
nullproc, /* FIELD */
nullproc, /* REGEXPR */
getline, /* GETLINE */
jump, /* RETURN */
split, /* SPLIT */
substr, /* SUBSTR */
whilestat, /* WHILE */
cat, /* CAT */
boolop, /* NOT */
arith, /* UMINUS */
arith, /* POWER */
nullproc, /* DECR */
nullproc, /* INCR */
indirect, /* INDIRECT */
nullproc, /* LASTTOKEN */
};
unsigned char *tokname(int n)
{
static unsigned char buf[100];
if (n < FIRSTTOKEN || n > LASTTOKEN) {
snprintf((char *)buf, sizeof buf, "token %d", n);
return buf;
}
return printname[n-257];
}

View file

@ -1,64 +0,0 @@
#include <getopt.h>
extern int optopt;
int ftruncate(int fd, int offset) {
return -1;
}
int getsid (int pid) {
return -1;
}
static int isblank(int c)
{
return c == ' ' || c == '\t';
}
#define lchown chown
// meslibc implements lstat but is missing declaration
#include <sys/stat.h>
int lstat (char const *file_name, struct stat *statbuf);
#include <fcntl.h>
int mkstemp(char *t)
{
mktemp(t);
int fd = open(t, O_CREAT|O_RDWR|O_TRUNC, 0600);
return fd;
}
int putenv(char *string)
{
return 0;
}
char* realpath (char* path, char* resolved) {
return NULL;
}
#define strncasecmp(a,b,n) strncmp(strupr(a),strupr(b),n)
#define nlink_t unsigned long
#include <limits.h>
#define USHRT_MAX UINT16_MAX
#define SSIZE_MAX LONG_MAX
#define MB_LEN_MAX 1
#define EPERM 1
#define ESRCH 3
#define EDOM 33
#define S_IFSOCK 0140000
#define S_ISVTX 01000
#define S_IREAD S_IRUSR
#define S_IWRITE S_IWUSR
#define S_IEXEC S_IXUSR
#define _PC_PATH_MAX PATH_MAX
#define _PC_VDISABLE 8
#define _POSIX_PATH_MAX PATH_MAX
#define LINE_MAX 4096
#define LC_TIME 0

View file

@ -1,92 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.linux-headers;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.linux-headers = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Header files and scripts for Linux kernel.";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.lgpl2Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for linux-headers.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.linux-headers = {
version = "6.5.6";
src = builtins.fetchurl {
url = "https://cdn.kernel.org/pub/linux/kernel/v${lib.versions.major cfg.version}.x/linux-${cfg.version}.tar.xz";
sha256 = "eONtQhRUcFHCTfIUD0zglCjWxRWtmnGziyjoCUqV0vY=";
};
package = builders.bash.build {
name = "linux-headers-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.gcc.package
stage1.musl.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.package
stage1.diffutils.package
stage1.findutils.package
stage1.gnutar.package
stage1.xz.package
];
script = ''
# Unpack
tar xf ${cfg.src}
cd linux-${cfg.version}
# Build
make -j $NIX_BUILD_CORES CC=musl-gcc HOSTCC=musl-gcc ARCH=x86 headers
# Install
find usr/include -name '.*' -exec rm {} +
mkdir -p $out
cp -rv usr/include $out/
'';
};
};
};
}

View file

@ -1,63 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.ln-boot;
builders = config.aux.foundation.builders;
stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.ln-boot = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "A basic program to create symlinks.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://github.com/auxolotl/labs";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.mit;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for ln-boot.";
};
};
config = {
aux.foundation.stages.stage1.ln-boot = {
package = builders.kaem.build {
name = "ln-boot";
meta = cfg.meta;
script = ''
mkdir -p ''${out}/bin
${stage1.mes.compiler.package}/bin/mes --no-auto-compile -e main ${stage1.mes.libs.src.bin}/bin/mescc.scm -- \
-L ${stage1.mes.libs.package}/lib \
-lc+tcc \
-o ''${out}/bin/ln \
${./main.c}
'';
};
};
};
}

View file

@ -1,16 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char **argv) {
if (argc != 4 || strcmp(argv[1], "-s")) {
fputs("Usage: ", stdout);
fputs(argv[0], stdout);
fputs(" -s TARGET LINK_NAME\n", stdout);
exit(EXIT_FAILURE);
}
symlink(argv[2], argv[3]);
exit(EXIT_SUCCESS);
}

View file

@ -1,109 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.mes.compiler;
system = config.aux.system;
builders = config.aux.foundation.builders;
stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.mes.compiler = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Scheme interpreter and C compiler for bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/mes";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for the mes compiler.";
};
};
config = {
aux.foundation.stages.stage1.mes.compiler = {
package =
let
compile =
path:
let
file = builtins.baseNameOf path;
fileWithoutExtension = builtins.replaceStrings [ ".c" ] [ "" ] file;
cc = builtins.concatStringsSep " " [
"${stage1.mes.libs.src.bin}/bin/mes-m2"
"-e"
"main"
"${stage1.mes.libs.src.bin}/bin/mescc.scm"
"--"
"-D"
"HAVE_CONFIG_H=1"
"-I"
"${stage1.mes.libs.prefix}/include"
"-I"
"${stage1.mes.libs.prefix}/include/linux/x86"
];
in
builders.kaem.build {
name = fileWithoutExtension;
script = ''
mkdir ''${out}
cd ''${out}
${cc} -c ${stage1.mes.libs.prefix}/${path}
'';
};
getSourcePath = suffix: source: "${source}/${source.name}${suffix}";
sources = import ./sources.nix;
files = lib.strings.concatMapSep " " (getSourcePath ".o") (
builtins.map compile sources.x86.linux.mescc.mes
);
in
builders.kaem.build {
name = "mes-${stage1.mes.version}";
meta = cfg.meta;
script = ''
mkdir -p ''${out}/bin
${stage1.mes.libs.src.bin}/bin/mes-m2 -e main ${stage1.mes.libs.src.bin}/bin/mescc.scm -- \
-L ${stage1.mes.libs.prefix}/lib \
-L ${stage1.mes.libs.package}/lib \
-lc \
-lmescc \
-nostdlib \
-o ''${out}/bin/mes \
${stage1.mes.libs.package}/lib/x86-mes/crt1.o \
${files}
'';
};
};
};
}

View file

@ -1,99 +0,0 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash coreutils gnutar
# Generate a sources.nix for a version of GNU mes. Creates lists of source files
# from build-aux/configure-lib.sh.
#
# You may point this tool at a manually downloaded tarball, but more ideal is
# using the source tarball from Nixpkgs. For example:
#
# MES_TARBALL="$(nix eval --raw .#extras.stage1.mes.src)"
# ./create-sources.sh "$MES_TARBALL" > ./sources.nix
#
# Alternatively, here is a one-liner:
#
# ./create-sources.sh "$(nix eval --raw .#extras.stage1.mes.src)" > ./sources.nix
set -eu
# Supported platforms
ARCHS="x86"
KERNELS="linux"
COMPILERS="mescc gcc"
format() {
echo "["
echo $* | xargs printf ' "%s"\n'
echo " ]"
}
gen_sources() {
# Configuration variables used by configure-lib.sh
export mes_libc=mes
export mes_cpu=$1
export mes_kernel=$2
export compiler=$3
# Populate source file lists
source $CONFIGURE_LIB_SH
cat <<EOF
$mes_cpu.$mes_kernel.$compiler = {
libc_mini = $(format $libc_mini_SOURCES);
libmescc = $(format $libmescc_SOURCES);
libtcc1 = $(format $libtcc1_SOURCES);
libc = $(format $libc_SOURCES);
libc_tcc = $(format $libc_tcc_SOURCES);
libc_gnu = $(format $libc_gnu_SOURCES);
mes = $(format $mes_SOURCES);
};
EOF
}
MES_TARBALL=$1
if [ ! -f $MES_TARBALL ]; then
echo "Provide path to mes-x.x.x.tar.gz as first argument" >&2
exit 1
fi
echo "Generating sources.nix from $MES_TARBALL" >&2
TMP=$(mktemp -d)
cd $TMP
echo "Workdir: $TMP" >&2
echo "Extracting $MES_TARBALL" >&2
tar --strip-components 1 -xf $MES_TARBALL
CONFIGURE_LIB_SH="$TMP/build-aux/configure-lib.sh"
if [ ! -f $CONFIGURE_LIB_SH ]; then
echo "Could not find mes's configure-lib.sh script at $CONFIGURE_LIB_SH" >&2
exit 1
fi
# Create dummy config expected by configure-lib.sh
touch config.sh
chmod +x config.sh
echo "Configuring with $CONFIGURE_LIB_SH" >&2
cat <<EOF
# This file is generated by ./create-sources.sh.
# Do not edit!
{
EOF
for arch in $ARCHS; do
for kernel in $KERNELS; do
for compiler in $COMPILERS; do
gen_sources $arch $kernel $compiler
done
done
done
cat <<EOF
}
EOF

View file

@ -1,37 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.mes;
system = config.aux.system;
builders = config.aux.foundation.builders;
in
{
includes = [
./compiler.nix
./libs.nix
./libc.nix
];
options.aux.foundation.stages.stage1.mes = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
};
config = {
aux.foundation.stages.stage1.mes = {
version = "0.25";
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/mes/mes-${cfg.version}.tar.gz";
sha256 = "MlJQs1Z+2SA7pwFhyDWvAQeec+vtl7S1u3fKUAuCiUA=";
};
};
};
}

View file

@ -1,93 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.mes.libc;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.mes.libc = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "The Mes C Library";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://gnu.org/software/mes";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for mes-libc.";
};
};
config = {
aux.foundation.stages.stage1.mes.libc = {
package =
let
sources = import ./sources.nix;
libtcc1 = sources.x86.linux.gcc.libtcc1;
first = lib.lists.take 100 sources.x86.linux.gcc.libc_gnu;
last = lib.lists.drop 100 sources.x86.linux.gcc.libc_gnu;
in
builders.kaem.build {
name = "mes-libc-${stage1.mes.version}";
meta = cfg.meta;
deps.build.host = [ stage1.ln-boot.package ];
script = ''
cd ${stage1.mes.libs.prefix}
# mescc compiled libc.a
mkdir -p ''${out}/lib/x86-mes
# libc.c
catm ''${TMPDIR}/first.c ${builtins.concatStringsSep " " first}
catm ''${out}/lib/libc.c ''${TMPDIR}/first.c ${builtins.concatStringsSep " " last}
# crt{1,n,i}.c
cp lib/linux/x86-mes-gcc/crt1.c ''${out}/lib
cp lib/linux/x86-mes-gcc/crtn.c ''${out}/lib
cp lib/linux/x86-mes-gcc/crti.c ''${out}/lib
# libtcc1.c
catm ''${out}/lib/libtcc1.c ${builtins.concatStringsSep " " libtcc1}
# getopt.c
cp lib/posix/getopt.c ''${out}/lib/libgetopt.c
# Install headers
ln -s ${stage1.mes.libs.prefix}/include ''${out}/include
'';
extras = {
CFLAGS = "-DHAVE_CONFIG_H=1 -I${cfg.package}/include -I${cfg.package}/include/linux/x86";
};
};
};
};
}

View file

@ -1,253 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.mes.libs;
system = config.aux.system;
builders = config.aux.foundation.builders;
stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.mes.libs = {
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "Scheme interpreter and C compiler for bootstrapping.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/mes";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = [ "i686-linux" ];
};
};
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for mes libs.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
prefix = lib.options.create {
type = lib.types.string;
description = "Prefix for the package.";
};
};
config = {
aux.foundation.stages.stage1.mes.libs = {
prefix = "${cfg.src.out}/mes-${stage1.mes.version}";
src =
let
config_h = builtins.toFile "config.h" ''
#undef SYSTEM_LIBC
#define MES_VERSION "${stage1.mes.version}"
'';
in
builders.kaem.build {
name = "mes-src-${stage1.mes.version}";
meta = cfg.meta;
outputs = [
"out"
"bin"
];
script = ''
# Unpack source
ungz --file ${stage1.mes.src} --output mes.tar
mkdir ''${out}
cd ''${out}
untar --non-strict --file ''${NIX_BUILD_TOP}/mes.tar # ignore symlinks
MES_PREFIX=''${out}/mes-${stage1.mes.version}
cd ''${MES_PREFIX}
cp ${config_h} include/mes/config.h
mkdir include/arch
cp include/linux/x86/syscall.h include/arch/syscall.h
cp include/linux/x86/kernel-stat.h include/arch/kernel-stat.h
# Remove pregenerated files
rm mes/module/mes/psyntax.pp mes/module/mes/psyntax.pp.header
# These files are symlinked in the repo
cp mes/module/srfi/srfi-9-struct.mes mes/module/srfi/srfi-9.mes
cp mes/module/srfi/srfi-9/gnu-struct.mes mes/module/srfi/srfi-9/gnu.mes
# Remove environment impurities
__GUILE_LOAD_PATH="\"''${MES_PREFIX}/mes/module:''${MES_PREFIX}/module:${stage1.nyacc.package.extras.guileModule}\""
boot0_scm=mes/module/mes/boot-0.scm
guile_mes=mes/module/mes/guile.mes
replace --file ''${boot0_scm} --output ''${boot0_scm} --match-on "(getenv \"GUILE_LOAD_PATH\")" --replace-with ''${__GUILE_LOAD_PATH}
replace --file ''${guile_mes} --output ''${guile_mes} --match-on "(getenv \"GUILE_LOAD_PATH\")" --replace-with ''${__GUILE_LOAD_PATH}
module_mescc_scm=module/mescc/mescc.scm
replace --file ''${module_mescc_scm} --output ''${module_mescc_scm} --match-on "(getenv \"M1\")" --replace-with "\"${stage0.mescc-tools.package}/bin/M1\""
replace --file ''${module_mescc_scm} --output ''${module_mescc_scm} --match-on "(getenv \"HEX2\")" --replace-with "\"${stage0.mescc-tools.package}/bin/hex2\""
replace --file ''${module_mescc_scm} --output ''${module_mescc_scm} --match-on "(getenv \"BLOOD_ELF\")" --replace-with "\"${stage0.mescc-tools.package}/bin/blood-elf\""
replace --file ''${module_mescc_scm} --output ''${module_mescc_scm} --match-on "(getenv \"srcdest\")" --replace-with "\"''${MES_PREFIX}\""
mes_c=src/mes.c
replace --file ''${mes_c} --output ''${mes_c} --match-on "getenv (\"MES_PREFIX\")" --replace-with "\"''${MES_PREFIX}\""
replace --file ''${mes_c} --output ''${mes_c} --match-on "getenv (\"srcdest\")" --replace-with "\"''${MES_PREFIX}\""
# Increase runtime resource limits
gc_c=src/gc.c
replace --file ''${gc_c} --output ''${gc_c} --match-on "getenv (\"MES_ARENA\")" --replace-with "\"100000000\""
replace --file ''${gc_c} --output ''${gc_c} --match-on "getenv (\"MES_MAX_ARENA\")" --replace-with "\"100000000\""
replace --file ''${gc_c} --output ''${gc_c} --match-on "getenv (\"MES_STACK\")" --replace-with "\"6000000\""
# Create mescc.scm
mescc_in=scripts/mescc.scm.in
replace --file ''${mescc_in} --output ''${mescc_in} --match-on "(getenv \"MES_PREFIX\")" --replace-with "\"''${MES_PREFIX}\""
replace --file ''${mescc_in} --output ''${mescc_in} --match-on "(getenv \"includedir\")" --replace-with "\"''${MES_PREFIX}/include\""
replace --file ''${mescc_in} --output ''${mescc_in} --match-on "(getenv \"libdir\")" --replace-with "\"''${MES_PREFIX}/lib\""
replace --file ''${mescc_in} --output ''${mescc_in} --match-on @prefix@ --replace-with ''${MES_PREFIX}
replace --file ''${mescc_in} --output ''${mescc_in} --match-on @VERSION@ --replace-with ${stage1.mes.version}
replace --file ''${mescc_in} --output ''${mescc_in} --match-on @mes_cpu@ --replace-with x86
replace --file ''${mescc_in} --output ''${mescc_in} --match-on @mes_kernel@ --replace-with linux
mkdir -p ''${bin}/bin
cp ''${mescc_in} ''${bin}/bin/mescc.scm
# Build mes-m2
kaem --verbose --strict --file kaem.x86
cp bin/mes-m2 ''${bin}/bin/mes-m2
chmod 555 ''${bin}/bin/mes-m2
'';
};
package =
let
compile =
path:
let
file = builtins.baseNameOf path;
fileWithoutExtension = builtins.replaceStrings [ ".c" ] [ "" ] file;
cc = builtins.concatStringsSep " " [
"${cfg.src.bin}/bin/mes-m2"
"-e"
"main"
"${cfg.src.bin}/bin/mescc.scm"
"--"
"-D"
"HAVE_CONFIG_H=1"
"-I"
"${cfg.prefix}/include"
"-I"
"${cfg.prefix}/include/linux/x86"
];
in
builders.kaem.build {
name = fileWithoutExtension;
script = ''
mkdir ''${out}
cd ''${out}
${cc} -c ${cfg.prefix}/${path}
'';
};
getSourcePath = suffix: source: "${source}/${source.name}${suffix}";
archive =
destination: sources:
"catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".o") sources}";
source =
destination: sources:
"catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".s") sources}";
createLib =
name: sources:
let
compiled = builtins.map compile sources;
in
builders.kaem.build {
name = "mes-${name}-${stage1.mes.version}";
meta = cfg.meta;
script = ''
LIBDIR=''${out}/lib
mkdir -p ''${LIBDIR}
cd ''${LIBDIR}
${archive "${name}.a" compiled}
${source "${name}.s" compiled}
'';
};
sources = import ./sources.nix;
crt1 = compile "lib/linux/x86-mes-mescc/crt1.c";
libc-mini = createLib "libc-mini" sources.x86.linux.mescc.libc_mini;
libmescc = createLib "libmescc" sources.x86.linux.mescc.libmescc;
libc = createLib "libc" sources.x86.linux.mescc.libc;
libc_tcc = createLib "libc+tcc" (
sources.x86.linux.mescc.libc_tcc
++ [
# We need `symlink` support for `ln-boot` to work.
"lib/linux/symlink.c"
]
);
in
builders.kaem.build {
name = "mes-m2-libs-${stage1.mes.version}";
meta = cfg.meta;
script = ''
LIBDIR=''${out}/lib
mkdir -p ''${out} ''${LIBDIR}
mkdir -p ''${LIBDIR}/x86-mes
# crt1.o
cp ${crt1}/crt1.o ''${LIBDIR}/x86-mes
cp ${crt1}/crt1.s ''${LIBDIR}/x86-mes
# libc-mini.a
cp ${libc-mini}/lib/libc-mini.a ''${LIBDIR}/x86-mes
cp ${libc-mini}/lib/libc-mini.s ''${LIBDIR}/x86-mes
# libmescc.a
cp ${libmescc}/lib/libmescc.a ''${LIBDIR}/x86-mes
cp ${libmescc}/lib/libmescc.s ''${LIBDIR}/x86-mes
# libc.a
cp ${libc}/lib/libc.a ''${LIBDIR}/x86-mes
cp ${libc}/lib/libc.s ''${LIBDIR}/x86-mes
# libc+tcc.a
cp ${libc_tcc}/lib/libc+tcc.a ''${LIBDIR}/x86-mes
cp ${libc_tcc}/lib/libc+tcc.s ''${LIBDIR}/x86-mes
'';
};
};
};
}

File diff suppressed because it is too large Load diff

View file

@ -1,139 +0,0 @@
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.musl.boot;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in
{
options.aux.foundation.stages.stage1.musl.boot = {
package = lib.options.create {
type = lib.types.derivation;
description = "The package to use for musl-boot.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
aux.foundation.stages.stage1.musl.boot = {
version = "1.1.24";
src = builtins.fetchurl {
url = "https://musl.libc.org/releases/musl-${cfg.version}.tar.gz";
sha256 = "E3DJqBKyzyp9koAlEMygBYzDfmanvt1wBR8KNAFQIqM=";
};
package =
let
# Thanks to the live-bootstrap project!
# See https://github.com/fosslinux/live-bootstrap/blob/d98f97e21413efc32c770d0356f1feda66025686/sysa/musl-1.1.24/musl-1.1.24.sh
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/d98f97e21413efc32c770d0356f1feda66025686/sysa/musl-1.1.24";
patches = [
(builtins.fetchurl {
url = "${liveBootstrap}/patches/avoid_set_thread_area.patch";
sha256 = "TsbBZXk4/KMZG9EKi7cF+sullVXrxlizLNH0UHGXsPs=";
})
(builtins.fetchurl {
url = "${liveBootstrap}/patches/avoid_sys_clone.patch";
sha256 = "/ZmH64J57MmbxdfQ4RNjamAiBdkImMTlHsHdgV4gMj4=";
})
(builtins.fetchurl {
url = "${liveBootstrap}/patches/fenv.patch";
sha256 = "vMVGjoN4deAJW5gsSqA207SJqAbvhrnOsGK49DdEiTI=";
})
(builtins.fetchurl {
url = "${liveBootstrap}/patches/makefile.patch";
sha256 = "03iYBAUnsrEdLIIhhhq5mM6BGnPn2EfUmIHu51opxbw=";
})
(builtins.fetchurl {
url = "${liveBootstrap}/patches/musl_weak_symbols.patch";
sha256 = "/d9a2eUkpe9uyi1ye6T4CiYc9MR3FZ9na0Gb90+g4v0=";
})
(builtins.fetchurl {
url = "${liveBootstrap}/patches/set_thread_area.patch";
sha256 = "RIZYqbbRSx4X/0iFUhriwwBRmoXVR295GNBUjf2UrM0=";
})
(builtins.fetchurl {
url = "${liveBootstrap}/patches/sigsetjmp.patch";
sha256 = "wd2Aev1zPJXy3q933aiup5p1IMKzVJBquAyl3gbK4PU=";
})
# FIXME: this patch causes the build to fail
# (builtins.fetchurl {
# url = "${liveBootstrap}/patches/stdio_flush_on_exit.patch";
# sha256 = "/z5ze3h3QTysay8nRvyvwPv3pmTcKptdkBIaMCoeLDg=";
# })
# HACK: always flush stdio immediately
./patches/always-flush.patch
(builtins.fetchurl {
url = "${liveBootstrap}/patches/va_list.patch";
sha256 = "UmcMIl+YCi3wIeVvjbsCyqFlkyYsM4ECNwTfXP+s7vg=";
})
];
in
builders.bash.boot.build {
name = "musl-boot-${cfg.version}";
meta = stage1.musl.meta;
deps.build.host = [
stage1.tinycc.mes.compiler.package
stage1.gnumake.boot.package
stage1.gnused.boot.package
stage1.gnugrep.package
stage1.gnupatch.package
stage1.gnutar.boot.package
stage1.gzip.package
];
script = ''
# Unpack
tar xzf ${cfg.src}
cd musl-${cfg.version}
# Patch
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
# tcc does not support complex types
rm -rf src/complex
# Configure fails without this
mkdir -p /dev
# https://github.com/ZilchOS/bootstrap-from-tcc/blob/2e0c68c36b3437386f786d619bc9a16177f2e149/using-nix/2a3-intermediate-musl.nix
sed -i 's|/bin/sh|${stage1.bash.boot.package}/bin/bash|' \
tools/*.sh
chmod 755 tools/*.sh
# patch popen/system to search in PATH instead of hardcoding /bin/sh
sed -i 's|posix_spawn(&pid, "/bin/sh",|posix_spawnp(\&pid, "sh",|' \
src/stdio/popen.c src/process/system.c
sed -i 's|execl("/bin/sh", "sh", "-c",|execlp("sh", "-c",|'\
src/misc/wordexp.c
# Configure
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
--disable-shared \
CC=tcc
# Build
make AR="tcc -ar" RANLIB=true CFLAGS="-DSYSCALL_NO_TLS"
# Install
make install
cp ${stage1.tinycc.mes.libs.package}/lib/libtcc1.a $out/lib
'';
};
};
};
}

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