diff --git a/Makefile b/Makefile index dc2852e..bbcc4d1 100644 --- a/Makefile +++ b/Makefile @@ -3,72 +3,59 @@ # variables names # value # - - - - - - - - - - - - - - # ! name is case sensitive -NAME = minitalk +SERVER = server +CLIENT = client +CC = gcc +VPATH = srcs -CC = gcc +S_SRCS = server.c +C_SRCS = client.c -VPATH = srcs +ODIR = ./builds +S_OBJS = $(S_SRCS:%.c=$(ODIR)/%.o) +C_OBJS = $(C_SRCS:%.c=$(ODIR)/%.o) -IDIR = ./includes -_DEPS = fdf.h -DEPS = $(_DEPS:%.h=$(IDIR)/%.h) +DEPS = ./includes/minitalk.h +IDIR = $(dir $(DEPS)) +# $(dir PATH/TO/FILE) expands to "PATH/TO/" -> the directory of a file -LDIR = ./libft -_LIBS = libft.a -LIBS = $(_LIBS:lib%.a=%) +LDIR = ./libft +_LIBS = libft.a +LIBS = $(_LIBS:lib%.a=%) -SRCS = fdf.c \ - parse.c \ - modifs.c \ - draw.c \ - keypress.c - -SRCS_B = fdf.c \ - parse.c \ - modifs.c \ - keypress_bonus.c \ - draw_bonus.c - -ODIR = ./builds -OBJS = $(SRCS:%.c=$(ODIR)/%.o) -OBJS_B = $(SRCS_B:%.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 +CFLAGS = $(IDIR:%=-I%) +CFLAGS += -g3 -Wall -Wextra -Werror +LFLAGS = -L$(LDIR) -l$(LIBS) # - - - - - - - - - - - - - - # target: prerequisites | $@ : target # rules to execute # recipe | $< : 1st prerequisite # - - - - - - - - - - - - - - # recipe | $^ : all prerequisites -all: $(NAME) +all: libft $(SERVER) $(CLIENT) -$(NAME): $(ODIR) $(OBJS) $(DEPS) +libft: make -C $(LDIR) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) -bonus: fclean $(ODIR) $(OBJS_B) $(DEPS) - make -C $(LDIR) - $(CC) $(CFLAGS) -o fdf $(OBJS_B) $(LFLAGS) +$(SERVER): $(S_OBJS) $(DEPS) + $(CC) $(CFLAGS) -o $@ $< $(LFLAGS) -$(ODIR): - mkdir -p $@ +$(CLIENT): $(C_OBJS) $(DEPS) + $(CC) $(CFLAGS) -o $@ $< $(LFLAGS) -$(ODIR)/%.o: %.c +$(ODIR)/%.o: %.c | $(ODIR) $(CC) $(CFLAGS) -c -o $@ $< -debug: CFLAGS += -fsanitize=address -debug: clean $(NAME) +$(ODIR): + mkdir $@ -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 +leaks: CFLAGS += -fsanitize=address +leaks: clean $(NAME) +# or: valgrind --leak-check=full --show-leak-kinds=all ./prgrm +# or: valgrind --leak-check=full --leak-resolution=low --show-reachable=yes ./prgrm clean: - /bin/rm -f $(OBJS) $(OBJS_B) + /bin/rm -f $(S_OBJS) $(C_OBJS) fclean: clean /bin/rm -rf $(ODIR) diff --git a/builds/client.o b/builds/client.o new file mode 100644 index 0000000..d2aa12b Binary files /dev/null and b/builds/client.o differ diff --git a/builds/server.o b/builds/server.o new file mode 100644 index 0000000..250856b Binary files /dev/null and b/builds/server.o differ diff --git a/client b/client new file mode 100755 index 0000000..44213f8 Binary files /dev/null and b/client differ diff --git a/libft b/libft new file mode 160000 index 0000000..c335eb1 --- /dev/null +++ b/libft @@ -0,0 +1 @@ +Subproject commit c335eb1f6a77f1db972c9f984962836c476d7e70 diff --git a/server b/server new file mode 100755 index 0000000..c653f6b Binary files /dev/null and b/server differ diff --git a/srcs/client b/srcs/client deleted file mode 100755 index 9b80930..0000000 Binary files a/srcs/client and /dev/null differ diff --git a/srcs/server b/srcs/server deleted file mode 100755 index c879682..0000000 Binary files a/srcs/server and /dev/null differ