summaryrefslogtreecommitdiff
path: root/partitions/Makefile
blob: 4a003335131c71ee232e8f00393497597b8e521c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

.PHONY: all clean

all: whole.img

whole.img:
	partvi

key.img:
	partvi key

persist.img:
	[ ! -e $@ ]
	fallocate -l 20G $@
	truncate -s 0 $@
	truncate -s 20G $@

persist := $(shell [ -e persist.img ] && printf %s '-drive file=persist.img,media=disk,driver=raw' || true)

.PHONY: usb emu key emu-key keymu
usb: whole.img
	usb=$$(usb) && sudo dd status=progress if="$<" of="$$usb"

# QEMU_DISPLAY_OPTIONS = -nographic
QEMU_DISPLAY_OPTIONS = -display gtk

define emu
	NO_AT_BRIDGE=1 qemu-system-x86_64 ${QEMU_DISPLAY_OPTIONS} -m 800 -enable-kvm -boot c \
	  -drive file=$(1),media=disk,driver=raw \
	  $(persist)
endef

emu: whole.img
	$(call emu,$<)

emu-key keymu: key.img
	$(call emu,$<)

key: key.img
	usb=$$(usb) && \
		sudo dd status=progress bs=1048576 if="$<" of="$$usb" && \
		sudo $(call emu,"$$usb")

clean:
	rm -rf _build whole.img key.img

.PHONY: total-destroy
total-destroy: clean
	rm -f persist.img
	$(MAKE) persist.img