commit:     cb01338bb42175efee3af2aeca1055c544b33140
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 10 01:41:53 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug  1 02:38:39 2021 +0000
URL:        https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=cb01338b

ebuild-writing/common-mistakes: add 'Calling pkg-config directly'

Quite a lot of ebuilds do this. We should instead use the tc-getPKG_CONFIG
helper from toolchain-funcs.eclass which respects ${PKG_CONFIG} - useful
for e.g. cross-compiling.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 ebuild-writing/common-mistakes/text.xml | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/ebuild-writing/common-mistakes/text.xml 
b/ebuild-writing/common-mistakes/text.xml
index 1969efe..cc87d74 100644
--- a/ebuild-writing/common-mistakes/text.xml
+++ b/ebuild-writing/common-mistakes/text.xml
@@ -505,8 +505,29 @@ the ebuild's quality and ease review.
 </p>
 </body>
 </subsection>
-</section>
 
+<subsection>
+<title>Calling pkg-config directly</title>
+<body>
+
+<p>
+You should not call <c>pkg-config</c> directly in ebuilds because this is
+problematic for e.g. cross-compiling. The correct helper respects
+<c>${PKG_CONFIG}</c>. Instead, use <c>tc-getPKG_CONFIG</c> from
+<c>toolchain-funcs.eclass</c>, e.g.
+</p>
+
+<codesample lang="ebuild">
+sed -i -e "s:-lncurses:$($(tc-getPKG_CONFIG) --libs ncurses):" || die
+</codesample>
+
+<p>
+Don't then forget to add <c>virtual/pkgconfig</c> to BDEPEND!
+</p>
+
+</body>
+</subsection>
+</section>
 
 <section>
 <title>Common Ebuild Submission Mistakes</title>

Reply via email to