[project @ 2001-01-11 17:25:56 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          , "PrelWord_Wzh_static_info"
72          , "PrelInt_I8zh_static_info"
73          , "PrelInt_I16zh_static_info"
74          , "PrelInt_I32zh_static_info"
75          , "PrelInt_I64zh_static_info"
76          , "PrelWord_W8zh_static_info"
77          , "PrelWord_W16zh_static_info"
78          , "PrelWord_W32zh_static_info"
79          , "PrelWord_W64zh_static_info"
80          , "PrelStable_StablePtr_static_info"
81          , "PrelBase_Izh_con_info"
82          , "PrelBase_Czh_con_info"
83          , "PrelFloat_Fzh_con_info"
84          , "PrelFloat_Dzh_con_info"
85          , "PrelAddr_Azh_con_info"
86          , "PrelAddr_Wzh_con_info"
87          , "PrelAddr_I64zh_con_info"
88          , "PrelAddr_W64zh_con_info"
89          , "PrelStable_StablePtr_con_info"
90          , "PrelBase_False_closure"
91          , "PrelBase_True_closure"
92          , "PrelPack_unpackCString_closure"
93          , "PrelIOBase_stackOverflow_closure"
94          , "PrelIOBase_heapOverflow_closure"
95          , "PrelIOBase_NonTermination_closure"
96          , "PrelIOBase_PutFullMVar_closure"
97          , "PrelIOBase_BlockedOnDeadMVar_closure"
98          , "PrelWeak_runFinalizzerBatch_closure"
99          , "__init_Prelude"
100          ]
101         },
102
103         Package {
104         name           = "std",  -- The Prelude & Standard Hs_libraries
105         import_dirs    = if installing
106                             then [ clibdir ++ "/imports/std" ]
107                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std" ],
108         library_dirs   = if installing
109                             then [ clibdir ]
110                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std"
111                                  , ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
112         hs_libraries      = [ "HSstd" ],
113         extra_libraries   = [ "HSstd_cbits" ],
114         include_dirs   = if installing
115                             then []
116                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
117         c_includes     = [ "HsStd.h" ],
118         package_deps   = [ "rts" ],
119         extra_ghc_opts = [],
120         extra_cc_opts  = [],
121         extra_ld_opts  = [
122 #ifdef mingw32_TARGET_OS
123                            "-lwsock32"
124 #else
125                            "-lm"
126 #endif
127                          ]
128         },
129
130          Package { 
131          name           = "lang",
132          import_dirs    = if installing
133                              then [ clibdir ++ "/imports/lang" ]
134                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/lang"
135                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/lang/monads" ],
136          library_dirs   = if installing
137                              then [ clibdir ]
138                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/lang"
139                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/lang/cbits" ],
140          hs_libraries      = [ "HSlang" ],
141          extra_libraries   = [ "HSlang_cbits" ],
142          include_dirs   = if installing
143                              then []
144                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/lang/cbits" ],
145          c_includes     = [ "HsLang.h" ],
146          package_deps   = [],
147          extra_ghc_opts = [],
148          extra_cc_opts  = [],
149          extra_ld_opts  = []
150         },
151
152          Package {
153          name           = "concurrent",
154          import_dirs    = if installing
155                              then [ clibdir ++ "/imports/concurrent" ]
156                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent" ],
157          library_dirs   = if installing
158                              then [ clibdir ]
159                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent" ],
160          hs_libraries      = [ "HSconcurrent" ],
161          extra_libraries   = [],
162          include_dirs   = if installing
163                              then []
164                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent/cbits" ],
165          c_includes     = [],
166          package_deps   = [ "lang" ],
167          extra_ghc_opts = [],
168          extra_cc_opts  = [],
169          extra_ld_opts  = []
170         },
171
172          Package {
173          name           = "data",
174          import_dirs    = if installing
175                              then [ clibdir ++ "/imports/data" ]
176                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data"
177                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison"
178                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Assoc"
179                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Coll"
180                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Seq" ],
181          library_dirs   = if installing
182                              then [clibdir ]
183                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data" ],
184          hs_libraries      = [ "HSdata" ],
185          extra_libraries   = [],
186          include_dirs   = if installing
187                              then []
188                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data/cbits" ],
189          c_includes     = [],
190          package_deps   = [ "lang" ],
191          extra_ghc_opts = [],
192          extra_cc_opts  = [],
193          extra_ld_opts  = []
194         },
195
196          Package {
197          name           = "net",
198          import_dirs    = if installing
199                              then [ clibdir ++ "/imports/net" ]
200                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net" ],
201          library_dirs   = if installing
202                              then [ clibdir ]
203                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net"
204                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/net/cbits" ],
205          hs_libraries      = [ "HSnet" ],
206          extra_libraries   = [ "HSnet_cbits" ],
207          include_dirs   = if installing
208                              then []
209                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net/cbits" ],
210          c_includes     = [ "HsNet.h" ],
211          package_deps   = [ "lang", "text" ],
212          extra_ghc_opts = [],
213          extra_cc_opts  = [],
214          extra_ld_opts  = if suffixMatch "solaris2" cTARGETPLATFORM
215                              then [ "-lnsl",  "-lsocket" ]
216                              else []
217         },
218
219          Package {
220          name           = "posix",
221          import_dirs    = if installing
222                              then [ clibdir ++ "/imports/posix" ]
223                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix" ],
224          library_dirs   = if installing
225                              then [ clibdir ]
226                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix"
227                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/posix/cbits" ],
228          hs_libraries      = [ "HSposix" ],
229          extra_libraries   = [ "HSposix_cbits" ],
230          include_dirs   = if installing
231                              then []
232                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix/cbits" ],
233          c_includes     = [ "HsPosix.h" ],
234          package_deps   = [ "lang" ],
235          extra_ghc_opts = [],
236          extra_cc_opts  = [],
237          extra_ld_opts  = []
238         },
239
240          Package {
241          name           = "text",
242          import_dirs    = if installing
243                              then [ clibdir ++ "/imports/text" ]
244                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text" 
245                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/html" 
246                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/HaXml/lib" 
247                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/parsec" ],
248          library_dirs   = if installing
249                              then [ clibdir ]
250                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text"
251                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/cbits" ],
252          hs_libraries      = [ "HStext" ],
253          extra_libraries   = [ "HStext_cbits" ],
254          include_dirs   = if installing
255                              then []
256                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text/cbits" ],
257          c_includes     = [ "HsText.h" ],
258          package_deps   = [ "lang", "data" ],
259          extra_ghc_opts = [],
260          extra_cc_opts  = [],
261          extra_ld_opts  = []
262         },
263
264          Package {
265          name           = "util",
266          import_dirs    = if installing
267                              then [ clibdir ++ "/imports/util" ]
268                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util"
269                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/util/check" ],
270          library_dirs   = if installing
271                              then [ clibdir ]
272                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util"
273                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
274          hs_libraries      = [ "HSutil" ],
275          extra_libraries   = [ "HSutil_cbits" ],
276          include_dirs   = if installing
277                              then []
278                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
279          c_includes     = [ "HsUtil.h" ],
280          package_deps   = [ "lang", "concurrent"
281 #ifndef mingw32_TARGET_OS
282                             , "posix"
283 #endif
284                           ],
285          extra_ghc_opts = [],
286          extra_cc_opts  = [],
287          extra_ld_opts  = words cLibsReadline
288         },
289
290         -- no cbits at the moment, we'll need to add one if this library
291         -- ever calls out to any C libs.
292          Package {
293          name           = "hssource",
294          import_dirs    = if installing
295                              then [ clibdir ++ "/imports/hssource" ]
296                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/hssource" ],
297          library_dirs   = if installing
298                              then [ clibdir ]
299                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/hssource" ],
300          hs_libraries      = [ "HShssource" ],
301          extra_libraries   = [],
302          include_dirs   = [],
303          c_includes     = [],
304          package_deps   = [ "text" ],
305          extra_ghc_opts = [],
306          extra_cc_opts  = [],
307          extra_ld_opts  = []
308         },
309
310          Package {
311          name         = "greencard",
312          import_dirs    = if installing
313                              then [ clibdir ++ "/imports/greencard" ]
314                              else [ cFPTOOLS_TOP_ABS ++ "/green-card/lib/ghc" ],
315          library_dirs   = if installing
316                              then [ clibdir ]
317                              else [ cFPTOOLS_TOP_ABS ++ "/green-card/lib/ghc" ],
318          hs_libraries      = [ "HSgreencard" ],
319          extra_libraries   = [],
320          include_dirs   = [],
321          c_includes     = [],
322          package_deps   = [ "lang" ],
323          extra_ghc_opts = [],
324          extra_cc_opts  = [],
325          extra_ld_opts  = [],
326         },
327
328          Package {
329          name         = "win32",
330          import_dirs    = if installing
331                              then [ clibdir ++ "/imports/win32" ]
332                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/win32" ],
333          library_dirs   = if installing
334                              then [ clibdir ]
335                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/win32" ],
336          hs_libraries      = [ "HSwin32" ],
337          extra_libraries   = [],
338          include_dirs   = [],
339          c_includes     = [],           -- ???
340          package_deps   = [ "lang", "greencard" ],
341          extra_ghc_opts = [],
342          extra_cc_opts  = [],
343          extra_ld_opts  = [ "-luser32",  "-lgdi32", "-lwinmm" ]
344         },
345
346          Package {
347          name           = "com",
348          import_dirs    = if installing
349                              then [ clibdir ++ "/imports/com" ]
350                              else [ cFPTOOLS_TOP_ABS ++ "/hdirect/lib" ],
351          library_dirs   = if installing
352                              then [ clibdir ]
353                              else [ cFPTOOLS_TOP_ABS ++ "/hdirect/lib" ],
354          hs_libraries      = [ "HScom" ],
355          extra_libraries   = [],
356          include_dirs   = [],
357          c_includes     = [],           -- ???
358          package_deps   = [ "lang" ],
359          extra_ghc_opts = [],
360          extra_cc_opts  = [],
361          extra_ld_opts  = [ "-luser32",  "-lole32",  "-loleaut32", "-ladvapi32" ]
362         }
363    ]
364
365 ghc_src_dir :: String -> String
366 ghc_src_dir path = cFPTOOLS_TOP_ABS ++ '/':cCURRENT_DIR ++ '/':path