Makefile 871 Bytes
Newer Older
1 2 3 4 5 6
ARCH=x86
TARGET=$(ARCH)-unknown-none

export LD=ld
export OBJCOPY=objcopy
export RUST_TARGET_PATH=$(CURDIR)/targets
Jeremy Soller's avatar
Jeremy Soller committed
7
export XARGO_HOME=$(CURDIR)/target/xargo
8 9 10

all: build/bootloader

Jeremy Soller's avatar
Jeremy Soller committed
11 12 13 14 15 16
clean:
	rm -rf build

build/libstartup.o: src/nasm/startup.asm src/nasm/*
	mkdir -p build
ifeq ($(KERNEL),)
Jeremy Soller's avatar
Jeremy Soller committed
17
	nasm -f elf32 $< -I src/nasm/ -o $@
Jeremy Soller's avatar
Jeremy Soller committed
18 19 20
else
	nasm -f elf32 $< -I src/nasm/ -D KERNEL=$(KERNEL) -o $@
endif
Jeremy Soller's avatar
Jeremy Soller committed
21

22 23 24 25
build/libbootloader.a: Cargo.lock Cargo.toml src/* src/*/* src/*/*/* src/*/*/*/*
	mkdir -p build
	xargo rustc --lib --target $(TARGET) --release -- -C soft-float -C debuginfo=2 --emit link=$@

Jeremy Soller's avatar
Jeremy Soller committed
26
build/bootloader: linkers/$(ARCH).ld build/libstartup.o build/libbootloader.a
Jeremy Soller's avatar
Jeremy Soller committed
27
	mkdir -p build
Jeremy Soller's avatar
Jeremy Soller committed
28
	$(LD) -m elf_i386 --gc-sections -z max-page-size=0x1000 -T $< -o $@ build/libstartup.o build/libbootloader.a && \
29 30
	$(OBJCOPY) --only-keep-debug $@ $@.sym && \
	$(OBJCOPY) --strip-debug $@