Autoreconf以"non-POSIX variable name"(非POSIX变量名)停止. [英] Autoreconf stops with "non-POSIX variable name"
问题描述
我创建了一个Makefile.in,在其中我从文件中读取内容并将其传递给CFLAGS.调用./configure ...将生成Makefile,一切正常.
I created a Makefile.in where I read the content out of a file and pass it to CFLAGS. Calling ./configure ... the Makefile will be generated an all works well.
Makefile.in:
...
MY_REVISION_FILE=my-revision.txt
MY_REVISION=$(shell cat $(top_srcdir)/$(MY_REVISION_FILE))
AM_CFLAGS = -I$(EXTRAS_INCLUDE_DIR) -I$(top_srcdir) -DMY_REVISION=$(MY_REVISION)
...
一旦我将Makefile.in代码移动到Makefile.am中以允许自动生成Makefile.in,就会出现问题.在那里调用autoreconf -i --force会由于以下错误而停止:
The problem arises once I moved the Makefile.in code into Makefile.am to allow the auto generation of Makefile.in. There calling autoreconf -i --force stops with the following error:
server/Makefile.am:9: cat $(top_srcdir: non-POSIX variable name
server/Makefile.am:9: (probably a GNU make extension)
autoreconf: automake failed with exit status: 1
这个问题现在已经困扰了我很长时间了.我到处搜索,但是没有找到任何可以帮助我找到解决方案的东西.简而言之,我唯一需要的是一种将未解释的文本(例如"$(shell cat $(top_srcdir)/$(MY_REVISION_FILE))")从Makefile.am复制到Makefile.in
This problem hunts me now since quite some time. I searched everywhere but did not find anything that could help me finding a solution for that. In short, the only thing I need is a way to get an uninterpreted text such as "$(shell cat $(top_srcdir)/$(MY_REVISION_FILE))" copied from Makefile.am to Makefile.in
有什么主意吗?
谢谢, 奥利弗(Oliver)
Thanks, Oliver
推荐答案
正如它所说,问题是您在Makefile.am
中使用的是GNUism,而这只意味着它包含可移植的Makefile代码.
As it says, the problem is you're using a GNUism in your Makefile.am
, when it's only meant to contain portable Makefile code.
要么重写您的代码,使其可移植(您应该使用AM_CPPFLAGS
,因为您是将标志传递给预处理器,而不是传递给编译器):
Either rewrite your code so it's portable (you should use AM_CPPFLAGS
because you're passing flags to the preprocessor, not the compiler):
AM_CPPFLAGS = -I$(EXTRAS_INCLUDE_DIR) -I$(top_srcdir) -DMY_REVISION=`cat $(top_srcdir)/$(MY_REVISION_FILE)`
如果不想在每次编译时都调用cat
,则可以在configure.ac
中找到该值,然后将AC_SUBST
放入Makefile
或AC_DEFINE
中,以便将其放入config.h
.
If you don't want to invoke cat
on every compile, you could find the value in configure.ac
and either AC_SUBST
it into Makefile
or AC_DEFINE
it so it goes into config.h
.
或者,如果您想成为非便携式(ಠ_ಠ),则可以从AM_INIT_AUTOMAKE
或AUTOMAKE_OPTIONS
中取出-Werror
,或添加-Wno-portability
.
Or if you want to be non-portable (ಠ_ಠ), you can take -Werror
out of your AM_INIT_AUTOMAKE
or AUTOMAKE_OPTIONS
, or add -Wno-portability
.
这篇关于Autoreconf以"non-POSIX variable name"(非POSIX变量名)停止.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!