I needed to apply the attached patches to git master to be able to build
on Solaris using the autoconf support and the Sun compilers - can they be
included for the 7.1 release?

There were two big portability problems I worked around instead of fixing:
 - Use of __inline and __inline__ instead of glheader.h's INLINE
 - Use of u_int{8,16,32}_t types instead of the C99 standard
    uint{8,16,32}_t

Since the Sun compilers and current Solaris headers are C99 compliant,
the standard forms (inline, uint*_t) work, but I had to add #defines
to map all the places the non-portable versions are used instead.  I
started doing global replaces to make all the mesa source consistent,
but the changes quickly became far larger than I wanted to submit this
close to a release, and adding the #defines protects the Solaris port
against future instances of these things coming back in.

-- 
        -Alan Coopersmith-           [EMAIL PROTECTED]
         Sun Microsystems, Inc. - X Window System Engineering


>From ee651be5e97e3b602e5776dd8de1c7a8d2c0fee0 Mon Sep 17 00:00:00 2001
From: Alan Coopersmith <[EMAIL PROTECTED]>
Date: Fri, 6 Jun 2008 16:06:09 -0700
Subject: [PATCH] Fix builds with compilers other than gcc 3.0 & newer

Add #include "glheader.h" for definition of __builtin_expect for compilers
that don't support it.
---
 src/glx/x11/indirect_vertex_program.c |    1 +
 src/glx/x11/pixelstore.c              |    1 +
 src/glx/x11/singlepix.c               |    1 +
 3 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/glx/x11/indirect_vertex_program.c 
b/src/glx/x11/indirect_vertex_program.c
index 5383dcc..8d7cec9 100644
--- a/src/glx/x11/indirect_vertex_program.c
+++ b/src/glx/x11/indirect_vertex_program.c
@@ -23,6 +23,7 @@
  * SOFTWARE.
  */
 
+#include "glheader.h"
 #include <inttypes.h>
 #include <GL/gl.h>
 #include "indirect.h"
diff --git a/src/glx/x11/pixelstore.c b/src/glx/x11/pixelstore.c
index 3bf1b35..8431b29 100644
--- a/src/glx/x11/pixelstore.c
+++ b/src/glx/x11/pixelstore.c
@@ -34,6 +34,7 @@
 **
 */
 
+#include "glheader.h"
 #include "glxclient.h"
 #include "indirect.h"
 
diff --git a/src/glx/x11/singlepix.c b/src/glx/x11/singlepix.c
index bc5b162..5f97766 100644
--- a/src/glx/x11/singlepix.c
+++ b/src/glx/x11/singlepix.c
@@ -34,6 +34,7 @@
 **
 */
 
+#include "glheader.h"
 #include "packsingle.h"
 #include "indirect.h"
 #include "dispatch.h"
-- 
1.4.1

>From 3c4b2835946f44cce5075688c78cdace69ece115 Mon Sep 17 00:00:00 2001
From: Alan Coopersmith <[EMAIL PROTECTED]>
Date: Fri, 6 Jun 2008 16:09:10 -0700
Subject: [PATCH] Make minstall work with Solaris /bin/sh

Solaris /bin/sh doesn't set $PWD for you
---
 bin/minstall |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/bin/minstall b/bin/minstall
