# Foundry OS -- the single entry point. `make help` lists the targets. # # Everything generated goes to out/ (git-ignored); `make clean` removes it. # Downloads (musl source etc.) go to cache/ (git-ignored, SHA256-checked). include config.mk OUT := $(CURDIR)/out IMAGE := $(OUT)/$(IMAGE_NAME) STAGING := $(OUT)/staging RUST_OUT := $(OUT)/rust-target/x86_64-unknown-none/release FIXTURES := $(OUT)/fixtures KSRC := $(OUT)/kernel-src KTARGET := $(OUT)/kernel-target KBOOT := $(OUT)/kernel/bootimage.bin KBOOT_HL := $(OUT)/kernel/bootimage-headless.bin .DEFAULT_GOAL := image .PHONY: help image rust fixtures staging kernel kernel-src run test compare musl clean distclean help: @echo "Foundry OS (userland for the Rustbelt kernel $(KERNEL_VERSION) @ $(KERNEL_REV))" @echo "" @echo " make / make image build out/$(IMAGE_NAME), the disk image (contract $(CONTRACT))" @echo " make rust cargo build the Rust programs in rust/" @echo " make fixtures build the kernel's ABI test programs from the pinned kernel" @echo " make staging assemble out/staging (rootfs/ + /bin)" @echo " make kernel build the pinned kernel into out/kernel-target" @echo " make run boot the image in a QEMU window" @echo " make test headless boot + the shell self-test + expected-line checks" @echo " make compare compare out/$(IMAGE_NAME) with the kernel's own disk.img" @echo " make musl fetch (cache/) + build musl $(MUSL_VERSION) into out/sysroot (not in the image yet)" @echo " make clean rm -rf out (distclean also removes cache/)" # ---- the pinned kernel ------------------------------------------------------- kernel-src: scripts/build-kernel.sh $(KERNEL_DIR) $(KERNEL_REV) $(OUT) --export-only kernel: scripts/build-kernel.sh $(KERNEL_DIR) $(KERNEL_REV) $(OUT) # ---- programs --------------------------------------------------------------- rust: cd rust && CARGO_TARGET_DIR=$(OUT)/rust-target cargo build --release fixtures: kernel-src scripts/build-fixtures.sh $(KSRC) $(FIXTURES) "$(FIXTURE_RUST)" "$(FIXTURE_C)" "$(FIXTURE_MUSL)" # ---- the image --------------------------------------------------------------- # Contract v1: rootfs/ minus etc/ (etc/ is for the contract-v2 ext2 root, # see docs/plan.md) goes to the top of the FAT32 volume, programs to /bin. staging: rust fixtures rm -rf $(STAGING) && mkdir -p $(STAGING)/bin cd rootfs && for e in $$(ls -A); do [ "$$e" = etc ] && [ "$(CONTRACT)" = v1 ] && continue; cp -r "$$e" $(STAGING)/; done for p in $(filter-out sh,$(RUST_PROGRAMS)); do cp $(RUST_OUT)/$$p $(STAGING)/bin/; done cp $(RUST_OUT)/rbsh $(STAGING)/bin/sh # contract v1: the kernel runs /mnt/disk0/bin/sh cp $(FIXTURES)/* $(STAGING)/bin/ image: staging scripts/mkimage.sh $(STAGING) $(IMAGE) $(IMAGE_MIB) $(IMAGE_LABEL) "$(BIN_ORDER)" # ---- booting ---------------------------------------------------------------- run: image kernel scripts/run-qemu.sh $(IMAGE) $(KBOOT) $(KTARGET) $(OUT) test: image kernel scripts/run-headless.sh $(IMAGE) $(KBOOT_HL) $(KTARGET) $(OUT) compare: image kernel scripts/compare-image.sh $(IMAGE) $(KTARGET)/disk.img $(OUT) # ---- toolchain (M2 groundwork; not used by the v1 image) --------------------- musl: toolchain/musl/fetch.sh cache toolchain/musl/build.sh cache $(OUT)/musl-build $(OUT)/sysroot clean: rm -rf out distclean: clean rm -rf cache