-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (38 loc) · 1.05 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
GPPPARAMS = -m32 -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -I $(srcdir) -Wno-write-strings
ASPARAMS = --32
LDPARAMS = -melf_i386
srcdir = src/
bindir = bin/
name = kernel
bin = $(name).bin
iso = $(name).iso
grub = grub.cfg
SRC = $(shell find $(srcdir) -regex ".*\.s\|.*\.cpp")
OBJ = $(subst $(srcdir), $(bindir), $(patsubst %.s, %.o, $(patsubst %.cpp, %.o, $(SRC))))
$(bindir)%.o : $(srcdir)%.cpp $(srcdir)%.h
mkdir -p $(dir $@)
g++ $(GPPPARAMS) -o $@ -c $<
$(bindir)%.o : $(srcdir)%.cpp
mkdir -p $(dir $@)
g++ $(GPPPARAMS) -o $@ -c $<
$(bindir)%.o : $(srcdir)%.s
mkdir -p $(dir $@)
as $(ASPARAMS) -o $@ $^
bin : $(bin)
$(bin) : linker.ld $(OBJ)
echo $(SRC)
ld $(LDPARAMS) -T $< -o $@ $(OBJ)
iso : $(iso)
$(iso) : $(bin)
mkdir -p iso/boot/grub
cp $(bin) iso/boot
cp $(grub) iso/boot/grub
grub-mkrescue --output=$@ iso
rm -rf iso
run : $(iso)
qemu-system-x86_64 $^
box : $(iso)
(killall VirtualBox && sleep 1) || true
VirtualBox --startvm "My kernel" &
clean :
rm -rf $(bindir) $(bin) $(iso)