Makefile updates
This commit is contained in:
parent
dad1b1b3cb
commit
e432b5a48e
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e42f25ac5fa51f4188d14baf8f387a97dcd8639644b2f3df948bf5f6dd7d6fa"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.0",
|
||||
"log",
|
||||
]
|
||||
|
||||
@ -33,9 +33,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.8.0"
|
||||
version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
||||
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
|
||||
|
||||
[[package]]
|
||||
name = "conquer-once"
|
||||
@ -89,7 +89,7 @@ version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ca87cab008b8efeebdbe037cd4d1438037d48c5cb6fed939ffa5aa06315a321"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -129,15 +129,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.10.0"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6"
|
||||
checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.19"
|
||||
version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
|
||||
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
@ -199,7 +199,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c101112411baafbb4bf8d33e4c4a80ab5b02d74d2612331c61e8192fc9710491"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.0",
|
||||
"rustversion",
|
||||
"volatile",
|
||||
]
|
||||
|
33
Makefile
33
Makefile
@ -1,8 +1,13 @@
|
||||
|
||||
# Default target is x86_64-unknown-none
|
||||
TARGET ?= "x86_64-unknown-none"
|
||||
# Limine BIOS file directory
|
||||
LIMINE-DIR ?= "/usr/share/limine"
|
||||
|
||||
# QEMU system is set accordingly and automatically
|
||||
qemu = "qemu-system-x86_64"
|
||||
# List of required BIOS files
|
||||
limine-files = limine-bios.sys limine-bios-cd.bin limine-bios-uefi-cd.bin
|
||||
|
||||
# Properly set QEMU command
|
||||
ifeq ($(TARGET),x86_64-unknown-none)
|
||||
@ -17,34 +22,50 @@ else ifeq ($(TARGET),loongarch64-unknown-none)
|
||||
qemu = "qemu-system-loongarch64"
|
||||
endif
|
||||
|
||||
executables = rustup xorriso limine $(qemu)
|
||||
|
||||
all: gila iso run
|
||||
|
||||
checkenv:
|
||||
|
||||
$(foreach file,$(limine-files),\
|
||||
$(if $(shell test -f $(LIMINE-DIR)/$(file) | echo "it exists"),$(info "Found $(file)"),$(error "No $(file) in $(LIMINE-DIR)")))
|
||||
|
||||
$(foreach exec,$(executables),\
|
||||
$(if $(shell which $(exec)),$(info "Found $(exec)"),$(error "No $(exec) in PATH")))
|
||||
|
||||
# Prepare toolchain
|
||||
prepare:
|
||||
prepare: checkenv
|
||||
|
||||
rustup install nightly
|
||||
rustup update
|
||||
rustup target add $(TARGET)
|
||||
|
||||
# Run the ISO in an emulator.
|
||||
run: build/gila.iso
|
||||
|
||||
$(qemu) -drive file=build/gila.iso,format=raw,index=0,media=disk
|
||||
|
||||
# Build the bootable kernel image.
|
||||
.PHONY: build/iso/gila
|
||||
gila: prepare $(wildcard src/*.rs) $(wildcard linker-scripts/*.ld)
|
||||
gila: prepare $(shell find src -type f -name *.rs) $(shell find src -type f -name linker.ld)
|
||||
|
||||
mkdir -p build/iso/
|
||||
cargo build --release -Z unstable-options --target=$(TARGET) --artifact-dir build/iso/
|
||||
|
||||
# Build a bootable ISO and install Limine.
|
||||
.PHONY: build/gila.iso
|
||||
iso: build/iso/gila limine.conf
|
||||
|
||||
mkdir -p build/iso/limine
|
||||
mkdir -p build/iso/EFI/BOOT
|
||||
|
||||
cp ./limine.conf build/iso/
|
||||
cp /usr/share/limine/limine-bios.sys build/iso/limine/
|
||||
cp /usr/share/limine/limine-bios-cd.bin build/iso/limine/
|
||||
cp /usr/share/limine/limine-uefi-cd.bin build/iso/limine/
|
||||
cp $(LIMINE-DIR)/limine-bios.sys build/iso/limine/
|
||||
cp $(LIMINE-DIR)/limine-bios-cd.bin build/iso/limine/
|
||||
cp $(LIMINE-DIR)/limine-uefi-cd.bin build/iso/limine/
|
||||
|
||||
tree build/iso/
|
||||
|
||||
xorriso -as mkisofs -b limine/limine-bios-cd.bin -no-emul-boot \
|
||||
-boot-load-size 4 -boot-info-table --efi-boot \
|
||||
limine/limine-uefi-cd.bin -efi-boot-part --efi-boot-image \
|
||||
|
4
build.rs
4
build.rs
@ -1,7 +1,7 @@
|
||||
fn main() {
|
||||
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||
// Tell cargo to pass the linker script to the linker..
|
||||
println!("cargo:rustc-link-arg=-Tlinker-scripts/linker-{arch}.ld");
|
||||
println!("cargo:rustc-link-arg=-Tsrc/arch/{arch}/linker.ld");
|
||||
// ..and to re-run if it changes.
|
||||
println!("cargo:rerun-if-changed=linker-scripts/linker-{arch}.ld");
|
||||
println!("cargo:rerun-if-changed=src/arch/{arch}linker.ld");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user