-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
37 lines (29 loc) · 856 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
#CC=i686-elf-gcc
CC=gcc -m32
ASMCC=nasm
QEMU= qemu-system-i386
IDIR=include
BINDIR = bin
TARGETDIR = .
SRCDIR = src
objects = boot.o helpers.o interrupt.o page.o stdlib.o monitor.o idt.o main.o gdt.o
CFLAGS=-I $(IDIR) -std=gnu99 -ffreestanding -O2 -Wall -Wextra -fno-pie
ASMFLAGS= -felf32
rickos.bin: $(objects)
$(CC) -T linker.ld -o $(TARGETDIR)/$@ -ffreestanding -O2 -nostdlib $(patsubst %.o, $(BINDIR)/%.o, $^)
%.o: $(SRCDIR)/%.c #C recipe
$(CC) $(CFLAGS) -o $(BINDIR)/$@ -c $<
%.o: $(SRCDIR)/%.s #NASM recipe
$(ASMCC) $(ASMFLAGS) -o $(BINDIR)/$@ $<
.PHONY: clean run gdb all remake
all:
mkdir -p $(BINDIR)
make rickos.bin
remake:
clean all
clean: #clean target
rm $(TARGETDIR)/rickos.bin $(patsubst %.o, $(BINDIR)/%.o, $(objects))
run: all
$(QEMU) -kernel $(TARGETDIR)/rickos.bin
gdb: all
$(QEMU) -s -S -kernel $(TARGETDIR)/rickos.bin