-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
43 lines (32 loc) · 920 Bytes
/
Makefile
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
#TOOL INPUT
BOOT=src/boot/boot.asm
KERNEL=src/kernel/kernel.c
KERNEL_ENTRY=src/kernel/kernel_entry.asm
INCLUDE=include/
BIN=bin
#TOOLS
EMULATOR=qemu-system-x86_64
NASM = /usr/bin/nasm
CROSSCOMPILER= i386-elf-gcc
LINKER=i386-elf-ld
#TOOL OPTIONS
EFLAGS=-boot c ### EMULATOR FLAG
FORMAT=bin
CCFLAGS=-ffreestanding -c ### CROSS COMPILER ==> To compile system-independent code
#TOOL OUTPUT
BOOT_SECT=bin/boot_sect.bin
MAIN_KERNEL=bin/kernel.bin
OS = bin/os_image.bin
###############################################################################
run: $(OS)
$(EMULATOR) -fda $<
$(OS): $(BOOT_SECT) $(MAIN_KERNEL)
cat $^ > $@
$(BOOT_SECT): $(BOOT)
$(NASM) $< -f $(FORMAT) -o $@
$(MAIN_KERNEL): kernel_entry.o kernel.o
$(LINKER) -o $@ -Ttext 0x1000 $^ --oformat binary
kernel.o: $(KERNEL)
$(CROSSCOMPILER) $(CCFLAGS) $< -o $@
kernel_entry.o: $(KERNEL_ENTRY)
$(NASM) $< -f elf -o $@