Bug 32094

Summary: doc should suggest .pc file generation in "make", not "configure"
Product: pkg-config Reporter: bdenckla
Component: srcAssignee: Tollef Fog Heen <tfheen>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: medium CC: ohnobinki
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description bdenckla 2010-12-04 00:36:34 UTC
The pkg-config man page says, when discussing an example .pc file:

"You would normally generate the file using configure, of course, so that the prefix, etc. are set to the proper values."

(e.g. as seen in http://cgit.freedesktop.org/pkg-config/tree/pkg-config.1)

I agree that this is normally what is done, but I don't think it is the best way to do it.  In particular, I think the best way to do it is at "make" time, not "configure" time.

For example, if you defer .pc generation until "make" time, you can generate .pc files based on a prefix which is based on a Makefile variable like $(abs_top_builddir).  For example, in configure.ac, you could do

AC_PREFIX_DEFAULT("\$(abs_top_builddir)/install")

If you (prematurely) generate the .pc file at "configure" time in such a situation, you'll get a broken .pc file because it will contain, literally, "$(abs_top_builddir)".  This is the most severe symptom of premature generation of the .pc file, and the one that brought the issue to my attention, but there is also just the general problem that, according to the GNU Coding Standards, you should be able to change the prefix at make time.

To me, the definitive reference here is the autoconf manual:

"[...] you should not rely on AC_CONFIG_FILES to replace bindir and friends in your shell scripts and other files; instead, let make manage their replacement."

I discussed the issue in detail in this post on the pkg-config discussion list:

http://lists.freedesktop.org/archives/pkg-config/2010-July/000645.html

I got no response there so I'm "escalating" the issue by logging this bug.
Comment 1 Tollef Fog Heen 2011-04-13 12:04:58 UTC
First, pkg-config is not part of the auto* suite, so we're not really bound by how the auto* people think a build system should act.  Now, that said, I've added a bit to current git saying that some people prefer to do it at build time, so I consider this bug closed.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.