Build kernel in root directory

This commit is contained in:
Braiden Vasco 2017-11-08 09:38:55 +00:00
parent 82cc935a33
commit 2e23f70e6f
3 changed files with 28 additions and 16 deletions

View File

@ -1,14 +1,20 @@
include config.mk
export AR = $(CCPREFIX)ar
export AS = $(CCPREFIX)as
export CC = $(CCPREFIX)gcc
export INCLUDE = $(shell pwd)/include
export KERNEL = $(shell pwd)/arch/$(ARCH)/kernel.multiboot
export KERNEL = $(shell pwd)/kernelmq.multiboot
export LIBK = $(shell pwd)/libk/libk.a
export LIBARCH = $(shell pwd)/arch/$(ARCH)/libarch.a
export LINKER = $(shell pwd)/arch/$(ARCH)/linker.ld
export MODULES = $(addprefix $(shell pwd)/modules/, dummy1.bin dummy2.bin)
run: run-iso
all: all-kernel all-iso all-libk all-test all-modules
clean: clean-kernel clean-iso clean-libk clean-test clean-modules
all: all-kernel all-iso all-libk all-arch all-test all-modules
clean: clean-kernel clean-iso clean-libk clean-arch clean-test clean-modules
test: run-test
@ -16,10 +22,21 @@ test: run-test
# Kernel #
##########
all-kernel: all-libk
make all -C arch
all-kernel: all-arch all-libk
$(CC) -T $(LINKER) -o $(KERNEL) -ffreestanding -nostdlib -lgcc $(LIBARCH) $(LIBK)
grub-file --is-x86-multiboot2 $(KERNEL)
clean-kernel:
rm -f $(KERNEL)
########
# arch #
########
all-arch:
make all -C arch
clean-arch:
make clean -C arch
#######

View File

@ -1,5 +1,4 @@
AS = $(CCPREFIX)as
CC = $(CCPREFIX)gcc
OUTPUT = libarch.a
# Architecture-dependent
OBJS = start.s.o
@ -33,14 +32,13 @@ OBJS += exception.c.o
OBJS += hwint.c.o
OBJS += syscall.c.o
all: kernel.multiboot
all: $(OUTPUT)
clean:
rm -f kernel.multiboot $(OBJS)
rm -f $(OUTPUT) $(OBJS)
kernel.multiboot: $(OBJS)
$(CC) -T linker.ld -o $@ -ffreestanding -nostdlib -lgcc $(OBJS) $(LIBK)
grub-file --is-x86-multiboot2 $@
$(OUTPUT): $(OBJS)
$(AR) -rcs $@ $(OBJS)
%.c.o: %.c
$(CC) -c $< -o $@ -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra -I "$(INCLUDE)"

View File

@ -1,10 +1,7 @@
AR = $(CCPREFIX)ar
CC = $(CCPREFIX)gcc
OUTPUT = libk.a
CFLAGS = -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra
OUTPUT = libk.a
OBJS = memset.o strlen.o itoa.o strncpy.o
all: $(OUTPUT)