Merge branch 'mesa_7_5_branch' into mesa_7_6_branch
diff --git a/configs/default b/configs/default
index 127b98e..2168b29 100644
--- a/configs/default
+++ b/configs/default
@@ -23,6 +23,7 @@
 CFLAGS = -O
 CXXFLAGS = -O
 LDFLAGS =
+HOST_CFLAGS = $(CFLAGS)
 GLU_CFLAGS = 
 
 # Compiler for building demos/tests/etc
diff --git a/configure.ac b/configure.ac
index c5ef676..7518976 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1202,7 +1202,7 @@
 fi
 
 dnl
-dnl Gallium Radeon configuration
+dnl Gallium Nouveau configuration
 dnl
 AC_ARG_ENABLE([gallium-nouveau],
     [AS_HELP_STRING([--enable-gallium-nouveau],
diff --git a/docs/relnotes-7.5.2.html b/docs/relnotes-7.5.2.html
index 3210014..ecdab29 100644
--- a/docs/relnotes-7.5.2.html
+++ b/docs/relnotes-7.5.2.html
@@ -45,6 +45,8 @@
 <ul>
 <li>Assorted bug fixes for i965/i945 drivers
 <li>Fixed Gallium glDrawPixels(GL_STENCIL_INDEX) failure.
+<li>Fixed GLSL linker/preprocessor version directive issue seen in Wine
+    (such as bug 23946)
 </ul>
 
 
diff --git a/progs/vp/vp-tris.c b/progs/vp/vp-tris.c
index 97995ac..1356242 100644
--- a/progs/vp/vp-tris.c
+++ b/progs/vp/vp-tris.c
@@ -119,6 +119,12 @@
       glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
       glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
 		        sz, (const GLubyte *) buf);
+      if (glGetError()) {
+         printf("Program failed to compile:\n%s\n", buf);
+         printf("Error: %s\n",
+                (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+         exit(1);
+      }
       assert(glIsProgramARB(prognum));
    }
 
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 05d1442..b2fbe22 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -70,7 +70,7 @@
       return GL_TRUE;
    }
 
-   _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param=0x%x)", wrap );
+   _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", wrap );
    return GL_FALSE;
 }
 
@@ -210,7 +210,7 @@
          }
          /* fall-through */
       default:
-         _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param=0x%x)",
+         _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)",
                       params[0] );
       }
       return GL_FALSE;
@@ -225,7 +225,7 @@
          texObj->MagFilter = params[0];
          return GL_TRUE;
       default:
-         _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param=0x%x)",
+         _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)",
                       params[0]);
       }
       return GL_FALSE;
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 54a25df..178b7d0 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1474,6 +1474,21 @@
    FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
    _slang_link(ctx, program, shProg);
+
+   /* debug code */
+   if (0) {
+      GLuint i;
+
+      _mesa_printf("Link %u shaders in program %u: %s\n",
+                   shProg->NumShaders, shProg->Name,
+                   shProg->LinkStatus ? "Success" : "Failed");
+
+      for (i = 0; i < shProg->NumShaders; i++) {
+         _mesa_printf(" shader %u, type 0x%x\n",
+                      shProg->Shaders[i]->Name,
+                      shProg->Shaders[i]->Type);
+      }
+   }
 }
 
 
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 169c07f..8f2b40d 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -546,6 +546,32 @@
 
 
 
+/**
+ * Remove extra #version directives from the concatenated source string.
+ * Disable the extra ones by converting first two chars to //, a comment.
+ * This is a bit of hack to work around a preprocessor bug that only
+ * allows one #version directive per source.
+ */
+static void
+remove_extra_version_directives(GLchar *source)
+{
+   GLuint verCount = 0;
+   while (1) {
+      char *ver = _mesa_strstr(source, "#version");
+      if (ver) {
+         verCount++;
+         if (verCount > 1) {
+            ver[0] = '/';
+            ver[1] = '/';
+         }
+         source += 8;
+      }
+      else {
+         break;
+      }
+   }
+}
+
 
 
 /**
@@ -593,6 +619,8 @@
    _mesa_printf("---NEW CONCATENATED SHADER---:\n%s\n------------\n", source);
    */
 
+   remove_extra_version_directives(source);
+
    newShader = CALLOC_STRUCT(gl_shader);
    newShader->Type = shaderType;
    newShader->Source = source;