index 819b2bc..8ee9608 100755
--- a/bin/minstall
+++ b/bin/minstall
@@ -42,6 +42,8 @@ if [ $# -ge 2 ] ; then
                        exit 0
                fi
 
+               PWDSAVE=`pwd`
+
                # determine file's type
                if [ -h "$FILE" ] ; then
                        #echo $FILE is a symlink
@@ -57,7 +59,6 @@ if [ $# -ge 2 ] ; then
 
                        FILE=`basename "$FILE"`
                        # Go to $DEST and make the link
-                       PWDSAVE="$PWD"
                        cd "$DEST"        # pushd
                                $RM "$FILE"
                                $SYMLINK "$TARGET" "$FILE"
-- 
1.4.1

>From 143181fe1c3fffac7a08f6f5f0496c426c658c79 Mon Sep 17 00:00:00 2001
From: Daniel Zhu <[EMAIL PROTECTED]>
Date: Fri, 20 Jun 2008 17:51:39 -0700
Subject: [PATCH] Rename quad function to quadr to avoid clash with Solaris quad 
typedef
---
 src/mesa/tnl_dd/t_dd_tritmp.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/tnl_dd/t_dd_tritmp.h b/src/mesa/tnl_dd/t_dd_tritmp.h
index 6c2378f..2bb8905 100644
--- a/src/mesa/tnl_dd/t_dd_tritmp.h
+++ b/src/mesa/tnl_dd/t_dd_tritmp.h
@@ -389,7 +389,7 @@ #endif
 
 #if DO_QUAD
 #if DO_FULL_QUAD
-static void TAG(quad)( GLcontext *ctx,
+static void TAG(quadr)( GLcontext *ctx,
                       GLuint e0, GLuint e1, GLuint e2, GLuint e3 )
 {
    struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
@@ -673,7 +673,7 @@ static void TAG(quad)( GLcontext *ctx,
    }
 }
 #else
-static void TAG(quad)( GLcontext *ctx, GLuint e0,
+static void TAG(quadr)( GLcontext *ctx, GLuint e0,
                       GLuint e1, GLuint e2, GLuint e3 )
 {
    if (DO_UNFILLED) {
@@ -765,7 +765,7 @@ #endif
 static void TAG(init)( void )
 {
 #if DO_QUAD
-   TAB[IND].quad = TAG(quad);
+   TAB[IND].quad = TAG(quadr);
 #endif
 #if DO_TRI
    TAB[IND].triangle = TAG(triangle);
-- 
1.4.1

>From ed395fb3b4fd55c091913c71c7c483f6b7c55aef Mon Sep 17 00:00:00 2001
From: Alan Coopersmith <[EMAIL PROTECTED]>
Date: Fri, 20 Jun 2008 17:58:53 -0700
Subject: [PATCH] Solaris port of Mesa 7.1 with autoconf support
---
 bin/mklib                               |   18 ++++++---
 configs/autoconf.in                     |    3 ++
 configure.ac                            |   60 +++++++++++++++++++++++++++----
 src/mesa/drivers/dri/common/dri_util.h  |    1 +
 src/mesa/drivers/dri/common/xmlconfig.c |    6 +++
 src/mesa/main/glheader.h                |   45 +++++++++++++++++++++--
 src/mesa/main/imports.h                 |    1 +
 7 files changed, 116 insertions(+), 18 deletions(-)

diff --git a/bin/mklib b/bin/mklib
index 2fb215e..0dc3135 100755
--- a/bin/mklib
+++ b/bin/mklib
@@ -61,7 +61,8 @@ do
            echo '  -minor N      specifies minor version number (default is 0)'
            echo '  -patch N      specifies patch version number (default is 0)'
            echo '  -lLIBRARY     specifies a dependency on LIBRARY'
-           echo '  -LDIR         search in DIR for library dependencies'
+           echo '  -LDIR         search in DIR for library dependencies at 
build time'
+           echo '  -RDIR         search in DIR for library dependencies at run 
time'
            echo '  -linker L     explicity specify the linker program to use 
(eg: gcc, g++)'
            echo '                Not observed on all systems at this time.'
            echo '  -ldflags OPT  specify any additional linker flags in OPT'
@@ -107,6 +108,9 @@ do
        -L*)
            DEPS="$DEPS $1"
            ;;
+       -R*)
+           DEPS="$DEPS $1"
+           ;;
        -Wl*)
             DEPS="$DEPS $1"
             ;;
@@ -336,7 +340,7 @@ #       rm -f exptmp
                        # use g++
                        LINK="g++"
                    else
-                       echo "mklib: warning: can't find C++ comiler, trying 
CC."
+                       echo "mklib: warning: can't find C++ compiler, trying 
CC."
                        LINK="CC"
                    fi
                else
@@ -365,9 +369,11 @@ #      rm -f exptmp
            # Check if objects are SPARC v9
            # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
            set ${OBJECTS}
-           SPARCV9=`file $1 | grep SPARCV9`
-           if [ "${SPARCV9}" ] ; then
-               OPTS="${OPTS} -xarch=v9"
+           if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
+               SPARCV9=`file $1 | grep SPARCV9`
+               if [ "${SPARCV9}" ] ; then
+                   OPTS="${OPTS} -xarch=v9"
+               fi
            fi
             if [ "${ALTOPTS}" ] ; then
                 OPTS=${ALTOPTS}
@@ -379,7 +385,7 @@ #       rm -f exptmp
                ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
            else
                rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
-               ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} 
${DEPS}
+               ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h 
${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
                ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
            fi
            FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
diff --git a/configs/autoconf.in b/configs/autoconf.in
index 9a70ec1..ed44a0f 100644
--- a/configs/autoconf.in
+++ b/configs/autoconf.in
@@ -98,3 +98,6 @@ DRI_DRIVER_INSTALL_DIR = @DRI_DRIVER_INS
 
 # Where libGL will look for DRI hardware drivers
 DRI_DRIVER_SEARCH_DIR = $(DRI_DRIVER_INSTALL_DIR)
+
+# Additional per-platform configuration settings
[EMAIL PROTECTED]@
diff --git a/configure.ac b/configure.ac
index a054330..c4b65db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,6 +29,18 @@ AC_CHECK_PROGS([MAKE], [gmake make])
 AC_PATH_PROG([MKDEP], [makedepend])
 AC_PATH_PROG([SED], [sed])
 
+dnl Platform-specific program settings
+EXTRA_CONFIG_LINES=""
+AC_SUBST([EXTRA_CONFIG_LINES])
+case "$host_os" in
+solaris*)
+    # Solaris /bin/sh is too old/non-POSIX compliant
+    AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
+    EXTRA_CONFIG_LINES="SHELL=$POSIX_SHELL"
+    ;;
+esac
+
+
 MKDEP_OPTIONS=-fdepend
 dnl Ask gcc where it's keeping its secret headers
 if test "x$GCC" = xyes; then
@@ -75,6 +87,9 @@ if test "x$GCC" = xyes; then
 fi
     DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS 
-DHAVE_POSIX_MEMALIGN"
     ;;
+solaris*)
+    DEFINES="$DEFINES -DPTHREADS -DSVR4"
+    ;;
 esac
 
 dnl Add flags for gcc and g++
@@ -325,6 +340,16 @@ if test "x$enable_selinux" = "xyes"; the
     DEFINES="$DEFINES -DMESA_SELINUX"
 fi
 
+dnl OS-specific libraries
+OS_LIBS=""
+case "$host_os" in
+solaris*)
+    OS_LIBS="-lc"
+    if test "x$GXX" != xyes; then
+        OS_CPLUSPLUS_LIBS="-lCrun $OS_LIBS"
+    fi
+    ;;
+esac
 
 dnl
 dnl Driver configuration. Options are xlib, dri and osmesa right now.
@@ -478,7 +503,7 @@ xlib)
         X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
         GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
     fi
