Skip to content

Commit

Permalink
build: Move the help targets above the actual target
Browse files Browse the repository at this point in the history
This makes the self-documentation easier to read.
  • Loading branch information
itislu committed Jul 31, 2024
1 parent c8e8752 commit d8c01dc
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: ldulling <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/12/23 03:22:46 by ldulling #+# #+# #
# Updated: 2024/07/31 00:45:06 by ldulling ### ########.fr #
# Updated: 2024/07/31 01:57:09 by ldulling ### ########.fr #
# #
# **************************************************************************** #

Expand Down Expand Up @@ -136,9 +136,15 @@ PHONY_TARGETS += $(HELP_TARGETS)
.DEFAULT :
$(MAKE) help

.DEFAULT_GOAL := all


# Compilation

help-all :
echo "Build the project."
echo "This is the default target when no target is specified."

all :
if $(MAKE) --question build; then \
echo $(MSG_NO_CHNG); \
Expand All @@ -157,53 +163,56 @@ all :
fi; \
fi

help-all :
echo "Build the project."
echo "This is the default target when no target is specified."


fast : CFLAGS := $(CFLAGS_STD) $(CFLAGS_OPT)
fast : re
$(MAKE) clean

help-fast :
echo "Build the project with the following compiler optimization flags:"
echo " $(CFLAGS_OPT)"

fast : CFLAGS := $(CFLAGS_STD) $(CFLAGS_OPT)
fast : re
$(MAKE) clean

run : all
"./$(NAME)"

help-run :
echo "Build the project and run the executable."


san : CFLAGS := $(CFLAGS_STD) $(CFLAGS_DBG) $(CFLAGS_SAN)
san : re
$(MAKE) clean
run : all
"./$(NAME)"


help-san :
echo "Rebuild the project with sanitizers enabled and run the executable."
echo "The following sanitizers are enabled:"
echo " $(CFLAGS_SAN)"

san : CFLAGS := $(CFLAGS_STD) $(CFLAGS_DBG) $(CFLAGS_SAN)
san : re
$(MAKE) clean
"./$(NAME)"

val : all
$(VALGRIND) $(VALGRINDFLAGS) "./$(NAME)"

help-val :
echo "Build the project and run the executable with valgrind."
echo "The following valgrind flags are used:"
echo "$(VALGRINDFLAGS)" | tr ' ' '\n' | sed 's/^/ /'

val : all
$(VALGRIND) $(VALGRINDFLAGS) "./$(NAME)"

noenv : all
env -i $(VALGRIND) $(VALGRINDFLAGS) "./$(NAME)"

help-noenv :
echo "Build and run the project with valgrind and with empty environment (env -i)."

noenv : all
env -i $(VALGRIND) $(VALGRINDFLAGS) "./$(NAME)"


help-valfd :
echo "Build and run the project with valgrind and file descriptor tracking."
echo "The following valgrind flags are used:"
echo "$(VALGRINDFLAGS)" | tr ' ' '\n' | sed 's/^/ /'
echo "File descriptor specific flags:"
echo "$(VALGRINDFDFLAGS)" | tr ' ' '\n' | sed 's/^/ /'

valfd : all
ifneq ($(TERMINAL),)
Expand All @@ -215,13 +224,6 @@ else
$(VALGRIND) $(VALGRINDFLAGS) $(VALGRINDFDFLAGS) "./$(NAME)"
endif

help-valfd :
echo "Build and run the project with valgrind and file descriptor tracking."
echo "The following valgrind flags are used:"
echo "$(VALGRINDFLAGS)" | tr ' ' '\n' | sed 's/^/ /'
echo "File descriptor specific flags:"
echo "$(VALGRINDFDFLAGS)" | tr ' ' '\n' | sed 's/^/ /'


help :
echo "Usage: make [target]"
Expand Down Expand Up @@ -296,6 +298,9 @@ $(DEP_SUBDIRS) :

# Cleaning

help-clean :
echo "Remove build artifacts."

clean :
$(MAKE) clean -C $(LIBRARIES)
rm -f $(OBJ) $(DEP)
Expand All @@ -306,32 +311,29 @@ ifneq (,$(wildcard $(DEP_DIR)))
-find $(DEP_DIR) -type d -empty -delete
endif

help-clean :
echo "Remove build artifacts."

help-fclean :
echo "Remove build artifacts and the executable."

fclean : clean
$(MAKE) fclean -C $(LIBRARIES)
rm -f $(NAME)

help-fclean :
echo "Remove build artifacts and the executable."

help-ffclean :
echo "Remove build artifacts and the executable without checking for unknown files."

ffclean : fclean
rm -rf $(OBJ_DIR) $(DEP_DIR)

help-ffclean :
echo "Remove build artifacts and the executable without checking for unknown files."

help-re :
echo "Rebuild the project."

re :
$(MAKE) fclean
$(MAKE) all

help-re :
echo "Rebuild the project."


# Include dependency files

Expand Down

0 comments on commit d8c01dc

Please sign in to comment.