From 0f77780f5e87d1d44189b664fcba0a0725d94742 Mon Sep 17 00:00:00 2001
From: sof <unknown>
Date: Fri, 8 Jan 1999 18:14:13 +0000
Subject: [PATCH] [project @ 1999-01-08 18:14:13 by sof] mkdependHS: for
 "source" imports of the form, e.g.,

   import {-# SOURCE #-} Foo

emit dependency on Foo.hi-boot-<iface-file-version-number>
rather than just Foo.hi-boot if the former exists.
---
 ghc/utils/mkdependHS/Makefile       |  3 ++-
 ghc/utils/mkdependHS/mkdependHS.prl | 18 +++++++++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/ghc/utils/mkdependHS/Makefile b/ghc/utils/mkdependHS/Makefile
index 3ff3e5226ba2..78c03f2b1991 100644
--- a/ghc/utils/mkdependHS/Makefile
+++ b/ghc/utils/mkdependHS/Makefile
@@ -9,7 +9,8 @@ SCRIPT_PROG=mkdependHS
 SCRIPT_OBJS=mkdependHS.prl
 SCRIPT_SUBST_VARS= \
  TOP_PWD \
- INSTALLING
+ INSTALLING \
+ HscIfaceFileVersion
 
 INTERP=perl
 
diff --git a/ghc/utils/mkdependHS/mkdependHS.prl b/ghc/utils/mkdependHS/mkdependHS.prl
index b68cb08322d0..54d96270a7bc 100644
--- a/ghc/utils/mkdependHS/mkdependHS.prl
+++ b/ghc/utils/mkdependHS/mkdependHS.prl
@@ -1,7 +1,7 @@
 #
 # perl script expect the following variables to be prepended:
 #
-#  RAWCPP TMPDIR TOP_PWD
+#  RAWCPP TMPDIR TOP_PWD HscIfaceFileVersion
 #  libdir libexecdir datadir INSTALLING
 #  SED 
 #
@@ -58,7 +58,7 @@ mkdependHS-specific options (not between --'s):
                 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
@@ -84,6 +84,9 @@ $InstDataDirGhc    = "${datadir}";
 $Unlit = ($INSTALLING) ? "${InstLibExecDirGhc}/unlit" 
 		       : "${TopPwd}/ghc/utils/unlit/unlit";
 
+$HiBootVersion = $HscIfaceFileVersion;
+$hi_boot_with_version = 0;
+
 $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");
@@ -466,7 +469,12 @@ sub process_dependency {
             local($source_dep);
 
             if ( $source ) {
-                $source_dep = "$int_file.hi-boot";
+		# if a version specific .hi-boot file exist, use it.
+		if ( -f "$int_file.hi-boot-${HiBootVersion}" ) {
+               	   $source_dep = "$int_file.hi-boot-${HiBootVersion}";
+		} else {
+		   $source_dep = "$int_file.hi-boot";
+		}
             } else {
 	        local($str)="";
 		foreach $obj (@Obj_suffix) {
@@ -535,6 +543,10 @@ sub find_in_Import_dirs {
         }
 
 	if ( $source ) {
+	    $name_to_check = "$import_dir/$modname.hi-boot-${HiBootVersion}";
+	    print STDERR "trying... $name_to_check\n" if $Verbose >= 2; # very verbose
+	    return($name_to_check) if -f $name_to_check;
+
 	    $name_to_check = "$import_dir/$modname.hi-boot";
 	    print STDERR "trying... $name_to_check\n" if $Verbose >= 2; # very verbose
 	    return($name_to_check) if -f $name_to_check;
-- 
GitLab