8/25/2006
autoconf hacks
Ever need to import a header that in turn ends up pulling in a config.h from another autotool’d package? Yes, it’s nasty and shouldn’t happen but it was something I had no control over. Searching around it seems that other people have had this issue before and were told that autoconf explicitly doesn’t support this. (as per the autoconf & automake mailing listings) The reason is that autoconf does not use #ifndef on it’s exported #define’s since there is no sense of namespacing in autoconf. The problem comes from the #define PACKAGE “your-pkg”, since it is most likely defined to some other name. There’s a bunch of hacks such as [no-define] in your automake m4 macros, but this doesn’t get rid of all of the defines. There’s other hacks to remove the defines however autoconf is not happy with most of them and spits out angry errors. The best solution to date I have found to make it work is the following.
AH_VERBATIM([PACKAGE_NAMD], [#if 0])
AH_VERBATIM([PACKAGE_NAME_], [#endif])AH_VERBATIM([PACKAGD], [#if 0])
AH_VERBATIM([PACKAGE_], [#endif])AH_VERBATIM([VERSIOM], [#if 0])
AH_VERBATIM([VERSION_], [#endif])AH_VERBATIM([PACKAGE_STRINE], [#if 0])
AH_VERBATIM([PACKAGE_STRING_], [#endif])AH_VERBATIM([PACKAGE_VERSIOM], [#if 0])
AH_VERBATIM([PACKAGE_VERSION_], [#endif])AH_VERBATIM([PACKAGE_TARNAMD], [#if 0])
AH_VERBATIM([PACKAGE_TARNAME_], [#endif])AH_VERBATIM([PACKAGE_BUGREPORS], [#if 0])
AH_VERBATIM([PACKAGE_BUGREPORT_], [#endif])
You will notice in your resulting config.h.in that autoheader creates will have all the #undef’s above defined properly for autoconf but they’ll be wrapped in #if 0 blocks so they’ll be entirely ignored. If you really want to, you could have #if !defined(PACKAGE).
Worst solution to the above problem I’ve seen:
cat config.h | grep -v “#undef PACKAGE” | grep -v “#undef VERSION” > config-final.h
at the end of your configure.in. This results in the timestamp being updated and EVERYTIME a dependancy is checked, it’ll cause a full rebuild.
Filed under: General, Linux
No Comments