-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (52 loc) · 1.69 KB
/
Makefile
File metadata and controls
67 lines (52 loc) · 1.69 KB
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
CC=i686-elf-gcc
OBJCOPY=i686-elf-objcopy
# OS-specific directory deletion command
ifeq ($(OS),Windows_NT)
RMDIR=rd /s /q
else
RMDIR=rm -rf
endif
BUILD_DIR=build
PLAT_DIR=plat
PORT_UTIL_DIR=utils
X86_OBJECTS = c_traps.o gdt.o main.o
PLAT_OBJECTS = irq_handlers.o pic.o pit.o terminal.o keyboard.o
ASM_OBJECTS = boot.o traps.o
UTIL_OBJECTS = string.o printf.o
# Collection of built objects (excluding test applications)
ALL_OBJECTS = $(PLAT_OBJECTS) $(X86_OBJECTS) $(ASM_OBJECTS) $(UTIL_OBJECTS)
BUILT_OBJECTS = $(patsubst %,$(BUILD_DIR)/%,$(ALL_OBJECTS))
# Search build/output directory for dependencies
vpath %.o ./$(BUILD_DIR)
# GCC flags
CFLAGS=-c -s -ffreestanding -std=gnu99 -Wall -Wextra -Werror \
-Wno-unused-parameter \
-Wno-unused-but-set-variable \
-Wno-unused-variable \
-Wno-sign-compare
#-O2
AFLAGS=$(CFLAGS) -x assembler-with-cpp
LFLAGS=-Tlinker.ld -Wall -ffreestanding -nostdlib
#################
# Build targets #
#################
main: $(BUILD_DIR) $(ALL_OBJECTS)
$(CC) $(LFLAGS) $(BUILT_OBJECTS) --output $(BUILD_DIR)/$@.bin
# Make build/output directory
$(BUILD_DIR):
mkdir $(BUILD_DIR)
# Platform C objects builder
$(PLAT_OBJECTS): %.o: $(PLAT_DIR)/%.c
$(CC) -c $(CFLAGS) -I. -I$(PORT_UTIL_DIR) $< -o $(BUILD_DIR)/$(notdir $@)
# Port C objects builder
$(X86_OBJECTS): %.o: %.c
$(CC) -c $(CFLAGS) -I. -Imachine/ -I$(PORT_UTIL_DIR) $< -o $(BUILD_DIR)/$(notdir $@)
# Port asm objects builder
$(ASM_OBJECTS): %.o: %.s
$(CC) -c $(AFLAGS) -I. $< -o $(BUILD_DIR)/$(notdir $@)
# Port C objects builder
$(UTIL_OBJECTS): %.o: $(PORT_UTIL_DIR)/%.c
$(CC) -c $(CFLAGS) -I. -I$(PORT_UTIL_DIR) $< -o $(BUILD_DIR)/$(notdir $@)
# Clean
clean:
$(RMDIR) build/*