-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
94 lines (76 loc) · 3.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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: rbourgea <rbourgea@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/04/24 16:00:27 by rbourgea #+# #+# #
# Updated: 2022/06/20 12:20:53 by rbourgea ### ########.fr #
# #
# **************************************************************************** #
# **************************************************************************** #
# 🎨 COLORS
# **************************************************************************** #
GREY = \033[030m
RED = \033[031m
GREEN = \033[032m
YELLOW = \033[033m
BLUE = \033[034m
MAGENTA = \033[035m
CYAN = \033[036m
BOLD = \033[1m
RESET = \033[0m
# **************************************************************************** #
# 💾 VARIABLES
# **************************************************************************** #
KERNEL_OUT = build/rbourgea_kfs.bin
ISO_OUT = build/rbourgea_kfs.iso
BOOT = src/boot.s
KERNEL = src/kernel.c
LINKER = src/linker.ld
FLAGS = -fno-builtin -fno-builtin -fno-builtin -nostdlib -nodefaultlibs
# **************************************************************************** #
# 📖 RULES
# **************************************************************************** #
all: build
build: fclean
@mkdir -p build
@nasm -f elf32 ${BOOT} -o build/boot.o
@gcc -m32 -ffreestanding ${FLAGS} -c ${KERNEL} -o build/kernel.o
@echo "$(BOLD)$(GREEN)[✓] KERNEL BUILD DONE$(RESET)"
@ld -m elf_i386 -T ${LINKER} -o ${KERNEL_OUT} build/boot.o build/kernel.o
@echo "$(BOLD)$(GREEN)[✓] KERNEL LINK DONE$(RESET)"
build_debug: fclean
@echo "$(BOLD)$(YELLOW)[✓] KERNEL DEBUG MODE ON$(RESET)"
@mkdir -p build
@nasm -f elf32 ${BOOT} -o build/boot.o
@gcc -m32 -ffreestanding -c ${FLAGS} ${KERNEL} -o build/kernel.o -ggdb
@echo "$(BOLD)$(GREEN)[✓] KERNEL BUILD DONE$(RESET)"
@ld -m elf_i386 -T ${LINKER} -o ${KERNEL_OUT} build/boot.o build/kernel.o
@echo "$(BOLD)$(GREEN)[✓] KERNEL LINK DONE$(RESET)"
run: build
@qemu-system-i386 -kernel ${KERNEL_OUT} -monitor stdio
@echo "\n$(BOLD)$(CYAN)[✓] KERNEL EXIT DONE$(RESET)"
debug: build_debug
@qemu-system-i386 -kernel ${KERNEL_OUT} -s -S &
@gdb -x .gdbinit
@echo "\n$(BOLD)$(CYAN)[✓] KERNEL DEBUG EXIT DONE$(RESET)"
iso: build
@mkdir -p build/iso/boot/grub
@cp grub.cfg build/iso/boot/grub
@cp ${KERNEL_OUT} build/iso/boot
@grub-mkrescue -o ${ISO_OUT} build/iso
@echo "$(BOLD)$(GREEN)[✓] KERNEL ISO BUILD$(RESET)"
run-iso: iso
@qemu-system-i386 -cdrom ${ISO_OUT}
@echo "\n$(BOLD)$(CYAN)[✓] KERNEL EXIT DONE$(RESET)"
clean:
@rm -rf $(KERNEL_OUT) $(ISO_OUT)
@echo "$(BOLD)$(RED)[♻︎] DELETE KERNEL DONE$(RESET)"
fclean:
clear
@rm -rf build/
@echo "$(BOLD)$(RED)[♻︎] DELETE BUILD/ DONE$(RESET)"
re: fclean all
.PHONY: all clean fclean re