-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
124 lines (93 loc) · 3.63 KB
/
Makefile
File metadata and controls
124 lines (93 loc) · 3.63 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# The Boron Operating System - Makefile
# DEBUG flags
DEBUG ?= yes
DEBUG2 ?= no
# The platform we are targetting
TARGET ?= AMD64
TARGETL ?= $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$(TARGET)))))))))))))))))))))))))))
# debug1: general debugging text, works all the time and keeps the
# kernel behaving how it should
# debug2: in-depth debugging, printing of page faults and stuff.
# careful because you might get jumbled output on SMP since the
# debug console won't lock. The advantage is that you'll be able
# to log basically anywhere
KERNEL_NAME = kernel.elf
SYSDLL_NAME = libboron.so
# Decide on a sysroot path.
# It can be overwritten by the platform-specific makefile component (for example,
# amd64 requires a special root where mlibc installs its stuff)
BORON_SYSROOT_PATH = root
include tools/Makefile.$(TARGETL)
# The build directory
BUILD_DIR = build/$(TARGETL)
# The driver directory
DRIVERS_DIR = drivers
# The userland directory
USER_DIR = user
# The ISO root directory
ISO_DIR = $(BUILD_DIR)/iso_root
# The ISO target.
IMAGE_TARGET = $(BUILD_DIR)/../image.$(TARGETL).iso
# The init ramdisk directory.
INITRD_DIR = $(BUILD_DIR)/initrd_root
# The init ramdisk target.
INITRD_TARGET = $(BUILD_DIR)/initrd.tar
KERNEL_BUILD = boron/build
KERNEL_ELF = $(patsubst %.elf,%.$(TARGETL).elf,$(KERNEL_BUILD)/$(KERNEL_NAME))
DRIVERS_TARGETS = $(patsubst %,$(BUILD_DIR)/%.sys,$(DRIVERS_LIST))
DRIVERS_DIRECTORIES = $(patsubst %,$(DRIVERS_DIR)/%,$(DRIVERS_LIST))
DRIVERS_BUILD_DIRS = $(patsubst %,%/build,$(DRIVERS_DIRECTORIES))
DRIVERS_LOCAL_TARGETS = $(patsubst %,%/build/out.$(TARGETL).sys,$(DRIVERS_DIRECTORIES))
# Convenience macro to reliably declare overridable command variables.
define DEFAULT_VAR =
ifeq ($(origin $1),default)
override $(1) := $(2)
endif
ifeq ($(origin $1),undefined)
override $(1) := $(2)
endif
endef
# Default target.
.PHONY: all
all: image
# Remove object files and the final executable.
.PHONY: clean
clean:
@echo "Cleaning..."
rm -rf $(KERNEL_BUILD) $(SYSDLL_BUILD) $(BUILD_DIR) $(DRIVERS_TARGETS) $(DRIVERS_LOCAL_TARGETS) $(DRIVERS_BUILD_DIRS)
@echo "Cleaning user applications..."
$(MAKE) -C user clean
image: limine $(IMAGE_TARGET) $(INITRD_TARGET)
include tools/build_image_$(TARGETL).mk
include tools/run_rule_$(TARGETL).mk
kernel: $(KERNEL_ELF)
drivers: $(DRIVERS_TARGETS)
initrd: $(INITRD_TARGET)
apps:
$(MAKE) -C user
$(KERNEL_ELF): FORCE
@mkdir -p $(BUILD_DIR)
@echo "[MK]\tMaking $(KERNEL_ELF)"
@$(MAKE) -C boron
@cp $(KERNEL_ELF) $(BUILD_DIR)/$(KERNEL_NAME)
$(BUILD_DIR)/%.exe: FORCE
@mkdir -p $(BUILD_DIR)
@echo "[MK]\tMaking app $(patsubst $(BUILD_DIR)/%.exe,%,$@)"
@echo $(patsubst $(BUILD_DIR)/%.exe,$(USER_DIR)/%,$@)
@$(MAKE) -C $(patsubst $(BUILD_DIR)/%.exe,$(USER_DIR)/%,$@)
@cp $(USER_DIR)/$*/build/$*.$(TARGETL).exe $@
$(BUILD_DIR)/%.sys: FORCE
@mkdir -p $(BUILD_DIR)
@echo "[MK]\tMaking driver $(patsubst $(BUILD_DIR)/%.sys,%,$@)"
@$(MAKE) -C $(patsubst $(BUILD_DIR)/%.sys,$(DRIVERS_DIR)/%,$@)
@cp $(patsubst $(BUILD_DIR)/%.sys,$(DRIVERS_DIR)/%/build/out.$(TARGETL).sys,$@) $@
$(BUILD_DIR)/%.tar: FORCE apps
@echo "[MK]\tBuilding initrd"
@rm -rf $(INITRD_DIR)/usr/include
@mkdir -p $(INITRD_DIR)/usr/include
@cp -rf root/* $(INITRD_DIR)
@cp -rf $(BORON_SYSROOT_PATH)/* $(INITRD_DIR)
@cp -rf common/include $(INITRD_DIR)/usr
@cp -rf user/include $(INITRD_DIR)/usr
@tar -cf $@ -C $(INITRD_DIR) .
FORCE: ;