Moved library linking in root Makefile

This commit is contained in:
lucic71 2020-06-23 19:56:09 +03:00
parent 80faf143d2
commit 5f9d8ed977
2 changed files with 9 additions and 8 deletions

View File

@ -48,6 +48,13 @@ LIB_DIR = lib/
INCFLAGS = $(foreach TMP, $(MODULE_INC_DIR), -I$(TMP))
# Library flags
LIB_SO_DIR := lib/so
LIBFLAGS = $(foreach TMP, $(LIB_SO_DIR), -L$(TMP))
LIBS = -lklib
.PHONY: all clean module_all
# Build
@ -71,7 +78,7 @@ lib_all:
kernel.elf: $(OBJ)
@$(call print_banner, "Building the kernel")
$(LD) $(LDFLAGS) $(OBJ) $(MODULE_OBJ) -o kernel.elf
$(LD) $(LDFLAGS) $(OBJ) $(MODULE_OBJ) -o kernel.elf $(LIBFLAGS) $(LIBS)
# os.iso - Create the OS image and place the kernel fiel in GRUB directory.

View File

@ -19,7 +19,6 @@ MOD_OBJ := $(MOBJ_DIR)/$(CURR_DIR).o
# Library dependencies
LIB_INC_DIR := $(ROOT_DIR)/lib/include
LIB_SO_DIR := $(ROOT_DIR)/lib/so
# Module sources and their object files
@ -38,11 +37,6 @@ HFLAGS = -MMD
LD = ld
LDFLAGS = -relocatable -m elf_i386
# Library flags
LIBFLAGS = $(foreach TMP, $(LIB_SO_DIR), -L$(TMP))
LIBS = -lklib
# INCFLAGS - include directories for each dependency. These dependencies
# include module dependencies and the include directory inside the current
# module
@ -57,7 +51,7 @@ INCFLAGS += $(foreach TMP, $(INC_DIR), -I$(TMP))
all: $(MOD_OBJ)
$(MOD_OBJ): $(OBJ) | $(MOBJ_DIR)
$(LD) $(LDFLAGS) $(OBJ) -o $@ $(LIBFLAGS) $(LIBS)
$(LD) $(LDFLAGS) $(OBJ) -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) $(CCFLAGS) $(HFLAGS) $(INCFLAGS) $< -o $@