[project @ 2000-10-03 16:51:57 by sewardj]
[ghc-hetmet.git] / ghc / driver / PackageSrc.hs
1 module Main (main) where
2
3 import IO
4 import System
5 import Config
6 import Package
7
8 main :: IO ()
9 main = do
10   args <- getArgs
11   case args of
12         [ "install"  ] -> do { putStrLn (dumpPackages (package_details True)) }
13         [ "in-place" ] -> do { putStrLn (dumpPackages (package_details False)) }
14         _ -> do hPutStr stderr "usage: pkgconf (install | in-place)\n"
15                 exitWith (ExitFailure 1)
16
17 package_details :: Bool -> [Package]
18 package_details installing =
19  [
20         Package {
21         name           = "gmp",  -- GMP is at the bottom of the heap
22         import_dirs    = [],
23         library_dirs   = if cHaveLibGmp == "YES"
24                             then []
25                             else if installing
26                                     then [ clibdir ]
27                                     else [ ghc_src_dir cGHC_RUNTIME_DIR ++ "/gmp" ],
28         hs_libraries   = [],
29         extra_libraries = [ "gmp" ],
30         include_dirs   = [],
31         c_includes     = [],
32         package_deps   = [],
33         extra_ghc_opts = [],
34         extra_cc_opts  = [],
35         extra_ld_opts  = []
36         },
37
38         Package {
39         name           = "rts",  -- The RTS is just another package!
40         import_dirs    = [],
41         library_dirs   = if installing
42                             then [ clibdir ]
43                             else [ ghc_src_dir cGHC_RUNTIME_DIR ],
44         hs_libraries      = [ "HSrts" ],
45         extra_libraries   = [],
46         include_dirs   = if installing
47                             then [ clibdir ++ "/includes" ]
48                             else [ ghc_src_dir cGHC_INCLUDE_DIR ],
49         c_includes     = [ "Stg.h" ],           -- ha!
50         package_deps   = [ "gmp" ],
51         extra_ghc_opts = [],
52         extra_cc_opts  = [],
53                 -- the RTS forward-references to a bunch of stuff in the prelude,
54                 -- so we force it to be included with special options to ld.
55         extra_ld_opts  = [
56            "-u PrelMain_mainIO_closure"
57          , "-u PrelBase_Izh_static_info"
58          , "-u PrelBase_Czh_static_info"
59          , "-u PrelFloat_Fzh_static_info"
60          , "-u PrelFloat_Dzh_static_info"
61          , "-u PrelAddr_Azh_static_info"
62          , "-u PrelAddr_Wzh_static_info"
63          , "-u PrelAddr_I64zh_static_info"
64          , "-u PrelAddr_W64zh_static_info"
65          , "-u PrelStable_StablePtr_static_info"
66          , "-u PrelBase_Izh_con_info"
67          , "-u PrelBase_Czh_con_info"
68          , "-u PrelFloat_Fzh_con_info"
69          , "-u PrelFloat_Dzh_con_info"
70          , "-u PrelAddr_Azh_con_info"
71          , "-u PrelAddr_Wzh_con_info"
72          , "-u PrelAddr_I64zh_con_info"
73          , "-u PrelAddr_W64zh_con_info"
74          , "-u PrelStable_StablePtr_con_info"
75          , "-u PrelBase_False_closure"
76          , "-u PrelBase_True_closure"
77          , "-u PrelPack_unpackCString_closure"
78          , "-u PrelIOBase_stackOverflow_closure"
79          , "-u PrelIOBase_heapOverflow_closure"
80          , "-u PrelIOBase_NonTermination_closure"
81          , "-u PrelIOBase_PutFullMVar_closure"
82          , "-u PrelIOBase_BlockedOnDeadMVar_closure"
83          , "-u PrelWeak_runFinalizzerBatch_closure"
84          , "-u __init_Prelude"
85          , "-u __init_PrelMain"
86          ]
87         },
88
89         Package {
90         name           = "std",  -- The Prelude & Standard Hs_libraries
91         import_dirs    = if installing
92                             then [ clibdir ++ "/imports/std" ]
93                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std" ],
94         library_dirs   = if installing
95                             then [ clibdir ]
96                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std"
97                                  , ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
98         hs_libraries      = [ "HSstd" ],
99         extra_libraries   = [ "HSstd_cbits" ],
100         include_dirs   = if installing
101                             then []
102                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
103         c_includes     = [ "HsStd.h" ],
104         package_deps   = [ "rts" ],
105         extra_ghc_opts = [],
106         extra_cc_opts  = [],
107         extra_ld_opts  = [ "-lm" ]
108         },
109
110          Package { 
111          name           = "lang",
112          import_dirs    = if installing
113                              then [ clibdir ++ "/imports/lang" ]
114                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/lang"
115                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/lang/monads" ],
116          library_dirs   = if installing
117                              then [ clibdir ]
118                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/lang"
119                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/lang/cbits" ],
120          hs_libraries      = [ "HSlang" ],
121          extra_libraries   = [ "HSlang_cbits" ],
122          include_dirs   = if installing
123                              then []
124                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/lang/cbits" ],
125          c_includes     = [ "HsLang.h" ],
126          package_deps   = [],
127          extra_ghc_opts = [],
128          extra_cc_opts  = [],
129          extra_ld_opts  = []
130         },
131
132          Package {
133          name           = "concurrent",
134          import_dirs    = if installing
135                              then [ clibdir ++ "/imports/concurrent" ]
136                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent" ],
137          library_dirs   = if installing
138                              then [ clibdir ]
139                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent" ],
140          hs_libraries      = [ "HSconcurrent" ],
141          extra_libraries   = [],
142          include_dirs   = if installing
143                              then []
144                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent/cbits" ],
145          c_includes     = [ "HsConcurrent.h" ],
146          package_deps   = [ "lang" ],
147          extra_ghc_opts = [],
148          extra_cc_opts  = [],
149          extra_ld_opts  = []
150         },
151
152          Package {
153          name           = "data",
154          import_dirs    = if installing
155                              then [ clibdir ++ "/imports/data" ]
156                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data"
157                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison"
158                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Assoc"
159                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Coll"
160                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Seq" ],
161          library_dirs   = if installing
162                              then [clibdir ]
163                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data" ],
164          hs_libraries      = [ "HSdata" ],
165          extra_libraries   = [],
166          include_dirs   = if installing
167                              then []
168                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data/cbits" ],
169          c_includes     = [ "HsData.h" ],
170          package_deps   = [ "lang" ],
171          extra_ghc_opts = [],
172          extra_cc_opts  = [],
173          extra_ld_opts  = []
174         },
175
176          Package {
177          name           = "net",
178          import_dirs    = if installing
179                              then [ clibdir ++ "/imports/net" ]
180                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net" ],
181          library_dirs   = if installing
182                              then [ clibdir ]
183                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net"
184                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/net/cbits" ],
185          hs_libraries      = [ "HSnet" ],
186          extra_libraries   = [ "HSnet_cbits" ],
187          include_dirs   = if installing
188                              then []
189                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net/cbits" ],
190          c_includes     = [ "HsNet.h" ],
191          package_deps   = [ "lang", "text" ],
192          extra_ghc_opts = [],
193          extra_cc_opts  = [],
194          extra_ld_opts  = if postfixMatch "solaris2" cTARGETPLATFORM
195                              then [ "-lnsl",  "-lsocket" ]
196                              else []
197         },
198
199          Package {
200          name           = "posix",
201          import_dirs    = if installing
202                              then [ clibdir ++ "/imports/posix" ]
203                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix" ],
204          library_dirs   = if installing
205                              then [ clibdir ]
206                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix"
207                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/posix/cbits" ],
208          hs_libraries      = [ "HSposix" ],
209          extra_libraries   = [ "HSposix_cbits" ],
210          include_dirs   = if installing
211                              then []
212                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix/cbits" ],
213          c_includes     = [ "HsPosix.h" ],
214          package_deps   = [ "lang" ],
215          extra_ghc_opts = [],
216          extra_cc_opts  = [],
217          extra_ld_opts  = []
218         },
219
220          Package {
221          name           = "text",
222          import_dirs    = if installing
223                              then [ clibdir ++ "/imports/text" ]
224                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text" 
225                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/html" 
226                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/haxml/lib" 
227                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/parsec" ],
228          library_dirs   = if installing
229                              then [ clibdir ]
230                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text"
231                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/cbits" ],
232          hs_libraries      = [ "HStext" ],
233          extra_libraries   = [ "HStext_cbits" ],
234          include_dirs   = if installing
235                              then []
236                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text/cbits" ],
237          c_includes     = [ "HsText.h" ],
238          package_deps   = [ "lang", "data" ],
239          extra_ghc_opts = [],
240          extra_cc_opts  = [],
241          extra_ld_opts  = []
242         },
243
244          Package {
245          name           = "util",
246          import_dirs    = if installing
247                              then [ clibdir ++ "/imports/util" ]
248                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util"
249                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/util/check" ],
250          library_dirs   = if installing
251                              then [ clibdir ]
252                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util"
253                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
254          hs_libraries      = [ "HSutil" ],
255          extra_libraries   = [ "HSutil_cbits" ],
256          include_dirs   = if installing
257                              then []
258                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
259          c_includes     = [ "HsUtil.h" ],
260          package_deps   = [ "lang", "concurrent", "posix" ],
261          extra_ghc_opts = [],
262          extra_cc_opts  = [],
263          extra_ld_opts  = []
264         },
265
266         -- no cbits at the moment, we'll need to add one if this library
267         -- ever calls out to any C libs.
268          Package {
269          name           = "hssource",
270          import_dirs    = if installing
271                              then [ clibdir ++ "/imports/hssource" ]
272                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/hssource" ],
273          library_dirs   = if installing
274                              then [ clibdir ]
275                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/hssource" ],
276          hs_libraries      = [ "HShssource" ],
277          extra_libraries   = [],
278          include_dirs   = [],
279          c_includes     = [],
280          package_deps   = [ "text" ],
281          extra_ghc_opts = [],
282          extra_cc_opts  = [],
283          extra_ld_opts  = []
284         },
285
286          Package {
287          name         = "win32",
288          import_dirs    = if installing
289                              then [ clibdir ++ "/imports/win32" ]
290                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/win32/src" ],
291          library_dirs   = if installing
292                              then [ clibdir ]
293                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/win32/src" ],
294          hs_libraries      = [ "HSwin32" ],
295          extra_libraries   = [],
296          include_dirs   = [],
297          c_includes     = [],           -- ???
298          package_deps   = [ "lang" ],
299          extra_ghc_opts = [],
300          extra_cc_opts  = [],
301          extra_ld_opts  = [ "-luser32",  "-lgdi32" ]
302         },
303
304          Package {
305          name           = "com",
306          import_dirs    = if installing
307                              then [ clibdir ++ "/imports/com" ]
308                              else [ cFPTOOLS_TOP_ABS ++ "/hdirect/lib" ],
309          library_dirs   = if installing
310                              then [ clibdir ]
311                              else [ cFPTOOLS_TOP_ABS ++ "/hdirect/lib" ],
312          hs_libraries      = [ "HScom" ],
313          extra_libraries   = [],
314          include_dirs   = [],
315          c_includes     = [],           -- ???
316          package_deps   = [ "lang" ],
317          extra_ghc_opts = [],
318          extra_cc_opts  = [],
319          extra_ld_opts  = [ "-luser32",  "-lole32",  "-loleaut32", "-ladvapi32" ]
320         }
321    ]
322
323 ghc_src_dir :: String -> String
324 ghc_src_dir path = cFPTOOLS_TOP_ABS ++ '/':cCURRENT_DIR ++ '/':path
325
326 prefixMatch :: Eq a => [a] -> [a] -> Bool
327 prefixMatch [] _str = True
328 prefixMatch _pat [] = False
329 prefixMatch (p:ps) (s:ss) | p == s    = prefixMatch ps ss
330                           | otherwise = False
331
332 postfixMatch :: String -> String -> Bool
333 postfixMatch pat str = prefixMatch (reverse pat) (reverse str)