-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
89 lines (65 loc) · 1.97 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
84
85
86
87
88
89
# Raspberry PI Version To Build For
RPI_VERSION ?= 1
# Current Version of the Operating System
PIOS_VERSION := 0.0.1
# Define absolute paths to directories
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
BUILD_DIR := $(ROOT_DIR)/build
# Cross compiler for code
CC_BASE ?= arm-none-eabi
CC = $(CC_BASE)-gcc
CC_ASM = $(CC_BASE)-as
LD = $(CC_BASE)-ld
OCPY = $(CC_BASE)-objcopy
ODMP = $(CC_BASE)-objdump
# Command line options for compiler
# -mcpu=arm1176jzf-s -mfpu=vfpv2 -march=armv6
CC_OPT = -mcpu=arm1176jzf-s -mfpu=vfpv2 -fpic -std=c17 -Wall -Wextra -nostdlib -nostartfiles -fasm -ffreestanding -c -I $(ROOT_DIR)/include
CC_ASM_OPT = -mcpu=arm1176jzf-s -mfpu=vfpv2
LD_OPT = -nostdlib
ODMP_OPT = -m arm -SwCrR
RELEASE = -O2
# Command line options for QEMU
# -M = model
# -serial mon:stdio = redirect serial output to terminal
# -kernel
QEMU_OPT = -m 512 -M raspi1ap -serial mon:stdio
KERNEL = $(BUILD_DIR)/kernel.elf
KERNEL_DEBUG = $(BUILD_DIR)/kerneld.elf
KERNEL_IMG = $(BUILD_DIR)/kernel7.img
KERNEL_ASM = $(BUILD_DIR)/kernel.asm
export
all: $(BUILD_DIR) kernel
$(BUILD_DIR): $(BUILD_DIR)/boot $(BUILD_DIR)/common $(BUILD_DIR)/kernel
mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/%:
mkdir -p $@
kernel: $(BUILD_DIR)
@echo
@echo Building PioneerOS
@echo
@echo Raspberry PI target : $(RPI_VERSION)
@echo PioneerOS Version : $(PIOS_VERSION)
@echo
$(MAKE) -C ./src $(KERNEL)
kernel-debug: $(BUILD_DIR)
$(MAKE) -C ./src $(KERNEL_DEBUG)
qemu: kernel
qemu-system-arm -nographic $(QEMU_OPT) -kernel $(KERNEL)
qemu-console: kernel
qemu-system-arm $(QEMU_OPT) -kernel $(KERNEL)
qemu-debug: kernel-debug
qemu-system-arm $(QEMU_OPT) -S -s -kernel $(KERNEL_DEBUG)
lldb:
lldb --arch armv6m --one-line "gdb-remote 1234" $(KERNEL_DEBUG)
format-check:
$(MAKE) -C ./src format-check
format:
$(MAKE) -C ./src format
doc:
doxygen
download-doc:
@echo "--TODO--"
clean:
@rm -rf $(BUILD_DIR)
.PHONY: all kernel kernel-debug qemu qemu-debug lldb format format-check clean