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

后端 未结 20 1432
难免孤独
难免孤独 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:31

    If you have bash completion for make installed, the completion script will define a function _make_target_extract_script. This function is meant to create a sed script which can be used to obtain the targets as a list.

    Use it like this:

    # Make sure bash completion is enabled
    source /etc/bash_completion 
    
    # List targets from Makefile
    sed -nrf <(_make_target_extract_script --) Makefile
    

提交回复
热议问题