-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (50 loc) · 973 Bytes
/
Makefile
File metadata and controls
60 lines (50 loc) · 973 Bytes
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
#
# Makefile for TestOS
#
# Compiler: GCC
# Assembler: NASM
# Linker: LD
#
TARGET := testos.bin
ALL_OBJ := environment.o \
boot.o \
_io.o \
kernel.o \
string.o \
idt.o \
_idt.o \
irq.o \
_irq.o \
pit.o \
kb.o
ALL_DEP := $(patsubst %.o,.%.d,$(ALL_OBJ))
#Assembly configuration
NASM := nasm
ASM_FLAGS := -f elf32
#C compilation configuration
CC := gcc
CFLAGS := -std=gnu99 -m32 -ffreestanding -O2 -Wall -Wextra
#Linker configuration
LD := ld
LD_FLAGS := -m elf_i386 -T linker.ld
#All rules
.PHONY : all testos clean
all : $(TARGET)
testos : $(TARGET)
#Rules
%.o : %.c
@echo " [C] $<"
@$(CC) $(CFLAGS) -MMD -MF $(patsubst %.o, .%.d, $@) \
-MT $(patsubst .%.d, %.o, $@) \
-c -o $(patsubst .%.d, %.o, $@) $<
%.o : %.asm
@echo " [NASM] $<"
@$(NASM) $(ASM_FLAGS) $< -o $@
testos.bin: $(ALL_OBJ)
@echo " [NASM] $@"
@$(LD) -o $@ $(LD_FLAGS) $^
clean:
rm -f $(ALL_DEP) $(ALL_OBJ)
ifneq ($(MAKECMDGOALS),clean)
-include $(ALL_DEP)
endif