diff options
| author | EmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com> | 2024-01-07 03:19:28 -0500 |
|---|---|---|
| committer | EmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com> | 2024-01-07 03:19:28 -0500 |
| commit | bb59107bd06a6a252b3743f17e55e3c17896db35 (patch) | |
| tree | cb8ad8bbd25fe7d5db6cf734c33f4777843876b9 | |
| parent | b7b97d32cbb6fbc928078ebe3a00714cbbebea86 (diff) | |
moved kernel libc stuff to libs/libck/
| -rw-r--r-- | kernel/makefile | 9 | ||||
| -rw-r--r-- | kernel/std/README.txt | 5 | ||||
| -rw-r--r-- | libs/libck/README.txt | 5 | ||||
| -rw-r--r-- | libs/libck/abort.c (renamed from kernel/std/abort.c) | 0 | ||||
| -rw-r--r-- | libs/libck/include/stdio.h (renamed from kernel/include/stdio.h) | 0 | ||||
| -rw-r--r-- | libs/libck/include/stdlib.h (renamed from kernel/include/stdlib.h) | 0 | ||||
| -rw-r--r-- | libs/libck/include/string.h (renamed from kernel/include/string.h) | 0 | ||||
| -rw-r--r-- | libs/libck/include/sys/cdefs.h (renamed from kernel/include/sys/cdefs.h) | 0 | ||||
| -rw-r--r-- | libs/libck/libck.a | bin | 0 -> 38554 bytes | |||
| -rw-r--r-- | libs/libck/makefile | 79 | ||||
| -rw-r--r-- | libs/libck/memcmp.c (renamed from kernel/std/memcmp.c) | 0 | ||||
| -rw-r--r-- | libs/libck/memcpy.c (renamed from kernel/std/memcpy.c) | 0 | ||||
| -rw-r--r-- | libs/libck/memmove.c (renamed from kernel/std/memmove.c) | 0 | ||||
| -rw-r--r-- | libs/libck/memset.c (renamed from kernel/std/memset.c) | 0 | ||||
| -rw-r--r-- | libs/libck/printf.c (renamed from kernel/std/printf.c) | 0 | ||||
| -rw-r--r-- | libs/libck/putchar.c (renamed from kernel/std/putchar.c) | 0 | ||||
| -rw-r--r-- | libs/libck/puts.c (renamed from kernel/std/puts.c) | 0 | ||||
| -rw-r--r-- | libs/libck/strlen.c (renamed from kernel/std/strlen.c) | 0 | ||||
| -rw-r--r-- | makefile | 17 |
19 files changed, 99 insertions, 16 deletions
diff --git a/kernel/makefile b/kernel/makefile index 6c563b8..a9407bd 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -1,5 +1,4 @@ # Kernel makefile
-#absolute hell
ifndef GAS
GAS = i686-elf-as
@@ -29,7 +28,7 @@ ifndef SYSROOT endif
-LIBS = -nostdlib -lgcc
+LIBS = -nostdlib -lgcc -lck
#Find all the source files
C_SOURCES := $(shell find $(PWD)/kernel -type f -name '*.c')
@@ -44,8 +43,8 @@ OBJECTS := $(patsubst %.c,%.o,$(C_SOURCES)) OBJECTS += $(patsubst %.cpp,%.o,$(CPP_SOURCES))
OBJECTS += $(patsubst %.asm,%.o,$(ASMFILES))
-DEPFILES := $(patsubst %.c,%.d,$(SRCFILES))
-DEPFILES += $(patsubst %.cpp,%.d,$(SRCFILES))
+DEPFILES := $(patsubst %.c,%.d,$(C_SOURCES))
+DEPFILES += $(patsubst %.cpp,%.d,$(CPP_SOURCES))
LINKLST := crti.o
LINKLST += $(CRTBEGIN)
@@ -87,4 +86,4 @@ install-headers: clean:
$(info [INFO] Cleaning)
- rm ${OBJECTS} ${DEPFILES} crti.o crtn.o
\ No newline at end of file + $(RM) ${OBJECTS} $(DEPFILES) crti.o crtn.o
\ No newline at end of file diff --git a/kernel/std/README.txt b/kernel/std/README.txt deleted file mode 100644 index 2ad6cb4..0000000 --- a/kernel/std/README.txt +++ /dev/null @@ -1,5 +0,0 @@ -a temporary(?) libc for the kernel
-
-code from meaty skeleton from osdev.org
-
-todo: change back to .c and seperate it as a library or something
\ No newline at end of file diff --git a/libs/libck/README.txt b/libs/libck/README.txt new file mode 100644 index 0000000..6806bd4 --- /dev/null +++ b/libs/libck/README.txt @@ -0,0 +1,5 @@ +a temporary(?) libc for the kernel
+
+code based off meaty skeleton from osdev.org
+
+todo:
\ No newline at end of file diff --git a/kernel/std/abort.c b/libs/libck/abort.c index 83873e8..83873e8 100644 --- a/kernel/std/abort.c +++ b/libs/libck/abort.c diff --git a/kernel/include/stdio.h b/libs/libck/include/stdio.h index eb4e45b..eb4e45b 100644 --- a/kernel/include/stdio.h +++ b/libs/libck/include/stdio.h diff --git a/kernel/include/stdlib.h b/libs/libck/include/stdlib.h index 1d1ee32..1d1ee32 100644 --- a/kernel/include/stdlib.h +++ b/libs/libck/include/stdlib.h diff --git a/kernel/include/string.h b/libs/libck/include/string.h index 4f6b5bd..4f6b5bd 100644 --- a/kernel/include/string.h +++ b/libs/libck/include/string.h diff --git a/kernel/include/sys/cdefs.h b/libs/libck/include/sys/cdefs.h index 1e2c277..1e2c277 100644 --- a/kernel/include/sys/cdefs.h +++ b/libs/libck/include/sys/cdefs.h diff --git a/libs/libck/libck.a b/libs/libck/libck.a Binary files differnew file mode 100644 index 0000000..1dba359 --- /dev/null +++ b/libs/libck/libck.a diff --git a/libs/libck/makefile b/libs/libck/makefile new file mode 100644 index 0000000..5f7b270 --- /dev/null +++ b/libs/libck/makefile @@ -0,0 +1,79 @@ +# libck makefile
+
+ifndef AR
+ AR = i686-elf-ar
+endif
+
+ifndef CFLAGS
+ CFLAGS = -ffreestanding -Wall -Wextra -g -std=gnu11 -O2 -Iinclude
+ CFLAGS += --sysroot="$(SYSROOT)"
+ CFLAGS += -isystem="/usr/include"
+endif
+
+ifndef CXXFLAGS
+ CXXFLAGS = -ffreestanding -Wall -Wextra -fno-exceptions -fno-rtti -D__is_kernel -g -O2 -Iinclude
+ CXXFLAGS += -Iinclude
+ CXXFLAGS += --sysroot="$(SYSROOT)"
+ CXXFLAGS += -isystem="/usr/include"
+endif
+
+ifndef LDFLAGS
+ LDFLAGS = -T arch/$(ARCH)/linker.ld -ffreestanding -g -O2 -Iinclude
+ LDFLAGS += --sysroot="$(SYSROOT)"
+ LDFLAGS += -isystem="/usr/include"
+endif
+
+ifndef SYSROOT
+ $(error No sysroot specified)
+endif
+
+
+LIBS = -nostdlib -lgcc
+
+#Find all the source files
+C_SOURCES := $(shell find $(PWD) -type f -name '*.c')
+#CPP_SOURCES := $(shell find $(PWD)/kernel -type f -name '*.cpp')
+HEADERS := $(shell find $(PWD) -type f -name '*.h')
+#ASMFILES := $(shell find $(PWD) -type f -name '*.asm')
+
+OBJECTS := $(patsubst %.c,%.o,$(C_SOURCES))
+# OBJECTS += $(patsubst %.cpp,%.o,$(CPP_SOURCES))
+# OBJECTS += $(patsubst %.asm,%.o,$(ASMFILES))
+
+DEPFILES := $(patsubst %.c,%.d,$(C_SOURCES))
+# DEPFILES += $(patsubst %.cpp,%.d,$(CPP_SOURCES))
+
+LINKLST += $(OBJECTS)
+LINKLST += $(LIBS)
+
+-include $(DEPFILES)
+
+.PHONY: all install-headers install-lib clean
+
+all: libck.a install-headers install-lib
+
+libck.a: ${OBJECTS}
+ $(info [INFO] Linking $<)
+ $(AR) rcs $@ $(OBJECTS)
+
+%.o: %.cpp
+ $(info [INFO] Compiling $<)
+ $(CXX) ${CXXFLAGS} -MMD -MP -c $< -o $@
+
+%.o: %.c
+ $(info [INFO] Compiling $<)
+ $(CC) $(CFLAGS) -MMD -MP -c $< -o $@
+
+%.o: %.asm
+ $(info [INFO] Assembling $<)
+ $(NASM) $< -felf32 -o $@ -g
+
+install-headers:
+ cp -r --preserve=timestamps include/. $(SYSROOT)/usr/include
+
+install-lib: libck.a
+ cp -r $< $(SYSROOT)/usr/lib/.
+
+clean:
+ $(info [INFO] Cleaning)
+ $(RM) ${OBJECTS} $(DEPFILES)
\ No newline at end of file diff --git a/kernel/std/memcmp.c b/libs/libck/memcmp.c index 93141e1..93141e1 100644 --- a/kernel/std/memcmp.c +++ b/libs/libck/memcmp.c diff --git a/kernel/std/memcpy.c b/libs/libck/memcpy.c index 7e09be7..7e09be7 100644 --- a/kernel/std/memcpy.c +++ b/libs/libck/memcpy.c diff --git a/kernel/std/memmove.c b/libs/libck/memmove.c index 98c787f..98c787f 100644 --- a/kernel/std/memmove.c +++ b/libs/libck/memmove.c diff --git a/kernel/std/memset.c b/libs/libck/memset.c index 67dadfe..67dadfe 100644 --- a/kernel/std/memset.c +++ b/libs/libck/memset.c diff --git a/kernel/std/printf.c b/libs/libck/printf.c index fe45892..fe45892 100644 --- a/kernel/std/printf.c +++ b/libs/libck/printf.c diff --git a/kernel/std/putchar.c b/libs/libck/putchar.c index c5a7976..c5a7976 100644 --- a/kernel/std/putchar.c +++ b/libs/libck/putchar.c diff --git a/kernel/std/puts.c b/libs/libck/puts.c index 8c8c036..8c8c036 100644 --- a/kernel/std/puts.c +++ b/libs/libck/puts.c diff --git a/kernel/std/strlen.c b/libs/libck/strlen.c index 441622a..441622a 100644 --- a/kernel/std/strlen.c +++ b/libs/libck/strlen.c @@ -16,11 +16,11 @@ ASMFLAGS = -felf32 .PHONY: all kernel.bin grub multiboot_test clean
-all: kernel.bin grub
+all: libck.a kernel.bin grub
-#libc.a:
-# $(info [INFO] Building libc)
-# $(MAKE) -C ./libc/ ARCH=$(ARCH) PREFIX=$(PWD) CC=$(CC) CXX=$(CXX) LD=$(LD) NASM=$(NASM) SYSROOT=$(SYSROOT)
+libck.a:
+ $(info [INFO] Building libck)
+ $(MAKE) -C ./libs/libck/ ARCH=$(ARCH) PREFIX=$(PWD) CC=$(CC) CXX=$(CXX) LD=$(LD) NASM=$(NASM) SYSROOT=$(SYSROOT)
kernel.bin:
$(info [INFO] Building kernel)
@@ -35,11 +35,16 @@ grub: kernel.bin grub.cfg qemu: grub
$(QEMU) -no-shutdown -no-reboot --serial stdio -s -m 512 -hda $(OS_NAME).iso
-install: install-headers
+install: install-headers install-libraries
install-headers:
$(MAKE) -C ./kernel/ install-headers SYSROOT=$(SYSROOT)
+ $(MAKE) -C ./libs/libck/ install-headers SYSROOT=$(SYSROOT)
+
+install-libraries:
+ $(MAKE) -C ./libs/libck/ install-lib SYSROOT=$(SYSROOT)
clean:
-@$(MAKE) -C ./kernel/ clean SYSROOT=$(SYSROOT)
- -@$(RM) $(wildcard *.bin)
+ -@$(MAKE) -C ./libs/libck/ clean SYSROOT=$(SYSROOT)
+ -@$(RM) $(wildcard *.bin *.a)
|
