Discussion:
Autoreconf stops with "non-POSIX variable name"
oborchert
2013-03-29 21:17:24 UTC
Permalink
Hi,
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)
...

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

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

Any idea?

Thanks,
Oliver



--
View this message in context: http://gnu-autoconf.7623.n7.nabble.com/Autoreconf-stops-with-non-POSIX-variable-name-tp18630.html
Sent from the Gnu - Autoconf - General mailing list archive at Nabble.com.
Russ Allbery
2013-03-29 21:44:08 UTC
Permalink
Post by oborchert
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.
...
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)
...
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
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
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
This is actually an Automake question, but the short answer is that you
probably have fatal warnings enabled and you need to add -Wno-portability
to the Automake flags (in AM_INIT_AUTOMAKE, for example).
--
Russ Allbery (***@stanford.edu) <http://www.eyrie.org/~eagle/>
Eric Blake
2013-03-29 21:54:02 UTC
Permalink
[adding automake]
Post by Russ Allbery
Post by oborchert
MY_REVISION_FILE=my-revision.txt
MY_REVISION=$(shell cat $(top_srcdir)/$(MY_REVISION_FILE))
$(shell ...) is a GNU make extension, and by using it, you are making
your Makefile.am useless for all other make flavors. Automake's goal is
to be portable to ALL makes by default, hence the warning.
Post by Russ Allbery
Post by oborchert
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
Admittedly, the warning is rather poor quality; perhaps it is worth
turning this into an automake bug to improve the quality of that message.
Post by Russ Allbery
This is actually an Automake question, but the short answer is that you
probably have fatal warnings enabled and you need to add -Wno-portability
to the Automake flags (in AM_INIT_AUTOMAKE, for example).
Or don't use $(shell), or upgrade to Automake-NG (which _requires_ GNU
make to be installed on the end-user's machine, and therefore should let
you use GNU make extensions without question).
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Eric Blake
2013-04-01 23:19:05 UTC
Permalink
This post might be inappropriate. Click to display it.
Russ Allbery
2013-04-01 23:24:54 UTC
Permalink
Post by Eric Blake
If you care about non-GNU make users, then you can't use $(shell). And
as long as you are going to mandate that your package be built with GNU
make, then you might as well go all the way and document that fact in
Post by Russ Allbery
This is actually an Automake question, but the short answer is that
you probably have fatal warnings enabled and you need to add
-Wno-portability to the Automake flags (in AM_INIT_AUTOMAKE, for
example).
...tell automake that you don't care about the non-portability aspect by
adding -Wno-portability to your AM_INIT_AUTOMAKE, at which point you'd
Yeah, if you're going to require GNU make, just say so and add
-Wno-portability. That's the whole point of the flag. Hiding the dollar
sign from Automake so that it can't detect the portability issue is an odd
way of expressing things and just adds complexity to no real purpose.
--
Russ Allbery (***@stanford.edu) <http://www.eyrie.org/~eagle/>
oborchert
2013-04-02 16:49:59 UTC
Permalink
This post might be inappropriate. Click to display it.
Borchert, Oliver
2013-04-01 23:07:19 UTC
Permalink
Eric and Russ,

thanks for the reply. After long testing back and forth I decided to use AC_SUBST.
My solution might not be the cleanest but it works for me.

In configure.ac I added the following line
AC_SUBST([DOLLAR_SIGN],[$])

In the Makefile.am I changed my previous line into
MY_REVISION=@DOLLAR_SIGN@(shell cat $(SRC_DIR)/$(MY_REVISION_FILE))

Finally the makefile ended up with the line of code I wanted
MY_REVISION=$(shell cat $(SRC_DIR)/$(MY_REVISION_FILE))

And it works.
Again, thanks for your help

Oliver
Post by Eric Blake
[adding automake]
Post by Russ Allbery
Post by oborchert
MY_REVISION_FILE=my-revision.txt
MY_REVISION=$(shell cat $(top_srcdir)/$(MY_REVISION_FILE))
$(shell ...) is a GNU make extension, and by using it, you are making your
Makefile.am useless for all other make flavors. Automake's goal is to be
portable to ALL makes by default, hence the warning.
Post by Russ Allbery
Post by oborchert
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
Admittedly, the warning is rather poor quality; perhaps it is worth turning this
into an automake bug to improve the quality of that message.
Post by Russ Allbery
This is actually an Automake question, but the short answer is that
you probably have fatal warnings enabled and you need to add
-Wno-portability to the Automake flags (in AM_INIT_AUTOMAKE, for
example).
Or don't use $(shell), or upgrade to Automake-NG (which _requires_ GNU
make to be installed on the end-user's machine, and therefore should let
you use GNU make extensions without question).
Peter Johansson
2013-03-30 03:53:57 UTC
Permalink
Post by oborchert
Hi,
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.
...
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)
...
Rather than carry this information via cmdline, I store create a header
file that I can include when needed. In that way dependencies become
correct too. I have the following rule in my Makefile.am:

BUILT_SOURCES += $(builddir)/svn_revision.h
$(builddir)/svn_revision.h: $(srcdir)/svn_revision.h.in $(srcdir)/.revision
$(AM_V_at)revision=$$(cat $(srcdir)/.revision) \
and then my svn_revision.h.in looks like

#ifndef SVN_REVISION
#define SVN_REVISION "@SVN_REVISION@"
#endif


Cheers,
Peter
--
Peter Johansson
Loading...