AC_CONFIG_HEADERS & AC_CONFIG_FILES combo

View: New views
5 Messages — Rating Filter:   Alert me  

AC_CONFIG_HEADERS & AC_CONFIG_FILES combo

by Sam Steingold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a header file avcall.h which collects the results of autoconf tests, so
it is mentioned in AC_CONFIG_HEADERS.
I also want it to define the package version cpp macro, so I added

#if !defined(LIBFFCALL_VERSION)
# define LIBFFCALL_VERSION @PACKAGE_VERSION@
#endif

to it (there are several such headers, each has these 3 lines).
however, configure did not substitute @PACKAGE_VERSION@.
thus I added avcall.h to AC_CONFIG_FILES.
nothing changed, no warning or error on configure generation.
so I added this to configure.in:

AC_CONFIG_HEADERS([avcall.h],
[sed "s/@PACKAGE_VERSION@/${PACKAGE_VERSION}/" avcall.h > tmp
mv -f tmp avcall.h])

now @PACKAGE_VERSION@ is removed, nothing is inserted.
if I replace " with ' or escape $ with \, I see ${PACKAGE_VERSION} instead of
its value in configure.

I am sure this can be fixed with some judicious use of quoting (how?!),
but I am wondering if there is a simpler way around.

Thanks.
Sam.



_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_CONFIG_HEADERS & AC_CONFIG_FILES combo

by Sam Steingold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sam Steingold wrote:
> I have a header file avcall.h which collects the results of autoconf
> tests, so it is mentioned in AC_CONFIG_HEADERS.
> I also want it to define the package version cpp macro, so I added
>
> #if !defined(LIBFFCALL_VERSION)
> # define LIBFFCALL_VERSION @PACKAGE_VERSION@
> #endif

I guess I can do this:

#if !defined(LIBFFCALL_VERSION)
# undef PACKAGE_VERSION
# define LIBFFCALL_VERSION PACKAGE_VERSION
#endif

and autoconf will replace it with

#if !defined(LIBFFCALL_VERSION)
# define PACKAGE_VERSION  123
# define LIBFFCALL_VERSION PACKAGE_VERSION
#endif

however, this is not good because the users of this package will have a
conflict of my PACKAGE_VERSION with their PACKAGE_VERSION from their config.h.
I cannot undef PACKAGE_VERSION in avcall.h because autoconf will replace it
with "#define PACKAGE_VERSION ...".



_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_CONFIG_HEADERS & AC_CONFIG_FILES combo

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 16 Oct 2009, Sam Steingold wrote:

> I have a header file avcall.h which collects the results of autoconf tests,
> so it is mentioned in AC_CONFIG_HEADERS.
> I also want it to define the package version cpp macro, so I added
>
> #if !defined(LIBFFCALL_VERSION)
> # define LIBFFCALL_VERSION @PACKAGE_VERSION@
> #endif
>
> to it (there are several such headers, each has these 3 lines).
> however, configure did not substitute @PACKAGE_VERSION@.
> thus I added avcall.h to AC_CONFIG_FILES.
> nothing changed, no warning or error on configure generation.
> so I added this to configure.in:
>
> AC_CONFIG_HEADERS([avcall.h],
> [sed "s/@PACKAGE_VERSION@/${PACKAGE_VERSION}/" avcall.h > tmp
> mv -f tmp avcall.h])
>
> now @PACKAGE_VERSION@ is removed, nothing is inserted.

That is because the sed command is executed by config.status where
PACKAGE_VERSION not undefined.  You should try

AC_CONFIG_HEADERS([avcall.h],
[sed "s/@PACKAGE_VERSION@/$my_PACKAGE_VERSION/" avcall.h > tmp
mv -f tmp avcall.h],
[my_PACKAGE_VERSION=$PACKAGE_VERSION])

(the changed variable name is to avoid conflicts, may not be needed).

Regards
Peter Breitenlohner <peb@...>


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_CONFIG_HEADERS & AC_CONFIG_FILES combo

by Paolo Bonzini-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/16/2009 05:49 PM, Sam Steingold wrote:

> I have a header file avcall.h which collects the results of autoconf
> tests, so it is mentioned in AC_CONFIG_HEADERS.
> I also want it to define the package version cpp macro, so I added
>
> #if !defined(LIBFFCALL_VERSION)
> # define LIBFFCALL_VERSION @PACKAGE_VERSION@
> #endif
>
> to it (there are several such headers, each has these 3 lines).
> however, configure did not substitute @PACKAGE_VERSION@.
> thus I added avcall.h to AC_CONFIG_FILES.

Right.

AC_CONFIG_HEADERS has to have a very specific format.  You'd do

AC_DEFINE_UNQUOTED([LIBFFCALL_VERSION], ["$PACKAGE_VERSION"],
                    [Version of libffcall, for avcall.h])

and in avcall.h.in

#ifndef LIBFFCALL_VERSION
#undef LIBFFCALL_VERSION
#endif

but I'm not sure whether autoheader would destroy avcall.h.in, so
Peter's solution is preferred.

Paolo


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_CONFIG_HEADERS & AC_CONFIG_FILES combo

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Paolo Bonzini wrote on Tue, Oct 20, 2009 at 07:41:12PM CEST:

> AC_CONFIG_HEADERS has to have a very specific format.  You'd do
>
> AC_DEFINE_UNQUOTED([LIBFFCALL_VERSION], ["$PACKAGE_VERSION"],
>                    [Version of libffcall, for avcall.h])
>
> and in avcall.h.in
>
> #ifndef LIBFFCALL_VERSION
> #undef LIBFFCALL_VERSION
> #endif
>
> but I'm not sure whether autoheader would destroy avcall.h.in, so
> Peter's solution is preferred.

autoheader only writes the input file to the first AC_CONFIG_HEADERS
that is specified in configure.ac; all following ones are supposed to be
written by the developer.

Cheers,
Ralf


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf