initial commit
This commit is contained in:
42
makefile
Normal file
42
makefile
Normal file
@@ -0,0 +1,42 @@
|
||||
CC = i686-elf-gcc
|
||||
LD = i686-elf-ld
|
||||
OBJCOPY = i686-elf-objcopy
|
||||
|
||||
CFLAGS = -m32 -ffreestanding -O2 -Wall -Wextra -nostdlib
|
||||
ASFLAGS = -m32
|
||||
|
||||
.PHONY: all clean run
|
||||
|
||||
all: os.img
|
||||
|
||||
boot.o: boot.s
|
||||
$(CC) $(ASFLAGS) -c boot.s -o boot.o
|
||||
|
||||
boot.elf: boot.o boot.ld
|
||||
$(LD) -T boot.ld -o boot.elf boot.o
|
||||
|
||||
boot.bin: boot.elf
|
||||
$(OBJCOPY) -O binary boot.elf boot.bin
|
||||
|
||||
prekernel.o: prekernel.s
|
||||
$(CC) $(ASFLAGS) -c prekernel.s -o prekernel.o
|
||||
|
||||
kmain.o: kmain.c
|
||||
$(CC) $(CFLAGS) -c kmain.c -o kmain.o
|
||||
|
||||
kernel.elf: prekernel.o kmain.o kernel.ld
|
||||
$(LD) -T kernel.ld -o kernel.elf prekernel.o kmain.o
|
||||
|
||||
kernel.bin: kernel.elf
|
||||
$(OBJCOPY) -O binary kernel.elf kernel.bin
|
||||
|
||||
os.img: boot.bin kernel.bin
|
||||
dd if=boot.bin of=os.img bs=512 count=1
|
||||
dd if=kernel.bin of=os.img bs=512 seek=1
|
||||
truncate -s 1440k os.img
|
||||
|
||||
run: os.img
|
||||
qemu-system-i386 -drive format=raw,file=os.img
|
||||
|
||||
clean:
|
||||
rm -f *.o *.elf *.bin os.img
|
||||
Reference in New Issue
Block a user