AC and AM version numbers

I ran into a problem with Open MPI’s build system today and have come up with a reasonable, but sub-optimal solution. The basics of the problem are that we need to support both the combinations of Autoconf 2.59/Automake 1.9.6 and Autoconf 2.60+/Automake 1.10+ in a project using Objective C (only for a very small, optional component). AC 2.59/AM 1.9.6 have basically zero support for Objective C, but AC 2.60+/AM 1.10 have full support for Objective C. I had back-ported in a bunch of macros to get the bare minimum support we needed for Objective C with AC 2.59, but that all conflicted with AC 2.60, so needed to be optionally provided. So there were two problems:

  • How to determine whether to provide compatibility AC_PROG_OBJC or use AC’s macro
  • How to prevent using AC 2.60 with AM 1.9.6

The problem with the first one is that looking at AC_PROG_OBJC seemed to cause all kinds of entertaining things to happen with AC 2.60. So the solution there was to peek at the internal structures for AC and get the version number, then act accordingly. After figuring out all the macros I needed to provide, this worked reasonably well. Look at config/ompi_objc.m4 to see which ones we ended up needing.

Automake doesn’t seem to provide an internal macro with its version number, so I couldn’t do the obvious to find the version number and do all the logic to make sure we never see AC 2.60 used with AM 1.9.6 (which would give us half support for Objective C and be a major pain). So the best I could come up with was to use the version requirement checking feature of AM_INIT_AUTOMAKE:

m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]), [2.60]), -1,
  [AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects no-define])],
  [AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects no-define 1.10])])

It’s really vile, but it does work…