PackageSrc.hs 15.9 KB
Newer Older
1
2
#include "../includes/config.h"

3
4
module Main (main) where

5
6
import Utils

7
8
9
10
import IO
import System
import Package

11
main :: IO ()
12
13
14
main = do
  args <- getArgs
  case args of
15
16
17
18
19
     ("install":rest)  -> do { putStrLn (dumpPackages (package_details True rest)) }
     ("in-place":rest) -> do { putStrLn (dumpPackages (package_details False rest)) }
     _ -> do hPutStr stderr "usage: pkgconf (install | in-place) ...\n"
             exitWith (ExitFailure 1)

20
-- The compiler automatically replaces the string "$libdir" at the
21
22
23
24
25
-- beginning of a path with the directory passed to the compiler via
-- the -B<dir> flag.  Absolute path names will be unchanged.
--
-- This is how we make package.conf independent of GHC's installation
-- location.
26

27
28
29
30
31
32
33
34
35
36
package_details :: Bool -> [String] -> [PackageConfig]
package_details installing
 [ cTARGETPLATFORM
 , cCURRENT_DIR
 , cHaveLibGmp
 , cLibsReadline
 , cGHC_LIB_DIR
 , cGHC_RUNTIME_DIR
 , cGHC_UTILS_DIR
 , 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
45
46
        library_dirs   = if cHaveLibGmp == "YES"
                            then []
                            else if installing
47
                                    then [ "$libdir" ]
48
                                    else [ ghc_src_dir cGHC_RUNTIME_DIR ++ "/gmp" ],
49
50
  	hs_libraries   = [],
        extra_libraries = [ "gmp" ],
51
52
53
54
55
56
        include_dirs   = [],
        c_includes     = [],
        package_deps   = [],
        extra_ghc_opts = [],
        extra_cc_opts  = [],
        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" ],
rrt's avatar
rrt committed
67
#ifndef mingw32_TARGET_OS
68
	extra_libraries   = [],
rrt's avatar
rrt committed
69
#else
rrt's avatar
rrt committed
70
        extra_libraries   = [ "winmm", "wsock32" ], -- winmm for the threadDelay timer, wsock32 for the linker
rrt's avatar
rrt committed
71
#endif
72
        include_dirs   = if installing
73
                            then [ "$libdir/includes" ]
74
75
76
77
78
79
80
                            else [ ghc_src_dir cGHC_INCLUDE_DIR ],
        c_includes     = [ "Stg.h" ],           -- ha!
        package_deps   = [ "gmp" ],
        extra_ghc_opts = [],
        extra_cc_opts  = [],
                -- the RTS forward-references to a bunch of stuff in the prelude,
                -- so we force it to be included with special options to ld.
81
82
83
84
85
86
87
88
89
90
91
        extra_ld_opts  = map (
#ifndef LEADING_UNDERSCORE
		          "-u "
#else
			  "-u _"
#endif
                          ++ ) [
           "PrelBase_Izh_static_info"
         , "PrelBase_Czh_static_info"
         , "PrelFloat_Fzh_static_info"
         , "PrelFloat_Dzh_static_info"
92
         , "PrelPtr_Ptr_static_info"
93
94
95
96
97
98
99
100
101
         , "PrelWord_Wzh_static_info"
         , "PrelInt_I8zh_static_info"
         , "PrelInt_I16zh_static_info"
         , "PrelInt_I32zh_static_info"
         , "PrelInt_I64zh_static_info"
         , "PrelWord_W8zh_static_info"
         , "PrelWord_W16zh_static_info"
         , "PrelWord_W32zh_static_info"
         , "PrelWord_W64zh_static_info"
102
103
104
105
106
         , "PrelStable_StablePtr_static_info"
         , "PrelBase_Izh_con_info"
         , "PrelBase_Czh_con_info"
         , "PrelFloat_Fzh_con_info"
         , "PrelFloat_Dzh_con_info"
107
         , "PrelPtr_Ptr_con_info"
108
109
110
111
112
113
114
115
116
117
         , "PrelStable_StablePtr_con_info"
         , "PrelBase_False_closure"
         , "PrelBase_True_closure"
         , "PrelPack_unpackCString_closure"
         , "PrelIOBase_stackOverflow_closure"
         , "PrelIOBase_heapOverflow_closure"
         , "PrelIOBase_NonTermination_closure"
         , "PrelIOBase_BlockedOnDeadMVar_closure"
         , "PrelWeak_runFinalizzerBatch_closure"
         , "__init_Prelude"
118
         ]
119
        },
120

121
        Package {
122
123
        name           = "std",  -- The Prelude & Standard Hs_libraries
	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
130
                            else [ ghc_src_dir cGHC_LIB_DIR ++ "/std"
                                 , ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
131
132
133
134
135
136
137
138

        hs_libraries      = 
#                           ifndef mingw32_TARGET_OS
                            [ "HSstd" ]
#                           else
                            [ "HSstd1", "HSstd2" ]
#                           endif
                            ,
139
140
	extra_libraries   = [ "HSstd_cbits" ] ++
#                           ifdef mingw32_TARGET_OS
rrt's avatar
rrt committed
141
                            [ "wsock32", "msvcrt" ]
142
#                           else
rrt's avatar
rrt committed
143
                            [ "m" ]   -- libm, that is
144
145
#                           endif
                            ,
146
147
148
149
150
151
152
        include_dirs   = if installing
                            then []
                            else [ ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
        c_includes     = [ "HsStd.h" ],
        package_deps   = [ "rts" ],
        extra_ghc_opts = [],
        extra_cc_opts  = [],
153
        extra_ld_opts  = []
154
        },
155

156
         Package { 
157
158
         name           = "lang",
	 import_dirs    = if installing
159
160
161
                             then [ "$libdir/imports/lang" ]
                             else [ "$libdir/hslibs/lang"
                                  , "$libdir/hslibs/lang/monads" ],
162
         source_dirs    = [],
163
         library_dirs   = if installing
164
165
166
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/lang"
                                  , "$libdir/hslibs/lang/cbits" ],
167
168
         hs_libraries      = [ "HSlang" ],
	 extra_libraries   = [ "HSlang_cbits" ],
169
170
         include_dirs   = if installing
                             then []
171
                             else [ "$libdir/hslibs/lang/cbits" ],
172
173
174
175
         c_includes     = [ "HsLang.h" ],
         package_deps   = [],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
176
177
178
179
180
181
182
         extra_ld_opts  = [
#ifndef LEADING_UNDERSCORE
		          "-u Addr_Azh_static_info"
#else
			  "-u _Addr_Azh_static_info"
#endif
			]
183
        },
184

185
         Package {
186
	 name           = "concurrent",
187
         import_dirs    = if installing
188
189
                             then [ "$libdir/imports/concurrent" ]
                             else [ "$libdir/hslibs/concurrent" ],
190
         source_dirs    = [],
191
         library_dirs   = if installing
192
193
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/concurrent" ],
194
195
         hs_libraries      = [ "HSconcurrent" ],
	 extra_libraries   = [],
196
197
         include_dirs   = if installing
                             then []
198
                             else [ "$libdir/hslibs/concurrent/cbits" ],
199
         c_includes     = [],
200
201
202
203
         package_deps   = [ "lang" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
204
        },
205

206
         Package {
207
         name           = "data",
208
         import_dirs    = if installing
209
210
211
212
213
214
                             then [ "$libdir/imports/data" ]
                             else [ "$libdir/hslibs/data"
                                  , "$libdir/hslibs/data/edison"
                                  , "$libdir/hslibs/data/edison/Assoc"
                                  , "$libdir/hslibs/data/edison/Coll"
                                  , "$libdir/hslibs/data/edison/Seq" ],
215
         source_dirs    = [],
216
         library_dirs   = if installing
217
218
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/data" ],
219
220
         hs_libraries      = [ "HSdata" ],
	 extra_libraries   = [],
221
222
         include_dirs   = if installing
                             then []
223
                             else [ "$libdir/hslibs/data/cbits" ],
224
         c_includes     = [],
225
         package_deps   = [ "lang", "util" ],
226
227
228
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
229
        },
230

231
         Package {
232
         name           = "net",
233
         import_dirs    = if installing
234
235
                             then [ "$libdir/imports/net" ]
                             else [ "$libdir/hslibs/net" ],
236
         source_dirs    = [],
237
         library_dirs   = if installing
238
239
240
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/net"
                                  , "$libdir/hslibs/net/cbits" ],
241
         hs_libraries      = [ "HSnet" ],
242
	 extra_libraries   = if suffixMatch "solaris2" cTARGETPLATFORM
243
244
245
                                then [ "nsl",  "socket" ]
                                else []
                             ,
246
247
         include_dirs   = if installing
                             then []
248
                             else [ "$libdir/hslibs/net/cbits" ],
249
         c_includes     = [ "HsNet.h" ],
250
         package_deps   = [ "lang", "text", "concurrent" ],
251
252
         extra_ghc_opts = [],
         extra_cc_opts  = [],
253
         extra_ld_opts  = []
254
        },
255

256
         Package {
257
         name           = "posix",
258
         import_dirs    = if installing
259
260
                             then [ "$libdir/imports/posix" ]
                             else [ "$libdir/hslibs/posix" ],
261
         source_dirs    = [],
262
         library_dirs   = if installing
263
264
265
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/posix"
                                  , "$libdir/hslibs/posix/cbits" ],
266
267
         hs_libraries      = [ "HSposix" ],
	 extra_libraries   = [ "HSposix_cbits" ],
268
269
         include_dirs   = if installing
                             then []
270
                             else [ "$libdir/hslibs/posix/cbits" ],
271
272
273
274
275
         c_includes     = [ "HsPosix.h" ],
         package_deps   = [ "lang" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
276
        },
277

278
         Package {
279
         name           = "text",
280
         import_dirs    = if installing
281
282
283
284
285
                             then [ "$libdir/imports/text" ]
                             else [ "$libdir/hslibs/text" 
                                  , "$libdir/hslibs/text/html" 
                                  , "$libdir/hslibs/text/HaXml/lib" 
                                  , "$libdir/hslibs/text/parsec" ],
286
         source_dirs    = [],
287
         library_dirs   = if installing
288
289
290
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/text"
                                  , "$libdir/hslibs/text/cbits" ],
291
292
         hs_libraries      = [ "HStext" ],
	 extra_libraries   = [ "HStext_cbits" ],
293
294
         include_dirs   = if installing
                             then []
295
                             else [ "$libdir/hslibs/text/cbits" ],
296
         c_includes     = [ "HsText.h" ],
297
         package_deps   = [ "lang" ],
298
299
300
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
301
        },
302

303
         Package {
304
         name           = "util",
305
         import_dirs    = if installing
306
307
308
                             then [ "$libdir/imports/util" ]
                             else [ "$libdir/hslibs/util"
                                  , "$libdir/hslibs/util/check" ],
309
         source_dirs    = [],
310
         library_dirs   = if installing
311
312
313
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/util"
                                  , "$libdir/hslibs/util/cbits" ],
314
         hs_libraries      = [ "HSutil" ],
315
	 extra_libraries   = [ "HSutil_cbits" ] ++ words cLibsReadline,
316
317
         include_dirs   = if installing
                             then []
318
                             else [ "$libdir/hslibs/util/cbits" ],
319
         c_includes     = [ "HsUtil.h" ],
320
321
322
323
324
         package_deps   = [ "lang", "concurrent"
#ifndef mingw32_TARGET_OS
			    , "posix"
#endif
			  ],
325
326
         extra_ghc_opts = [],
         extra_cc_opts  = [],
327
         extra_ld_opts  = []
328
        },
329

330
331
332
        -- no cbits at the moment, we'll need to add one if this library
        -- ever calls out to any C libs.
         Package {
333
         name           = "hssource",
334
         import_dirs    = if installing
335
336
                             then [ "$libdir/imports/hssource" ]
                             else [ "$libdir/hslibs/hssource" ],
337
         source_dirs    = [],
338
         library_dirs   = if installing
339
340
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/hssource" ],
341
342
         hs_libraries      = [ "HShssource" ],
	 extra_libraries   = [],
343
344
345
346
347
348
         include_dirs   = [],
         c_includes     = [],
         package_deps   = [ "text" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
349
        },
350

rrt's avatar
rrt committed
351
352
353
         Package {
	 name         = "greencard",
         import_dirs    = if installing
354
355
                             then [ "$libdir/imports/greencard" ]
                   	     else [ "$libdir/green-card/lib/ghc" ],
356
         source_dirs    = [],
rrt's avatar
rrt committed
357
         library_dirs   = if installing
358
359
                             then [ "$libdir" ]
                             else [ "$libdir/green-card/lib/ghc" ],
rrt's avatar
rrt committed
360
361
362
363
         hs_libraries      = [ "HSgreencard" ],
         extra_libraries   = [],
         include_dirs   = [],
         c_includes     = [],
rrt's avatar
rrt committed
364
         package_deps   = [ "lang" ],
rrt's avatar
rrt committed
365
366
367
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = [],
368
        }
rrt's avatar
rrt committed
369

370
371
#if defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS)
         ,Package {
372
373
         name         = "win32",
	 import_dirs    = if installing
374
375
                             then [ "$libdir/imports/win32" ]
                             else [ "$libdir/hslibs/win32" ],
376
         source_dirs    = [],
377
         library_dirs   = if installing
378
379
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/win32" ],
380
         hs_libraries      = [ "HSwin32" ],
381
	 extra_libraries   = [ "user32",  "gdi32", "winmm" ],
382
383
         include_dirs   = [],
         c_includes     = [],           -- ???
rrt's avatar
rrt committed
384
         package_deps   = [ "lang", "greencard" ],
385
386
         extra_ghc_opts = [],
         extra_cc_opts  = [],
387
         extra_ld_opts  = []
388
        },
389

390
         Package {
391
         name           = "com",
392
         import_dirs    = if installing
393
394
                             then [ "$libdir/imports/com" ]
                             else [ "$libdir/hdirect/lib" ],
395
         source_dirs    = [],
396
         library_dirs   = if installing
397
398
                             then [ "$libdir" ]
                             else [ "$libdir/hdirect/lib" ],
399
         hs_libraries      = [ "HScom" ],
400
	 extra_libraries   = [ "user32",  "ole32",  "oleaut32", "advapi32" ],
401
402
403
404
405
         include_dirs   = [],
         c_includes     = [],           -- ???
         package_deps   = [ "lang" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
406
         extra_ld_opts  = []
407
        }
408
#endif
reid's avatar
reid committed
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431

         ,Package {
         name           = "xlib",
         import_dirs    = if installing
                             then [ "$libdir/imports/xlib" ]
                             else [ "$libdir/hslibs/xlib" ],
         source_dirs    = [],
         library_dirs   = if installing
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/xlib"
                                  , "$libdir/hslibs/xlib/cbits" ],
         hs_libraries      = [ "HSxlib" ],
	 extra_libraries   = [ "HSxlib_cbits", "X11" ],
         include_dirs   = if installing
                             then []
                             else [ "$libdir/hslibs/xlib/cbits" ],
         c_includes     = [ "HsXlib.h" ],
         package_deps   = [ "greencard" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
        }

432
   ]
433
434
  where
	ghc_src_dir :: String -> String
435
	ghc_src_dir path = "$libdir/" ++ cCURRENT_DIR ++ '/':path