How do you get the list of targets in a makefile?

后端 未结 20 1504
难免孤独
难免孤独 2020-11-30 16:50

I\'ve used rake a bit (a Ruby make program), and it has an option to get a list of all the available targets, eg

> rake --tasks
rake db:charset      # ret         


        
20条回答
  •  不知归路
    2020-11-30 17:30

    For a Bash Script

    Here's a very simple way to do this in bash -- based on the comment by @cibercitizen1 above:

    grep : Makefile | awk -F: '/^[^.]/ {print $1;}'
    

    See also the more authoritative answer by @Marc.2377, too, which says how the Bash completion module for make does it.

提交回复
热议问题