From 9571b94360e0e12b5347ccfdd0358489dd925063 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Tue, 4 Oct 2022 03:47:06 +0300 Subject: makefile: use script instead of passing options to the linker --- Makefile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 014a6e0..aebce96 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ LD = $(TARGET_TOOLS)ld AS = $(TARGET_TOOLS)as OBJDUMP = $(TARGET_TOOLS)objdump +KERN_HEAD = $(ARCH_BOOT)/head.o C_SOURCES = \ kernel/main.c \ kernel/string.c \ @@ -39,18 +40,15 @@ $(OSBIN): $(OS_BINARIES) cat $^ > $@ dd if=/dev/zero bs=512 count=128 >> $@ # 65536 -$(BOOTBIN): +$(BOOTBIN) $(KERN_HEAD): $(MAKE) -C $(ARCH_BOOT) -$(KERNBIN): $(ARCH_BOOT)/head.o $(OBJECTS) - $(CC) -Wl,--oformat binary -Ttext 0x1000 -o $@ \ +$(KERNBIN): $(KERN_HEAD) $(OBJECTS) + $(CC) -T $(ARCH_BOOT)/linker.ld -o $@ \ -ffreestanding -nostdlib \ $^ -lgcc printf "Kernel size: 0x%x\n" `stat -c "%s" $@` -%.o: %.s - $(AS) $< -o $@ - %.o: %.c $(CC) -std=gnu89 -Wall -ffreestanding -nostdlib \ -I arch/$(ARCH)/include \ @@ -70,5 +68,4 @@ objdump-kernel: $(KERNBIN) clean: $(MAKE) -C $(ARCH_BOOT) clean - rm -rf $(ARCH_BOOT)/head.o kernel/main.o - rm -rf $(KERNBIN) $(OSBIN) $(OBJECTS) + rm -f $(KERNBIN) $(OSBIN) $(OBJECTS) -- cgit v1.2.3-18-g5258