Skip to content

Commit

Permalink
Merge pull request #383 from LeaYeh/build-makefile-usage
Browse files Browse the repository at this point in the history
[BUILD] Move usage guides to the end of the help messages in Makefile
  • Loading branch information
LeaYeh authored Oct 23, 2024
2 parents 7602a98 + 07b77ea commit d45a8c9
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ CPPFLAGS := $(addprefix -I,$(INC_DIR) $(LIB_INCLUDES))
DEPFLAGS = -M -MP -MF $@ -MT "$(OBJ_DIR)/$*.o $@"
LDFLAGS := $(addprefix -L,$(LIBRARIES))
LDLIBS := $(addprefix -l,$(patsubst lib%,%,$(notdir $(LIBRARIES) $(LIBRARIES_EXT))))
MAKEFLAGS := -j -s
MAKEFLAGS += -j -s


# Macro definitions
Expand All @@ -79,7 +79,7 @@ VALGRINDFLAGS = --errors-for-leak-kinds=all \
--read-var-info=yes \
--show-error-list=yes \
--show-leak-kinds=all \
--suppressions=./minishell.supp \
--suppressions=$(CURDIR)/minishell.supp \
--trace-children=yes \
--trace-children-skip=$(subst $(SPACE),$(COMMA),$(ABSOLUTE_PATHS)) \
--track-origins=yes
Expand Down Expand Up @@ -275,7 +275,7 @@ waitforlib : lib
# Executable linkage

$(NAME) : $(LIBRARIES) $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) $(LDLIBS) -o $(NAME)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) $(LDLIBS) -o $@


# Source file compilation
Expand Down Expand Up @@ -329,8 +329,6 @@ ffclean :
# ****************************** HELP TARGETS ******************************** #

help :
echo "Usage: make [\\$(STY_UND)target\\$(STY_RES)] [MODE=\"<\\$(STY_UND)mode1\\$(STY_RES)> [\\$(STY_UND)mode2\\$(STY_RES)] [...]\"]"
echo
echo "Targets:"
echo " all Build the project (default target)"
echo " run Build and run the project"
Expand All @@ -353,6 +351,7 @@ help :
echo "Environment Variables:"
echo " MODE Build mode to combine multiple targets"
echo
echo "Usage: make [\\$(STY_UND)target\\$(STY_RES)] [MODE=\"<\\$(STY_UND)mode1\\$(STY_RES)> [\\$(STY_UND)mode2\\$(STY_RES)] [...]\"]"

help-all :
echo "Build the project."
Expand All @@ -378,12 +377,14 @@ help-san :

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

help-valfd :
echo "Build the project and run the executable with valgrind and file descriptor tracking."
echo "A new terminal window is opened to avoid inheriting open file descriptors."
echo
echo "The following valgrind flags are used:"
echo "$(VALGRINDFLAGS)" | tr ' ' '\n' | sed 's/^/ /'
echo "File descriptor specific flags:"
Expand All @@ -408,21 +409,21 @@ help-ffclean :
echo "Remove build artifacts and the executable without checking for unknown files."

help-print :
echo "Usage: make print-<\\$(STY_UND)variable name\\$(STY_RES)>"
echo
echo "Print the value of a Makefile variable by appending the variable name to print-..."
echo "Useful for Makefile debugging."
echo
echo "Usage: make print-<\\$(STY_UND)variable name\\$(STY_RES)>"

help-help :
echo "Usage: make help-<\\$(STY_UND)target\\$(STY_RES)> | make <\\$(STY_UND)target\\$(STY_RES)>-help"
echo
echo "Display more information for a specific target by appending or prepending help."
echo
echo "Usage: make help-<\\$(STY_UND)target\\$(STY_RES)> | make <\\$(STY_UND)target\\$(STY_RES)>-help"

help-MODE MODE-help:
echo "Usage: make <\\$(STY_UND)target\\$(STY_RES)> MODE=\"<\\$(STY_UND)mode1\\$(STY_RES)> [\\$(STY_UND)mode2\\$(STY_RES)] [...]\""
echo
echo "Build mode to combine with other targets."
echo "Multiple modes can be combined by separating them with a space."
echo
echo "Usage: make <\\$(STY_UND)target\\$(STY_RES)> MODE=\"<\\$(STY_UND)mode1\\$(STY_RES)> [\\$(STY_UND)mode2\\$(STY_RES)] [...]\""

%-help:
$(MAKE) help-$(subst -help,,$@)
Expand Down

0 comments on commit d45a8c9

Please sign in to comment.