diff options
author | aqua <aqua@iserlohn-fortress.net> | 2022-10-28 16:40:46 +0300 |
---|---|---|
committer | aqua <aqua@iserlohn-fortress.net> | 2022-10-28 16:40:46 +0300 |
commit | 138c0efa33990ae16d9d950181d65d8b3dfc60c9 (patch) | |
tree | 44d018d8b8b634b5d52865bbd7a6c764adc04bb0 | |
parent | Add LICENSE.md (diff) | |
download | kernel-138c0efa33990ae16d9d950181d65d8b3dfc60c9.tar.xz |
makefile: add libk target
-rw-r--r-- | Makefile | 28 | ||||
-rw-r--r-- | i686/toolchain.mk | 10 | ||||
-rw-r--r-- | lib/targets.mk | 6 |
3 files changed, 44 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d7caeea --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +MAKE = make +TARGET = i686 +include ${TARGET}/toolchain.mk + +CCFLAGS += -Ilib -I. + +all: libk.a + +info: + @echo "this is the all target" + @echo "TARGET ${TARGET}" + @echo "BUILD ${BUILD}" + @echo " MAKE ${MAKE}" + @${MAKE} --version | head -n1 + @echo " CC ${CC} ${CCFLAGS}" + @${CC} --version | head -n1 + @echo " LD ${LD} ${LDFLAGS}" + @${LD} --version | head -n1 + +clean: + @rm -rf ${libk,OBJS} + +.SUFFIXES: .c .o +.c.o: + @echo ' CC $^' + @$(CC) $(CCFLAGS) -c -o $@ $^ + +include lib/targets.mk diff --git a/i686/toolchain.mk b/i686/toolchain.mk new file mode 100644 index 0000000..884369c --- /dev/null +++ b/i686/toolchain.mk @@ -0,0 +1,10 @@ +# define compiler, linker, archiver and strip and their flags +# +CC = i686-elf-gcc +CCFLAGS = -Wall -Wextra -Wpedantic -fanalyzer -ffreestanding +LD = i686-elf-ld +LDFLAGS = -nostdlib +AR = i686-elf-ar +STRIP = i686-elf-strip + + diff --git a/lib/targets.mk b/lib/targets.mk new file mode 100644 index 0000000..cbf9da8 --- /dev/null +++ b/lib/targets.mk @@ -0,0 +1,6 @@ +libk,SRCS = lib/memcpy.c lib/memset.c lib/stdio/printf.c lib/string/itoa.c +libk,OBJS = $(libk,SRCS:%.c=%.o) +libk.a: ${libk,OBJS} + @echo ' AR $@' + @${AR} ${ARFLAGS} $@ $^ + |