on e46572e help sign in
stackage/patching/patches/cairo-0.12.4.patch
150 lines 6.3 kB history raw
1diff -ru orig/Gtk2HsSetup.hs new/Gtk2HsSetup.hs
2--- orig/Gtk2HsSetup.hs 2013-10-28 08:36:50.283581635 +0100
3+++ new/Gtk2HsSetup.hs 2013-10-28 08:36:50.000000000 +0100
4@@ -1,4 +1,4 @@
5-{-# LANGUAGE CPP #-}
6+{-# LANGUAGE CPP, ViewPatterns #-}
7
8 #ifndef CABAL_VERSION_CHECK
9 #error This module has to be compiled via the Setup.hs program which generates the gtk2hs-macros.h file
10@@ -29,7 +29,7 @@
11 emptyBuildInfo, allBuildInfo,
12 Library(..),
13 libModules, hasLibs)
14-import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..),
15+import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(withPackageDB, buildDir, localPkgDescr, installedPkgs, withPrograms),
16 InstallDirs(..),
17 componentPackageDeps,
18 absoluteInstallDirs)
19@@ -56,14 +56,26 @@
20 import Distribution.Verbosity
21 import Control.Monad (when, unless, filterM, liftM, forM, forM_)
22 import Data.Maybe ( isJust, isNothing, fromMaybe, maybeToList )
23-import Data.List (isPrefixOf, isSuffixOf, nub, minimumBy)
24+import Data.List (isPrefixOf, isSuffixOf, nub, minimumBy, stripPrefix)
25 import Data.Ord as Ord (comparing)
26-import Data.Char (isAlpha)
27+import Data.Char (isAlpha, isNumber)
28 import qualified Data.Map as M
29 import qualified Data.Set as S
30+import qualified Distribution.Simple.LocalBuildInfo as LBI
32 import Control.Applicative ((<$>))
34+#if CABAL_VERSION_CHECK(1,17,0)
35+import Distribution.Simple.Program.Find ( defaultProgramSearchPath )
36+onDefaultSearchPath f a b = f a b defaultProgramSearchPath
37+libraryConfig lbi = case [clbi | (LBI.CLibName, clbi, _) <- LBI.componentsConfigs lbi] of
38+ [clbi] -> Just clbi
39+ _ -> Nothing
40+#else
41+onDefaultSearchPath = id
42+libraryConfig = LBI.libraryConfig
43+#endif
45 -- the name of the c2hs pre-compiled header file
46 precompFile = "precompchs.bin"
48@@ -100,7 +112,7 @@
50 fixLibs :: [FilePath] -> [String] -> [String]
51 fixLibs dlls = concatMap $ \ lib ->
52- case filter (("lib" ++ lib) `isPrefixOf`) dlls of
53+ case filter (isLib lib) dlls of
54 dlls@(_:_) -> [dropExtension (pickDll dlls)]
55 _ -> if lib == "z" then [] else [lib]
56 where
57@@ -111,7 +123,12 @@
58 -- Yes this is a hack but the proper solution is hard: we would need to
59 -- parse the .a file and see which .dll file(s) it needed to link to.
60 pickDll = minimumBy (Ord.comparing length)
62+ isLib lib dll =
63+ case stripPrefix ("lib"++lib) dll of
64+ Just ('.':_) -> True
65+ Just ('-':n:_) | isNumber n -> True
66+ _ -> False
67+
68 -- The following code is a big copy-and-paste job from the sources of
69 -- Cabal 1.8 just to be able to fix a field in the package file. Yuck.
71@@ -144,8 +161,8 @@
72 register :: PackageDescription -> LocalBuildInfo
73 -> RegisterFlags -- ^Install in the user's database?; verbose
74 -> IO ()
75-register pkg@PackageDescription { library = Just lib }
76- lbi@LocalBuildInfo { libraryConfig = Just clbi } regFlags
77+register pkg@(library -> Just lib )
78+ lbi@(libraryConfig -> Just clbi) regFlags
79 = do
81 installedPkgInfoRaw <- generateRegistrationInfo
82@@ -237,6 +254,7 @@
83 = nub $
84 ["-I" ++ dir | dir <- PD.includeDirs bi]
85 ++ [opt | opt@('-':c:_) <- PD.cppOptions bi ++ PD.ccOptions bi, c `elem` "DIU"]
86+ ++ ["-D__GLASGOW_HASKELL__="++show __GLASGOW_HASKELL__]
88 installCHI :: PackageDescription -- ^information from the .cabal file
89 -> LocalBuildInfo -- ^information from the configure step
90@@ -426,7 +444,7 @@
91 checkGtk2hsBuildtools :: [Program] -> IO ()
92 checkGtk2hsBuildtools programs = do
93 programInfos <- mapM (\ prog -> do
94- location <- programFindLocation prog normal
95+ location <- onDefaultSearchPath programFindLocation prog normal
96 return (programName prog, location)
97 ) programs
98 let printError name = do
99diff -ru orig/SetupWrapper.hs new/SetupWrapper.hs
100--- orig/SetupWrapper.hs 2013-10-28 08:36:50.283581635 +0100
101+++ new/SetupWrapper.hs 2013-10-28 08:36:50.000000000 +0100
102@@ -29,6 +29,24 @@
103 import Control.Monad
106+-- moreRecentFile is implemented in Distribution.Simple.Utils, but only in
107+-- Cabal >= 1.18. For backwards-compatibility, we implement a copy with a new
108+-- name here. Some desirable alternate strategies don't work:
109+-- * We can't use CPP to check which version of Cabal we're up against because
110+-- this is the file that's generating the macros for doing that.
111+-- * We can't use the name moreRecentFiles and use
112+-- import D.S.U hiding (moreRecentFiles)
113+-- because on old GHC's (and according to the Report) hiding a name that
114+-- doesn't exist is an error.
115+moreRecentFile' :: FilePath -> FilePath -> IO Bool
116+moreRecentFile' a b = do
117+ exists <- doesFileExist b
118+ if not exists
119+ then return True
120+ else do tb <- getModificationTime b
121+ ta <- getModificationTime a
122+ return (ta > tb)
124 setupWrapper :: FilePath -> IO ()
125 setupWrapper setupHsFile = do
126 args <- getArgs
127@@ -91,8 +109,8 @@
128 -- Currently this is GHC only. It should really be generalised.
129 --
130 compileSetupExecutable = do
131- setupHsNewer <- setupHsFile `moreRecentFile` setupProgFile
132- cabalVersionNewer <- setupVersionFile `moreRecentFile` setupProgFile
133+ setupHsNewer <- setupHsFile `moreRecentFile'` setupProgFile
134+ cabalVersionNewer <- setupVersionFile `moreRecentFile'` setupProgFile
135 let outOfDate = setupHsNewer || cabalVersionNewer
136 when outOfDate $ do
137 debug verbosity "Setup script is out of date, compiling..."
138@@ -144,12 +162,3 @@
139 Nothing Nothing Nothing
140 exitCode <- waitForProcess process
141 unless (exitCode == ExitSuccess) $ exitWith exitCode
143-moreRecentFile :: FilePath -> FilePath -> IO Bool
144-moreRecentFile a b = do
145- exists <- doesFileExist b
146- if not exists
147- then return True
148- else do tb <- getModificationTime b
149- ta <- getModificationTime a
150- return (ta > tb)