-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
58 lines (44 loc) · 898 Bytes
/
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
# File: Makefile
# File Created: 09 Apr 2019 10:58
# By Maxence Moutoussamy <[email protected]>
LINKER_CFG_FILE = linker.ld
CC = i686-elf-gcc
CASM = nasm
CFLAGS = \
-std=gnu99 \
-ffreestanding \
-O2 \
-Wall \
-Wextra \
-I ./include
ASMFLAGS = \
-f elf32
CSOURCES = \
src/kernel.c \
src/tty.c
ASMSOURCES = \
src/boot.S
OBJS = $(CSOURCES:.c=.o) $(ASMSOURCES:.S=.o)
os.iso: kernel grub.cfg
mkdir -p iso/boot/grub
cp kernel iso/boot/kernel
cp grub.cfg iso/boot/grub/grub.cfg
grub-mkrescue -o $@ iso
kernel: $(LINKER_CFG_FILE) $(OBJS)
echo $(OBJS)
i686-elf-gcc -T linker.ld -o $@ -ffreestanding -O2 -nostdlib $(OBJS) -lgcc
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.S
$(CASM) $(ASMFLAGS) $< -o $@
.PHONY: run
run: os.iso
qemu-system-i386 -cdrom os.iso
.PHONY: clean
clean:
rm -f $(OBJS)
rm -rf iso
.PHONY: fclean
fclean: clean
rm -f kernel
rm -f os.iso