From 5c789e424c1461c1dadfd38c44fcb9e8f38bf755 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Fri, 6 Apr 2007 15:18:22 +0000 Subject: [PATCH] Fixes for building the libraries with cabal on Windows * configure can be told where ld is * make an hsc2hs-inplace.bat * tell Setup configure about foo.bar rather than foo on Windows * tell Setup configure to pass a --with-cc=$(CC) argument to ./configure --- aclocal.m4 | 40 +++++++++++++++++++++++----------------- configure.ac | 19 +++++++++++++++++++ libraries/Makefile | 15 ++++++++++++--- utils/hsc2hs/Makefile | 11 ++++++++++- 4 files changed, 64 insertions(+), 21 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 1daac04..5755dbe 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -319,24 +319,30 @@ AC_SUBST(AlexVersion) # 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], -[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]) +[ +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 -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 AC_SUBST([LdCmd]) ])# FP_PROG_LD diff --git a/configure.ac b/configure.ac index 6067f3c..dce5a07 100644 --- a/configure.ac +++ b/configure.ac @@ -756,6 +756,25 @@ AC_ARG_WITH(gcc, ) 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" + then + if test "${OSTYPE}" != "msys" + then + # Canonicalise to :/path/to/ld + withval=`cygpath -w ${withval} | sed -e 's@\\\\@/@g' ` + fi + fi; + LD=$withval + FP_PROG_LD([$LD]) + ], + [FP_PROG_LD()] +) + dnl ** Booting from .hc files? dnl -------------------------------------------------------------- AC_ARG_ENABLE(hc-boot, diff --git a/libraries/Makefile b/libraries/Makefile index 82cf02e..694adae 100644 --- a/libraries/Makefile +++ b/libraries/Makefile @@ -56,6 +56,12 @@ endif empty= space=$(empty) $(empty) +ifeq "$(Windows)" "YES" +dot_bat=.bat +else +dot_bat= +endif + CONFIGURE_OPTS = CONFIGURE_STAMP_EXTRAS := @@ -122,10 +128,13 @@ stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup cd $* && setup/Setup configure \ $(CONFIGURE_OPTS) \ --prefix=$(prefix) \ - --with-compiler=../../compiler/ghc-inplace \ - --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace \ + --with-compiler=../../compiler/ghc-inplace$(dot_bat) \ + --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace$(dot_bat) \ + --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace$(dot_bat) \ + --with-ld=$(LD) \ --datasubdir=ghc \ - --haddock-args="--use-contents=../index.html --use-index=../doc-index.html" + --haddock-args="--use-contents=../index.html --use-index=../doc-index.html" \ + --configure-option=--with-cc=$(CC) touch $@ $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\ diff --git a/utils/hsc2hs/Makefile b/utils/hsc2hs/Makefile index 88f3edb..f87d049 100644 --- a/utils/hsc2hs/Makefile +++ b/utils/hsc2hs/Makefile @@ -63,7 +63,7 @@ ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32" extra_flags=$(addprefix --cflag=,$(filter-out -O,$(SRC_CC_OPTS))) endif -HSC2HS_EXTRA="--cc=$(CC) --ld=$(CC) $(extra_flags) --cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt) -I$(FPTOOLS_TOP_ABS_PLATFORM)/$(GHC_INCLUDE_DIR_REL)" +HSC2HS_EXTRA=--cc=$(CC) --ld=$(CC) $(extra_flags) --cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt) -I$(FPTOOLS_TOP_ABS_PLATFORM)/$(GHC_INCLUDE_DIR_REL) endif $(SCRIPT_PROG) : Makefile @@ -95,4 +95,13 @@ clean distclean maintainer-clean :: $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@ endif +ifeq "$(INSTALLING)$(HOSTPLATFORM)" "0i386-unknown-mingw32" +all :: $(INPLACE_SCRIPT_PROG).bat + +FULL_INPLACE_PATH=$(subst /,\\,$(FPTOOLS_TOP_ABS)/utils/hsc2hs/) +$(INPLACE_SCRIPT_PROG).bat : + echo '@call $(FULL_INPLACE_PATH)$(HS_PROG) --template=$(FULL_INPLACE_PATH)template-hsc.h $(HSC2HS_EXTRA) %*' >> $@ + chmod 755 $@ +endif + include $(TOP)/mk/target.mk -- 1.7.10.4