TARGET = pc.img
TARGETS = $(TARGET)
include ../common.mk

QEMU_FLAGS = -accel kvm -accel tcg -machine q35 \
	-chardev stdio,id=char0 \
	-serial chardev:char0 \
	-rtc base=utc
QEMU_DRVOPTS = format=raw,index=0,if=ide

$(TARGET): $(DUSK) init.fs
	dd if=/dev/zero of=$@ bs=512 count=16384 # 8M
	$(DUSK) -c '"$@" mountImage f<< xcomp/i386/pc/mkfat.fs'
	$(DUSK) -c 'f<< xcomp/i386/pc/deploy.fs "$@" mountImage install'
	$(DUSK) -c '"$@"' -f $(DUSKDIR)/syncfs.fs
	$(DUSK) -c '"init.fs" "$@" mountImage' -f $(DUSKDIR)/fatcp.fs < init.fs

.PHONY: emul
emul: $(TARGET)
	qemu-system-i386 $(QEMU_FLAGS) -drive file=$(TARGET),$(QEMU_DRVOPTS)
