mirror of https://github.com/vinc/moros.git
77 lines
1.9 KiB
Makefile
77 lines
1.9 KiB
Makefile
.PHONY: setup image qemu
|
|
.EXPORT_ALL_VARIABLES:
|
|
|
|
setup:
|
|
curl https://sh.rustup.rs -sSf | sh -s -- -y
|
|
rustup install nightly
|
|
rustup default nightly
|
|
cargo install bootimage
|
|
|
|
# Compilation options
|
|
output = video# video, serial
|
|
keyboard = qwerty# qwerty, azerty, dvorak
|
|
|
|
# Emulation options
|
|
nic = rtl8139# rtl8139, pcnet
|
|
audio = sdl# sdl, coreaudio
|
|
kvm = false
|
|
|
|
export MOROS_KEYBOARD = $(keyboard)
|
|
|
|
# Build userspace binaries
|
|
user-nasm:
|
|
basename -s .s dsk/src/bin/*.s | xargs -I {} \
|
|
nasm dsk/src/bin/{}.s -o dsk/bin/{}.tmp
|
|
basename -s .s dsk/src/bin/*.s | xargs -I {} \
|
|
sh -c "printf '\x7FBIN' | cat - dsk/bin/{}.tmp > dsk/bin/{}"
|
|
rm dsk/bin/*.tmp
|
|
user-rust:
|
|
basename -s .rs src/bin/*.rs | xargs -I {} \
|
|
touch dsk/bin/{}
|
|
basename -s .rs src/bin/*.rs | xargs -I {} \
|
|
cargo rustc --release --bin {} -- \
|
|
-C relocation-model=static
|
|
basename -s .rs src/bin/*.rs | xargs -I {} \
|
|
cp target/x86_64-moros/release/{} dsk/bin/{}
|
|
#strip dsk/bin/*
|
|
|
|
bin = target/x86_64-moros/release/bootimage-moros.bin
|
|
img = disk.img
|
|
|
|
$(img):
|
|
qemu-img create $(img) 32M
|
|
|
|
# Rebuild MOROS if the features list changed
|
|
image: $(img)
|
|
touch src/lib.rs
|
|
env | grep MOROS
|
|
cargo bootimage --no-default-features --features $(output) --release --bin moros
|
|
dd conv=notrunc if=$(bin) of=$(img)
|
|
|
|
opts = -m 32 -drive file=$(img),format=raw \
|
|
-audiodev $(audio),id=a0 -machine pcspk-audiodev=a0 \
|
|
-netdev user,id=e0,hostfwd=tcp::8080-:80 -device $(nic),netdev=e0
|
|
ifeq ($(kvm),true)
|
|
opts += -cpu host -accel kvm
|
|
else
|
|
opts += -cpu max
|
|
endif
|
|
|
|
ifeq ($(pcap),true)
|
|
opts += -object filter-dump,id=f1,netdev=e0,file=/tmp/qemu.pcap
|
|
endif
|
|
|
|
ifeq ($(output),serial)
|
|
opts += -display none -chardev stdio,id=s0,signal=off -serial chardev:s0
|
|
endif
|
|
|
|
qemu:
|
|
qemu-system-x86_64 $(opts)
|
|
|
|
test:
|
|
cargo test --release --lib --no-default-features --features serial -- \
|
|
-m 32 -display none -serial stdio -device isa-debug-exit,iobase=0xf4,iosize=0x04
|
|
|
|
clean:
|
|
cargo clean
|