-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (35 loc) · 1.61 KB
/
Makefile
File metadata and controls
49 lines (35 loc) · 1.61 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
include conf
ARMGNU = aarch64-none-elf
COPS = -DMAINFSFUNC=$(MAINFSFUNC) -fPIE -Wall -O0 -ffreestanding -nostdlib -nostartfiles -mstrict-align -Ikernel -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
CPPOPS = $(COPS) -std=c++20 -fno-exceptions -fno-rtti -Wno-write-strings
ASMOPS = -Ikernel -fPIE
BUILD_DIR = build
SRC_DIR = kernel
all : clean kernel8.img
screen:
scripts/view_tty.sh $(TTYDEV) $(VIEW_TTY)
dump:
$(ARMGNU)-objdump -D $(BUILD_DIR)/kernel8.elf > dump
clean :
@rm -rf $(BUILD_DIR) *.img dump
$(BUILD_DIR)/%_c.o: $(SRC_DIR)/%.c
@mkdir -p $(@D)
@$(ARMGNU)-gcc $(COPS) -MMD -c $< -o $@
$(BUILD_DIR)/%_cpp.o: $(SRC_DIR)/%.cpp
@mkdir -p $(@D)
@$(ARMGNU)-g++ $(CPPOPS) -MMD -c $< -o $@
$(BUILD_DIR)/%_s.o: $(SRC_DIR)/%.S
@mkdir -p $(@D)
@$(ARMGNU)-gcc $(ASMOPS) -MMD -c $< -o $@
C_FILES = $(shell find . \( -path ./library -o -path ./modules \) -prune -o -type f -name "*.c" -print | cut -d'/' -f2-)
CPP_FILES = $(shell find . \( -path ./library -o -path ./modules \) -prune -o -type f -name "*.cpp" -print | cut -d'/' -f2-)
ASM_FILES = $(shell find . \( -path ./library -o -path ./modules \) -prune -o -type f -name "*.S" -print | cut -d'/' -f2-)
OBJ_FILES = $(C_FILES:$(SRC_DIR)/%.c=$(BUILD_DIR)/%_c.o)
OBJ_FILES += $(CPP_FILES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%_cpp.o)
OBJ_FILES += $(ASM_FILES:$(SRC_DIR)/%.S=$(BUILD_DIR)/%_s.o)
DEP_FILES = $(OBJ_FILES:%.o=%.d)
-include $(DEP_FILES)
kernel8.img: linker.ld $(OBJ_FILES)
@$(ARMGNU)-ld -pie -T linker.ld -o $(BUILD_DIR)/kernel8.elf $(OBJ_FILES)
@$(ARMGNU)-objcopy $(BUILD_DIR)/kernel8.elf -O binary kernel8.img
scripts/go_rpi.sh $(RPI_PATH) $(TTYDEV) $(VIEW_TTY)