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