makefile ok
This commit is contained in:
69
Makefile
69
Makefile
@@ -3,72 +3,59 @@
|
|||||||
# variables names # value
|
# variables names # value
|
||||||
# - - - - - - - - - - - - - - # ! name is case sensitive
|
# - - - - - - - - - - - - - - # ! name is case sensitive
|
||||||
|
|
||||||
NAME = minitalk
|
SERVER = server
|
||||||
|
CLIENT = client
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
VPATH = srcs
|
VPATH = srcs
|
||||||
|
|
||||||
IDIR = ./includes
|
S_SRCS = server.c
|
||||||
_DEPS = fdf.h
|
C_SRCS = client.c
|
||||||
DEPS = $(_DEPS:%.h=$(IDIR)/%.h)
|
|
||||||
|
ODIR = ./builds
|
||||||
|
S_OBJS = $(S_SRCS:%.c=$(ODIR)/%.o)
|
||||||
|
C_OBJS = $(C_SRCS:%.c=$(ODIR)/%.o)
|
||||||
|
|
||||||
|
DEPS = ./includes/minitalk.h
|
||||||
|
IDIR = $(dir $(DEPS))
|
||||||
|
# $(dir PATH/TO/FILE) expands to "PATH/TO/" -> the directory of a file
|
||||||
|
|
||||||
LDIR = ./libft
|
LDIR = ./libft
|
||||||
_LIBS = libft.a
|
_LIBS = libft.a
|
||||||
LIBS = $(_LIBS:lib%.a=%)
|
LIBS = $(_LIBS:lib%.a=%)
|
||||||
|
|
||||||
SRCS = fdf.c \
|
CFLAGS = $(IDIR:%=-I%)
|
||||||
parse.c \
|
CFLAGS += -g3 -Wall -Wextra -Werror
|
||||||
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)
|
LFLAGS = -L$(LDIR) -l$(LIBS)
|
||||||
CFLAGS += -I./minilibx-linux-master
|
|
||||||
LFLAGS += -lm -lmlx -lXext -lX11 -L./minilibx-linux-master
|
|
||||||
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - # target: prerequisites | $@ : target
|
# - - - - - - - - - - - - - - # target: prerequisites | $@ : target
|
||||||
# rules to execute # recipe | $< : 1st prerequisite
|
# rules to execute # recipe | $< : 1st prerequisite
|
||||||
# - - - - - - - - - - - - - - # recipe | $^ : all prerequisites
|
# - - - - - - - - - - - - - - # recipe | $^ : all prerequisites
|
||||||
|
|
||||||
all: $(NAME)
|
all: libft $(SERVER) $(CLIENT)
|
||||||
|
|
||||||
$(NAME): $(ODIR) $(OBJS) $(DEPS)
|
libft:
|
||||||
make -C $(LDIR)
|
make -C $(LDIR)
|
||||||
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS)
|
|
||||||
|
|
||||||
bonus: fclean $(ODIR) $(OBJS_B) $(DEPS)
|
$(SERVER): $(S_OBJS) $(DEPS)
|
||||||
make -C $(LDIR)
|
$(CC) $(CFLAGS) -o $@ $< $(LFLAGS)
|
||||||
$(CC) $(CFLAGS) -o fdf $(OBJS_B) $(LFLAGS)
|
|
||||||
|
|
||||||
$(ODIR):
|
$(CLIENT): $(C_OBJS) $(DEPS)
|
||||||
mkdir -p $@
|
$(CC) $(CFLAGS) -o $@ $< $(LFLAGS)
|
||||||
|
|
||||||
$(ODIR)/%.o: %.c
|
$(ODIR)/%.o: %.c | $(ODIR)
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
debug: CFLAGS += -fsanitize=address
|
$(ODIR):
|
||||||
debug: clean $(NAME)
|
mkdir $@
|
||||||
|
|
||||||
leaks: $(NAME)
|
leaks: CFLAGS += -fsanitize=address
|
||||||
valgrind --leak-check=full --show-leak-kinds=all ./$(NAME) maps/42_color.fdf
|
leaks: clean $(NAME)
|
||||||
# valgrind --leak-check=full --leak-resolution=low --show-reachable=yes ./$(NAME) maps/42_color.fdf
|
# or: valgrind --leak-check=full --show-leak-kinds=all ./prgrm
|
||||||
|
# or: valgrind --leak-check=full --leak-resolution=low --show-reachable=yes ./prgrm
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
/bin/rm -f $(OBJS) $(OBJS_B)
|
/bin/rm -f $(S_OBJS) $(C_OBJS)
|
||||||
|
|
||||||
fclean: clean
|
fclean: clean
|
||||||
/bin/rm -rf $(ODIR)
|
/bin/rm -rf $(ODIR)
|
||||||
|
|||||||
BIN
builds/client.o
Normal file
BIN
builds/client.o
Normal file
Binary file not shown.
BIN
builds/server.o
Normal file
BIN
builds/server.o
Normal file
Binary file not shown.
1
libft
Submodule
1
libft
Submodule
Submodule libft added at c335eb1f6a
BIN
srcs/client
BIN
srcs/client
Binary file not shown.
BIN
srcs/server
BIN
srcs/server
Binary file not shown.
Reference in New Issue
Block a user