From: Lukas Jiriste Date: Fri, 2 Aug 2024 13:09:59 +0000 (+0200) Subject: Improve Makefile debug functionality X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=4afafbba59ad4abf953ea8aa23f1e61fb2c1daea;p=Libft.git 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. --- 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 $@ $^