#
# RAWCPP TMPDIR TOP_PWD
# libdir libexecdir datadir INSTALLING
-# PROJECTVERSION SED
+# ProjectVersionInt SED
#
# tries to work like mkdependC - capable of dealing with:
#
-w No warnings
-f blah Use "blah" as the makefile, rather than "makefile"
or "Makefile".
+ -cpp Wash the input files through cpp(1).
-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
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.
$Dashdashes_seen = 0;
$Cpp = ${RAWCPP};
+$Cpp_flag_set = 0; # 1 => run cpp over input files.
if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
$Tmp_prefix = $ENV{'TMPDIR'} . "/mkdependHS$$";
$TopPwd = "${TOP_PWD}";
$InstLibDirGhc = "${libdir}";
$InstLibExecDirGhc = "${libexecdir}";
-$InstHsLibDirGhc = "${libdir}/hslibs";
$InstDataDirGhc = "${datadir}";
$Unlit = ($INSTALLING) ? "${InstLibExecDirGhc}/unlit"
$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 = ();
# 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 {
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 {
- push(@Import_dirs, @dirs);
+ push(@Import_dirs, $dir);
}
}
}
-# 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
$_ = <OMKF>;
}
# insert dependencies
-print $Begin_magic_str, @Depend_lines, $End_magic_str || die "Failed to write out dependencies ($!)";
+print "\n$Begin_magic_str", @Depend_lines, $End_magic_str || die "Failed to write out dependencies ($!)";
while (<OMKF>) { # copy the rest through
print $_ || die "Failed to write out dependencies ($!)";
} elsif ( /^-D(.*)/ ) { # recognized wherever they occur
push(@Defines, $_);
- } elsif ( /^-i(.*)/ ) { # ditto
- $Import_dirs .= ":$1";
+ } elsif ( /^-cpp$/ ) { # recognized wherever they occur
+ $Cpp_flag_set =1;
+ } elsif ( /^-i$/ ) {
+ $Import_dirs = ''; # import path cleared!
+ } elsif ( /^-i(.*)/ ) {
+ $Import_dirs = "$1:$Import_dirs";
} elsif ( /^-I/ ) {
$Include_dirs .= " $_";
} elsif ( /^-syslib$/ ) {
push(@Syslibs, &grab_arg_arg($_,''));
+ } elsif ( /^-fglasgow-exts$/ ) {
+ push(@Syslibs, 'exts');
} elsif ($Dashdashes_seen != 1) { # not between -- ... --
if ( /^-v$/ ) {
$Verbose++;
} 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);
}
# 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;
+ local ($open_cmd);
+ if ($Cpp_flag_set) {
+ $open_cmd = "${SED} -e '/^# *include/{p;s/^# *include/!include/;};s/'\\''//g;s/\"//g' $file_to_read | $Cpp $Include_dirs -I$last_seen_dir @Defines |";
+ } else {
+ $open_cmd = $file_to_read;
+ }
+ print STDERR "$open_cmd\n" if $Verbose;
- 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";
+ open(SRCFILE, $open_cmd) || die "$Pgm: Can't open $file_to_read: $!\n";
while (<SRCFILE>) {
#