1# **************************************************************************** #
4# Makefile :+: :+: :+: #
6# By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ #
8# Created: 2025/03/15 19:38:29 by kamitsui #+# #+# #
9# Updated: 2025/05/16 14:56:01 by kamitsui ### ########.fr #
11# **************************************************************************** #
14# @brief This File is a Makefile for building Fixed class in ex02 directory.
21SRCS = main.cpp ClapTrap.cpp ScavTrap.cpp FragTrap.cpp
23# Object files and dependency files
24OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS:.cpp=.o))
25DEPS = $(addprefix $(DEP_DIR)/, $(SRCS:.cpp=.d))
32CXXFLAGS = -Wall -Wextra -Werror -std=c++98
33CF_DEP = -MMD -MP -MF $(@:$(OBJ_DIR)/%.o=$(DEP_DIR)/%.d)
35# Rules for building object files
39 $(CXX) $(CXXFLAGS) $(CF_DEP) -c $< -o $@
41# Rules for building dependency files
45# Enable dependency file
54 $(CXX) $(CXXFLAGS) $(OBJS) -o $(NAME)
55 $(call ASCII_ART,$(NAME))
58TEST_ROOT = ../../cpp_module_tester
59TEST_DIR = $(TEST_ROOT)/cpp03
60URL_TEST_CPP = "https://github.com/kamitsui/cpp_module_tester.git"
61TEST_TARGET = $(TEST_DIR)/ex02_app
66ifeq ($(shell test -d $(TEST_DIR) && echo exist),)
67 @echo "Please clone the test repository"
68 $(call ASK_AND_EXECUTE_ON_YES, git clone $(URL_TEST_CPP) $(TEST_ROOT))
70 $(call ASK_AND_EXECUTE_ON_YES, make -C $(TEST_DIR) $(EX_NUM))
71 $(call ASK_AND_EXECUTE_ON_YES, ./$(TEST_TARGET))
74# Rule for removing object & dependency files
76 rm -rf $(OBJ_DIR) $(DEP_DIR) $(TEST_DIR)/objs $(TEST_DIR)/.deps
79# Rule for removing Target & others
81 rm -f $(NAME) $(TEST_TARGET)
84# Rule for Clean & Build Target
88# ASCII Art : Display Tips the way to use.
90 @echo " _____________________________________________"
92 @echo "< $$ ./a.out >"
94 @echo "< Test Case : >"
95 @echo "< $$ make test >"
96 @echo "----------------------------------------------"
98 @echo " \ (oo)\_______"
105define ASK_AND_EXECUTE_ON_YES
106 @echo "Execute? $(1) (y/n)"
119# Makefile Option : Disable '--print-directory'
120MAKEFLAGS += --no-print-directory