-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
78 lines (54 loc) · 1.58 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
ARCH=i386
CROSS=cross
CC=$(CROSS)/bin/$(ARCH)-elf-gcc
LD=$(CROSS)/bin/$(ARCH)-elf-ld
AS=nasm
GRUB_MKRESCUE?=grub-mkrescue
LIBGCC=$(CROSS)/lib/gcc/$(ARCH)-elf/8.2.0/libgcc.a
CWARNINGS= -Wno-unused-variable -Wno-attributes -Wno-unused-parameter -Wno-pointer-to-int-cast -Wno-int-conversion
CFLAGS=-m32 -std=c99 -nostdlib -nostartfiles -nodefaultlibs -ffreestanding -fno-builtin -fno-omit-frame-pointer $(CWARNINGS) $(CINCLUDES) -Isrc/include/
DFLAGS=-g -DDEBUG -O0
ASFLAGS=-f elf
LDFLAGS=-melf_i386 -nostdlib -T src/arch/$(ARCH)/linker.ld -Map=build/mandelbrotos.map
CSOURCES:=\
$(wildcard src/kernel/*.c)\
src/string/string.c\
$(wildcard src/arch/$(ARCH)/*.c)
ASOURCES:=\
src/arch/$(ARCH)/boot.S\
NASMSOURCES:=\
src/arch/$(ARCH)/interrupts.asm\
COBJECTS:=$(CSOURCES:%.c=%.o)
AOBJECTS:=$(ASOURCES:%.S=%.ao)
NASMOBJECTS:=$(NASMSOURCES:%.asm=%.aso)
OBJS=\
$(ARCH_OBJS)\
$(KERNEL_OBJS)\
KERNEL=build/mandelbrotos.elf
STAGE2=build/stage2_eltorito
GENISOIMAGE=genisoimage
ISO=build/mandelbrotos.iso
QEMU=qemu-system-x86_64 -cdrom $(ISO)
.PHONY: all build clean qemu
all: $(ISO)
$(ISO): $(KERNEL)
mkdir -p iso/boot/grub
cp $(KERNEL) iso/boot/$(notdir $(KERNEL))
cp resources/grub.cfg iso/boot/grub
$(GRUB_MKRESCUE) -o $(ISO) iso
$(KERNEL): $(COBJECTS) $(AOBJECTS) $(NASMOBJECTS)
mkdir -p build
$(LD) $(LDFLAGS) $(AOBJECTS) $(COBJECTS) $(NASMOBJECTS) $(LIBGCC) -o $@
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
%.ao: %.S
$(CC) $(CFLAGS) -o $@ -c $<
%.aso: %.asm
$(AS) $(ASFLAGS) -o $@ $<
qemu: $(ISO)
$(QEMU)
clean:
rm -rf iso
rm -rf build
find src/ -type f -name "*o" -delete
rm -f $(ISO)