[project @ 2001-07-22 03:19:51 by chak]
[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/include"
74 #ifdef mingw32_TARGET_OS
75                                  , "$libdir/include/mingw"
76 #endif
77                                  ]
78                             else [ ghc_src_dir cGHC_INCLUDE_DIR ],
79         c_includes     = [ "Stg.h" ],           -- ha!
80         package_deps   = [ "gmp" ],
81         extra_ghc_opts = [],
82         extra_cc_opts  = [],
83                 -- the RTS forward-references to a bunch of stuff in the prelude,
84                 -- so we force it to be included with special options to ld.
85         extra_ld_opts  =
86            foldr (\ x xs -> "-u" : x : xs) []
87                  (map (
88 #ifndef LEADING_UNDERSCORE
89                           ""
90 #else
91                           "_"
92 #endif
93                           ++ ) [
94            "PrelBase_Izh_static_info"
95          , "PrelBase_Czh_static_info"
96          , "PrelFloat_Fzh_static_info"
97          , "PrelFloat_Dzh_static_info"
98          , "PrelPtr_Ptr_static_info"
99          , "PrelWord_Wzh_static_info"
100          , "PrelInt_I8zh_static_info"
101          , "PrelInt_I16zh_static_info"
102          , "PrelInt_I32zh_static_info"
103          , "PrelInt_I64zh_static_info"
104          , "PrelWord_W8zh_static_info"
105          , "PrelWord_W16zh_static_info"
106          , "PrelWord_W32zh_static_info"
107          , "PrelWord_W64zh_static_info"
108          , "PrelStable_StablePtr_static_info"
109          , "PrelBase_Izh_con_info"
110          , "PrelBase_Czh_con_info"
111          , "PrelFloat_Fzh_con_info"
112          , "PrelFloat_Dzh_con_info"
113          , "PrelPtr_Ptr_con_info"
114          , "PrelStable_StablePtr_con_info"
115          , "PrelBase_False_closure"
116          , "PrelBase_True_closure"
117          , "PrelPack_unpackCString_closure"
118          , "PrelIOBase_stackOverflow_closure"
119          , "PrelIOBase_heapOverflow_closure"
120          , "PrelIOBase_NonTermination_closure"
121          , "PrelIOBase_BlockedOnDeadMVar_closure"
122          , "PrelWeak_runFinalizzerBatch_closure"
123          , "__init_Prelude"
124          ])
125         },
126
127         Package {
128         name           = "std",  -- The Prelude & Standard Hs_libraries
129         import_dirs    = if installing
130                             then [ "$libdir/imports/std" ]
131                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std" ],
132         source_dirs    = [],
133         library_dirs   = if installing
134                             then [ "$libdir" ]
135                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std"
136                                  , ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
137
138         hs_libraries      = 
139 #                           ifndef mingw32_TARGET_OS
140                             [ "HSstd" ]
141 #                           else
142                             -- This splitting is the subject of a totally 
143                             -- horrible hack, which glues HSstd1 and HSstd2 
144                             -- back into HSstd for the purposes of static linking.
145                             -- See DriverState.getPackageLibraries for details.
146                             [ "HSstd1", "HSstd2" ]
147 #                           endif
148                             ,
149         extra_libraries   = [ "HSstd_cbits" ] ++
150 #                           ifdef mingw32_TARGET_OS
151                             [ "wsock32", "msvcrt" ]
152 #                           else
153                             [ "m" ]   -- libm, that is
154 #                           endif
155                             ,
156         include_dirs   = if installing
157                             then []
158                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
159         c_includes     = [ "HsStd.h" ],
160         package_deps   = [ "rts" ],
161         extra_ghc_opts = [],
162         extra_cc_opts  = [],
163         extra_ld_opts  = []
164         },
165
166          Package { 
167          name           = "lang",
168          import_dirs    = if installing
169                              then [ "$libdir/imports/lang" ]
170                              else [ "$libdir/hslibs/lang"
171                                   , "$libdir/hslibs/lang/monads" ],
172          source_dirs    = [],
173          library_dirs   = if installing
174                              then [ "$libdir" ]
175                              else [ "$libdir/hslibs/lang"
176                                   , "$libdir/hslibs/lang/cbits" ],
177          hs_libraries      = [ "HSlang" ],
178          extra_libraries   = [ "HSlang_cbits" ],
179          include_dirs   = if installing
180                              then []
181                              else [ "$libdir/hslibs/lang/cbits" ],
182          c_includes     = [ "HsLang.h" ],
183          package_deps   = [],
184          extra_ghc_opts = [],
185          extra_cc_opts  = [],
186          extra_ld_opts  = [
187 #ifndef LEADING_UNDERSCORE
188                           "-u", "Addr_Azh_static_info"
189 #else
190                           "-u", "_Addr_Azh_static_info"
191 #endif
192                         ]
193         },
194
195          Package {
196          name           = "concurrent",
197          import_dirs    = if installing
198                              then [ "$libdir/imports/concurrent" ]
199                              else [ "$libdir/hslibs/concurrent" ],
200          source_dirs    = [],
201          library_dirs   = if installing
202                              then [ "$libdir" ]
203                              else [ "$libdir/hslibs/concurrent" ],
204          hs_libraries      = [ "HSconcurrent" ],
205          extra_libraries   = [],
206          include_dirs   = if installing
207                              then []
208                              else [ "$libdir/hslibs/concurrent/cbits" ],
209          c_includes     = [],
210          package_deps   = [ "lang" ],
211          extra_ghc_opts = [],
212          extra_cc_opts  = [],
213          extra_ld_opts  = []
214         },
215
216          Package {
217          name           = "data",
218          import_dirs    = if installing
219                              then [ "$libdir/imports/data" ]
220                              else [ "$libdir/hslibs/data"
221                                   , "$libdir/hslibs/data/edison"
222                                   , "$libdir/hslibs/data/edison/Assoc"
223                                   , "$libdir/hslibs/data/edison/Coll"
224                                   , "$libdir/hslibs/data/edison/Seq" ],
225          source_dirs    = [],
226          library_dirs   = if installing
227                              then [ "$libdir" ]
228                              else [ "$libdir/hslibs/data" ],
229          hs_libraries      = [ "HSdata" ],
230          extra_libraries   = [],
231          include_dirs   = if installing
232                              then []
233                              else [ "$libdir/hslibs/data/cbits" ],
234          c_includes     = [],
235          package_deps   = [ "lang", "util" ],
236          extra_ghc_opts = [],
237          extra_cc_opts  = [],
238          extra_ld_opts  = []
239         },
240
241          Package {
242          name           = "net",
243          import_dirs    = if installing
244                              then [ "$libdir/imports/net" ]
245                              else [ "$libdir/hslibs/net" ],
246          source_dirs    = [],
247          library_dirs   = if installing
248                              then [ "$libdir" ]
249                              else [ "$libdir/hslibs/net"
250                                   , "$libdir/hslibs/net/cbits" ],
251          hs_libraries      = [ "HSnet" ],
252          extra_libraries   = if suffixMatch "solaris2" cTARGETPLATFORM
253                                 then [ "nsl",  "socket" ]
254                                 else []
255                              ,
256          include_dirs   = if installing
257                              then []
258                              else [ "$libdir/hslibs/net/cbits" ],
259          c_includes     = [ "HsNet.h" ],
260          package_deps   = [ "lang", "text", "concurrent" ],
261          extra_ghc_opts = [],
262          extra_cc_opts  = [],
263          extra_ld_opts  = []
264         },
265
266          Package {
267          name           = "posix",
268          import_dirs    = if installing
269                              then [ "$libdir/imports/posix" ]
270                              else [ "$libdir/hslibs/posix" ],
271          source_dirs    = [],
272          library_dirs   = if installing
273                              then [ "$libdir" ]
274                              else [ "$libdir/hslibs/posix"
275                                   , "$libdir/hslibs/posix/cbits" ],
276          hs_libraries      = [ "HSposix" ],
277          extra_libraries   = [ "HSposix_cbits" ],
278          include_dirs   = if installing
279                              then []
280                              else [ "$libdir/hslibs/posix/cbits" ],
281          c_includes     = [ "HsPosix.h" ],
282          package_deps   = [ "lang" ],
283          extra_ghc_opts = [],
284          extra_cc_opts  = [],
285          extra_ld_opts  = []
286         },
287
288          Package {
289          name           = "text",
290          import_dirs    = if installing
291                              then [ "$libdir/imports/text" ]
292                              else [ "$libdir/hslibs/text" 
293                                   , "$libdir/hslibs/text/html" 
294                                   , "$libdir/hslibs/text/HaXml/lib" 
295                                   , "$libdir/hslibs/text/parsec" ],
296          source_dirs    = [],
297          library_dirs   = if installing
298                              then [ "$libdir" ]
299                              else [ "$libdir/hslibs/text"
300                                   , "$libdir/hslibs/text/cbits" ],
301          hs_libraries      = [ "HStext" ],
302          extra_libraries   = [ "HStext_cbits" ],
303          include_dirs   = if installing
304                              then []
305                              else [ "$libdir/hslibs/text/cbits" ],
306          c_includes     = [ "HsText.h" ],
307          package_deps   = [ "lang" ],
308          extra_ghc_opts = [],
309          extra_cc_opts  = [],
310          extra_ld_opts  = []
311         },
312
313          Package {
314          name           = "util",
315          import_dirs    = if installing
316                              then [ "$libdir/imports/util" ]
317                              else [ "$libdir/hslibs/util"
318                                   , "$libdir/hslibs/util/check" ],
319          source_dirs    = [],
320          library_dirs   = if installing
321                              then [ "$libdir" ]
322                              else [ "$libdir/hslibs/util"
323                                   , "$libdir/hslibs/util/cbits" ],
324          hs_libraries      = [ "HSutil" ],
325          extra_libraries   = [ "HSutil_cbits" ] 
326 #ifndef mingw32_TARGET_OS
327                              ++ words cLibsReadline
328 #endif
329                              ,
330          include_dirs   = if installing
331                              then []
332                              else [ "$libdir/hslibs/util/cbits" ],
333          c_includes     = [ "HsUtil.h" ],
334          package_deps   = [ "lang", "concurrent"
335 #ifndef mingw32_TARGET_OS
336                             , "posix"
337 #endif
338                           ],
339          extra_ghc_opts = [],
340          extra_cc_opts  = [],
341          extra_ld_opts  = []
342         },
343
344         -- no cbits at the moment, we'll need to add one if this library
345         -- ever calls out to any C libs.
346          Package {
347          name           = "hssource",
348          import_dirs    = if installing
349                              then [ "$libdir/imports/hssource" ]
350                              else [ "$libdir/hslibs/hssource" ],
351          source_dirs    = [],
352          library_dirs   = if installing
353                              then [ "$libdir" ]
354                              else [ "$libdir/hslibs/hssource" ],
355          hs_libraries      = [ "HShssource" ],
356          extra_libraries   = [],
357          include_dirs   = [],
358          c_includes     = [],
359          package_deps   = [ "text" ],
360          extra_ghc_opts = [],
361          extra_cc_opts  = [],
362          extra_ld_opts  = []
363         },
364
365          Package {
366          name         = "greencard",
367          import_dirs    = if installing
368                              then [ "$libdir/imports/greencard" ]
369                              else [ "$libdir/green-card/lib/ghc" ],
370          source_dirs    = [],
371          library_dirs   = if installing
372                              then [ "$libdir" ]
373                              else [ "$libdir/green-card/lib/ghc" ],
374          hs_libraries      = [ "HSgreencard" ],
375          extra_libraries   = [],
376          include_dirs   = [],
377          c_includes     = [],
378          package_deps   = [ "lang" ],
379          extra_ghc_opts = [],
380          extra_cc_opts  = [],
381          extra_ld_opts  = [],
382         }
383
384 #if defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS)
385          ,Package {
386          name         = "win32",
387          import_dirs    = if installing
388                              then [ "$libdir/imports/win32" ]
389                              else [ "$libdir/hslibs/win32" ],
390          source_dirs    = [],
391          library_dirs   = if installing
392                              then [ "$libdir" ]
393                              else [ "$libdir/hslibs/win32" ],
394          hs_libraries      = [ "HSwin32" ],
395          extra_libraries   = [ "user32",  "gdi32", "winmm" ],
396          include_dirs   = [],
397          c_includes     = [],           -- ???
398          package_deps   = [ "lang", "greencard" ],
399          extra_ghc_opts = [],
400          extra_cc_opts  = [],
401          extra_ld_opts  = []
402         },
403
404          Package {
405          name           = "com",
406          import_dirs    = if installing
407                              then [ "$libdir/imports/com" ]
408                              else [ "$libdir/hdirect/lib" ],
409          source_dirs    = [],
410          library_dirs   = if installing
411                              then [ "$libdir" ]
412                              else [ "$libdir/hdirect/lib" ],
413          hs_libraries      = [ "HScom" ],
414          extra_libraries   = [ "user32",  "ole32",  "oleaut32", "advapi32" ],
415          include_dirs   = [],
416          c_includes     = [],           -- ???
417          package_deps   = [ "lang" ],
418          extra_ghc_opts = [],
419          extra_cc_opts  = [],
420          extra_ld_opts  = []
421         }
422 #endif
423
424          ,Package {
425          name           = "xlib",
426          import_dirs    = if installing
427                              then [ "$libdir/imports/xlib" ]
428                              else [ "$libdir/hslibs/xlib" ],
429          source_dirs    = [],
430          library_dirs   = if installing
431                              then [ "$libdir" ]
432                              else [ "$libdir/hslibs/xlib"
433                                   , "$libdir/hslibs/xlib/cbits" ],
434          hs_libraries      = [ "HSxlib" ],
435          extra_libraries   = [ "HSxlib_cbits", "X11" ],
436          include_dirs   = if installing
437                              then []
438                              else [ "$libdir/hslibs/xlib/cbits" ],
439          c_includes     = [ "HsXlib.h" ],
440          package_deps   = [ "greencard" ],
441          extra_ghc_opts = [],
442          extra_cc_opts  = [],
443          extra_ld_opts  = []
444         }
445
446          ,Package {
447          name           = "HGL",
448          import_dirs    = if installing
449                              then [ "$libdir/imports/HGL" ]
450                              else [ "$libdir/hslibs/graphics/lib/x11" ],
451          source_dirs    = [],
452          library_dirs   = [],
453          hs_libraries   = [ "HSHGL" ],
454          extra_libraries= [],
455          include_dirs   = [],
456          c_includes     = [],
457          package_deps   = [ "xlib", "concurrent" ],
458          extra_ghc_opts = [],
459          extra_cc_opts  = [],
460          extra_ld_opts  = []
461         }
462
463    ]
464   where
465         ghc_src_dir :: String -> String
466         ghc_src_dir path = "$libdir/" ++ cCURRENT_DIR ++ '/':path