-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (81 loc) · 3.99 KB
/
Makefile
File metadata and controls
97 lines (81 loc) · 3.99 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
# This Makefile is used to build the SimpleMultiThreadedOS project.
#
# Targets:
# all: Builds the bootloader and kernel binaries.
# clean: Cleans the bin and build directories.
#
# Files:
# - ./bin/boot.bin: The compiled bootloader binary.
# - ./bin/kernel.bin: The compiled kernel binary.
# - ./bin/os.bin: The combined bootloader and kernel binary.
# - ./build/kernel.asm.o: The compiled kernel assembly object file.
# - ./build/kernel.o: The compiled kernel C object file.
# - ./build/idt/idt.asm.o: The compiled IDT assembly object file.
# - ./build/idt/idt.o: The compiled IDT C object file.
# - ./build/io/io.asm.o: The compiled IO assembly object file.
# - ./build/memory/heap/heap.o: The compiled heap C object file.
# The files to compile.
FILES = ./build/kernel.asm.o ./build/kernel.o ./build/idt/idt.asm.o ./build/idt/idt.o ./build/memory/memory.o \
./build/io/io.asm.o ./build/memory/heap/heap.o ./build/memory/heap/kheap.o
# The include directories for the project.
INCLUDES = -I./src
INCLUDES += -I./src/idt
INCLUDES += -I./src/memory
INCLUDES += -I./src/io
INCLUDES += -I./src/memory/heap
# The compiler flags for the project.
FLAGS = -g -ggdb -g3 -ffreestanding -falign-jumps -falign-functions -falign-labels -falign-loops -fstrength-reduce -fomit-frame-pointer -finline-functions -Wno-unused-function -fno-builtin -Werror -Wno-unused-label -Wno-cpp -Wno-unused-parameter -nostdlib -nostartfiles -nodefaultlibs -Wall -O0 -Iinc
# The default target.
all: ./bin/boot.bin ./bin/kernel.bin
# Combine the bootloader and kernel binaries into a single binary.
rm -rf ./bin/os.bin
dd if=./bin/boot.bin >> ./bin/os.bin
dd if=./bin/kernel.bin >> ./bin/os.bin
dd if=/dev/zero bs=512 count=100 >> ./bin/os.bin
# The kernel binary target.
./bin/kernel.bin : $(FILES)
# Link the kernel object files into a single binary.
i686-elf-ld -g -relocatable $(FILES) -o ./build/kernelfull.o
# Compile the kernel binary.
i686-elf-gcc $(FLAGS) -T ./src/linker.ld -ffreestanding -O0 -nostdlib ./build/kernelfull.o -o ./bin/kernel.bin
# The bootloader binary target.
./bin/boot.bin: ./src/boot/boot.asm
# Compile the bootloader assembly file into a binary.
nasm -f bin -g ./src/boot/boot.asm -o ./bin/boot.bin
# The kernel assembly object file target.
./build/kernel.asm.o: ./src/kernel.asm
# Compile the kernel assembly file into an object file.
nasm -f elf -g ./src/kernel.asm -o ./build/kernel.asm.o
# The kernel C object file target.
./build/kernel.o: ./src/kernel.c
# Compile the kernel C file into an object file.
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/kernel.c -o ./build/kernel.o
# The IDT assembly object file target.
./build/idt/idt.asm.o: ./src/idt/idt.asm
# Compile the IDT assembly file into an object file.
nasm -f elf -g ./src/idt/idt.asm -o ./build/idt/idt.asm.o
# The IDT C object file target.
./build/idt/idt.o: ./src/idt/idt.c
# Compile the IDT C file into an object file.
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/idt/idt.c -o ./build/idt/idt.o
# The memory C object file target.
./build/memory/memory.o: ./src/memory/memory.c
# Compile the memory C file into an object file.
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/memory/memory.c -o ./build/memory/memory.o
# The IO assembly object file target.
./build/io/io.asm.o: ./src/io/io.asm
# Compile the IO assembly file into an object file.
nasm -f elf -g ./src/io/io.asm -o ./build/io/io.asm.o
# The heap C object file target.
./build/memory/heap/heap.o: ./src/memory/heap/heap.c
# Compile the heap C file into an object file.
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/memory/heap/heap.c -o ./build/memory/heap/heap.o
# The kheap C object file target.
./build/memory/heap/kheap.o: ./src/memory/heap/kheap.c
# Compile the kheap C file into an object file.
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/memory/heap/kheap.c -o ./build/memory/heap/kheap.o
# The clean target.
clean:
# Clean the bin and build directories.
rm -rf ./bin/*
rm -rf ./build/*