blob: 1a50a18cb54106726939b3151f96f3608fb0794d (
plain)
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
|
# https://www.gnu.org/software/make/manual/html_node/Setting.html
# := expanded variable, right-hand side can contain variables
# ?= only set if it doesn't have a value
# != execute a shell script on the right-hand side and assign its result to the left-hand side
export TARGET := i686-elf
export AR := llvm-ar
AS := clang
LD := ld.lld
LD_FLAGS := -T linker.ld -lk
export CXX := clang
export CXX_FLAGS := -std=c++20 -ffreestanding -nostdlib -nostdinc -nostdinc++ \
-fno-exceptions -fno-rtti -Wall -Wextra -O2
CXX_INCLUDE := $(CURDIR)/libk
CXX_OBJ := kernel.o vga.o
# $@ is target
# $< is first dependency
# $^ is all dependencies
default: glitch.elf
check-grub: glitch.elf
grub-file --is-x86-multiboot2 glitch.elf
glitch.elf: boot.o $(CXX_OBJ) libk/libk.a
$(LD) $(LD_FLAGS) -o $@ boot.o $(CXX_OBJ)
boot.o: boot.s
$(AS) -target $(TARGET) -nostdlib -Wall -Wextra -c $^ -o $@
$(CXX_OBJ): %.o : %.cc
$(CXX) -target $(TARGET) $(CXX_FLAGS) -I$(CXX_INCLUDE) -c $^ -o $@
libk/libk.a:
$(MAKE) -C libk libk.a
libk/test:
$(MAKE) -C libk test
test: libk/test
iso: glitch.elf
mkdir -p isodir/boot/grub
cp glitch.elf isodir/boot/glitch.elf
cp grub.cfg isodir/boot/grub/grub.cfg
grub-mkrescue -o myos.iso isodir
run: iso
qemu-system-i386 -cdrom myos.iso
clean:
rm -f boot.o $(CXX_OBJ) glitch.elf
$(MAKE) -C libk clean
clean-iso:
rm -rf isodir
|