asterinas/Makefile

109 lines
2.4 KiB
Makefile
Raw Normal View History

# Make varaiables and defaults, you should refer to jinux-runner for more details
AUTO_TEST ?= none
BOOT_METHOD ?= qemu-grub
BOOT_PROTOCOL ?= multiboot2
BUILD_SYSCALL_TEST ?= 0
EMULATE_IOMMU ?= 0
ENABLE_KVM ?= 1
GDB_CLIENT ?= 0
GDB_SERVER ?= 0
INTEL_TDX ?= 0
SKIP_GRUB_MENU ?= 1
RELEASE_MODE ?= 0
# End of setting up Make varaiables
KERNEL_CMDLINE := SHELL="/bin/sh" LOGNAME="root" HOME="/" USER="root" PATH="/bin" init=/usr/bin/busybox -- sh -l
ifeq ($(AUTO_TEST), syscall)
BUILD_SYSCALL_TEST := 1
KERNEL_CMDLINE += /opt/syscall_test/run_syscall_test.sh
endif
ifeq ($(AUTO_TEST), boot)
KERNEL_CMDLINE += -c exit 0
endif
CARGO_KBUILD_ARGS :=
CARGO_KRUN_ARGS :=
ifeq ($(RELEASE_MODE), 1)
CARGO_KBUILD_ARGS += --release
CARGO_KRUN_ARGS += --release
endif
CARGO_KRUN_ARGS += -- '$(KERNEL_CMDLINE)'
CARGO_KRUN_ARGS += --boot-method="$(BOOT_METHOD)"
CARGO_KRUN_ARGS += --boot-protocol="$(BOOT_PROTOCOL)"
ifeq ($(RELEASE_MODE), 1)
CARGO_KRUN_ARGS += --release-mode
endif
ifeq ($(EMULATE_IOMMU), 1)
CARGO_KRUN_ARGS += --emulate-iommu
endif
ifeq ($(ENABLE_KVM), 1)
CARGO_KRUN_ARGS += --enable-kvm
endif
ifeq ($(GDB_SERVER), 1)
ENABLE_KVM := 0
CARGO_KRUN_ARGS += --halt-for-gdb
endif
ifeq ($(GDB_CLIENT), 1)
CARGO_KRUN_ARGS += --run-gdb-client
2023-08-27 12:17:32 +00:00
endif
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
endif
# Pass make variables to all subdirectory makes
export
# Toolchain variables that are used when building the Linux setup header
export CARGO := cargo
.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
@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
@cargo krun $(CARGO_KRUN_ARGS)
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