Gentoo pkg-config and cross-compilation

A note to myself (given that I’ve solved this issue a few times now).

If you’re attempting to cross-compile under Gentoo, and are using pkg-config, certain functionality will be silently disabled. Of particular note for my purposes is PKG_CONFIG_PATH, which I use as part of my autotools sub-package strategy. There is no point filing bugs for this issue as the maintainers have made it explicit that this is deliberate and no patches will be accepted.

To reinstate this functionality you will need to manually modify /usr/bin/cross-pkg-config as below:

*** a/cross-pkg-config	2016-06-16 16:22:20.602295016 +1000
--- b/cross-pkg-config	2016-06-16 16:22:29.993353044 +1000
***************
*** 72,78 ****
  # Some distributions pollute the pkg-config environment.
  # Time to pull a captain planet on them.
  #
- unset PKG_CONFIG_PATH
  unset PKG_CONFIG_ALLOW_SYSTEM_CFLAGS
  unset PKG_CONFIG_ALLOW_SYSTEM_LIBS
  
--- 72,77 ----

Depending on your situation there are probably a great deal more lines one could delete.

Note that you will need to reapply this patch every time cross-dev is reinstalled. The ebuild doesn’t trigger the usual user patch hooks, so a more permanent fix would require editing the ebuild. But as the package is updated infrequently the manual process from above is fairly painless.