[project @ 2000-05-12 11:55:52 by rrt]
[ghc-hetmet.git] / ghc / utils / mkdependHS / mkdependHS.prl
index 4919a0a..93d08b3 100644 (file)
@@ -24,7 +24,7 @@ Options recognised wherever they occur (mkdependHS or GHC):
                to search for "import"ed modules
     -I<dir>    Add <dir> to list of directories to search for
                .h files (i.e., usual meaning)
-    -syslib <blah> This program uses this GHC system library; take
+    -package <blah> This program uses this GHC system library; take
                appropriate action (e.g., recognise when they are
                "import"ing a module from that library).
 
@@ -52,7 +52,7 @@ mkdependHS-specific options (not between --'s):
     --include-prelude
                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
+                various system libraries. If a -package option is used, dependencies
                 will also be generated on the library's interfaces.
     --include-module=<file> 
                 Regard <file> as not "stable"; i.e., generate dependencies
@@ -99,12 +99,14 @@ $Import_dirs = '.';
 # directories to considered stable.
 @Ignore_dirs = ();
 
+%ModuleIn = ();
+
 $Include_dirs = '-I.';
 $Makefile = '';
 @Src_files = ();
 $Include_prelude = 0;
 @Defines = ();
-$WarnOddOptions=1;
+$ProcessingOptions=0;
 
 # Delete temp. file if script is halted.
 sub quit_upon_signal { print STDERR "Deleting $Tmp_prefix.hs .. \n"; unlink "$Tmp_prefix.hs"; }
@@ -228,18 +230,22 @@ sub mangle_command_line_args {
            $Import_dirs = "$1:$Import_dirs";
        } elsif ( /^-I/ ) {
            $Include_dirs .= " $_";
-       } elsif ( /^-syslib$/ ) {
+       } elsif ( /^-syslib$/ ) { # deprecated, use -syslib
+           push(@Syslibs, &grab_arg_arg(*Args,$_,''));
+       } elsif ( /^-package$/ ) {
            push(@Syslibs, &grab_arg_arg(*Args,$_,''));
        } elsif ( /^-fglasgow-exts$/ ) {
-           push(@Syslibs, 'exts');
+           push(@Syslibs, 'lang');
        } elsif ( /^-concurrent$/ ) {
            push(@Syslibs, 'concurrent');
+       } elsif (/^-#include(.*)/) {
+           &grab_arg_arg(*Args,$_,'');
        } elsif ($Dashdashes_seen != 1) { # not between -- ... --
            if ( /^-v$/ ) {
                $Verbose++;
            } elsif ( /^-w$/ ) {
                $Warnings     = 0;
-           } elsif ( /^-f(.*)/ ) {
+           } elsif ( /^-f(.*)/ && !$ProcessingOptions ) {
                $Makefile       = &grab_arg_arg(*Args,'-f',$1);
            } elsif ( /^-o(.*)/ ) {
                local($suff)    = &grab_arg_arg(*Args,'-o',$1);
@@ -266,7 +272,7 @@ sub mangle_command_line_args {
                local($suff)    =  &grab_arg_arg(*Args,'-s',$1);
                push(@File_suffix, $suff);
            } elsif ( /^-/ ) {
-               if ($WarnOddOptions) {
+               if (!$ProcessingOptions) {
                   print STDERR "$Pgm: unknown option ignored: $_\n";
                   $Status++;
                }
@@ -318,13 +324,31 @@ sub gather_import_dirs {
           local($dir);
 
            # Yuck ^ 2
+           if ( $lib eq 'lang' && ! $INSTALLING ) {
+              push(@Import_dirs, "${TopPwd}/hslibs/${lib}/monads");
+          }
+           if ( $lib eq 'text' && ! $INSTALLING ) {
+              push(@Import_dirs, "${TopPwd}/hslibs/${lib}/html");
+              push(@Import_dirs, "${TopPwd}/hslibs/${lib}/haxml/lib");
+          }
+           if ( $lib eq 'data' && ! $INSTALLING ) {
+              push(@Import_dirs, "${TopPwd}/hslibs/${lib}/edison");
+              push(@Import_dirs, "${TopPwd}/hslibs/${lib}/edison/Assoc");
+              push(@Import_dirs, "${TopPwd}/hslibs/${lib}/edison/Coll");
+              push(@Import_dirs, "${TopPwd}/hslibs/${lib}/edison/Seq");
+          }
+           if ( $lib eq 'util' && ! $INSTALLING ) {
+              push(@Import_dirs, "${TopPwd}/hslibs/${lib}/check");
+          }
+
+           # Yuck ^ 3
            if ( $lib eq 'win32' && ! $INSTALLING ) {
               $dir = "${TopPwd}/hslibs/${lib}/src";
            } elsif ( $lib eq 'com' && ! $INSTALLING ) {
               $dir = "${TopPwd}/hdirect/lib";
            } else {
               $dir = ($INSTALLING) ? "${InstLibDirGhc}/imports/${lib}" 
-                                  : "${TopPwd}/ghc/lib/${lib}";
+                                  : "${TopPwd}/hslibs/${lib}";
            }
           if (!$Include_prelude) {
               push(@Ignore_dirs,$dir);
@@ -341,7 +365,6 @@ sub preprocess_import_dirs {
     # the @Import_dirs before we start processing.
     local($d, $thing);
     local($_);
-    %ModuleIn = ();
 
     foreach $d ( @Import_dirs ) {
         # Check to see if it can be ignored
@@ -353,11 +376,7 @@ sub preprocess_import_dirs {
        for ($_ = readdir(DIR); $_; $_ = readdir(DIR)) {
            next unless /(.*)\.hi$/;
            $thing = $1;
-           # 
-           # dLL_ifs.hi is used to indicate whether a directory
-           # contains interface files whose object codes reside in a Win32 DLL.
-           # 
-           if ($ModuleIn{$thing} && $ModuleIn{$thing} ne $d && $thing ne 'dLL_ifs') {
+           if ($ModuleIn{$thing} && $ModuleIn{$thing} ne $d) {
                print STDERR "$Pgm: warning: $thing.hi appears in both $ModuleIn{$thing} and $d!\n" if ($Warnings);
            } else {
                $ModuleIn{$thing} = $d;
@@ -416,8 +435,8 @@ sub slurp_file_for_imports {
     $options = &check_for_source_options($file_to_read);
     if ($options ne "") {
       @Old_Syslibs=@Syslibs;
-      $WarnOddOptions=0;
-      &mangle_command_line_args(split(/ /,$options));
+      $ProcessingOptions=1;
+      &mangle_command_line_args(split(/\s+/,$options));
       if (@Old_Syslibs ne @Syslibs) {
         $found_options=1;
        @Old_Ignore_dirs = @Ignore_dirs;
@@ -457,7 +476,9 @@ sub slurp_file_for_imports {
        &process_dependency($todo,$source,$modname);
     }
 
-    @Ignore_dirs = @Old_Ignore_dirs if ($found_options);
+    if ($found_options) {
+      @Ignore_dirs = @Old_Ignore_dirs;
+    }
 
     close(SRCFILE) || exit(1);
     # remove temporary file, if any.