]> git.dkaiser.de - 42/pipex.git/commitdiff
Add libft and prettify the make-process
authorDominik Kaiser <dkaiser@2-D-9.42heilbronn.de>
Mon, 29 Apr 2024 15:24:14 +0000 (17:24 +0200)
committerDominik Kaiser <dkaiser@2-D-9.42heilbronn.de>
Mon, 29 Apr 2024 15:24:14 +0000 (17:24 +0200)
.gitmodules [new file with mode: 0644]
Makefile
include/pipex.h
libft [new submodule]

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..87a27f6
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "libft"]
+       path = libft
+       url = https://github.com/dpu-kaiser/libft
index 2cc3168e5c210307e55fc326c4b32775b0731653..a7c15a4e9252064d129c202f5846294b2fb657a0 100644 (file)
--- 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
index a742093ee90610c78396f3538a7c7452f87a2363..1a79cf1d820ad30d45f54eb695c7fdd42bc2a374 100644 (file)
@@ -6,11 +6,14 @@
 /*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/04/29 14:04:28 by dkaiser           #+#    #+#             */
-/*   Updated: 2024/04/29 14:05:02 by dkaiser          ###   ########.fr       */
+/*   Updated: 2024/04/29 16:38:38 by dkaiser          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
 #ifndef PIPEX_H
 # define PIPEX_H
 
+# include "../libft/libft.h"
+# include <unistd.h>
+
 #endif // PIPEX_H
diff --git a/libft b/libft
new file mode 160000 (submodule)
index 0000000..f4c8da1
--- /dev/null
+++ b/libft
@@ -0,0 +1 @@
+Subproject commit f4c8da1124e7377632f88bdd56e7b1b91a4986e9