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 /libs/libck/makefile | |
| parent | b7b97d32cbb6fbc928078ebe3a00714cbbebea86 (diff) | |
moved kernel libc stuff to libs/libck/
Diffstat (limited to 'libs/libck/makefile')
| -rw-r--r-- | libs/libck/makefile | 79 |
1 files changed, 79 insertions, 0 deletions
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 |
