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