gpt4 book ai didi

makefile - 如何获取 makefile 中的目标列表?

转载 作者:行者123 更新时间:2023-12-02 10:49:42 28 4
gpt4 key购买 nike

我使用过一点 rake(一个 Ruby make 程序),它有一个选项来获取所有可用目标的列表,例如

> rake --tasks
rake db:charset # retrieve the charset for your data...
rake db:collation # retrieve the collation for your da...
rake db:create # Creates the databases defined in y...
rake db:drop # Drops the database for your curren...
...

但在 GNU make 中似乎没有选项可以做到这一点。

显然代码已经准备好了,截至 2007 年 - http://www.mail-archive.com/help-make@gnu.org/msg06434.html

无论如何,我做了一些小技巧来从 makefile 中提取目标,您可以将其包含在 makefile 中。

list:
@grep '^[^#[:space:]].*:' Makefile

它将为您提供已定义目标的列表。这只是一个开始 - 例如,它不会过滤掉依赖项。

> make list
list:
copy:
run:
plot:
turnin:

最佳答案

在 Bash 下(至少),这可以通过制表符补全自动完成:

make 空格制表符制表符

<小时/>

如果您使用的是简单的发行版(可能是容器),您可能需要安装一个软件包。

$ apt-get install bash-completion ## Debian/Ubuntu/etc.
$ . /etc/bash_completion ## or just launch bash again

关于makefile - 如何获取 makefile 中的目标列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4219255/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com