Fixes for building the libraries with cabal on Windows
authorIan Lynagh <igloo@earth.li>
Fri, 6 Apr 2007 15:18:22 +0000 (15:18 +0000)
committerIan Lynagh <igloo@earth.li>
Fri, 6 Apr 2007 15:18:22 +0000 (15:18 +0000)
* 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
configure.ac
libraries/Makefile
utils/hsc2hs/Makefile

index 1daac04..5755dbe 100644 (file)
@@ -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
 
index 6067f3c..dce5a07 100644 (file)
@@ -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 <drive>:/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,
index 82cf02e..694adae 100644 (file)
@@ -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)):\
index 88f3edb..f87d049 100644 (file)
@@ -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