Index: source-builder/sb/pkgconfig.py
===================================================================
--- source-builder/sb/pkgconfig.py	(revision 0ffee1931680e92757a4d91199e2517f05e7364d)
+++ source-builder/sb/pkgconfig.py	(revision c434884af121faf9c172dc660e61e384539cd003)
@@ -42,14 +42,30 @@
 import sys
 
+import path
+
 def default_prefix(common = True):
     paths = []
+    #
+    # We have two paths to work around an issue in MSYS2 and the
+    # conversion of Windows paths to shell paths.
+    #
+    if 'PKG_CONFIG_DEFAULT_PATH' in os.environ:
+        for p in os.environ['PKG_CONFIG_DEFAULT_PATH'].split(os.pathsep):
+            paths += [path.shell(p)]
     if 'PKG_CONFIG_PATH' in os.environ:
-        paths += os.environ['PKG_CONFIG_PATH'].split(':')
+        for p in os.environ['PKG_CONFIG_PATH'].split(os.pathsep):
+            paths += [path.shell(p)]
     if common:
-        defaults = ['/usr', '/usr/share', '/lib', '/lib64', '/usr/lib', '/usr/lib64', '/usr/local']
+        defaults = ['/usr',
+                    '/usr/share',
+                    '/lib',
+                    '/lib64',
+                    '/usr/lib',
+                    '/usr/lib64',
+                    '/usr/local']
         for d in defaults:
             for cp in package.config_prefixes:
-                prefix = os.path.join(d, cp, 'pkgconfig')
-                if os.path.exists(prefix):
+                prefix = path.join(d, cp, 'pkgconfig')
+                if path.exists(prefix):
                     paths += [prefix]
     return paths
@@ -65,5 +81,7 @@
 
     node_types = ['requires', 'requires.private']
-    node_type_labels = { 'requires': 'r', 'requires.private': 'rp', 'failed': 'F' }
+    node_type_labels = { 'requires': 'r',
+                         'requires.private': 'rp',
+                         'failed': 'F' }
     version_ops = ['=', '<', '>', '<=', '>=', '!=']
     config_prefixes = ['lib', 'libdata']
@@ -181,5 +199,6 @@
             print package.loaded[n]._str()
 
-    def __init__(self, name = None, prefix = None, libs_scan = False, output = None, src = None):
+    def __init__(self, name = None, prefix = None,
+                 libs_scan = False, output = None, src = None):
         self._clean()
         self.name_ = name
@@ -192,6 +211,8 @@
             prefix = default_prefix()
         if prefix:
+            self._log('prefix: %s' % (prefix))
             if type(prefix) is str:
-                self.prefix = prefix.split(os.pathsep)
+                for p in prefix.split(os.pathsep):
+                    self.prefix += [path.shell(p)]
             elif type(prefix) is list:
                 self.prefix = prefix
@@ -199,5 +220,5 @@
                 raise error('invalid type of prefix: %s' % (type(prefix)))
             for p in self.prefix:
-                if os.path.exists(p):
+                if path.exists(p):
                     self.paths += [p]
             self._log('paths: %s' % (', '.join(self.paths)))
@@ -265,7 +286,7 @@
     def _find_package(self, name):
         if len(self.paths):
-            for path in self.paths:
-                pc = os.path.join(path, '%s.pc' % (name))
-                if os.path.isfile(pc):
+            for p in self.paths:
+                pc = path.join(p, '%s.pc' % (name))
+                if path.isfile(pc):
                     return pc;
         return None
@@ -275,9 +296,9 @@
         if self.libs_scan:
             for prefix in self.prefix:
-                prefix = os.path.join(prefix, 'lib')
-                if os.path.exists(prefix):
-                    for l in os.listdir(prefix):
+                prefix = path.join(prefix, 'lib')
+                if path.exists(prefix):
+                    for l in os.listdir(path.host(prefix)):
                         if l.startswith(name + '.'):
-                            libraries += [os.path.join(prefix, l)]
+                            libraries += [path.join(prefix, l)]
                             break
         return libraries
@@ -306,7 +327,7 @@
                         break
                     if offset + dash + 2 < len(s) and s[offset + dash + 1] in 'LI':
-                        path = s[offset + dash + 2:]
-                        if not path.startswith(top_builddir):
-                            s = s[:offset + dash + 2] + top_builddir + path
+                        p = s[offset + dash + 2:]
+                        if not p.startswith(top_builddir):
+                            s = s[:offset + dash + 2] + top_builddir + p
                     offset += dash + 1
         return s
@@ -373,5 +394,5 @@
         if file is None:
             return None
-        name = os.path.basename(file)
+        name = path.basename(file)
         if name.endswith('.pc'):
             name = name[:-3]
@@ -407,5 +428,5 @@
                 self.src(' %s %s%s' % (file, '=' * (80 - len(file)), os.linesep))
                 self.src('==%s%s' % ('=' * 80, os.linesep))
-            f = open(file)
+            f = open(path.host(file))
             tm = False
             for l in f.readlines():
@@ -559,3 +580,2 @@
             break
     return ec, pkg, flags
-
