如何在 Makefile.am 中使用“else if”编写多个条件
我想用 autoconf/automake 编译我的项目。我的 configure.ac 中定义了 2 个条件,
AM_CONDITIONAL(HAVE_CLIENT, test $enable-client -eq 1)
AM_CONDITIONAL(HAVE_SERVER, test $enable-server -eq 1)
我想将 _LIBS 与 Makefile.am 中的这 2 个条件分开
if HAVE_CLIENT
libtest_LIBS = \
$(top_builddir)/libclient.la
else if HAVE_SERVER
libtest_LIBS = \
$(top_builddir)/libserver.la
else
libtest_LIBS =
endif
,但 else if HAVE_SERVER
不起作用。
如何在 makefile.am 中编写“else if”?
I want to compile my project with autoconf/automake. There are 2 conditions defined in my configure.ac
AM_CONDITIONAL(HAVE_CLIENT, test $enable-client -eq 1)
AM_CONDITIONAL(HAVE_SERVER, test $enable-server -eq 1)
I want to separate _LIBS from these 2 conditions in Makefile.am
if HAVE_CLIENT
libtest_LIBS = \
$(top_builddir)/libclient.la
else if HAVE_SERVER
libtest_LIBS = \
$(top_builddir)/libserver.la
else
libtest_LIBS =
endif
but else if HAVE_SERVER
does NOT work.
How to write 'else if' in makefile.am?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
ptomato 的代码也可以用更简洁的方式编写,例如:
ptomato's code can also be written in a cleaner manner like:
如果我是你,我会接受 ldav1s 的回答,但我只想指出,“else if”可以用任何语言的“else”和“if”来编写:(
缩进是为了清楚起见。Don”不要缩进行,它们不起作用。)
I would accept ldav1s' answer if I were you, but I just want to point out that 'else if' can be written in terms of 'else's and 'if's in any language:
(The indentation is for clarity. Don't indent the lines, they won't work.)
注意:不要缩进 if 那么它不起作用!
NOTE: DO NOT indent the if then it don't work!
正如您所发现的,您不能这样做。你可以这样做:
...
As you've discovered, you can't do that. You can do:
...