redox/Makefile

131 lines
3.9 KiB
Makefile
Raw Normal View History

2016-08-29 02:38:53 +02:00
ARCH?=x86_64
2016-08-14 02:21:46 +02:00
2016-09-10 03:08:04 +02:00
# Kernel variables
KTARGET=$(ARCH)-unknown-none
KBUILD=build/kernel
KRUSTC=./krustc.sh
KRUSTCFLAGS=--target $(KTARGET).json -O -C soft-float
KCARGO=RUSTC="$(KRUSTC)" cargo
KCARGOFLAGS=--target $(KTARGET).json -- -O -C soft-float
# Userspace variables
TARGET=$(ARCH)-unknown-redox
BUILD=build/userspace
RUSTC=./rustc.sh
RUSTCFLAGS=--target $(TARGET).json -O -C soft-float --cfg redox
CARGO=RUSTC="$(RUSTC)" cargo
CARGOFLAGS=--target $(TARGET).json -- -O -C soft-float --cfg redox
# Default targets
.PHONY: all clean qemu bochs FORCE
all: $(KBUILD)/harddrive.bin
2016-08-26 01:03:01 +02:00
2016-09-10 03:08:04 +02:00
clean:
cargo clean
cargo clean --manifest-path libstd/Cargo.toml
cargo clean --manifest-path init/Cargo.toml
2016-09-11 23:56:48 +02:00
cargo clean --manifest-path drivers/pcid/Cargo.toml
2016-09-10 03:08:04 +02:00
rm -rf build
FORCE:
2016-09-10 03:08:04 +02:00
# Emulation
QEMU=qemu-system-$(ARCH)
QEMUFLAGS=-serial mon:stdio -d guest_errors
2016-08-26 01:03:01 +02:00
ifeq ($(ARCH),arm)
LD=$(ARCH)-none-eabi-ld
QEMUFLAGS+=-cpu arm1176 -machine integratorcp
QEMUFLAGS+=-nographic
2016-09-10 03:08:04 +02:00
2016-09-11 06:06:09 +02:00
build/%.list: build/%
2016-09-10 03:08:04 +02:00
$(ARCH)-none-eabi-objdump -C -D $< > $@
2016-09-11 06:06:09 +02:00
$(KBUILD)/harddrive.bin: $(KBUILD)/kernel
2016-09-10 03:08:04 +02:00
cp $< $@
qemu: $(KBUILD)/harddrive.bin
$(QEMU) $(QEMUFLAGS) -kernel $<
2016-08-26 01:03:01 +02:00
else
LD=ld
QEMUFLAGS+=-machine q35 -smp 4
ifeq ($(kvm),yes)
QEMUFLAGS+=-enable-kvm -cpu host
endif
ifeq ($(vga),no)
QEMUFLAGS+=-nographic -vga none
endif
2016-08-26 01:03:01 +02:00
#,int,pcall
#-device intel-iommu
UNAME := $(shell uname)
ifeq ($(UNAME),Darwin)
LD=$(ARCH)-elf-ld
endif
2016-08-20 17:44:14 +02:00
2016-09-11 06:06:09 +02:00
build/%.list: build/%
2016-09-10 03:08:04 +02:00
objdump -C -M intel -D $< > $@
2016-08-14 02:58:31 +02:00
2016-09-11 06:06:09 +02:00
$(KBUILD)/harddrive.bin: $(KBUILD)/kernel bootloader/$(ARCH)/**
nasm -f bin -o $@ -D ARCH_$(ARCH) -ibootloader/$(ARCH)/ bootloader/$(ARCH)/harddrive.asm
2016-08-14 02:58:31 +02:00
2016-09-10 03:08:04 +02:00
qemu: $(KBUILD)/harddrive.bin
$(QEMU) $(QEMUFLAGS) -drive file=$<,format=raw,index=0,media=disk
endif
2016-08-14 02:21:46 +02:00
2016-09-10 03:08:04 +02:00
bochs: $(KBUILD)/harddrive.bin
2016-08-14 02:21:46 +02:00
bochs -f bochs.$(ARCH)
2016-09-10 03:08:04 +02:00
# Kernel recipes
$(KBUILD)/libcore.rlib: rust/src/libcore/lib.rs
mkdir -p $(KBUILD)
$(KRUSTC) $(KRUSTCFLAGS) -o $@ $<
2016-08-14 02:21:46 +02:00
2016-09-10 03:08:04 +02:00
$(KBUILD)/librand.rlib: rust/src/librand/lib.rs $(KBUILD)/libcore.rlib
$(KRUSTC) $(KRUSTCFLAGS) -o $@ $<
2016-08-15 02:16:56 +02:00
2016-09-10 03:08:04 +02:00
$(KBUILD)/liballoc.rlib: rust/src/liballoc/lib.rs $(KBUILD)/libcore.rlib
$(KRUSTC) $(KRUSTCFLAGS) -o $@ $<
2016-09-10 03:08:04 +02:00
$(KBUILD)/librustc_unicode.rlib: rust/src/librustc_unicode/lib.rs $(KBUILD)/libcore.rlib
$(KRUSTC) $(KRUSTCFLAGS) -o $@ $<
2016-09-10 03:08:04 +02:00
$(KBUILD)/libcollections.rlib: rust/src/libcollections/lib.rs $(KBUILD)/libcore.rlib $(KBUILD)/liballoc.rlib $(KBUILD)/librustc_unicode.rlib
$(KRUSTC) $(KRUSTCFLAGS) -o $@ $<
2016-09-11 23:56:48 +02:00
$(KBUILD)/libkernel.a: kernel/** $(KBUILD)/libcore.rlib $(KBUILD)/liballoc.rlib $(KBUILD)/libcollections.rlib $(BUILD)/init $(BUILD)/pcid FORCE
2016-09-10 03:08:04 +02:00
$(KCARGO) rustc $(KCARGOFLAGS) -o $@
2016-09-11 06:06:09 +02:00
$(KBUILD)/kernel: $(KBUILD)/libkernel.a
2016-09-10 03:08:04 +02:00
$(LD) --gc-sections -z max-page-size=0x1000 -T arch/$(ARCH)/src/linker.ld -o $@ $<
2016-09-11 23:56:48 +02:00
strip $@
2016-09-10 03:08:04 +02:00
# Userspace recipes
$(BUILD)/libcore.rlib: rust/src/libcore/lib.rs
mkdir -p $(BUILD)
$(RUSTC) $(RUSTCFLAGS) -o $@ $<
2016-09-10 03:08:04 +02:00
$(BUILD)/librand.rlib: rust/src/librand/lib.rs $(BUILD)/libcore.rlib
$(RUSTC) $(RUSTCFLAGS) -o $@ $<
2016-08-14 02:21:46 +02:00
2016-09-10 03:08:04 +02:00
$(BUILD)/liballoc.rlib: rust/src/liballoc/lib.rs $(BUILD)/libcore.rlib
$(RUSTC) $(RUSTCFLAGS) -o $@ $<
2016-08-14 02:21:46 +02:00
2016-09-10 03:08:04 +02:00
$(BUILD)/librustc_unicode.rlib: rust/src/librustc_unicode/lib.rs $(BUILD)/libcore.rlib
$(RUSTC) $(RUSTCFLAGS) -o $@ $<
2016-08-26 01:03:01 +02:00
2016-09-10 03:08:04 +02:00
$(BUILD)/libcollections.rlib: rust/src/libcollections/lib.rs $(BUILD)/libcore.rlib $(BUILD)/liballoc.rlib $(BUILD)/librustc_unicode.rlib
$(RUSTC) $(RUSTCFLAGS) -o $@ $<
2016-08-26 01:03:01 +02:00
2016-09-10 03:08:04 +02:00
$(BUILD)/libstd.rlib: libstd/Cargo.toml libstd/src/** $(BUILD)/libcore.rlib $(BUILD)/liballoc.rlib $(BUILD)/librustc_unicode.rlib $(BUILD)/libcollections.rlib $(BUILD)/librand.rlib
$(CARGO) rustc --verbose --manifest-path $< $(CARGOFLAGS) -o $@
cp libstd/target/$(TARGET)/debug/deps/*.rlib $(BUILD)
2016-08-14 02:21:46 +02:00
2016-09-10 03:08:04 +02:00
$(BUILD)/init: init/Cargo.toml init/src/*.rs $(BUILD)/libstd.rlib
$(CARGO) rustc --manifest-path $< $(CARGOFLAGS) -o $@
2016-09-11 23:56:48 +02:00
strip $@
$(BUILD)/pcid: drivers/pcid/Cargo.toml drivers/pcid/src/** $(BUILD)/libstd.rlib
$(CARGO) rustc --manifest-path $< $(CARGOFLAGS) -o $@
strip $@