-# *** MSUB does some substitutions here ***
-# *** grep for $( ***
#
-# tries to work like mkdependC
+# perl script expect the following variables to be prepended:
#
+# RAWCPP TMPDIR TOP_PWD
+# libdir libexecdir datadir INSTALLING
+# PROJECTVERSION SED
+#
+# tries to work like mkdependC - capable of dealing with:
+#
+# -literate Haskell code (Bird tracks or Glasgow literate style) (.lhs)
+# -straight Haskell source (.hs)
+# -literate or straight Happy specs (.ly)
+#
# ToDo: strip out all the .h junk
#
($Pgm = $0) =~ s/.*\/([^\/]+)$/\1/;
-$Usage = "usage: $Pgm: not done yet\n";
+$Usage = <<EOUSAGE;
+Usage: $Pgm [mkdependHS options] [-- GHC options --] srcfile1 [srcfile2 ...]
+
+Options recognised wherever they occur (mkdependHS or GHC):
+
+ -D<blah> A cpp #define; usual meaning
+ -i<dirs> Add <dirs> (colon-separated) to list of directories
+ 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
+ appropriate action (e.g., recognise when they are
+ "import"ing a module from that library).
+ -fhaskell1.[2-9] Deal with the oddities associated with a
+ particular version of Haskell 1.
+
+mkdependHS-specific options (not between --'s):
+
+ -v Be verbose.
+ -v -v Be very verbose.
+ -f blah Use "blah" as the makefile, rather than "makefile"
+ or "Makefile".
+ -o <osuf> Use <osuf> as the "object file" suffix ( default: .o)
+ -s <suf> Make extra dependencies for files with
+ suffix <suf><osuf>; thus, "-o .hc -s _a" will
+ make dependencies both for .hc files and for _a.hc
+ files. (Useful in conjunction with NoFib "ways".)
+ --exclude-module=<file>
+ Regard <file> as "stable"; i.e., eXclude it from having
+ dependencies on it.
+ -x same as --exclude-module
+ --exclude-directory=<dirs>
+ Regard : separated list of directories as containing stable,
+ don't generate any dependencies on modules therein.
+ -Xdirs same as --exclude-directory
+ --include-module=<file>
+ Regard <file> as not "stable"; i.e., generate dependencies
+ on it (if any). This option is normally used in conjunction
+ with the --exclude-directory option.
+
+EOUSAGE
$Status = 0; # just used for exit() status
-$Verbose = '';
+$Verbose = 0; # 1 => verbose, 2 => very verbose
$Dashdashes_seen = 0;
-$OrigCpp = '$(RAWCPP)';
-if ( $OrigCpp =~ /(\S+)\s+(.*)/ ) {
+# Try to guess how to run gcc's CPP directly -------------
+
+$OrigCpp = ${RAWCPP};
+if ( $OrigCpp !~ /(\S+)\s+(.*)/ ) {
+ $Cpp = $OrigCpp;
+} else {
$cmd = $1;
$rest = $2;
if ( -x $cmd ) { # cool
die "hscpp: don't know how to run cpp: $OrigCpp\n";
}
}
-} else {
- $Cpp = $OrigCpp;
}
-$Tmp_prefix = (( $ENV{'TMPDIR'} ) # to make tmp file names
- ? ($ENV{'TMPDIR'} . "/mkdependHS$$")
- : "$(TMPDIR)/mkdependHS$$" );
-
-#------------------------------------------------------------------------
-# If you are adjusting paths by hand for a binary GHC distribution,
-# de-commenting the line to set GLASGOW_HASKELL_ROOT should do.
-# Or you can leave it as is, and set the environment variable externally.
-#------------------------------------------------------------------------
-# $ENV{'GLASGOW_HASKELL_ROOT'} = '/some/absolute/path/name';
-
-if (! $ENV{'GLASGOW_HASKELL_ROOT'}) { # good -- death to environment variables
- $TopPwd = '$(TOP_PWD)';
- $InstLibDirGhc = '$(INSTLIBDIR_GHC)';
- $InstDataDirGhc = '$(INSTDATADIR_GHC)';
+if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
+ $Tmp_prefix = $ENV{'TMPDIR'} . "/mkdependHS$$";
} else {
- $TopPwd = $ENV{'GLASGOW_HASKELL_ROOT'};
-
- if ( '$(INSTLIBDIR_GHC)' =~ /\/local\/fp(\/.*)/ ) {
- $InstLibDirGhc = $ENV{'GLASGOW_HASKELL_ROOT'} . $1;
- } else {
- print STDERR "GLASGOW_HASKELL_ROOT environment variable is set;\nBut can't untangle $(INSTLIBDIR_GHC).\n(Installation error)\n";
- exit(1);
- }
-
- if ( '$(INSTDATADIR_GHC)' =~ /\/local\/fp(\/.*)/ ) {
- $InstDataDirGhc = $ENV{'GLASGOW_HASKELL_ROOT'} . $1;
- } else {
- print STDERR "GLASGOW_HASKELL_ROOT environment variable is set;\nBut can't untangle $(INSTDATADIR_GHC).\n(Installation error)\n";
- exit(1);
- }
+ $Tmp_prefix ="${TMPDIR}/mkdependHS$$";
+ $ENV{'TMPDIR'} = "${TMPDIR}"; # set the env var as well
}
-$Unlit = ( $(INSTALLING) ) ? "$InstLibDirGhc/unlit"
- : "$TopPwd/$(CURRENT_DIR)/$(GHC_UNLIT)";
+$TopPwd = "${TOP_PWD}";
+$InstLibDirGhc = "${libdir}";
+$InstLibExecDirGhc = "${libexecdir}";
+$InstHsLibDirGhc = "${libdir}/hslibs";
+$InstDataDirGhc = "${datadir}";
+
+$Unlit = ($INSTALLING) ? "${InstLibExecDirGhc}/unlit"
+ : "${TopPwd}/ghc/utils/unlit/unlit";
$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';
-$ghc_version_info = $(PROJECTVERSION) * 100;
-@Defines = ('-D__HASKELL1__=2', "-D__GLASGOW_HASKELL__=$ghc_version_info");
+$Obj_suffix = 'o';
+$ghc_version_info = int ( ${PROJECTVERSION} * 100 );
$Import_dirs = '.';
%Syslibs = ();
-%StableLibs = ();
-%PreludeIfaces = ( 'Prelude', '1',
- 'PreludeGlaST', '1',
- 'PreludeGlaMisc', '1',
- 'Concurrent', '1',
- 'Parallel', '1');
-%GhcLibIfaces = ( 'Bag', '1',
- 'BitSet', '1',
- # CharSeq not supposed to be used by user (I think. WDP)
- 'FiniteMap', '1',
- 'ListSetOps', '1',
- 'Maybes', '1',
- 'PackedString', '1',
- 'Regex', '1',
- 'MatchPS', '1',
- 'Readline', '1',
- 'Socket', '1',
- 'SocketPrim', '1',
- 'BSD', '1',
- 'Pretty', '1',
- 'Set', '1',
- 'Util', '1' );
-%HbcLibIfaces = ( 'Algebra', '1',
- 'Hash', '1',
- 'ListUtil', '1',
- 'Miranda', '1',
- 'NameSupply', '1',
- 'Native', '1',
- 'Number', '1',
- 'Parse', '1',
- 'Pretty', '1',
- 'Printf', '1',
- 'QSort', '1',
- 'Random', '1',
- 'SimpleLex', '1',
- 'Time', '1',
- 'Trace', '1',
- 'Word', '1' );
-%IO13Ifaces = ( 'LibSystem', '1',
- 'LibCPUTime', '1',
- 'LibDirectory', '1',
- 'LibPosix', '1',
- 'LibTime', '1' );
-
-$Haskell_1_3 = 0; # assume Haskell 1.2, still. Changed by -fhaskell-1.3
+%LibIfaces = (); # known prelude/syslib ifaces; read from a file
+
+%IgnoreMe = ();
+# directories to considered stable.
+@Ignore_dirs = ($INSTALLING) ?
+ ("$InstLibDirGhc/imports")
+ : ("$TopPwd/ghc/lib/ghc",
+ "$TopPwd/ghc/lib/required",
+ "$TopPwd/ghc/lib/glaExts",
+ "$TopPwd/ghc/lib/concurrent");
+
+$Haskell_1 = 3; # assume Haskell 1.3. Changed by -fhaskell-1.?
$Include_dirs = '-I.';
-$Col_width = 78; # ignored
$Makefile = '';
@Src_files = ();
&mangle_command_line_args();
+# set up array of ignored modules
+foreach $lib ( @Syslibs ) {
+ local($dir) =
+ ($INSTALLING) ? "${InstHsLibDirGhc}/${lib}/imports"
+ : "${TopPwd}/hslibs/${lib}/src";
+ push(@Ignore_dirs,$dir);
+}
+
+if ( $Status ) {
+ print stderr $Usage;
+ exit(1);
+}
+
+push(@Defines,
+ ("-D__HASKELL1__=$Haskell_1",
+ "-D__GLASGOW_HASKELL__=$ghc_version_info"));
+
+@Import_dirs = split(/:/,$Import_dirs);
+@Include_dirs = split(/\s+/,$Include_dirs); # still has -I's in it
+# NB: We keep the scalar-variable equivalents to use in error messages
+
if ( ! $Makefile && -f 'makefile' ) {
$Makefile = 'makefile';
} elsif ( ! $Makefile && -f 'Makefile') {
$Makefile = 'Makefile';
-} else {
+} elsif ( ! $Makefile) {
die "$Pgm: no makefile or Makefile found\n";
}
-@Depend_lines = ();
-
print STDERR "CPP defines=@Defines\n" if $Verbose;
-print STDERR "Import_dirs=$Import_dirs\n" if $Verbose;
-print STDERR "Include_dirs=$Include_dirs\n" if $Verbose;
+print STDERR "Import_dirs=@Import_dirs\n" if $Verbose;
+print STDERR "Include_dirs=@Include_dirs\n" if $Verbose;
+
+&preprocess_import_dirs();
+
+@Depend_lines = ();
foreach $sf (@Src_files) {
# just like lit-inputter
# a de-commenter (not implemented);
# builds up @Depend_lines
print STDERR "Here we go for source file: $sf\n" if $Verbose;
- ($bf = $sf) =~ s/\.l?hs$//;
- push(@Depend_lines, "$bf$Obj_suffix : $sf\n");
+ ($bf = $sf) =~ s/\.l?(hs|y)$//;
+ #push(@Depend_lines, "$bf.$Obj_suffix $bf.hi : $sf\n");
+ push(@Depend_lines, "$bf.$Obj_suffix : $sf\n");
foreach $suff (@File_suffix) {
- push(@Depend_lines, "$bf$suff$Obj_suffix : $sf\n");
+ push(@Depend_lines, "$bf.${suff}_$Obj_suffix : $sf\n");
}
- # if it's a literate file, .lhs, then we de-literatize it:
- if ( $sf !~ /\.lhs$/ ) {
+ # if it's a literate file, .lhs or .ly? (happy specs), then we de-literatize it:
+ if ( $sf !~ /\.l(hs|y)$/ ) {
$file_to_read = $sf;
} else {
$file_to_read = "$Tmp_prefix.hs";
}
&slurp_file_for_imports($file_to_read, $sf);
- if ( $sf =~ /\.lhs$/ ) {
+ if ( $sf =~ /\.l(hs|y)$/ ) {
unlink "$Tmp_prefix.hs";
}
}
# OK, mangle the Makefile
unlink("$Makefile.bak");
-rename($Makefile,"$Makefile.bak");
+
+#
+# If no output file exist as yet, create one.
+#
+if ( ! -f $Makefile.bak ) {
+ system("touch $Makefile.bak");
+}
+if ( -f $Makefile ) {
+ rename($Makefile,"$Makefile.bak");
+}
# now copy Makefile.bak into Makefile, rm'ing old dependencies
# and adding the new
open(OMKF,"< $Makefile.bak") || die "$Pgm: can't open $Makefile.bak: $!\n";
}
close(NMKF) || exit(1);
close(OMKF) || exit(1);
-chmod 0444, 'Makefile';
exit 0;
sub mangle_command_line_args {
$Include_dirs .= " $_";
} elsif ( /^-syslib$/ ) {
push(@Syslibs, &grab_arg_arg($_,''));
- } elsif ( /^-fhaskell-1\.3/ ) {
- $Haskell_1_3 = 1;
- } elsif ( /^-stable$/ ) {
- # user-defined syslibs that she believes are stable.
- push(@StableLibs, &grab_arg_arg($_,''));
-
+ } elsif ( /^-fhaskell-1\.([2-9])/ ) {
+ $Haskell_1 = $1;
} elsif ($Dashdashes_seen != 1) { # not between -- ... --
if ( /^-v$/ ) {
- $Verbose = '-v';
+ $Verbose++;
} elsif ( /^-f(.*)/ ) {
$Makefile = &grab_arg_arg('-f',$1);
} elsif ( /^-o(.*)/ ) {
$Obj_suffix = &grab_arg_arg('-o',$1);
+ #
+ # --exclude-module=mod => it's stable, trust me!
+
+ } elsif ( /^-(x|-exclude-module=)(.*)/ ) {
+ local($thing) = &grab_arg_arg($1,$2);
+ $IgnoreMe{$thing} = 'y';
+ } elsif ( /^-(X|-exclude-directory=)(.*)/ ) {
+ foreach $d ( split(/:/,&grab_arg_arg($1, $2)) ) {
+ push(@Ignore_dirs,"$d");
+ }
+ } elsif ( /^--include-module=(.*)/ ) {
+ local($thing) = &grab_arg_arg($1,$2);
+ $IgnoreMe{$thing} = 'n';
} elsif ( /^-s(.*)/ ) {
local($suff) = &grab_arg_arg('-s',$1);
- $File_suffix{$suff} = $suff;
- } elsif ( /^-bs(.*)/ ) {
- $Begin_magic_str = &grab_arg_arg('-bs',$1) . "\n";
- } elsif ( /^-es(.*)/ ) {
- $End_magic_str = &grab_arg_arg('-es',$1) . "\n";
- } elsif ( /^-w(.*)/ ) {
- $Width = &grab_arg_arg('-w',$1);
+ push(@File_suffix, $suff);
} elsif ( /^-/ ) {
print STDERR "$Pgm: unknown option ignored: $_\n";
+ $Status++;
} else {
push(@Src_files, $_);
}
} elsif ($Dashdashes_seen == 1) { # where we ignore unknown options
- push(@Src_files,$_) if ! /^-/;
+ push(@Src_files, $_) if ! /^-/;
}
}
- @File_suffix = sort (keys %File_suffix);
+ @File_suffix = sort (@File_suffix);
}
sub grab_arg_arg {
}
}
+sub preprocess_import_dirs {
+ # it's probably cheaper to find out what's in all
+ # the @Import_dirs before we start processing.
+ local($d, $thing);
+ local($_);
+ %ModuleIn = ();
+
+ foreach $d ( @Import_dirs ) {
+ # Check to see if it can be ignored
+ #print STDERR "Ignore imports from $d\n" if $Verbose && $Ignore_dirs{$d};
+ #next if $Ignore_dirs{$d};
+
+ opendir(DIR, $d) || die "$Pgm: can't open directory $d\n";
+
+ for ($_ = readdir(DIR); $_; $_ = readdir(DIR)) {
+ next unless /(.*)\.hi$/;
+ $thing = $1;
+ if ($ModuleIn{$thing} && $ModuleIn{$thing} ne $d) {
+ print STDERR "$Pgm: warning: $thing.hi appears in both $ModuleIn{$thing} and $d!\n";
+ } else {
+ $ModuleIn{$thing} = $d;
+ }
+ }
+ closedir(DIR); # No, don't check the error code
+ }
+
+ # Add all the modules
+ # to the IgnoreMe array before we start scanning for imports.
+ foreach $d (@Ignore_dirs) {
+
+ opendir(DIR, $d) || die "$Pgm: can't open directory $d\n";
+
+ for ($_ = readdir(DIR); $_; $_ = readdir(DIR)) {
+ next unless /(.*)\.(hi|l?hs|l?y)$/;
+ #don't tag it twice or overwrite it with a diff. value
+ next if $IgnoreMe{$1};
+ print STDERR "Module $d/$1.$2 will be ignored\n" if $Verbose;
+
+ $IgnoreMe{$1} = 'y';
+ }
+ closedir(DIR); # No, don't check the error code
+ }
+}
+
sub slurp_file_for_imports {
local($file_to_read, $orig_src_file) = @_;
local($follow_file);
# we mangle #include's so they will also leave something
# behind to indicate the dependency on _them_
+
+ print STDERR "${SED} -e '/^# *include/{p;s/^# *include/!include/;};s/'\\''//g;s/\"//g' $file_to_read | $Cpp $Include_dirs -I$last_seen_dir @Defines |\n" if $Verbose;
- print STDERR "/usr/bin/sed -e '/^# *include/{p;s/^# *include/!include/;};s/'\\''//g;s/\"//g' $file_to_read | $Cpp $Include_dirs -I$last_seen_dir @Defines |\n" if $Verbose;
-
- open(SRCFILE, "/usr/bin/sed -e '/^# *include/{p;s/^# *include/!include/;};s/'\\''//g;s/\"//g' $file_to_read | $Cpp $Include_dirs -I$last_seen_dir @Defines |")
+ open(SRCFILE, "${SED} -e '/^# *include/{p;s/^# *include/!include/;};s/'\\''//g;s/\"//g' $file_to_read | $Cpp $Include_dirs -I$last_seen_dir @Defines |")
|| die "$Pgm: Can't open $file_to_read: $!\n";
while (<SRCFILE>) {
- if (/^>?\s*import\s+([A-Z][A-Za-z0-9_']*)/ || /^!include\s+"(\S+)"/) {
- $modname = $1;
- if (/^>?\s*import/) {
- $follow_file = &find_in_Import_dirs($orig_src_file, $modname, $last_seen_dir);
- } else {
- $follow_file = &find_in_Include_dirs($orig_src_file, $modname, $last_seen_dir);
+ #
+ # import {-# SOURCE #-} Foo (bar) generates dependencies on the source file only,
+ # the compiler will deal with the absence of Foo.hi by consulting the
+ # source for Foo directly. (for dealing with recursive modules).
+ #
+ next unless (/^>?\s*(import)(\s+{-#\s*SOURCE\s*#-})?(\s+qualified)?\s+([A-Z][A-Za-z0-9_']*)/ || /^!(include)(\s+)"(\S+)"/);
+ $todo = $1;
+ $source = ( $2 ne '') ? 1 : 0;
+ $modname = $4;
+
+ next if $modname eq '';
+ if ($todo eq 'import') {
+ if ( $ModuleIn{$modname} ) {
+ $follow_file = "$ModuleIn{$modname}/$modname.hi";
+ } else { # hard way
+ $follow_file
+ = &find_in_Import_dirs($orig_src_file, $modname, $last_seen_dir );
}
+ } else {
+ $follow_file
+ = &find_in_Include_dirs($orig_src_file, $modname, $last_seen_dir);
+ }
+
+ if (! $follow_file) { # it didnae find anything
+ die "$orig_src_file: Couldn't handle: $_\n";
- if ($follow_file) { # it found something
-
- if ($follow_file ne '__syslib__') {
- local($int_file);
- $int_file = $follow_file;
- if ( $int_file !~ /\.(l?hs|hi)$/ ) {
- push(@Depend_lines, "$bf$Obj_suffix : $int_file\n");
- foreach $suff (@File_suffix) {
- push(@Depend_lines, "$bf$suff$Obj_suffix : $int_file\n");
- }
-
- } else {
- $int_file =~ s/\.l?hs$//;
- $int_file =~ s/\.hi$//;
-
- push(@Depend_lines, "$bf$Obj_suffix : $int_file.hi\n");
- foreach $suff (@File_suffix) {
- push(@Depend_lines, "$bf$suff$Obj_suffix : $int_file$suff.hi\n");
- }
+ } else { # it found something
+ if ($follow_file ne '__ignore__') {
+ local($int_file);
+ $int_file = $follow_file;
+
+ if ( $int_file !~ /\.(l?hs|hi|l?y)$/ ) {
+ push(@Depend_lines, "$bf.$Obj_suffix : $int_file\n");
+ foreach $suff (@File_suffix) {
+ push(@Depend_lines, "$bf.${suff}_$Obj_suffix : $int_file\n");
}
+
+ } else {
+ $int_file =~ s/\.l?hs$//;
+ $int_file =~ s/\.l?y$//;
+ $int_file =~ s/\.hi$//;
+ local($source_dep);
+
+ if ( $source && -f "$int_file.hs" ) {
+ $source_dep = "$int_file.hs";
+ push(@Depend_lines, "$bf.$Obj_suffix : $source_dep\n");
+ } elsif ( $source && -f "$int_file.lhs" ) {
+ $source_dep = "$int_file.lhs";
+ push(@Depend_lines, "$bf.$Obj_suffix : $source_dep\n");
+ } elsif ( $source && ( -f "$int_file.ly" || -f "$int_file.y" ) ) {
+ $source_dep = "$int_file.hs";
+ push(@Depend_lines, "$bf.$Obj_suffix : $source_dep\n");
+ } else {
+ if ( $source ) {
+ print STDERR "Warning: could not find source file dependency $int_file.(hs|lhs|y|ly)\n";
+ }
+ push(@Depend_lines, "$bf.$Obj_suffix : $int_file.hi\n");
+ }
+
+ if ( ! $source ) {
+ foreach $suff (@File_suffix) {
+ push(@Depend_lines, "$bf.${suff}_$Obj_suffix : $int_file.${suff}_hi\n");
+ }
+ } else {
+ foreach $suff (@File_suffix) {
+ push(@Depend_lines, "$bf.${suff}_$Obj_suffix : $source_dep\n");
+ }
+ }
}
- } else {
- die "$orig_src_file: Couldn't handle: $_\n";
- }
+ }
}
}
close(SRCFILE) || exit(1);
%FileExists = ();
sub find_in_Import_dirs {
- local($orig_src_file, $modname, $last_seen_dir) = @_;
+ local($orig_src_file, $modname, $last_seen_dir, $source) = @_;
local($import_dir);
local($do_magical_check) = 0;
local($name_to_check);
- # hop along Import_dir list
- foreach $import_dir (split(/:/,$Import_dirs)) {
+ # do it the old hard way: hop along Import_dir list
+ foreach $import_dir (@Import_dirs) {
# handle . magically
if ($import_dir eq '.') {
# record that we should do a SPECIAL try for a file in last_seen_dir (LAST)
$name_to_check = "$import_dir/$modname.hi";
if ( $FileExists{$name_to_check} ne 'n' ) { # either 'y' or nothing
- print STDERR "trying $name_to_check...\n" if $Verbose;
+ print STDERR "trying $name_to_check...\n" if $Verbose >= 2; # very verbose
return($name_to_check) if $FileExists{$name_to_check} eq 'y';
if (-f $name_to_check) {
$FileExists{$name_to_check} = 'y';
}
}
- $name_to_check = "$import_dir/$modname.hs";
- print STDERR "trying... $name_to_check\n" if $Verbose;
- return($name_to_check) if -f $name_to_check;
-
- $name_to_check = "$import_dir/$modname.lhs";
- print STDERR "trying... $name_to_check\n" if $Verbose;
- return($name_to_check) if -f $name_to_check;
+ for $suff ('hs', 'lhs', 'ly', 'y') {
+ $name_to_check = "$import_dir/$modname.$suff";
+ print STDERR "trying... $name_to_check\n" if $Verbose >= 2; # very verbose
+ return($name_to_check) if -f $name_to_check;
+ }
}
if ($do_magical_check == 1) {
$name_to_check = "$last_seen_dir/$modname.hi";
if ( $FileExists{$name_to_check} ne 'n' ) { # either 'y' or nothing
- print STDERR "trying $name_to_check...\n" if $Verbose;
+ print STDERR "trying $name_to_check...\n" if $Verbose >= 2; # very verbose
return($name_to_check) if $FileExists{$name_to_check} eq 'y';
if (-f $name_to_check) {
$FileExists{$name_to_check} = 'y';
}
}
- $name_to_check = "$last_seen_dir/$modname.lhs";
- print STDERR "trying... $name_to_check\n" if $Verbose;
- return($name_to_check) if -f $name_to_check;
-
- $name_to_check = "$last_seen_dir/$modname.hs";
- print STDERR "trying... $name_to_check\n" if $Verbose;
- return($name_to_check) if -f $name_to_check;
- }
- # OK, maybe it's referring to something in a system library
- foreach $lib ( @Syslibs ) {
- if ( $lib eq 'ghc' ) {
- return('__syslib__') if $GhcLibIfaces{$modname};
- } elsif ( $lib eq 'hbc' ) {
- return('__syslib__') if $HbcLibIfaces{$modname};
- } else {
- die "Unrecognised syslib: $lib\n";
- }
+ for $suff ('lhs', 'hs', 'ly', 'y') {
+ $name_to_check = "$last_seen_dir/$modname.$suff";
+ print STDERR "trying... $name_to_check\n" if $Verbose >= 2; # very verbose
+ return($name_to_check) if -f $name_to_check;
+ }
}
- # HACK HACK: Let the user define his own "stable" modules.
- foreach $stableLib ( @StableLibs ) {
- return('__syslib__') if ( $stableLib eq $modname );
- }
-
- # Might be a Haskell 1.3 Module (but only if we've said -fhaskell-1.3)
- if ( $Haskell_1_3 == 1 ) {
- return('__syslib__') if $IO13Ifaces{$modname};
- }
+ # OK, maybe it's referring to something in a system library
+ #foreach $lib ( @Syslibs ) {
+ # return('__ignore__') if $LibIfaces{"$lib:$modname"};
+ #}
# Last hope: referring to a Prelude interface
- return('__syslib__') if $PreludeIfaces{$modname};
+ return('__ignore__') if ( $IgnoreMe{$modname} eq 'y' );
- die "No file `$modname.hi', `$modname.lhs' or `$modname.hs' (reqd from file `$orig_src_file')\namong import directories:\n\t$Import_dirs\n";
+ die "No file `$modname.hi', `$modname.lhs', `$modname.hs' (reqd from file `$orig_src_file')\namong import directories:\n\t$Import_dirs\n";
}
sub find_in_Include_dirs {
# no funny name guessing here
# hop along Include_dir list
- foreach $include_dir (split(/\s+/,$Include_dirs)) {
+ foreach $include_dir (@Include_dirs) {
$include_dir =~ s/^-I//;
# handle . magically
# record that we should do a SPECIAL try for a file in last_seen_dir (LAST)
$do_magical_check = 1;
}
- print STDERR "trying $include_dir/$name...\n" if $Verbose;
+ print STDERR "trying $include_dir/$name...\n" if $Verbose >= 2; # very verbose
if (-f "$include_dir/$name") {
return("$include_dir/$name");
}
}
if ($do_magical_check == 1) {
- print STDERR "trying $last_seen_dir/$name...\n" if $Verbose;
+ print STDERR "trying $last_seen_dir/$name...\n" if $Verbose >= 2; # very verbose
if (-f "$last_seen_dir/$name") {
return("$last_seen_dir/$name");
}