diff --git a/Makefile b/Makefile index 6f94c80..22e0553 100644 --- a/Makefile +++ b/Makefile @@ -5,48 +5,67 @@ # +:+ > +:++:+ +:+ # # By: whaffman +#+ +:+ +#++#++:++#++ # # +#+ +#+#+ +#++#+ +#+ \o/ # -# Created: 2024/10/15 11:48:46 by whaffman #+#+# #+#+# #+# #+# | # -# Updated: 2024/10/15 12:40:48 by whaffman ### ### ### ### / \ # +# Created: 2024/10/10 16:44:36 by whaffman #+#+# #+#+# #+# #+# | # +# Updated: 2024/10/10 18:00:05 by whaffman ### ### ### ### / \ # # # # **************************************************************************** # NAME = libftprintf.a -SOURCES = ft_printf.c +INC_DIR = inc/ -OBJECTS = $(SOURCES:.c=.o) +OBJ_DIR = obj/ -CC = gcc +CC = cc -CFLAGS = -Wall -Wextra -Werror +WARNINGS = -Wall -Wextra -Werror -AR = ar +CFLAGS = $(WARNINGS) + +VPATH = src:src/conversion:src/ft_printf:src/list:src/memory:src/output:\ + src/string + +SRC_CONVERSION = ft_atoi.c ft_itoa.c ft_tolower.c ft_toupper.c \ + +SRC_MEMORY = ft_memchr.c ft_memcmp.c ft_memcpy.c ft_memmove.c ft_memset.c \ + ft_bzero.c ft_calloc.c + +SRC_STRING = ft_isalnum.c ft_isalpha.c ft_isascii.c ft_isdigit.c ft_isprint.c \ + ft_split.c ft_strchr.c ft_strdup.c ft_striteri.c ft_strjoin.c \ + ft_strlcat.c ft_strlcpy.c ft_strlen.c ft_strmapi.c ft_strncmp.c \ + ft_strnstr.c ft_strrchr.c ft_strtrim.c ft_substr.c + +SRC_LIST = ft_lstadd_back.c ft_lstadd_front.c ft_lstclear.c ft_lstdelone.c \ + ft_lstiter.c ft_lstlast.c ft_lstmap.c ft_lstnew.c ft_lstsize.c + +SRC_OUTPUT = ft_putchar_fd.c ft_putendl_fd.c ft_putnbr_fd.c ft_putstr_fd.c + +SRC_FT_PRINTF = ft_isbase.c ft_putnbr_base.c ft_write_str.c parse_placeholder.c \ + print_hex.c print_pointer.c print_unumber.c ft_printf.c \ + ft_putnbr_signed.c parse_conversion.c print_char.c \ + print_number.c print_string.c + +SOURCES = $(SRC_CONVERSION) $(SRC_MEMORY) $(SRC_STRING) \ + $(SRC_LIST) $(SRC_OUTPUT) $(SRC_FT_PRINTF) + +OBJECTS = $(addprefix $(OBJ_DIR), $(SOURCES:.c=.o)) all: $(NAME) -lib/libft.a: - $(MAKE) -C libft - $(MAKE) -C libft clean - mkdir -p lib - mkdir -p inc - cp libft/libft.h inc/libft.h - mv libft/libft.a lib/libft.a +$(NAME): $(OBJECTS) + $(AR) rcs $@ $? -$(NAME): lib/libft.a $(OBJECTS) - cp lib/libft.a $(NAME) - $(AR) -rcs $@ $? +$(OBJ_DIR)/%.o: %.c + mkdir -o $(OBJ_DIR) + $(CC) $(CFLAGS) -I $(INC_DIR) -c $< -o $@ -%.o: %.c - $(CC) -I./inc -L./lib -lft -c $(CFLAGS) $? +bonus: $(NAME) clean: rm -f $(OBJECTS) - $(MAKE) -C libft clean fclean: clean rm -f $(NAME) - rm -rf lib - $(MAKE) -C libft fclean re: fclean all diff --git a/src/libft/ft_atoi.c b/src/conversion/ft_atoi.c similarity index 100% rename from src/libft/ft_atoi.c rename to src/conversion/ft_atoi.c diff --git a/src/libft/ft_itoa.c b/src/conversion/ft_itoa.c similarity index 100% rename from src/libft/ft_itoa.c rename to src/conversion/ft_itoa.c diff --git a/src/libft/ft_tolower.c b/src/conversion/ft_tolower.c similarity index 100% rename from src/libft/ft_tolower.c rename to src/conversion/ft_tolower.c diff --git a/src/libft/ft_toupper.c b/src/conversion/ft_toupper.c similarity index 100% rename from src/libft/ft_toupper.c rename to src/conversion/ft_toupper.c diff --git a/src/libft/Makefile b/src/libft/Makefile deleted file mode 100644 index 23fa4ae..0000000 --- a/src/libft/Makefile +++ /dev/null @@ -1,54 +0,0 @@ -# **************************************************************************** # -# # -# ::: o_ :::::: ::: # -# Makefile :+: / :+::+: :+: # -# +:+ > +:++:+ +:+ # -# By: whaffman +#+ +:+ +#++#++:++#++ # -# +#+ +#+#+ +#++#+ +#+ \o/ # -# Created: 2024/10/10 16:44:36 by whaffman #+#+# #+#+# #+# #+# | # -# Updated: 2024/10/10 18:00:05 by whaffman ### ### ### ### / \ # -# # -# **************************************************************************** # - -NAME = libft.a - -SOURCES = ft_atoi.c ft_bzero.c ft_calloc.c ft_isalnum.c ft_isalpha.c \ - ft_isascii.c ft_isdigit.c ft_isprint.c ft_itoa.c ft_memchr.c \ - ft_memcmp.c ft_memcpy.c ft_memmove.c ft_memset.c ft_putchar_fd.c \ - ft_putendl_fd.c ft_putnbr_fd.c ft_putstr_fd.c ft_split.c ft_strchr.c \ - ft_strdup.c ft_striteri.c ft_strjoin.c ft_strlcat.c ft_strlcpy.c \ - ft_strlen.c ft_strmapi.c ft_strncmp.c ft_strnstr.c ft_strrchr.c \ - ft_strtrim.c ft_substr.c ft_tolower.c ft_toupper.c - -BONUS_SOURCES = ft_lstadd_back_bonus.c ft_lstadd_front_bonus.c ft_lstclear_bonus.c \ - ft_lstdelone_bonus.c ft_lstiter_bonus.c ft_lstlast_bonus.c ft_lstmap_bonus.c \ - ft_lstnew_bonus.c ft_lstsize_bonus.c - -OBJECTS = $(SOURCES:.c=.o) - -BONUS_OBJECTS = $(BONUS_SOURCES:.c=.o) - -CC = cc -CFLAGS = -Wall -Wextra -Werror - -all: $(NAME) - -$(NAME): $(OBJECTS) - $(AR) -r $@ $? - -bonus: $(OBJECTS) $(BONUS_OBJECTS) - $(AR) -r $(NAME) $? - -%.o: %.c - $(CC) -c $(CFLAGS) $? - -clean: - rm -f $(OBJECTS) $(BONUS_OBJECTS) - -fclean: clean - rm -f $(NAME) - -re: fclean all - -.PHONY: all bonus clean fclean re - diff --git a/src/libft/ft_lstadd_back.c b/src/list/ft_lstadd_back.c similarity index 100% rename from src/libft/ft_lstadd_back.c rename to src/list/ft_lstadd_back.c diff --git a/src/libft/ft_lstadd_front.c b/src/list/ft_lstadd_front.c similarity index 100% rename from src/libft/ft_lstadd_front.c rename to src/list/ft_lstadd_front.c diff --git a/src/libft/ft_lstclear.c b/src/list/ft_lstclear.c similarity index 100% rename from src/libft/ft_lstclear.c rename to src/list/ft_lstclear.c diff --git a/src/libft/ft_lstdelone.c b/src/list/ft_lstdelone.c similarity index 100% rename from src/libft/ft_lstdelone.c rename to src/list/ft_lstdelone.c diff --git a/src/libft/ft_lstiter.c b/src/list/ft_lstiter.c similarity index 100% rename from src/libft/ft_lstiter.c rename to src/list/ft_lstiter.c diff --git a/src/libft/ft_lstlast.c b/src/list/ft_lstlast.c similarity index 100% rename from src/libft/ft_lstlast.c rename to src/list/ft_lstlast.c diff --git a/src/libft/ft_lstmap.c b/src/list/ft_lstmap.c similarity index 100% rename from src/libft/ft_lstmap.c rename to src/list/ft_lstmap.c diff --git a/src/libft/ft_lstnew.c b/src/list/ft_lstnew.c similarity index 100% rename from src/libft/ft_lstnew.c rename to src/list/ft_lstnew.c diff --git a/src/libft/ft_lstsize.c b/src/list/ft_lstsize.c similarity index 100% rename from src/libft/ft_lstsize.c rename to src/list/ft_lstsize.c diff --git a/src/libft/ft_bzero.c b/src/memory/ft_bzero.c similarity index 100% rename from src/libft/ft_bzero.c rename to src/memory/ft_bzero.c diff --git a/src/libft/ft_calloc.c b/src/memory/ft_calloc.c similarity index 100% rename from src/libft/ft_calloc.c rename to src/memory/ft_calloc.c diff --git a/src/libft/ft_memchr.c b/src/memory/ft_memchr.c similarity index 100% rename from src/libft/ft_memchr.c rename to src/memory/ft_memchr.c diff --git a/src/libft/ft_memcmp.c b/src/memory/ft_memcmp.c similarity index 100% rename from src/libft/ft_memcmp.c rename to src/memory/ft_memcmp.c diff --git a/src/libft/ft_memcpy.c b/src/memory/ft_memcpy.c similarity index 100% rename from src/libft/ft_memcpy.c rename to src/memory/ft_memcpy.c diff --git a/src/libft/ft_memmove.c b/src/memory/ft_memmove.c similarity index 100% rename from src/libft/ft_memmove.c rename to src/memory/ft_memmove.c diff --git a/src/libft/ft_memset.c b/src/memory/ft_memset.c similarity index 100% rename from src/libft/ft_memset.c rename to src/memory/ft_memset.c diff --git a/src/libft/ft_putchar_fd.c b/src/output/ft_putchar_fd.c similarity index 100% rename from src/libft/ft_putchar_fd.c rename to src/output/ft_putchar_fd.c diff --git a/src/libft/ft_putendl_fd.c b/src/output/ft_putendl_fd.c similarity index 100% rename from src/libft/ft_putendl_fd.c rename to src/output/ft_putendl_fd.c diff --git a/src/libft/ft_putnbr_fd.c b/src/output/ft_putnbr_fd.c similarity index 100% rename from src/libft/ft_putnbr_fd.c rename to src/output/ft_putnbr_fd.c diff --git a/src/libft/ft_putstr_fd.c b/src/output/ft_putstr_fd.c similarity index 100% rename from src/libft/ft_putstr_fd.c rename to src/output/ft_putstr_fd.c diff --git a/src/libft/ft_isalnum.c b/src/string/ft_isalnum.c similarity index 100% rename from src/libft/ft_isalnum.c rename to src/string/ft_isalnum.c diff --git a/src/libft/ft_isalpha.c b/src/string/ft_isalpha.c similarity index 100% rename from src/libft/ft_isalpha.c rename to src/string/ft_isalpha.c diff --git a/src/libft/ft_isascii.c b/src/string/ft_isascii.c similarity index 100% rename from src/libft/ft_isascii.c rename to src/string/ft_isascii.c diff --git a/src/libft/ft_isdigit.c b/src/string/ft_isdigit.c similarity index 100% rename from src/libft/ft_isdigit.c rename to src/string/ft_isdigit.c diff --git a/src/libft/ft_isprint.c b/src/string/ft_isprint.c similarity index 100% rename from src/libft/ft_isprint.c rename to src/string/ft_isprint.c diff --git a/src/libft/ft_split.c b/src/string/ft_split.c similarity index 100% rename from src/libft/ft_split.c rename to src/string/ft_split.c diff --git a/src/libft/ft_strchr.c b/src/string/ft_strchr.c similarity index 100% rename from src/libft/ft_strchr.c rename to src/string/ft_strchr.c diff --git a/src/libft/ft_strdup.c b/src/string/ft_strdup.c similarity index 100% rename from src/libft/ft_strdup.c rename to src/string/ft_strdup.c diff --git a/src/libft/ft_striteri.c b/src/string/ft_striteri.c similarity index 100% rename from src/libft/ft_striteri.c rename to src/string/ft_striteri.c diff --git a/src/libft/ft_strjoin.c b/src/string/ft_strjoin.c similarity index 100% rename from src/libft/ft_strjoin.c rename to src/string/ft_strjoin.c diff --git a/src/libft/ft_strlcat.c b/src/string/ft_strlcat.c similarity index 100% rename from src/libft/ft_strlcat.c rename to src/string/ft_strlcat.c diff --git a/src/libft/ft_strlcpy.c b/src/string/ft_strlcpy.c similarity index 100% rename from src/libft/ft_strlcpy.c rename to src/string/ft_strlcpy.c diff --git a/src/libft/ft_strlen.c b/src/string/ft_strlen.c similarity index 100% rename from src/libft/ft_strlen.c rename to src/string/ft_strlen.c diff --git a/src/libft/ft_strmapi.c b/src/string/ft_strmapi.c similarity index 100% rename from src/libft/ft_strmapi.c rename to src/string/ft_strmapi.c diff --git a/src/libft/ft_strncmp.c b/src/string/ft_strncmp.c similarity index 100% rename from src/libft/ft_strncmp.c rename to src/string/ft_strncmp.c diff --git a/src/libft/ft_strnstr.c b/src/string/ft_strnstr.c similarity index 100% rename from src/libft/ft_strnstr.c rename to src/string/ft_strnstr.c diff --git a/src/libft/ft_strrchr.c b/src/string/ft_strrchr.c similarity index 100% rename from src/libft/ft_strrchr.c rename to src/string/ft_strrchr.c diff --git a/src/libft/ft_strtrim.c b/src/string/ft_strtrim.c similarity index 100% rename from src/libft/ft_strtrim.c rename to src/string/ft_strtrim.c diff --git a/src/libft/ft_substr.c b/src/string/ft_substr.c similarity index 100% rename from src/libft/ft_substr.c rename to src/string/ft_substr.c