From 7865fdf85d18da7deffcfb57c1c3f0082bdc72ff Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Wed, 8 Nov 2017 12:02:36 +0000 Subject: [PATCH] Build kernel in arch directory --- Makefile | 8 +++----- arch/Makefile | 2 ++ arch/none/Makefile | 4 +--- arch/x86/Makefile | 4 +--- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 5108734..3d4027a 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,8 @@ export INCLUDE = $(shell pwd)/include export KERNEL = $(shell pwd)/kernelmq export LIBSRC = $(shell pwd)/src/libsrc.a -export LIBARCH = $(shell pwd)/arch/$(ARCH)/libarch.a export LIBK = $(shell pwd)/libk/libk.a -export LINKER = $(shell pwd)/arch/$(ARCH)/linker.ld export MODULES = $(addprefix $(shell pwd)/modules/, dummy1.bin dummy2.bin) export CFLAGS = -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra -I $(INCLUDE) @@ -32,8 +30,8 @@ test: run-test # Kernel # ########## -all-kernel: all-src all-arch all-libk - $(CC) -T $(LINKER) -o $(KERNEL) -ffreestanding -nostdlib -lgcc $(LIBARCH) $(LIBSRC) $(LIBK) +all-kernel: all-arch + cp arch/$(ARCH)/kernel $(KERNEL) clean-kernel: rm -f $(KERNEL) @@ -52,7 +50,7 @@ clean-src: # arch # ######## -all-arch: +all-arch: all-src all-libk make all -C arch clean-arch: diff --git a/arch/Makefile b/arch/Makefile index 7a7e428..c7c97d8 100644 --- a/arch/Makefile +++ b/arch/Makefile @@ -1,3 +1,5 @@ +export OUTPUT = kernel + ARCHES = $(shell ls -d */) ARCHES := $(ARCHES:/=) diff --git a/arch/none/Makefile b/arch/none/Makefile index bb1d2fe..536853f 100644 --- a/arch/none/Makefile +++ b/arch/none/Makefile @@ -1,5 +1,3 @@ -OUTPUT = libarch.a - OBJS = dummy.c.o all: $(OUTPUT) @@ -8,7 +6,7 @@ clean: rm -f $(OUTPUT) $(OBJS) $(OUTPUT): $(OBJS) - $(AR) -rcs $@ $(OBJS) + $(CC) -T linker.ld -o $(OUTPUT) -ffreestanding -nostdlib -lgcc $(OBJS) $(LIBSRC) $(LIBK) %.c.o: %.c $(CC) -c $< -o $@ -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra -I "$(INCLUDE)" diff --git a/arch/x86/Makefile b/arch/x86/Makefile index bd059ba..0ec92f7 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -1,5 +1,3 @@ -OUTPUT = libarch.a - # Architecture-dependent OBJS = start.s.o OBJS += init.c.o @@ -37,7 +35,7 @@ clean: rm -f $(OUTPUT) $(OBJS) $(OUTPUT): $(OBJS) - $(AR) -rcs $@ $(OBJS) + $(CC) -T linker.ld -o $(OUTPUT) -ffreestanding -nostdlib -lgcc $(OBJS) $(LIBSRC) $(LIBK) %.c.o: %.c $(CC) -c $< -o $@ $(CFLAGS)