# - - - - - - - - - - - - - - # name = value \ # variables names # value # - - - - - - - - - - - - - - # ! name is case sensitive NAME = fdf CC = gcc VPATH = srcs IDIR = ./includes _DEPS = fdf.h DEPS = $(_DEPS:%.h=$(IDIR)/%.h) LDIR = ./libft _LIBS = libft.a LIBS = $(_LIBS:lib%.a=%) SRCS = fdf.c \ draw.c \ parse.c \ modifs.c \ keypress.c ODIR = ./builds OBJS = $(SRCS:%.c=$(ODIR)/%.o) # flag -g generates debug informations, g3 is maximal version CFLAGS = -I$(IDIR) -g3 -Wall -Wextra -Werror LFLAGS = -L$(LDIR) -l$(LIBS) CFLAGS += -I./minilibx-linux-master LFLAGS += -lm -lmlx -lXext -lX11 -L./minilibx-linux-master # - - - - - - - - - - - - - - # target: prerequisites | $@ : target # rules to execute # recipe | $< : 1st prerequisite # - - - - - - - - - - - - - - # recipe | $^ : all prerequisites all: $(NAME) # it verify if anything has changed in .c and .h files # then it makes LDIR library, then it compiles NAME $(NAME): $(ODIR) $(OBJS) $(DEPS) make -C $(LDIR) $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) # create "builds/" if doesn't exist $(ODIR): mkdir -p $@ # if a file.c has been modified, it's recompiled in object file.o $(ODIR)/%.o: %.c $(CC) $(CFLAGS) -c -o $@ $< debug: CFLAGS += -fsanitize=address debug: clean $(NAME) leaks: $(NAME) valgrind --leak-check=full --show-leak-kinds=all ./$(NAME) maps/42_color.fdf # valgrind --leak-check=full --leak-resolution=low --show-reachable=yes ./$(NAME) maps/42_color.fdf clean: /bin/rm -f $(OBJS) fclean: clean /bin/rm -rf $(ODIR) /bin/rm -f $(NAME) /bin/rm -rf a.out a.out.dSYM libfclean: make fclean -C $(LDIR) re: fclean all relib: libfclean re .PHONY: all clean fclean re gcc