49 lines
1.1 KiB
Makefile
49 lines
1.1 KiB
Makefile
|
# Build script for BIOS (legacy) boot.
|
||
|
#
|
||
|
# This compiles our bootloader as a static library,
|
||
|
# and wraps it in a multistage loader.
|
||
|
|
||
|
|
||
|
BUILD = ./build
|
||
|
BIOS_BUILD = $(BUILD)/bios
|
||
|
|
||
|
STAGE2_SECTOR=34
|
||
|
|
||
|
.PHONY: all
|
||
|
all: $(BIOS_BUILD)/bios.mbr.bin $(BIOS_BUILD)/bios.stage2.bin
|
||
|
|
||
|
.PHONY: clean
|
||
|
clean:
|
||
|
rm -drf $(BUILD)
|
||
|
|
||
|
include bios.mk
|
||
|
|
||
|
# Compile bootloader as library
|
||
|
LIB_SRC = ./bootloader/Cargo.toml ./bootloader/Cargo.lock $(shell find ./bootloader/src -type f)
|
||
|
$(BUILD)/bios.lib: $(LIB_SRC)
|
||
|
@mkdir -p $(BUILD)
|
||
|
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 bootloader
|
||
|
BIOS_LD = ./bootloader/linkers/x86-unknown-none.ld
|
||
|
$(BUILD)/bios.elf: $(BUILD)/bios.lib $(BIOS_LD)
|
||
|
ld \
|
||
|
-m elf_i386 \
|
||
|
--gc-sections \
|
||
|
-z max-page-size=0x1000 \
|
||
|
-T "$(BIOS_LD)" \
|
||
|
-o "$@" \
|
||
|
"$<"
|
||
|
|
||
|
objcopy --only-keep-debug "$@" "$@.sym"
|
||
|
objcopy --strip-debug "$@"
|