From 7b4287b8e44ebece15e01ac5ec46ad8775119706 Mon Sep 17 00:00:00 2001
From: sof <unknown>
Date: Thu, 30 Oct 1997 22:39:15 +0000
Subject: [PATCH] [project @ 1997-10-30 22:39:15 by sof] Quote -#include opts
 when passing them on (to mkdependHS); silently add ghc syslib with posix (it
 depends on it.)

---
 ghc/driver/ghc.lprl | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/ghc/driver/ghc.lprl b/ghc/driver/ghc.lprl
index ce77c6006366..8a8823112270 100644
--- a/ghc/driver/ghc.lprl
+++ b/ghc/driver/ghc.lprl
@@ -577,6 +577,8 @@ if (  $Status == 0 && $Only_generate_deps ) {
     push (@MkDependHS_flags, "-o$Osuffix") if $Osuffix;
     push (@MkDependHS_flags, "-s$BuildTag") if $BuildTag;
     push (@MkDependHS_flags, "-D__HASKELL1__=$Haskell1Version");
+    # They're not (currently) needed, but we need to quote any -#include options
+    map(s/-#include.*$/'$&'/g, @Cmd_opts);
     local($to_do) = "$MkDependHS @MkDependHS_flags -- @Cmd_opts -- @Input_file" ;
     &run_something($to_do, 'Haskell dependencies');
     exit $Status;
@@ -2757,24 +2759,33 @@ arg: while($_ = $Args[0]) {
 			    print STDERR "$Pgm: no such system library (-syslib): $syslib\n",
 			      $Status++ unless $syslib =~ /^(hbc|ghc|posix|contrib)$/;
 
+			    again:
+			    #
+			    # The posix library is a `special' in that it relies on
+			    # the ghc system library (packed strings). Wielding our
+			    # sledgehammer, the problem is solved by silently including
+			    # the ghc system library as well.
+			    # (ToDo: `nub' -syslib list)
+			    #
 			    unshift(@SysImport_dir,
 				${INSTALLING}
 				? "$InstSysLibDir/$syslib/imports"
 				: "$TopPwd/hslibs/$syslib/src");
-
-			    if ( ${INSTALLING} ) {
-				push(@SysLibrary_dir,
-					("$InstSysLibDir"));
-			    } else {
-				push(@SysLibrary_dir,
-					("$TopPwd/hslibs/$syslib"
-					,"$TopPwd/hslibs/$syslib/cbits"));
-			    }
+			
+			    push(@SysLibrary_dir,
+			    	 ${INSTALLING}
+				 ? ("$InstSysLibDir")
+			         : ("$TopPwd/hslibs/$syslib"
+				   ,"$TopPwd/hslibs/$syslib/cbits"));
 
 			    push(@SysLibrary, "-lHS$syslib");
 			    push(@SysLibrary, "-lHS${syslib}_cbits")
 			      unless $syslib eq 'contrib'; #HACK! it has no cbits
 
+			    if ( $syslib eq 'posiz') {
+				$syslib='ghc';
+				goto again;
+			    }
 			    next arg; };
 
     #=======================================================================
-- 
GitLab