[project @ 2001-05-01 09:26:10 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   = if suffixMatch "solaris2" cTARGETPLATFORM
230                                 then [ "nsl",  "socket" ]
231                                 else []
232                              ,
233          include_dirs   = if installing
234                              then []
235                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net/cbits" ],
236          c_includes     = [ "HsNet.h" ],
237          package_deps   = [ "lang", "text", "concurrent" ],
238          extra_ghc_opts = [],
239          extra_cc_opts  = [],
240          extra_ld_opts  = []
241         },
242
243          Package {
244          name           = "posix",
245          import_dirs    = if installing
246                              then [ clibdir ++ "/imports/posix" ]
247                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix" ],
248          source_dirs    = [],
249          library_dirs   = if installing
250                              then [ clibdir ]
251                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix"
252                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/posix/cbits" ],
253          hs_libraries      = [ "HSposix" ],
254          extra_libraries   = [ "HSposix_cbits" ],
255          include_dirs   = if installing
256                              then []
257                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix/cbits" ],
258          c_includes     = [ "HsPosix.h" ],
259          package_deps   = [ "lang" ],
260          extra_ghc_opts = [],
261          extra_cc_opts  = [],
262          extra_ld_opts  = []
263         },
264
265          Package {
266          name           = "text",
267          import_dirs    = if installing
268                              then [ clibdir ++ "/imports/text" ]
269                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text" 
270                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/html" 
271                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/HaXml/lib" 
272                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/parsec" ],
273          source_dirs    = [],
274          library_dirs   = if installing
275                              then [ clibdir ]
276                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text"
277                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/cbits" ],
278          hs_libraries      = [ "HStext" ],
279          extra_libraries   = [ "HStext_cbits" ],
280          include_dirs   = if installing
281                              then []
282                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text/cbits" ],
283          c_includes     = [ "HsText.h" ],
284          package_deps   = [ "lang" ],
285          extra_ghc_opts = [],
286          extra_cc_opts  = [],
287          extra_ld_opts  = []
288         },
289
290          Package {
291          name           = "util",
292          import_dirs    = if installing
293                              then [ clibdir ++ "/imports/util" ]
294                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util"
295                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/util/check" ],
296          source_dirs    = [],
297          library_dirs   = if installing
298                              then [ clibdir ]
299                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util"
300                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
301          hs_libraries      = [ "HSutil" ],
302          extra_libraries   = [ "HSutil_cbits" ] ++ words cLibsReadline,
303          include_dirs   = if installing
304                              then []
305                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
306          c_includes     = [ "HsUtil.h" ],
307          package_deps   = [ "lang", "concurrent"
308 #ifndef mingw32_TARGET_OS
309                             , "posix"
310 #endif
311                           ],
312          extra_ghc_opts = [],
313          extra_cc_opts  = [],
314          extra_ld_opts  = []
315         },
316
317         -- no cbits at the moment, we'll need to add one if this library
318         -- ever calls out to any C libs.
319          Package {
320          name           = "hssource",
321          import_dirs    = if installing
322                              then [ clibdir ++ "/imports/hssource" ]
323                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/hssource" ],
324          source_dirs    = [],
325          library_dirs   = if installing
326                              then [ clibdir ]
327                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/hssource" ],
328          hs_libraries      = [ "HShssource" ],
329          extra_libraries   = [],
330          include_dirs   = [],
331          c_includes     = [],
332          package_deps   = [ "text" ],
333          extra_ghc_opts = [],
334          extra_cc_opts  = [],
335          extra_ld_opts  = []
336         },
337
338          Package {
339          name         = "greencard",
340          import_dirs    = if installing
341                              then [ clibdir ++ "/imports/greencard" ]
342                              else [ cFPTOOLS_TOP_ABS ++ "/green-card/lib/ghc" ],
343          source_dirs    = [],
344          library_dirs   = if installing
345                              then [ clibdir ]
346                              else [ cFPTOOLS_TOP_ABS ++ "/green-card/lib/ghc" ],
347          hs_libraries      = [ "HSgreencard" ],
348          extra_libraries   = [],
349          include_dirs   = [],
350          c_includes     = [],
351          package_deps   = [ "lang" ],
352          extra_ghc_opts = [],
353          extra_cc_opts  = [],
354          extra_ld_opts  = [],
355         }
356
357 #if defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS)
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 #endif
396    ]
397   where
398         ghc_src_dir :: String -> String
399         ghc_src_dir path = cFPTOOLS_TOP_ABS ++ '/':cCURRENT_DIR ++ '/':path