[project @ 2000-06-13 16:07:20 by simonmar]
[ghc-hetmet.git] / ghc / driver / PackageSrc.hs
1 module Main (main) where
2
3 import IOExts
4 import IO
5 import System
6 import Config
7 import Package
8
9 main = do
10   args <- getArgs
11   case args of
12         [ "install"  ] -> do { putStr (pprPackage (package_details True)) }
13         [ "in-place" ] -> do { putStr (pprPackage (package_details False)) }
14         _ -> do hPutStr stderr "usage: pkgconf (install | in-place)\n"
15                 exitWith (ExitFailure 1)
16
17 package_details :: Bool -> [(String,Package)]
18 package_details installing =
19  [
20       ( "gmp",  -- GMP is at the bottom of the heap
21         Package {
22         import_dirs    = [],
23         library_dirs   = if _HaveLibGmp == "YES"
24                              then []
25                              else if installing 
26                                    then [ _libdir ]
27                                    else [ ghc_src_dir _GHC_RUNTIME_DIR ++ "/gmp" ],
28         libraries      = [ "gmp" ],
29         include_dir    = "",
30         c_include      = "",
31         package_deps   = [],
32         extra_ghc_opts = "",
33         extra_cc_opts  = "",
34         extra_ld_opts  = ""
35         }
36        ),
37
38       ( "rts",  -- The RTS is just another package!
39         Package {
40         import_dirs    = [],
41         library_dirs   = [ if installing 
42                               then _libdir
43                               else ghc_src_dir _GHC_RUNTIME_DIR ],
44         libraries      = [ "HSrts" ],
45         include_dir    = if installing 
46                             then "" 
47                             else ghc_src_dir _GHC_INCLUDE_DIR,
48         c_include      = "Stg.h",               -- ha!
49         package_deps   = [ "gmp" ],
50         extra_ghc_opts = "",
51         extra_cc_opts  = "",
52                 -- the RTS forward-references to a bunch of stuff in the prelude,
53                 -- so we force it to be included with special options to ld.
54         extra_ld_opts  = unwords [
55          "-u PrelMain_mainIO_closure",
56          "-u PrelBase_Izh_static_info",
57          "-u PrelBase_Czh_static_info",
58          "-u PrelFloat_Fzh_static_info",
59          "-u PrelFloat_Dzh_static_info",
60          "-u PrelAddr_Azh_static_info",
61          "-u PrelAddr_Wzh_static_info",
62          "-u PrelAddr_I64zh_static_info",
63          "-u PrelAddr_W64zh_static_info",
64          "-u PrelStable_StablePtr_static_info",
65          "-u PrelBase_Izh_con_info",
66          "-u PrelBase_Czh_con_info",
67          "-u PrelFloat_Fzh_con_info",
68          "-u PrelFloat_Dzh_con_info",
69          "-u PrelAddr_Azh_con_info",
70          "-u PrelAddr_Wzh_con_info",
71          "-u PrelAddr_I64zh_con_info",
72          "-u PrelAddr_W64zh_con_info",
73          "-u PrelStable_StablePtr_con_info",
74          "-u PrelBase_False_closure",
75          "-u PrelBase_True_closure",
76          "-u PrelPack_unpackCString_closure",
77          "-u PrelException_stackOverflow_closure",
78          "-u PrelException_heapOverflow_closure",
79          "-u PrelException_NonTermination_closure",
80          "-u PrelException_PutFullMVar_closure",
81          "-u PrelException_BlockedOnDeadMVar_closure",
82          "-u PrelWeak_runFinalizzerBatch_closure",
83          "-u __init_Prelude",
84          "-u __init_PrelMain"
85          ]
86         }
87       ),
88
89       ( "std",  -- The Prelude & Standard Libraries
90         Package {
91         import_dirs    = [ if installing 
92                              then _libdir ++ "/imports/std"
93                              else ghc_src_dir _GHC_LIB_DIR ++ "/std" ],
94         library_dirs   = if installing 
95                            then [ _libdir ]
96                            else [ ghc_src_dir _GHC_LIB_DIR ++ "/std"
97                                 , ghc_src_dir _GHC_LIB_DIR ++ "/std/cbits" ],
98         libraries      = [ "HSstd", "HSstd_cbits" ],
99         include_dir    = if installing 
100                            then "" 
101                            else ghc_src_dir _GHC_LIB_DIR ++ "/std/cbits",
102         c_include      = "HsStd.h",
103         package_deps   = [ "rts" ],
104         extra_ghc_opts = "",
105         extra_cc_opts  = "",
106         extra_ld_opts  = "-lm"
107         }
108        ),
109
110        ( "lang",
111          Package { 
112          import_dirs    = if installing 
113                            then [ _libdir ++ "/imports/lang" ]
114                            else [ _FPTOOLS_TOP_ABS ++ "/hslibs/lang"
115                                 , _FPTOOLS_TOP_ABS ++ "/hslibs/lang/monads"],
116          library_dirs   = if installing 
117                              then [ _libdir ]
118                              else [ _FPTOOLS_TOP_ABS ++ "/hslibs/lang"
119                                   , _FPTOOLS_TOP_ABS ++ "/hslibs/lang/cbits" ],
120          libraries      = [ "HSlang", "HSlang_cbits" ],
121          include_dir    = if installing 
122                              then "" 
123                              else _FPTOOLS_TOP_ABS ++ "/hslibs/lang/cbits",
124          c_include      = "HsLang.h",
125          package_deps   = [],
126          extra_ghc_opts = "",
127          extra_cc_opts  = "",
128          extra_ld_opts  = ""
129         }
130        ),
131
132        ( "concurrent",
133          Package {
134          import_dirs    = [ if installing 
135                                 then _libdir ++ "/imports/concurrent"
136                                 else _FPTOOLS_TOP_ABS ++ "/hslibs/concurrent" ],
137          library_dirs   = [ if installing 
138                                 then _libdir
139                                 else _FPTOOLS_TOP_ABS ++ "/hslibs/concurrent" ],
140          libraries      = [ "HSconcurrent" ],
141          include_dir    = if installing 
142                             then "" 
143                             else _FPTOOLS_TOP_ABS ++ "/hslibs/concurrent/cbits",
144          c_include      = "HsConcurrent.h",
145          package_deps   = [ "lang" ],
146          extra_ghc_opts = "",
147          extra_cc_opts  = "",
148          extra_ld_opts  = ""
149         }
150        ),
151
152        ( "data",
153          Package {
154          import_dirs    = if installing 
155                              then [ _libdir ++ "/imports/data" ]
156                              else [ _FPTOOLS_TOP_ABS ++ "/hslibs/data"
157                                   , _FPTOOLS_TOP_ABS ++ "/hslibs/data/edison"
158                                   , _FPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Assoc"
159                                   , _FPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Coll"
160                                   , _FPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Seq" ],
161          library_dirs   = if installing 
162                              then [_libdir ]
163                              else [ _FPTOOLS_TOP_ABS ++ "/hslibs/data" ],
164          libraries      = [ "HSdata" ],
165          include_dir    = if installing 
166                              then "" 
167                              else _FPTOOLS_TOP_ABS ++ "/hslibs/data/cbits",
168          c_include      = "HsData.h",
169          package_deps   = [ "lang" ],
170          extra_ghc_opts = "",
171          extra_cc_opts  = "",
172          extra_ld_opts  = ""
173         }
174        ),
175
176        ( "net",
177          Package {
178          import_dirs    = if installing 
179                              then [ _libdir ++ "/imports/net" ]
180                              else [ _FPTOOLS_TOP_ABS ++ "/hslibs/net" ],
181          library_dirs   = if installing 
182                              then [ _libdir ]
183                              else [ _FPTOOLS_TOP_ABS ++ "/hslibs/net"
184                                   , _FPTOOLS_TOP_ABS ++ "/hslibs/net/cbits" ],
185          libraries      = [ "HSnet", "HSnet_cbits" ],
186          include_dir    = if installing 
187                              then "" 
188                              else _FPTOOLS_TOP_ABS ++ "/hslibs/net/cbits",
189          c_include      = "HsNet.h",
190          package_deps   = [ "lang", "text" ],
191          extra_ghc_opts = "",
192          extra_cc_opts  = "",
193          extra_ld_opts  = if postfixMatch "solaris2" _TARGETPLATFORM
194                                 then "-lnsl -lsocket"
195                                 else ""
196         }
197        ),
198
199        ( "posix",
200          Package {
201          import_dirs    = if installing 
202                              then [ _libdir ++ "/imports/posix" ]
203                              else [ _FPTOOLS_TOP_ABS ++ "/hslibs/posix" ],
204          library_dirs   = if installing 
205                              then [ _libdir ]
206                              else [ _FPTOOLS_TOP_ABS ++ "/hslibs/posix"
207                                   , _FPTOOLS_TOP_ABS ++ "/hslibs/posix/cbits" ],
208          libraries      = [ "HSposix", "HSposix_cbits" ],
209          include_dir    = if installing 
210                              then "" 
211                              else _FPTOOLS_TOP_ABS ++ "/hslibs/posix/cbits",
212          c_include      = "HsPosix.h",
213          package_deps   = [ "lang" ],
214          extra_ghc_opts = "",
215          extra_cc_opts  = "",
216          extra_ld_opts  = ""
217         }
218        ),
219
220        ( "text",
221          Package {
222          import_dirs    = if installing 
223                              then [ _libdir ++ "/imports/text" ]
224                              else [ _FPTOOLS_TOP_ABS ++ "/hslibs/text" 
225                                   , _FPTOOLS_TOP_ABS ++ "/hslibs/text/html" 
226                                   , _FPTOOLS_TOP_ABS ++ "/hslibs/text/haxml/lib" 
227                                   , _FPTOOLS_TOP_ABS ++ "/hslibs/text/parsec" ],
228          library_dirs   = if installing 
229                              then [ _libdir ]
230                              else [ _FPTOOLS_TOP_ABS ++ "/hslibs/text"
231                                   , _FPTOOLS_TOP_ABS ++ "/hslibs/text/cbits" ],
232          libraries      = [ "HStext", "HStext_cbits" ],
233          include_dir    = if installing 
234                              then "" 
235                              else _FPTOOLS_TOP_ABS ++ "/hslibs/text/cbits",
236          c_include      = "HsText.h",
237          package_deps   = [ "lang", "data" ],
238          extra_ghc_opts = "",
239          extra_cc_opts  = "",
240          extra_ld_opts  = ""
241         }
242        ),
243
244        ( "util",
245          Package {
246          import_dirs    = if installing 
247                              then [ _libdir ++ "/imports/util" ]
248                              else [ _FPTOOLS_TOP_ABS ++ "/hslibs/util"
249                                   , _FPTOOLS_TOP_ABS ++ "/hslibs/util/check" ],
250          library_dirs   = if installing 
251                              then [ _libdir ]
252                              else [ _FPTOOLS_TOP_ABS ++ "/hslibs/util"
253                                   , _FPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
254          libraries      = [ "HSutil", "HSutil_cbits" ],
255          include_dir    = if installing 
256                              then "" 
257                              else _FPTOOLS_TOP_ABS ++ "/hslibs/util/cbits",
258          c_include      = "HsUtil.h",
259          package_deps   = ["lang", "concurrent", "posix"],
260          extra_ghc_opts = "",
261          extra_cc_opts  = "",
262          extra_ld_opts  = ""
263         }
264        ),
265
266        ( "win32",
267          Package {
268          import_dirs    = if installing 
269                              then [ _libdir ++ "/imports/win32" ]
270                              else [ _FPTOOLS_TOP_ABS ++ "/hslibs/win32/src" ],
271          library_dirs   = if installing 
272                              then [ _libdir ]
273                              else [ _FPTOOLS_TOP_ABS ++ "/hslibs/win32/src" ],
274          libraries      = [ "HSwin32" ],
275          include_dir    = "",
276          c_include      = "",           -- ???
277          package_deps   = ["lang"],
278          extra_ghc_opts = "",
279          extra_cc_opts  = "",
280          extra_ld_opts  = "-luser32 -lgdi32"
281         }
282        ),
283
284        ( "com",
285          Package {
286          import_dirs    = if installing 
287                              then [ _libdir ++ "/imports/com" ]
288                              else [ _FPTOOLS_TOP_ABS ++ "/hdirect/lib" ],
289          library_dirs   = if installing 
290                              then [ _libdir ]
291                              else [ _FPTOOLS_TOP_ABS ++ "/hdirect/lib" ],
292          libraries      = [ "HScom" ],
293          include_dir    = "",
294          c_include      = "",           -- ???
295          package_deps   = [ "lang" ],
296          extra_ghc_opts = "",
297          extra_cc_opts  = "",
298          extra_ld_opts  = "-luser32 -lole32 -loleaut32 -ladvapi32"
299         }
300        )
301    ]
302
303 ghc_src_dir path = _FPTOOLS_TOP_ABS ++ '/':_CURRENT_DIR ++ '/':path
304
305 prefixMatch :: Eq a => [a] -> [a] -> Bool
306 prefixMatch [] str = True
307 prefixMatch pat [] = False
308 prefixMatch (p:ps) (s:ss) | p == s    = prefixMatch ps ss
309                           | otherwise = False
310
311 postfixMatch :: String -> String -> Bool
312 postfixMatch pat str = prefixMatch (reverse pat) (reverse str)