forked from N1709/obsidian_kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
108 lines (88 loc) · 2.97 KB
/
Copy pathMakefile
File metadata and controls
108 lines (88 loc) · 2.97 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
# Obsidian Kernel build system.
#
# Usage:
# make build everything (both architectures, both variants)
# make x86_64 64-bit kernels only
# make x86_32 32-bit kernels only
# make arm64 aarch64 kernels (needs aarch64-linux-gnu-gcc)
# make iso bootable GRUB images with the English boot menu
# make run QEMU the 64-bit ISO
# make run32 QEMU the 32-bit ISO
# make secure rebuild only the Secure Kernels
# make clean delete all artifacts
#
# The kernel version lives here and is injected into every compile.
OBSIDIAN_NAME := obsidian
OBSIDIAN_VERSION := 0.3.0
BUILD_DATE := $(shell date +"%Y-%m-%d %H:%M:%S %Z")
CC := gcc
LD := gcc
NASM := nasm
RUSTC := rustc
GRUB_MK := grub-mkrescue
export CC LD NASM RUSTC GRUB_MK
QEMU64 ?= qemu-system-x86_64
QEMU32 ?= qemu-system-i386
ARCHES := x86_64 x86 arm64
VARIANTS:= standard secure
.PHONY: all help x86_64 x86_32 arm64 iso run run32 secure clean distclean
all:
@for a in $(ARCHES); do \
for v in $(VARIANTS); do \
$(MAKE) --no-print-directory build-one ARCH=$$a VARIANT=$$v || exit 1; \
done; \
done
x86_64:
@for v in $(VARIANTS); do \
$(MAKE) --no-print-directory build-one ARCH=x86_64 VARIANT=$$v || exit 1; \
done
x86_32:
@for v in $(VARIANTS); do \
$(MAKE) --no-print-directory build-one ARCH=x86 VARIANT=$$v || exit 1; \
done
arm64:
@if ! command -v aarch64-linux-gnu-gcc >/dev/null 2>&1; then \
echo "arm64 skipped: install gcc-aarch64-linux-gnu"; exit 0; \
fi
@for v in $(VARIANTS); do \
$(MAKE) --no-print-directory build-one ARCH=arm64 VARIANT=$$v || exit 1; \
done
secure:
@for a in $(ARCHES); do \
$(MAKE) --no-print-directory build-one ARCH=$$a VARIANT=secure || exit 1; \
done
build-one:
@$(MAKE) --no-print-directory -f Makefile.build \
ARCH=$(ARCH) VARIANT=$(VARIANT) \
OBSIDIAN_VERSION=$(OBSIDIAN_VERSION) \
BUILD_DATE="$(BUILD_DATE)" kernel
iso: all
@$(MAKE) --no-print-directory iso-x86_64
@$(MAKE) --no-print-directory iso-x86
iso-x86_64:
@rm -rf stage/x86_64
@mkdir -p stage/x86_64/boot/grub
@cp out/x86_64-standard/obsidian_core.elf stage/x86_64/boot/
@cp out/x86_64-secure/obsidian_secure.elf stage/x86_64/boot/
@sed -e "s/@VERSION@/$(OBSIDIAN_VERSION)/g" \
-e "s/@ARCHNAME@/x86_64/g" \
-e "s/@LOADERCMD@/multiboot2/g" grub.cfg.in \
> stage/x86_64/boot/grub/grub.cfg
$(GRUB_MK) -o obsidian-x86_64.iso stage/x86_64
iso-x86:
@rm -rf stage/x86
@mkdir -p stage/x86/boot/grub
@cp out/x86-standard/obsidian_core.elf stage/x86/boot/
@cp out/x86-secure/obsidian_secure.elf stage/x86/boot/
@sed -e "s/@VERSION@/$(OBSIDIAN_VERSION)/g" \
-e "s/@ARCHNAME@/i686/g" \
-e "s/@LOADERCMD@/multiboot/g" grub.cfg.in \
> stage/x86/boot/grub/grub.cfg
$(GRUB_MK) -o obsidian-i386.iso stage/x86
run: iso-x86_64
$(QEMU64) -m 512 -vga std -cdrom obsidian-x86_64.iso
run32: iso-x86
$(QEMU32) -m 512 -cdrom obsidian-i386.iso
clean:
rm -rf out stage *.iso
distclean: clean