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