make: Hoist kernel declaration to top.
[rhbz1184405.git] / Makefile
1 kver    = 3.19.0-0.rc4.57.sa2.aarch64
2 use_efi = 1
3 kernel  = /boot/vmlinuz-$(kver)
4 qemu    = /usr/libexec/qemu-kvm
5 modules = virtio.ko virtio_ring.ko virtio_mmio.ko virtio_scsi.ko
6 disks   = sda.img sdb.img sdc.img sdd.img sde.img sdf.img
7
8 all:    initrd $(disks) AAVMF_VARS.fd
9
10 ifeq ($(use_efi),1)
11 AAVMF_VARS.fd: /usr/share/AAVMF/AAVMF_VARS.fd
12         cp $< $@
13 efi_params = \
14         -drive if=pflash,format=raw,file=/usr/share/AAVMF/AAVMF_CODE.fd,readonly \
15         -drive if=pflash,format=raw,file=AAVMF_VARS.fd
16 else
17 AAVMF_VARS.fd:
18         touch $@
19 endif
20
21 initrd: dev init $(modules)
22         ls -1d $^ | cpio -o -H newc | gzip -9 > $@
23
24 dev:
25         rm -rf $@
26         mkdir $@
27
28 %.ko:
29         find /lib/modules/$(kver) -name $@ -exec cp {} . \;
30
31 init:   init.c
32         gcc -Wall -Werror -static $< -o $@
33
34 %.img:
35         rm -f $@
36         truncate -s $$(( RANDOM % 3 + 1 ))G $@
37         echo '2048,,L' | sfdisk --force $@
38
39 clean:
40         rm -f $(disks) $(modules) init initrd AAVMF_VARS.fd
41
42 run:    initrd $(disks) AAVMF_VARS.fd
43         $(qemu) \
44           -nodefconfig -nodefaults -display none \
45           -machine virt,accel=kvm \
46           -no-reboot \
47           -cpu host \
48           -m 1024 \
49           $(efi_params) \
50           -kernel $(kernel) -initrd initrd \
51           -append 'panic=1 earlyprintk=pl011,0x9000000 ignore_loglevel console=ttyAMA0 no_timer_check printk.time=1' \
52           -serial stdio \
53           -device virtio-scsi-device,id=scsi \
54           -drive file=sda.img,cache=writeback,format=raw,if=none,id=sda \
55           -device scsi-hd,drive=sda \
56           -drive file=sdb.img,cache=writeback,format=raw,if=none,id=sdb \
57           -device scsi-hd,drive=sdb \
58           -drive file=sdc.img,cache=writeback,format=raw,if=none,id=sdc \
59           -device scsi-hd,drive=sdc \
60           -drive file=sdd.img,cache=writeback,format=raw,if=none,id=sdd \
61           -device scsi-hd,drive=sdd \
62           -drive file=sde.img,cache=writeback,format=raw,if=none,id=sde \
63           -device scsi-hd,drive=sde \
64           -drive file=sdf.img,cache=writeback,format=raw,if=none,id=sdf \
65           -device scsi-hd,drive=sdf