Skip to content

Instantly share code, notes, and snippets.

@embayer
Created May 12, 2016 08:31
Show Gist options
  • Save embayer/b7ce342dbdc3ca0bd35edf729be6d1b9 to your computer and use it in GitHub Desktop.
Save embayer/b7ce342dbdc3ca0bd35edf729be6d1b9 to your computer and use it in GitHub Desktop.
make target that lists all visible targets in a Makefile
.PHONY: list
list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs | tr ' ' '\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment