MINGW-packages: fontconfig.pc doesn't define prefix

This is half-bug-report, half-question (since I’m not sure which label describes it best). I’m trying to install a Haskell package (cairo) that depends on mingw-w64-x86_64-cairo being installed. However, it doesn’t work out-of-the-box at the moment. You can read the full error log here, but the gist of it is that a Windows tool (ghc-pkg) is being confused by a Unix-style paths (e.g., /mingw64/include/freetype2 rather than, say, C:/msys2/mingw64/include/freetype2).

The issue seems to be related to fontconfig.pc (since fontconfig is one of cairo’s dependencies). If you run pkg-config --cflags fontconfig, you get some interesting results:

-mms-bitfields -IC:/msys64/mingw64/include -I/mingw64/include/freetype2 -I/mingw64/include/libpng16 -I/mingw64/include/harfbuzz -I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/freetype2 -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/libpng16 -IC:/msys64/mingw64/include/harfbuzz -IC:/msys64/mingw64/include/glib-2.0 -IC:/msys64/mingw64/lib/glib-2.0/include

There are many duplicates that have only changed -IC:/msys64/mingw64/... to -I/mingw64/.... The latter kind of paths are probably what is confusing ghc-pkg.

Curiously, this seems to be intentional, since there is a .patch file that configures this behavior via --dont-define-prefix:

--- fontconfig-2.11.93/m4/pkg.m4.orig   2015-03-09 02:54:03.000000000 +0000
+++ fontconfig-2.11.93/m4/pkg.m4    2015-04-06 11:04:21.862416100 +0000
@@ -111,8 +111,8 @@
 pkg_failed=no
 AC_MSG_CHECKING([for $1])

-_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
-_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+_PKG_CONFIG([$1][_CFLAGS], [cflags --dont-define-prefix], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs --dont-define-prefix], [$2])

 m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
 and $1[]_LIBS to avoid the need to call pkg-config.
@@ -207,7 +207,7 @@
 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
 AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl

-_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+_PKG_CONFIG([$1], [variable="][$3][" --dont-define-prefix], [$2])
 AS_VAR_COPY([$1], [pkg_cv_][$1])

 AS_VAR_IF([$1], [""], [$5], [$4])dnl

My question is: if this was not intentional, could this be removed to make building cairo easier? And if it is intentional, can you give me an explanation for why it is done that way?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 20 (18 by maintainers)

Most upvoted comments

@mingwandroid, thanks for the link. The Hard-coded paths and relocation section has an interesting nugget of wisdom:

Sometimes these paths are baked into shell scripts or pkg-config’s .pc files. In that case, you should use sed in the PKGBUILD package() function to correct this back to the msys2 version of the path.

Interestingly, the the PKGBUILD package() function for mingw-w64-fontconfig does not use sed at the moment to sanitize fontconfig.pc’s hardcoded paths. Is there any reason it couldn’t? Perhaps that would be an easier fix than changing the source code of pkg-config itself.