-
-
Save ScriptedDeveloper/4bcad3eb9be428042677d1c2440b9b88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override NASM := nasm | |
override CC := gcc | |
override LD := i686-elf-ld | |
CFLAGS := -I ../src/ | |
CFLAGS += -ffreestanding | |
CFLAGS += -m32 | |
CFLAGS += -fno-stack-protector | |
CFLAGS += -fno-PIE | |
CFLAGS += -g | |
LDFLAGS += -m32 | |
LDFLAGS += -fno-PIE | |
LDFLAGS += -g | |
LDFLAGS += -nostartfiles | |
LDFLAGS += -nostdlib | |
S_SRC := $(shell find . -type f -name '*.asm') | |
C_SRC := $(shell find . -type f -name '*.c') | |
LIBGCC := $(shell $(CC) $(CFLAGS) --print-libgcc-file-name) | |
OBJ := $(S_SRC:.asm=.o) $(C_SRC:.c=.o) | |
all: kernel.bin | |
kernel.bin: $(OBJ) | |
$(CC) -T ../link.ld $(LDFLAGS) -o $@ $^ $(LIBGCC) | |
%.o: %.c | |
$(CC) $(CFLAGS) -c $^ -o $@ | |
%.o: %.asm | |
$(NASM) -felf32 $^ -o $@ | |
run: kernel.bin | |
qemu-system-x86_64 -m 128M -kernel $< | |
.PHONY: run all clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gcc -T ../link.ld -m32 -fno-PIE -o kernel.bin idt/idt_.o gdt/gdt_.o kernel/boot.o video/video.o memory/memory.o idt/isr.o idt/idt.o gdt/gdt.o string/string.o kernel/kernel.o shell/shell.o keyboard/keyboard.o
/usr/bin/ld: gdt/gdt_.o: warning: relocation in read-only section
.text' /usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib32/Scrt1.o: in function
_start':(.text+0x22): undefined reference to `main'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [Makefile:23: kernel.bin] Error 1