130 lines
3.3 KiB
Makefile
130 lines
3.3 KiB
Makefile
|
|
# - - - - - - - #
|
|
# #
|
|
# COLORS #
|
|
# #
|
|
# - - - - - - - #
|
|
|
|
GRAY = "\e[0;30m"
|
|
RED = "\e[0;31m"
|
|
GREEN = "\e[0;32m"
|
|
YELLOW = "\e[0;33m"
|
|
BLUE = "\e[0;34m"
|
|
PURPLE = "\e[0;35m"
|
|
CYAN = "\e[0;36m"
|
|
WHITE = "\e[0;37m"
|
|
|
|
B_GRAY = "\e[1;30m"
|
|
B_RED = "\e[1;31m"
|
|
B_GREEN = "\e[1;32m"
|
|
B_YELLOW = "\e[1;33m"
|
|
B_BLUE = "\e[1;34m"
|
|
B_PURPLE = "\e[1;35m"
|
|
B_CYAN = "\e[1;36m"
|
|
B_WHITE = "\e[1;37m"
|
|
|
|
RESET = "\e[0m"
|
|
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
|
# . name = value \ . += append to a variable #
|
|
# VARIABLES . value . != set result of command #
|
|
# . . ?= set if not already set #
|
|
# . (case sensitive) . := expand once at definition line #
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
|
|
|
NAME = containers
|
|
NAME_FT = containers_ft
|
|
NAME_STL = containers_stl
|
|
|
|
CC = c++
|
|
EXT = cpp
|
|
|
|
CFLAGS = -Wall -Wextra -Werror $(INCLUDES)
|
|
CFLAGS += -MMD -MP #see end-page note on header dependencie
|
|
CFLAGS += -std=c++98
|
|
CFLAGS += -g3
|
|
|
|
CFLAGS_STL = $(CFLAGS)
|
|
CFLAGS_STL += -D STL
|
|
|
|
VPATH = $(D_SRCS)
|
|
|
|
LIBS =
|
|
|
|
D_INCLUDE = ./headers \
|
|
./templates \
|
|
./tests/includes
|
|
|
|
INCLUDES = $(D_INCLUDE:%=-I%)
|
|
|
|
D_SRCS = ./tests
|
|
#SRCS = main42.cpp
|
|
#SRCS = main_map_1.cpp
|
|
#SRCS = main_map_2.cpp
|
|
#SRCS = main_stack_1.cpp
|
|
SRCS = main.cpp \
|
|
tests_definitions.cpp \
|
|
tests_vector.cpp \
|
|
tests_map.cpp \
|
|
tests_stack.cpp
|
|
|
|
D_OBJS_FT = builds_ft
|
|
OBJS_FT = $(SRCS:%.$(EXT)=$(D_OBJS_FT)/%.o)
|
|
D_OBJS_STL = builds_stl
|
|
OBJS_STL = $(SRCS:%.$(EXT)=$(D_OBJS_STL)/%.o)
|
|
|
|
OBJS = $(OBJS_FT) $(OBJS_STL)
|
|
DEPS = $(OBJS:.o=.d) #see end-page note on header dependencie
|
|
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
|
# . target: prerequisites . $@ : target #
|
|
# RULES . recipe . $< : 1st prerequisite #
|
|
# . @recipe (silent) . $^ : all prerequisites #
|
|
# . target: VAR = assignment . | : order-only prereq. #
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
|
|
|
all: $(NAME_FT) $(NAME_STL)
|
|
stl: $(NAME_STL)
|
|
ft: $(NAME_FT)
|
|
|
|
$(D_OBJS_FT)/%.o: %.$(EXT) | $(D_OBJS_FT)
|
|
@echo $(CYAN)"compilation " $@ $(RESET)
|
|
@$(CC) $(CFLAGS) -c $< -o $@
|
|
$(D_OBJS_STL)/%.o: %.$(EXT) | $(D_OBJS_STL)
|
|
@echo $(CYAN)"compilation -D STL" $@ $(RESET)
|
|
@$(CC) $(CFLAGS) -D STL -c $< -o $@
|
|
|
|
$(D_OBJS_FT) $(D_OBJS_STL):
|
|
mkdir $@
|
|
|
|
$(NAME_FT): $(OBJS_FT)
|
|
$(NAME_STL): $(OBJS_STL)
|
|
$(NAME_FT) $(NAME_STL):
|
|
@echo $(PURPLE)"linkage (link objects.o)"$(RESET)
|
|
@$(CC) $^ -o $@ $(LIBS)
|
|
|
|
leaks: leaksft
|
|
leaksft: $(NAME_FT)
|
|
valgrind --leak-check=full --show-leak-kinds=all ./$<
|
|
leakstl: $(NAME_STL)
|
|
valgrind --leak-check=full --show-leak-kinds=all ./$<
|
|
|
|
clean:
|
|
rm -rf $(D_OBJS_FT)
|
|
rm -rf $(D_OBJS_STL)
|
|
|
|
fclean: clean
|
|
rm -f $(NAME_FT) $(NAME_STL)
|
|
|
|
re: fclean all
|
|
|
|
.PHONY : all clean fclean re
|
|
|
|
# header dependencie
|
|
# https://spin.atomicobject.com/2016/08/26/makefile-c-projects
|
|
# https://stackoverflow.com/questions/13432127/how-to-use-the-include-directive-in-a-makefile-for-a-specific-target
|
|
-include $(DEPS)
|
|
|