[project @ 2001-04-30 11:37:36 by panne]
[ghc-hetmet.git] / ghc / driver / PackageSrc.hs
index 22fbf4b..cd488d1 100644 (file)
@@ -1,25 +1,40 @@
+#include "../includes/config.h"
+
 module Main (main) where
 
+import Utils
+
 import IO
 import System
-import Config
 import Package
 
 main :: IO ()
 main = do
   args <- getArgs
   case args of
-        [ "install"  ] -> do { putStrLn (dumpPackages (package_details True)) }
-        [ "in-place" ] -> do { putStrLn (dumpPackages (package_details False)) }
-        _ -> do hPutStr stderr "usage: pkgconf (install | in-place)\n"
-                exitWith (ExitFailure 1)
+     ("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)
+
+package_details :: Bool -> [String] -> [PackageConfig]
+package_details installing
+ [ cTARGETPLATFORM
+ , cCURRENT_DIR
+ , cHaveLibGmp
+ , cLibsReadline
+ , clibdir
+ , cGHC_LIB_DIR
+ , cGHC_RUNTIME_DIR
+ , cGHC_UTILS_DIR
+ , cGHC_INCLUDE_DIR
+ , cFPTOOLS_TOP_ABS ] =
 
-package_details :: Bool -> [Package]
-package_details installing =
  [
         Package {
        name           = "gmp",  -- GMP is at the bottom of the heap
         import_dirs    = [],
+        source_dirs    = [],
         library_dirs   = if cHaveLibGmp == "YES"
                             then []
                             else if installing
@@ -38,11 +53,16 @@ package_details installing =
         Package {
        name           = "rts",  -- The RTS is just another package!
         import_dirs    = [],
+        source_dirs    = [],
         library_dirs   = if installing
                             then [ clibdir ]
                             else [ ghc_src_dir cGHC_RUNTIME_DIR ],
         hs_libraries      = [ "HSrts" ],
+#ifndef mingw32_TARGET_OS
        extra_libraries   = [],
+#else
+        extra_libraries   = [ "winmm" ], -- for the threadDelay timer
+#endif
         include_dirs   = if installing
                             then [ clibdir ++ "/includes" ]
                             else [ ghc_src_dir cGHC_INCLUDE_DIR ],
@@ -52,37 +72,43 @@ package_details installing =
         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.
-        extra_ld_opts  = [
-           "-u PrelMain_mainIO_closure"
-         , "-u PrelBase_Izh_static_info"
-         , "-u PrelBase_Czh_static_info"
-         , "-u PrelFloat_Fzh_static_info"
-         , "-u PrelFloat_Dzh_static_info"
-         , "-u PrelAddr_Azh_static_info"
-         , "-u PrelAddr_Wzh_static_info"
-         , "-u PrelAddr_I64zh_static_info"
-         , "-u PrelAddr_W64zh_static_info"
-         , "-u PrelStable_StablePtr_static_info"
-         , "-u PrelBase_Izh_con_info"
-         , "-u PrelBase_Czh_con_info"
-         , "-u PrelFloat_Fzh_con_info"
-         , "-u PrelFloat_Dzh_con_info"
-         , "-u PrelAddr_Azh_con_info"
-         , "-u PrelAddr_Wzh_con_info"
-         , "-u PrelAddr_I64zh_con_info"
-         , "-u PrelAddr_W64zh_con_info"
-         , "-u PrelStable_StablePtr_con_info"
-         , "-u PrelBase_False_closure"
-         , "-u PrelBase_True_closure"
-         , "-u PrelPack_unpackCString_closure"
-         , "-u PrelIOBase_stackOverflow_closure"
-         , "-u PrelIOBase_heapOverflow_closure"
-         , "-u PrelIOBase_NonTermination_closure"
-         , "-u PrelIOBase_PutFullMVar_closure"
-         , "-u PrelIOBase_BlockedOnDeadMVar_closure"
-         , "-u PrelWeak_runFinalizzerBatch_closure"
-         , "-u __init_Prelude"
-         , "-u __init_PrelMain"
+        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"
+         , "PrelPtr_Ptr_static_info"
+         , "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"
+         , "PrelStable_StablePtr_static_info"
+         , "PrelBase_Izh_con_info"
+         , "PrelBase_Czh_con_info"
+         , "PrelFloat_Fzh_con_info"
+         , "PrelFloat_Dzh_con_info"
+         , "PrelPtr_Ptr_con_info"
+         , "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"
          ]
         },
 
@@ -91,12 +117,19 @@ package_details installing =
        import_dirs    = if installing
                             then [ clibdir ++ "/imports/std" ]
                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std" ],
+        source_dirs    = [],
         library_dirs   = if installing
                             then [ clibdir ]
                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std"
                                  , ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
         hs_libraries      = [ "HSstd" ],
-       extra_libraries   = [ "HSstd_cbits" ],
+       extra_libraries   = [ "HSstd_cbits" ] ++
+#                           ifdef mingw32_TARGET_OS
+                            ["wsock32", "msvcrt"]
+#                           else
+                            ["m"]   -- libm, that is
+#                           endif
+                            ,
         include_dirs   = if installing
                             then []
                             else [ ghc_src_dir cGHC_LIB_DIR ++ "/std/cbits" ],
@@ -104,7 +137,7 @@ package_details installing =
         package_deps   = [ "rts" ],
         extra_ghc_opts = [],
         extra_cc_opts  = [],
-        extra_ld_opts  = [ "-lm" ]
+        extra_ld_opts  = []
         },
 
          Package { 
@@ -113,6 +146,7 @@ package_details installing =
                              then [ clibdir ++ "/imports/lang" ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/lang"
                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/lang/monads" ],
+         source_dirs    = [],
          library_dirs   = if installing
                              then [ clibdir ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/lang"
@@ -126,7 +160,13 @@ package_details installing =
          package_deps   = [],
          extra_ghc_opts = [],
          extra_cc_opts  = [],
-         extra_ld_opts  = []
+         extra_ld_opts  = [
+#ifndef LEADING_UNDERSCORE
+                         "-u Addr_Azh_static_info"
+#else
+                         "-u _Addr_Azh_static_info"
+#endif
+                       ]
         },
 
          Package {
@@ -134,6 +174,7 @@ package_details installing =
          import_dirs    = if installing
                              then [ clibdir ++ "/imports/concurrent" ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent" ],
+         source_dirs    = [],
          library_dirs   = if installing
                              then [ clibdir ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent" ],
@@ -142,7 +183,7 @@ package_details installing =
          include_dirs   = if installing
                              then []
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/concurrent/cbits" ],
-         c_includes     = [ "HsConcurrent.h" ],
+         c_includes     = [],
          package_deps   = [ "lang" ],
          extra_ghc_opts = [],
          extra_cc_opts  = [],
@@ -158,6 +199,7 @@ package_details installing =
                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Assoc"
                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Coll"
                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/data/edison/Seq" ],
+         source_dirs    = [],
          library_dirs   = if installing
                              then [clibdir ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data" ],
@@ -166,8 +208,8 @@ package_details installing =
          include_dirs   = if installing
                              then []
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/data/cbits" ],
-         c_includes     = [ "HsData.h" ],
-         package_deps   = [ "lang" ],
+         c_includes     = [],
+         package_deps   = [ "lang", "util" ],
          extra_ghc_opts = [],
          extra_cc_opts  = [],
          extra_ld_opts  = []
@@ -178,22 +220,24 @@ package_details installing =
          import_dirs    = if installing
                              then [ clibdir ++ "/imports/net" ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net" ],
+         source_dirs    = [],
          library_dirs   = if installing
                              then [ clibdir ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net"
                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/net/cbits" ],
          hs_libraries      = [ "HSnet" ],
-        extra_libraries   = [ "HSnet_cbits" ],
+        extra_libraries   = if suffixMatch "solaris2" cTARGETPLATFORM
+                                then [ "nsl",  "socket" ]
+                                else []
+                             ,
          include_dirs   = if installing
                              then []
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/net/cbits" ],
          c_includes     = [ "HsNet.h" ],
-         package_deps   = [ "lang", "text" ],
+         package_deps   = [ "lang", "text", "concurrent" ],
          extra_ghc_opts = [],
          extra_cc_opts  = [],
-         extra_ld_opts  = if postfixMatch "solaris2" cTARGETPLATFORM
-                             then [ "-lnsl",  "-lsocket" ]
-                             else []
+         extra_ld_opts  = []
         },
 
          Package {
@@ -201,6 +245,7 @@ package_details installing =
          import_dirs    = if installing
                              then [ clibdir ++ "/imports/posix" ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix" ],
+         source_dirs    = [],
          library_dirs   = if installing
                              then [ clibdir ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/posix"
@@ -223,8 +268,9 @@ package_details installing =
                              then [ clibdir ++ "/imports/text" ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text" 
                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/html" 
-                                  , cFPTOOLS_TOP_ABS ++ "/hslibs/text/haxml/lib" 
+                                  , cFPTOOLS_TOP_ABS ++ "/hslibs/text/HaXml/lib" 
                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/text/parsec" ],
+         source_dirs    = [],
          library_dirs   = if installing
                              then [ clibdir ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text"
@@ -235,7 +281,7 @@ package_details installing =
                              then []
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/text/cbits" ],
          c_includes     = [ "HsText.h" ],
-         package_deps   = [ "lang", "data" ],
+         package_deps   = [ "lang" ],
          extra_ghc_opts = [],
          extra_cc_opts  = [],
          extra_ld_opts  = []
@@ -247,6 +293,7 @@ package_details installing =
                              then [ clibdir ++ "/imports/util" ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util"
                                   , cFPTOOLS_TOP_ABS ++ "/hslibs/util/check" ],
+         source_dirs    = [],
          library_dirs   = if installing
                              then [ clibdir ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util"
@@ -257,10 +304,14 @@ package_details installing =
                              then []
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
          c_includes     = [ "HsUtil.h" ],
-         package_deps   = [ "lang", "concurrent", "posix" ],
+         package_deps   = [ "lang", "concurrent"
+#ifndef mingw32_TARGET_OS
+                           , "posix"
+#endif
+                         ],
          extra_ghc_opts = [],
          extra_cc_opts  = [],
-         extra_ld_opts  = []
+         extra_ld_opts  = words cLibsReadline
         },
 
         -- no cbits at the moment, we'll need to add one if this library
@@ -270,6 +321,7 @@ package_details installing =
          import_dirs    = if installing
                              then [ clibdir ++ "/imports/hssource" ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/hssource" ],
+         source_dirs    = [],
          library_dirs   = if installing
                              then [ clibdir ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hslibs/hssource" ],
@@ -284,21 +336,41 @@ package_details installing =
         },
 
          Package {
+        name         = "greencard",
+         import_dirs    = if installing
+                             then [ clibdir ++ "/imports/greencard" ]
+                            else [ cFPTOOLS_TOP_ABS ++ "/green-card/lib/ghc" ],
+         source_dirs    = [],
+         library_dirs   = if installing
+                             then [ clibdir ]
+                             else [ cFPTOOLS_TOP_ABS ++ "/green-card/lib/ghc" ],
+         hs_libraries      = [ "HSgreencard" ],
+         extra_libraries   = [],
+         include_dirs   = [],
+         c_includes     = [],
+         package_deps   = [ "lang" ],
+         extra_ghc_opts = [],
+         extra_cc_opts  = [],
+         extra_ld_opts  = [],
+        },
+
+         Package {
          name         = "win32",
         import_dirs    = if installing
                              then [ clibdir ++ "/imports/win32" ]
-                             else [ cFPTOOLS_TOP_ABS ++ "/hslibs/win32/src" ],
+                             else [ cFPTOOLS_TOP_ABS ++ "/hslibs/win32" ],
+         source_dirs    = [],
          library_dirs   = if installing
                              then [ clibdir ]
-                             else [ cFPTOOLS_TOP_ABS ++ "/hslibs/win32/src" ],
+                             else [ cFPTOOLS_TOP_ABS ++ "/hslibs/win32" ],
          hs_libraries      = [ "HSwin32" ],
-        extra_libraries   = [],
+        extra_libraries   = [ "user32",  "gdi32", "winmm" ],
          include_dirs   = [],
          c_includes     = [],           -- ???
-         package_deps   = [ "lang" ],
+         package_deps   = [ "lang", "greencard" ],
          extra_ghc_opts = [],
          extra_cc_opts  = [],
-         extra_ld_opts  = [ "-luser32",  "-lgdi32" ]
+         extra_ld_opts  = []
         },
 
          Package {
@@ -306,28 +378,20 @@ package_details installing =
          import_dirs    = if installing
                              then [ clibdir ++ "/imports/com" ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hdirect/lib" ],
+         source_dirs    = [],
          library_dirs   = if installing
                              then [ clibdir ]
                              else [ cFPTOOLS_TOP_ABS ++ "/hdirect/lib" ],
          hs_libraries      = [ "HScom" ],
-        extra_libraries   = [],
+        extra_libraries   = [ "user32",  "ole32",  "oleaut32", "advapi32" ],
          include_dirs   = [],
          c_includes     = [],           -- ???
          package_deps   = [ "lang" ],
          extra_ghc_opts = [],
          extra_cc_opts  = [],
-         extra_ld_opts  = [ "-luser32",  "-lole32",  "-loleaut32", "-ladvapi32" ]
+         extra_ld_opts  = []
         }
    ]
-
-ghc_src_dir :: String -> String
-ghc_src_dir path = cFPTOOLS_TOP_ABS ++ '/':cCURRENT_DIR ++ '/':path
-
-prefixMatch :: Eq a => [a] -> [a] -> Bool
-prefixMatch [] _str = True
-prefixMatch _pat [] = False
-prefixMatch (p:ps) (s:ss) | p == s    = prefixMatch ps ss
-                          | otherwise = False
-
-postfixMatch :: String -> String -> Bool
-postfixMatch pat str = prefixMatch (reverse pat) (reverse str)
+  where
+       ghc_src_dir :: String -> String
+       ghc_src_dir path = cFPTOOLS_TOP_ABS ++ '/':cCURRENT_DIR ++ '/':path