Re: Fwd: How to include macro headers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eric, That helps...I appreciate.

I have more software components which depends on the platform.inc, doing
the same would take some effort.
Is there any way that I could rewrite the paltform.inc so that I can reuse
it for all other components which use autoconf ?

-Praveen



On Wed, Jun 25, 2014 at 6:25 PM, Eric Blake <eblake@xxxxxxxxxx> wrote:

> On 06/25/2014 12:15 AM, Praveen kumar R wrote:
> > I apologize for my poor description of the issue.
> > To start of with I have a file platform.inc, which includes the build
> time
> > macro definitions,
> > B_REFSW_OS  = linuxuser
> > NEXUS_PLATFORM  = 97428
> > NEXUS_MODE  =
> > BCHP_CHIP  = 7429
> > BCHP_VER  = B0
> >
>
> Ah, so these are Makefile snippets, to be included during 'make' (and
> not .m4 files during autoconf or .h files during the compiler run by
> make).  See what a difference it makes when you give us details we can
> work with?
>
> > which are used in my source file to make switches,see below code snippet
> >
> > if (NEXUS_PLATFORM  == 97428) {
> > {
> > }
> > else
> > {
> > }
>
> Wait, this looks like C code.  Are you trying to turn your makefile
> macros into C .h macros?
>
> >
> > I am trying to include this inc file in the automake file so that the
> build
> > variables are available for the sources at the compile time.
>
> But this is the autoconf list, not the automake list.  Are you sure you
> are asking in the right location?
>
> > This is an existing inc file which is used in the normal makefile, as I
> am
> > porting this component to autotools I needed to do the same.
> >
> > I tried this in my Makefile,am
> >
> > include platform.inc
>
> Yes, that is how you would include a makefile snippet.  But including a
> makefile snippet does not impact the C code that the compiler sees.
>
> If you are using just make variables, then you could do this in your
> Makefile.am:
>
> include platform.inc
>
> NULL =
> AM_CFLAGS = \
>         -DB_REFSW_OS=$(B_REFSW_OS) \
>         -DNEXUS_PLATFORM=$(NEXUS_PLATFORM) \
>         $(NULL)
>
> (expanded to mention all variable names you want to turn into
> preprocessor macros), but that feels like a lot of duplication.  Are you
> sure you even need make variables?
>
> >
> > this is not working and I am getting compile time errors, like
> >  NEXUS_PLATFORM undefined, because there is check in the source before
> > using it like
> > ifndef NEXUS_PLATFORM: ERROR
> >
> >
> > can I use the existing inc file as is ? or do I need to port this as to
> > suit for autotools environment.
>
> If you want to propagate a make-time macro into your C files, the
> general way to do that via autoconf is to use AC_DEFINE (or
> AC_DEFINE_UNQUOTED), to stick the definition into your config.h file.
> This is completely independent of make variables.  Stick this in your
> configure.ac (and NOT your Makefile.am):
>
> AC_DEFINE([B_REFSW_OS], [linuxuser], [some doc comment])
> AC_DEFINE([NEXUS_PLATFORM], [97428], [whatever this variable does...])
>
> and so forth.  If you don't want to hard-code those values, but instead
> let the user configure them, then add appropriate configure tests,
> collect the value into a shell variable, such as:
>
> bchp_chip=`some command to determine appropriate value`
> AC_DEFINE_UNQUOTED([BCHP_CHIP], [$bchp_chip], [whatever this does])
>
> then in your .c files, just #include <config.h> (first, before any other
> headers), and the macros will already be defined.
>
> --
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
>
>
_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux