-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
56 lines (41 loc) · 1020 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
# Compiler, Linker and Assembler
CC=clang
CXX=clang++
ASM=clang++
LD=clang++
# Compiler, Assembler and Linker flags go here
CCFLAGS=-Wall -ffreestanding -I include
CXXFLAGS+=CCFLAGS
LDFLAGS=
ASMFLAGS=-f bin
# Object and binary directories
SRCDIR=src
BINDIR=bin
OBJDIR=$(BINDIR)/obj
# Object files go here
OBJS=$(OBJDIR)/kernel.o
# Binaries go here
BIN=$(BINDIR)/kernel.bin $(BINDIR)/boot.bin
# Virtual Machines go here
VM=qemu-system-x86_64
# PHONY targets
.PHONY: bootstrap iso clean run
all: bootstrap $(OBJS) $(BIN)
# Compile C source files
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) -c $(CCFLAGS) -o $@ $<
# Compile C source files
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(CXX) -c $(CCFLAGS) -o $@ $<
$(OBJDIR)/%.asm.o: $(SRCDIR)/%.asm
$(ASM) $(ASMFLAGS) -o $@ $<
$(OBJDIR)/%.asm.o: $(SRCDIR)/%.s
$(ASM) $(ASMFLAGS) -o $@ $<
$(BIN): $(OBJS)
$(LD) $(LDFLAGS) -o $@ $<
bootstrap:
mkdir -p bin/obj
run: all
$(VM) bin/boot.bin
clean:
rm -rf bin/*.bin obj/*