Moved lib and modules in kernel/
This commit is contained in:
parent
b677ef2c4f
commit
864d8593a6
|
@ -1,58 +1,47 @@
|
|||
# Stand-alone directories present in lib/.
|
||||
|
||||
SO_DIR := so/
|
||||
INC_DIR := include/
|
||||
|
||||
# Upper directories
|
||||
|
||||
ROOT_DIR := ../
|
||||
SCRIPTS_DIR = $(ROOT_DIR)/scripts/
|
||||
PUBLIC_LIBRARY_DIR := so/
|
||||
INCLUDE_DIR := include/
|
||||
|
||||
# Directories containing actual code for libraries.
|
||||
|
||||
LIB_DIR = $(wildcard */)
|
||||
LIB_DIR := $(filter-out $(SO_DIR), $(LIB_DIR))
|
||||
LIB_DIR := $(filter-out $(INC_DIR), $(LIB_DIR))
|
||||
LIBRARY_DIRS = $(wildcard */)
|
||||
LIBRARY_DIRS := $(filter-out $(PUBLIC_LIBRARY_DIR), $(LIBRARY_DIRS))
|
||||
LIBRARY_DIRS := $(filter-out $(INCLUDE_DIR), $(LIBRARY_DIRS))
|
||||
|
||||
# Library objects.
|
||||
|
||||
LIB_OBJ = $(foreach TMP, $(LIB_DIR), $(wildcard $(TMP)/lobj/*))
|
||||
LIBRARY_OBJS = $(foreach TMP, $(LIBRARY_DIRS), $(wildcard $(TMP)lobj/*))
|
||||
|
||||
# Name of the resulted shared object.
|
||||
|
||||
SO := libklib.a
|
||||
|
||||
# Archiver
|
||||
# Archiver flags
|
||||
|
||||
AR = i686-elf-ar
|
||||
ARFLAGS = rcs
|
||||
|
||||
# Makefile for each library
|
||||
|
||||
MAKEFILE = $(SCRIPTS_DIR)/Makefile.Library
|
||||
MAKEFILE = Makefile.Library
|
||||
|
||||
all: rbuild
|
||||
$(AR) $(ARFLAGS) $(SO_DIR)/$(SO) $(LIB_OBJ)
|
||||
all: lib_build
|
||||
mkdir -p $(PUBLIC_LIBRARY_DIR)
|
||||
$(AR) $(ARFLAGS) $(PUBLIC_LIBRARY_DIR)$(SO) $(LIBRARY_OBJS)
|
||||
|
||||
# Build all libraries recursively.
|
||||
|
||||
rbuild:
|
||||
lib_build:
|
||||
@echo
|
||||
@$(foreach LIB, $(LIB_DIR), \
|
||||
@$(foreach LIB, $(LIBRARY_DIRS), \
|
||||
cp $(MAKEFILE) $(LIB)/Makefile; \
|
||||
$(MAKE) -C $(LIB); \
|
||||
$(RM) $(LIB)/Makefile; \
|
||||
echo; \
|
||||
)
|
||||
|
||||
# Clean all libraries recursively.
|
||||
|
||||
clean:
|
||||
@echo
|
||||
@$(foreach LIB, $(LIB_DIR), \
|
||||
@$(foreach LIB, $(LIBRARY_DIRS), \
|
||||
cp $(MAKEFILE) $(LIB)/Makefile; \
|
||||
$(MAKE) -C $(LIB) clean; \
|
||||
$(RM) $(LIB)/Makefile; \
|
||||
echo; \
|
||||
)
|
||||
@$(RM) -rv $(SO_DIR)/$(SO)
|
||||
@$(RM) -rv $(PUBLIC_LIBRARY_DIR)
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
# Stand-alone directories used to fetch source files and create object
|
||||
# files.
|
||||
|
||||
SRC_DIR := src/
|
||||
ASM_DIR := asm/
|
||||
OBJ_DIR := obj
|
||||
LOBJ_DIR := lobj
|
||||
|
||||
# Directory where library interfaces are kept.
|
||||
|
||||
INC_DIR := ../include/
|
||||
|
||||
# Final object file created by this library. It will have the same name
|
||||
# as the library directory.
|
||||
|
||||
LIB_NAME = $(notdir $(shell pwd))
|
||||
LIB_OBJ := $(LOBJ_DIR)/$(LIB_NAME).o
|
||||
|
||||
# C and assembly source code files.
|
||||
|
||||
SRC := $(wildcard $(SRC_DIR)/*.c)
|
||||
ASM := $(wildcard $(ASM_DIR)/*.s)
|
||||
|
||||
# Objects created from source files.
|
||||
|
||||
OBJ := $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
|
||||
OBJ += $(ASM:$(ASM_DIR)/%.s=$(OBJ_DIR)/%.o)
|
||||
|
||||
# Compiler settings.
|
||||
|
||||
CC = i686-elf-gcc
|
||||
CCFLAGS = -ffreestanding -mno-red-zone -c
|
||||
CCFLAGS += -Wall -Wextra -Werror -pedantic
|
||||
HFLAGS = -MMD
|
||||
|
||||
# Linker settings.
|
||||
|
||||
LD = i686-elf-gcc
|
||||
LDFLAGS = -r -nostdlib -ffreestanding -lgcc
|
||||
|
||||
# Include flags.
|
||||
|
||||
INCFLAGS := $(foreach TMP, $(INC_DIR), -I$(TMP))
|
||||
|
||||
# Assembler and flags for assembler.
|
||||
|
||||
AS = i686-elf-as
|
||||
ASFLAGS =
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
# Start of rules.
|
||||
|
||||
all: $(LIB_OBJ)
|
||||
|
||||
$(LIB_OBJ): $(OBJ) | $(LOBJ_DIR)
|
||||
$(LD) $(OBJ) -o $@ $(LDFLAGS)
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
|
||||
$(CC) $< -o $@ $(CCFLAGS) $(HFLAGS) $(INCFLAGS)
|
||||
|
||||
$(OBJ_DIR)/%.o: $(ASM_DIR)/%.s | $(OBJ_DIR)
|
||||
$(AS) $< -o $@ $(ASFLAGS)
|
||||
|
||||
$(LOBJ_DIR) $(OBJ_DIR):
|
||||
mkdir -p $@
|
||||
|
||||
clean:
|
||||
@$(RM) -rv $(LOBJ_DIR) $(OBJ_DIR)
|
||||
|
||||
-include $(OBJ:.o=.d)
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef STDDEF_H_
|
||||
#define STDDEF_H_
|
||||
|
||||
#define size_t unsigned long
|
||||
|
||||
#endif
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef STDINT_H_
|
||||
#define STDINT_H_
|
||||
|
||||
/* Abstractions over integer data types. */
|
||||
|
||||
/* Signed types. */
|
||||
|
||||
typedef char int8_t;
|
||||
typedef short int16_t;
|
||||
typedef int int32_t;
|
||||
typedef long int64_t;
|
||||
|
||||
/* Unsigned types. */
|
||||
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned long uint64_t;
|
||||
|
||||
#endif
|
|
@ -1,2 +0,0 @@
|
|||
# This is the folder where archives and shared liraries are placed. I put a
|
||||
# gitignore here because git doesn't allow empty folders to be uploaded.
|
|
@ -1,4 +1,4 @@
|
|||
#include "vga.h"
|
||||
#include "lib/vga.h"
|
||||
|
||||
uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg) {
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "cursor.h"
|
||||
|
||||
#include "memio.h"
|
||||
#include "vga.h"
|
||||
#include "lib/memio.h"
|
||||
#include "lib/vga.h"
|
||||
|
||||
/*
|
||||
* screen_move_cursor:
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "screen.h"
|
||||
#include "kernel/screen.h"
|
||||
|
||||
#include "framebuffer.h"
|
||||
#include "cursor.h"
|
||||
|
||||
#include "vga.h"
|
||||
#include "memio.h"
|
||||
#include "lib/vga.h"
|
||||
#include "lib/memio.h"
|
||||
|
||||
/*
|
||||
* Variables that determine the state of the screen.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "ports.h"
|
||||
#include "commands.h"
|
||||
|
||||
#include "memio.h"
|
||||
#include "lib/memio.h"
|
||||
|
||||
/*
|
||||
* serial_config_baud_rate:
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "serial.h"
|
||||
#include "kernel/serial.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "status.h"
|
||||
#include "ports.h"
|
||||
|
||||
#include "memio.h"
|
||||
#include "lib/memio.h"
|
||||
|
||||
/* Private functions declaration. */
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "ports.h"
|
||||
#include "commands.h"
|
||||
|
||||
#include "memio.h"
|
||||
#include "lib/memio.h"
|
||||
|
||||
int serial_is_transmit_fifo_empty(uint16_t com) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue