init repo with gitignore makefile readme minilibx and libft submodule
This commit is contained in:
87
Makefile
Normal file
87
Makefile
Normal file
@@ -0,0 +1,87 @@
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
# . name = value \ . += append to a variable #
|
||||
# VARIABLES . value . != set result of command #
|
||||
# . name is case sensitive . ?= set if not already set #
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
|
||||
NAME = cube3d
|
||||
VPATH = $(D_SRCS)
|
||||
EXT = c
|
||||
CC = gcc
|
||||
|
||||
# sources
|
||||
D_SRCS = srcs \
|
||||
srcs/init \
|
||||
srcs/hook \
|
||||
srcs/draw \
|
||||
srcs/free
|
||||
|
||||
SRCS = cube3d.c \
|
||||
\
|
||||
init_struct.c \
|
||||
init_parsing.c \
|
||||
\
|
||||
keyhook.c \
|
||||
key_do_action.c \
|
||||
key_is_action_1.c
|
||||
|
||||
# headers
|
||||
D_HEADERS = headers
|
||||
HEADERS = cube3d.h \
|
||||
cube3d_proto.h \
|
||||
cube3d_macro.h \
|
||||
cube3d_struct.h
|
||||
|
||||
INCLUDES = -I$(D_HEADERS) -I$(D_LFT) -I$(D_LMLX)
|
||||
|
||||
# libraries
|
||||
D_LIB = libs
|
||||
D_LFT = $(D_LIB)/libft
|
||||
D_LMLX = $(D_LIB)/minilibx-linux-master
|
||||
|
||||
# objects
|
||||
D_OBJS = builds
|
||||
OBJS = $(SRCS:%.$(EXT)=$(D_OBJS)/%.o)
|
||||
RM_OBJS = rm -rf $(D_OBJS)
|
||||
|
||||
# flags
|
||||
CFLAGS = -Wall -Wextra -Werror $(INCLUDES)
|
||||
CFLAGS += -g3
|
||||
LFLAGS = -L$(D_LFT) -lft
|
||||
LFLAGS += -L$(D_LMLX) -lm -lmlx -lXext -lX11
|
||||
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
# . target: prerequisites . $@ : target #
|
||||
# RULES . recipe . $< : 1st prerequisite #
|
||||
# . recipe . $^ : all prerequisites #
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
$(D_OBJS)/%.o: %.$(EXT) | $(D_OBJS)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(D_OBJS):
|
||||
mkdir $@
|
||||
|
||||
$(OBJS): $(HEADERS:%=$(D_HEADERS)/%)
|
||||
|
||||
$(NAME): $(OBJS)
|
||||
make -C $(D_LFT)
|
||||
$(CC) $(OBJS) -o $@ $(LFLAGS) $(CFLAGS)
|
||||
|
||||
leaks: $(NAME)
|
||||
valgrind --leak-check=full --show-leak-kinds=all ./$(NAME)
|
||||
|
||||
clean:
|
||||
$(RM_OBJS)
|
||||
|
||||
fclean: clean
|
||||
make fclean -C $(D_LFT)
|
||||
rm -f $(NAME)
|
||||
|
||||
re: fclean all
|
||||
|
||||
.PHONY : all clean fclean re
|
||||
|
||||
Reference in New Issue
Block a user