mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-07 21:15:19 +03:00
tools: makefile help system improvements
This commit is contained in:
parent
21d9945ba9
commit
c83fcab8cb
@ -16,38 +16,54 @@
|
||||
#
|
||||
# Also:
|
||||
#
|
||||
# $(call def-help-section,SECTION,HELP)
|
||||
# $(call def-help-section,TITLE,HELP) -- show a section heading
|
||||
#
|
||||
# and:
|
||||
# $(call def-help-subsection,TITLE,HELP) -- show a subsection heading
|
||||
#
|
||||
# $(call def-help-subsection,SECTION,HELP)
|
||||
# $(call def-help-hide,TARGET,HELP) -- temporarily suppress the help)
|
||||
# $(call def-help-section-hide,TITLE,HELP)
|
||||
# $(call def-help-subsection-hide,TITLE,HELP)
|
||||
#
|
||||
# HELP is one or more lines, or can be blank.
|
||||
# Certain characters such as comma and parentheses are not allowed.
|
||||
# Certain characters are not allowed, comma in particular.
|
||||
# You may want to avoid ' also as it breaks emacs font-lock.
|
||||
|
||||
# if the make targets include "help" or there are no targets, show help
|
||||
need-help := $(if $(MAKECMDGOALS),$(filter help,$(MAKECMDGOALS)),true)
|
||||
|
||||
help:
|
||||
@echo $(if $(need-help),,Type \'make$(dash-f) help\' to get help)
|
||||
|
||||
need-help := $(filter help,$(MAKECMDGOALS))
|
||||
|
||||
# show a make target's help when help has been requested
|
||||
define def-help
|
||||
$(if $(need-help),$(warning $1 --$2))
|
||||
$(if $(need-help), $(warning make $1 --$2))
|
||||
endef
|
||||
|
||||
# show a section heading when help has been requested
|
||||
define def-help-section
|
||||
$(if $(need-help),$(warning --------------------$1--------------------$2))
|
||||
endef
|
||||
|
||||
# show a subsection heading when help has been requested
|
||||
define def-help-subsection
|
||||
$(if $(need-help),$(warning ($1)))
|
||||
endef
|
||||
|
||||
# no-ops, for hiding help without removing it entirely
|
||||
define def-help-hide
|
||||
endef
|
||||
define def-help-section-hide
|
||||
endef
|
||||
define def-help-subsection-hide
|
||||
endef
|
||||
|
||||
# utilities
|
||||
|
||||
# define print-lines
|
||||
# @echo $1
|
||||
# endef
|
||||
# $(if $(true),$(printf $1),$(printf '\n'$1))
|
||||
|
||||
define def-help-section
|
||||
$(if $(need-help),$(warning --------------------$1--------------------$2))
|
||||
endef
|
||||
|
||||
define def-help-subsection
|
||||
$(if $(need-help),$(warning $1$2))
|
||||
endef
|
||||
|
||||
define last-element
|
||||
$(word $(words $1),$1)
|
||||
endef
|
||||
@ -55,6 +71,4 @@ endef
|
||||
this-makefile := $(call last-element,$(MAKEFILE_LIST))
|
||||
other-makefiles := $(filter-out $(this-makefile),$(MAKEFILE_LIST))
|
||||
parent-makefile := $(call last-element,$(other-makefiles))
|
||||
|
||||
dash-f := $(if $(filter-out Makefile makefile GNUmakefile, $(parent-makefile)), -f $(parent-makefile))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user