68 lines
1.5 KiB
Makefile
68 lines
1.5 KiB
Makefile
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
|
# . name = value . name is case sensitive #
|
|
# VARIABLES . or name = value \ . use VPATH only for .c #
|
|
# . value . or .cpp #
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
|
|
|
NAME = robots
|
|
|
|
CC = c++
|
|
CFLAGS = -Wall -Wextra -Werror $(INCLUDES) -std=c++98
|
|
|
|
VPATH = $(D_SRCS)
|
|
|
|
LIBS =
|
|
|
|
INCLUDES = -I$(D_HEADERS)
|
|
|
|
D_SRCS = .
|
|
SRCS = main.cpp \
|
|
ClapTrap.cpp \
|
|
ScavTrap.cpp
|
|
|
|
D_HEADERS = .
|
|
HEADERS = ClapTrap.hpp \
|
|
ScavTrap.hpp
|
|
|
|
D_OBJS = builds
|
|
OBJS = $(SRCS:%.cpp=$(D_OBJS)/%.o)
|
|
|
|
RM_D_OBJS = rm -rf $(D_OBJS)
|
|
ifeq "$(D_OBJS)" "."
|
|
RM_D_OBJS =
|
|
endif
|
|
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
|
# . target: prerequisites . $@ : target #
|
|
# RULES . recipe . $< : 1st prerequisite #
|
|
# . recipe . $^ : all prerequisites #
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
|
|
|
all: $(NAME)
|
|
|
|
$(D_OBJS)/%.o: %.cpp | $(D_OBJS)
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
$(D_OBJS):
|
|
mkdir $@
|
|
|
|
$(OBJS): $(HEADERS:%=$(D_HEADERS)/%)
|
|
|
|
$(NAME): $(OBJS)
|
|
$(CC) $(OBJS) -o $@ $(LIBS)
|
|
|
|
leaks: $(NAME)
|
|
valgrind --leak-check=full --show-leak-kinds=all ./$(NAME)
|
|
|
|
clean:
|
|
rm -f $(OBJS)
|
|
|
|
fclean: clean
|
|
rm -f $(NAME)
|
|
$(RM_D_OBJS)
|
|
|
|
re: fclean all
|
|
|
|
.PHONY : all clean fclean re bonus run valgrind
|