-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
executable file
·66 lines (45 loc) · 1.55 KB
/
makefile
File metadata and controls
executable file
·66 lines (45 loc) · 1.55 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
AS=nasm
PLATFORM=$(shell uname)
$(info $(PLATFORM))
ifeq ($(PLATFORM), Linux)
GCC=x86_64-linux-gnu-gcc
LD=x86_64-linux-gnu-ld
endif
ifeq ($(PLATFORM), Darwin)
GCC=x86_64-elf-gcc
LD=x86_64-elf-ld
endif
GCC_OPTIONS = -m32 -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-rtti -fno-stack-protector -fleading-underscore -fno-asynchronous-unwind-tables -fno-pie
all: kernel.bin
clean:
rm -f *.o *.bin
run:
qemu-system-x86_64 -kernel kernel.bin -serial stdio
debug:
qemu-system-x86_64 -s -S -kernel kernel.bin
# ==== KERNEL ENTRY POINT ====
start.o: start.asm
$(AS) -f elf -o start.o start.asm
utils.o: utils.C utils.H
$(GCC) $(GCC_OPTIONS) -c -o utils.o utils.C
assert.o: assert.C assert.H
$(GCC) $(GCC_OPTIONS) -c -o assert.o assert.C
# ==== VARIOUS LOW-LEVEL STUFF =====
machine.o: machine.C machine.H
$(GCC) $(GCC_OPTIONS) -c -o machine.o machine.C
machine_low.o: machine_low.asm machine_low.H
$(AS) -f elf -o machine_low.o machine_low.asm
# ==== DEVICES =====
console.o: console.C console.H
$(GCC) $(GCC_OPTIONS) -c -o console.o console.C
# ==== MEMORY =====
cont_frame_pool.o: cont_frame_pool.C cont_frame_pool.H
$(GCC) $(GCC_OPTIONS) -c -o cont_frame_pool.o cont_frame_pool.C
# ==== KERNEL MAIN FILE =====
kernel.o: kernel.C console.H
$(GCC) $(GCC_OPTIONS) -c -o kernel.o kernel.C
kernel.bin: start.o utils.o kernel.o assert.o console.o \
cont_frame_pool.o machine.o machine_low.o
$(LD) -melf_i386 -T linker.ld -o kernel.bin start.o utils.o \
kernel.o assert.o console.o \
cont_frame_pool.o machine.o machine_low.o