blob: 15540307f80da766f22d1331dd8ab277e4ddd4a2 (
plain)
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
|
arch ?= x86_64
kernel := build/kernel-$(arch).bin
iso := build/os-$(arch).iso
linker_script := arch/$(arch)/boot/linker.ld
grub_cfg := arch/$(arch)/boot/grub.cfg
assembly_source_files := $(wildcard arch/$(arch)/boot/*.asm)
assembly_object_files := $(patsubst arch/$(arch)/boot/%.asm, \
build/arch/$(arch)/%.o, $(assembly_source_files))
dats_source_files := $(wildcard kernel/*.dats kernel/**/*.dats)
dats_object_files := $(patsubst kernel/%.dats, \
build/kernel/%_dats.o, $(dats_source_files))
PATSCC=acc pc
INCLUDE_ATS :=
INCLUDE_ATS += -I${PATSHOME}
INCLUDE_ATS += -I${PATSHOME}/ccomp/runtime
CLFAGS_ATS :=
CFLAGS_ATS += -D_ATS_CCOMP_RUNTIME_NONE_
CFLAGS_ATS += -D_ATS_CCOMP_EXCEPTION_NONE_
CFLAGS=-ffreestanding -mcmodel=large -mno-red-zone -mgeneral-regs-only -m64 -fpack-struct
.PHONY: all clean run iso
all: $(kernel)
clean:
@rm -r build
run: $(iso)
@qemu-system-x86_64 -cdrom $(iso)
iso: $(iso)
$(iso): $(kernel) $(grub_cfg)
@mkdir -p build/isofiles/boot/grub
@cp $(kernel) build/isofiles/boot/kernel.bin
@cp $(grub_cfg) build/isofiles/boot/grub
@grub-mkrescue -o $(iso) build/isofiles 2> /dev/null
@rm -r build/isofiles
$(kernel): $(assembly_object_files) $(linker_script) $(dats_object_files)
@ld -n -T $(linker_script) -o $(kernel) $(assembly_object_files) $(dats_object_files) -nostdlib -z noexecstack
# compile assembly files
build/arch/$(arch)/%.o: arch/$(arch)/boot/%.asm
@mkdir -p $(shell dirname $@)
@nasm -felf64 $< -o $@
build/kernel/%_dats.c: kernel/%.dats
@mkdir -p $(shell dirname $@)
$(PATSCC) -ccats -o $@ $<
@mv *_dats.c $@
build/kernel/%.o: build/kernel/%.c
@mkdir -p $(shell dirname $@)
$(CC) $(INCLUDE_ATS) $(CFLAGS) $(CFLAGS_ATS) -O2 -c $< -o $@
|