1
0
Fork 0

Added makefiles

main
Mark 2024-12-11 18:21:14 -08:00
parent 1fd7b7c55f
commit bebed12bf4
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
3 changed files with 52 additions and 0 deletions

11
Makefile Normal file
View File

@ -0,0 +1,11 @@
BUILD_DIR=./build
.PHONY: clean
all: $(BUILD_DIR)/bootloader.bin
include make/bios
include make/bootloader
clean:
rm -drf $(BUILD_DIR)

12
make/bios Normal file
View File

@ -0,0 +1,12 @@
BIOS_SRC = ./bios
STAGE3_BIN = $(BUILD_DIR)/stage3.elf
$(BUILD_DIR)/bootloader.bin: $(wildcard $(BIOS_SRC)/*.asm) $(STAGE3_BIN)
@mkdir -p "$(BUILD_DIR)"
nasm \
-f bin \
-o "$@" \
-l "$@.lst" \
-D STAGE3="$(STAGE3_BIN)" \
-i "$(BIOS_SRC)" \
"$(BIOS_SRC)/bootloader.asm"

29
make/bootloader Normal file
View File

@ -0,0 +1,29 @@
STAGE3_SRC = ./bootloader/Cargo.toml ./bootloader/Cargo.lock $(shell find ./bootloader/src -type f)
STAGE3_LD = ./bootloader/linkers/x86-unknown-none.ld
# Compile stage 3 bootloader
$(BUILD_DIR)/stage3.lib.a: $(STAGE3_SRC)
@mkdir -p $(BUILD_DIR)
env RUSTFLAGS="-C soft-float" \
cargo rustc \
--manifest-path="./bootloader/Cargo.toml" \
-Z build-std=core,alloc \
-Z build-std-features=compiler-builtins-mem \
--target "./bootloader/targets/x86-unknown-none.json" \
--lib \
--release \
-- \
--emit link="$(CURDIR)/$@"
# Link stage 3 bootloader
$(BUILD_DIR)/stage3.elf: $(BUILD_DIR)/stage3.lib.a $(STAGE3_LD)
ld \
-m elf_i386 \
--gc-sections \
-z max-page-size=0x1000 \
-T "$(STAGE3_LD)" \
-o "$@" \
"$<"
objcopy --only-keep-debug "$@" "$@.sym"
objcopy --strip-debug "$@"