-    GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread"
+    GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $OS_LIBS"
 
     # if static, move the external libraries to the programs
     # and empty the libraries for libGL
@@ -522,11 +547,11 @@ dri)
     fi
 
     # need DRM libs, -lpthread, etc.
-    GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
+    GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS $OS_LIBS"
     ;;
 osmesa)
     # No libGL for osmesa
-    GL_LIB_DEPS=""
+    GL_LIB_DEPS="$OS_LIBS"
     ;;
 esac
 AC_SUBST([GL_LIB_DEPS])
@@ -671,6 +696,13 @@ if test "$mesa_driver" = dri; then
                 unichrome savage sis swrast"
         fi
         ;;
+    solaris*)
+        DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
+        DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
+        if test "x$driglx_direct" = xyes; then
+            DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
+        fi
+        ;;
     esac
 
     # default drivers
@@ -750,7 +782,7 @@ AC_SUBST([OSMESA_LIB])
 
 case "$mesa_driver" in
 osmesa)
-    # only link librararies with osmesa if shared
+    # only link libraries with osmesa if shared
     if test "$enable_static" = no; then
         OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
     else
@@ -761,7 +793,7 @@ osmesa)
 *)
     # Link OSMesa to libGL otherwise
     OSMESA_LIB_DEPS=""
-    # only link librararies with osmesa if shared
+    # only link libraries with osmesa if shared
     if test "$enable_static" = no; then
         OSMESA_MESA_DEPS='-l$(GL_LIB)'
     else
@@ -769,6 +801,9 @@ osmesa)
     fi
     ;;
 esac
+if test "$enable_static" = no; then
+    OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS $OS_LIBS"
+fi
 AC_SUBST([OSMESA_LIB_DEPS])
 AC_SUBST([OSMESA_MESA_DEPS])
 
@@ -812,6 +847,9 @@ if test "x$enable_glu" = xyes; then
         ;;
     esac
 fi
+if test "$enable_static" = no; then
+    GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
+fi
 AC_SUBST([GLU_LIB_DEPS])
 AC_SUBST([GLU_MESA_DEPS])
 
@@ -841,6 +879,7 @@ if test "x$enable_glw" = xyes; then
     # If static, empty GLW_LIB_DEPS and add libs for programs to link
     if test "$enable_static" = no; then
         GLW_MESA_DEPS='-l$(GL_LIB)'
+        GLW_LIB_DEPS="$GLW_LIB_DEPS $OS_LIBS"
     else
         APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
         GLW_LIB_DEPS=""
@@ -888,7 +927,7 @@ if test "x$enable_glut" = xyes; then
         # should check these...
         GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
     fi
-    GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
+    GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm $OS_LIBS"
 
     # If glut is available, we can build most programs
     if test "$with_demos" = yes; then
@@ -914,7 +953,14 @@ dnl    Only libm is added here if necess
 dnl    be pulled in by the linker
 dnl
 if test "x$APP_LIB_DEPS" = x; then
