Created
July 1, 2015 12:50
-
-
Save ejmr/00baeff569624a23a676 to your computer and use it in GitHub Desktop.
List all targets of a Makefile from the terminal
This file contains hidden or 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
#!/bin/sh | |
# | |
# Running this script in a directory with a Makefile will print the | |
# targets in that Makefile, e.g. | |
# | |
# $ list-makefile-targets | |
# all | |
# clean | |
# docs | |
# install | |
# install-docs | |
# | |
# The script uses Perl. Any remotely modern version should suffice. | |
make -pn | perl -F: -ane 'print "$F[0]\n" if /^\w+\s*:/' | sort | uniq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
make -pn | perl -F: -ane 'print "$F[0]\n" if /^((?!Makefile)\w+\s*:[^=])/' | sort | uniq
Would be better (added
((?!Makefile) ...)
and[^=]
just after thes*:
) in order to:see https://www.gnu.org/software/make/manual/make.html#Reading-Makefiles