Fix missing -static-libgcc when building dlls
diff --git a/ChangeLog b/ChangeLog
index 8f5a03b..243b865 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,8 @@
      Studio projects (found by Kristian Bendiksen).
    * Fix build error with CMake and pre-4.5 versions of GCC (found by Hugo
      Leisink).
+   * Fix missing -static-ligcc when building shared libraries for Windows with
+     make.
 
 Changes
    * Add SSL_MIN_DHM_BYTES configuration parameter in config.h to choose the
diff --git a/library/Makefile b/library/Makefile
index 20b9860..c7c5bf0 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -126,7 +126,7 @@
 
 libmbedtls.dll: $(OBJS)
 	echo "  LD    $@"
-	$(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS) -lws2_32 -lwinmm -lgdi32 $(LOCAL_LDFLAGS) $(LDFLAGS)
+	$(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS) -lws2_32 -lwinmm -lgdi32 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
 
 .c.o:
 	echo "  CC    $<"
diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh
index 6ca8cd7..aecdd4d 100755
--- a/tests/scripts/all.sh
+++ b/tests/scripts/all.sh
@@ -158,6 +158,12 @@
 scripts/config.pl set POLARSSL_PLATFORM_NO_STD_FUNCTIONS
 CC=gcc CFLAGS='-Werror -O0' make
 
+if uname -a | grep -F Linux >/dev/null; then
+msg "build/test: make shared" # ~ 40s
+cleanup
+make SHARED=1 all check
+fi
+
 if uname -a | grep -F x86_64 >/dev/null; then
 msg "build: i386, make, gcc" # ~ 30s
 cleanup
@@ -208,7 +214,10 @@
 if which i686-w64-mingw32-gcc >/dev/null; then
 msg "build: cross-mingw64, make" # ~ 30s
 cleanup
-CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS=-Werror WINDOWS_BUILD=1 make
+CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 make
+WINDOWS_BUILD=1 make clean
+CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1 make
+WINDOWS_BUILD=1 make clean
 fi
 
 # MemSan currently only available on Linux 64 bits