From e51cdf9b6e54fb4052e46b6d7afb15e062928467 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Fri, 23 Oct 2009 17:44:43 +0000 Subject: [PATCH] Make a mingw tree from mingw tarballs --- aclocal.m4 | 72 ++++++++++++++++++++--------------------- compiler/main/SysTools.lhs | 2 +- configure.ac | 77 +++++++++++++++++++++++++------------------- darcs-all | 75 ------------------------------------------ ghc.mk | 12 ------- ghc/ghc.mk | 6 ++-- libffi/ghc.mk | 2 +- mk/config.mk.in | 3 +- packages | 1 + 9 files changed, 87 insertions(+), 163 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index e7adaff..d4a58f9 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -44,6 +44,40 @@ AC_DEFUN([FP_EVAL_STDERR], ])# FP_EVAL_STDERR +# FP_ARG_WITH_PATH_GNU_PROG +# -------------------- +# XXX +# +# $1 = the command to look for +# $2 = the variable to set +# +AC_DEFUN([FP_ARG_WITH_PATH_GNU_PROG], +[ +AC_ARG_WITH($2, +[AC_HELP_STRING([--with-$2=ARG], + [Use ARG as the path to $2 [default=autodetect]])], +[ + if test "$HostOS" = "mingw32" + then + AC_MSG_WARN([Request to use $withval will be ignored]) + else + $1=$withval + fi +], +[ + if test "$HostOS" != "mingw32" + then + AC_PATH_PROG([$1], [$2]) + if test -z "$$1" + then + AC_MSG_ERROR([cannot find $2 in your PATH, no idea how to link]) + fi + fi +] +) +]) # FP_ARG_WITH_PATH_GNU_PROG + + # FP_PROG_CONTEXT_DIFF # -------------------- # Figure out how to do context diffs. Sets the output variable ContextDiffCmd. @@ -289,46 +323,12 @@ AC_SUBST(AlexVersion) ]) - -# FP_PROG_LD -# ---------- -# Sets the output variable LdCmd to the (non-Cygwin version of the) full path -# of ld. Exits if no ld can be found -AC_DEFUN([FP_PROG_LD], -[ -if test -z "$1" -then - AC_PATH_PROG([fp_prog_ld_raw], [ld]) - if test -z "$fp_prog_ld_raw"; then - AC_MSG_ERROR([cannot find ld in your PATH, no idea how to link]) - fi - LdCmd=$fp_prog_ld_raw - case $HostPlatform in - *mingw32) if test x${OSTYPE} != xmsys; then - LdCmd="`cygpath -w ${fp_prog_ld_raw} | sed -e 's@\\\\@/@g'`" - AC_MSG_NOTICE([normalized ld command to $LdCmd]) - fi - # Insist on >= ld-2.15.x, since earlier versions doesn't handle - # the generation of relocatable object files with large amounts - # of relocations correctly. (cf. HSbase.o splittage-hack) - fp_prog_ld_version=`${LdCmd} --version | sed -n '/GNU ld/p' | tr -cd 0-9 | cut -b1-3` - FP_COMPARE_VERSIONS([$fp_prog_ld_version],[-lt],[214], - [AC_MSG_ERROR([GNU ld version later than 2.14 required to compile GHC on Windows.])])[]dnl - ;; - esac -else - LdCmd="$1" -fi -AC_SUBST([LdCmd]) -])# FP_PROG_LD - - # FP_PROG_LD_X # ------------ # Sets the output variable LdXFlag to -x if ld supports this flag, otherwise the # variable's value is empty. AC_DEFUN([FP_PROG_LD_X], -[AC_REQUIRE([FP_PROG_LD]) +[ AC_CACHE_CHECK([whether ld understands -x], [fp_cv_ld_x], [echo 'foo() {}' > conftest.c ${CC-cc} -c conftest.c @@ -352,7 +352,7 @@ AC_SUBST([LdXFlag]) # Sets the output variable LdIsGNULd to YES or NO, depending on whether it is # GNU ld or not. AC_DEFUN([FP_PROG_LD_IS_GNU], -[AC_REQUIRE([FP_PROG_LD]) +[ AC_CACHE_CHECK([whether ld is GNU ld], [fp_cv_gnu_ld], [if ${LdCmd} --version 2> /dev/null | grep "GNU" > /dev/null 2>&1; then fp_cv_gnu_ld=yes diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs index cfa43ff..c8960dc 100644 --- a/compiler/main/SysTools.lhs +++ b/compiler/main/SysTools.lhs @@ -184,7 +184,7 @@ initSysTools mbMinusB dflags0 | isWindowsHost = installed_mingw_bin "gcc" | otherwise = cGCC perl_path - | isWindowsHost = installed cGHC_PERL + | isWindowsHost = installed_mingw_bin cGHC_PERL | otherwise = cGHC_PERL -- 'touch' is a GHC util for Windows touch_path diff --git a/configure.ac b/configure.ac index 9cd89a6..2ca1735 100644 --- a/configure.ac +++ b/configure.ac @@ -380,47 +380,56 @@ AC_SUBST(WithHc) AC_PATH_PROGS(NHC,nhc nhc98) AC_PATH_PROG(HBC,hbc) +# This uses GHC, so put it after the "GHC is required" check above: +FP_FIND_ROOT + +if test "$HostOS" = "mingw32" +then + CC="$hardtop/inplace/mingw/bin/gcc.exe" + LD="$hardtop/inplace/mingw/bin/ld.exe" + NM="$hardtop/inplace/mingw/bin/nm.exe" + if ! test -d inplace/mingw || + test inplace/mingw -ot ghc-tarballs/mingw/binutils*.tar.gz || + test inplace/mingw -ot ghc-tarballs/mingw/gcc-core*.tar.gz || + test inplace/mingw -ot ghc-tarballs/mingw/libcrypt*.tar.bz2 || + test inplace/mingw -ot ghc-tarballs/mingw/mingw-runtime*.tar.gz || + test inplace/mingw -ot ghc-tarballs/mingw/perl*.tar.bz2 || + test inplace/mingw -ot ghc-tarballs/mingw/w32api*.tar.gz + then + AC_MSG_NOTICE([Making in-tree mingw tree]) + rm -rf inplace/mingw + mkdir inplace + mkdir inplace/mingw + cd inplace/mingw + tar -zxf ../../ghc-tarballs/mingw/binutils*.tar.gz + tar -zxf ../../ghc-tarballs/mingw/gcc-core*.tar.gz + tar -jxf ../../ghc-tarballs/mingw/libcrypt*.tar.bz2 + tar -zxf ../../ghc-tarballs/mingw/mingw-runtime*.tar.gz + tar -jxf ../../ghc-tarballs/mingw/perl*.tar.bz2 + tar -zxf ../../ghc-tarballs/mingw/w32api*.tar.gz + cd ../.. + AC_MSG_NOTICE([In-tree mingw tree created]) + fi +fi + dnl ** Which gcc to use? dnl -------------------------------------------------------------- -AC_ARG_WITH(gcc, -[AC_HELP_STRING([--with-gcc=ARG], - [Use ARG as the path to GCC [default=autodetect]])], -[WhatGccIsCalled="$withval" - if test "x$HostPlatform" = "xi386-unknown-mingw32" && \ - test "${OSTYPE}" != "msys" && \ - test "${withval}" != "" - then - # Canonicalise to :/path/to/gcc - withval=`cygpath -m ${withval}` - fi; - CC="$withval" - export CC - ], -[WhatGccIsCalled="gcc"] -) +FP_ARG_WITH_PATH_GNU_PROG([CC], [gcc]) +export CC +WhatGccIsCalled="$CC" AC_SUBST(WhatGccIsCalled) dnl ** Which ld to use? dnl -------------------------------------------------------------- -AC_ARG_WITH(ld, -[AC_HELP_STRING([--with-ld=ARG], - [Use ARG as the path to LD [default=autodetect]])], -[if test "x$HostPlatform" = "xi386-unknown-mingw32" && \ - test "${OSTYPE}" != "msys" && \ - test "${withval}" != "" - then - # Canonicalise to :/path/to/ld - withval=`cygpath -m ${withval}` - fi; - LD=$withval - FP_PROG_LD([$LD]) - ], - [FP_PROG_LD()] -) - -# This uses GHC, so put it after the "GHC is required" check above: -FP_FIND_ROOT +FP_ARG_WITH_PATH_GNU_PROG([LD], [ld]) +LdCmd="$LD" +AC_SUBST([LdCmd]) +dnl ** Which nm to use? +dnl -------------------------------------------------------------- +FP_ARG_WITH_PATH_GNU_PROG([NM], [nm]) +NmCmd="$NM" +AC_SUBST([NmCmd]) dnl ** Mac OS X: explicit deployment target dnl -------------------------------------------------------------- diff --git a/darcs-all b/darcs-all index a80e6f8..2792481 100644 --- a/darcs-all +++ b/darcs-all @@ -112,20 +112,6 @@ sub warning { } } -sub download { - my ($from, $to) = @_; - - my @cmd = ("wget", $from, "-O", $to); - message "== running @cmd"; - system @cmd; - if ($? == -1) { - die "Failed to execute wget: $!\n"; - } - elsif ($? != 0) { - die "wget failed: $?\n"; - } -} - sub darcs { message "== running darcs @_"; system ("darcs", @_) == 0 @@ -178,10 +164,6 @@ sub darcsall { die "Bad line: $_"; } } - - if ($_[0] eq "pull" || $_[0] eq "pul") { - &sync_tarballs(); - } } sub darcsget { @@ -233,63 +215,6 @@ sub darcsget { die "Bad line: $_"; } } - - &sync_tarballs(); -} - -sub sync_tarballs { - my $localpath; - my $localdirectory; - my $localfilename; - my $actualpath; - my $actualfilename; - my $remotepath; - my $path; - my @tarballs; - my %localtarballs; - my ($repo_base, $checked_out_tree) = getrepo(); - - message "== Syncing tarballs"; - - open IN, "< tarballs" or die "Can't open packages file"; - @tarballs = ; - close IN; - - foreach (@tarballs) { - chomp; - if (m@^([^# ]+)/([^#/ ]+) +([^ ]+)$@) { - $localdirectory = $1; - $localfilename = $2; - $remotepath = $3; - $localpath = "$localdirectory/$localfilename"; - - $localtarballs{$localdirectory}{$localfilename} = 1; - - if (! -e $localpath) { - if ($checked_out_tree) { - $path = "$repo_base/$localpath"; - } - else { - $path = "$repo_base/$remotepath"; - } - &download($path, $localpath); - } - } - elsif (! /^(#.*)?$/) { - die "Bad line: $_"; - } - } - - foreach $localdirectory (keys %localtarballs) { - FILE: foreach $actualpath (glob "$localdirectory/*.tar.gz $localdirectory/*.tar.bz2") { - $actualfilename = $actualpath; - $actualfilename =~ s#.*/##; - if (! defined($localtarballs{$localdirectory}{$actualfilename})) { - message "== Deleting $actualpath"; - unlink $actualpath; - } - } - } } sub main { diff --git a/ghc.mk b/ghc.mk index 28e4f44..9e1026e 100644 --- a/ghc.mk +++ b/ghc.mk @@ -686,18 +686,6 @@ endif ifeq "$(Windows)" "YES" -# directories don't work well as dependencies, hence a stamp file -$(INPLACE)/stamp-mingw : $(MKDIRHIER) - $(MKDIRHIER) $(INPLACE_MINGW)/bin - GCC=`type -p $(WhatGccIsCalled)`; \ - GccDir=`dirname $$GCC`; \ - "$(CP)" -p $$GccDir/{gcc.exe,ar.exe,as.exe,dlltool.exe,dllwrap.exe,windres.exe} $(INPLACE_MINGW)/bin; \ - "$(CP)" -Rp $$GccDir/../include $(INPLACE_MINGW); \ - "$(CP)" -Rp $$GccDir/../lib $(INPLACE_MINGW); \ - "$(CP)" -Rp $$GccDir/../libexec $(INPLACE_MINGW); \ - "$(CP)" -Rp $$GccDir/../mingw32 $(INPLACE_MINGW) - touch $(INPLACE)/stamp-mingw - install : install_mingw .PHONY: install_mingw install_mingw : $(INPLACE_MINGW) diff --git a/ghc/ghc.mk b/ghc/ghc.mk index e5cb843..6d6652a 100644 --- a/ghc/ghc.mk +++ b/ghc/ghc.mk @@ -135,9 +135,9 @@ $(GHC_STAGE2) : $(INPLACE_LIB)/extra-gcc-opts $(GHC_STAGE3) : $(INPLACE_LIB)/extra-gcc-opts ifeq "$(Windows)" "YES" -$(GHC_STAGE1) : $(TOUCHY) $(INPLACE)/stamp-mingw $(INPLACE_LIB)/perl.exe -$(GHC_STAGE2) : $(TOUCHY) $(INPLACE)/stamp-mingw $(INPLACE_LIB)/perl.exe -$(GHC_STAGE3) : $(TOUCHY) $(INPLACE)/stamp-mingw $(INPLACE_LIB)/perl.exe +$(GHC_STAGE1) : $(TOUCHY) +$(GHC_STAGE2) : $(TOUCHY) +$(GHC_STAGE3) : $(TOUCHY) endif ifeq "$(BootingFromHc)" "YES" diff --git a/libffi/ghc.mk b/libffi/ghc.mk index b09fb07..a1c2748 100644 --- a/libffi/ghc.mk +++ b/libffi/ghc.mk @@ -106,7 +106,7 @@ endif ifneq "$(BINDIST)" "YES" $(libffi_STAMP_CONFIGURE): "$(RM)" $(RM_OPTS) -r $(LIBFFI_DIR) libffi/build - cd libffi && $(TAR) -zxf tarball/libffi*.tar.gz + cd libffi && $(TAR) -zxf ../ghc-tarballs/libffi/libffi*.tar.gz mv libffi/libffi-* libffi/build chmod +x libffi/ln cd libffi/build && "$(PATCH)" -p1 < ../libffi.dllize-3.0.8.patch diff --git a/mk/config.mk.in b/mk/config.mk.in index 09c8621..7acb3a2 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -603,7 +603,8 @@ RANLIB = @RANLIB@ SED = @SedCmd@ SHELL = /bin/sh -LD = @LdCmd@ +LD = @LdCmd@ +NM = @NmCmd@ # Some ld's support the -x flag and some don't, so the configure # script detects which we have and sets LdXFlag to "-x" or "" diff --git a/packages b/packages index a0ddcde..7feed1f 100644 --- a/packages +++ b/packages @@ -17,6 +17,7 @@ # # Lines that start with a '#' are comments. . ghc git +ghc-tarballs ghc-tarballs darcs utils/hsc2hs hsc2hs darcs utils/haddock haddock2 darcs libraries/array packages/array darcs -- 1.7.10.4