Skip to content

Instantly share code, notes, and snippets.

@darthdeus
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darthdeus/15669f75acd02fbbd476 to your computer and use it in GitHub Desktop.
Save darthdeus/15669f75acd02fbbd476 to your computer and use it in GitHub Desktop.
Configuring mysql-0.1.1.7...
setup.exe: Can't locate File/Basename.pm in @INC (@INC contains: C:/Program
Files/Haskell Platform/2014.2.0.0/lib .) at mysql_config.pl line 39.
BEGIN failed--compilation aborted at mysql_config.pl line 39.
#!/usr/bin/env runhaskell
\begin{code}
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
{- OPTIONS_GHC -Wall #-}
import Control.Monad (liftM2, mplus)
import Data.List (isPrefixOf)
import Distribution.PackageDescription
import Distribution.Simple
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Program
import Distribution.Verbosity
-- A Cabal 1.16 vs 1.18 compatibility hack, as in 1.18
-- findProgramLocation has a new (unused in this case) parameter.
-- ConstOrId adds this parameter when types say it is mandatory.
class ConstOrId a b where
constOrId :: a -> b
instance ConstOrId a a where
constOrId = id
instance ConstOrId a (b -> a) where
constOrId = const
main = defaultMainWithHooks simpleUserHooks {
hookedPrograms = [mysqlConfigProgram],
confHook = \pkg flags -> do
lbi <- confHook simpleUserHooks pkg flags
bi <- mysqlBuildInfo lbi
return lbi {
localPkgDescr = updatePackageDescription (Just bi, []) (localPkgDescr lbi)
}
}
mysqlConfigProgram = (simpleProgram "perl") {
programFindLocation = \verbosity -> constOrId $ liftM2 mplus
(findProgramLocation verbosity "perl")
(findProgramLocation verbosity "mysql_config5")
}
mysqlBuildInfo :: LocalBuildInfo -> IO BuildInfo
mysqlBuildInfo lbi = do
let mysqlConfig = fmap words . rawSystemProgramStdoutConf normal
mysqlConfigProgram (withPrograms lbi)
include <- mysqlConfig ["mysql_config.pl", "--", "--include"]
libs <- mysqlConfig ["mysql_config.pl", "--", "--libs"]
return emptyBuildInfo {
extraLibDirs = map (drop 2) . filter ("-L" `isPrefixOf`) $ libs
, extraLibs = map (drop 2) . filter ("-l" `isPrefixOf`) .
filter (/= "-lmygcc") $ libs
, includeDirs = map (drop 2) include
}
\end{code}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment