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

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

        hs_libraries      = 
#                           ifndef mingw32_TARGET_OS
                            [ "HSstd" ]
#                           else
156
157
158
159
                            -- 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.
160
161
162
                            [ "HSstd1", "HSstd2" ]
#                           endif
                            ,
163
164
	extra_libraries   = [ "HSstd_cbits" ] ++
#                           ifdef mingw32_TARGET_OS
sof's avatar
sof committed
165
                            [ "wsock32", "msvcrt", "kernel32", "user32" ]
166
#                           else
167
                            [ ]
168
169
#                           endif
                            ,
170
171
172
173
174
175
176
        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  = [],
177
        extra_ld_opts  = []
178
        },
179

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

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

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

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

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

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

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

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

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

398
399
#if defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS)
         ,Package {
400
401
         name         = "win32",
	 import_dirs    = if installing
402
403
                             then [ "$libdir/imports/win32" ]
                             else [ "$libdir/hslibs/win32" ],
404
         source_dirs    = [],
405
         library_dirs   = if installing
406
407
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/win32" ],
408
409
410
         hs_libraries      = [ "HSwin321", "HSwin322" ],
	 extra_libraries   = [ "user32",  "gdi32", "winmm", 
                               "kernel32", "advapi32" ],
411
412
         include_dirs   = [],
         c_includes     = [],           -- ???
rrt's avatar
rrt committed
413
         package_deps   = [ "lang" ], -- greencard now built in
414
415
         extra_ghc_opts = [],
         extra_cc_opts  = [],
416
         extra_ld_opts  = []
417
        }
418
#endif
reid's avatar
reid committed
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437

         ,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 = [],
438
439
         extra_cc_opts  = [ cX_CFLAGS ],
         extra_ld_opts  = [ cX_LIBS ]
reid's avatar
reid committed
440
441
        }

reid's avatar
reid committed
442
443
444
445
446
447
         ,Package {
         name           = "HGL",
         import_dirs    = if installing
                             then [ "$libdir/imports/HGL" ]
                             else [ "$libdir/hslibs/graphics/lib/x11" ],
         source_dirs    = [],
448
449
450
         library_dirs   = if installing
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/graphics/lib/x11"],
reid's avatar
reid committed
451
452
453
454
455
456
457
458
459
460
         hs_libraries   = [ "HSHGL" ],
	 extra_libraries= [],
         include_dirs   = [],
         c_includes     = [],
         package_deps   = [ "xlib", "concurrent" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
        }

461
   ]
462
463
  where
	ghc_src_dir :: String -> String
464
	ghc_src_dir path = "$libdir/" ++ cCURRENT_DIR ++ '/':path