fix make file crash with depedencies

This commit is contained in:
David Gailleton
2025-11-11 16:33:30 +01:00
parent a3e7a3d556
commit 3433a95ddd
3 changed files with 72 additions and 74 deletions

View File

@@ -6,12 +6,14 @@ ARFLAGS = rc
HEADER= libft.h HEADER= libft.h
CFLAGS = -Wall -Wextra -Werror CFLAGS= -Wall \
-Wextra \
-Werror
NAME= libft.a NAME= libft.a
SRC = ft_isalpha.c \ SRC= ft_isdigit.c \
ft_isdigit.c \ ft_isalpha.c \
ft_isalnum.c \ ft_isalnum.c \
ft_isascii.c \ ft_isascii.c \
ft_isprint.c \ ft_isprint.c \
@@ -69,28 +71,22 @@ ALL_OBJ = $(OBJ) $(BONUS_OBJ)
ALL_DEP= $(DEP) $(BONUS_DEP) ALL_DEP= $(DEP) $(BONUS_DEP)
%.o: %.c %.o: %.c
$(CC) -o $@ -c $< $(CFLAGS) -I$(HEADER) $(CC) -MMD -MP -o $@ -c $< $(CFLAGS) -I$(HEADER)
%.d: %.c
@set -e; rm -f $@; \
$(CC) -M $(CFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
$(NAME): $(OBJ) $(DEP) $(NAME): $(OBJ)
$(AR) $(ARFLAGS) $(NAME) $(OBJ) $(AR) $(ARFLAGS) $(NAME) $(OBJ)
ranlib $(NAME) ranlib $(NAME)
all: $(NAME) all: $(NAME)
bonus: $(ALL_OBJ) $(ALL_DEP) bonus: $(ALL_OBJ)
$(AR) $(ARFLAGS) $(NAME) $(OBJ) $(BONUS_OBJ) $(AR) $(ARFLAGS) $(NAME) $(ALL_OBJ)
ranlib $(NAME) ranlib $(NAME)
clean: clean:
rm -f $(OBJ) $(BONUS_OBJ) rm -f $(ALL_OBJ) $(ALL_DEP)
fclean: clean fclean: clean
rm -f $(NAME) rm -f $(NAME)

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 09:57:01 by dgaillet #+# #+# */ /* Created: 2025/11/05 09:57:01 by dgaillet #+# #+# */
/* Updated: 2025/11/05 21:08:46 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/11 15:45:19 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/09 15:22:02 by dgaillet #+# #+# */ /* Created: 2025/11/09 15:22:02 by dgaillet #+# #+# */
/* Updated: 2025/11/10 18:19:01 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/11 16:10:09 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -14,6 +14,8 @@
void ft_lstdelone(t_list *lst, void (*del)(void *)) void ft_lstdelone(t_list *lst, void (*del)(void *))
{ {
if (!lst)
return ;
del(lst->content); del(lst->content);
free(lst); free(lst);
} }