-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
64 lines (52 loc) · 2.53 KB
/
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
57
58
59
60
61
62
63
COMPILER=gcc
SHELL=sh
OS_VERSION="0.1"
BUILD_DIR=./build
SRC_DIR=./src
PREV_KERNEL_PATH=./prev_kernels
INSTALL_TO=/farmix.bin
BUILD_ARGS= -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./$(SRC_DIR)/include -c
all: link
compile: clean
mkdir $(BUILD_DIR)
nasm -f elf -o $(BUILD_DIR)/start.o $(SRC_DIR)/start.asm
$(COMPILER) $(BUILD_ARGS) -D OS_VERSION='$(OS_VERSION)' -o $(BUILD_DIR)/main.o $(SRC_DIR)/main.c
$(COMPILER) $(BUILD_ARGS) -o $(BUILD_DIR)/scrn.o $(SRC_DIR)/scrn.c
$(COMPILER) $(BUILD_ARGS) -o $(BUILD_DIR)/mem_utils.o $(SRC_DIR)/memory/mem_utils.c
$(COMPILER) $(BUILD_ARGS) -o $(BUILD_DIR)/mem_detect.o $(SRC_DIR)/memory/mem_detect.c
$(COMPILER) $(BUILD_ARGS) -o $(BUILD_DIR)/mem_api.o $(SRC_DIR)/memory/mem_api.c
$(COMPILER) $(BUILD_ARGS) -o $(BUILD_DIR)/str_utils.o $(SRC_DIR)/str_utils.c
$(COMPILER) $(BUILD_ARGS) -o $(BUILD_DIR)/gdt.o $(SRC_DIR)/gdt.c
$(COMPILER) $(BUILD_ARGS) -o $(BUILD_DIR)/idt.o $(SRC_DIR)/idt.c
$(COMPILER) $(BUILD_ARGS) -o $(BUILD_DIR)/isrs.o $(SRC_DIR)/isrs.c
$(COMPILER) $(BUILD_ARGS) -o $(BUILD_DIR)/irq.o $(SRC_DIR)/irq.c
$(COMPILER) $(BUILD_ARGS) -o $(BUILD_DIR)/timer.o $(SRC_DIR)/timer.c
$(COMPILER) $(BUILD_ARGS) -o $(BUILD_DIR)/kb.o $(SRC_DIR)/kb.c
$(COMPILER) $(BUILD_ARGS) -o $(BUILD_DIR)/ramdisk.o $(SRC_DIR)/ramdisk.c
$(COMPILER) $(BUILD_ARGS) -o $(BUILD_DIR)/ata_pio.o $(SRC_DIR)/ata_pio.c
OBJECT_FILES := $(BUILD_DIR)/mem_utils.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/mem_api.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/mem_detect.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/start.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/main.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/str_utils.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/scrn.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/gdt.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/idt.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/isrs.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/irq.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/timer.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/kb.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/ramdisk.o
OBJECT_FILES := $(OBJECT_FILES) $(BUILD_DIR)/ata_pio.o
link: compile
ld -T $(SRC_DIR)/link.ld -o $(BUILD_DIR)/kernel.bin $(OBJECT_FILES)
clean: prev_kernel
rm -rf $(BUILD_DIR)
prev_kernel:
cp $(INSTALL_TO) $(PREV_KERNEL_PATH)$(INSTALL_TO)_`date +%y-%m-%d_%H_%M` || true
active_kernel:
cp $(BUILD_DIR)/kernel.bin $(INSTALL_TO)
disassemble: compile
objdump -d $(OBJECT_FILES) >> $(BUILD_DIR)/disassemble.asm
less $(BUILD_DIR)/disassemble.asm