From 83d1541b491bcf46b4347d01671685578ef372fc Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Fri, 25 Oct 2024 13:00:04 +0200 Subject: [PATCH] Change Makefile to invoke g++ -MM for dependencies The g++ -MM $(SOURCES) creates dependency list (without system deps) for all the sources in a format suitable for Makefile. I don't like using g++ just after making use of clang++ explicit as I don't know whether both of those are usually present on PCs. The solution would probably be to provide the g++ incompatible flag conditionally when c++ == clang++. --- ex01/Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ex01/Makefile b/ex01/Makefile index ca73b43..6b87155 100644 --- a/ex01/Makefile +++ b/ex01/Makefile @@ -1,6 +1,8 @@ CC := clang++ CFLAGS = -std=c++98 -Wall -Wextra -Werror -Wpedantic +DEP_GEN = g++ -MM + ifneq ("$(wildcard .debug)","") CFLAGS += -g -fno-limit-debug-info endif @@ -56,3 +58,11 @@ fclean : clean re : fclean $(MAKE) all + +depend: .depend + +.depend: $(SOURCES) + rm -f $@ + $(DEP_GEN) $^ > $@ + +include .depend -- 2.30.2