[project @ 1998-02-18 09:27:43 by sof]
[ghc-hetmet.git] / ghc / utils / mkdependHS / mkdependHS.prl
index f76bee6..c7b5488 100644 (file)
@@ -3,7 +3,7 @@
 #
 #  RAWCPP TMPDIR TOP_PWD
 #  libdir libexecdir datadir INSTALLING
-#  PROJECTVERSION SED 
+#  ProjectVersionInt SED 
 #
 # tries to work like mkdependC - capable of dealing with:
 #
@@ -49,7 +49,7 @@ mkdependHS-specific options (not between --'s):
                 don't generate any dependencies on modules therein.
     -Xdirs      same as --exclude-directory
     --include-prelude
-               Regard prelude library as unstable, i.e., generate dependencies
+               Regard prelude libraries as unstable, i.e., generate dependencies
                on prelude modules. This option is normally only used by the
                 various system libraries. If a -syslib option is used, dependencies
                 will also be generated on the library's interfaces.
@@ -87,7 +87,7 @@ $Begin_magic_str = "# DO NOT DELETE: Beginning of Haskell dependencies\n";
 $End_magic_str = "# DO NOT DELETE: End of Haskell dependencies\n";
 @Obj_suffix =  ("o");
 @File_suffix = ();
-$ghc_version_info = int ( ${PROJECTVERSION} * 100 );
+$ghc_version_info = ${ProjectVersionInt};
 
 $Import_dirs = '.';
 %Syslibs = ();
@@ -117,11 +117,8 @@ push(@Defines,
 
 # set up array of ignored modules
 local(@dirs) = ($INSTALLING) ? 
-              ("$InstLibDirGhc/imports")
-            : ("$TopPwd/ghc/lib/ghc",
-               "$TopPwd/ghc/lib/required",
-               "$TopPwd/ghc/lib/glaExts",
-               "$TopPwd/ghc/lib/concurrent");
+              ("$InstLibDirGhc/imports/std")
+            : ("$TopPwd/ghc/lib/std");
 if (!$Include_prelude) {
     push(@Ignore_dirs, @dirs);
 } else {
@@ -130,8 +127,8 @@ if (!$Include_prelude) {
 
 foreach $lib ( @Syslibs ) {
     local($dir) = 
-      ($INSTALLING) ? "${InstHsLibDirGhc}/${lib}/imports" 
-                   : "${TopPwd}/hslibs/${lib}/src";
+      ($INSTALLING) ? "${InstLibDirGhc}/imports/${lib}" 
+                   : "${TopPwd}/ghc/lib/${lib}";
     if (!$Include_prelude) {
        push(@Ignore_dirs,$dir);
     } else {
@@ -196,16 +193,15 @@ foreach $sf (@Src_files) {
 }
 
 
-# OK, mangle the Makefile
-unlink("$Makefile.bak");
-
 #
-# If no output file exist as yet, create one.
+# Create backup version of output file.
 # 
-if ( ! -f $Makefile.bak ) {
-   system("touch $Makefile.bak");
-} 
-if ( -f $Makefile ) {
+if ( ! -f $Makefile ) {
+   # truncate() may not be implemented, so we
+   # play it safe here.
+   local(*TRUNC);
+   open(TRUNC,"> $Makefile.bak") && close(TRUNC);
+} else {
    rename($Makefile,"$Makefile.bak");
 }
 # now copy Makefile.bak into Makefile, rm'ing old dependencies
@@ -248,6 +244,8 @@ sub mangle_command_line_args {
            $Include_dirs .= " $_";
        } elsif ( /^-syslib$/ ) {
            push(@Syslibs, &grab_arg_arg($_,''));
+       } elsif ( /^-fglasgow-exts$/ ) {
+           push(@Syslibs, 'exts');
        } elsif ($Dashdashes_seen != 1) { # not between -- ... --
            if ( /^-v$/ ) {
                $Verbose++;
@@ -285,10 +283,16 @@ sub mangle_command_line_args {
            } else {
                push(@Src_files, $_);
            }
-
-       } elsif ($Dashdashes_seen == 1) { # where we ignore unknown options
-           push(@Src_files, $_) if ! /^-/;
-       }
+        }
+        # Removed support for picking up plausible source file 
+        # names inside the ghc options chunk of the command
+        # line. It failed to deal with `option-value' stuff present
+        # on some invocations of ghc (e.g., "-ohi foo.baz").
+        #  -- sof 12/97
+       #
+       # } elsif ($Dashdashes_seen == 1) {
+       #     push(@Src_files, $_) if ! /^-/;
+       # }
     }
     @File_suffix = sort (@File_suffix);
 }