$(BUILD)/.inter/libbootstrap.a: $(shell find ./sources/bootstrap -type f -not -path "*/target/*")
	@mkdir -p $(BUILD)/.inter
	cd sources/bootstrap && \
		$(CARGO) \
			-Zbuild-std=core,alloc,compiler_builtins \
			-Zbuild-std-features=compiler-builtins-mem rustc \
			--target "x86_64-unknown-redox" \
			--release \
			-- \
			--emit link="../../$(BUILD)/.inter/libbootstrap.a"

$(BUILD)/boot/bootstrap: $(BUILD)/.inter/libbootstrap.a
	@mkdir -p $(BUILD)/boot
	x86_64-unknown-redox-ld \
		-o "$(BUILD)/boot/bootstrap" \
		--gc-sections \
		-T "./sources/bootstrap/src/x86_64.ld" \
		-z max-page-size=4096 \
		"$(BUILD)/.inter/libbootstrap.a"