@@ -59,7 +59,6 @@ CMAKE_COMMON += -DCMAKE_SYSTEM_NAME=Windows
5959CMAKE_COMMON += -DCMAKE_RC_COMPILER="$$(which $(CROSS_COMPILE ) windres ) "
6060endif
6161
62- # For now this is LLVM specific, but I expect it won't be in the future
6362ifeq ($(CMAKE_GENERATOR ) ,Ninja)
6463CMAKE_GENERATOR_COMMAND := -G Ninja
6564else ifeq ($(CMAKE_GENERATOR),make)
6867$(error Unknown CMake generator '$(CMAKE_GENERATOR)'. Options are 'Ninja' and 'make')
6968endif
7069
70+ ifneq (,$(findstring MINGW,$(RAW_BUILD_OS ) ) )
71+ ifneq (,$(shell ldd $(shell which cmake) | grep msys-2.0.dll) )
72+ # Detect MSYS2 with cygwin CMake rather than MinGW cmake - the former fails to
73+ # properly drive MinGW tools
74+ override CMAKE := echo "ERROR: CMake is Cygwin CMake, not MinGW CMake. Build will fail. Use 'pacman -S mingw-w64-{i686,x86_64}-cmake'."; exit 1; $(CMAKE )
75+ endif
76+ # In our setup, CMAKE_INSTALL_PREFIX is a relative path inside usr-staging.
77+ # We do not want this converted to a windows path, because our make system
78+ # assumes it to be relative to msys `/`.
79+ override CMAKE := MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX" $(CMAKE )
80+ endif
81+
82+ # Some dependencies' tarballs contains symlinks to non-existent targets. This breaks the
83+ # the default msys strategy `deepcopy` symlink strategy. To workaround this,
84+ # switch to `native` which tries native windows symlinks (possible if the
85+ # machine is in developer mode) - or if not, falls back to cygwin-style
86+ # symlinks. We don't particularly care either way - we just need to symlinks
87+ # to succeed. We could guard this by a uname check, but it's harmless elsewhere,
88+ # so let's not incur the additional overhead.
89+ MSYS_NONEXISTENT_SYMLINK_TARGET_FIX := export MSYS=winsymlinks:native
90+
7191# If the top-level Makefile is called with environment variables,
7292# they will override the values passed above to ./configure
7393MAKE_COMMON := DESTDIR="" prefix=$(build_prefix ) bindir=$(build_depsbindir ) libdir=$(build_libdir ) shlibdir=$(build_shlibdir ) libexecdir=$(build_libexecdir ) datarootdir=$(build_datarootdir ) includedir=$(build_includedir ) sysconfdir=$(build_sysconfdir ) O=
@@ -144,7 +164,7 @@ upper = $(shell echo $1 | tr a-z A-Z)
144164# this rule ensures that make install is more nearly atomic
145165# so it's harder to get half-installed (or half-reinstalled) dependencies
146166# # and enables sharing deps compiles, uninstall, and fast reinstall
147- MAKE_INSTALL = + $$(MAKE ) -C $1 install $$(MAKE_COMMON ) $3 DESTDIR="$2"
167+ MAKE_INSTALL = MSYS2_ARG_CONV_EXCL="prefix=" $$(MAKE ) -C $1 install $$(MAKE_COMMON ) $3 DESTDIR="$2"
148168
149169define SHLIBFILE_INSTALL
150170 mkdir -p $2/$$(build_shlibdir )
0 commit comments