diff --git a/Makefile b/Makefile index b12d422e..a1b28674 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,11 @@ # cleaned, built and booted in QEMU: the # acceptance boot (.claude/CLAUDE.md) # make boards list boards and whether they can be built +# make ARCH= init install everything needed to build , +# boot it in QEMU and build the documents +# (Debian/Ubuntu, apt-get; sudo if not root). +# ARCH=amd64,aarch64,riscv64 sets up all +# three, for the full acceptance # make goes to v3/Makefile (make help-hosted) # ============================================================================== @@ -63,7 +68,7 @@ SUBMAKE := $(MAKE) --no-print-directory .DEFAULT_GOAL := all .PHONY: all boot_image boot_images write_stick docs clean clean-docs kernel boards help help-hosted sbom sbom-board \ - qemu qemu-esp qemu-gdb + qemu qemu-esp qemu-gdb init # ARCH given on the command line and no TARGET: `clean` is the kernel's for that # ISA, as `qemu` always is (make ARCH= clean qemu). @@ -232,6 +237,37 @@ write_stick: @[ -n "$(DEVICE)" ] || { echo "Usage: make write_stick DEVICE=/dev/sdX (lsblk lists the disks)"; exit 1; } @bash scripts/write_stick.sh build/boards/pc/lithos-pc.img $(DEVICE) +# init -- the packages this tree needs, for one ISA or several (ARCH=amd64,aarch64,riscv64). +# Common: the build, the disk images (scripts/mkdiskimage.sh; sfdisk is in fdisk), git-lfs for +# the logs and DoE CSVs (.gitattributes), and the documents: the book (docs/book/Makefile's own +# list) and the formal volumes and API reference (docs/formal/Makefile: pdflatex, doxygen, dot). +# Per ISA: its QEMU, its UEFI firmware (kernel/Makefile's paths) and its compiler (kernel/Makefile +# TOOLCHAIN; aarch64's loader is clang + lld-link). Not installed: syft, which make sbom and +# boot_image need -- it is not packaged; see the message make sbom prints. +INIT_COMMON := build-essential make git git-lfs python3 xorriso mtools gdisk dosfstools fdisk \ + pandoc latexmk texlive-xetex texlive-latex-base texlive-latex-recommended \ + texlive-latex-extra texlive-pictures texlive-fonts-recommended lmodern \ + fonts-dejavu fonts-dejavu-extra doxygen graphviz +INIT_amd64 := qemu-system-x86 ovmf +INIT_aarch64 := qemu-system-arm qemu-efi-aarch64 gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu clang lld +INIT_riscv64 := qemu-system-misc qemu-efi-riscv64 gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu +comma := , +INIT_ARCHES := $(subst $(comma),$(space),$(ARCH)) +INIT_BAD := $(filter-out amd64 aarch64 riscv64,$(INIT_ARCHES)) +SUDO := $(if $(filter 0,$(shell id -u)),,sudo) + +init: + @[ -n "$(INIT_ARCHES)" ] && [ -z "$(INIT_BAD)" ] || { \ + echo "Usage: make ARCH=[,...] init (e.g. ARCH=amd64,aarch64,riscv64)"; exit 1; } + @command -v apt-get >/dev/null 2>&1 || { \ + echo "init: needs apt-get (Debian/Ubuntu). The packages are listed in the Makefile, at init."; exit 1; } + $(SUDO) env DEBIAN_FRONTEND=noninteractive apt-get update -qq + $(SUDO) env DEBIAN_FRONTEND=noninteractive apt-get install -y -qq \ + $(INIT_COMMON) $(foreach a,$(INIT_ARCHES),$(INIT_$(a))) + git lfs install --local + @echo "" + @echo "Ready for $(INIT_ARCHES): make ARCH= clean qemu, make -C v4 test, make docs" + help: @sed -n '/^# TARGET is/,/^# =====/p' Makefile | sed '$$d; s/^# \{0,1\}//'