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?
[^$#\\\/t=]*
to match? right now, it's excluding notther I think? – steeldriver Mar 30 '20 at 21:20make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}'
– Arkadiusz Drabczyk Apr 15 '20 at 15:08[^$#\\\/t=]
. It should be[^$#\/\t=]
. – Arkadiusz Drabczyk Apr 15 '20 at 15:17make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\\/t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}'
– NSS Apr 22 '20 at 12:57make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}'
but I got the errornonterminated character class ^[a-zA-Z0-9][^$#
– NSS Apr 22 '20 at 12:58awk
are you using? Post output ofawk --version
– Arkadiusz Drabczyk Apr 22 '20 at 13:15awk version 20070501
– NSS Apr 22 '20 at 13:51awk
or, as a last resort, installingGNU awk
? I tried withawk version 20121220 (FreeBSD)
and it works well. – Arkadiusz Drabczyk Apr 22 '20 at 13:56