-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathMakefile
More file actions
166 lines (123 loc) · 7.95 KB
/
Makefile
File metadata and controls
166 lines (123 loc) · 7.95 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# PeachOS 32-Bit Kernel project
# Copyright (C) 2026 Daniel McCarthy <daniel@dragonzap.com>
# This file is part of th PeachOS Kernel.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License version 2 for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <https://www.gnu.org/licenses/>.
#
# For full source code, documentation, and structured learning,
# see the official kernel development video course:
# https://dragonzap.com/course/developing-a-multithreaded-kernel-from-scratch
#
# The new part two course is now here
# Learn to extend your kernel into 64-bit long mode with GUI
# Get all modules today here: https://dragonzap.com/offer/developing-a-multithreaded-kernel-from-scratch-part-two-full-series
#
# Or get them individually here:
# MODULE 1 https://dragonzap.com/course/developing-a-multithreaded-kernel-from-scratch-part-two-module-one
# MODULE 2 https://dragonzap.com/course/developing-a-multithreaded-kernel-from-scratch-part-two-module-two
#
FILES = ./build/kernel.asm.o ./build/kernel.o ./build/loader/formats/elf.o ./build/loader/formats/elfloader.o ./build/isr80h/isr80h.o ./build/isr80h/process.o ./build/isr80h/heap.o ./build/keyboard/keyboard.o ./build/keyboard/classic.o ./build/isr80h/io.o ./build/isr80h/misc.o ./build/disk/disk.o ./build/disk/streamer.o ./build/task/process.o ./build/task/task.o ./build/task/task.asm.o ./build/task/tss.asm.o ./build/fs/pparser.o ./build/fs/file.o ./build/fs/fat/fat16.o ./build/string/string.o ./build/idt/idt.asm.o ./build/idt/idt.o ./build/memory/memory.o ./build/io/io.asm.o ./build/gdt/gdt.o ./build/gdt/gdt.asm.o ./build/memory/heap/heap.o ./build/memory/heap/kheap.o ./build/memory/paging/paging.o ./build/memory/paging/paging.asm.o
INCLUDES = -I./src
FLAGS = -g -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
all: ./bin/boot.bin ./bin/kernel.bin user_programs
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=1048576 count=16 >> ./bin/os.bin
sudo mount -t vfat ./bin/os.bin /mnt/d
# Copy a file over
sudo cp ./hello.txt /mnt/d
sudo cp ./programs/blank/blank.elf /mnt/d
sudo cp ./programs/shell/shell.elf /mnt/d
sudo umount /mnt/d
./bin/kernel.bin: $(FILES)
i686-elf-ld -g -relocatable $(FILES) -o ./build/kernelfull.o
i686-elf-gcc $(FLAGS) -T ./src/linker.ld -o ./bin/kernel.bin -ffreestanding -O0 -nostdlib ./build/kernelfull.o
./bin/boot.bin: ./src/boot/boot.asm
nasm -f bin ./src/boot/boot.asm -o ./bin/boot.bin
./build/kernel.asm.o: ./src/kernel.asm
nasm -f elf -g ./src/kernel.asm -o ./build/kernel.asm.o
./build/kernel.o: ./src/kernel.c
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/kernel.c -o ./build/kernel.o
./build/idt/idt.asm.o: ./src/idt/idt.asm
nasm -f elf -g ./src/idt/idt.asm -o ./build/idt/idt.asm.o
./build/loader/formats/elf.o: ./src/loader/formats/elf.c
i686-elf-gcc $(INCLUDES) -I./src/loader/formats $(FLAGS) -std=gnu99 -c ./src/loader/formats/elf.c -o ./build/loader/formats/elf.o
./build/loader/formats/elfloader.o: ./src/loader/formats/elfloader.c
i686-elf-gcc $(INCLUDES) -I./src/loader/formats $(FLAGS) -std=gnu99 -c ./src/loader/formats/elfloader.c -o ./build/loader/formats/elfloader.o
./build/gdt/gdt.o: ./src/gdt/gdt.c
i686-elf-gcc $(INCLUDES) -I./src/gdt $(FLAGS) -std=gnu99 -c ./src/gdt/gdt.c -o ./build/gdt/gdt.o
./build/gdt/gdt.asm.o: ./src/gdt/gdt.asm
nasm -f elf -g ./src/gdt/gdt.asm -o ./build/gdt/gdt.asm.o
./build/isr80h/isr80h.o: ./src/isr80h/isr80h.c
i686-elf-gcc $(INCLUDES) -I./src/isr80h $(FLAGS) -std=gnu99 -c ./src/isr80h/isr80h.c -o ./build/isr80h/isr80h.o
./build/isr80h/heap.o: ./src/isr80h/heap.c
i686-elf-gcc $(INCLUDES) -I./src/isr80h $(FLAGS) -std=gnu99 -c ./src/isr80h/heap.c -o ./build/isr80h/heap.o
./build/isr80h/misc.o: ./src/isr80h/misc.c
i686-elf-gcc $(INCLUDES) -I./src/isr80h $(FLAGS) -std=gnu99 -c ./src/isr80h/misc.c -o ./build/isr80h/misc.o
./build/isr80h/io.o: ./src/isr80h/io.c
i686-elf-gcc $(INCLUDES) -I./src/isr80h $(FLAGS) -std=gnu99 -c ./src/isr80h/io.c -o ./build/isr80h/io.o
./build/isr80h/process.o: ./src/isr80h/process.c
i686-elf-gcc $(INCLUDES) -I./src/isr80h $(FLAGS) -std=gnu99 -c ./src/isr80h/process.c -o ./build/isr80h/process.o
./build/keyboard/keyboard.o: ./src/keyboard/keyboard.c
i686-elf-gcc $(INCLUDES) -I./src/keyboard $(FLAGS) -std=gnu99 -c ./src/keyboard/keyboard.c -o ./build/keyboard/keyboard.o
./build/keyboard/classic.o: ./src/keyboard/classic.c
i686-elf-gcc $(INCLUDES) -I./src/keyboard $(FLAGS) -std=gnu99 -c ./src/keyboard/classic.c -o ./build/keyboard/classic.o
./build/idt/idt.o: ./src/idt/idt.c
i686-elf-gcc $(INCLUDES) -I./src/idt $(FLAGS) -std=gnu99 -c ./src/idt/idt.c -o ./build/idt/idt.o
./build/memory/memory.o: ./src/memory/memory.c
i686-elf-gcc $(INCLUDES) -I./src/memory $(FLAGS) -std=gnu99 -c ./src/memory/memory.c -o ./build/memory/memory.o
./build/task/process.o: ./src/task/process.c
i686-elf-gcc $(INCLUDES) -I./src/task $(FLAGS) -std=gnu99 -c ./src/task/process.c -o ./build/task/process.o
./build/task/task.o: ./src/task/task.c
i686-elf-gcc $(INCLUDES) -I./src/task $(FLAGS) -std=gnu99 -c ./src/task/task.c -o ./build/task/task.o
./build/task/task.asm.o: ./src/task/task.asm
nasm -f elf -g ./src/task/task.asm -o ./build/task/task.asm.o
./build/task/tss.asm.o: ./src/task/tss.asm
nasm -f elf -g ./src/task/tss.asm -o ./build/task/tss.asm.o
./build/io/io.asm.o: ./src/io/io.asm
nasm -f elf -g ./src/io/io.asm -o ./build/io/io.asm.o
./build/memory/heap/heap.o: ./src/memory/heap/heap.c
i686-elf-gcc $(INCLUDES) -I./src/memory/heap $(FLAGS) -std=gnu99 -c ./src/memory/heap/heap.c -o ./build/memory/heap/heap.o
./build/memory/heap/kheap.o: ./src/memory/heap/kheap.c
i686-elf-gcc $(INCLUDES) -I./src/memory/heap $(FLAGS) -std=gnu99 -c ./src/memory/heap/kheap.c -o ./build/memory/heap/kheap.o
./build/memory/paging/paging.o: ./src/memory/paging/paging.c
i686-elf-gcc $(INCLUDES) -I./src/memory/paging $(FLAGS) -std=gnu99 -c ./src/memory/paging/paging.c -o ./build/memory/paging/paging.o
./build/memory/paging/paging.asm.o: ./src/memory/paging/paging.asm
nasm -f elf -g ./src/memory/paging/paging.asm -o ./build/memory/paging/paging.asm.o
./build/disk/disk.o: ./src/disk/disk.c
i686-elf-gcc $(INCLUDES) -I./src/disk $(FLAGS) -std=gnu99 -c ./src/disk/disk.c -o ./build/disk/disk.o
./build/disk/streamer.o: ./src/disk/streamer.c
i686-elf-gcc $(INCLUDES) -I./src/disk $(FLAGS) -std=gnu99 -c ./src/disk/streamer.c -o ./build/disk/streamer.o
./build/fs/fat/fat16.o: ./src/fs/fat/fat16.c
i686-elf-gcc $(INCLUDES) -I./src/fs -I./src/fat $(FLAGS) -std=gnu99 -c ./src/fs/fat/fat16.c -o ./build/fs/fat/fat16.o
./build/fs/file.o: ./src/fs/file.c
i686-elf-gcc $(INCLUDES) -I./src/fs $(FLAGS) -std=gnu99 -c ./src/fs/file.c -o ./build/fs/file.o
./build/fs/pparser.o: ./src/fs/pparser.c
i686-elf-gcc $(INCLUDES) -I./src/fs $(FLAGS) -std=gnu99 -c ./src/fs/pparser.c -o ./build/fs/pparser.o
./build/string/string.o: ./src/string/string.c
i686-elf-gcc $(INCLUDES) -I./src/string $(FLAGS) -std=gnu99 -c ./src/string/string.c -o ./build/string/string.o
user_programs:
cd ./programs/stdlib && $(MAKE) all
cd ./programs/blank && $(MAKE) all
cd ./programs/shell && $(MAKE) all
user_programs_clean:
cd ./programs/stdlib && $(MAKE) clean
cd ./programs/blank && $(MAKE) clean
cd ./programs/shell && $(MAKE) clean
clean: user_programs_clean
rm -rf ./bin/boot.bin
rm -rf ./bin/kernel.bin
rm -rf ./bin/os.bin
rm -rf ${FILES}
rm -rf ./build/kernelfull.o