From 12d1092753fbf7a55b7394505f42362d515f8c58 Mon Sep 17 00:00:00 2001 From: Quinten Kock Date: Mon, 7 Dec 2020 01:54:57 +0100 Subject: [PATCH] Add support for NASM assembler --- kernel/Makefile | 6 +++--- kernel/make/i386/make.config | 2 ++ kernel/make/x86/make.config | 11 +++++++++-- kernel/make/x86_64/make.config | 1 + 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index 6e8056a..cc60313 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -19,7 +19,7 @@ TARGET := kernel CFILES := $(shell find src -path src/arch -prune -o -type f -name '*.c' -print) ARCHFILES := $(ARCHFILES) $(shell find src/arch/$(ARCH) -type f -name '*.c' -print) HFILES := $(shell find src -type f -name '*.h') -OBJ := $(patsubst src/%.c,obj/$(ARCH)/%.o,$(CFILES) $(ARCHFILES)) +OBJ := $(patsubst src/%,obj/$(ARCH)/%.o,$(CFILES) $(ARCHFILES)) .PHONY: all clean obj $(ARCHES) @@ -32,9 +32,9 @@ $(ARCHES): bin/$(TARGET)-$(ARCH): $(OBJ) @mkdir -p $(@D) @echo Linking $@ - @$(LD) $(LDFLAGS) $(OBJ) -o $@ + $(LD) $(LDFLAGS) $(OBJ) -o $@ -obj/$(ARCH)/%.o: src/%.c $(HFILES) +obj/$(ARCH)/%.c.o: src/%.c $(HFILES) @mkdir -p $(@D) @echo $(CC) $< @$(CC) $(CFLAGS) -c $< -o $@ diff --git a/kernel/make/i386/make.config b/kernel/make/i386/make.config index 7772620..888900c 100644 --- a/kernel/make/i386/make.config +++ b/kernel/make/i386/make.config @@ -1 +1,3 @@ -include make/x86/make.config + +NASM := nasm -felf32 \ No newline at end of file diff --git a/kernel/make/x86/make.config b/kernel/make/x86/make.config index 17f5cca..822d909 100644 --- a/kernel/make/x86/make.config +++ b/kernel/make/x86/make.config @@ -1,2 +1,9 @@ -ARCHFILES := $(shell find src/arch/x86 -type f -name '*.c' -print) -ARCH_CFLAGS := -masm=intel \ No newline at end of file +ARCHFILES := $(shell find src/arch/x86 -type f -name '*.c' -print) \ + $(shell find src/arch/x86 -type f -name '*.nasm' -print) \ + $(shell find src/arch/$(ARCH) -type f -name '*.nasm' -print) +ARCH_CFLAGS := -masm=intel + +obj/$(ARCH)/%.nasm.o: src/%.nasm + @mkdir -p $(@D) + @echo nasm $< + @$(NASM) $(NASMFLAGS) $< -o $@ \ No newline at end of file diff --git a/kernel/make/x86_64/make.config b/kernel/make/x86_64/make.config index 58dd9fd..ed8c0bf 100644 --- a/kernel/make/x86_64/make.config +++ b/kernel/make/x86_64/make.config @@ -1,3 +1,4 @@ -include make/x86/make.config +NASM := nasm -felf64 ARCH_CFLAGS := $(ARCH_CFLAGS) -mcmodel=kernel