From ca8b11036c9b9b045aedf36584cb9942946e6a29 Mon Sep 17 00:00:00 2001
From: Karel Gardas <karel.gardas@centrum.cz>
Date: Fri, 8 Apr 2011 18:53:42 +0200
Subject: [PATCH] - disable shared lib support on Solaris 10 and older (fixes #4973)

---
 configure.ac     |   17 +++++++++++++++++
 mk/config.mk.in  |   13 +++++++++----
 mk/project.mk.in |    4 ++++
 3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index a8d535f..21e965b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -222,6 +222,21 @@ x86_64-apple-darwin)
     ;;
 esac
 
+# Testing if we shall enable shared libs support on Solaris.
+# Anything older than SunOS 5.11 aka Solaris 11 (Express) is broken.
+
+SOLARIS_BROKEN_SHLD=NO
+
+case $host in
+     i386-*-solaris2)
+     # here we go with the test
+     MINOR=`uname -r|cut -d '.' -f 2-`
+     if test "$MINOR" -lt "11"; then
+     	SOLARIS_BROKEN_SHLD=YES
+     fi
+     ;;
+esac
+
 # Sync this with cTargetArch in compiler/ghc.mk
 checkArch() {
     case $1 in
@@ -322,6 +337,8 @@ AC_SUBST(TargetVendor_CPP)
 AC_SUBST(exeext)
 AC_SUBST(soext)
 
+AC_SUBST(SOLARIS_BROKEN_SHLD)
+
 AC_ARG_WITH(hc,
 [AC_HELP_STRING([--with-hc=ARG],
         [Use ARG as the path to the compiler for compiling ordinary
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 4de412e..e5b6811 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -104,13 +104,18 @@ GhcDynamic=NO
 GhcProfiled=NO
 
 # Do we support shared libs?
-PlatformSupportsSharedLibs = $(if $(filter $(TARGETPLATFORM),\
-	i386-unknown-linux x86_64-unknown-linux \
+SharedLibsPlatformList = i386-unknown-linux x86_64-unknown-linux \
 	i386-unknown-freebsd x86_64-unknown-freebsd \
 	i386-unknown-openbsd x86_64-unknown-openbsd \
 	i386-unknown-mingw32 \
-	i386-unknown-solaris2 \
-	i386-apple-darwin powerpc-apple-darwin),YES,NO)
+	i386-apple-darwin powerpc-apple-darwin
+
+ifeq ($(SOLARIS_BROKEN_SHLD), NO)
+SharedLibsPlatformList := $(SharedLibsPlatformList) i386-unknown-solaris2
+endif
+
+PlatformSupportsSharedLibs = $(if $(filter $(TARGETPLATFORM),\
+	$(SharedLibsPlatformList)),YES,NO)
 
 # Build a compiler that will build *unregisterised* libraries and
 # binaries by default.  Unregisterised code is supposed to compile and
diff --git a/mk/project.mk.in b/mk/project.mk.in
index 3ceef15..58b0f1a 100644
--- a/mk/project.mk.in
+++ b/mk/project.mk.in
@@ -139,3 +139,7 @@ endif
 # This distinguishes "msys" and "cygwin", which are not
 # not distinguished by HOST_OS_CPP
 OSTYPE=@OSTYPE@
+
+# In case of Solaris OS, does it provide broken shared libs
+# linker or not?
+SOLARIS_BROKEN_SHLD=@SOLARIS_BROKEN_SHLD@
-- 
1.7.4.3

