Update Libft and Makefile
authorLukáš Jiřiště <gymnazium.jiriste@gmail.com>
Sun, 15 Dec 2024 07:30:30 +0000 (08:30 +0100)
committerLukáš Jiřiště <gymnazium.jiriste@gmail.com>
Sun, 15 Dec 2024 08:00:11 +0000 (09:00 +0100)
.gitignore
Libft
Makefile
src/main.c

index b4d162eb327a22d58a6c66f0825beea8a811fd73..a1fa47dd17687d00588351e0c286f60ca56a91d7 100644 (file)
@@ -1,3 +1,4 @@
 FET_sim
 *.[oa]
 *.swp
+.debug
diff --git a/Libft b/Libft
index 0c6fb946da0bd3d8a0a15e4686020b3e103cdede..62f583c8ab43754b5265c708243f3f5353ebfa1e 160000 (submodule)
--- a/Libft
+++ b/Libft
@@ -1 +1 @@
-Subproject commit 0c6fb946da0bd3d8a0a15e4686020b3e103cdede
+Subproject commit 62f583c8ab43754b5265c708243f3f5353ebfa1e
index d5e8252e04fe49cfb2fd56682e088711cf8d659b..1e65f98d6dee65c8ac267daacd317560f4d950a3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,10 @@
 CC := gcc
-CFLAGS = -std=c99 -Wall -Wextra -Werror -Wpedantic
+CFLAGS := -std=c99 -Wall -Wextra -Werror -Wpedantic
+LDFLAGS := -L Libft -lft
+
+ifneq ("$(wildcard .debug)","")
+       CFLAGS += -g
+endif
 
 RM := rm -f
 
@@ -39,18 +44,26 @@ NAME := FET_sim
 
 all : $(NAME)
 
-debug : CFLAGS += -g
-debug : $(NAME)
+debug : .debug
+       $(MAKE) -C Libft debug
+       $(MAKE) all
+
+nodebug :
+       $(MAKE) -C Libft nodebug
+       $(RM) .debug
+       $(MAKE) shallow_re
 
-$(NAME) : $(OBJECTS) Libft/libft.a
-       $(CC) $(CFLAGS) -o $@ $^
+.% :
+       $(MAKE) shallow_fclean
+       touch $@
 
-Libft/libft.a : | Libft/Makefile
-ifneq (,$(findstring debug, $(MAKECMDGOALS)))
-       $(MAKE) -C Libft debug
-else
+FORCE : ;
+
+Libft/libft.a : FORCE
        $(MAKE) -C Libft
-endif
+
+$(NAME) : $(OBJECTS) Libft/libft.a
+       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
 
 %.o : %.c | Libft/Makefile
        $(CC) $(CFLAGS) -o $@ -c $< $(INCLUDE)
@@ -62,7 +75,14 @@ clean :
        $(RM) $(OBJECTS)
 
 fclean : clean
+       $(MAKE) -C Libft fclean
        $(RM) $(NAME)
 
 re : fclean
        $(MAKE) all
+
+shallow_fclean : clean
+       $(RM) $(NAME)
+
+shallow_re : shallow_fclean
+       $(MAKE) all
index 769e87fbfa458a32e1aded92e08a30cc5e7aa3bc..bfcdeb4ae94a6dd027b7086d6434edbfcf164f10 100644 (file)
@@ -233,7 +233,7 @@ int get_input(t_input *input, int fd)
        }
        if (str_inp[0] && str_inp[ft_strlen(str_inp) - 1] == '\n')
                str_inp[ft_strlen(str_inp) - 1] = '\0';
-       split_inp = ft_split(str_inp, ' ');
+       split_inp = ft_split(str_inp, " ");
        res = construct_input(input, split_inp);
        if (!res)
        {