pkg-config and Autoconf

Five different people asked or commented, in reply to my previous journal post about pkg-config files, why I didn't just have Autoconf generate the pkg-config configuration file directly. One could use the same template that I proposed in the previous post, but rather than adding the sed fragment to Makefile.am, instead add libfoo.pc to AC_CONFIG_FILES and let configure and config.status generate it directly.

This is simpler, but it has two problems:

I therefore prefer this approach, even though it's a bit more complex. I think it's more robust against both unusual ways in which people want to build my source packages and any future changes to Autoconf. Note, for example, that it's possible and sometimes useful to configure a package with a command like:

    ./configure --libdir='${datadir}'

(admittedly, more common to do that the other way arond) but that would fail with a pkg-config configuration file generated directly from Autoconf unless I'd anticipated that usage and added both datadir and datarootdir to the pkg-config template even though I wasn't using either.

I've updated my build system coding style page to include this rationale.

Posted: 2010-10-14 15:25 — Why no comments?

Last spun 2022-02-06 from thread modified 2013-01-04