From 0638e7d81533677f5c821a8ec3565b2b32c5543e Mon Sep 17 00:00:00 2001 From: simonpj Date: Mon, 18 Nov 2002 17:01:03 +0000 Subject: [PATCH] [project @ 2002-11-18 17:01:01 by simonpj] ----------------------------- 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 | 17 ++++++++++++++++- glafp-utils/mkdependC/mkdependC.prl | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ghc/compiler/Makefile b/ghc/compiler/Makefile index bc2191e..41cc372 100644 --- a/ghc/compiler/Makefile +++ b/ghc/compiler/Makefile @@ -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) diff --git a/glafp-utils/mkdependC/mkdependC.prl b/glafp-utils/mkdependC/mkdependC.prl index 95ec39a..d22f6d9 100644 --- a/glafp-utils/mkdependC/mkdependC.prl +++ b/glafp-utils/mkdependC/mkdependC.prl @@ -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); $_ = ; while ($_ && $_ ne $Begin_magic_str) { # copy through, 'til Begin_magic_str -- 1.7.10.4