-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (33 loc) · 981 Bytes
/
Makefile
File metadata and controls
49 lines (33 loc) · 981 Bytes
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
BUILD=build/
KERNEL_SOURCES=$(wildcard kernel/*.c kernel/drivers/*.c)
OBJ=${KERNEL_SOURCES:.c=.o}
C_FLAGS=-m32 -ffreestanding -g
LD_FLAGS=-melf_i386
NASMFLAGS=-felf32
#C_FLAGS=-ffreestanding -g
#LD_FLAGS=-melf
#NASMFLAGS=-felf
QEMU=qemu-system-i386
all: dir kernel.bin boot.bin os-image os
run:
$(QEMU) -hda ${BUILD}os.img
debug:
$(QEMU) -fda ${BUILD}os.img -gdb tcp::9999 -S
os-image:
cat ${BUILD}boot.bin ${BUILD}kernel.bin > ${BUILD}os-image
os: $(BUILD)os-image
dd if=/dev/zero bs=1024 count=1440 > ${BUILD}$@.img
dd if=$< of=${BUILD}$@.img conv=notrunc
boot.bin: boot/boot_sect.asm
nasm $(NASM_FLAGS) $< -f bin -I 'boot/' -o ${BUILD}$@
%kernel_entry.o: kernel/kernel_entry.asm
nasm $< $(NASMFLAGS) -o kernel/kernel_entry.o
kernel.bin: kernel/kernel_entry.o $(OBJ)
ld $(LD_FLAGS) -o ${BUILD}$@ -Ttext 0x1000 $^ --oformat binary
%.o: %.c
gcc $(C_FLAGS) -c $< -o $@
dir:
mkdir -p $(BUILD)
clean:
@rm -f kernel/*.o kernel/drivers/*.o
@rm -r $(BUILD)