# Das OS build entry points. Everything except QEMU runs in the Void builder container.

.PHONY: help packages iso iso-server qemu qemu-bios qemu-disk qemu-server test clean

help:
	@echo "make packages   build srcpkgs/* into the local repository (out/hostdir/binpkgs)"
	@echo "make iso        build packages, then the live ISO (out/iso)"
	@echo "make iso-server build packages, then the server ISO (out/iso)"
	@echo "make qemu       boot the newest ISO in QEMU with UEFI"
	@echo "make qemu-bios  boot the newest ISO in QEMU with legacy BIOS"
	@echo "make qemu-disk  boot with a 20 GB virtual disk attached (for installer tests)"
	@echo "make qemu-server boot the newest server ISO on a serial console, with the disk"
	@echo "make test       run Go tests"
	@echo "make clean      remove build output (keeps download caches)"

packages:
	scripts/builder.sh /work/scripts/container/build-packages.sh

iso: packages
	scripts/builder.sh /work/scripts/container/build-iso.sh

iso-server: packages
	scripts/builder.sh /work/scripts/container/build-iso.sh server

qemu:
	scripts/run-qemu.sh

qemu-bios:
	scripts/run-qemu.sh --bios

qemu-disk:
	scripts/run-qemu.sh --disk

qemu-server:
	scripts/run-qemu.sh --serial --disk

test:
	cd srcpkgs/das-theme/files/xfwm4gen && go test ./...
	cd srcpkgs/das-tools/files/src && go test ./...

# Build output may be owned by root when a build was interrupted, so remove it from the container
clean:
	scripts/builder.sh rm -rf /work/out/hostdir/binpkgs /work/out/iso
	rm -rf out/qemu
