顶层 makefile 中的输出
我在 makefile
中设置一个变量,如下所示:
SOMEVAR = foo
此 makefile 稍后包含其他一些 makefile
,其中发生实际的程序构建:
include generic/Makefile.common
因此,在第一个 makefile
,它仅设置变量,然后由通用通用 makefile
使用这些变量来执行实际的包构建。
现在我知道使用 foo
时应该小心,因此为了提醒自己这一点,每当使用此 makefile 设置 make 过程时,我想打印一条警告消息。问题是我不能在变量定义之后插入一个 echo 命令,因为我们还没有在那里构建一些东西。
有没有解决方案(比在打印消息的地方添加一个假目标更优雅,这会破坏设置变量和构建的分离)?
I am setting a variable in a makefile
like this:
SOMEVAR = foo
This makefile later includes some other makefile
in which the actual building of programs takes place:
include generic/Makefile.common
So no build targets are defined in the first makefile
, it's only setting up variables which are then used by the common generic makefile
to do the actual package building.
Now I know that I should be careful when using foo
, so to remind myself of this, I want to print a warning message whenever this makefile is used to setup the make process. The problem is that I cannot just insert an echo
command after the variable definition, because we are not yet building something there.
Is there a solution (more elegant than adding a fake target where the message is printed which would destroy the separation of setting variables and building)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据官方文档,有三种方法在 makefile 中执行顶级输出
以防万一您想以其他方式执行此操作。
我希望有帮助。
According with official documentation there is three ways to do a top-level output in a makefile
Just in case you want do that in another way.
I hope helps.