summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac143
1 files changed, 21 insertions, 122 deletions
diff --git a/configure.ac b/configure.ac
index 95d0043f59..7f2fb42bc6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -354,111 +354,10 @@ AC_SUBST(TargetHasRTSLinker)
# Requires FPTOOLS_SET_PLATFORMS_VARS to be run first.
FP_FIND_ROOT
-
-if test "$HostOS" = "mingw32"
-then
- # Find the mingw-w64 7z file to extract.
- # NB. If you update the tarballs to a new version of gcc, don't
- # forget to tweak the paths in driver/gcc/gcc.c.
- if test "$HostArch" = "i386"
- then
- mingw_arch="i686"
- tarball_dest_dir="mingw-w64/i686"
- tarball_mingw_dir="mingw32"
- else
- mingw_arch="x86_64"
- tarball_dest_dir="mingw-w64/x86_64"
- tarball_mingw_dir="mingw64"
- fi
-fi
-
-set_up_tarballs() {
- AC_MSG_NOTICE([Checking for Windows toolchain tarballs...])
- local action
- if test "$TarballsAutodownload" = "NO"
- then
- action="verify"
- else
- action="download"
- fi
- $PYTHON mk/get-win32-tarballs.py $action $mingw_arch > missing-win32-tarballs
- case $? in
- 0)
- rm missing-win32-tarballs
- ;;
- 2)
- echo
- echo "Error:"
- echo "Needed msys2 tarballs are missing. You have a few options to get them,"
- echo
- echo " * run configure with the --enable-tarballs-autodownload option"
- echo
- echo " * run mk/get-win32-tarballs.py download $mingw_arch"
- echo
- echo " * manually download the files listed in ./missing-win32-tarballs and place"
- echo " them in the ghc-tarballs directory."
- echo
- exit 1
- ;;
- *)
- echo
- echo "Error fetching msys2 tarballs; see errors above."
- exit 1
- ;;
- esac
-
- # Extract all the tarballs in one go
- if ! test -d inplace/mingw
- then
- AC_MSG_NOTICE([Extracting Windows toolchain from archives (may take a while)...])
- rm -rf inplace/mingw
- local base_dir="../ghc-tarballs/${tarball_dest_dir}"
- ( cd inplace &&
- find "${base_dir}" -name "*.tar.xz" -exec tar --xz -xf {} \; &&
- find "${base_dir}" -name "*.tar.zst" -exec tar --zstd -xf {} \; &&
- rm ".MTREE" &&
- rm ".PKGINFO" &&
- cd .. ) || AC_MSG_ERROR([Could not extract Windows toolchains.])
-
- mv "inplace/${tarball_mingw_dir}" inplace/mingw &&
- touch inplace/mingw
-
- # NB. Now since the GCC is hardcoded to use /mingw32 we need to
- # make a wrapper around it to give it the proper paths
- mv inplace/mingw/bin/gcc.exe inplace/mingw/bin/realgcc.exe
- PATH=`pwd`/inplace/mingw/bin:$PATH
- inplace/mingw/bin/realgcc.exe driver/gcc/gcc.c driver/utils/cwrapper.c driver/utils/getLocation.c -Idriver/utils -o inplace/mingw/bin/gcc.exe
-
- AC_MSG_NOTICE([In-tree MingW-w64 tree created])
- fi
-}
-
-# See Note [tooldir: How GHC finds mingw on Windows]
-if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"
-then
- test -d inplace || mkdir inplace
-
- # NB. Download and extract the MingW-w64 distribution if required
- set_up_tarballs
-
- mingwbin="$hardtop/inplace/mingw/bin/"
- CC="${mingwbin}gcc.exe"
- LD="${mingwbin}ld.exe"
- NM="${mingwbin}nm.exe"
- RANLIB="${mingwbin}ranlib.exe"
- OBJDUMP="${mingwbin}objdump.exe"
- MergeObjsCmd="$LD"
- MergeObjsArgs="-r --oformat=pe-bigobj-x86-64"
- fp_prog_ar="${mingwbin}ar.exe"
-
- AC_PATH_PROG([Genlib],[genlib])
-fi
-
-# We don't want to bundle a MinGW-w64 toolchain
-# So we have to find these individual tools.
-# See Note [tooldir: How GHC finds mingw on Windows]
-if test "$EnableDistroToolchain" = "YES"
-then
+# Extract and configure the Windows toolchain
+if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"; then
+ FP_SETUP_WINDOWS_TOOLCHAIN
+else
# Ideally should use AC_CHECK_TARGET_TOOL but our triples
# are screwed up. Configure doesn't think they're ever equal and
# so never tried without the prefix.
@@ -471,28 +370,28 @@ then
AC_PATH_PROG([DllWrap],[dllwrap])
AC_PATH_PROG([Windres],[windres])
AC_PATH_PROG([Genlib],[genlib])
-else
- AC_CHECK_TARGET_TOOL([Windres],[windres])
- AC_CHECK_TARGET_TOOL([DllWrap],[dllwrap])
- AC_CHECK_TARGET_TOOL([OBJDUMP],[objdump])
-fi
-DllWrapCmd="$DllWrap"
-WindresCmd="$Windres"
+ HAVE_GENLIB=False
+ if test "$HostOS" = "mingw32"; then
+ AC_CHECK_TARGET_TOOL([Windres],[windres])
+ AC_CHECK_TARGET_TOOL([DllWrap],[dllwrap])
+ AC_CHECK_TARGET_TOOL([OBJDUMP],[objdump])
-HAVE_GENLIB=False
-if test "$HostOS" = "mingw32"
-then
- if test "$Genlib" != ""; then
- GenlibCmd="$(cygpath -m $Genlib)"
- HAVE_GENLIB=True
+ if test "$Genlib" != ""; then
+ GenlibCmd="$(cygpath -m $Genlib)"
+ HAVE_GENLIB=True
+ fi
fi
fi
-AC_SUBST([DllWrapCmd])
-AC_SUBST([WindresCmd])
-AC_SUBST([GenlibCmd])
-AC_SUBST([HAVE_GENLIB])
+if test "$HostOS" = "mingw32"; then
+ DllWrapCmd="$DllWrap"
+ WindresCmd="$Windres"
+ AC_SUBST([DllWrapCmd])
+ AC_SUBST([WindresCmd])
+ AC_SUBST([GenlibCmd])
+ AC_SUBST([HAVE_GENLIB])
+fi
FP_ICONV
FP_GMP