在 automake 中使用条件语句

发布于 2024-09-08 09:28:57 字数 308 浏览 3 评论 0原文

我最近从使用 Makefiles 切换到使用 Automake,并且我不知道如何使用 automake 编写以下简单的 if 语句:

DEBUG ?= 1
ifeq (${DEBUG},1)
CXXFLAGS:=$(CXXFLAGS) -g
else
CXXFLAGS:=$(CXXFLAGS) -O3 -DNDEBUG
endif

如果我使用 automake,这甚至可能做到吗?既然它自动生成 makefile,那么将其写入 Makefile 模板是否有意义?或者我应该尝试找到某种方法将其添加到自动生成的 Makefile 中?

I recently switched from using Makefiles to using Automake, and I can't figure out how to write the following simple if statement using automake:

DEBUG ?= 1
ifeq (${DEBUG},1)
CXXFLAGS:=$(CXXFLAGS) -g
else
CXXFLAGS:=$(CXXFLAGS) -O3 -DNDEBUG
endif

Is this even possible to do if I'm using automake? Since it generates the makefile from automatically, does it make sense writing it in the Makefile template? Or should I try to find some way of adding it the automatically generated Makefile?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷默言语 2024-09-15 09:28:57

不,您不能在 Automake 中使用这样的语法。前两行没有完全相同的内容。

您可以使用 Automake 条件做一些接近的事情(有关示例,请参阅 Automake 手册中的条件的使用),并从 ./configure 设置 DEBUG
不过,我认为这样做没有什么意义:如果您想全局更改 CXXFLAGS,只需在 configure 中更改此变量,而不是在 Makefile.am 中>。

No, you cannot use such a syntax with Automake. There is no exact equivalent for the first two lines.

You could do something close using an Automake conditional (see Usage of Conditionals in the Automake manual for examples), and set DEBUG from ./configure.
However I see little point in doing that: if you want to change CXXFLAGS globally, simply alter this variable in configure, not in the Makefile.am.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文