2012-11-14 13:05:49 +00:00
|
|
|
# Copyright 2012 Yann Diorcet
|
|
|
|
# Licensed under the GPL v2. See COPYING in the root of this package
|
|
|
|
|
2018-11-24 06:14:07 +00:00
|
|
|
mingw_w64_set_install_prefix()
|
|
|
|
{
|
2015-03-24 14:07:51 +00:00
|
|
|
MINGW_INSTALL_PREFIX=/usr/${CT_TARGET}
|
2017-05-30 05:32:38 +00:00
|
|
|
if [[ ${CT_MINGW_W64_VERSION} == 2* ]]; then
|
2015-03-24 14:07:51 +00:00
|
|
|
MINGW_INSTALL_PREFIX=/usr
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
Fold libc_start_files into libc
After 557b9d4, libc_start_files and libc_main steps are performed one
after another. It doesn't make sense, especially since some of the libcs
(glibc, uClibc-ng) go to great lengths to first install start files in
the first step, libc_start_files, only to remove them immediately in the
second step, libc_main.
Current build steps also break in the xtensa newlib configurations, as
it needs to install the custom xtensa headers before building the libgcc
and after 557b9d4, the headers are not installed before libgcc is built
in pass-1.
Therefore, finish what 557b9d4 mentioned but did not do: move header
installation into a new step, libc_headers, and combine libc_start_files
and libc_main into a single step.
This also allows to combine the core pass-1/pass-2 steps, to be done in
a subsequent commit.
Signed-off-by: Alexey Neyman <stilor@att.net>
2022-02-08 23:52:48 +00:00
|
|
|
mingw_w64_headers() {
|
2012-11-14 13:05:49 +00:00
|
|
|
local -a sdk_opts
|
|
|
|
|
2010-07-11 19:36:20 +00:00
|
|
|
CT_DoStep INFO "Installing C library headers"
|
|
|
|
|
2012-11-14 13:05:49 +00:00
|
|
|
case "${CT_MINGW_DIRECTX}:${CT_MINGW_DDK}" in
|
|
|
|
y:y) sdk_opts+=( "--enable-sdk=all" );;
|
|
|
|
y:) sdk_opts+=( "--enable-sdk=directx" );;
|
|
|
|
:y) sdk_opts+=( "--enable-sdk=ddk" );;
|
|
|
|
:) ;;
|
|
|
|
esac
|
|
|
|
|
2017-04-07 20:57:05 +00:00
|
|
|
if [ "${CT_MINGW_SECURE_API}" = "y" ]; then
|
|
|
|
sdk_opts+=( "--enable-secure-api" )
|
|
|
|
fi
|
2017-04-07 01:22:33 +00:00
|
|
|
|
2023-05-30 11:47:19 +00:00
|
|
|
if [ "${CT_MINGW_DEFAULT_MSVCRT_MSVCRT}" = "y" ]; then
|
|
|
|
sdk_opts+=( "--with-default-msvcrt=msvcrt" )
|
|
|
|
elif [ "${CT_MINGW_DEFAULT_MSVCRT_UCRT}" = "y" ]; then
|
|
|
|
sdk_opts+=( "--with-default-msvcrt=ucrt" )
|
|
|
|
elif [ -n "${CT_MINGW_DEFAULT_MSVCRT}" ]; then
|
|
|
|
sdk_opts+=( "--with-default-msvcrt=${CT_MINGW_DEFAULT_MSVCRT}" )
|
|
|
|
fi
|
|
|
|
|
2012-11-14 13:05:49 +00:00
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-headers"
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Configuring Headers"
|
|
|
|
|
2018-11-24 06:14:07 +00:00
|
|
|
mingw_w64_set_install_prefix
|
2012-11-14 13:05:49 +00:00
|
|
|
CT_DoExecLog CFG \
|
2017-01-25 08:06:28 +00:00
|
|
|
${CONFIG_SHELL} \
|
2017-05-30 05:32:38 +00:00
|
|
|
"${CT_SRC_DIR}/mingw-w64/mingw-w64-headers/configure" \
|
2012-11-14 13:05:49 +00:00
|
|
|
--build=${CT_BUILD} \
|
|
|
|
--host=${CT_TARGET} \
|
2015-03-24 14:07:51 +00:00
|
|
|
--prefix=${MINGW_INSTALL_PREFIX} \
|
2012-11-14 13:05:49 +00:00
|
|
|
"${sdk_opts[@]}"
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Compile Headers"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make
|
2012-11-14 13:05:49 +00:00
|
|
|
|
|
|
|
CT_DoLog EXTRA "Installing Headers"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR}
|
2015-03-24 14:07:51 +00:00
|
|
|
|
2012-11-14 13:05:49 +00:00
|
|
|
CT_Popd
|
2011-01-25 23:04:41 +00:00
|
|
|
|
|
|
|
# It seems mingw is strangely set up to look into /mingw instead of
|
|
|
|
# /usr (notably when looking for the headers). This symlink is
|
|
|
|
# here to workaround this, and seems to be here to last... :-/
|
2012-11-14 13:05:49 +00:00
|
|
|
CT_DoExecLog ALL ln -sv "usr/${CT_TARGET}" "${CT_SYSROOT_DIR}/mingw"
|
2010-07-11 19:36:20 +00:00
|
|
|
|
|
|
|
CT_EndStep
|
|
|
|
}
|
|
|
|
|
2015-03-24 14:07:51 +00:00
|
|
|
do_check_mingw_vendor_tuple()
|
|
|
|
{
|
2022-01-05 08:37:45 +00:00
|
|
|
CT_DoStep INFO "Checking configured vendor tuple"
|
|
|
|
if [ ${CT_TARGET_VENDOR} = "w64" ]; then
|
|
|
|
CT_DoLog DEBUG "The tuple is set to '${CT_TARGET_VENDOR}', as recommended by mingw-64 developers."
|
|
|
|
else
|
|
|
|
CT_DoLog WARN "The tuple vendor is '${CT_TARGET_VENDOR}', not equal to 'w64' and might break the toolchain!"
|
|
|
|
fi
|
|
|
|
CT_EndStep
|
2015-03-24 14:07:51 +00:00
|
|
|
}
|
|
|
|
|
2017-03-29 20:26:13 +00:00
|
|
|
do_mingw_tools()
|
|
|
|
{
|
|
|
|
local f
|
|
|
|
|
|
|
|
for f in "${CT_MINGW_TOOL_LIST_ARRAY[@]}"; do
|
|
|
|
CT_mkdir_pushd "${f}"
|
2017-05-30 05:32:38 +00:00
|
|
|
if [ ! -d "${CT_SRC_DIR}/mingw-w64/mingw-w64-tools/${f}" ]; then
|
2017-03-29 20:26:13 +00:00
|
|
|
CT_DoLog WARN "Skipping ${f}: not found"
|
|
|
|
CT_Popd
|
|
|
|
continue
|
2016-10-07 02:54:46 +00:00
|
|
|
fi
|
|
|
|
|
2017-03-29 20:26:13 +00:00
|
|
|
CT_DoLog EXTRA "Configuring ${f}"
|
2016-10-07 02:54:46 +00:00
|
|
|
CT_DoExecLog CFG \
|
2017-01-25 08:06:28 +00:00
|
|
|
${CONFIG_SHELL} \
|
2017-05-30 05:32:38 +00:00
|
|
|
"${CT_SRC_DIR}/mingw-w64/mingw-w64-tools/${f}/configure" \
|
2016-10-07 02:54:46 +00:00
|
|
|
--build=${CT_BUILD} \
|
|
|
|
--host=${CT_HOST} \
|
|
|
|
--target=${CT_TARGET} \
|
|
|
|
--program-prefix=${CT_TARGET}- \
|
|
|
|
--prefix="${CT_PREFIX_DIR}"
|
|
|
|
|
2018-11-24 06:14:07 +00:00
|
|
|
# mingw-w64 has issues with parallel builds, see mingw_w64_main
|
2017-03-29 20:26:13 +00:00
|
|
|
CT_DoLog EXTRA "Building ${f}"
|
|
|
|
CT_DoExecLog ALL make
|
|
|
|
CT_DoLog EXTRA "Installing ${f}"
|
|
|
|
CT_DoExecLog ALL make install
|
|
|
|
CT_Popd
|
|
|
|
done
|
|
|
|
}
|
2016-10-07 02:54:46 +00:00
|
|
|
|
2017-03-29 20:26:13 +00:00
|
|
|
do_mingw_pthreads()
|
|
|
|
{
|
|
|
|
local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count multi_target
|
|
|
|
local libprefix
|
|
|
|
local rcflags dlltoolflags
|
2016-10-07 02:54:46 +00:00
|
|
|
|
2017-03-29 20:26:13 +00:00
|
|
|
for arg in "$@"; do
|
|
|
|
eval "${arg// /\\ }"
|
2016-10-07 02:54:46 +00:00
|
|
|
done
|
2017-03-29 20:26:13 +00:00
|
|
|
|
|
|
|
CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'"
|
|
|
|
|
|
|
|
libprefix="${MINGW_INSTALL_PREFIX}/lib/${multi_os_dir}"
|
|
|
|
CT_SanitizeVarDir libprefix
|
|
|
|
|
|
|
|
CT_SymlinkToolsMultilib
|
|
|
|
|
|
|
|
# DLLTOOLFLAGS does not appear to be currently used by winpthread package, but
|
|
|
|
# the master package uses this variable and describes this as one of the changes
|
|
|
|
# needed for i686 in mingw-w64-doc/howto-build/mingw-w64-howto-build-adv.txt
|
|
|
|
case "${multi_target}" in
|
|
|
|
i[3456]86-*)
|
|
|
|
rcflags="-F pe-i386"
|
|
|
|
dlltoolflags="-m i386"
|
|
|
|
;;
|
|
|
|
x86_64-*)
|
|
|
|
rcflags="-F pe-x86-64"
|
|
|
|
dlltoolflags="-m i386:x86_64"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
CT_Abort "Tuple ${multi_target} is not supported by mingw-w64"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Configuring mingw-w64-winpthreads"
|
|
|
|
|
|
|
|
CT_DoExecLog CFG \
|
|
|
|
CFLAGS="${multi_flags}" \
|
|
|
|
CXXFLAGS="${multi_flags}" \
|
|
|
|
RCFLAGS="${rcflags}" \
|
|
|
|
DLLTOOLFLAGS="${dlltoolflags}" \
|
|
|
|
${CONFIG_SHELL} \
|
2017-05-30 05:32:38 +00:00
|
|
|
"${CT_SRC_DIR}/mingw-w64/mingw-w64-libraries/winpthreads/configure" \
|
2017-03-29 20:26:13 +00:00
|
|
|
--with-sysroot=${CT_SYSROOT_DIR} \
|
|
|
|
--prefix=${MINGW_INSTALL_PREFIX} \
|
|
|
|
--libdir=${libprefix} \
|
|
|
|
--build=${CT_BUILD} \
|
|
|
|
--host=${multi_target}
|
|
|
|
|
2018-11-24 06:14:07 +00:00
|
|
|
# mingw-w64 has issues with parallel builds, see mingw_w64_main
|
2017-03-29 20:26:13 +00:00
|
|
|
CT_DoLog EXTRA "Building mingw-w64-winpthreads"
|
|
|
|
CT_DoExecLog ALL make
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Installing mingw-w64-winpthreads"
|
|
|
|
CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR}
|
|
|
|
|
2018-05-04 05:28:10 +00:00
|
|
|
# Post-install hackery: all libwinpthread-1.dll end up being installed
|
|
|
|
# into /bin, which is broken on multilib install. Hence, stash it back
|
|
|
|
# into /lib - and after iterating over multilibs, copy the default one
|
|
|
|
# back into /bin.
|
|
|
|
if [ "${multi_index}" != 1 -o "${multi_count}" != 1 ]; then
|
|
|
|
CT_DoExecLog ALL mv "${CT_SYSROOT_DIR}${MINGW_INSTALL_PREFIX}/bin/libwinpthread-1.dll" \
|
|
|
|
"${CT_SYSROOT_DIR}${libprefix}/libwinpthread-1.dll"
|
|
|
|
if [ "${multi_index}" = 1 ]; then
|
|
|
|
default_libprefix="${libprefix}"
|
|
|
|
elif [ "${multi_index}" = "${multi_count}" ]; then
|
|
|
|
CT_DoExecLog ALL cp "${CT_SYSROOT_DIR}${default_libprefix}/libwinpthread-1.dll" \
|
|
|
|
"${CT_SYSROOT_DIR}${MINGW_INSTALL_PREFIX}/bin/libwinpthread-1.dll"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-03-29 20:26:13 +00:00
|
|
|
CT_EndStep
|
2016-10-07 02:54:46 +00:00
|
|
|
}
|
|
|
|
|
2018-11-24 06:14:07 +00:00
|
|
|
mingw_w64_main()
|
2017-03-29 20:26:13 +00:00
|
|
|
{
|
2018-05-04 05:28:10 +00:00
|
|
|
# Used when iterating over libwinpthread
|
|
|
|
local default_libprefix
|
2023-05-30 11:47:19 +00:00
|
|
|
local -a crt_opts
|
2018-05-04 05:28:10 +00:00
|
|
|
|
2015-03-24 14:07:51 +00:00
|
|
|
do_check_mingw_vendor_tuple
|
|
|
|
|
2017-03-29 20:26:13 +00:00
|
|
|
CT_DoStep INFO "Building mingw-w64"
|
2010-07-11 19:36:20 +00:00
|
|
|
|
2012-11-14 13:05:49 +00:00
|
|
|
CT_DoLog EXTRA "Configuring mingw-w64-crt"
|
2010-07-11 19:36:20 +00:00
|
|
|
|
2012-11-14 13:05:49 +00:00
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-crt"
|
2010-07-11 19:36:20 +00:00
|
|
|
|
2023-05-30 11:47:19 +00:00
|
|
|
if [ "${CT_MINGW_DEFAULT_MSVCRT_MSVCRT}" = "y" ]; then
|
|
|
|
crt_opts+=( "--with-default-msvcrt=msvcrt" )
|
|
|
|
elif [ "${CT_MINGW_DEFAULT_MSVCRT_UCRT}" = "y" ]; then
|
|
|
|
crt_opts+=( "--with-default-msvcrt=ucrt" )
|
|
|
|
elif [ -n "${CT_MINGW_DEFAULT_MSVCRT}" ]; then
|
|
|
|
crt_opts+=( "--with-default-msvcrt=${CT_MINGW_DEFAULT_MSVCRT}" )
|
|
|
|
fi
|
|
|
|
|
2018-11-24 06:14:07 +00:00
|
|
|
mingw_w64_set_install_prefix
|
2017-03-29 20:26:13 +00:00
|
|
|
CT_DoExecLog CFG \
|
|
|
|
${CONFIG_SHELL} \
|
2017-05-30 05:32:38 +00:00
|
|
|
"${CT_SRC_DIR}/mingw-w64/mingw-w64-crt/configure" \
|
2017-03-29 20:26:13 +00:00
|
|
|
--with-sysroot=${CT_SYSROOT_DIR} \
|
|
|
|
--prefix=${MINGW_INSTALL_PREFIX} \
|
|
|
|
--build=${CT_BUILD} \
|
2023-05-30 11:47:19 +00:00
|
|
|
--host=${CT_TARGET} \
|
|
|
|
"${crt_opts[@]}"
|
2010-07-11 19:36:20 +00:00
|
|
|
|
2015-11-11 02:21:43 +00:00
|
|
|
# mingw-w64-crt has a missing dependency occasionally breaking the
|
|
|
|
# parallel build. See https://github.com/crosstool-ng/crosstool-ng/issues/246
|
2019-04-04 23:47:50 +00:00
|
|
|
# Do not pass ${CT_JOBSFLAGS} - build serially.
|
2012-11-14 13:05:49 +00:00
|
|
|
CT_DoLog EXTRA "Building mingw-w64-crt"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make
|
2010-07-11 19:36:20 +00:00
|
|
|
|
2012-11-14 13:05:49 +00:00
|
|
|
CT_DoLog EXTRA "Installing mingw-w64-crt"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR}
|
2010-07-11 19:36:20 +00:00
|
|
|
CT_EndStep
|
2016-03-07 22:57:29 +00:00
|
|
|
|
|
|
|
if [ "${CT_THREADS}" = "posix" ]; then
|
2017-03-29 20:26:13 +00:00
|
|
|
CT_DoStep INFO "Building mingw-w64-winpthreads"
|
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-winpthreads"
|
|
|
|
CT_IterateMultilibs do_mingw_pthreads pthreads-multilib
|
|
|
|
CT_Popd
|
|
|
|
CT_EndStep
|
|
|
|
fi
|
|
|
|
|
2017-04-06 19:45:22 +00:00
|
|
|
if [ "${CT_MINGW_TOOLS}" = "y" ]; then
|
2017-03-29 20:26:13 +00:00
|
|
|
CT_DoStep INFO "Installing mingw-w64 companion tools"
|
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-tools"
|
|
|
|
do_mingw_tools
|
|
|
|
CT_Popd
|
|
|
|
CT_EndStep
|
2016-03-07 22:57:29 +00:00
|
|
|
fi
|
2010-07-11 19:36:20 +00:00
|
|
|
}
|