Autoconf: AC_CONFIG_SUBDIRS with Custom Flags for Subprojects

| Comments

Starting with version 2.3.0, MacPorts will use its own copy of Tcl rather than relying on the Tcl shipped by Apple with OS X. Since MacPorts still works on versions of OS X down to Tiger that only have Tcl 8.4, all features introduced in Tcl 8.5 have been off limits and workarounds had to be used. That turned out to be unsatisfactory, especially avoiding {*} argument expansion (with the ugly workaround of using eval).

The idea of bundling a private copy of Tcl first came up in July 2013 on the macports-dev mailing list, originally in the context of the Apple distribution of Tcl changing in OS X Mavericks in a way that would no longer allow MacPorts to build from source if the optional Command Line Tools package wasn’t installed.

The Problem

MacPorts uses GNU autoconf in its build system. GNU autoconf supports bundling dependencies in subdirectories using the AC_CONFIG_SUBDIRS macro – but it wasn’t sufficient for two reasons:

  • The Tcl configure script creates a file that is needed by MacPorts’ configure to find the correct Tcl interpreter and build setup. AC_CONFIG_SUBDIRS will delay configuring subpackages to the very end, but we needed it to be done earlier.
  • AC_CONFIG_SUBDIRS will always pass the same arguments given to the main configure script, which includes the prefix setting. That would install our local copy of Tcl to a location that’s being used by the MacPorts tcl port (which is version 8.6 and at the moment incompatible with some of the MacPorts code).

There have been a few attempts at solving similar problems, one of which is a patch against autoconf and has been sent to the autoconf mailinglist in April 2011, but was apparently never applied. I didn’t want to require a patched autoconf to generate the MacPorts configure script either, so applying the patch was not an option.

The Solution

An unsolved problem in a technology I haven’t used a lot yet? That sounded like a great opportunity to learn something new – and so I wrote the missing macro, mostly by reading and copying the source of AC_CONFIG_SUBDIRS and adjusting it where needed. I added extracting from a tarball so I didn’t have to commit the extracted Tcl sources. MP_CONFIG_TARBALL (source) takes the path to a tarball, the directory that’s created by extracting the tarball that contains the configure script and a list of configure parameters to pass to the subproject. Each given configure parameter overrides those given on the main project’s command line and preserves those that have not been overwritten like AC_CONFIG_SUBDIRS would.


Please enable JavaScript to view comments. Note that comments are provided by a local instance of Isso. No data is sent to third party servers. For more information, see the privacy policy.