-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
83 lines (61 loc) · 1.88 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
################################# INFO #################################
KER_VER := 0.0.1_a
BOOT_VER := 0.0.1_a
TARGET := i386-elf
FS := fat16
###################### Tools ######################
MSG := @echo
CC =
ASM =
LD =
########### x86 ###########
LD_X86 := @./x86/tools/bin/$(TARGET)-ld
ASM_X86 := @nasm
CC_X86 := ./x86/tools/bin/$(TARGET)-gcc
################################# CONFIG #################################
ARCH = nan
CONFIG := ./makeconfig/
CONFIG_RULES := $(CONFIG)rules/
include $(CONFIG)flags.mk
include $(CONFIG)files.mk
include $(CONFIG)directories.mk
include $(CONFIG)rules.mk
################################# RULES #################################
.PHONY: all
all: x86
$(MSG) "_purpOSe assembled."
.PHONY: acpica
acpica: $(ACPICA_OBJ)
.PHONY: libk
libk: $(LIBK_OBJ)
.PHONY: libc
libc: $(LIBC_OBJ)
.PHONY: dir_tree
dir_tree:
@mkdir -p $(SYSROOT_DIR)Purpose/Boot/
.PHONY: clean
clean:
$(eval ARCH := x86)
@$(RM) -rf $(SYSROOT_DIR)*
@$(RM) $(KER_OBJ_DIR)*.obj $(LIBK_OBJ_DIR)*.obj $(LIBC_OBJ_DIR)*.obj $(ACPICA_OBJ_DIR)*.obj $(BOOT_OBJ_DIR)*.bin
###################### Architecture specyfic ######################
$(SYSROOT_DIR)Purpose/poskernel.elf: $(KER_OBJ) $(CRT_OBJ)
$(LD) $(LD_FLAGS) $(OS_OBJ) -o $@
$(SYSROOT_DIR)Purpose/Boot/bootpos.COM: $(BOOT_OBJ)
@cp $(BOOT_S2_OBJ) $@
########### x86 ###########
.PHONY: x86
ifeq ($(ARCH), x86)
x86: dir_tree boot_x86 kernel_x86
@sudo ./utils/mkdisk_$(FS).sh x86
.PHONY: kernel_x86
kernel_x86: acpica libk libc $(SYSROOT_DIR)Purpose/poskernel.elf
.PHONY: boot_x86
boot_x86: $(SYSROOT_DIR)Purpose/Boot/bootpos.COM
else
x86:
$(eval ARCH := x86)
@$(MAKE) $@ --no-print-directory ARCH=$(ARCH) LD="$(LD_X86)" CC="$(CC_X86)" \
ASM="$(ASM_X86)" LD_FLAGS="$(LD_FLAGS) $(LD_X86_FLAGS)" ASM_FLAGS="$(ASM_FLAGS) \
$(ASM_X86_FLAGS)" C_FLAGS="$(C_FLAGS) $(C_X86_FLAGS)" BOOT_ASM_FLAGS="$(BOOT_ASM_FLAGS) $(BOOT_ASM_X86_FLAGS)"
endif