[project @ 2001-03-19 10:23:45 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 -> [PackageConfig]
22 package_details installing =
23  [
24         Package {
25         name           = "gmp",  -- GMP is at the bottom of the heap
26         import_dirs    = [],
27         source_dirs    = [],
28         library_dirs   = if cHaveLibGmp == "YES"
29                             then []
30                             else if installing
31                                     then [ clibdir ]
32                                     else [ ghc_src_dir cGHC_RUNTIME_DIR ++ "/gmp" ],
33         hs_libraries   = [],
34         extra_libraries = [ "gmp" ],
35         include_dirs   = [],
36         c_includes     = [],
37         package_deps   = [],
38         extra_ghc_opts = [],
39         extra_cc_opts  = [],
40         extra_ld_opts  = []
41         },
42
43         Package {
44         name           = "rts",  -- The RTS is just another package!
45         import_dirs    = [],
46         source_dirs    = [],
47         library_dirs   = if installing
48                             then [ clibdir ]
49                             else [ ghc_src_dir cGHC_RUNTIME_DIR ],
50         hs_libraries      = [ "HSrts" ],
51 #ifndef mingw32_TARGET_OS
52         extra_libraries   = [],
53 #else
54         extra_libraries   = [ "winmm" ], -- for the threadDelay timer
55 #endif
56         include_dirs   = if installing
57                             then [ clibdir ++ "/includes" ]
58                             else [ ghc_src_dir cGHC_INCLUDE_DIR ],
59         c_includes     = [ "Stg.h" ],           -- ha!
60         package_deps   = [ "gmp" ],
61         extra_ghc_opts = [],
62         extra_cc_opts  = [],
63                 -- the RTS forward-references to a bunch of stuff in the prelude,
64                 -- so we force it to be included with special options to ld.
65         extra_ld_opts  = map (
66 #ifndef LEADING_UNDERSCORE
67                           "-u "
68 #else
69                           "-u _"
70 #endif
71                           ++ ) [
72            "PrelBase_Izh_static_info"
73          , "PrelBase_Czh_static_info"
74          , "PrelFloat_Fzh_static_info"
75          , "PrelFloat_Dzh_static_info"
76          , "PrelPtr_Ptr_static_info"
77          , "PrelWord_Wzh_static_info"
78          , "PrelInt_I8zh_static_info"
79          , "PrelInt_I16zh_static_info"
80          , "PrelInt_I32zh_static_info"
81          , "PrelInt_I64zh_static_info"
82          , "PrelWord_W8zh_static_info"
83          , "PrelWord_W16zh_static_info"
84          , "PrelWord_W32zh_static_info"
85          , "PrelWord_W64zh_static_info"
86          , "PrelStable_StablePtr_static_info"
87          , "PrelBase_Izh_con_info"
88          , "PrelBase_Czh_con_info"
89          , "PrelFloat_Fzh_con_info"
90          , "PrelFloat_Dzh_con_info"
91          , "PrelPtr_Ptr_con_info"
92          , "PrelStable_StablePtr_con_info"
93          , "PrelBase_False_closure"
94          , "PrelBase_True_closure"
95          , "PrelPack_unpackCString_closure"
96          , "PrelIOBase_stackOverflow_closure"
97          , "PrelIOBase_heapOverflow_closure"
98          , "PrelIOBase_NonTermination_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         source_dirs    = [],
111         library_dirs   = if installing
112                             then [ clibdir ]
113                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std"
114                                  , ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
115         hs_libraries      = [ "HSstd" ],
116         extra_libraries   = [ "HSstd_cbits" ] ++
117 #                           ifdef mingw32_TARGET_OS
118                             ["wsock32", "msvcrt"]
119 #                           else
120                             ["m"]   -- libm, that is
121 #                           endif
122                             ,
123         include_dirs   = if installing
124                             then []
125                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
126         c_includes     = [ "HsStd.h" ],
127         package_deps   = [ "rts" ],
128         extra_ghc_opts = [],
129         extra_cc_opts  = [],
130         extra_ld_opts  = []
131         },
132
133          Package { 
134          name           = "lang",
135          import_dirs    = if installing
136                              then [ clibdir ++ "/imports/lang" ]
137                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/lang"
138                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/lang/monads" ],
139          source_dirs    = [],
140          library_dirs   = if installing
141                              then [ clibdir ]
142                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/lang"
143                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/lang/cbits" ],
144          hs_libraries      = [ "HSlang" ],
145          extra_libraries   = [ "HSlang_cbits" ],
146          include_dirs   = if installing
147                              then []
148                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/lang/cbits" ],
149          c_includes     = [ "HsLang.h" ],
150          package_deps   = [],
151          extra_ghc_opts = [],
152          extra_cc_opts  = [],
153          extra_ld_opts  = [
154 #ifndef LEADING_UNDERSCORE
155                           "-u Addr_Azh_static_info"
156 #else
157                           "-u _Addr_Azh_static_info"
158 #endif
159                         ]
160         },
161
162          Package {
163          name           = "concurrent",
164          import_dirs    = if installing
165                              then [ clibdir ++ "/imports/concurrent" ]
166                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent" ],
167          source_dirs    = [],
168          library_dirs   = if installing
169                              then [ clibdir ]
170                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent" ],
171          hs_libraries      = [ "HSconcurrent" ],
172          extra_libraries   = [],
173          include_dirs   = if installing
174                              then []
175                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent/cbits" ],
176          c_includes     = [],
177          package_deps   = [ "lang" ],
178          extra_ghc_opts = [],
179          extra_cc_opts  = [],
180          extra_ld_opts  = []
181         },
182
183          Package {
184          name           = "data",
185          import_dirs    = if installing
186                              then [ clibdir ++ "/imports/data" ]
187                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data"
188                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison"
189                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Assoc"
190                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Coll"
191                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Seq" ],
192          source_dirs    = [],
193          library_dirs   = if installing
194                              then [clibdir ]
195                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data" ],
196          hs_libraries      = [ "HSdata" ],
197          extra_libraries   = [],
198          include_dirs   = if installing
199                              then []
200                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data/cbits" ],
201          c_includes     = [],
202          package_deps   = [ "lang", "util" ],
203          extra_ghc_opts = [],
204          extra_cc_opts  = [],
205          extra_ld_opts  = []
206         },
207
208          Package {
209          name           = "net",
210          import_dirs    = if installing
211                              then [ clibdir ++ "/imports/net" ]
212                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net" ],
213          source_dirs    = [],
214          library_dirs   = if installing
215                              then [ clibdir ]
216                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net"
217                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/net/cbits" ],
218          hs_libraries      = [ "HSnet" ],
219          extra_libraries   = [ "HSnet_cbits" ] 
220                              ++ if suffixMatch "solaris2" cTARGETPLATFORM
221                                 then [ "nsl",  "socket" ]
222                                 else []
223                              ,
224          include_dirs   = if installing
225                              then []
226                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net/cbits" ],
227          c_includes     = [ "HsNet.h" ],
228          package_deps   = [ "lang", "text", "concurrent" ],
229          extra_ghc_opts = [],
230          extra_cc_opts  = [],
231          extra_ld_opts  = []
232         },
233
234          Package {
235          name           = "posix",
236          import_dirs    = if installing
237                              then [ clibdir ++ "/imports/posix" ]
238                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix" ],
239          source_dirs    = [],
240          library_dirs   = if installing
241                              then [ clibdir ]
242                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix"
243                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/posix/cbits" ],
244          hs_libraries      = [ "HSposix" ],
245          extra_libraries   = [ "HSposix_cbits" ],
246          include_dirs   = if installing
247                              then []
248                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix/cbits" ],
249          c_includes     = [ "HsPosix.h" ],
250          package_deps   = [ "lang" ],
251          extra_ghc_opts = [],
252          extra_cc_opts  = [],
253          extra_ld_opts  = []
254         },
255
256          Package {
257          name           = "text",
258          import_dirs    = if installing
259                              then [ clibdir ++ "/imports/text" ]
260                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text" 
261                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/html" 
262                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/HaXml/lib" 
263                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/parsec" ],
264          source_dirs    = [],
265          library_dirs   = if installing
266                              then [ clibdir ]
267                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text"
268                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/cbits" ],
269          hs_libraries      = [ "HStext" ],
270          extra_libraries   = [ "HStext_cbits" ],
271          include_dirs   = if installing
272                              then []
273                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text/cbits" ],
274          c_includes     = [ "HsText.h" ],
275          package_deps   = [ "lang" ],
276          extra_ghc_opts = [],
277          extra_cc_opts  = [],
278          extra_ld_opts  = []
279         },
280
281          Package {
282          name           = "util",
283          import_dirs    = if installing
284                              then [ clibdir ++ "/imports/util" ]
285                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util"
286                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/util/check" ],
287          source_dirs    = [],
288          library_dirs   = if installing
289                              then [ clibdir ]
290                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util"
291                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
292          hs_libraries      = [ "HSutil" ],
293          extra_libraries   = [ "HSutil_cbits" ],
294          include_dirs   = if installing
295                              then []
296                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
297          c_includes     = [ "HsUtil.h" ],
298          package_deps   = [ "lang", "concurrent"
299 #ifndef mingw32_TARGET_OS
300                             , "posix"
301 #endif
302                           ],
303          extra_ghc_opts = [],
304          extra_cc_opts  = [],
305          extra_ld_opts  = words cLibsReadline
306         },
307
308         -- no cbits at the moment, we'll need to add one if this library
309         -- ever calls out to any C libs.
310          Package {
311          name           = "hssource",
312          import_dirs    = if installing
313                              then [ clibdir ++ "/imports/hssource" ]
314                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/hssource" ],
315          source_dirs    = [],
316          library_dirs   = if installing
317                              then [ clibdir ]
318                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/hssource" ],
319          hs_libraries      = [ "HShssource" ],
320          extra_libraries   = [],
321          include_dirs   = [],
322          c_includes     = [],
323          package_deps   = [ "text" ],
324          extra_ghc_opts = [],
325          extra_cc_opts  = [],
326          extra_ld_opts  = []
327         },
328
329          Package {
330          name         = "greencard",
331          import_dirs    = if installing
332                              then [ clibdir ++ "/imports/greencard" ]
333                              else [ cFPTOOLS_TOP_ABS ++ "/green-card/lib/ghc" ],
334          source_dirs    = [],
335          library_dirs   = if installing
336                              then [ clibdir ]
337                              else [ cFPTOOLS_TOP_ABS ++ "/green-card/lib/ghc" ],
338          hs_libraries      = [ "HSgreencard" ],
339          extra_libraries   = [],
340          include_dirs   = [],
341          c_includes     = [],
342          package_deps   = [ "lang" ],
343          extra_ghc_opts = [],
344          extra_cc_opts  = [],
345          extra_ld_opts  = [],
346         },
347
348          Package {
349          name         = "win32",
350          import_dirs    = if installing
351                              then [ clibdir ++ "/imports/win32" ]
352                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/win32" ],
353          source_dirs    = [],
354          library_dirs   = if installing
355                              then [ clibdir ]
356                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/win32" ],
357          hs_libraries      = [ "HSwin32" ],
358          extra_libraries   = [ "user32",  "gdi32", "winmm" ],
359          include_dirs   = [],
360          c_includes     = [],           -- ???
361          package_deps   = [ "lang", "greencard" ],
362          extra_ghc_opts = [],
363          extra_cc_opts  = [],
364          extra_ld_opts  = []
365         },
366
367          Package {
368          name           = "com",
369          import_dirs    = if installing
370                              then [ clibdir ++ "/imports/com" ]
371                              else [ cFPTOOLS_TOP_ABS ++ "/hdirect/lib" ],
372          source_dirs    = [],
373          library_dirs   = if installing
374                              then [ clibdir ]
375                              else [ cFPTOOLS_TOP_ABS ++ "/hdirect/lib" ],
376          hs_libraries      = [ "HScom" ],
377          extra_libraries   = [ "user32",  "ole32",  "oleaut32", "advapi32" ],
378          include_dirs   = [],
379          c_includes     = [],           -- ???
380          package_deps   = [ "lang" ],
381          extra_ghc_opts = [],
382          extra_cc_opts  = [],
383          extra_ld_opts  = []
384         }
385    ]
386
387 ghc_src_dir :: String -> String
388 ghc_src_dir path = cFPTOOLS_TOP_ABS ++ '/':cCURRENT_DIR ++ '/':path