From: pho Date: Sat, 14 Apr 2007 12:36:04 +0000 (+0900) Subject: CleanUp of Setup.hs X-Git-Tag: RELEASE-0_2_1~54 X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=c4438b4375f90b03b0c38a4719f9b158d04f6d80;p=Lucu.git CleanUp of Setup.hs darcs-hash:20070414123604-62b54-879f25f7ed1c5d7a72b6bb83f6929f26397f2c5c.gz --- diff --git a/Setup.hs b/Setup.hs index 411bd08..bd92fff 100755 --- a/Setup.hs +++ b/Setup.hs @@ -2,162 +2,3 @@ import Distribution.Simple main = defaultMain - -{- -import Data.Maybe -import Distribution.PackageDescription -import Distribution.Setup -import Distribution.Simple -import Distribution.Simple.Configure -import Distribution.Simple.LocalBuildInfo -import System.IO -import System.Exit -import System.Directory -import System.Process -import Control.Monad -import Control.Exception - -buildInfoName = "Kirschbaum.buildinfo" -cgiName = "Kirschbaum.cgi" - -main = defaultMainWithHooks defaultUserHooks {preConf = preConf, postConf = postConf} - where - preConf :: [String] -> ConfigFlags -> IO HookedBuildInfo - preConf args flags - = do try (removeFile buildInfoName) - return emptyHookedBuildInfo - postConf :: [String] -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ExitCode - postConf args flags _ localbuildinfo - = do binfo <- pkgConfigBuildInfo (configVerbose flags) - let default_binfo = emptyBuildInfo {extraLibs = ["xml2", "xslt", "exslt"]} - writeHookedBuildInfo buildInfoName (Just emptyBuildInfo, - [(cgiName, fromMaybe default_binfo binfo)]) - return ExitSuccess - - -message :: String -> IO () -message s = putStrLn $ "configure: " ++ s - -rawSystemGrabOutput :: Int -> FilePath -> [String] -> IO String -rawSystemGrabOutput verbose path args - = do when (verbose > 0) $ - putStrLn (path ++ concatMap (' ':) args) - (inp,out,err,pid) <- runInteractiveProcess path args Nothing Nothing - exitCode <- waitForProcess pid - if exitCode /= ExitSuccess then - do errMsg <- hGetContents err - hPutStr stderr errMsg - exitWith exitCode else - return () - hClose inp - hClose err - hGetContents out - -{- -mergeBuildInfo :: BuildInfo -> BuildInfo -> BuildInfo -mergeBuildInfo b1 b2 = BuildInfo { - buildable = buildable b1 || buildable b2, - ccOptions = ccOptions b1 ++ ccOptions b2, - ldOptions = ldOptions b1 ++ ldOptions b2, - frameworks = frameworks b1 ++ frameworks b2, - cSources = cSources b1 ++ cSources b2, - hsSourceDirs = hsSourceDirs b1 ++ hsSourceDirs b2, - otherModules = otherModules b1 ++ otherModules b2, - extensions = extensions b1 ++ extensions b2, - extraLibs = extraLibs b1 ++ extraLibs b2, - extraLibDirs = extraLibDirs b1 ++ extraLibDirs b2, - includeDirs = includeDirs b1 ++ includeDirs b2, - includes = includes b1 ++ includes b2, - installIncludes = installIncludes b1 ++ installIncludes b2, - options = options b1 ++ options b2, - ghcProfOptions = ghcProfOptions b1 ++ ghcProfOptions b2 - } - -libXml2ConfigBuildInfo :: Int -> IO (Maybe BuildInfo) -libXml2ConfigBuildInfo verbose - = do mb_libxml2_config_path <- findProgram "xml2-config" Nothing - case mb_libxml2_config_path - of Just libxml2_config_path - -> do message "configuring libxml2 library" - res <- rawSystemGrabOutput verbose libxml2_config_path ["--libs"] - let (lib_dirs, libs, ld_opts) = splitLibsFlags (words res) - res <- rawSystemGrabOutput verbose libxml2_config_path ["--cflags"] - let (inc_dirs, cc_opts) = splitCFlags (words res) - let bi = emptyBuildInfo { - extraLibDirs = lib_dirs, - extraLibs = libs, - ldOptions = ld_opts, - includeDirs = inc_dirs, - ccOptions = cc_opts - } - return $ Just bi - Nothing - -> do message "This package will be built using default settings for libxml2 library" - return Nothing - -libXsltConfigBuildInfo :: Int -> IO (Maybe BuildInfo) -libXsltConfigBuildInfo verbose - = do mb_libxslt_config_path <- findProgram "xslt-config" Nothing - case mb_libxslt_config_path - of Just libxslt_config_path - -> do message "configuring libxslt library" - res <- rawSystemGrabOutput verbose libxslt_config_path ["--libs"] - let (lib_dirs, libs, ld_opts) = splitLibsFlags (words res) - res <- rawSystemGrabOutput verbose libxslt_config_path ["--cflags"] - let (inc_dirs, cc_opts) = splitCFlags (words res) - let bi = emptyBuildInfo { - extraLibDirs = lib_dirs, - extraLibs = libs, - ldOptions = ld_opts, - includeDirs = inc_dirs, - ccOptions = cc_opts - } - return $ Just bi - Nothing - -> do message "This package will be built using default settings for libxslt library" - return Nothing --} - -pkgConfigBuildInfo :: Int -> IO (Maybe BuildInfo) -pkgConfigBuildInfo verbose - = do mb_libxslt_config_path <- findProgram "pkg-config" Nothing - case mb_libxslt_config_path - of Just libxslt_config_path - -> do message "configuring libxml2, libxslt and libexslt library" - let modules = ["libxml-2.0", "libxslt", "libexslt"] - res <- rawSystemGrabOutput verbose libxslt_config_path (modules ++ ["--libs"]) - let (lib_dirs, libs, ld_opts) = splitLibsFlags (words res) - res <- rawSystemGrabOutput verbose libxslt_config_path (modules ++ ["--cflags"]) - let (inc_dirs, cc_opts) = splitCFlags (words res) - let bi = emptyBuildInfo { - extraLibDirs = lib_dirs, - extraLibs = libs, - ldOptions = ld_opts, - includeDirs = inc_dirs, - ccOptions = cc_opts - } - return $ Just bi - Nothing - -> do message "This package will be built using default settings for libxslt library" - return Nothing - -splitLibsFlags :: [String] -> ([String], [String], [String]) -splitLibsFlags [] = ([], [], []) -splitLibsFlags (arg:args) - = case arg - of ('-':'L':lib_dir) -> let (lib_dirs, libs, ld_opts) = splitLibsFlags args - in (lib_dir:lib_dirs, libs, ld_opts) - ('-':'l':lib) -> let (lib_dirs, libs, ld_opts) = splitLibsFlags args - in (lib_dirs, lib:libs, ld_opts) - ld_opt -> let (lib_dirs, libs, ld_opts) = splitLibsFlags args - in (lib_dirs, libs, ld_opt:ld_opts) - -splitCFlags :: [String] -> ([String], [String]) -splitCFlags [] = ([], []) -splitCFlags (arg:args) - = case arg - of ('-':'I':inc_dir) -> let (inc_dirs, c_opts) = splitCFlags args - in (inc_dir:inc_dirs, c_opts) - c_opt -> let (inc_dirs, c_opts) = splitCFlags args - in (inc_dirs, c_opt:c_opts) --} \ No newline at end of file