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