|
@@ -1,8 +1,9 @@
|
|
|
let
|
|
|
system = "x86_64-linux";
|
|
|
|
|
|
- ARCH_DIR = "AMD64";
|
|
|
- ARCH = "amd64";
|
|
|
+ ARCH_DIR = "x86";
|
|
|
+ ARCH = "x86";
|
|
|
+ ELF_ARCH = "i386";
|
|
|
|
|
|
stage0-src = builtins.fetchGit {
|
|
|
url = "https://github.com/oriansj/stage0-posix.git";
|
|
@@ -23,29 +24,29 @@ let
|
|
|
|
|
|
hex0 = run "hex0" [
|
|
|
"${stage0-src}/bootstrap-seeds/POSIX/${ARCH_DIR}/hex0-seed"
|
|
|
- "${arch-src}/hex0_AMD64.hex0"
|
|
|
+ "${arch-src}/hex0_${ARCH_DIR}.hex0"
|
|
|
out
|
|
|
];
|
|
|
|
|
|
hex1 = run "hex1" [
|
|
|
hex0
|
|
|
- "${arch-src}/hex1_AMD64.hex0"
|
|
|
+ "${arch-src}/hex1_${ARCH_DIR}.hex0"
|
|
|
out
|
|
|
];
|
|
|
|
|
|
catm = run "catm" [
|
|
|
hex0
|
|
|
- "${arch-src}/catm_AMD64.hex0"
|
|
|
+ "${arch-src}/catm_${ARCH_DIR}.hex0"
|
|
|
out
|
|
|
];
|
|
|
|
|
|
hex2-0 = run "hex2-0" [
|
|
|
hex1
|
|
|
- "${arch-src}/hex2_AMD64.hex1"
|
|
|
+ "${arch-src}/hex2_${ARCH_DIR}.hex1"
|
|
|
out
|
|
|
];
|
|
|
|
|
|
- arch-elf-hex2 = "${arch-src}/ELF-amd64.hex2";
|
|
|
+ arch-elf-hex2 = "${arch-src}/ELF-${ELF_ARCH}.hex2";
|
|
|
|
|
|
cat = name: args: run name ([
|
|
|
catm
|
|
@@ -58,7 +59,7 @@ let
|
|
|
out
|
|
|
];
|
|
|
|
|
|
- M0 = buildHex2 "M0" arch-elf-hex2 "${arch-src}/M0_AMD64.hex2";
|
|
|
+ M0 = buildHex2 "M0" arch-elf-hex2 "${arch-src}/M0_${ARCH_DIR}.hex2";
|
|
|
|
|
|
buildM0 = name: elf: src: buildHex2 name elf (run "${name}-m0" [
|
|
|
M0
|
|
@@ -66,12 +67,12 @@ let
|
|
|
out
|
|
|
]);
|
|
|
|
|
|
- cc_amd64 = buildM0 "cc_amd64" arch-elf-hex2 "${arch-src}/cc_amd64.M1";
|
|
|
+ cc = buildM0 "cc_${ARCH}" arch-elf-hex2 "${arch-src}/cc_${ARCH}.M1";
|
|
|
|
|
|
M2 =
|
|
|
let
|
|
|
M2-0-c = cat "M2-0.c" [
|
|
|
- "${stage0-src}/M2libc/amd64/linux/bootstrap.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/bootstrap.c"
|
|
|
"${stage0-src}/M2-Planet/cc.h"
|
|
|
"${stage0-src}/M2libc/bootstrappable.c"
|
|
|
"${stage0-src}/M2-Planet/cc_globals.c"
|
|
@@ -83,27 +84,27 @@ let
|
|
|
"${stage0-src}/M2-Planet/cc.c"
|
|
|
];
|
|
|
M2-0-M1 = run "M2-0.M1" [
|
|
|
- cc_amd64
|
|
|
+ cc
|
|
|
M2-0-c
|
|
|
out
|
|
|
];
|
|
|
M2-0-0-M1 = cat "M2-0-0.m1" [
|
|
|
- "${arch-src}/amd64_defs.M1"
|
|
|
+ "${arch-src}/${ARCH}_defs.M1"
|
|
|
"${arch-src}/libc-core.M1"
|
|
|
M2-0-M1
|
|
|
];
|
|
|
in
|
|
|
buildM0 "M2" arch-elf-hex2 M2-0-0-M1;
|
|
|
|
|
|
- libc-elf-hex2 = "${stage0-src}/M2libc/amd64/ELF-amd64.hex2";
|
|
|
- libc-elf-debug-hex2 = "${stage0-src}/M2libc/amd64/ELF-amd64-debug.hex2";
|
|
|
+ libc-elf-hex2 = "${stage0-src}/M2libc/${ARCH}/ELF-${ARCH}.hex2";
|
|
|
+ libc-elf-debug-hex2 = "${stage0-src}/M2libc/${ARCH}/ELF-${ARCH}-debug.hex2";
|
|
|
|
|
|
blood-elf-0 =
|
|
|
let
|
|
|
blood-elf-0-M1 = run "blood-elf-0.M1" [
|
|
|
M2
|
|
|
- "--architecture" "amd64"
|
|
|
- "-f" "${stage0-src}/M2libc/amd64/linux/bootstrap.c"
|
|
|
+ "--architecture" ARCH
|
|
|
+ "-f" "${stage0-src}/M2libc/${ARCH}/linux/bootstrap.c"
|
|
|
"-f" "${stage0-src}/M2libc/bootstrappable.c"
|
|
|
"-f" "${stage0-src}/mescc-tools/stringify.c"
|
|
|
"-f" "${stage0-src}/mescc-tools/blood-elf.c"
|
|
@@ -111,7 +112,7 @@ let
|
|
|
"-o" out
|
|
|
];
|
|
|
blood-elf-0-0-M1 = cat "blood-elf-0-0.M1" [
|
|
|
- "${arch-src}/amd64_defs.M1"
|
|
|
+ "${arch-src}/${ARCH}_defs.M1"
|
|
|
"${arch-src}/libc-core.M1"
|
|
|
blood-elf-0-M1
|
|
|
];
|
|
@@ -129,8 +130,8 @@ let
|
|
|
let
|
|
|
M1-macro-0-M1 = run "M1-macro-0.M1" [
|
|
|
M2
|
|
|
- "--architecture" "amd64"
|
|
|
- "-f" "${stage0-src}/M2libc/amd64/linux/bootstrap.c"
|
|
|
+ "--architecture" ARCH
|
|
|
+ "-f" "${stage0-src}/M2libc/${ARCH}/linux/bootstrap.c"
|
|
|
"-f" "${stage0-src}/M2libc/bootstrappable.c"
|
|
|
"-f" "${stage0-src}/mescc-tools/stringify.c"
|
|
|
"-f" "${stage0-src}/mescc-tools/M1-macro.c"
|
|
@@ -140,7 +141,7 @@ let
|
|
|
];
|
|
|
M1-macro-0-footer-M1 = runBloodelf blood-elf-0 "M1-macro-0-footer.M1" M1-macro-0-M1;
|
|
|
M1-macro-0-0-M1 = cat "M1-macro-0-0.M1" [
|
|
|
- "${arch-src}/amd64_defs.M1"
|
|
|
+ "${arch-src}/${ARCH}_defs.M1"
|
|
|
"${arch-src}/libc-core.M1"
|
|
|
M1-macro-0-M1
|
|
|
M1-macro-0-footer-M1
|
|
@@ -152,12 +153,12 @@ let
|
|
|
let
|
|
|
hex2_linker-1-M1 = run "hex2_linker-1.M1" [
|
|
|
M2
|
|
|
- "--architecture" "amd64"
|
|
|
+ "--architecture" ARCH
|
|
|
"-f" "${stage0-src}/M2libc/sys/types.h"
|
|
|
"-f" "${stage0-src}/M2libc/stddef.h"
|
|
|
- "-f" "${stage0-src}/M2libc/amd64/linux/fcntl.c"
|
|
|
- "-f" "${stage0-src}/M2libc/amd64/linux/unistd.c"
|
|
|
- "-f" "${stage0-src}/M2libc/amd64/linux/sys/stat.c"
|
|
|
+ "-f" "${stage0-src}/M2libc/${ARCH}/linux/fcntl.c"
|
|
|
+ "-f" "${stage0-src}/M2libc/${ARCH}/linux/unistd.c"
|
|
|
+ "-f" "${stage0-src}/M2libc/${ARCH}/linux/sys/stat.c"
|
|
|
"-f" "${stage0-src}/M2libc/stdlib.c"
|
|
|
"-f" "${stage0-src}/M2libc/stdio.c"
|
|
|
"-f" "${stage0-src}/M2libc/bootstrappable.c"
|
|
@@ -171,10 +172,10 @@ let
|
|
|
hex2_linker-1-footer-M1 = runBloodelf blood-elf-0 "hex2_linker-1-footer.M1" hex2_linker-1-M1;
|
|
|
hex2_linker-1-hex2 = run "hex2_linker-1.hex2" [
|
|
|
M1-0
|
|
|
- "--architecture" "amd64"
|
|
|
+ "--architecture" ARCH
|
|
|
"--little-endian"
|
|
|
- "-f" "${stage0-src}/M2libc/amd64/amd64_defs.M1"
|
|
|
- "-f" "${stage0-src}/M2libc/amd64/libc-full.M1"
|
|
|
+ "-f" "${stage0-src}/M2libc/${ARCH}/${ARCH}_defs.M1"
|
|
|
+ "-f" "${stage0-src}/M2libc/${ARCH}/libc-full.M1"
|
|
|
"-f" hex2_linker-1-M1
|
|
|
"-f" hex2_linker-1-footer-M1
|
|
|
"-o" out
|
|
@@ -185,17 +186,17 @@ let
|
|
|
buildM1 = deps: name: srcs:
|
|
|
let
|
|
|
M1-src = run "${name}.M1" (
|
|
|
- [ M2 "--architecture" "amd64" ]
|
|
|
+ [ M2 "--architecture" ARCH ]
|
|
|
++ (builtins.concatMap (x: [ "-f" x ]) srcs)
|
|
|
++ [ "--debug" "-o" out ]
|
|
|
);
|
|
|
M1-footer-src = runBloodelf deps.blood-elf "${name}-footer.M1" M1-src;
|
|
|
hex2-src = run "${name}.hex2" [
|
|
|
deps.M1
|
|
|
- "--architecture" "amd64"
|
|
|
+ "--architecture" ARCH
|
|
|
"--little-endian"
|
|
|
- "-f" "${stage0-src}/M2libc/amd64/amd64_defs.M1"
|
|
|
- "-f" "${stage0-src}/M2libc/amd64/libc-full.M1"
|
|
|
+ "-f" "${stage0-src}/M2libc/${ARCH}/${ARCH}_defs.M1"
|
|
|
+ "-f" "${stage0-src}/M2libc/${ARCH}/libc-full.M1"
|
|
|
"-f" M1-src
|
|
|
"-f" M1-footer-src
|
|
|
"-o" out
|
|
@@ -203,7 +204,7 @@ let
|
|
|
in
|
|
|
run name [
|
|
|
deps.hex2
|
|
|
- "--architecture" "amd64"
|
|
|
+ "--architecture" ARCH
|
|
|
"--little-endian"
|
|
|
"--base-address" "0x00600000"
|
|
|
"-f" libc-elf-debug-hex2
|
|
@@ -218,8 +219,8 @@ let
|
|
|
} "M1" [
|
|
|
"${stage0-src}/M2libc/sys/types.h"
|
|
|
"${stage0-src}/M2libc/stddef.h"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/fcntl.c"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/unistd.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/fcntl.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/unistd.c"
|
|
|
"${stage0-src}/M2libc/string.c"
|
|
|
"${stage0-src}/M2libc/stdlib.c"
|
|
|
"${stage0-src}/M2libc/stdio.c"
|
|
@@ -235,9 +236,9 @@ let
|
|
|
} "hex2" [
|
|
|
"${stage0-src}/M2libc/sys/types.h"
|
|
|
"${stage0-src}/M2libc/stddef.h"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/fcntl.c"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/unistd.c"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/sys/stat.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/fcntl.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/unistd.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/sys/stat.c"
|
|
|
"${stage0-src}/M2libc/stdlib.c"
|
|
|
"${stage0-src}/M2libc/stdio.c"
|
|
|
"${stage0-src}/M2libc/bootstrappable.c"
|
|
@@ -256,8 +257,8 @@ let
|
|
|
"${stage0-src}/M2libc/sys/types.h"
|
|
|
"${stage0-src}/M2libc/stddef.h"
|
|
|
"${stage0-src}/M2libc/string.c"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/fcntl.c"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/unistd.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/fcntl.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/unistd.c"
|
|
|
"${stage0-src}/M2libc/stdlib.c"
|
|
|
"${stage0-src}/M2libc/stdio.c"
|
|
|
"${stage0-src}/M2libc/bootstrappable.c"
|
|
@@ -338,9 +339,9 @@ let
|
|
|
"${stage0-src}/M2libc/sys/types.h"
|
|
|
"${stage0-src}/M2libc/stddef.h"
|
|
|
"${stage0-src}/M2libc/string.c"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/fcntl.c"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/unistd.c"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/sys/stat.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/fcntl.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/unistd.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/sys/stat.c"
|
|
|
"${stage0-src}/M2libc/stdlib.c"
|
|
|
"${stage0-src}/M2libc/stdio.c"
|
|
|
"${stage0-src}/M2libc/bootstrappable.c"
|
|
@@ -351,9 +352,9 @@ let
|
|
|
"${stage0-src}/M2libc/sys/types.h"
|
|
|
"${stage0-src}/M2libc/stddef.h"
|
|
|
"${stage0-src}/M2libc/string.c"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/fcntl.c"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/unistd.c"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/sys/stat.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/fcntl.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/unistd.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/sys/stat.c"
|
|
|
"${stage0-src}/M2libc/stdlib.c"
|
|
|
"${stage0-src}/M2libc/stdio.c"
|
|
|
"${stage0-src}/M2libc/bootstrappable.c"
|
|
@@ -364,8 +365,8 @@ let
|
|
|
"${stage0-src}/M2libc/sys/types.h"
|
|
|
"${stage0-src}/M2libc/stddef.h"
|
|
|
"${stage0-src}/M2libc/string.c"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/fcntl.c"
|
|
|
- "${stage0-src}/M2libc/amd64/linux/unistd.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/fcntl.c"
|
|
|
+ "${stage0-src}/M2libc/${ARCH}/linux/unistd.c"
|
|
|
"${stage0-src}/M2libc/stdlib.c"
|
|
|
"${stage0-src}/M2libc/stdio.c"
|
|
|
"${stage0-src}/M2libc/bootstrappable.c"
|
|
@@ -453,7 +454,7 @@ in
|
|
|
catm
|
|
|
hex2-0
|
|
|
M0
|
|
|
- cc_amd64
|
|
|
+ cc
|
|
|
M2
|
|
|
blood-elf-0
|
|
|
M1-0
|