[project @ 2001-01-30 10:56:55 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 -> [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 #ifndef LEADING_UNDERSCORE
148                           "-u Addr_Azh_static_info"
149 #else
150                           "-u _Addr_Azh_static_info"
151 #endif
152                         ]
153         },
154
155          Package {
156          name           = "concurrent",
157          import_dirs    = if installing
158                              then [ clibdir ++ "/imports/concurrent" ]
159                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent" ],
160          library_dirs   = if installing
161                              then [ clibdir ]
162                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent" ],
163          hs_libraries      = [ "HSconcurrent" ],
164          extra_libraries   = [],
165          include_dirs   = if installing
166                              then []
167                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent/cbits" ],
168          c_includes     = [],
169          package_deps   = [ "lang" ],
170          extra_ghc_opts = [],
171          extra_cc_opts  = [],
172          extra_ld_opts  = []
173         },
174
175          Package {
176          name           = "data",
177          import_dirs    = if installing
178                              then [ clibdir ++ "/imports/data" ]
179                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data"
180                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison"
181                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Assoc"
182                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Coll"
183                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Seq" ],
184          library_dirs   = if installing
185                              then [clibdir ]
186                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data" ],
187          hs_libraries      = [ "HSdata" ],
188          extra_libraries   = [],
189          include_dirs   = if installing
190                              then []
191                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data/cbits" ],
192          c_includes     = [],
193          package_deps   = [ "lang" ],
194          extra_ghc_opts = [],
195          extra_cc_opts  = [],
196          extra_ld_opts  = []
197         },
198
199          Package {
200          name           = "net",
201          import_dirs    = if installing
202                              then [ clibdir ++ "/imports/net" ]
203                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net" ],
204          library_dirs   = if installing
205                              then [ clibdir ]
206                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net"
207                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/net/cbits" ],
208          hs_libraries      = [ "HSnet" ],
209          extra_libraries   = [ "HSnet_cbits" ],
210          include_dirs   = if installing
211                              then []
212                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net/cbits" ],
213          c_includes     = [ "HsNet.h" ],
214          package_deps   = [ "lang", "text" ],
215          extra_ghc_opts = [],
216          extra_cc_opts  = [],
217          extra_ld_opts  = if suffixMatch "solaris2" cTARGETPLATFORM
218                              then [ "-lnsl",  "-lsocket" ]
219                              else []
220         },
221
222          Package {
223          name           = "posix",
224          import_dirs    = if installing
225                              then [ clibdir ++ "/imports/posix" ]
226                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix" ],
227          library_dirs   = if installing
228                              then [ clibdir ]
229                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix"
230                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/posix/cbits" ],
231          hs_libraries      = [ "HSposix" ],
232          extra_libraries   = [ "HSposix_cbits" ],
233          include_dirs   = if installing
234                              then []
235                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix/cbits" ],
236          c_includes     = [ "HsPosix.h" ],
237          package_deps   = [ "lang" ],
238          extra_ghc_opts = [],
239          extra_cc_opts  = [],
240          extra_ld_opts  = []
241         },
242
243          Package {
244          name           = "text",
245          import_dirs    = if installing
246                              then [ clibdir ++ "/imports/text" ]
247                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text" 
248                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/html" 
249                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/HaXml/lib" 
250                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/parsec" ],
251          library_dirs   = if installing
252                              then [ clibdir ]
253                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text"
254                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/cbits" ],
255          hs_libraries      = [ "HStext" ],
256          extra_libraries   = [ "HStext_cbits" ],
257          include_dirs   = if installing
258                              then []
259                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text/cbits" ],
260          c_includes     = [ "HsText.h" ],
261          package_deps   = [ "lang", "data" ],
262          extra_ghc_opts = [],
263          extra_cc_opts  = [],
264          extra_ld_opts  = []
265         },
266
267          Package {
268          name           = "util",
269          import_dirs    = if installing
270                              then [ clibdir ++ "/imports/util" ]
271                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util"
272                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/util/check" ],
273          library_dirs   = if installing
274                              then [ clibdir ]
275                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util"
276                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
277          hs_libraries      = [ "HSutil" ],
278          extra_libraries   = [ "HSutil_cbits" ],
279          include_dirs   = if installing
280                              then []
281                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
282          c_includes     = [ "HsUtil.h" ],
283          package_deps   = [ "lang", "concurrent"
284 #ifndef mingw32_TARGET_OS
285                             , "posix"
286 #endif
287                           ],
288          extra_ghc_opts = [],
289          extra_cc_opts  = [],
290          extra_ld_opts  = words cLibsReadline
291         },
292
293         -- no cbits at the moment, we'll need to add one if this library
294         -- ever calls out to any C libs.
295          Package {
296          name           = "hssource",
297          import_dirs    = if installing
298                              then [ clibdir ++ "/imports/hssource" ]
299                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/hssource" ],
300          library_dirs   = if installing
301                              then [ clibdir ]
302                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/hssource" ],
303          hs_libraries      = [ "HShssource" ],
304          extra_libraries   = [],
305          include_dirs   = [],
306          c_includes     = [],
307          package_deps   = [ "text" ],
308          extra_ghc_opts = [],
309          extra_cc_opts  = [],
310          extra_ld_opts  = []
311         },
312
313          Package {
314          name         = "greencard",
315          import_dirs    = if installing
316                              then [ clibdir ++ "/imports/greencard" ]
317                              else [ cFPTOOLS_TOP_ABS ++ "/green-card/lib/ghc" ],
318          library_dirs   = if installing
319                              then [ clibdir ]
320                              else [ cFPTOOLS_TOP_ABS ++ "/green-card/lib/ghc" ],
321          hs_libraries      = [ "HSgreencard" ],
322          extra_libraries   = [],
323          include_dirs   = [],
324          c_includes     = [],
325          package_deps   = [ "lang" ],
326          extra_ghc_opts = [],
327          extra_cc_opts  = [],
328          extra_ld_opts  = [],
329         },
330
331          Package {
332          name         = "win32",
333          import_dirs    = if installing
334                              then [ clibdir ++ "/imports/win32" ]
335                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/win32" ],
336          library_dirs   = if installing
337                              then [ clibdir ]
338                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/win32" ],
339          hs_libraries      = [ "HSwin32" ],
340          extra_libraries   = [],
341          include_dirs   = [],
342          c_includes     = [],           -- ???
343          package_deps   = [ "lang", "greencard" ],
344          extra_ghc_opts = [],
345          extra_cc_opts  = [],
346          extra_ld_opts  = [ "-luser32",  "-lgdi32", "-lwinmm" ]
347         },
348
349          Package {
350          name           = "com",
351          import_dirs    = if installing
352                              then [ clibdir ++ "/imports/com" ]
353                              else [ cFPTOOLS_TOP_ABS ++ "/hdirect/lib" ],
354          library_dirs   = if installing
355                              then [ clibdir ]
356                              else [ cFPTOOLS_TOP_ABS ++ "/hdirect/lib" ],
357          hs_libraries      = [ "HScom" ],
358          extra_libraries   = [],
359          include_dirs   = [],
360          c_includes     = [],           -- ???
361          package_deps   = [ "lang" ],
362          extra_ghc_opts = [],
363          extra_cc_opts  = [],
364          extra_ld_opts  = [ "-luser32",  "-lole32",  "-loleaut32", "-ladvapi32" ]
365         }
366    ]
367
368 ghc_src_dir :: String -> String
369 ghc_src_dir path = cFPTOOLS_TOP_ABS ++ '/':cCURRENT_DIR ++ '/':path