Sign in to follow this  

autotools

This topic is 4862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, been trying to learn how to use autotools (autoconf,automake,libtool) and got a couple of queries regarding them: - How can I create a Makefile.am that accepts wildcards? I tried foo_SOURCES = $(wildcard *.c) But the Makefile configure produces does not expand the the wildcard (it resulted in an empty string). - Is there a way to test for integer sizes? I have code that typedefs fixed size integers (eg byte, word16, word32 etc) and I would like to programatically "discover" and generate a header that contains the typedefs. The discovery procedure must work on cross-compiles.

Share this post


Link to post
Share on other sites
Quote:
Original post by ugenn
- How can I create a Makefile.am that accepts wildcards? I tried
foo_SOURCES = $(wildcard *.c)
But the Makefile configure produces does not expand the the wildcard (it resulted in an empty string).

You can really. There are tools that sit on top of automake (like autogen) that can do that for you though. The way automake works requires that it knows the exact source files it will need to handle when it generates a make file for autoconf.

Quote:
Original post by ugenn
- Is there a way to test for integer sizes?
I have code that typedefs fixed size integers (eg byte, word16, word32 etc) and I would like to programatically "discover" and generate a header that contains the typedefs. The discovery procedure must work on cross-compiles.

Yes and it'll work on most cross-compile configurations with new enough autotools.

In configure.ac:

...

AC_CONFIG_HEADERS([config.h:config.h.in])

AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)

...


In config.h.in (which can be generated by autoheader, as this snippet happens to be):

/* The size of a `char', as computed by sizeof. */
#undef SIZEOF_CHAR

/* The size of a `int', as computed by sizeof. */
#undef SIZEOF_INT

/* The size of a `long', as computed by sizeof. */
#undef SIZEOF_LONG

/* The size of a `long long', as computed by sizeof. */
#undef SIZEOF_LONG_LONG

/* The size of a `short', as computed by sizeof. */
#undef SIZEOF_SHORT


When config.h is generated it'll look like this:

/* The size of a `char', as computed by sizeof. */
#define SIZEOF_CHAR 1

/* The size of a `int', as computed by sizeof. */
#define SIZEOF_INT 4

/* The size of a `long', as computed by sizeof. */
#define SIZEOF_LONG 4

/* The size of a `long long', as computed by sizeof. */
#define SIZEOF_LONG_LONG 8

/* The size of a `short', as computed by sizeof. */
#define SIZEOF_SHORT 2


Make sure to install config.h in an architecture-dependent directory such-as /usr/lib/yourproject/include/config.h for good form :P.

Share this post


Link to post
Share on other sites
Thanks for the quick reply. I forgot to include a few other questions:

- Is there a test for endian order?
- Test alignment restrictions?
- Test internal floating point format (eg IEEE)?

Also, do you know where I can find a good searchable reference for autotool macros? The GNU manuals aren't too search friendly.
Thanks again.

Share this post


Link to post
Share on other sites
Quote:
Original post by ugenn
- Is there a test for endian order?

Yes; see AC_C_BIGENDIAN.
Quote:
Original post by ugenn
- Test alignment restrictions?
- Test internal floating point format (eg IEEE)?

Not that I'm aware of. You could write your own test without too much difficultly, but it wouldn't be particularly cross-compiler configuration friendly (the best you'd be able to do easily is fail gracefully when you're cross-compiling).
Quote:
Original post by ugenn
Also, do you know where I can find a good searchable reference for autotool macros? The GNU manuals aren't too search friendly.

The autoconf manual seems good enough to me. Other than that, not really; as I just generally just try Google with a moderately descriptive search string.

Share this post


Link to post
Share on other sites
Sign in to follow this