@node ax_prefix_config_h @unnumberedsec ax_prefix_config_h @majorheading Synopsis @smallexample AX_PREFIX_CONFIG_H [(OUTPUT-HEADER [,PREFIX [,ORIG-HEADER]])] @end smallexample @majorheading Description Generate an installable config.h. A package should not normally install its config.h as a system header, but if it must, this macro can be used to avoid namespace pollution by making a copy of config.h with a prefix added to all the macro names. Each "#define SOMEDEF" line of the configuration header has the given prefix added, in the same case as the first character of the macro name. Defaults: @smallexample OUTPUT-HEADER = $PACKAGE-config.h PREFIX = $PACKAGE ORIG-HEADER, from AM_CONFIG_HEADER(config.h) @end smallexample Your configure.ac script should contain both macros in this order. Example: @smallexample AC_INIT(config.h.in) # config.h.in as created by "autoheader" AM_INIT_AUTOMAKE(testpkg, 0.1.1) # makes #undef VERSION and PACKAGE AM_CONFIG_HEADER(config.h) # prep config.h from config.h.in AX_PREFIX_CONFIG_H(mylib/_config.h) # prep mylib/_config.h from it.. AC_MEMORY_H # makes "#undef NEED_MEMORY_H" AC_C_CONST_H # makes "#undef const" AC_OUTPUT(Makefile) # creates the "config.h" now # and also mylib/_config.h @end smallexample If the argument to AX_PREFIX_CONFIG_H would have been omitted then the default output file would have been called simply "testpkg-config.h", but even under the name "mylib/_config.h" it contains prefix-defines like @smallexample #ifndef TESTPKG_VERSION #define TESTPKG_VERSION "0.1.1" #endif #ifndef TESTPKG_NEED_MEMORY_H #define TESTPKG_NEED_MEMORY_H 1 #endif #ifndef _testpkg_const #define _testpkg_const _const #endif @end smallexample and this "mylib/_config.h" can be installed along with other header files, which is most convenient when creating a shared library (that has some headers) whose functionality depends on features detected at compile-time. No need to invent some "mylib-confdefs.h.in" manually. Note that some AC_DEFINEs that end up in the config.h file are actually self-referential - e.g. AC_C_INLINE, AC_C_CONST, and the AC_TYPE_OFF_T say that they "will define inline|const|off_t if the system does not do it by itself". You might want to clean up about these - consider an extra mylib/conf.h that reads something like: @smallexample #include #ifndef _testpkg_const #define _testpkg_const const #endif @end smallexample and then start using _testpkg_const in the header files. That is also a good thing to differentiate whether some library-user has starting to take up with a different compiler, so perhaps it could read something like this: @smallexample #ifdef _MSC_VER #include #else #include #endif #ifndef _testpkg_const #define _testpkg_const const #endif @end smallexample @majorheading Source Code Download the @uref{http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_prefix_config_h.m4,latest version of @file{ax_prefix_config_h.m4}} or browse @uref{http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=history;f=m4/ax_prefix_config_h.m4,the macro's revision history}. @majorheading License @w{Copyright @copyright{} 2014 Reuben Thomas @email{rrt@@sc3d.org}} @* @w{Copyright @copyright{} 2008 Guido U. Draheim @email{guidod@@gmx.de}} @* @w{Copyright @copyright{} 2008 Marten Svantesson} @* @w{Copyright @copyright{} 2008 Gerald Point @email{Gerald.Point@@labri.fr}} This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . As a special exception, the respective Autoconf Macro's copyright owner gives unlimited permission to copy, distribute and modify the configure scripts that are the output of Autoconf when processing the Macro. You need not follow the terms of the GNU General Public License when using or distributing such scripts, even though portions of the text of the Macro appear in them. The GNU General Public License (GPL) does govern all other use of the material that constitutes the Autoconf Macro. This special exception to the GPL applies to versions of the Autoconf Macro released by the Autoconf Archive. When you make and distribute a modified version of the Autoconf Macro, you may extend this special exception to the GPL to apply to your modified version as well.