From 4afafbba59ad4abf953ea8aa23f1e61fb2c1daea Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Fri, 2 Aug 2024 15:09:59 +0200 Subject: [PATCH] Improve Makefile debug functionality Makefile now creates .debug file when "make debug" is executed. This make Makefile able to remember the debug mode for futher builds and rebuilds. The debug mode can be disabled by removing the .debug file or by executing "make nodebug" which will also build the project. --- .gitignore | 1 + Makefile | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e41909e..8350638 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.swp .libtemp tags +.debug diff --git a/Makefile b/Makefile index 5199275..537e92d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,10 @@ CC := cc CFLAGS := -std=c99 -Wall -Wextra -Werror -Wpedantic + +ifneq ("$(wildcard .debug)","") + CFLAGS += -g +endif + AR := ar RM := rm -f @@ -149,8 +154,16 @@ NAME = libft.a all : $(NAME) -debug : CFLAGS += -g -debug : $(NAME) +.debug : + $(MAKE) fclean + touch $@ + +debug : .debug + $(MAKE) all + +nodebug : + $(RM) .debug + $(MAKE) re $(NAME) : $(OBJECTS) $(AR) rcs $@ $^ -- 2.30.2