From 87f506fc6edf8140cc6ec1aede38bb316a2e4933 Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Mon, 29 Apr 2024 17:24:14 +0200 Subject: [PATCH] Add libft and prettify the make-process --- .gitmodules | 3 +++ Makefile | 21 ++++++++++++++------- include/pipex.h | 5 ++++- libft | 1 + 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 .gitmodules create mode 160000 libft diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..87a27f6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libft"] + path = libft + url = https://github.com/dpu-kaiser/libft diff --git a/Makefile b/Makefile index 2cc3168..a7c15a4 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ NAME := pipex CC = cc CFLAGS = -Wall -Wextra -Werror HEADERS = -Iinclude -LIBS = +LIBS = -Llibft -lft VPATH := src SRC = main.c @@ -14,27 +14,34 @@ OBJ := $(addprefix $(OBJ_DIR)/, $(SRC:%.c=%.o)) all: $(NAME) -$(NAME): $(OBJ) - $(CC) $(CFLAGS) $(HEADERS) $^ -o $@ $(LIBS) +$(NAME): $(OBJ) | libft + @$(CC) $(CFLAGS) $(HEADERS) $^ -o $@ $(LIBS) + @echo "[$(NAME)] Created binary." $(OBJ_DIR)/%.o: %.c @if [ ! -d "$(OBJ_DIR)" ]; then \ mkdir $(OBJ_DIR); \ fi - $(CC) $(CFLAGS) $(HEADERS) -c $< -o $@ + @$(CC) $(CFLAGS) $(HEADERS) -c $< -o $@ + @echo "[$(NAME)] Compiled $<." + +libft: + @make -C libft clean: + @make -C libft clean @if [ -d "$(OBJ_DIR)" ]; then \ rm -rf $(OBJ_DIR); \ - echo "Removed object files."; \ + echo "[$(NAME)] Removed object files."; \ fi fclean: clean + @make -C libft fclean @if [ -f "$(NAME)" ]; then \ rm -f $(NAME); \ - echo "Removed binary."; \ + echo "[$(NAME)] Removed binary."; \ fi re: fclean all -.PHONY: all clean fclean re +.PHONY: all libft clean fclean re diff --git a/include/pipex.h b/include/pipex.h index a742093..1a79cf1 100644 --- a/include/pipex.h +++ b/include/pipex.h @@ -6,11 +6,14 @@ /* By: dkaiser + #endif // PIPEX_H diff --git a/libft b/libft new file mode 160000 index 0000000..f4c8da1 --- /dev/null +++ b/libft @@ -0,0 +1 @@ +Subproject commit f4c8da1124e7377632f88bdd56e7b1b91a4986e9 -- 2.47.2