-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
132 lines (101 loc) · 2.07 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
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
125
126
127
128
129
130
131
132
default: all
.PHONY: \
all \
build \
run \
debug \
sonar \
kernel \
clean \
limine
###########
# Tooling #
###########
export \
ARCH \
CC \
LD \
AS
ARCH = x86_64
CC = clang
LD = gcc
AS = nasm
QFLAGS = \
-name sonar \
-m 2G \
-boot menu=off \
-smp cpus=4 \
-cdrom ${SONAR_ISO_TARGET} \
-device ahci,id=ahci \
-drive if=none,id=disk,file=${SONAR_ISO_TARGET},format=raw \
-machine q35
#########################
# Top Level Directories #
#########################
export \
BOOT_DIR \
SRC_DIR \
BUILD_DIR
DIR = $(shell readlink -f .)
SRC_DIR = ${DIR}/src
BOOT_DIR = ${SRC_DIR}/boot
BUILD_DIR = ${DIR}/build
################
# Build Output #
################
export \
SONAR_KERNEL_TARGET \
SONAR_IMG_TARGET
SONAR_KERNEL_TARGET = ${BUILD_DIR}/sonar.elf
SONAR_MOUNT_TARGET = ${BUILD_DIR}/iso_root
SONAR_ISO_TARGET = ${BUILD_DIR}/sonar.iso
################
# Dependencies #
################
LIMINE_DIR = ${BUILD_DIR}/limine
LIMINE_REPO = https://github.com/limine-bootloader/limine
LIMINE_BRANCH = v4.x-branch-binary
all: build run
build:
docker run \
--rm \
-v ${BUILD_DIR}:/sonar/build \
$(shell docker build -q . || echo "Build failed")
run:
qemu-system-${ARCH} ${QFLAGS} -serial stdio
debug:
qemu-system-${ARCH} ${QFLAGS} -no-reboot -d int
#################
# Raw ISO Build #
#################
sonar: kernel limine
mkdir -p ${SONAR_MOUNT_TARGET}
cp -v \
${SONAR_KERNEL_TARGET} \
${BOOT_DIR}/limine.cfg \
${LIMINE_DIR}/limine.sys \
${LIMINE_DIR}/limine-cd.bin \
${LIMINE_DIR}/limine-cd-efi.bin \
${SONAR_MOUNT_TARGET}
xorriso -as mkisofs \
-b limine-cd.bin \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
--efi-boot limine-cd-efi.bin \
-efi-boot-part \
--efi-boot-image \
--protective-msdos-label \
${SONAR_MOUNT_TARGET} \
-o ${SONAR_ISO_TARGET}
${LIMINE_DIR}/limine-deploy ${SONAR_ISO_TARGET}
kernel:
make -C ${SRC_DIR}
clean:
rm -rf ${BUILD_DIR}/*
limine:
cd ${BUILD_DIR}
git clone ${LIMINE_REPO} --branch=${LIMINE_BRANCH} --depth=1 ${LIMINE_DIR} \
|| echo "Limine already exists"
make -C ${LIMINE_DIR}
cd -