Source
FROM scratch AS sources
ARG STAGE0_POSIX_X86_SOURCE
ARG M2_MESOPLANET_SOURCE
ARG M2_PLANET_SOURCE
ARG M2LIBC_SOURCE
ARG MESCC_TOOLS_SOURCE
ARG MESCC_TOOLS_EXTRA_SOURCE
ADD fetch/${STAGE0_POSIX_X86_SOURCE} .
ADD fetch/${M2_MESOPLANET_SOURCE} .
ADD fetch/${M2_PLANET_SOURCE} .
ADD fetch/${M2LIBC_SOURCE} .
ADD fetch/${MESCC_TOOLS_SOURCE} .
ADD fetch/${MESCC_TOOLS_EXTRA_SOURCE} .
FROM scratch AS seeds
ARG STAGE0_POSIX_X86_VERSION
COPY --from=sources /stage0-posix-x86-${STAGE0_POSIX_X86_VERSION} /x86
ADD hex0-seed .
WORKDIR /build
RUN ["/hex0-seed", "/x86/hex0_x86.hex0", "hex0"]
RUN ["./hex0", "/x86/kaem-minimal.hex0", "kaem-minimal"]
FROM scratch AS build
ARG STAGE0_POSIX_X86_VERSION
ARG M2_MESOPLANET_VERSION
ARG M2_PLANET_VERSION
ARG M2LIBC_VERSION
ARG MESCC_TOOLS_VERSION
ARG MESCC_TOOLS_EXTRA_VERSION
COPY --from=seeds /build/ /build/
COPY --from=sources /stage0-posix-x86-${STAGE0_POSIX_X86_VERSION} /x86
COPY --from=sources /M2libc-${M2LIBC_VERSION} /M2libc
COPY --from=sources /M2-Planet-${M2_PLANET_VERSION} /M2-Planet
COPY --from=sources /M2-Mesoplanet-${M2_MESOPLANET_VERSION} /M2-Mesoplanet
COPY --from=sources /mescc-tools-${MESCC_TOOLS_VERSION} /mescc-tools
COPY --from=sources /mescc-tools-extra-${MESCC_TOOLS_EXTRA_VERSION} /mescc-tools-extra
WORKDIR build
ENV M2LIBC_PATH=/M2libc
ENV TMPDIR=/build
ENV PATH=/build
COPY <<-EOF kaem.x86
./hex0 /x86/hex1_x86.hex0 hex1
./hex1 /x86/hex2_x86.hex1 hex2-0
./hex2-0 /x86/catm_x86.hex2 catm
./catm M0.hex2 /x86/ELF-i386.hex2 /x86/M0_x86.hex2
./hex2-0 M0.hex2 M0
./M0 /x86/cc_x86.M1 cc_x86-0.hex2
./catm cc_x86-1.hex2 /x86/ELF-i386.hex2 cc_x86-0.hex2
./hex2-0 cc_x86-1.hex2 cc_x86
./catm M2-0.c /M2libc/x86/linux/bootstrap.c /M2-Planet/cc.h /M2libc/bootstrappable.c /M2-Planet/cc_globals.c /M2-Planet/cc_reader.c /M2-Planet/cc_strings.c /M2-Planet/cc_types.c /M2-Planet/cc_core.c /M2-Planet/cc_macro.c /M2-Planet/cc.c
./cc_x86 M2-0.c M2-0.M1
./catm M2-0-0.M1 /x86/x86_defs.M1 /x86/libc-core.M1 M2-0.M1
./M0 M2-0-0.M1 M2-0.hex2
./catm M2-0-0.hex2 /x86/ELF-i386.hex2 M2-0.hex2
./hex2-0 M2-0-0.hex2 M2
./M2 --architecture x86 -f /M2libc/x86/linux/bootstrap.c -f /M2libc/bootstrappable.c -f /mescc-tools/stringify.c -f /mescc-tools/blood-elf.c --bootstrap-mode -o blood-elf-0.M1
./catm blood-elf-0-0.M1 /M2libc/x86/x86_defs.M1 /M2libc/x86/libc-core.M1 blood-elf-0.M1
./M0 blood-elf-0-0.M1 blood-elf-0.hex2
./catm blood-elf-0-0.hex2 /M2libc/x86/ELF-x86.hex2 blood-elf-0.hex2
./hex2-0 blood-elf-0-0.hex2 blood-elf-0
./M2 --architecture x86 -f /M2libc/x86/linux/bootstrap.c -f /M2libc/bootstrappable.c -f /mescc-tools/stringify.c -f /mescc-tools/M1-macro.c --bootstrap-mode --debug -o M1-macro-0.M1
./blood-elf-0 -f M1-macro-0.M1 --little-endian -o M1-macro-0-footer.M1
./catm M1-macro-0-0.M1 /M2libc/x86/x86_defs.M1 /M2libc/x86/libc-core.M1 M1-macro-0.M1 M1-macro-0-footer.M1
./M0 M1-macro-0-0.M1 M1-macro-0.hex2
./catm M1-macro-0-0.hex2 /M2libc/x86/ELF-x86-debug.hex2 M1-macro-0.hex2
./hex2-0 M1-macro-0-0.hex2 M1-0
./M2 --architecture x86 -f /M2libc/sys/types.h -f /M2libc/stddef.h -f /M2libc/sys/utsname.h -f /M2libc/x86/linux/unistd.c -f /M2libc/x86/linux/fcntl.c -f /M2libc/fcntl.c -f /M2libc/x86/linux/sys/stat.c -f /M2libc/stdlib.c -f /M2libc/stdio.h -f /M2libc/stdio.c -f /M2libc/bootstrappable.c -f /mescc-tools/hex2.h -f /mescc-tools/hex2_linker.c -f /mescc-tools/hex2_word.c -f /mescc-tools/hex2.c --debug -o hex2_linker-0.M1
./blood-elf-0 -f hex2_linker-0.M1 --little-endian -o hex2_linker-0-footer.M1
./M1-0 --architecture x86 --little-endian -f /M2libc/x86/x86_defs.M1 -f /M2libc/x86/libc-full.M1 -f hex2_linker-0.M1 -f hex2_linker-0-footer.M1 -o hex2_linker-0.hex2
./catm hex2_linker-0-0.hex2 /M2libc/x86/ELF-x86-debug.hex2 hex2_linker-0.hex2
./hex2-0 hex2_linker-0-0.hex2 hex2-1
./M2 --architecture x86 -f /M2libc/sys/types.h -f /M2libc/stddef.h -f /M2libc/x86/linux/fcntl.c -f /M2libc/fcntl.c -f /M2libc/sys/utsname.h -f /M2libc/x86/linux/unistd.c -f /M2libc/string.c -f /M2libc/stdlib.c -f /M2libc/stdio.h -f /M2libc/stdio.c -f /M2libc/bootstrappable.c -f /mescc-tools/stringify.c -f /mescc-tools/M1-macro.c --debug -o M1-macro-1.M1
./blood-elf-0 -f M1-macro-1.M1 --little-endian -o M1-macro-1-footer.M1
./M1-0 --architecture x86 --little-endian -f /M2libc/x86/x86_defs.M1 -f /M2libc/x86/libc-full.M1 -f M1-macro-1.M1 -f M1-macro-1-footer.M1 -o M1-macro-1.hex2
./hex2-1 --architecture x86 --little-endian --base-address 0x8048000 -f /M2libc/x86/ELF-x86-debug.hex2 -f M1-macro-1.hex2 -o M1
./M2 --architecture x86 -f /M2libc/sys/types.h -f /M2libc/stddef.h -f /M2libc/sys/utsname.h -f /M2libc/x86/linux/unistd.c -f /M2libc/x86/linux/fcntl.c -f /M2libc/fcntl.c -f /M2libc/x86/linux/sys/stat.c -f /M2libc/stdlib.c -f /M2libc/stdio.h -f /M2libc/stdio.c -f /M2libc/bootstrappable.c -f /mescc-tools/hex2.h -f /mescc-tools/hex2_linker.c -f /mescc-tools/hex2_word.c -f /mescc-tools/hex2.c --debug -o hex2_linker-2.M1
./blood-elf-0 -f hex2_linker-2.M1 --little-endian -o hex2_linker-2-footer.M1
./M1 --architecture x86 --little-endian -f /M2libc/x86/x86_defs.M1 -f /M2libc/x86/libc-full.M1 -f hex2_linker-2.M1 -f hex2_linker-2-footer.M1 -o hex2_linker-2.hex2
./hex2-1 --architecture x86 --little-endian --base-address 0x8048000 -f /M2libc/x86/ELF-x86-debug.hex2 -f hex2_linker-2.hex2 -o hex2
./M2 --architecture x86 -f /M2libc/sys/types.h -f /M2libc/stddef.h -f /M2libc/string.c -f /M2libc/sys/utsname.h -f /M2libc/x86/linux/unistd.c -f /M2libc/x86/linux/fcntl.c -f /M2libc/fcntl.c -f /M2libc/stdlib.c -f /M2libc/stdio.h -f /M2libc/stdio.c -f /M2libc/bootstrappable.c -f /mescc-tools/Kaem/kaem.h -f /mescc-tools/Kaem/variable.c -f /mescc-tools/Kaem/kaem_globals.c -f /mescc-tools/Kaem/kaem.c --debug -o kaem.M1
./blood-elf-0 -f kaem.M1 --little-endian -o kaem-footer.M1
./M1 --architecture x86 --little-endian -f /M2libc/x86/x86_defs.M1 -f /M2libc/x86/libc-full.M1 -f kaem.M1 -f kaem-footer.M1 -o kaem.hex2
./hex2 --architecture x86 --little-endian -f /M2libc/x86/ELF-x86-debug.hex2 -f kaem.hex2 --base-address 0x8048000 -o kaem
./M2 --architecture x86 -f /M2libc/sys/types.h -f /M2libc/stddef.h -f /M2libc/x86/linux/fcntl.c -f /M2libc/fcntl.c -f /M2libc/sys/utsname.h -f /M2libc/x86/linux/unistd.c -f /M2libc/x86/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 /M2-Mesoplanet/cc.h -f /M2-Mesoplanet/cc_globals.c -f /M2-Mesoplanet/cc_env.c -f /M2-Mesoplanet/cc_reader.c -f /M2-Mesoplanet/cc_spawn.c -f /M2-Mesoplanet/cc_core.c -f /M2-Mesoplanet/cc_macro.c -f /M2-Mesoplanet/cc.c --debug -o M2-Mesoplanet-1.M1
./blood-elf-0 --little-endian -f M2-Mesoplanet-1.M1 -o M2-Mesoplanet-1-footer.M1
./M1 --architecture x86 --little-endian -f /M2libc/x86/x86_defs.M1 -f /M2libc/x86/libc-full.M1 -f M2-Mesoplanet-1.M1 -f M2-Mesoplanet-1-footer.M1 -o M2-Mesoplanet-1.hex2
./hex2 --architecture x86 --little-endian --base-address 0x08048000 -f /M2libc/x86/ELF-x86-debug.hex2 -f M2-Mesoplanet-1.hex2 -o M2-Mesoplanet
./M2 --architecture x86 -f /M2libc/sys/types.h -f /M2libc/stddef.h -f /M2libc/x86/linux/fcntl.c -f /M2libc/fcntl.c -f /M2libc/sys/utsname.h -f /M2libc/x86/linux/unistd.c -f /M2libc/stdlib.c -f /M2libc/stdio.h -f /M2libc/stdio.c -f /M2libc/bootstrappable.c -f /mescc-tools/stringify.c -f /mescc-tools/blood-elf.c --debug -o blood-elf-1.M1
./blood-elf-0 --little-endian -f blood-elf-1.M1 -o blood-elf-1-footer.M1
./M1 --architecture x86 --little-endian -f /M2libc/x86/x86_defs.M1 -f /M2libc/x86/libc-full.M1 -f blood-elf-1.M1 -f blood-elf-1-footer.M1 -o blood-elf-1.hex2
./hex2 --architecture x86 --little-endian --base-address 0x08048000 -f /M2libc/x86/ELF-x86-debug.hex2 -f blood-elf-1.hex2 -o blood-elf
./M2 --architecture x86 -f /M2libc/sys/types.h -f /M2libc/stddef.h -f /M2libc/sys/utsname.h -f /M2libc/x86/linux/unistd.c -f /M2libc/x86/linux/fcntl.c -f /M2libc/fcntl.c -f /M2libc/stdlib.c -f /M2libc/stdio.h -f /M2libc/stdio.c -f /M2libc/bootstrappable.c -f /mescc-tools/get_machine.c --debug -o get_machine.M1
./blood-elf --little-endian -f get_machine.M1 -o get_machine-footer.M1
./M1 --architecture x86 --little-endian -f /M2libc/x86/x86_defs.M1 -f /M2libc/x86/libc-full.M1 -f get_machine.M1 -f get_machine-footer.M1 -o get_machine.hex2
./hex2 --architecture x86 --little-endian --base-address 0x08048000 -f /M2libc/x86/ELF-x86-debug.hex2 -f get_machine.hex2 -o get_machine
./M2 --architecture x86 -f /M2libc/sys/types.h -f /M2libc/stddef.h -f /M2libc/sys/utsname.h -f /M2libc/x86/linux/unistd.c -f /M2libc/x86/linux/fcntl.c -f /M2libc/fcntl.c -f /M2libc/stdlib.c -f /M2libc/stdio.h -f /M2libc/stdio.c -f /M2libc/bootstrappable.c -f /M2-Planet/cc.h -f /M2-Planet/cc_globals.c -f /M2-Planet/cc_reader.c -f /M2-Planet/cc_strings.c -f /M2-Planet/cc_types.c -f /M2-Planet/cc_core.c -f /M2-Planet/cc_macro.c -f /M2-Planet/cc.c --debug -o M2-1.M1
./blood-elf --little-endian -f M2-1.M1 -o M2-1-footer.M1
./M1 --architecture x86 --little-endian -f /M2libc/x86/x86_defs.M1 -f /M2libc/x86/libc-full.M1 -f M2-1.M1 -f M2-1-footer.M1 -o M2-1.hex2
./hex2 --architecture x86 --little-endian --base-address 0x08048000 -f /M2libc/x86/ELF-x86-debug.hex2 -f M2-1.hex2 -o M2-Planet
./M2-Mesoplanet --architecture x86 -f /mescc-tools-extra/sha256sum.c -o sha256sum
./M2-Mesoplanet --architecture x86 -f /mescc-tools-extra/match.c -o match
./M2-Mesoplanet --architecture x86 -f /mescc-tools-extra/mkdir.c -o mkdir
./M2-Mesoplanet --architecture x86 -f /mescc-tools-extra/untar.c -o untar
./M2-Mesoplanet --architecture x86 -f /mescc-tools-extra/ungz.c -o ungz
./M2-Mesoplanet --architecture x86 -f /mescc-tools-extra/unbz2.c -o unbz2
./M2-Mesoplanet --architecture x86 -f /mescc-tools-extra/unxz.c -o unxz
./M2-Mesoplanet --architecture x86 -f /mescc-tools-extra/catm.c -o catm
./M2-Mesoplanet --architecture x86 -f /mescc-tools-extra/cp.c -o cp
./M2-Mesoplanet --architecture x86 -f /mescc-tools-extra/chmod.c -o chmod
./M2-Mesoplanet --architecture x86 -f /mescc-tools-extra/rm.c -o rm
./M2-Mesoplanet --architecture x86 -f /mescc-tools-extra/replace.c -o replace
./M2-Mesoplanet --architecture x86 -f /mescc-tools-extra/wrap.c -o wrap
EOF
RUN ["/build/kaem-minimal"]
FROM scratch AS package
COPY --from=build /build/hex2 /bin/
COPY --from=build /build/kaem /bin/
COPY --from=build /build/M1 /bin/
COPY --from=build /build/M2-Mesoplanet /bin/
COPY --from=build /build/M2-Planet /bin/
COPY --from=build /build/blood-elf /bin/
COPY --from=build /build/get_machine /bin/
COPY --from=build /build/sha256sum /bin/
COPY --from=build /build/match /bin/
COPY --from=build /build/mkdir /bin/
COPY --from=build /build/untar /bin/
COPY --from=build /build/ungz /bin/
COPY --from=build /build/unbz2 /bin/
COPY --from=build /build/unxz /bin/
COPY --from=build /build/catm /bin/
COPY --from=build /build/cp /bin/
COPY --from=build /build/chmod /bin/
COPY --from=build /build/rm /bin/
COPY --from=build /build/replace /bin/
COPY --from=build /build/wrap /bin/