Skip to content
Snippets Groups Projects
Commit 41cbaf44 authored by Matthew Pickering's avatar Matthew Pickering Committed by Marge Bot
Browse files

packaging: Fix installation scripts on windows/RelocatableBuild case


This includes quite a lot of small fixes which fix the installation
makefile to work on windows properly. This also required fixing the
RelocatableBuild variable which seemed to have been broken for a long
while.

Sam helped me a lot writing this patch by providing a windows machine to
test the changes. Without him it would have taken ages to tweak
everything.

Co-authored-by: sheaf's avatarsheaf <sam.derbyshire@gmail.com>
parent fe23629b
No related branches found
No related tags found
No related merge requests found
......@@ -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])
......
......@@ -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}
......
......@@ -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)" ""
......
......@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment