cpp04/ex00/Makefile

50 lines
780 B
Makefile
Raw Normal View History

2025-05-30 08:14:26 +02:00
NAME = ex00
ifeq ($(CPPFLAGS),)
CPPFLAGS = -Wall -Wextra -Werror -std=c++98 -ggdb -fsanitize=address,undefined
endif
ifeq ($(CXX),)
CXX = c++
endif
# g++ is the default on 42 computers
ifeq ($(CXX),g++)
CXX = c++
endif
srcs = \
Animal.cpp \
Cat.cpp \
Dog.cpp \
WrongAnimal.cpp \
WrongDog.cpp \
WrongCat.cpp \
main_objs = main.o $(srcs:.cpp=.o)
all_objs = $(main_objs)
deps = $(all_objs:.o=.d)
.PHONY: all clean fclean re run
all: $(NAME)
-include $(deps)
$(NAME): $(main_objs)
$(CXX) $(CPPFLAGS) -o $@ $^
%.o: %.cpp
$(CXX) -c $(CPPFLAGS) -o $*.o $*.cpp
$(CXX) -MM $(CPPFLAGS) -MT $*.o $*.cpp > $*.d
clean:
find . -name '*.o' -print -delete
find . -name '*.d' -print -delete
fclean: clean
rm -f $(NAME)
re:
+make fclean
+make all
run: $(NAME)
./$(NAME)