Re: Making variably-named .in files work with config.status

2012-12-24 Thread Nick Bowler
On 2012-12-23 21:36 +, Reuben Thomas wrote:
 In my configure.ac, I have:
 
 AC_SUBST(PACKAGE) # so that automake can generate dependencies for 
 ${PACKAGE}*.rockspec
 AC_CONFIG_FILES(${PACKAGE}.rockspec)

While this is not related to your problem, note that your macro
arguments are underquoted.  Since the arguments are (presumably) not
meant to be subject to macro expansion, they should have one level of
quotation, as in:

  AC_SUBST([PACKAGE])
  AC_CONFIG_FILES([...])

The Autoconf manual includes a whole section on the gory details of M4
quoting.

Furthermore, AC_SUBST([PACKAGE]) is not required (but should not be
harmful) as Automake does this automatically.

 This works in getting the requisite dependency generated in Makefile.in:
 
 ${PACKAGE}-git-1.rockspec: $(top_builddir)/config.status
 $(srcdir)/${PACKAGE}-git-1.rockspec.in
 cd $(top_builddir)  $(SHELL) ./config.status $@
 
 But when I actually try to use the rule, it fails:
 
 $ make zee-git-1.rockspec
 cd .  /bin/bash ./config.status zee-git-1.rockspec
 config.status: error: invalid argument: `zee-git-1.rockspec'
 make: *** [zee-git-1.rockspec] Error 1
 
 As far as I can tell, this is because config.status doesn't get passed a
 value for PACKAGE.

I suspect (without testing) that config.status is actually looking
to generate a file called, literally, ${PACKAGE}.rockspec from
${PACKAGE}.rockspec.in.  This is wrong, because what you wanted was
for ${PACKAGE} to be replaced with the package name.

 AC_ARG_VAR doesn't seem to be relevant here, and I'm out of other ideas
 after searching online and reading the autoconf manual. What should I be
 doing here?

While I don't know if you can successfully use shell variables in
AC_CONFIG_FILES, there is another possibility in your case.
Autoconf defines the macro:

  AC_PACKAGE_NAME

which expands to the package name at M4 time.  This should be usable in
the argument to AC_CONFIG_FILES, with something like (untested):

  AC_CONFIG_FILES(m4_defn([AC_PACKAGE_NAME])[.rockspec])

Note the (lack of) quoting around the call to m4_defn: this is because
m4_defn produces an appropriately quoted string and we actually want
that macro to be expanded before passing the result to AC_CONFIG_FILES.
But the rest of the argument is quoted because that part should not be
subject to macro expansion.

Hope that helps,
-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)



Re: Making variably-named .in files work with config.status

2012-12-24 Thread Reuben Thomas
On 24 December 2012 15:16, Nick Bowler nbow...@elliptictech.com wrote:

 On 2012-12-23 21:36 +, Reuben Thomas wrote:
  In my configure.ac, I have:
 
  AC_SUBST(PACKAGE) # so that automake can generate dependencies for
 ${PACKAGE}*.rockspec
  AC_CONFIG_FILES(${PACKAGE}.rockspec)

 While this is not related to your problem, note that your macro
 arguments are underquoted.  Since the arguments are (presumably) not
 meant to be subject to macro expansion, they should have one level of
 quotation, as in:

   AC_SUBST([PACKAGE])
   AC_CONFIG_FILES([...])


Done, thanks.


 Furthermore, AC_SUBST([PACKAGE]) is not required (but should not be
 harmful) as Automake does this automatically.


Ditto. (I added this on purpose in the past because I thought I found it
was needed, but tests confirm what you and the manual say!)

While I don't know if you can successfully use shell variables in
 AC_CONFIG_FILES, there is another possibility in your case.
 Autoconf defines the macro:

   AC_PACKAGE_NAME

 which expands to the package name at M4 time.  This should be usable in
 the argument to AC_CONFIG_FILES, with something like (untested):

   AC_CONFIG_FILES(m4_defn([AC_PACKAGE_NAME])[.rockspec])

 Note the (lack of) quoting around the call to m4_defn: this is because
 m4_defn produces an appropriately quoted string and we actually want
 that macro to be expanded before passing the result to AC_CONFIG_FILES.
 But the rest of the argument is quoted because that part should not be
 subject to macro expansion.


Thanks very much. I need AC_PACKAGE_TARNAME, in fact, but it works
beautifully!

-- 
http://rrt.sc3d.org


Making variably-named .in files work with config.status

2012-12-23 Thread Reuben Thomas
In my configure.ac, I have:

AC_SUBST(PACKAGE) # so that automake can generate dependencies for
${PACKAGE}*.rockspec
AC_CONFIG_FILES(${PACKAGE}.rockspec)

This works in getting the requisite dependency generated in Makefile.in:

${PACKAGE}-git-1.rockspec: $(top_builddir)/config.status
$(srcdir)/${PACKAGE}-git-1.rockspec.in
cd $(top_builddir)  $(SHELL) ./config.status $@

But when I actually try to use the rule, it fails:

$ make zee-git-1.rockspec
cd .  /bin/bash ./config.status zee-git-1.rockspec
config.status: error: invalid argument: `zee-git-1.rockspec'
make: *** [zee-git-1.rockspec] Error 1

As far as I can tell, this is because config.status doesn't get passed a
value for PACKAGE.

AC_ARG_VAR doesn't seem to be relevant here, and I'm out of other ideas
after searching online and reading the autoconf manual. What should I be
doing here?

-- 
http://rrt.sc3d.org