PackageSrc.hs 14.8 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
        hs_libraries      = [ "HSstd" ],
132
133
	extra_libraries   = [ "HSstd_cbits" ] ++
#                           ifdef mingw32_TARGET_OS
rrt's avatar
rrt committed
134
                            ["wsock32", "msvcrt"]
135
136
137
138
#                           else
                            ["m"]   -- libm, that is
#                           endif
                            ,
139
140
141
142
143
144
145
        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  = [],
146
        extra_ld_opts  = []
147
        },
148

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

178
         Package {
179
	 name           = "concurrent",
180
         import_dirs    = if installing
181
182
                             then [ "$libdir/imports/concurrent" ]
                             else [ "$libdir/hslibs/concurrent" ],
183
         source_dirs    = [],
184
         library_dirs   = if installing
185
186
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/concurrent" ],
187
188
         hs_libraries      = [ "HSconcurrent" ],
	 extra_libraries   = [],
189
190
         include_dirs   = if installing
                             then []
191
                             else [ "$libdir/hslibs/concurrent/cbits" ],
192
         c_includes     = [],
193
194
195
196
         package_deps   = [ "lang" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
197
        },
198

199
         Package {
200
         name           = "data",
201
         import_dirs    = if installing
202
203
204
205
206
207
                             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" ],
208
         source_dirs    = [],
209
         library_dirs   = if installing
210
211
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/data" ],
212
213
         hs_libraries      = [ "HSdata" ],
	 extra_libraries   = [],
214
215
         include_dirs   = if installing
                             then []
216
                             else [ "$libdir/hslibs/data/cbits" ],
217
         c_includes     = [],
218
         package_deps   = [ "lang", "util" ],
219
220
221
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
222
        },
223

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

249
         Package {
250
         name           = "posix",
251
         import_dirs    = if installing
252
253
                             then [ "$libdir/imports/posix" ]
                             else [ "$libdir/hslibs/posix" ],
254
         source_dirs    = [],
255
         library_dirs   = if installing
256
257
258
                             then [ "$libdir" ]
                             else [ "$libdir/hslibs/posix"
                                  , "$libdir/hslibs/posix/cbits" ],
259
260
         hs_libraries      = [ "HSposix" ],
	 extra_libraries   = [ "HSposix_cbits" ],
261
262
         include_dirs   = if installing
                             then []
263
                             else [ "$libdir/hslibs/posix/cbits" ],
264
265
266
267
268
         c_includes     = [ "HsPosix.h" ],
         package_deps   = [ "lang" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = []
269
        },
270

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

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

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

rrt's avatar
rrt committed
344
345
346
         Package {
	 name         = "greencard",
         import_dirs    = if installing
347
348
                             then [ "$libdir/imports/greencard" ]
                   	     else [ "$libdir/green-card/lib/ghc" ],
349
         source_dirs    = [],
rrt's avatar
rrt committed
350
         library_dirs   = if installing
351
352
                             then [ "$libdir" ]
                             else [ "$libdir/green-card/lib/ghc" ],
rrt's avatar
rrt committed
353
354
355
356
         hs_libraries      = [ "HSgreencard" ],
         extra_libraries   = [],
         include_dirs   = [],
         c_includes     = [],
rrt's avatar
rrt committed
357
         package_deps   = [ "lang" ],
rrt's avatar
rrt committed
358
359
360
         extra_ghc_opts = [],
         extra_cc_opts  = [],
         extra_ld_opts  = [],
361
        }
rrt's avatar
rrt committed
362

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

383
         Package {
384
         name           = "com",
385
         import_dirs    = if installing
386
387
                             then [ "$libdir/imports/com" ]
                             else [ "$libdir/hdirect/lib" ],
388
         source_dirs    = [],
389
         library_dirs   = if installing
390
391
                             then [ "$libdir" ]
                             else [ "$libdir/hdirect/lib" ],
392
         hs_libraries      = [ "HScom" ],
393
	 extra_libraries   = [ "user32",  "ole32",  "oleaut32", "advapi32" ],
394
395
396
397
398
         include_dirs   = [],
         c_includes     = [],           -- ???
         package_deps   = [ "lang" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
399
         extra_ld_opts  = []
400
        }
401
#endif
402
   ]
403
404
  where
	ghc_src_dir :: String -> String
405
	ghc_src_dir path = "$libdir/" ++ cCURRENT_DIR ++ '/':path