Merge pull request #5151 from tom-cosgrove-arm/serialise-builds-of-archives-on-windows-2.16

Backport 2.16: Serialise builds of the .a files on Windows
diff --git a/library/Makefile b/library/Makefile
index 1e1b035..6a17091 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -110,6 +110,14 @@
 
 shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT)
 
+# Windows builds under Mingw can fail if make tries to create archives in the same
+# directory at the same time - see https://bugs.launchpad.net/gcc-arm-embedded/+bug/1848002.
+# This forces builds of the .a files to be serialised.
+ifdef WINDOWS
+libmbedtls.a: | libmbedx509.a
+libmbedx509.a: | libmbedcrypto.a
+endif
+
 # tls
 libmbedtls.a: $(OBJS_TLS)
 	echo "  AR    $@"