diff --git a/Cabal/Distribution/Simple/Configure.hs b/Cabal/Distribution/Simple/Configure.hs
index 2eefd29eb..9f8613f82 100644
--- a/Cabal/Distribution/Simple/Configure.hs
+++ b/Cabal/Distribution/Simple/Configure.hs
@@ -133,7 +133,8 @@ import qualified System.Info
 import System.IO
     ( hPutStrLn, hClose )
 import Distribution.Text
-    ( Text(disp), defaultStyle, display, simpleParse )
+    ( Text(disp), defaultStyle, display, simpleParse
+    , longestParse )
 import Text.PrettyPrint
     ( Doc, (<+>), ($+$), char, comma, hsep, nest
     , punctuate, quotes, render, renderStyle, sep, text )
@@ -1525,7 +1526,14 @@ configurePkgconfigPackages verbosity pkg_descr progdb enabled
       version <- pkgconfig ["--modversion", pkg]
                  `catchIO`   (\_ -> die' verbosity notFound)
                  `catchExit` (\_ -> die' verbosity notFound)
-      case simpleParse version of
+      -- pkg-config versions have much more flexibility than the
+      -- sequence of dotted numbers that we can
+      -- parse. https://github.com/haskell/cabal/issues/163
+      -- Here we implement the "stopgap" suggestion of
+      -- https://github.com/haskell/cabal/issues/163#issuecomment-284608073
+      -- We take the longest prefix which can be parsed as a dotted
+      -- sequence of numbers.
+      case longestParse version of
         Nothing -> die' verbosity "parsing output of pkg-config --modversion failed"
         Just v | not (withinRange v range) -> die' verbosity (badVersion v)
                | otherwise                 -> info verbosity (depSatisfied v)
diff --git a/Cabal/Distribution/Text.hs b/Cabal/Distribution/Text.hs
index 92eeb79bf..469713642 100644
--- a/Cabal/Distribution/Text.hs
+++ b/Cabal/Distribution/Text.hs
@@ -19,10 +19,12 @@ module Distribution.Text (
   flatStyle,
   simpleParse,
   stdParse,
+  longestParse
   ) where
 
 import Prelude ()
 import Distribution.Compat.Prelude
+import Data.List(minimumBy)
 
 import           Data.Functor.Identity    (Identity (..))
 import           Distribution.Pretty
@@ -53,6 +55,14 @@ simpleParse str = case [ p | (p, s) <- Parse.readP_to_S parse str
   []    -> Nothing
   (p:_) -> Just p
 
+longestParse :: Text a => String -> Maybe a
+longestParse str =
+    let ps = Parse.readP_to_S parse str
+    in if null ps then Nothing
+       else Just $ fst
+                $ minimumBy  -- minimize the leftover string
+                (\x y -> compare (length $ snd x) (length $ snd y)) ps
+
 stdParse :: Text ver => (ver -> String -> res) -> Parse.ReadP r res
 stdParse f = do
   cs   <- Parse.sepBy1 component (Parse.char '-')
@@ -90,7 +100,10 @@ instance Text a => Text (Identity a) where
 parseNat :: Parse.ReadP r Int
 parseNat = read `fmap` Parse.munch1 isDigit -- TODO: eradicateNoParse
 
-
+-- This instance is used in, among other places,
+-- Distribution.Client.HttpUtils in cabal-install.  Note well, this
+-- type, Data.Version.Version, is a different type from
+-- Distribution.Types.Version, which has a similar Text instance.
 instance Text Version where
   disp (Version branch _tags)     -- Death to version tags!!
     = Disp.hcat (Disp.punctuate (Disp.char '.') (map Disp.int branch))
