2

I use the following code to get a makefile targets list which works OK for most cases, however when you use makefile like this you get only two targets and not all.

The another command doesn't show up

cat Makefile

command: ## Command description
    @echo "Execution log"

another-command: ## Command description
    @echo "Execution log"

command2: ## Command description
    @echo "Execution log" 

The output is:

command
command2

I don't understand why I don't getting the command another-command, This is the code

`make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\\\/t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}' `;

What could be the problem ?

I use this as reference How to list all targets in make?

enter image description here

NSS
  • 73

1 Answers1

5
$ make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\\\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}'
command
Makefile
command2
another-command

In my character set are backslash and tab, in your set are backslash, slash and "t".

And "another" contains a "t" ;-)

Credits to steeldriver

Polluks
  • 249
  • 1
  • 8