blob: f9c7c06cffeed0aec3450e2bbaf4548e363be11f (
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
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
|
BUILD_DIR = ./build
BOOT_ASM =./src/boot/bootloader.asm
KERNEL_ASM_OBJ = $(BUILD_DIR)/kernel.asm.o
KERNEL_OBJ = $(BUILD_DIR)/kernel.o
KLIB_FILES = ./src/lib/string.c
KOBJ_LIBS = ./build/string.o
KOBJ_FILES = $(KERNEL_ASM_OBJ) \
$(KERNEL_OBJ) \
./build/vga.o \
./build/idt/idt.asm.o \
./build/idt/idt.o \
./build/io/io.asm.o \
./build/mm/heap.o \
./build/mm/kernel_heap.o \
./build/mm/paging.asm.o \
./build/mm/paging.o \
./build/drivers/ata.o \
./build/block/block.o \
./build/fs/path.o
BOOT_TGT =./bin/boot.bin
KERNEL_TGT = ./bin/kernel.bin
BIN_TGT = $(BOOT_TGT) $(KERNEL_TGT)
INCLUDES = -I ./src/include
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_TGT)
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
./bin/kernel.bin: $(KOBJ_FILES)
i686-elf-ld -g -relocatable $(KOBJ_FILES) $(KOBJ_LIBS) -o $(BUILD_DIR)/cemOS.o
i686-elf-gcc $(FLAGS) -T ./src/linker.ld -o ./bin/kernel.bin -ffreestanding -O0 -nostdlib $(BUILD_DIR)/cemOS.o
./bin/boot.bin: $(BOOT_ASM)
nasm -f bin $(BOOT_ASM) -o $(BOOT_TGT)
$(BUILD_DIR)/kernel.asm.o: ./src/kernel.asm
nasm -f elf -g ./src/kernel.asm -o $(BUILD_DIR)/kernel.asm.o
$(BUILD_DIR)/kernel.o: ./src/kernel.c ./build/vga.o $(KOBJ_LIBS)
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/kernel.c -o $(BUILD_DIR)/kernel.o
$(BUILD_DIR)/vga.o: ./src/vga.c $(KOBJ_LIBS)
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/vga.c -o $(BUILD_DIR)/vga.o
$(BUILD_DIR)/idt/idt.asm.o: ./src/idt/idt.asm
nasm -f elf -g ./src/idt/idt.asm -o $(BUILD_DIR)/idt/idt.asm.o
$(BUILD_DIR)/idt/idt.o: ./src/idt/idt.c ./build/vga.o $(KOBJ_LIBS)
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/idt/idt.c -o $(BUILD_DIR)/idt/idt.o
$(BUILD_DIR)/io/io.asm.o: ./src/io/io.asm
nasm -f elf -g ./src/io/io.asm -o $(BUILD_DIR)/io/io.asm.o
$(BUILD_DIR)/mm/heap.o: ./src/mm/heap.c
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/mm/heap.c -o $(BUILD_DIR)/mm/heap.o
$(BUILD_DIR)/mm/kernel_heap.o: ./src/mm/kernel_heap.c
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/mm/kernel_heap.c -o $(BUILD_DIR)/mm/kernel_heap.o
$(KOBJ_LIBS):
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/lib/string.c -o $(BUILD_DIR)/string.o
$(BUILD_DIR)/mm/paging.asm.o: ./src/mm/paging.asm
nasm -f elf -g ./src/mm/paging.asm -o $(BUILD_DIR)/mm/paging.asm.o
$(BUILD_DIR)/mm/paging.o: ./src/mm/paging.c
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/mm/paging.c -o $(BUILD_DIR)/mm/paging.o
$(BUILD_DIR)/drivers/ata.o: ./src/drivers/ata.c
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/drivers/ata.c -o $(BUILD_DIR)/drivers/ata.o
$(BUILD_DIR)/block/block.o: ./src/block/block.c
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/block/block.c -o $(BUILD_DIR)/block/block.o
$(BUILD_DIR)/fs/path.o: ./src/fs/path.c
i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/fs/path.c -o $(BUILD_DIR)/fs/path.o
clean:
rm -f $(BOOT_TGT)
rm -f bin/kernel.bin
rm -f build/cemOS.o
rm -f build/kernel.asm.o
rm -f build/kernel.o
rm -f build/vga.o
rm -f build/string.o
rm -f build/idt/idt.asm.o
rm -f build/idt/idt.o
rm -f build/io/io.asm.o
rm -f build/mm/*.o
rm -f build/drivers/*.o
rm -f build/block/*.o
rm -f build/fs/*.o
rm -f bin/os.bin
|