We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cross-compiling gcc and gdb is a bit difficult for me, so I used brew to complete this part. It runs well on macOS 13.5! Someone will need it.
# $@ = target file # $< = first dependency # $^ = all dependencies # First rule is the one executed when no parameters are fed to the Makefile C_SOURCE_FILES = $(wildcard kernel/*.c drivers/*.c cpu/*.c libc/*.c) HEADERS = $(wildcard kernel/*.h drivers/*.h cpu/*.h libc/*.h) OBJ = ${C_SOURCE_FILES:.c=.o cpu/interrupt.o} CC = x86_64-elf-gcc # Get x86_64-elf-gcc by `brew install x86_64-elf-gcc` GDB = i386-elf-gdb # Get i386-elf-gdb by `brew install i386-elf-gdb` LD = x86_64-elf-ld # Get x86_64-elf-ld by `brew install x86_64-elf-binutils` CFLAGS = -g all: run kernel.bin: boot/kernel_entry.o ${OBJ} ${LD} -m elf_i386 -o $@ -Ttext 0x1000 --entry _start $^ --oformat binary kernel.elf: boot/kernel_entry.o ${OBJ} ${LD} -m elf_i386 -o $@ -Ttext 0x1000 --entry _start $^ kernel_entry.o: kernel_entry.asm nasm $< -f elf -o $@ kernel.o: kernel.c ${CC} -m32 -march=i386 -ffreestanding -c $< -o $@ kernel.dis: kernel.bin ndisasm -b 32 $< > $@ bootsect.bin: bootsect.asm nasm $< -f bin -o $@ os-image.bin: boot/bootsect.bin kernel.bin cat $^ > $@ run: os-image.bin qemu-system-i386 -fda $< debug: os-image.bin kernel.elf qemu-system-i386 -s -fda os-image.bin & ${GDB} -ex "target remote localhost:1234" -ex "symbol-file kernel.elf" %.o : %.c ${HEADERS} ${CC} ${CFLAGS} -m32 -march=i386 -ffreestanding -c $< -o $@ %.o : %.asm nasm $< -f elf -o $@ %.bin : %.asm nasm $< -f bin -o $@ clean: rm -fr *.bin *.dis *.o os-image.bin *.elf rm -fr kernel/*.o boot/*.bin boot/*.o drivers/*.o cpu/*.o libc/*.o
The text was updated successfully, but these errors were encountered:
You can also use i686-elf-gcc and ld and skip the flag requiring the output to be i386
Sorry, something went wrong.
No branches or pull requests
Cross-compiling gcc and gdb is a bit difficult for me, so I used brew to complete this part. It runs well on macOS 13.5! Someone will need it.
The text was updated successfully, but these errors were encountered: