2016-08-29 02:38:53 +02:00
|
|
|
ARCH?=x86_64
|
2016-08-14 02:21:46 +02:00
|
|
|
|
2016-08-20 17:44:14 +02:00
|
|
|
QEMU=qemu-system-$(ARCH)
|
2016-08-26 01:03:01 +02:00
|
|
|
QEMUFLAGS=-serial mon:stdio -d guest_errors
|
|
|
|
|
2016-09-10 01:13:16 +02:00
|
|
|
RUSTCFLAGS=--target $(ARCH)-unknown-redox.json -O -C soft-float --cfg redox
|
|
|
|
CARGOFLAGS=--target $(ARCH)-unknown-redox.json -- -O -C soft-float --cfg redox
|
2016-09-01 23:31:39 +02:00
|
|
|
|
2016-08-26 01:03:01 +02:00
|
|
|
ifeq ($(ARCH),arm)
|
|
|
|
LD=$(ARCH)-none-eabi-ld
|
|
|
|
QEMUFLAGS+=-cpu arm1176 -machine integratorcp
|
|
|
|
QEMUFLAGS+=-nographic
|
|
|
|
else
|
|
|
|
LD=ld
|
|
|
|
QEMUFLAGS+=-enable-kvm -cpu host -machine q35 -smp 4
|
2016-09-08 23:45:26 +02:00
|
|
|
QEMUFLAGS+=-nographic -vga none
|
2016-08-26 01:03:01 +02:00
|
|
|
#,int,pcall
|
|
|
|
#-device intel-iommu
|
|
|
|
|
|
|
|
UNAME := $(shell uname)
|
|
|
|
ifeq ($(UNAME),Darwin)
|
|
|
|
LD=$(ARCH)-elf-ld
|
|
|
|
QEMUFLAGS=
|
|
|
|
endif
|
2016-08-20 17:44:14 +02:00
|
|
|
endif
|
|
|
|
|
2016-08-26 01:03:01 +02:00
|
|
|
all: build/kernel.bin
|
2016-08-14 02:58:31 +02:00
|
|
|
|
|
|
|
list: build/kernel.list
|
|
|
|
|
|
|
|
run: bochs
|
2016-08-14 02:21:46 +02:00
|
|
|
|
|
|
|
bochs: build/harddrive.bin
|
|
|
|
bochs -f bochs.$(ARCH)
|
|
|
|
|
|
|
|
FORCE:
|
|
|
|
|
2016-08-15 19:29:53 +02:00
|
|
|
build/libcore.rlib: rust/src/libcore/lib.rs
|
|
|
|
mkdir -p build
|
2016-09-01 23:31:39 +02:00
|
|
|
./rustc.sh $(RUSTCFLAGS) -o $@ $<
|
2016-08-15 02:16:56 +02:00
|
|
|
|
2016-09-10 01:13:16 +02:00
|
|
|
build/librand.rlib: rust/src/librand/lib.rs build/libcore.rlib
|
|
|
|
./rustc.sh $(RUSTCFLAGS) -o $@ $<
|
|
|
|
|
2016-08-15 19:29:53 +02:00
|
|
|
build/liballoc.rlib: rust/src/liballoc/lib.rs build/libcore.rlib
|
2016-09-01 23:31:39 +02:00
|
|
|
./rustc.sh $(RUSTCFLAGS) -o $@ $<
|
2016-08-15 19:29:53 +02:00
|
|
|
|
|
|
|
build/librustc_unicode.rlib: rust/src/librustc_unicode/lib.rs build/libcore.rlib
|
2016-09-01 23:31:39 +02:00
|
|
|
./rustc.sh $(RUSTCFLAGS) -o $@ $<
|
2016-08-15 19:29:53 +02:00
|
|
|
|
|
|
|
build/libcollections.rlib: rust/src/libcollections/lib.rs build/libcore.rlib build/liballoc.rlib build/librustc_unicode.rlib
|
2016-09-01 23:31:39 +02:00
|
|
|
./rustc.sh $(RUSTCFLAGS) -o $@ $<
|
2016-08-15 19:29:53 +02:00
|
|
|
|
2016-09-10 01:13:16 +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
|
2016-09-09 03:13:52 +02:00
|
|
|
RUSTC="./rustc.sh" cargo rustc --manifest-path $< $(CARGOFLAGS) -o $@
|
2016-09-10 01:13:16 +02:00
|
|
|
cp libstd/target/$(ARCH)-unknown-redox/debug/deps/*.rlib build
|
2016-09-09 03:09:58 +02:00
|
|
|
|
2016-09-10 01:13:16 +02:00
|
|
|
build/init: init/Cargo.toml init/src/*.rs build/libstd.rlib
|
|
|
|
RUSTC="./rustc.sh" cargo rustc --manifest-path $< $(CARGOFLAGS) -o $@
|
2016-09-10 01:28:20 +02:00
|
|
|
strip $@
|
2016-09-09 03:09:58 +02:00
|
|
|
|
2016-09-10 02:31:28 +02:00
|
|
|
build/libkernel.a: build/libcore.rlib build/liballoc.rlib build/libcollections.rlib build/init kernel/** FORCE
|
2016-09-01 23:31:39 +02:00
|
|
|
RUSTC="./rustc.sh" cargo rustc $(CARGOFLAGS) -o $@
|
2016-08-14 02:21:46 +02:00
|
|
|
|
|
|
|
build/kernel.bin: build/libkernel.a
|
2016-08-26 01:03:01 +02:00
|
|
|
$(LD) --gc-sections -z max-page-size=0x1000 -T arch/$(ARCH)/src/linker.ld -o $@ $<
|
2016-09-10 02:31:28 +02:00
|
|
|
strip $@
|
2016-08-14 02:21:46 +02:00
|
|
|
|
2016-08-26 01:03:01 +02:00
|
|
|
ifeq ($(ARCH),arm)
|
|
|
|
build/kernel.list: build/kernel.bin
|
|
|
|
$(ARCH)-none-eabi-objdump -C -D $< > $@
|
|
|
|
|
|
|
|
qemu: build/kernel.bin
|
|
|
|
$(QEMU) $(QEMUFLAGS) -kernel $<
|
|
|
|
else
|
2016-08-14 02:58:31 +02:00
|
|
|
build/kernel.list: build/kernel.bin
|
|
|
|
objdump -C -M intel -D $< > $@
|
|
|
|
|
2016-09-10 02:31:28 +02:00
|
|
|
build/harddrive.bin: build/kernel.bin bootloader/$(ARCH)/**
|
2016-08-26 01:03:01 +02:00
|
|
|
nasm -f bin -o $@ -D ARCH_$(ARCH) -ibootloader/$(ARCH)/ -ibuild/ bootloader/$(ARCH)/harddrive.asm
|
|
|
|
|
|
|
|
qemu: build/harddrive.bin
|
|
|
|
$(QEMU) $(QEMUFLAGS) -drive file=$<,format=raw,index=0,media=disk
|
|
|
|
endif
|
2016-08-14 02:21:46 +02:00
|
|
|
|
|
|
|
clean:
|
2016-09-09 23:48:54 +02:00
|
|
|
cargo clean
|
2016-09-10 01:13:16 +02:00
|
|
|
cargo clean --manifest-path libstd/Cargo.toml
|
|
|
|
cargo clean --manifest-path init/Cargo.toml
|
2016-09-09 23:48:54 +02:00
|
|
|
rm -rf build/*
|