Change Makefile to download submodules
authorLukas Jiriste <ljiriste@student.42prague.com>
Tue, 16 Jan 2024 09:38:15 +0000 (10:38 +0100)
committerLukas Jiriste <ljiriste@student.42prague.com>
Tue, 16 Jan 2024 09:38:15 +0000 (10:38 +0100)
Add target %/Makefile to Makefile and add Makefiles of subprojects as
prerequisites for compilation. This ammends the situation when after git
clone, the submodule folders are empty nad compilation fails because
header files are missing.

Makefile

index 510eea586827738fe10a3a42945323a6bb51f70a..4f55ad5d2ee873696d7470fd50460a6e0ec855a6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -21,13 +21,13 @@ debug : $(NAME)
 $(NAME) : $(OBJS) $(LFT) $(MLX)
        $(CC) $(CFLAGS) $(OBJS) -o $@ $(LINKGRAPH)
 
-%.o : %.c
+%.o : %.c $(LFTDIR)Makefile $(MLX)Makefile
        $(CC) $(CFLAGS) $(INCGRAPH) -c $< -o $@
 
-$(MLX) :
+$(MLX) : | $(MLXDIR)Makefile
        $(MAKE) -C $(MLXDIR)
 
-$(LFT) :
+$(LFT) : | $(LFTDIR)Makefile
 ifneq (,$(findstring debug, $(MAKECMDGOALS)))
        $(MAKE) -C $(LFTDIR) debug
 else
@@ -46,3 +46,6 @@ fclean :
 
 re : fclean
        $(MAKE)
+
+%/Makefile :
+       git submodule update --init $($@%/Makefile=%)