[project @ 2002-11-18 17:01:01 by simonpj]
authorsimonpj <unknown>
Mon, 18 Nov 2002 17:01:03 +0000 (17:01 +0000)
committersimonpj <unknown>
Mon, 18 Nov 2002 17:01:03 +0000 (17:01 +0000)
-----------------------------
Perl and control-M's on Win32
-----------------------------

If the Cygwin 'perl' processes a file produced by a Mingw program
(such as ghc -M), so that the latter has DOS-style line termination,
the Cygwin 'perl' gets confused and adds extra control-M's.

This affects
a) mkdependC, which processes the .depend file produced by
ghc -M
b) the perl post-procssing step in ghc/compiler/Makefile,
which makes .depend-1 etc from .depend-BASE

The solution is to sprinkle few
binmode( HANDLE );
statements around in the perl scripts.

I think they don't affect the Unix version.

ghc/compiler/Makefile
glafp-utils/mkdependC/mkdependC.prl

index bc2191e..41cc372 100644 (file)
@@ -93,9 +93,23 @@ boot ::
        for i in $(ALL_DIRS); do \
            $(MKDIRHIER) stage$(stage)/$$i; \
        done
+# On Windows, we can't use symbolic links for the -hi-boot files
+# because GHC itself is a Mingw program and does not understand
+# symbolic links.  So we have to copy the files instead of link them.
+# That means that if you modify a .hi-boot file in Windows, you
+# have to to say 'make boot' again.
+#
+# PS: 'ln -s foo baz' takes 'foo' relative to the path to 'baz'
+#     whereas 'cp foo baz' treats the two paths independently.
+#     Hence the "../.." in the ln command line
+ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
+       for i in */*hi-boot*; do \
+       done
+else
        for i in */*hi-boot*; do \
            $(LN_S) -f ../../$$i stage$(stage)/$$i; \
        done
+endif
 
 ifeq "$(stage)" ""
 stage=1
@@ -527,6 +541,7 @@ MKDEPENDHS=$(HC)
 depend :: $(HS_SRCS) $(C_SRCS)
        $(MKDEPENDHS) -M -optdep-f -optdep.depend-BASE $(foreach way,$(WAYS),-optdep-s -optdep$(way)) $(foreach obj,$(MKDEPENDHS_OBJ_SUFFICES),-osuf $(obj)) $(MKDEPENDHS_OPTS) $(filter-out -split-objs, $(MKDEPENDHS_HC_OPTS)) $(HS_SRCS)
        $(MKDEPENDC) -f .depend-BASE $(MKDEPENDC_OPTS) $(foreach way,$(WAYS),-s $(way)) -- $(CC_OPTS) -- $(C_SRCS) 
-       $(PERL) -pe 's@^(\S*\.o)@stage$(stage)/$$1@g; s@(\S*\.hi)@stage$(stage)/$$1@g' <.depend-BASE >.depend-$(stage)
+       $(PERL) -pe 'binmode(stdin); binmode(stdout); s@^(\S*\.o)@stage$(stage)/$$1@g; s@(\S*\.hi)@stage$(stage)/$$1@g' <.depend-BASE >.depend-$(stage)
+# The binmode stuff tells perl not to add stupid ^M's to the output
 
 -include .depend-$(stage)
index 95ec39a..d22f6d9 100644 (file)
@@ -73,6 +73,9 @@ rename($Makefile,"$Makefile.bak");
 # and adding the new
 open(OMKF,"< $Makefile.bak") || die "$Pgm: can't open $Makefile.bak: $!\n";
 open(NMKF,"> $Makefile") || die "$Pgm: can't open $Makefile: $!\n";
+binmode(OMKF); # Do not add stupid ^M's to the output on Win32
+binmode(NMKF); # Do not add stupid ^M's to the output on Win32
+
 select(NMKF);
 $_ = <OMKF>;
 while ($_ && $_ ne $Begin_magic_str) { # copy through, 'til Begin_magic_str