]> rtime.felk.cvut.cz Git - hercules2020/jailhouse-build.git/blob - build/Makefile
Simple memguard test
[hercules2020/jailhouse-build.git] / build / Makefile
1 all: buildroot/images/rootfs.cpio.uboot kernel-4.4/vmlinux
2
3 NPROC:=$(shell nproc)
4
5 # TX2 U-Boot does not support FIT images
6 image.fit: buildroot/images/rootfs.cpio.uboot kernel-4.4/vmlinux
7         mkimage -f auto -d kernel-4.4/arch/arm64/boot/Image -i buildroot/images/rootfs.cpio.uboot -b kernel-4.4/arch/arm64/boot/dts/tegra186-quill-p3310-1000-c03-00-base.dtb image.fit
8
9 buildroot/images/rootfs.cpio.uboot: ./buildroot/.config
10 buildroot/images/rootfs.cpio.uboot: rootfs-overlay/lib/firmware/jailhouse.bin
11 buildroot/images/rootfs.cpio.uboot: modules_install
12 buildroot/images/rootfs.cpio.uboot: $(shell find rootfs-overlay)
13 buildroot/images/rootfs.cpio.uboot: rootfs-overlay/bin/prem-test
14         $(MAKE) -j1 -C buildroot ROOTFS_CPIO_COMPRESS_CMD="gzip --fast -c"
15
16 rootfs-overlay/bin/prem-test: ../test/prem-test
17         install -D $< $@
18
19 rootfs-overlay/lib/firmware/jailhouse.bin: ../jailhouse/hypervisor/jailhouse.bin
20 rootfs-overlay/lib/firmware/jailhouse.bin: $(wildcard ../jailhouse/configs/arm64/*.cell)
21         $(MAKE) jailhouse-install
22
23 jailhouse: ../jailhouse/hypervisor/jailhouse.bin
24
25 DESTDIR=$(CURDIR)/rootfs-overlay
26
27 jailhouse-install: FORCE
28         $(MAKE) -C ../jailhouse -j$(NPROC) install KDIR=$(CURDIR)/kernel-4.4 ARCH=arm64 DESTDIR=$(abspath $(DESTDIR)) prefix=/usr
29         mkdir -p $(DESTDIR)/jailhouse/configs/ $(DESTDIR)/jailhouse/demos/
30 #       cp ../jailhouse/inmates/demos/arm64/my-demo.bin rootfs-overlay/jailhouse/demos/
31         cp ../jailhouse/configs/arm64/jetson-tx2.cell $(DESTDIR)/jailhouse/configs/
32         cp ../jailhouse/configs/arm64/jetson-tx2-demo.cell $(DESTDIR)/jailhouse/demos/
33
34 # Add something like this to ~/.ssh/config for
35 # jailhouse-install-remote to work out of the box:
36 #
37 #    Host tx2
38 #      Hostname 192.168.1.54
39 INSTALL_HOST ?= root@tx2
40
41 jailhouse-install-remote: JAILHOUSE_DESTDIR=jailhouse-install
42 jailhouse-install-remote: jailhouse-install
43         rsync -rlptD jailhouse-install/ $(INSTALL_HOST):/
44         rsync -rlptD rootfs-overlay/lib/modules/ $(INSTALL_HOST):/lib/modules
45
46 ../jailhouse/hypervisor/jailhouse.bin: ../jailhouse/include/jailhouse/config.h
47 ../jailhouse/hypervisor/jailhouse.bin: kernel-4.4/vmlinux
48 ../jailhouse/hypervisor/jailhouse.bin: $(addprefix ../jailhouse/,$(shell cd ../jailhouse && git ls-files))
49         $(MAKE) -C ../jailhouse -j$(NPROC) KDIR=$(CURDIR)/kernel-4.4 ARCH=arm64 prefix=/usr
50
51 ../jailhouse/include/jailhouse/config.h: Makefile
52         rm -f $@.tmp
53         echo '#define CONFIG_TRACE_ERROR             1' >> $@.tmp
54         echo '#define CONFIG_ARM_GIC_V2              1' >> $@.tmp
55         echo '#define CONFIG_MACH_JETSON_TX2         1' >> $@.tmp
56         mv --update $@.tmp $@
57
58 kernel-4.4/vmlinux:
59         $(MAKE) -C $(@D) -j$(NPROC)
60
61 linux_install: kernel-4.4/vmlinux
62         install -m644 -D kernel-4.4/arch/arm64/boot/Image $(DESTDIR)/boot/Image-prem
63
64 modules_install: kernel-4.4/vmlinux
65         $(MAKE) -C kernel-4.4 -j$(NPROC)  modules_install INSTALL_MOD_PATH=$(DESTDIR)
66
67 .PHONY: FORCE
68
69 ../test/prem-test: FORCE
70         $(MAKE) -C ../test
71
72 clean:
73         rm -rf buildroot/images/rootfs.cpio.uboot kernel-4.4/vmlinux buildroot/target `find buildroot/ -name .stamp_target_installed` jailhouse-install
74
75 deploy: ../test/prem-test
76 #deploy: ../jailhouse/hypervisor/jailhouse.bin
77         scp ../test/prem-test tx2:/bin
78 #       scp ../jailhouse/hypervisor/jailhouse.bin tx2:/lib/firmware
79         ssh tx2 'sh /etc/init.d/S20jailhouse.sh stop && sh /etc/init.d/S20jailhouse.sh start'
80
81 deb: DESTDIR=$(CURDIR)/_install.deb
82 deb: jailhouse-install linux_install modules_install DEBIAN_DIR
83         $(file >$(DESTDIR)/DEBIAN/control,$(deb_control))
84         $(file >$(DESTDIR)/DEBIAN/postinst,$(deb_postinst))
85         $(file >$(DESTDIR)/DEBIAN/prerm,$(deb_prerm))
86         chmod +x $(DESTDIR)/DEBIAN/postinst $(DESTDIR)/DEBIAN/prerm
87         rm -f _install.deb/lib/modules/*/source _install.deb/lib/modules/*/build
88         install -D ./rootfs-overlay/etc/init.d/S20jailhouse.sh $(DESTDIR)/etc/init.d/jailhouse
89         install -m644 -D ./rootfs-overlay/etc/systemd/system/jailhouse.service $(DESTDIR)/lib/systemd/system/jailhouse.service
90         #install -d $(DESTDIR)/lib/systemd/system/multi-user.target.wants/
91         #ln -sf ../jailhouse.service $(DESTDIR)/lib/systemd/system/multi-user.target.wants/jailhouse.service
92 # Note: --root-owner-group requires dpkg version 1.19.0+
93         dpkg-deb --root-owner-group --build $(DESTDIR) .
94
95 DEBIAN_DIR:
96         install -d $(DESTDIR)/DEBIAN
97
98
99 define deb_control
100 Package: jailhouse
101 Essential: no
102 Priority: optional
103 Section: admin
104 Maintainer: Michal Sojka <michal.sojka@cvut.cz>
105 Architecture: arm64
106 Version: $(shell git describe --always --dirty)
107 Description: Jailhouse hypervisor and the Linux kernel for the HERCULES project.
108 endef
109
110 define deb_postinst
111 #!/bin/sh
112 set -e
113 if ! grep -q Image-prem /boot/extlinux/extlinux.conf; then
114 cat >>/boot/extlinux/extlinux.conf <<'EOF'
115 LABEL prem
116       MENU LABEL prem kernel and jailhouse
117       LINUX /boot/Image-prem
118       APPEND $${cbootargs} root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 mem=7808M vmalloc=512M jailhouse
119 EOF
120 fi
121 endef
122
123 define deb_prerm
124 #!/bin/sh
125 set -e
126 if grep -q Image-prem /boot/extlinux/extlinux.conf; then
127         . # TODO
128 fi
129 endef