-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
38 lines (27 loc) · 801 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
WARNINGS := -Wall -Wextra -Werror
#WARNINGS := -w
CPP_COMPILER := i686-elf-g++
ASSEMBLER := nasm
PROJDIRS := src
CPPSRC := $(shell find $(PROJDIRS) -type f -name \*.cpp)
ASMSRC := $(shell find $(PROJDIRS) -type f -name \*.asm)
OBJFILES := $(patsubst %.cpp, %.o, $(CPPSRC)) $(patsubst %.asm, %.asm_o, $(ASMSRC))
CPPFLAGS := -std=c++17 -O2 -ffreestanding -mno-red-zone -fno-exceptions -fno-rtti
LINKERFLAGS := -nostdlib
ASMFLAGS := -f elf32
LINKER := src/link.ld
EXEC := os
.PHONY: all, run
%.o: %.cpp
$(CPP_COMPILER) $< $(WARNINGS) $(CPPFLAGS) -c -o $@
%.asm_o: %.asm
$(ASSEMBLER) $< $(ASMFLAGS) -o $@
all: $(OBJFILES)
$(CPP_COMPILER) $(OBJFILES) $(LINKERFLAGS) -o $(EXEC) -T $(LINKER)
clean:
-@rm $(OBJFILES) $(EXEC)
# Misc
run:
qemu-system-i386 $(EXEC)
hex:
hexdump -Cv $(EXEC)