-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
39 lines (28 loc) · 846 Bytes
/
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
TOOLCHAIN = i686-elf
TOOLCHAIN_DIR = toolchain/$(TOOLCHAIN)/bin
CC = $(TOOLCHAIN_DIR)/$(TOOLCHAIN)-gcc
LD = $(TOOLCHAIN_DIR)/$(TOOLCHAIN)-ld
AS = nasm
SOURCE_DIR = kernel/
C_SOURCES = $(shell find $(SOURCE_DIR) -name '*.c')
HEADERS = $(shell find $(SOURCE_DIR) -name '*.h')
OBJ = ${C_SOURCES:.c=.o}
all: malard.iso
%.o: %.c
$(CC) -ffreestanding -Wall -Wextra -Werror -c $^ -o $@
%.o: %.asm
$(AS) $^ -f elf -o $@
%.bin: %.asm
$(AS) $^ -f bin -I 'boot' -o $@
kernel.bin: kernel/kentry.o ${OBJ}
$(LD) -o $@ -Ttext 0x1000 $^ --oformat binary
boot.bin: boot/boot.asm
$(AS) $^ -f bin -I 'boot' -o $@
malard.iso: boot.bin kernel.bin
cat $^ > malard.iso
clean:
rm -rf *.bin *.o kernel/*.o src/*.bin malard.iso
run: malard.iso
qemu-system-i386 \
-serial stdio \
-fda malard.iso