# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # . name = value . name is case sensitive # # VARIABLES . or name = value \ . use VPATH only for .c # # . value . or .cpp # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # NAME = brain CC = clang++ CFLAGS = -Wall -Wextra -Werror $(INCLUDES) -std=c++98 -g3 VPATH = $(D_SRCS) LIBS = INCLUDES = -I$(D_HEADERS) D_SRCS = . SRCS = main.cpp D_HEADERS = . HEADERS = 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) clean: rm -f $(OBJS) fclean: clean rm -f $(NAME) $(RM_D_OBJS) re: fclean all .PHONY : all clean fclean re bonus run valgrind