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