automake
[Top][All Lists]
Advanced

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

Re: Public header files


From: Jef Driesen
Subject: Re: Public header files
Date: Mon, 08 Mar 2010 14:10:04 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9pre) Gecko/20100217 Lightning/1.0pre Shredder/3.0.3pre

On 02/03/10 22:17, Ralf Wildenhues wrote:
* Jef Driesen wrote on Tue, Mar 02, 2010 at 10:03:35PM CET:
On 01/03/10 19:35, Ralf Wildenhues wrote:
* Jef Driesen wrote on Mon, Mar 01, 2010 at 01:33:46PM CET:
Since a config.h header files is not supposed to be public, that's
not an option. But how can I do this correctly?

Use a second config header.  Its input template will not be generated by
autoheader; you write it yourself.  That way you can be sure to only put
safe stuff in there.

Can you give me some info to guide me into the right direction. I
don't know where or what I should be looking for.

Hmm, put
   AC_CONFIG_HEADERS([config.h foo-api.h])
   ...
   AC_DEFINE([ticks_t], [...], [...])

in configure.ac, create foo-api.h.in with contents
   /* Public API header of package Foo */
   ...
   #undef ticks_t

and add foo-api.h to include_HEADERS in Makefile.am.  Untested,
be sure to test distcheck.

In case anyone is interested, at the end of this post you can find the solution that I'm using now.

The next thing I want to add is a MYLIB_VERSION_REVISION, that contains some info from the SCM system (e.g. a svn revision number, a git sha1 hash). When building a (not yet released) development version of my code, it would be useful to know the exact revision.



m4_define([mylib_version_major], 1)
m4_define([mylib_version_minor], 2)
m4_define([mylib_version_micro], 3)
...
AC_INIT(
   [mylib],
   [mylib_version_major.mylib_version_minor.mylib_version_micro]
)
...
AC_SUBST([MYLIB_VERSION_MAJOR],[mylib_version_major])
AC_SUBST([MYLIB_VERSION_MINOR],[mylib_version_minor])
AC_SUBST([MYLIB_VERSION_MICRO],[mylib_version_micro])
...
AC_CONFIG_FILES([
   ...
   version.h
   ..
])
AC_OUTPUT

Together with a version.h.in template that contains:

#define MYLIB_VERSION_MAJOR @MYLIB_VERSION_MAJOR@
#define MYLIB_VERSION_MINOR @MYLIB_VERSION_MINOR@
#define MYLIB_VERSION_MICRO @MYLIB_VERSION_MICRO@





reply via email to

[Prev in Thread] Current Thread [Next in Thread]