Discussion:
using macro ...
raespi
2013-02-08 15:32:55 UTC
Permalink
Hi ... I've been googlin' around and I stumbled upon a project called
XENO for providing a C++ wrapper for Xenomai. The project's outdated
and I'm trying to port it to the newer versions of Xenomai and Autotools
( for the build part ). I noticed in the configure.ac something like this:

AC_SUBST_INT_HEX

and in the m4/general.m4 file these two lines:

AC_SUBST_INT_HEX(EXPRESSION, HEADER, SYMBOL)
AC_SUBST_INT_HEX(EXPRESSION-AND-SYMBOL, HEADER)

This macro doesn't show up anywhere on the web. If you search for it
only 2 links pop up. Are these macros defined by you ?? If so, how can
I get them??

Thanks ...
Eric Blake
2013-02-08 16:52:06 UTC
Permalink
Post by raespi
Hi ... I've been googlin' around and I stumbled upon a project called
XENO for providing a C++ wrapper for Xenomai. The project's outdated
and I'm trying to port it to the newer versions of Xenomai and Autotools
AC_SUBST_INT_HEX
AC_SUBST_INT_HEX(EXPRESSION, HEADER, SYMBOL)
AC_SUBST_INT_HEX(EXPRESSION-AND-SYMBOL, HEADER)
This macro doesn't show up anywhere on the web. If you search for it
only 2 links pop up. Are these macros defined by you ?? If so, how can
I get them??
Sorry, but 'git grep AC_SUBST_INT_HEX' in autoconf.git has no hits.
Whoever wrote them was stupid to collide with the autoconf namespace,
but they are not official autoconf macros. I hope you can find the
original source, and convince the author to rename the macros to
something that doesn't infringe on autoconf's namespace.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
raespi
2013-02-08 18:09:41 UTC
Permalink
Studying a bit more the code, this weird macro gets called like so:

AC_SUBST_INT_HEX(T_FPU, native/task.h)

This line substitutes a variable in a file task_mode.hh.in ( notice the
.in at the end ):

typedef flag<@T_FPU@> fpu_flag;

And fetches the value of the T_FPU macro ( XNFPU ) in the native/task.h
file:

#define T_FPU XNFPU

The resulting file task_mode.hh gets generated like so:

typedef flag<XNFPU> fpu_flag;

Does autoconf support anything like this ?? I've been searching the
manual but haven't found anything like it ...
Post by Eric Blake
Post by raespi
Hi ... I've been googlin' around and I stumbled upon a project called
XENO for providing a C++ wrapper for Xenomai. The project's outdated
and I'm trying to port it to the newer versions of Xenomai and Autotools
AC_SUBST_INT_HEX
AC_SUBST_INT_HEX(EXPRESSION, HEADER, SYMBOL)
AC_SUBST_INT_HEX(EXPRESSION-AND-SYMBOL, HEADER)
This macro doesn't show up anywhere on the web. If you search for it
only 2 links pop up. Are these macros defined by you ?? If so, how can
I get them??
Sorry, but 'git grep AC_SUBST_INT_HEX' in autoconf.git has no hits.
Whoever wrote them was stupid to collide with the autoconf namespace,
but they are not official autoconf macros. I hope you can find the
original source, and convince the author to rename the macros to
something that doesn't infringe on autoconf's namespace.
Eric Blake
2013-02-08 18:28:40 UTC
Permalink
[please don't top-post on technical lists]
Post by raespi
AC_SUBST_INT_HEX(T_FPU, native/task.h)
This line substitutes a variable in a file task_mode.hh.in ( notice the
This behavior sounds like whoever wrote AC_SUBST_INT_HEX was calling
AC_SUBST_UNQUOTED([T_FPU], [$value], [documentation])
somewhere inside.
Post by raespi
And fetches the value of the T_FPU macro ( XNFPU ) in the native/task.h
#define T_FPU XNFPU
And this part (figuring out what to pass for the $value of the
AC_SUBST_UNQUOTED) sounds like it is doing something as naive as:

value=`sed -n 's/.*#.*define.*T_FPU[ ]*//p' native/task.h`
Post by raespi
typedef flag<XNFPU> fpu_flag;
Do you know if XNFPU is a numeric constant? Is the generated file
actually using a symbolic constant instead of the numeric value of that
constant? Also, grepping native/task.h in order to reuse one of its
values in the generated task_mode.hh file feels inherently fragile -
that sounds like it is platform-specific, as it is not a standard header.

Can you look at the resulting configure file to see what really got
emitted, if you are trying to reverse-engineer what AC_SUBST_INT_HEX
expanded to? Would using AC_COMPUTE_INT be any less fragile than
directly grepping a platform header?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
raespi
2013-02-08 19:30:54 UTC
Permalink
Post by Eric Blake
[please don't top-post on technical lists]
Post by raespi
AC_SUBST_INT_HEX(T_FPU, native/task.h)
This line substitutes a variable in a file task_mode.hh.in ( notice the
This behavior sounds like whoever wrote AC_SUBST_INT_HEX was calling
AC_SUBST_UNQUOTED([T_FPU], [$value], [documentation])
somewhere inside.
Post by raespi
And fetches the value of the T_FPU macro ( XNFPU ) in the native/task.h
#define T_FPU XNFPU
And this part (figuring out what to pass for the $value of the
value=`sed -n 's/.*#.*define.*T_FPU[ ]*//p' native/task.h`
Post by raespi
typedef flag<XNFPU> fpu_flag;
Do you know if XNFPU is a numeric constant? Is the generated file
actually using a symbolic constant instead of the numeric value of that
constant?
yes it is in another header file:

#define XNFPU 0x00100000
Post by Eric Blake
Also, grepping native/task.h in order to reuse one of its
values in the generated task_mode.hh file feels inherently fragile -
that sounds like it is platform-specific, as it is not a standard header.
Can you look at the resulting configure file to see what really got
emitted, if you are trying to reverse-engineer what AC_SUBST_INT_HEX
expanded to?
the resulting configure file generated this:

T_FPU=T_FPU

but I imagine it not to be the desired output. It surely works, but I
think that storing the original numeric value would be less troublesome
since I don't have to include their header files in everyone of the .in
files.
Post by Eric Blake
Would using AC_COMPUTE_INT be any less fragile than
directly grepping a platform header?
something like ?

AC_COMPUTE_INT( T_FPU, "T_FPU", include='<native/task.h>' )
Eric Blake
2013-02-08 20:37:35 UTC
Permalink
Post by raespi
Post by Eric Blake
This behavior sounds like whoever wrote AC_SUBST_INT_HEX was calling
AC_SUBST_UNQUOTED([T_FPU], [$value], [documentation])
somewhere inside.
Apologies; I was thinking of AC_DEFINE_UNQUOTED; there is no
AC_SUBST_UNQUOTED. But based on how you want @T_FPU@ replacement,
rather than a #define added, you want AC_SUBST.
Post by raespi
Post by Eric Blake
Would using AC_COMPUTE_INT be any less fragile than
directly grepping a platform header?
something like ?
AC_COMPUTE_INT( T_FPU, "T_FPU", include='<native/task.h>' )
That's not proper syntax. More like:

AC_COMPUTE_INT([prefix_cv_t_fpu], [T_FPU], [[#include <native/task.h>]])
AC_SUBST([T_FPU], [$prefix_cv_t_fpu])

where you can replace prefix_ with your own package's namespace.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Loading...