makefile really improved on header dependencies
This commit is contained in:
57
Makefile
57
Makefile
@@ -38,70 +38,43 @@ CC = clang++
|
||||
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 = -Wall -Wextra -Werror $(INCLUDES)
|
||||
CFLAGS_STL = $(CFLAGS)
|
||||
CFLAGS_STL += -D STL
|
||||
CFLAGS_STL += -std=c++98
|
||||
CFLAGS_STL += -g3
|
||||
|
||||
VPATH = $(D_SRCS)
|
||||
|
||||
LIBS =
|
||||
|
||||
F_INCLUDES = $(HEADERS:%=$(D_HEADERS)/%) \
|
||||
$(TEMPLATES:%=$(D_TEMPLATES)/%) \
|
||||
$(TESTS:%=$(D_TESTS)/%)
|
||||
INCLUDES = -I$(D_HEADERS) \
|
||||
-I$(D_TEMPLATES) \
|
||||
-I$(D_TESTS)
|
||||
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 \
|
||||
SRCS = main.cpp \
|
||||
tests_definitions.cpp \
|
||||
\
|
||||
tests_vector.cpp \
|
||||
tests_map.cpp \
|
||||
tests_stack.cpp
|
||||
|
||||
D_HEADERS = ./headers
|
||||
HEADERS = \
|
||||
colors.h \
|
||||
\
|
||||
enable_if.hpp \
|
||||
iterator_traits.hpp \
|
||||
reverse_iterator.hpp \
|
||||
equal.hpp \
|
||||
lexicographical_compare.hpp \
|
||||
pair.hpp \
|
||||
\
|
||||
map.hpp \
|
||||
map_node.hpp \
|
||||
map_iterator.hpp \
|
||||
vector.hpp \
|
||||
stack.hpp
|
||||
|
||||
D_TEMPLATES = ./templates
|
||||
TEMPLATES = \
|
||||
vector.tpp \
|
||||
map.tpp
|
||||
|
||||
D_TESTS = ./tests/includes
|
||||
TESTS = \
|
||||
main.hpp \
|
||||
tests_utils.hpp
|
||||
|
||||
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 #
|
||||
@@ -110,7 +83,6 @@ OBJS_STL = $(SRCS:%.$(EXT)=$(D_OBJS_STL)/%.o)
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
|
||||
all: $(NAME_FT) $(NAME_STL)
|
||||
|
||||
stl: $(NAME_STL)
|
||||
ft: $(NAME_FT)
|
||||
|
||||
@@ -124,9 +96,6 @@ $(D_OBJS_STL)/%.o: %.$(EXT) | $(D_OBJS_STL)
|
||||
$(D_OBJS_FT) $(D_OBJS_STL):
|
||||
mkdir $@
|
||||
|
||||
$(OBJS_FT) $(OBJS_STL): $(F_INCLUDES)
|
||||
|
||||
# https://stackoverflow.com/questions/19259108/makefile-same-rule-for-multiple-targets
|
||||
$(NAME_FT): $(OBJS_FT)
|
||||
$(NAME_STL): $(OBJS_STL)
|
||||
$(NAME_FT) $(NAME_STL):
|
||||
@@ -150,3 +119,7 @@ re: fclean all
|
||||
|
||||
.PHONY : all clean fclean re
|
||||
|
||||
# header dependencie
|
||||
# https://spin.atomicobject.com/2016/08/26/makefile-c-projects
|
||||
-include $(DEPS)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user