How to list all targets in make?
This is how the bash completion module for make
gets its list:
make -qp |
awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}' |
sort -u
It prints out a newline-delimited list of targets, without paging.
FreeBSD and NetBSD make(1) have a built-in variable called .ALLTARGETS
. You can print out its contents like this
make -V .ALLTARGETS
That will unfortunately print out a space-delimited list. I find the following more useful
make -V .ALLTARGETS | tr ' ' '\n'
It prints out each target on its own line.