-    APP_LIB_DEPS="-lm"
+    case "$host_os" in
+    solaris*)
+        APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
+        ;;
+    *)
+        APP_LIB_DEPS="-lm"
+        ;;
+    esac
 fi
 AC_SUBST([APP_LIB_DEPS])
 AC_SUBST([PROGRAM_DIRS])
diff --git a/src/mesa/drivers/dri/common/dri_util.h 
b/src/mesa/drivers/dri/common/dri_util.h
index 203479e..f126d08 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -53,6 +53,7 @@ #include <GL/gl.h>
 #include <drm.h>
 #include <drm_sarea.h>
 #include <xf86drm.h>
+#include "glheader.h"
 #include "GL/internal/glcore.h"
 #include "GL/internal/dri_interface.h"
 #include "GL/internal/dri_sarea.h"
diff --git a/src/mesa/drivers/dri/common/xmlconfig.c 
b/src/mesa/drivers/dri/common/xmlconfig.c
index 8602d47..f6ae755 100644
--- a/src/mesa/drivers/dri/common/xmlconfig.c
+++ b/src/mesa/drivers/dri/common/xmlconfig.c
@@ -63,6 +63,12 @@ #    endif
 #elif defined(__NetBSD__) && defined(__NetBSD_Version) && (__NetBSD_Version >= 
106000100)
 #    include <stdlib.h>
 #    define GET_PROGRAM_NAME() getprogname()
+#elif defined(__sun)
+/* Solaris has getexecname() which returns the full path - return just
+   the basename to match BSD getprogname() */
+#    include <stdlib.h>
+#    include <libgen.h>
+#    define GET_PROGRAM_NAME() basename(getexecname())
 #endif
 
 #if !defined(GET_PROGRAM_NAME)
diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h
index c6f81fd..533e4a2 100644
--- a/src/mesa/main/glheader.h
+++ b/src/mesa/main/glheader.h
@@ -76,6 +76,30 @@ #else
 #  include <inttypes.h>
 #endif
 
+/* For platforms that have the C99 standard uint*_t,
+   but not the commonly used u_int*_t */
+#if defined(__sun)
+# define u_int8_t uint8_t
+# define u_int16_t uint16_t
+# define u_int32_t uint32_t
+# define u_int64_t uint64_t
+# define u_intptr_t uintptr_t
+#endif
+
+/* Sun compilers define __i386 instead of the gcc-style __i386__ */
+#ifdef __SUNPRO_C
+# if !defined(__i386__) && defined(__i386)
+#  define __i386__
+# elif !defined(__amd64__) && defined(__amd64)
+#  define __amd64__
+# elif !defined(__sparc__) && defined(__sparc)
+#  define __sparc__
+# endif
+# if !defined(__volatile)
+#  define __volatile volatile
+# endif
+#endif
+
 #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && 
!defined(BUILD_FOR_SNAP)
 #  define __WIN32__
 #  define finite _finite
@@ -195,6 +219,12 @@ #elif defined(__INTEL_COMPILER)
 #  define INLINE inline
 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
 #  define INLINE __inline
+#elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
+#  define INLINE inline
+#  define __inline inline
+#  define __inline__ inline
+#elif (__STDC_VERSION__ >= 199901L) /* C99 */
+#  define INLINE inline
 #else
 #  define INLINE
 #endif
@@ -240,12 +270,17 @@ #endif
  * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
  * Don't define it if using a newer Windows compiler.
  */
-#if defined(__VMS)
-# define __FUNCTION__ "VMS$NL:"
-#elif __STDC_VERSION__ < 199901L
-# if ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \
+#ifndef __FUNCTION__
+# if defined(__VMS)
+#  define __FUNCTION__ "VMS$NL:"
+# elif ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \
       (!defined(_MSC_VER) || _MSC_VER < 1300)
-#  define __FUNCTION__ "<unknown>"
+#  if (__STDC_VERSION__ >= 199901L) /* C99 */ || \
+    (defined(__SUNPRO_C) && defined(__C99FEATURES__))
+#   define __FUNCTION__ __func__
+#  else
+#   define __FUNCTION__ "<unknown>"
+#  endif
 # endif
 #endif
 
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 7ee26b4..00a18d3 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -165,6 +165,7 @@ #if defined(__i386__) || defined(__386__
     defined(__mips) || defined(_MIPS_ARCH) || \
     defined(__arm__) || \
     defined(__sh__) || defined(__m32r__) || \
+    (defined(__sun) && defined(_IEEE_754)) || \
     (defined(__alpha__) && (defined(__IEEE_FLOAT) || !defined(VMS)))
 #define USE_IEEE
 #define IEEE_ONE 0x3f800000
-- 
1.4.1

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to