-
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (107 loc) · 3.46 KB
/
Copy pathMakefile
File metadata and controls
133 lines (107 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
.PHONY: setup image qemu
.EXPORT_ALL_VARIABLES:
setup:
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none
rustup show
cargo install bootimage
# Compilation options
output = video# video, serial
keyboard = qwerty# qwerty, azerty, dvorak
mode = release
# Emulation options
memory = 32
smp = 2
nic = rtl8139# rtl8139, pcnet, e1000
snd = sb16# ac97, sb16
audio = sdl# sdl, coreaudio
signal = off# on
kvm = false
pcap = false
trace = false# e1000
monitor = false
export MOROS_VERSION = $(shell git describe --tags | sed "s/^v//")
export MOROS_KEYBOARD = $(keyboard)
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-cargo-opts = --no-default-features --features userspace --release
# FIXME: Userspace alloc panic when the default `lld` linker is used because it
# sets the entry point 0x200000 which is used by the kernel, so we use `ld` to
# set it at 0x800000 that is free. With `ld` the resulting binaries are much
# larger though. This is useful only for programs that allocate memory.
ld-opts = -Ttext=800000 -Trodata=900000 -Tbss=950000
linker-opts = -C linker-flavor=ld -C link-args="$(ld-opts)"
user-rust:
basename -s .rs src/bin/*.rs | xargs -I {} \
touch dsk/bin/{}
basename -s .rs src/bin/*.rs | xargs -I {} \
cargo rustc $(user-cargo-opts) --bin {} \
-- $(linker-opts)
basename -s .rs src/bin/*.rs | xargs -I {} \
cp target/x86_64-moros/release/{} dsk/bin/{}
basename -s .rs src/bin/*.rs | xargs -I {} \
strip dsk/bin/{}
bin = target/x86_64-moros/$(mode)/bootimage-moros.bin
img = disk.img
$(img):
qemu-img create $(img) 32M
cargo-opts = --no-default-features --features $(output) --bin moros
ifeq ($(mode),release)
cargo-opts += --release
endif
# Rebuild MOROS if the features list changed
image: $(img)
touch src/lib.rs
env | grep MOROS
cargo bootimage $(cargo-opts)
dd conv=notrunc if=$(bin) of=$(img)
qemu-opts = -name "MOROS $$MOROS_VERSION" \
-m $(memory) -smp $(smp) -drive file=$(img),format=raw \
-audiodev $(audio),id=a0 -machine pcspk-audiodev=a0 \
-audio driver=$(audio),model=$(snd) \
-netdev user,id=e0,hostfwd=tcp::8080-:80 -device $(nic),netdev=e0
ifeq ($(kvm),true)
qemu-opts += -cpu host -accel kvm
else
qemu-opts += -cpu core2duo
endif
ifeq ($(pcap),true)
qemu-opts += -object filter-dump,id=f1,netdev=e0,file=/tmp/qemu.pcap
endif
ifeq ($(monitor),true)
qemu-opts += -monitor telnet:127.0.0.1:7777,server,nowait
endif
ifeq ($(output),serial)
qemu-opts += -display none
qemu-opts += -chardev stdio,id=s0,signal=$(signal) -serial chardev:s0
endif
ifeq ($(mode),debug)
qemu-opts += -s -S
endif
ifeq ($(trace),e1000)
qemu-opts += -trace 'e1000*'
endif
# In debug mode, open another terminal with the following command
# and type `continue` to start the boot process:
# > gdb target/x86_64-moros/debug/moros -ex "target remote :1234"
qemu:
qemu-system-x86_64 $(qemu-opts)
test:
cargo test --release --lib --no-default-features --features serial -- \
-m $(memory) -cpu core2duo -display none -serial stdio \
-device isa-debug-exit,iobase=0xF4,iosize=0x04
website:
cd www && sh build.sh
spell:
cd dsk/lib/spell && sh build.sh
pkg:
ls -1 dsk/var/pkg | grep -v index.html > dsk/var/pkg/index.html
pkg-kernel:
cp $(bin) dsk/ini/kernel.img
sh run/deflate.sh dsk/ini/kernel.img
clean:
cargo clean
rm -f www/*.html www/images/*.png