Created
January 28, 2025 14:05
-
-
Save flowl/b7eddd0c71ca82fcf788258d301b4ad5 to your computer and use it in GitHub Desktop.
Listing make targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credit: https://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile | |
# Make > 4.4.1 | |
make --print-targets | |
# Make <= 4.4.1 | |
.PHONY: list | |
list: | |
@LC_ALL=C $(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/(^|\n)# Files(\n|$$)/,/(^|\n)# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | grep -E -v -e '^[^[:alnum:]]' -e '^$@$$' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment