PackageSrc.hs 17.5 KB
Newer Older
1
#include "../includes/config.h"
ken's avatar
ken committed
2
#include "../includes/Derived.h"
3

4
5
module Main (main) where

6
7
import Utils

8
9
10
11
import IO
import System
import Package

12
main :: IO ()
13
14
15
main = do
  args <- getArgs
  case args of
16
17
18
19
20
     ("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)

21
-- The compiler automatically replaces the string "$libdir" at the
22
23
24
25
26
-- 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.
27

28
29
30
31
32
33
34
35
36
37
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
38
39
 , cX_CFLAGS
 , 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
48
49
        library_dirs   = if cHaveLibGmp == "YES"
                            then []
                            else if installing
50
                                    then [ "$libdir" ]
51
                                    else [ ghc_src_dir cGHC_RUNTIME_DIR ++ "/gmp" ],
52
53
  	hs_libraries   = [],
        extra_libraries = [ "gmp" ],
54
55
56
57
58
59
        include_dirs   = [],
        c_includes     = [],
        package_deps   = [],
        extra_ghc_opts = [],
        extra_cc_opts  = [],
        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
sof's avatar
sof committed
67
68
69
70
71
72
73
                            then 
#ifdef mingw32_TARGET_OS
				-- force the dist-provided gcc-lib/ into scope.
			    	 [ "$libdir", "$libdir/gcc-lib" ]
#else
			    	 [ "$libdir" ]
#endif
74
                            else [ ghc_src_dir cGHC_RUNTIME_DIR ],
75
        hs_libraries      = [ "HSrts" ],
ken's avatar
ken committed
76
77
78
79
80
81
82
83
	extra_libraries   =
			      "m":		-- for ldexp()
#ifdef mingw32_TARGET_OS
			      "winmm":		-- for the threadDelay timer
			      "wsock32":	-- for the linker
#endif
#ifdef USING_LIBBFD
			      "bfd": "iberty":	-- for debugging
rrt's avatar
rrt committed
84
#endif
sof's avatar
sof committed
85
86
87
88
#ifdef THREADED_RTS
			      "pthread" :
#endif

ken's avatar
ken committed
89
			    [],
90
        include_dirs   = if installing
rrt's avatar
rrt committed
91
92
93
94
95
                            then [ "$libdir/include"
#ifdef mingw32_TARGET_OS
				 , "$libdir/include/mingw"
#endif
				 ]
96
97
98
99
100
101
102
                            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.
rrt's avatar
rrt committed
103
104
105
        extra_ld_opts  =
	   foldr (\ x xs -> "-u" : x : xs) []
                 (map (
106
#ifndef LEADING_UNDERSCORE
rrt's avatar
rrt committed
107
		          ""
108
#else
rrt's avatar
rrt committed
109
			  "_"
110
111
112
113
114
115
#endif
                          ++ ) [
           "PrelBase_Izh_static_info"
         , "PrelBase_Czh_static_info"
         , "PrelFloat_Fzh_static_info"
         , "PrelFloat_Dzh_static_info"
116
         , "PrelPtr_Ptr_static_info"
117
118
119
120
121
122
123
124
125
         , "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"
126
127
128
129
130
         , "PrelStable_StablePtr_static_info"
         , "PrelBase_Izh_con_info"
         , "PrelBase_Czh_con_info"
         , "PrelFloat_Fzh_con_info"
         , "PrelFloat_Dzh_con_info"
131
         , "PrelPtr_Ptr_con_info"
132
133
134
135
136
137
138
139
         , "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"
140
         , "PrelIOBase_Deadlock_closure"
141
         , "PrelWeak_runFinalizzerBatch_closure"
ken's avatar
ken committed
142
         , "__stginit_Prelude"
rrt's avatar
rrt committed
143
         ])
144
        },
145

146
        Package {
147
148
        name           = "std",  -- The Prelude & Standard Hs_libraries
	import_dirs    = if installing
149
                            then [ "$libdir/imports/std" ]
150
                            else [ ghc_src_dir cGHC_LIB_DIR ++ "/std" ],
151
        source_dirs    = [],
152
        library_dirs   = if installing
153
                            then [ "$libdir" ]
154
155
                            else [ ghc_src_dir cGHC_LIB_DIR ++ "/std"
                                 , ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
156
157
158
159
160

        hs_libraries      = 
#                           ifndef mingw32_TARGET_OS
                            [ "HSstd" ]
#                           else
161
162
163
164
                            -- This splitting is the subject of a totally 
                            -- horrible hack, which glues HSstd1 and HSstd2 
                            -- back into HSstd for the purposes of static linking.
                            -- See DriverState.getPackageLibraries for details.
165
166
167
                            [ "HSstd1", "HSstd2" ]
#                           endif
                            ,
168
169
	extra_libraries   = [ "HSstd_cbits" ] ++
#                           ifdef mingw32_TARGET_OS
sof's avatar
sof committed
170
                            [ "wsock32", "msvcrt", "kernel32", "user32" ]
171
#                           else
172
                            [ ]
173
174
#                           endif
                            ,
175
176
177
178
179
180
181
        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  = [],
182
        extra_ld_opts  = []
183
        },
184

185
         Package { 
186
187
         name           = "lang",
	 import_dirs    = if installing
188
189
190
                             then [ "$libdir/imports/lang" ]
                             else [ "$libdir/hslibs/lang"
                                  , "$libdir/hslibs/lang/monads" ],
191
         source_dirs    = [],
192
         library_dirs   = if installing
193
194
195
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/lang"
                                  , "$libdir/hslibs/lang/cbits" ],
196
197
         hs_libraries      = [ "HSlang" ],
	 extra_libraries   = [ "HSlang_cbits" ],
198
199
         include_dirs   = if installing
                             then []
200
                             else [ "$libdir/hslibs/lang/cbits" ],
201
202
203
204
         c_includes     = [ "HsLang.h" ],
         package_deps   = [],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
205
206
         extra_ld_opts  = [
#ifndef LEADING_UNDERSCORE
rrt's avatar
rrt committed
207
		          "-u", "Addr_Azh_static_info"
208
#else
rrt's avatar
rrt committed
209
			  "-u", "_Addr_Azh_static_info"
210
211
#endif
			]
212
        },
213

214
         Package {
215
	 name           = "concurrent",
216
         import_dirs    = if installing
217
218
                             then [ "$libdir/imports/concurrent" ]
                             else [ "$libdir/hslibs/concurrent" ],
219
         source_dirs    = [],
220
         library_dirs   = if installing
221
222
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/concurrent" ],
223
224
         hs_libraries      = [ "HSconcurrent" ],
	 extra_libraries   = [],
225
226
         include_dirs   = if installing
                             then []
227
                             else [ "$libdir/hslibs/concurrent/cbits" ],
228
         c_includes     = [],
229
230
231
232
         package_deps   = [ "lang" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
233
        },
234

235
         Package {
236
         name           = "data",
237
         import_dirs    = if installing
238
239
240
241
242
243
                             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" ],
244
         source_dirs    = [],
245
         library_dirs   = if installing
246
247
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/data" ],
248
249
         hs_libraries      = [ "HSdata" ],
	 extra_libraries   = [],
250
251
         include_dirs   = if installing
                             then []
252
                             else [ "$libdir/hslibs/data/cbits" ],
253
         c_includes     = [],
254
         package_deps   = [ "lang", "util" ],
255
256
257
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
258
        },
259

260
         Package {
261
         name           = "net",
262
         import_dirs    = if installing
263
264
                             then [ "$libdir/imports/net" ]
                             else [ "$libdir/hslibs/net" ],
265
         source_dirs    = [],
266
         library_dirs   = if installing
267
268
269
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/net"
                                  , "$libdir/hslibs/net/cbits" ],
270
         hs_libraries      = [ "HSnet" ],
271
	 extra_libraries   = if suffixMatch "solaris2" cTARGETPLATFORM
272
273
274
                                then [ "nsl",  "socket" ]
                                else []
                             ,
275
276
         include_dirs   = if installing
                             then []
277
                             else [ "$libdir/hslibs/net/cbits" ],
278
         c_includes     = [ "HsNet.h" ],
279
         package_deps   = [ "lang", "text", "concurrent" ],
280
281
         extra_ghc_opts = [],
         extra_cc_opts  = [],
282
         extra_ld_opts  = []
283
        },
284

285
         Package {
286
         name           = "posix",
287
         import_dirs    = if installing
288
289
                             then [ "$libdir/imports/posix" ]
                             else [ "$libdir/hslibs/posix" ],
290
         source_dirs    = [],
291
         library_dirs   = if installing
292
293
294
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/posix"
                                  , "$libdir/hslibs/posix/cbits" ],
295
296
         hs_libraries      = [ "HSposix" ],
	 extra_libraries   = [ "HSposix_cbits" ],
297
298
         include_dirs   = if installing
                             then []
299
                             else [ "$libdir/hslibs/posix/cbits" ],
300
301
302
303
304
         c_includes     = [ "HsPosix.h" ],
         package_deps   = [ "lang" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
305
        },
306

307
         Package {
308
         name           = "text",
309
         import_dirs    = if installing
310
311
312
313
314
                             then [ "$libdir/imports/text" ]
                             else [ "$libdir/hslibs/text" 
                                  , "$libdir/hslibs/text/html" 
                                  , "$libdir/hslibs/text/HaXml/lib" 
                                  , "$libdir/hslibs/text/parsec" ],
315
         source_dirs    = [],
316
         library_dirs   = if installing
317
318
319
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/text"
                                  , "$libdir/hslibs/text/cbits" ],
320
321
         hs_libraries      = [ "HStext" ],
	 extra_libraries   = [ "HStext_cbits" ],
322
323
         include_dirs   = if installing
                             then []
324
                             else [ "$libdir/hslibs/text/cbits" ],
325
         c_includes     = [ "HsText.h" ],
326
         package_deps   = [ "lang" ],
327
328
329
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
330
        },
331

332
         Package {
333
         name           = "util",
334
         import_dirs    = if installing
335
336
337
                             then [ "$libdir/imports/util" ]
                             else [ "$libdir/hslibs/util"
                                  , "$libdir/hslibs/util/check" ],
338
         source_dirs    = [],
339
         library_dirs   = if installing
340
341
342
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/util"
                                  , "$libdir/hslibs/util/cbits" ],
343
         hs_libraries      = [ "HSutil" ],
344
345
346
347
348
	 extra_libraries   = [ "HSutil_cbits" ] 
#ifndef mingw32_TARGET_OS
                             ++ words cLibsReadline
#endif
                             ,
349
350
         include_dirs   = if installing
                             then []
351
                             else [ "$libdir/hslibs/util/cbits" ],
352
         c_includes     = [ "HsUtil.h" ],
353
354
355
356
357
         package_deps   = [ "lang", "concurrent"
#ifndef mingw32_TARGET_OS
			    , "posix"
#endif
			  ],
358
359
         extra_ghc_opts = [],
         extra_cc_opts  = [],
360
         extra_ld_opts  = []
361
        },
362

363
364
365
        -- no cbits at the moment, we'll need to add one if this library
        -- ever calls out to any C libs.
         Package {
366
         name           = "hssource",
367
         import_dirs    = if installing
368
369
                             then [ "$libdir/imports/hssource" ]
                             else [ "$libdir/hslibs/hssource" ],
370
         source_dirs    = [],
371
         library_dirs   = if installing
372
373
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/hssource" ],
374
375
         hs_libraries      = [ "HShssource" ],
	 extra_libraries   = [],
376
377
378
379
380
381
         include_dirs   = [],
         c_includes     = [],
         package_deps   = [ "text" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
382
        },
383

rrt's avatar
rrt committed
384
385
386
         Package {
	 name         = "greencard",
         import_dirs    = if installing
387
388
                             then [ "$libdir/imports/greencard" ]
                   	     else [ "$libdir/green-card/lib/ghc" ],
389
         source_dirs    = [],
rrt's avatar
rrt committed
390
         library_dirs   = if installing
391
392
                             then [ "$libdir" ]
                             else [ "$libdir/green-card/lib/ghc" ],
rrt's avatar
rrt committed
393
394
395
396
         hs_libraries      = [ "HSgreencard" ],
         extra_libraries   = [],
         include_dirs   = [],
         c_includes     = [],
rrt's avatar
rrt committed
397
         package_deps   = [ "lang" ],
rrt's avatar
rrt committed
398
399
400
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = [],
401
        }
rrt's avatar
rrt committed
402

403
404
#if defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS)
         ,Package {
405
406
         name         = "win32",
	 import_dirs    = if installing
407
408
                             then [ "$libdir/imports/win32" ]
                             else [ "$libdir/hslibs/win32" ],
409
         source_dirs    = [],
410
         library_dirs   = if installing
411
412
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/win32" ],
413
414
415
         hs_libraries      = [ "HSwin321", "HSwin322" ],
	 extra_libraries   = [ "user32",  "gdi32", "winmm", 
                               "kernel32", "advapi32" ],
416
417
         include_dirs   = [],
         c_includes     = [],           -- ???
rrt's avatar
rrt committed
418
         package_deps   = [ "lang" ], -- greencard now built in
419
420
         extra_ghc_opts = [],
         extra_cc_opts  = [],
421
         extra_ld_opts  = []
422
        }
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
        ,Package {
	 name = "objectio",
	 import_dirs = if installing
	               then ["$libdir/imports/objectio"]
	               else ["$libdir/hslibs/object-io/ObjectIO","$libdir/hslibs/object-io/OSWindows"],
	 source_dirs = [],
	 library_dirs = if installing
	                then [ "$libdir" ]
	                else [ "$libdir/hslibs/object-io"],
	 hs_libraries = ["HSobjectio"],
	 extra_libraries =
		       ["user32",
			"gdi32",
			"kernel32",
			"comctl32",
			"comdlg32",
			"shell32",
			"winmm",
			"winspool",
			"ole32"],
	 include_dirs = [],
	 c_includes = [],
	 package_deps = ["concurrent", "lang"],
	 extra_ghc_opts = [],
	 extra_cc_opts = [],
	 extra_ld_opts = []
	}
450
#endif
reid's avatar
reid committed
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469

         ,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 = [],
470
471
         extra_cc_opts  = [ cX_CFLAGS ],
         extra_ld_opts  = [ cX_LIBS ]
reid's avatar
reid committed
472
473
        }

reid's avatar
reid committed
474
475
476
477
478
479
         ,Package {
         name           = "HGL",
         import_dirs    = if installing
                             then [ "$libdir/imports/HGL" ]
                             else [ "$libdir/hslibs/graphics/lib/x11" ],
         source_dirs    = [],
480
481
482
         library_dirs   = if installing
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/graphics/lib/x11"],
reid's avatar
reid committed
483
484
485
486
487
488
489
490
491
492
         hs_libraries   = [ "HSHGL" ],
	 extra_libraries= [],
         include_dirs   = [],
         c_includes     = [],
         package_deps   = [ "xlib", "concurrent" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
        }

493
   ]
494
495
  where
	ghc_src_dir :: String -> String
496
	ghc_src_dir path = "$libdir/" ++ cCURRENT_DIR ++ '/':path