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