makefile ok

This commit is contained in:
hugogogo
2021-08-26 12:38:52 +02:00
parent 2d9dd9e9a9
commit c37cd1bbfe
8 changed files with 33 additions and 45 deletions

View File

@@ -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)

BIN
builds/client.o Normal file

Binary file not shown.

BIN
builds/server.o Normal file

Binary file not shown.

BIN
client Executable file

Binary file not shown.

1
libft Submodule

Submodule libft added at c335eb1f6a

BIN
server Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.