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