如何使用make打印目标的所有先决条件和构建规则 [英] how to print all the prerequisites and build rules for a target using make

查看:149
本文介绍了如何使用make打印目标的所有先决条件和构建规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个大项目通常具有一个复杂的Makefile系统.在不同的Makefile中分散了许多变量定义和目标优先级依赖项.有什么方便的方法可以打印所有先决条件并为目标建立规则?

A big project usually has a complicated Makefile system. There are lots of variable definitions and target-prerequisity dependencies scattered in different Makefiles. Any handy way to print all the prerequisites and build rules for a target?

具体来说,两个问题:

问题1

说我有四个Makefile:

say I have four Makefiles:

Makefile1:

Makefile1:

p: a b
    [some rule]

Makefile2:

Makefile2:

q: c d
    [some rule]

Makefile3:

Makefile3:

r: e f
    [some rule]

Makefile:

all: p q r
    [some rule]

我可以调用一些命令来获取类似于以下内容的输出吗?

Can I invoke some command to get some output similar to the following?

all: a b c d e f
    [rule 1]
    [rule 2]
    [rule 3]
    ......

问题2

然后,如果我要检查的实体只是普通二进制文件而不是Makefile中指定的目标,该怎么办?例如,如何在coreutils中获取sha1sum的先决条件和构建规则? (很明显,coreutils的Makefile中没有名为sha1sum的目标.)

And, what if the entity I want to examine is just an ordinary binary instead of a target specified in Makefile? For example, how can I get the prerequisites and build rules for sha1sum in coreutils? (It is obvious there is no target named as sha1sum in coreutils' Makefile.)

我研究了make的帮助和手册,但徒劳无功.也许我没有弄清楚用于谷歌搜索的正确关键字.谁能帮我?谢谢!

I have looked into the help and manual of make, but in vain. Maybe I didn't figure out the correct keywords for googling. Can anyone help me? Thanks!

推荐答案

对于这个问题我不太清楚,但是您是否尝试过-p选项.它会打印从解析makefile生成的DAG,并打印规则,依赖项和变量值

I am a little unclear about the question, but have you tried the -p option. It prints the DAG generated from parsing the makefiles and prints the rules, dependencies and variable values

任何构建,甚至复杂的构建,都遵循相同的原则来构建目标.从您的示例中尚不清楚,例如,依赖项a和b是如何构建的.最终目标是什么?

Any build even a complex one follows the same principles for building the targets. From your example what is unclear is how the dependencies a and b for instance get built. What is the final target.

这篇关于如何使用make打印目标的所有先决条件和构建规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