Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #TODO: Update this to put everything into a build directory
- BOOTOUTPUT = boot.bin
- OSOUTPUT = os.bin
- SRCS = $(wildcard kernel/*.c)
- CINC = $(wildcard kernel/*.h)
- OBJS = $(patsubst %.c, %.o, $(SRCS))
- #Final step in the build process
- $(OSOUTPUT): kernel.bin $(BOOTOUTPUT)
- cat $(BOOTOUTPUT) kernel.bin > $(OSOUTPUT)
- #Assemble the boot sector code
- $(BOOTOUTPUT): boot/bootsector.asm
- nasm -f bin boot/bootsector.asm -o $(BOOTOUTPUT)
- #Compile all the kernel files
- %.o:%.c $(CINC)
- gcc -m32 -ffreestanding -fno-pie -fno-stack-protector -nostdlib -c $< -o $@
- #Assemble the kernel entry code
- kernelEntry.o: boot/kernelEntry.asm
- nasm boot/kernelEntry.asm -f elf32 -o kernelEntry.o
- #Link all the .o files with the kernel entry
- kernel.bin: kernelEntry.o $(OBJS)
- ld -melf_i386 -o kernel.bin -Ttext 0x1000 $^ --oformat binary
- run:
- qemu-system-x86_64 -fda $(OSOUTPUT)
- clean:
- rm -f *.bin *.o $(OBJS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement