-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
148 lines (119 loc) · 4.24 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
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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: agrumbac <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2016/11/04 17:08:23 by agrumbac #+# #+# #
# Updated: 2019/06/07 00:44:33 by agrumbac ### ########.fr #
# #
# **************************************************************************** #
############################## VAR #############################################
ifeq ($(shell uname -s), Darwin)
CC = i386-elf-gcc
AR = i386-elf-ar
GRUB = i386-elf-grub
else
CC = gcc
AR = ar
GRUB = grub
endif
NAME = kfs
AS = nasm
ASFLAGS = -f elf
CFLAGS = -fno-builtin -fno-exceptions -fno-stack-protector \
-nostdlib -nodefaultlibs \
-std=gnu99 -ffreestanding -Wall -Wextra -Iincludes -m32 -g3
LDFLAGS = -ffreestanding -nostdlib -lgcc -m32
############################## SRC #############################################
SRC = boot/boot.s \
kernel/gdt_flush.s \
kernel/gdt.c \
kernel/idt_flush.s \
kernel/idt.c \
kernel/irq.s \
kernel/isr.s \
kernel/kernel.c \
kernel/keyboard_handler.c \
kernel/keyboard.s \
kernel/pic.c \
kernel/terminal.c
COBJ = $(SRC:.c=.o)
OBJ = $(COBJ:.s=.o)
libkfs = libkfs/libkfs.a
############################## COLORS ##########################################
BY = "\033[33;1m"
BR = "\033[31;1m"
BG = "\033[32;1m"
BB = "\033[34;1m"
BM = "\033[35;1m"
BC = "\033[36;1m"
BW = "\033[37;1m"
Y = "\033[33m"
R = "\033[31m"
G = "\033[32m"
B = "\033[34m"
M = "\033[35m"
C = "\033[36m"
W = "\033[0m""\033[32;1m"
WR = "\033[0m""\033[31;5m"
WY = "\033[0m""\033[33;5m"
X = "\033[0m"
############################## BUILD ###########################################
.PHONY: clean all re fclean
all: art ${NAME}
${libkfs}:
make -C libkfs CFLAGS+="$(CFLAGS)" AR=$(AR) CC+=$(CC) TARGET=../$@
${NAME}: ${libkfs} ${OBJ}
$(CC) -T linker.ld ${LDFLAGS} -o ${NAME} ${OBJ} -Llibkfs -lkfs
############################## MORE ############################################
check:
@$(GRUB)-file --is-x86-multiboot ${NAME} && echo ${B}[${NAME}] ${G}Multiboot OK!${X} || echo ${B}[${NAME}] ${R}NOT Multiboot${X}
iso: art ${NAME}
$(shell printf 'menuentry "${NAME}" {\n\
\tmultiboot /boot/${NAME}\n\
}\n' > grub.cfg)
/bin/mkdir -p isodir/boot/grub
/bin/cp ${NAME} isodir/boot/${NAME}
/bin/cp grub.cfg isodir/boot/grub/grub.cfg
$(GRUB)-mkrescue -o ${NAME}.iso isodir
run: ${NAME}
qemu-system-i386 -kernel ${NAME} -curses
debug: ${NAME}
qemu-system-i386 -kernel ${NAME} -curses -s -S
clean:
@echo ${R}Cleaning libkfs objs...${X}
make -C libkfs fclean
@echo ${R}Cleaning...${X}
/bin/rm -f ${OBJ}
/bin/rm -rf isodir
/bin/rm -f grub.cfg
/bin/rm -f ${NAME}.iso
fclean: clean
@echo ${R}Cleaning libkfs...${X}
make -C libkfs TARGET=../${libkfs} fclean
@echo ${R}Cleaning" "[${NAME}]...${X}
/bin/rm -f ${NAME}
re:
$(MAKE) fclean
$(MAKE) all
############################## ART #############################################
art:
@echo ${BB}
@echo " ,--. .--."
@echo " / \\\\"${WR}". ."${X}${BB}"/ \\"
@echo " / /\\ / \" \\ /\\ \\"
@echo " / _/ {~~v~~} \\_ \\"
@echo " / { | } \\"
@echo "; /\\{ | }/\\ \\"
@echo "| _/ { | } \\_ :"
@echo "| { | } | "${BG}" _ _______ ____"${BB}
@echo "| /{ | }\\ | "${BG}" | |/ / ___/ ___| "${BB}
@echo "| / { | } \\ | "${BG}" | ' /| |_ \___ \ "${BB}
@echo "| / { | } \\ | "${BG}" | . \| _| ___) |"${BB}
@echo "| \\ \\ | / / |"${BG}" |_|\_\_| |____/ "${BB}
@echo "| \\ \\ | / / |"
@echo "\\ \\ \\ | / / /"
@echo " \\ / ~~~~~ \\ /"${X}
.PHONY: all clean fclean re iso check art