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