From 829f540224ceebfa6babaed7d6b3f955fbe0f7e3 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Thu, 4 Dec 2025 14:55:01 +0100 Subject: [PATCH] share/mk/: help, help-*: Add targets to list targets, variables, and build dependencies Suggested-by: Paolo Bonzini Signed-off-by: Alejandro Colomar --- GNUmakefile | 23 +++------------------- share/mk/help/list.mk | 46 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 share/mk/help/list.mk diff --git a/GNUmakefile b/GNUmakefile index 6ee1a8874..3f2ea50ba 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -55,32 +55,15 @@ help: $(info $(INFO_) dist Produce the release tarball) $(info $(INFO_) distcheck Check the release tarball) $(info $(INFO_) help Print this help) + $(info $(INFO_) help-list-build-depends List build dependencies (package/program)) + $(info $(INFO_) help-list-targets List all targets) + $(info $(INFO_) help-list-variables List configurable variables) $(info $(INFO_) install Install the usual stuff) $(info $(INFO_) install-all Install everything) $(info $(INFO_) lint Lint the source code) $(info $(INFO_) nothing Do nothing; useful for debugging) $(info $(INFO_) uninstall Uninstall everything (might leave traces)) $(info ) - $(info $(INFO_)To see the full list of targets, run:) - $(info $(INFO_) $$ make -R -p nothing \) - $(info $(INFO_) | grep '^\.PHONY:' \) - $(info $(INFO_) | tr ' ' '\n' \) - $(info $(INFO_) | grep -v '^\.PHONY:' \) - $(info $(INFO_) | sort;) - $(info ) - $(info $(INFO_)To see a list of variables, run:) - $(info $(INFO_) $$ find GNUmakefile share/mk/configure -type f \) - $(info $(INFO_) | sort \) - $(info $(INFO_) | xargs grep '^[^[:space:]].*=' \) - $(info $(INFO_) | sed 's/=.*/=/' \) - $(info $(INFO_) | grep -v -e ':DEFAULT_.*=' -e ':MAKEFILE_.*INCLUDED :=';) - $(info ) - $(info $(INFO_)To see a list of dependencies (package/program), run:) - $(info $(INFO_) $$ find share/mk/configure/build-depends -type f \) - $(info $(INFO_) | sed 's,share/mk/configure/build-depends/,,' \) - $(info $(INFO_) | sed 's,\.mk,,' \) - $(info $(INFO_) | sort;) - $(info ) .DELETE_ON_ERROR: diff --git a/share/mk/help/list.mk b/share/mk/help/list.mk new file mode 100644 index 000000000..7443d1288 --- /dev/null +++ b/share/mk/help/list.mk @@ -0,0 +1,46 @@ +# Copyright, the authors of the Linux man-pages project +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_HELP_LIST_INCLUDED +MAKEFILE_HELP_LIST_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils/sort.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils/tr.mk +include $(MAKEFILEDIR)/configure/build-depends/findutils/find.mk +include $(MAKEFILEDIR)/configure/build-depends/findutils/xargs.mk +include $(MAKEFILEDIR)/configure/build-depends/grep/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/sed/sed.mk + + +.PHONY: help-list-targets +help-list-targets: + $(MAKE) -p nothing \ + | $(GREP) '^\.PHONY:' \ + | $(TR) ' ' '\n' \ + | $(GREP) -v '^\.PHONY:' \ + | $(SORT) + + +.PHONY: help-list-variables +help-list-variables: + $(FIND) $(CURDIR)/GNUmakefile $(MAKEFILEDIR) -type f \ + | $(GREP) -e '/GNUmakefile$$' -e '\.mk$$' \ + | $(SORT) \ + | $(XARGS) $(GREP) '^[^[:space:]].*=' \ + | $(SED) 's,$(CURDIR)/,,' \ + | $(SED) 's/=.*/=/' \ + | $(GREP) -v -e ':DEFAULT_.*=' -e ':MAKEFILE_.*INCLUDED :=' + + +.PHONY: help-list-build-depends +help-list-build-depends: + $(FIND) $(MAKEFILEDIR)/configure/build-depends -type f \ + | $(GREP) -e '\.mk$$' -e '\.mk$$' \ + | $(SED) 's,$(MAKEFILEDIR)/configure/build-depends/,,' \ + | $(SED) 's,\.mk$$,,' \ + | $(SORT) + + +endif # include guard -- 2.47.3