Files
42_INT_05_minitalk/Makefile

71 lines
1.4 KiB
Makefile

# - - - - - - - - - - - - - - # name = value \
# variables names # value
# - - - - - - - - - - - - - - # ! name is case sensitive
VPATH = srcs
CC = gcc
ODIR = ./builds
IDIR = ./includes ./libft/includes
LDIR = ./libft
LIBS = ft
CFLAGS = $(IDIR:%=-I%)
CFLAGS += -g3 -Wall -Wextra -Werror
LFLAGS = -L./libft -lft
S_NAME = server
S_SRCS = server.c
S_OBJS = $(S_SRCS:%.c=$(ODIR)/%.o)
S_DEPS = ./includes/server.h
C_NAME = client
C_SRCS = client.c
C_OBJS = $(C_SRCS:%.c=$(ODIR)/%.o)
C_DEPS = ./includes/client.h
# - - - - - - - - - - - - - - # target: prerequisites | $@ : target
# rules to execute # recipe | $< : 1st prerequisite
# - - - - - - - - - - - - - - # recipe | $^ : all prerequisites
all: libft $(S_NAME) $(C_NAME)
libft:
@echo "hello"
make -C $(LDIR)
$(S_NAME): $(S_OBJS) $(S_DEPS)
$(CC) $(CFLAGS) -o $@ $< $(LFLAGS)
$(C_NAME): $(C_OBJS) $(C_DEPS)
$(CC) $(CFLAGS) -o $@ $< $(LFLAGS)
$(ODIR)/%.o: %.c | $(ODIR)
$(CC) $(CFLAGS) -c -o $@ $<
$(ODIR):
mkdir $@
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 $(S_OBJS) $(C_OBJS)
fclean: clean
/bin/rm -rf $(ODIR)
/bin/rm -f $(S_NAME) $(C_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