diff --git a/Makefile b/Makefile index 9fa26d9..5108734 100644 --- a/Makefile +++ b/Makefile @@ -6,11 +6,16 @@ export CC = $(CCPREFIX)gcc export INCLUDE = $(shell pwd)/include export KERNEL = $(shell pwd)/kernelmq -export LIBK = $(shell pwd)/libk/libk.a + +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) + ifeq (none, $(ARCH)) run: test else @@ -27,12 +32,22 @@ test: run-test # Kernel # ########## -all-kernel: all-arch all-libk - $(CC) -T $(LINKER) -o $(KERNEL) -ffreestanding -nostdlib -lgcc $(LIBARCH) $(LIBK) +all-kernel: all-src all-arch all-libk + $(CC) -T $(LINKER) -o $(KERNEL) -ffreestanding -nostdlib -lgcc $(LIBARCH) $(LIBSRC) $(LIBK) clean-kernel: rm -f $(KERNEL) +####### +# src # +####### + +all-src: + make all -C src + +clean-src: + make clean -C src + ######## # arch # ######## diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 7d59921..bd059ba 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -9,7 +9,6 @@ OBJS += pfa.c.o OBJS += paging.c.o paging.asm.cpp.o # Architecture-independent -OBJS += ../../src/info.c.o OBJS += main.c.o # Built-in drivers @@ -41,7 +40,7 @@ $(OUTPUT): $(OBJS) $(AR) -rcs $@ $(OBJS) %.c.o: %.c - $(CC) -c $< -o $@ -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra -I "$(INCLUDE)" + $(CC) -c $< -o $@ $(CFLAGS) %.s.o: %.s $(AS) $< -o $@ diff --git a/libk/Makefile b/libk/Makefile index 45097ac..119c620 100644 --- a/libk/Makefile +++ b/libk/Makefile @@ -1,7 +1,5 @@ OUTPUT = libk.a -CFLAGS = -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra - OBJS = memset.o strlen.o itoa.o strncpy.o all: $(OUTPUT) diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..53bc455 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,14 @@ +OUTPUT = libsrc.a + +OBJS = info.o + +all: $(OUTPUT) + +clean: + rm -f $(OUTPUT) $(OBJS) + +$(OUTPUT): $(OBJS) + $(AR) -rcs $@ $(OBJS) + +%.o: %.c + $(CC) -c $< -o $@ $(CFLAGS)