~kameliya/syso

syso/Makefile -rw-r--r-- 883 bytes
bffd41fe — Yuki Izumi ugly idt 4 years ago
                                                                                
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
QEMU = qemu-system-x86_64
LD = x86_64-elf-ld
AS = x86_64-elf-as

ASFLAGS = -gstabs

BUILD=build
HDD=hdd.img
TARGET=syso

TARGET = $(BUILD)/syso
MENU = menu.lst
COPYDEST = C:/syso
ASMS = entry.s
ASMS_OUT = $(ASMS:%.s=$(BUILD)/%.s.o)

LINK_SCRIPT = syso.ld
CARGO_OUT = target/x86_64-unknown-linux-gnu/debug/libsyso.a

all: $(TARGET)-copy

run: $(TARGET)-copy
	$(QEMU) -d int,cpu_reset -D debug -debugcon stdio -boot order=c -drive file=$(HDD),index=0,media=disk,format=raw -net none -s & \
	osascript -e "`cat foreground`"; \
  wait

$(TARGET)-copy: $(TARGET)
	MTOOLSRC=mtoolsrc mcopy -D o $(TARGET) $(COPYDEST)

.PHONY: $(TARGET) clean

$(TARGET): $(ASMS_OUT)
	cargo build --target=x86_64-unknown-linux-gnu
	$(LD) -n --gc-sections -T $(LINK_SCRIPT) -o $(TARGET) $(ASMS_OUT) $(CARGO_OUT)

$(BUILD)/%.s.o: %.s
	$(AS) $(ASFLAGS) $< -o $@

clean:
	-cargo clean
	-rm $(ASMS_OUT) $(TARGET)