From 138c0efa33990ae16d9d950181d65d8b3dfc60c9 Mon Sep 17 00:00:00 2001 From: aqua Date: Fri, 28 Oct 2022 16:40:46 +0300 Subject: makefile: add libk target --- Makefile | 28 ++++++++++++++++++++++++++++ i686/toolchain.mk | 10 ++++++++++ lib/targets.mk | 6 ++++++ 3 files changed, 44 insertions(+) create mode 100644 Makefile create mode 100644 i686/toolchain.mk create mode 100644 lib/targets.mk 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} $@ $^ + -- cgit v1.2.1