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