[project @ 2001-06-27 13:16:30 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
132         hs_libraries      = 
133 #                           ifndef mingw32_TARGET_OS
134                             [ "HSstd" ]
135 #                           else
136                             [ "HSstd1", "HSstd2" ]
137 #                           endif
138                             ,
139         extra_libraries   = [ "HSstd_cbits" ] ++
140 #                           ifdef mingw32_TARGET_OS
141                             [ "wsock32", "msvcrt" ]
142 #                           else
143                             [ "m" ]   -- libm, that is
144 #                           endif
145                             ,
146         include_dirs   = if installing
147                             then []
148                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
149         c_includes     = [ "HsStd.h" ],
150         package_deps   = [ "rts" ],
151         extra_ghc_opts = [],
152         extra_cc_opts  = [],
153         extra_ld_opts  = []
154         },
155
156          Package { 
157          name           = "lang",
158          import_dirs    = if installing
159                              then [ "$libdir/imports/lang" ]
160                              else [ "$libdir/hslibs/lang"
161                                   , "$libdir/hslibs/lang/monads" ],
162          source_dirs    = [],
163          library_dirs   = if installing
164                              then [ "$libdir" ]
165                              else [ "$libdir/hslibs/lang"
166                                   , "$libdir/hslibs/lang/cbits" ],
167          hs_libraries      = [ "HSlang" ],
168          extra_libraries   = [ "HSlang_cbits" ],
169          include_dirs   = if installing
170                              then []
171                              else [ "$libdir/hslibs/lang/cbits" ],
172          c_includes     = [ "HsLang.h" ],
173          package_deps   = [],
174          extra_ghc_opts = [],
175          extra_cc_opts  = [],
176          extra_ld_opts  = [
177 #ifndef LEADING_UNDERSCORE
178                           "-u Addr_Azh_static_info"
179 #else
180                           "-u _Addr_Azh_static_info"
181 #endif
182                         ]
183         },
184
185          Package {
186          name           = "concurrent",
187          import_dirs    = if installing
188                              then [ "$libdir/imports/concurrent" ]
189                              else [ "$libdir/hslibs/concurrent" ],
190          source_dirs    = [],
191          library_dirs   = if installing
192                              then [ "$libdir" ]
193                              else [ "$libdir/hslibs/concurrent" ],
194          hs_libraries      = [ "HSconcurrent" ],
195          extra_libraries   = [],
196          include_dirs   = if installing
197                              then []
198                              else [ "$libdir/hslibs/concurrent/cbits" ],
199          c_includes     = [],
200          package_deps   = [ "lang" ],
201          extra_ghc_opts = [],
202          extra_cc_opts  = [],
203          extra_ld_opts  = []
204         },
205
206          Package {
207          name           = "data",
208          import_dirs    = if installing
209                              then [ "$libdir/imports/data" ]
210                              else [ "$libdir/hslibs/data"
211                                   , "$libdir/hslibs/data/edison"
212                                   , "$libdir/hslibs/data/edison/Assoc"
213                                   , "$libdir/hslibs/data/edison/Coll"
214                                   , "$libdir/hslibs/data/edison/Seq" ],
215          source_dirs    = [],
216          library_dirs   = if installing
217                              then [ "$libdir" ]
218                              else [ "$libdir/hslibs/data" ],
219          hs_libraries      = [ "HSdata" ],
220          extra_libraries   = [],
221          include_dirs   = if installing
222                              then []
223                              else [ "$libdir/hslibs/data/cbits" ],
224          c_includes     = [],
225          package_deps   = [ "lang", "util" ],
226          extra_ghc_opts = [],
227          extra_cc_opts  = [],
228          extra_ld_opts  = []
229         },
230
231          Package {
232          name           = "net",
233          import_dirs    = if installing
234                              then [ "$libdir/imports/net" ]
235                              else [ "$libdir/hslibs/net" ],
236          source_dirs    = [],
237          library_dirs   = if installing
238                              then [ "$libdir" ]
239                              else [ "$libdir/hslibs/net"
240                                   , "$libdir/hslibs/net/cbits" ],
241          hs_libraries      = [ "HSnet" ],
242          extra_libraries   = if suffixMatch "solaris2" cTARGETPLATFORM
243                                 then [ "nsl",  "socket" ]
244                                 else []
245                              ,
246          include_dirs   = if installing
247                              then []
248                              else [ "$libdir/hslibs/net/cbits" ],
249          c_includes     = [ "HsNet.h" ],
250          package_deps   = [ "lang", "text", "concurrent" ],
251          extra_ghc_opts = [],
252          extra_cc_opts  = [],
253          extra_ld_opts  = []
254         },
255
256          Package {
257          name           = "posix",
258          import_dirs    = if installing
259                              then [ "$libdir/imports/posix" ]
260                              else [ "$libdir/hslibs/posix" ],
261          source_dirs    = [],
262          library_dirs   = if installing
263                              then [ "$libdir" ]
264                              else [ "$libdir/hslibs/posix"
265                                   , "$libdir/hslibs/posix/cbits" ],
266          hs_libraries      = [ "HSposix" ],
267          extra_libraries   = [ "HSposix_cbits" ],
268          include_dirs   = if installing
269                              then []
270                              else [ "$libdir/hslibs/posix/cbits" ],
271          c_includes     = [ "HsPosix.h" ],
272          package_deps   = [ "lang" ],
273          extra_ghc_opts = [],
274          extra_cc_opts  = [],
275          extra_ld_opts  = []
276         },
277
278          Package {
279          name           = "text",
280          import_dirs    = if installing
281                              then [ "$libdir/imports/text" ]
282                              else [ "$libdir/hslibs/text" 
283                                   , "$libdir/hslibs/text/html" 
284                                   , "$libdir/hslibs/text/HaXml/lib" 
285                                   , "$libdir/hslibs/text/parsec" ],
286          source_dirs    = [],
287          library_dirs   = if installing
288                              then [ "$libdir" ]
289                              else [ "$libdir/hslibs/text"
290                                   , "$libdir/hslibs/text/cbits" ],
291          hs_libraries      = [ "HStext" ],
292          extra_libraries   = [ "HStext_cbits" ],
293          include_dirs   = if installing
294                              then []
295                              else [ "$libdir/hslibs/text/cbits" ],
296          c_includes     = [ "HsText.h" ],
297          package_deps   = [ "lang" ],
298          extra_ghc_opts = [],
299          extra_cc_opts  = [],
300          extra_ld_opts  = []
301         },
302
303          Package {
304          name           = "util",
305          import_dirs    = if installing
306                              then [ "$libdir/imports/util" ]
307                              else [ "$libdir/hslibs/util"
308                                   , "$libdir/hslibs/util/check" ],
309          source_dirs    = [],
310          library_dirs   = if installing
311                              then [ "$libdir" ]
312                              else [ "$libdir/hslibs/util"
313                                   , "$libdir/hslibs/util/cbits" ],
314          hs_libraries      = [ "HSutil" ],
315          extra_libraries   = [ "HSutil_cbits" ] ++ words cLibsReadline,
316          include_dirs   = if installing
317                              then []
318                              else [ "$libdir/hslibs/util/cbits" ],
319          c_includes     = [ "HsUtil.h" ],
320          package_deps   = [ "lang", "concurrent"
321 #ifndef mingw32_TARGET_OS
322                             , "posix"
323 #endif
324                           ],
325          extra_ghc_opts = [],
326          extra_cc_opts  = [],
327          extra_ld_opts  = []
328         },
329
330         -- no cbits at the moment, we'll need to add one if this library
331         -- ever calls out to any C libs.
332          Package {
333          name           = "hssource",
334          import_dirs    = if installing
335                              then [ "$libdir/imports/hssource" ]
336                              else [ "$libdir/hslibs/hssource" ],
337          source_dirs    = [],
338          library_dirs   = if installing
339                              then [ "$libdir" ]
340                              else [ "$libdir/hslibs/hssource" ],
341          hs_libraries      = [ "HShssource" ],
342          extra_libraries   = [],
343          include_dirs   = [],
344          c_includes     = [],
345          package_deps   = [ "text" ],
346          extra_ghc_opts = [],
347          extra_cc_opts  = [],
348          extra_ld_opts  = []
349         },
350
351          Package {
352          name         = "greencard",
353          import_dirs    = if installing
354                              then [ "$libdir/imports/greencard" ]
355                              else [ "$libdir/green-card/lib/ghc" ],
356          source_dirs    = [],
357          library_dirs   = if installing
358                              then [ "$libdir" ]
359                              else [ "$libdir/green-card/lib/ghc" ],
360          hs_libraries      = [ "HSgreencard" ],
361          extra_libraries   = [],
362          include_dirs   = [],
363          c_includes     = [],
364          package_deps   = [ "lang" ],
365          extra_ghc_opts = [],
366          extra_cc_opts  = [],
367          extra_ld_opts  = [],
368         }
369
370 #if defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS)
371          ,Package {
372          name         = "win32",
373          import_dirs    = if installing
374                              then [ "$libdir/imports/win32" ]
375                              else [ "$libdir/hslibs/win32" ],
376          source_dirs    = [],
377          library_dirs   = if installing
378                              then [ "$libdir" ]
379                              else [ "$libdir/hslibs/win32" ],
380          hs_libraries      = [ "HSwin32" ],
381          extra_libraries   = [ "user32",  "gdi32", "winmm" ],
382          include_dirs   = [],
383          c_includes     = [],           -- ???
384          package_deps   = [ "lang", "greencard" ],
385          extra_ghc_opts = [],
386          extra_cc_opts  = [],
387          extra_ld_opts  = []
388         },
389
390          Package {
391          name           = "com",
392          import_dirs    = if installing
393                              then [ "$libdir/imports/com" ]
394                              else [ "$libdir/hdirect/lib" ],
395          source_dirs    = [],
396          library_dirs   = if installing
397                              then [ "$libdir" ]
398                              else [ "$libdir/hdirect/lib" ],
399          hs_libraries      = [ "HScom" ],
400          extra_libraries   = [ "user32",  "ole32",  "oleaut32", "advapi32" ],
401          include_dirs   = [],
402          c_includes     = [],           -- ???
403          package_deps   = [ "lang" ],
404          extra_ghc_opts = [],
405          extra_cc_opts  = [],
406          extra_ld_opts  = []
407         }
408 #endif
409
410          ,Package {
411          name           = "xlib",
412          import_dirs    = if installing
413                              then [ "$libdir/imports/xlib" ]
414                              else [ "$libdir/hslibs/xlib" ],
415          source_dirs    = [],
416          library_dirs   = if installing
417                              then [ "$libdir" ]
418                              else [ "$libdir/hslibs/xlib"
419                                   , "$libdir/hslibs/xlib/cbits" ],
420          hs_libraries      = [ "HSxlib" ],
421          extra_libraries   = [ "HSxlib_cbits", "X11" ],
422          include_dirs   = if installing
423                              then []
424                              else [ "$libdir/hslibs/xlib/cbits" ],
425          c_includes     = [ "HsXlib.h" ],
426          package_deps   = [ "greencard" ],
427          extra_ghc_opts = [],
428          extra_cc_opts  = [],
429          extra_ld_opts  = []
430         }
431
432    ]
433   where
434         ghc_src_dir :: String -> String
435         ghc_src_dir path = "$libdir/" ++ cCURRENT_DIR ++ '/':path