1+ {-# LANGUAGE CPP #-}
12{-# LANGUAGE TupleSections #-}
23
34import Distribution.Simple
45import Distribution.Simple.Setup (ConfigFlags (.. ), toFlag )
56import Distribution.Simple.LocalBuildInfo (localPkgDescr )
7+
8+ #if __GLASGOW_HASKELL__ >= 802
9+ import Distribution.PackageDescription (FlagName (.. ), mkFlagName )
10+ #else
611import Distribution.PackageDescription (FlagName (.. ))
12+ #endif
13+
714import Distribution.Verbosity (silent )
815import System.Info (os )
916import qualified Control.Exception as E (tryJust , throw )
@@ -34,13 +41,13 @@ conf descr cfg = do
3441 Right lbi -> return lbi -- library was found
3542 Left e
3643 | configConfigurationsFlags cfg
37- `intersect` [(FlagName f, True ) | f <- flags] /= [] ->
44+ `intersect` [(mkFlagName f, True ) | f <- flags] /= [] ->
3845 E. throw e
3946 -- flag was set but library still wasn't found
4047 | otherwise -> do
4148 r <- forM flags $ \ f ->
4249 fmap (f,) $ tryConfig descr $
43- setFlag f cfg { configVerbosity = toFlag silent }
50+ setFlag (mkFlagName f) cfg { configVerbosity = toFlag silent }
4451 -- TODO: configure is a long operation
4552 -- while checkForeignDeps is fast.
4653 -- Perhaps there is a way to configure once
@@ -55,21 +62,23 @@ conf descr cfg = do
5562 fs ->
5663 fail $ multipleFound fs
5764
58- notFound =
59- " Can't find OpenSSL library,\n \
60- \install it via 'brew install openssl' or 'port install openssl'\n \
61- \or use --extra-include-dirs= and --extra-lib-dirs=\n \
62- \to specify location of installed OpenSSL library."
65+ notFound = unlines
66+ [ " Can't find OpenSSL library,"
67+ , " install it via 'brew install openssl' or 'port install openssl'"
68+ , " or use --extra-include-dirs= and --extra-lib-dirs="
69+ , " to specify location of installed OpenSSL library."
70+ ]
6371
64- multipleFound fs =
65- " Multiple OpenSSL libraries were found,\n \
66- \use " ++ intercalate " or " [" '-f " ++ f ++ " '" | (f,_) <- fs] ++ " \n \
67- \to specify location of installed OpenSSL library."
72+ multipleFound fs = unlines
73+ [ " Multiple OpenSSL libraries were found,"
74+ , " use " ++ intercalate " or " [" '-f " ++ f ++ " '" | (f,_) <- fs]
75+ , " to specify location of installed OpenSSL library."
76+ ]
6877
6978setFlag f c = c { configConfigurationsFlags = go (configConfigurationsFlags c) }
7079 where go [] = []
71- go (x@ (FlagName n, _): xs)
72- | n == f = (FlagName f, True ) : xs
80+ go (x@ (n, _): xs)
81+ | n == f = (f, True ) : xs
7382 | otherwise = x : go xs
7483
7584tryConfig descr flags = do
@@ -88,3 +97,8 @@ tryConfig descr flags = do
8897
8998 where ue e | isUserError e = Just e
9099 | otherwise = Nothing
100+
101+ #if __GLASGOW_HASKELL__ < 802
102+ mkFlagName = FlagName
103+ #endif
104+
0 commit comments