1# **************************************************************************** #
4# Makefile :+: :+: :+: #
6# By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ #
8# Created: 2025/03/15 19:38:29 by kamitsui #+# #+# #
9# Updated: 2025/05/06 00:10:09 by kamitsui ### ########.fr #
11# **************************************************************************** #
14# @brief This File is a Makefile for building Fixed class in ex02 directory.
21SRCS = main.cpp Fixed.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
51 $(CXX) $(CXXFLAGS) $(OBJS) -o $(NAME)
52 $(call ASCII_ART,$(NAME))
55TEST_ROOT = ../../cpp_module_tester
56TEST_DIR = $(TEST_ROOT)/cpp02
57URL_TEST_CPP = "https://github.com/kamitsui/cpp_module_tester.git"
58TEST_TARGET = $(TEST_DIR)/ex02_app
62ifeq ($(shell test -d $(TEST_DIR) && echo exist),)
63 @echo "Please clone the test repository"
64 $(call ASK_AND_EXECUTE_ON_YES, git clone $(URL_TEST_CPP) $(TEST_ROOT))
66 $(call ASK_AND_EXECUTE_ON_YES, make -C $(TEST_DIR) ex02)
67 $(call ASK_AND_EXECUTE_ON_YES, ./$(TEST_TARGET))
70# Rule for removing object & dependency files
72 rm -rf $(OBJ_DIR) $(DEP_DIR) $(TEST_DIR)/objs $(TEST_DIR)/.deps
75# Rule for removing Target & others
77 rm -f $(NAME) $(TEST_DIR)/$(TEST_TARGET)
80# Rule for Clean & Build Target
84# ASCII Art : Display Tips the way to use.
86 @echo " _____________________________________________"
88 @echo "< $$ ./a.out >"
90 @echo "< Test Case : >"
91 @echo "< $$ make test >"
92 @echo "----------------------------------------------"
94 @echo " \ (oo)\_______"
101define ASK_AND_EXECUTE_ON_YES
102 @echo "Execute? $(1) (y/n)"
115# Makefile Option : Disable '--print-directory'
116MAKEFLAGS += --no-print-directory