-
Notifications
You must be signed in to change notification settings - Fork 90
/
Makefile
110 lines (90 loc) · 4.02 KB
/
Makefile
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
HYPERVISOR ?= cloud_hypervisor
GUESTOS_IMAGE ?= centos
WASM_RUNTIME ?= wasmedge
KERNEL_VERSION ?= 6.2
ARCH ?= x86_64
# DEST_DIR is used when built with RPM format
DEST_DIR ?= /
INSTALL_DIR := /var/lib/kuasar
BIN_DIR := /usr/local/bin
SYSTEMD_SERVICE_DIR := /usr/lib/systemd/system
SYSTEMD_CONF_DIR := /etc/sysconfig
ENABLE_YOUKI ?= false
RUNC_FEATURES =
VMM_TASK_FEATURES =
ifeq ($(ENABLE_YOUKI), true)
RUNC_FEATURES = youki
VMM_TASK_FEATURES = youki
endif
.PHONY: vmm wasm quark clean all install-vmm install-wasm install-quark install \
bin/vmm-sandboxer bin/vmm-task bin/vmlinux.bin bin/kuasar.img bin/kuasar.initrd \
bin/wasm-sandboxer bin/quark-sandboxer bin/runc-sandboxer
all: vmm quark wasm
bin/vmm-sandboxer:
@cd vmm/sandbox && cargo build --release --bin ${HYPERVISOR}
@mkdir -p bin && cp vmm/sandbox/target/release/${HYPERVISOR} bin/vmm-sandboxer
bin/vmm-task:
@cd vmm/task && cargo build --release --target=${ARCH}-unknown-linux-musl --features=${VMM_TASK_FEATURES}
@mkdir -p bin && cp vmm/task/target/${ARCH}-unknown-linux-musl/release/vmm-task bin/vmm-task
bin/vmlinux.bin:
@bash vmm/scripts/kernel/${HYPERVISOR}/build.sh ${KERNEL_VERSION}
@mkdir -p bin && cp vmm/scripts/kernel/${HYPERVISOR}/vmlinux.bin bin/vmlinux.bin && rm vmm/scripts/kernel/${HYPERVISOR}/vmlinux.bin
bin/kuasar.img:
@bash vmm/scripts/image/build.sh image ${GUESTOS_IMAGE}
@mkdir -p bin && cp /tmp/kuasar.img bin/kuasar.img && rm /tmp/kuasar.img
bin/kuasar.initrd:
@bash vmm/scripts/image/build.sh initrd ${GUESTOS_IMAGE}
@mkdir -p bin && cp /tmp/kuasar.initrd bin/kuasar.initrd && rm /tmp/kuasar.initrd
bin/wasm-sandboxer:
@cd wasm && cargo build --release --features=${WASM_RUNTIME}
@mkdir -p bin && cp wasm/target/release/wasm-sandboxer bin/wasm-sandboxer
bin/quark-sandboxer:
@cd quark && cargo build --release
@mkdir -p bin && cp quark/target/release/quark-sandboxer bin/quark-sandboxer
bin/runc-sandboxer:
@cd runc && cargo build --release --features=${RUNC_FEATURES}
@mkdir -p bin && cp runc/target/release/runc-sandboxer bin/runc-sandboxer
wasm: bin/wasm-sandboxer
quark: bin/quark-sandboxer
runc: bin/runc-sandboxer
ifeq ($(HYPERVISOR), cloud_hypervisor)
vmm: bin/vmm-sandboxer bin/kuasar.img bin/vmlinux.bin
else
# stratovirt or qemu
vmm: bin/vmm-sandboxer bin/kuasar.initrd bin/vmlinux.bin
endif
clean:
@rm -rf bin
@cd vmm/sandbox && cargo clean
@cd vmm/task && cargo clean
@cd wasm && cargo clean
@cd quark && cargo clean
@cd runc && cargo clean
install-vmm:
@install -d -m 750 ${DEST_DIR}${BIN_DIR}
@install -p -m 550 bin/vmm-sandboxer ${DEST_DIR}${BIN_DIR}/vmm-sandboxer
@install -d -m 750 ${DEST_DIR}${INSTALL_DIR}
@install -p -m 640 bin/vmlinux.bin ${DEST_DIR}${INSTALL_DIR}/vmlinux.bin
@install -d -m 750 ${DEST_DIR}${SYSTEMD_SERVICE_DIR}
@install -p -m 640 vmm/service/kuasar-vmm.service ${DEST_DIR}${SYSTEMD_SERVICE_DIR}/kuasar-vmm.service
@install -d -m 750 ${DEST_DIR}${SYSTEMD_CONF_DIR}
@install -p -m 640 vmm/service/kuasar-vmm ${DEST_DIR}${SYSTEMD_CONF_DIR}/kuasar-vmm
ifeq ($(HYPERVISOR), cloud_hypervisor)
@install -p -m 640 bin/kuasar.img ${DEST_DIR}${INSTALL_DIR}/kuasar.img
@install -p -m 640 vmm/sandbox/config_clh.toml ${DEST_DIR}${INSTALL_DIR}/config.toml
else
# stratovirt or qemu
@install -p -m 640 bin/kuasar.initrd ${DEST_DIR}${INSTALL_DIR}/kuasar.initrd
@install -p -m 640 vmm/sandbox/config_${HYPERVISOR}_${ARCH}.toml ${DEST_DIR}${INSTALL_DIR}/config.toml
endif
install-wasm:
@install -p -m 550 bin/wasm-sandboxer ${DEST_DIR}${BIN_DIR}/wasm-sandboxer
@install -d -m 750 ${DEST_DIR}${SYSTEMD_SERVICE_DIR}
@install -p -m 640 wasm/service/kuasar-wasm.service ${DEST_DIR}${SYSTEMD_SERVICE_DIR}/kuasar-wasm.service
install-quark:
@install -p -m 550 bin/quark-sandboxer ${DEST_DIR}${BIN_DIR}/quark-sandboxer
@install -d -m 750 ${DEST_DIR}${SYSTEMD_SERVICE_DIR}
@install -p -m 640 quark/service/kuasar-quark.service ${DEST_DIR}${SYSTEMD_SERVICE_DIR}/kuasar-quark.service
install-runc:
@install -p -m 550 bin/runc-sandboxer ${DEST_DIR}${BIN_DIR}/runc-sandboxer
install: all install-vmm install-wasm install-quark install-runc