-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
106 lines (90 loc) · 2.29 KB
/
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
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
CC = i686-elf-gcc
NASM = nasm
LD = i686-elf-ld
QEMU = qemu-system-x86_64
GRUB = /usr/bin/grub-mkrescue
BOCHS = bochs
SRC = ./src
ISO = ./iso
UTILS = $(SRC)/utils
DRIVERS = $(SRC)/drivers
BIOS = $(DRIVERS)/bios
GDT = $(DRIVERS)/gdt
IDT = $(DRIVERS)/idt
GUI = $(DRIVERS)/vesa
VESA_CLI = $(DRIVERS)/vesa_cli
KEYBOARD = $(DRIVERS)/keyboard
PIC = $(DRIVERS)/pic
FS = $(DRIVERS)/fs
STRING_LIB = $(UTILS)/string/libstring.a
MEMORY_LIB = $(UTILS)/memory/libmemory.a
LIBS = $(STRING_LIB) $(MEMORY_LIB)
INCLUDES = -I $(SRC) -I $(UTILS)
C_FLAGS = -W -Wall -Wextra -ffreestanding $(INCLUDES)
LD_FLAGS = -T config/linker.ld -nostdlib -m elf_i386
ASM_FLAGS = -f elf32
QEMU_FLAGS = -d int -no-reboot
BOCHS_FLAGS = -f bochsrc -q
C_SRC = src/kernel.c \
$(GDT)/gdt.c \
$(BIOS)/32/bios32.c \
$(UTILS)/VGA/clear.c \
$(UTILS)/VGA/print.c \
$(IDT)/handler.c \
$(IDT)/idt.c \
$(IDT)/init.c \
$(PIC)/io.c \
$(PIC)/remap.c \
$(KEYBOARD)/init.c \
$(KEYBOARD)/handler.c \
$(KEYBOARD)/scancode.c \
$(GUI)/draw_square.c \
$(GUI)/init.c \
$(GUI)/put_pixel.c \
$(GUI)/print.c \
$(VESA_CLI)/init.c \
$(VESA_CLI)/update.c \
$(VESA_CLI)/draw.c \
$(VESA_CLI)/clear.c \
$(VESA_CLI)/prompt.c \
$(VESA_CLI)/buffer.c \
$(VESA_CLI)/commands.c \
$(VESA_CLI)/commands/launch.c \
$(VESA_CLI)/commands/echo.c \
$(VESA_CLI)/commands/clear.c \
$(FS)/init.c \
$(FS)/file.c \
$(FS)/files.c
ASM_SRC = $(BIOS)/32/interrupts.asm \
$(SRC)/boot_sector.asm \
$(GDT)/load_gdt.asm \
$(IDT)/interrupts.asm \
$(GUI)/font/TacOS_font.asm
OBJ = $(C_SRC:.c=.o) $(ASM_SRC:.asm=.o)
TARGET_BIN = $(ISO)/TacOS.bin
TARGET_ISO = $(TARGET_BIN:.bin=.iso)
all: deps build
deps:
make -C $(UTILS)/string
make -C $(UTILS)/memory
build: $(OBJ)
$(LD) $(LD_FLAGS) -o $(TARGET_BIN) $(OBJ) $(LIBS)
$(GRUB) -o $(TARGET_ISO) .
run:
$(QEMU) $(QEMU_FLAGS) $(TARGET_ISO)
run_bochs:
$(BOCHS) $(BOCHS_FLAGS)
clean:
make -C $(UTILS)/string clean
make -C $(UTILS)/memory clean
$(RM) $(OBJ)
fclean: clean
make -C $(UTILS)/string fclean
make -C $(UTILS)/memory fclean
$(RM) $(TARGET_BIN)
$(RM) $(TARGET_ISO)
re: fclean all
%.o: %.c
$(CC) -c $(C_FLAGS) -o $@ $<
%.o: %.asm
$(NASM) $(ASM_FLAGS) -o $@ $<