2023-10-26 03:27:35 +00:00
|
|
|
# Make varaiables and defaults, you should refer to jinux-runner for more details
|
|
|
|
|
AUTO_TEST ?= none
|
2023-10-08 09:38:24 +00:00
|
|
|
BOOT_METHOD ?= qemu-grub
|
|
|
|
|
BOOT_PROTOCOL ?= multiboot2
|
2023-08-02 11:08:02 +00:00
|
|
|
BUILD_SYSCALL_TEST ?= 0
|
|
|
|
|
EMULATE_IOMMU ?= 0
|
|
|
|
|
ENABLE_KVM ?= 1
|
2023-08-09 03:40:00 +00:00
|
|
|
GDB_CLIENT ?= 0
|
|
|
|
|
GDB_SERVER ?= 0
|
2023-09-10 11:23:53 +00:00
|
|
|
INTEL_TDX ?= 0
|
2023-10-23 10:58:40 +00:00
|
|
|
SKIP_GRUB_MENU ?= 1
|
2023-10-26 03:27:35 +00:00
|
|
|
# End of setting up Make varaiables
|
2023-08-02 11:08:02 +00:00
|
|
|
|
|
|
|
|
KERNEL_CMDLINE := SHELL="/bin/sh" LOGNAME="root" HOME="/" USER="root" PATH="/bin" init=/usr/bin/busybox -- sh -l
|
2023-10-23 10:58:40 +00:00
|
|
|
ifeq ($(AUTO_TEST), syscall)
|
|
|
|
|
BUILD_SYSCALL_TEST := 1
|
2023-08-02 11:08:02 +00:00
|
|
|
KERNEL_CMDLINE += /opt/syscall_test/run_syscall_test.sh
|
|
|
|
|
endif
|
2023-10-26 03:27:35 +00:00
|
|
|
ifeq ($(AUTO_TEST), boot)
|
2023-10-23 10:58:40 +00:00
|
|
|
KERNEL_CMDLINE += -c exit 0
|
|
|
|
|
endif
|
2023-08-02 11:08:02 +00:00
|
|
|
|
2023-09-10 11:23:53 +00:00
|
|
|
CARGO_KBUILD_ARGS :=
|
|
|
|
|
|
2023-08-02 11:08:02 +00:00
|
|
|
CARGO_KRUN_ARGS := -- '$(KERNEL_CMDLINE)'
|
|
|
|
|
|
2023-08-09 03:40:00 +00:00
|
|
|
CARGO_KRUN_ARGS += --boot-method="$(BOOT_METHOD)"
|
2023-10-08 09:38:24 +00:00
|
|
|
CARGO_KRUN_ARGS += --boot-protocol="$(BOOT_PROTOCOL)"
|
2023-08-09 03:40:00 +00:00
|
|
|
|
|
|
|
|
ifeq ($(EMULATE_IOMMU), 1)
|
|
|
|
|
CARGO_KRUN_ARGS += --emulate-iommu
|
2023-09-10 11:23:53 +00:00
|
|
|
endif
|
|
|
|
|
|
2023-08-02 11:08:02 +00:00
|
|
|
ifeq ($(ENABLE_KVM), 1)
|
|
|
|
|
CARGO_KRUN_ARGS += --enable-kvm
|
|
|
|
|
endif
|
|
|
|
|
|
2023-08-09 03:40:00 +00:00
|
|
|
ifeq ($(GDB_SERVER), 1)
|
|
|
|
|
ENABLE_KVM := 0
|
|
|
|
|
CARGO_KRUN_ARGS += --halt-for-gdb
|
2023-08-02 11:08:02 +00:00
|
|
|
endif
|
|
|
|
|
|
2023-08-09 03:40:00 +00:00
|
|
|
ifeq ($(GDB_CLIENT), 1)
|
|
|
|
|
CARGO_KRUN_ARGS += --run-gdb-client
|
2023-08-27 12:17:32 +00:00
|
|
|
endif
|
|
|
|
|
|
2023-08-09 03:40:00 +00:00
|
|
|
ifeq ($(INTEL_TDX), 1)
|
|
|
|
|
CARGO_KBUILD_ARGS += --features intel_tdx
|
|
|
|
|
CARGO_KRUN_ARGS += --features intel_tdx
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifeq ($(SKIP_GRUB_MENU), 1)
|
|
|
|
|
CARGO_KRUN_ARGS += --skip-grub-menu
|
2023-08-02 11:08:02 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# Pass make variables to all subdirectory makes
|
|
|
|
|
export
|
|
|
|
|
|
2023-10-08 09:38:24 +00:00
|
|
|
# Toolchain variables that are used when building the Linux setup header
|
2023-10-06 14:08:20 +00:00
|
|
|
export CARGO := cargo
|
2023-08-09 03:40:00 +00:00
|
|
|
|
2023-08-02 11:08:02 +00:00
|
|
|
.PHONY: all setup build tools run test docs check clean
|
2022-08-08 22:43:47 +00:00
|
|
|
|
2023-04-10 03:12:42 +00:00
|
|
|
all: build
|
2022-08-08 22:43:47 +00:00
|
|
|
|
2022-08-17 03:22:49 +00:00
|
|
|
setup:
|
|
|
|
|
@rustup component add rust-src
|
2023-02-07 08:05:21 +00:00
|
|
|
@rustup component add rustc-dev
|
2022-08-17 03:22:49 +00:00
|
|
|
@rustup component add llvm-tools-preview
|
|
|
|
|
@cargo install mdbook
|
|
|
|
|
|
2022-08-08 22:43:47 +00:00
|
|
|
build:
|
2023-05-29 05:29:53 +00:00
|
|
|
@make --no-print-directory -C regression
|
2023-09-10 11:23:53 +00:00
|
|
|
@cargo kbuild $(CARGO_KBUILD_ARGS)
|
2023-08-07 02:56:03 +00:00
|
|
|
|
2023-02-07 08:05:21 +00:00
|
|
|
tools:
|
2023-04-10 03:12:42 +00:00
|
|
|
@cd services/libs/comp-sys && cargo install --path cargo-component
|
2023-02-07 08:05:21 +00:00
|
|
|
|
2022-08-17 03:22:49 +00:00
|
|
|
run: build
|
2023-08-02 11:08:02 +00:00
|
|
|
@cargo krun $(CARGO_KRUN_ARGS)
|
2023-07-26 07:36:40 +00:00
|
|
|
|
2022-08-08 22:43:47 +00:00
|
|
|
test: build
|
2023-04-10 03:12:42 +00:00
|
|
|
@cargo ktest
|
2022-08-08 22:43:47 +00:00
|
|
|
|
|
|
|
|
docs:
|
2023-04-10 03:12:42 +00:00
|
|
|
@cargo doc # Build Rust docs
|
2022-08-08 22:43:47 +00:00
|
|
|
@echo "" # Add a blank line
|
2022-08-08 23:02:55 +00:00
|
|
|
@cd docs && mdbook build # Build mdBook
|
2022-08-08 22:43:47 +00:00
|
|
|
|
2022-08-08 23:02:55 +00:00
|
|
|
check:
|
2023-09-04 03:04:42 +00:00
|
|
|
@cargo fmt --check # Check Rust format issues
|
|
|
|
|
@cargo kclippy -- -D warnings # Make build fail if any warnings are found by rustc and clippy
|
2022-08-08 22:43:47 +00:00
|
|
|
|
|
|
|
|
clean:
|
2023-04-10 03:12:42 +00:00
|
|
|
@cargo clean
|
2022-08-17 03:22:49 +00:00
|
|
|
@cd docs && mdbook clean
|
2023-05-29 05:29:53 +00:00
|
|
|
@make --no-print-directory -C regression clean
|