-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
35 lines (25 loc) · 779 Bytes
/
Copy pathmakefile
File metadata and controls
35 lines (25 loc) · 779 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
C_SOURCES = $(wildcard kernel/*.c drivers/*.c)
HEADERS = $(wildcard kernel/*.h drivers/*.h)
OBJ = $(C_SOURCES:.c=.o)
all: os-image
run: all
bochs -q
os-image: bootsector/bootsec32.bin kernel/kernel.bin
if [ -f os-image ]; then mv os-image os-image.backup; fi;
cat $^ > os-image
bootsector/bootsec32.bin: bootsector/bootsec32.asm
nasm $< -f bin -o $@
kernel/kernel.bin: kernel/kernel_entry.o ${OBJ}
#kernel.bin: kernel/kernel_entry.o kernel/kernel.o
ld -o $@ -Ttext 0x1000 $^ --oformat binary --entry kernel_start
#generic rule for compiling C to an object file
%.o: %.c ${HEADERS}
gcc -ffreestanding -c $< -o $@
#assemble kernel entry
%.o: %.asm
nasm $< -f elf64 -o $@
%.bin: %.asm
nasm $< -f bin -o $@
#generic disassemble
%.dis : %.bin
ndisasm -b 32 $< > $@