From: Lukas Jiriste Date: Tue, 3 Oct 2023 16:46:16 +0000 (+0200) Subject: Added ft_printf as a submodule. X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=2c714ddf0cc3786e9dbb28d955341dcf31537b49;p=Libft.git Added ft_printf as a submodule. Quite some changes where made in Makefile to make it work and it is not pretty. Update to libft.h by the ft_printf function prototype. --- diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f29e137 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "ft_printf"] + path = ft_printf + url = git://78.102.58.167/ft_printf + branch = inLibft diff --git a/Makefile b/Makefile index 1867830..b9c0162 100644 --- a/Makefile +++ b/Makefile @@ -4,27 +4,52 @@ AR = ar RM = rm -f -INCDIR = . SRCDIR = . -# SOURCES = $(addprefix $(SRCDIR)/, ft_putchar.c ft_putstr.c ft_strcmp.c ft_strlen.c ft_swap.c) +INCDIR = $(SRCDIR) SOURCES = $(shell find $(SRCDIR) -maxdepth 1 -name "*.c") OBJECTS = $(SOURCES:.c=.o) +# Temporary dir to extract all sub-libraries to +LIBTEMP = .libtemp +# This finds all the directories except hidden ones and '.' (assumes only visible dirs are project ones) +# It may prove better to find dirs with Makefiles inside +COMPLEX_PROJECTS := $(shell find $(SRCDIR) -maxdepth 1 -not -path '*/.*' -not -name . -type d) + +COMPLEX_LIBS = $(foreach DIR, $(COMPLEX_PROJECTS:./%=%), ./$(DIR)/$(DIR).a) + NAME = libft.a all : $(NAME) -$(NAME) : $(OBJECTS) - $(AR) rcs $(NAME) $(OBJECTS) +$(NAME) : $(OBJECTS) $(COMPLEX_LIBS) $(LIBTEMP) + for lib in $(COMPLEX_LIBS) ; do \ + $(AR) x $$lib --output $(LIBTEMP) ; \ + done + $(AR) rcs $(NAME) $(OBJECTS) $(shell find $(LIBTEMP) -type f) %.o : %.c $(CC) $(CFLAGS) -o $@ -c $< -I $(INCDIR) +$(COMPLEX_LIBS) : + $(MAKE) -C $(shell dirname $@) + +$(LIBTEMP): + mkdir -p $(LIBTEMP) + clean : - $(RM) $(OBJECTS) $(BONUS_OBJECTS) + $(RM) $(OBJECTS) + $(RM) -r $(LIBTEMP) + for subpr in $(COMPLEX_PROJECTS) ; do \ + $(MAKE) -C $$subpr clean ; \ + done -fclean : clean +fclean : $(RM) $(NAME) + $(RM) $(OBJECTS) + $(RM) -r $(LIBTEMP) + for subpr in $(COMPLEX_PROJECTS) ; do \ + $(MAKE) -C $$subpr fclean ; \ + done re : fclean $(MAKE) all diff --git a/ft_printf b/ft_printf new file mode 160000 index 0000000..7f5ddfc --- /dev/null +++ b/ft_printf @@ -0,0 +1 @@ +Subproject commit 7f5ddfc2e05cf67a9aa52e77fb6fab96439b0d65 diff --git a/libft.h b/libft.h index 2a9f9ec..4178e77 100644 --- a/libft.h +++ b/libft.h @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/08/15 12:58:15 by ljiriste #+# #+# */ -/* Updated: 2023/09/15 18:43:23 by ljiriste ### ########.fr */ +/* Updated: 2023/10/03 16:28:50 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -67,6 +67,7 @@ void ft_putchar_fd(char c, int fd); void ft_putstr_fd(char *s, int fd); void ft_putendl_fd(char *s, int fd); void ft_putnbr_fd(int n, int fd); +int ft_printf(const char *format, ...); typedef struct s_list {