diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in index 777c5259c52cef3092df0e9bf17cee8be09c234e..5095af3ac2ffc81f51a67312cf2a6d49570a08b1 100644 --- a/distrib/configure.ac.in +++ b/distrib/configure.ac.in @@ -103,6 +103,17 @@ AC_ARG_ENABLE(distro-toolchain, [EnableDistroToolchain=@SettingsUseDistroMINGW@] ) +if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"; then + FP_SETUP_WINDOWS_TOOLCHAIN([$hardtop/mingw/], [\$\$topdir/../mingw/]) +fi + +if test "$HostOS" = "mingw32"; then + WindresCmd="$Windres" + AC_SUBST([WindresCmd]) + AC_SUBST([GenlibCmd]) + AC_SUBST([HAVE_GENLIB]) +fi + dnl ** Which gcc to use? dnl -------------------------------------------------------------- AC_PROG_CC([gcc clang]) @@ -288,6 +299,7 @@ if test "x$UseLibdw" = "xYES" ; then fi AC_SUBST(UseLibdw) + FP_SETTINGS AC_CONFIG_FILES([config.mk]) diff --git a/hadrian/bindist/Makefile b/hadrian/bindist/Makefile index 32fa695d649ebb7947fd5379c0c98ed74ec7b755..fb34637fc6a05236acafdd4e25810c2e659974c9 100644 --- a/hadrian/bindist/Makefile +++ b/hadrian/bindist/Makefile @@ -62,20 +62,29 @@ show: .PHONY: install -ifeq "$(TargetOS_CPP)" "mingw32" -install_bin: install_mingw install_bin_direct +ifeq "$(EnableDistroToolchain)" "NO" +install_extra: install_mingw +else +install_extra: +endif + +ifeq "$(RelocatableBuild)" "YES" +install_bin: install_bin_direct else install_bin: install_bin_libdir install_wrappers endif -install: install_bin install_lib + + +install: install_bin install_lib install_extra install: install_man install_docs update_package_db -ActualBinsDir=${ghclibdir}/bin ifeq "$(RelocatableBuild)" "YES" ActualLibsDir=${ghclibdir} +ActualBinsDir=${bindir} else ActualLibsDir=${ghclibdir}/lib +ActualBinsDir=${ghclibdir}/bin endif WrapperBinsDir=${bindir} diff --git a/hadrian/bindist/config.mk.in b/hadrian/bindist/config.mk.in index ab4ae7a90579350a70b530614d9cb6cf90c401ba..4a21d7d0e437401c2463be6265715940a2354b81 100644 --- a/hadrian/bindist/config.mk.in +++ b/hadrian/bindist/config.mk.in @@ -67,6 +67,13 @@ $(eval $(call set_default,dvidir,$${docdir})) $(eval $(call set_default,pdfdir,$${docdir})) $(eval $(call set_default,psdir,$${docdir})) +# On Windows we can only make a relocatable bindist because the normal install +# script creates wrapper scripts which do not work on windows. Therefore we force +# RelocatableBuild = YES here until/if that is ever fixed. +ifeq "$(Windows_Host)" "YES" +RelocatableBuild = YES +endif + ifeq "$(RelocatableBuild)" "YES" # Hack: our directory layouts tend to be different on Windows, so @@ -153,14 +160,6 @@ else GhcWithInterpreter=$(if $(findstring YES,$(DYNAMIC_GHC_PROGRAMS)),YES,NO) endif -# On Windows we normally want to make a relocatable bindist, to we -# ignore flags like libdir -ifeq "$(Windows_Host)" "YES" -RelocatableBuild = YES -else -RelocatableBuild = NO -endif - ifneq "$(DESTDIR)" "" diff --git a/hadrian/src/Rules/BinaryDist.hs b/hadrian/src/Rules/BinaryDist.hs index 3b39ad1453a4d61b4155a415dcc64612f621be16..8cb7e9063cb99c428ebf09f3657c42b4b95eabce 100644 --- a/hadrian/src/Rules/BinaryDist.hs +++ b/hadrian/src/Rules/BinaryDist.hs @@ -229,16 +229,6 @@ bindistRules = do cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName) ["recache"] - -- The settings file must be regenerated by the bindist installation - -- logic to account for the environment discovered by the bindist - -- configure script on the host. Not on Windows, however, where - -- we do not ship a configure script with the bindist. See #20254. - -- - -- N.B. we must do this after ghc-pkg has been run as it will go - -- looking for the settings files. - unless windowsHost $ - removeFile (bindistFilesDir -/- "lib" -/- "settings") - unless cross $ need ["docs"] -- TODO: we should only embed the docs that have been generated @@ -272,37 +262,33 @@ bindistRules = do whenM (liftIO (IO.doesDirectoryExist (root -/- "manpage"))) $ do copyDirectory (root -/- "manpage") bindistFilesDir - -- These scripts are only necessary in the configure/install - -- workflow which is not supported on windows. - -- TODO: Instead of guarding against windows, we could offer the - -- option to make a relocatable, but not installable bindist on any - -- platform. - unless windowsHost $ do - -- We then 'need' all the files necessary to configure and install - -- (as in, './configure [...] && make install') this build on some - -- other machine. - need $ map (bindistFilesDir -/-) - (["configure", "Makefile"] ++ bindistInstallFiles) - copyFile ("hadrian" -/- "bindist" -/- "config.mk.in") (bindistFilesDir -/- "config.mk.in") - generateBuildMk >>= writeFile' (bindistFilesDir -/- "build.mk") - copyFile ("hadrian" -/- "cfg" -/- "default.target.in") (bindistFilesDir -/- "default.target.in") - copyFile ("hadrian" -/- "cfg" -/- "default.host.target.in") (bindistFilesDir -/- "default.host.target.in") - forM_ bin_targets $ \(pkg, _) -> do - needed_wrappers <- pkgToWrappers pkg - forM_ needed_wrappers $ \wrapper_name -> do - let suffix = if useGhcPrefix pkg - then "ghc-" ++ version - else version - wrapper_content <- wrapper wrapper_name - let unversioned_wrapper_path = bindistFilesDir -/- "wrappers" -/- wrapper_name - versioned_wrapper = wrapper_name ++ "-" ++ suffix - versioned_wrapper_path = bindistFilesDir -/- "wrappers" -/- versioned_wrapper - -- Write the wrapper to the versioned path - writeFile' versioned_wrapper_path wrapper_content - -- Create a symlink from the non-versioned to the versioned. - liftIO $ do - IO.removeFile unversioned_wrapper_path <|> return () - IO.createFileLink versioned_wrapper unversioned_wrapper_path + -- We then 'need' all the files necessary to configure and install + -- (as in, './configure [...] && make install') this build on some + -- other machine. + need $ map (bindistFilesDir -/-) + (["configure", "Makefile"] ++ bindistInstallFiles) + copyFile ("hadrian" -/- "bindist" -/- "config.mk.in") (bindistFilesDir -/- "config.mk.in") + generateBuildMk >>= writeFile' (bindistFilesDir -/- "build.mk") + copyFile ("hadrian" -/- "cfg" -/- "default.target.in") (bindistFilesDir -/- "default.target.in") + copyFile ("hadrian" -/- "cfg" -/- "default.host.target.in") (bindistFilesDir -/- "default.host.target.in") + + -- todo: do we need these wrappers on windows + forM_ bin_targets $ \(pkg, _) -> do + needed_wrappers <- pkgToWrappers pkg + forM_ needed_wrappers $ \wrapper_name -> do + let suffix = if useGhcPrefix pkg + then "ghc-" ++ version + else version + wrapper_content <- wrapper wrapper_name + let unversioned_wrapper_path = bindistFilesDir -/- "wrappers" -/- wrapper_name + versioned_wrapper = wrapper_name ++ "-" ++ suffix + versioned_wrapper_path = bindistFilesDir -/- "wrappers" -/- versioned_wrapper + -- Write the wrapper to the versioned path + writeFile' versioned_wrapper_path wrapper_content + -- Create a symlink from the non-versioned to the versioned. + liftIO $ do + IO.removeFile unversioned_wrapper_path <|> return () + IO.createFileLink versioned_wrapper unversioned_wrapper_path let buildBinDist = buildBinDistX "binary-dist-dir" "bindist" buildBinDistReloc = buildBinDistX "reloc-binary-dist-dir" "reloc-bindist"