Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 vtk (5.8.0-13) unstable; urgency=low
 .
   * Make sure to include VTK/QT cmake file. Closes: #656115
   * Revert back to libtiff4-dev and use libtiff-dev in d/control. Closes: #674998
   * Fix tkInt.h installation, using proper cmake magic. Closes: #674169
   * Make sure to discover init.tcl properly. Closes: #673245
Author: Mathieu Malaterre <malat@debian.org>
Bug-Debian: http://bugs.debian.org/656115
Bug-Debian: http://bugs.debian.org/673245
Bug-Debian: http://bugs.debian.org/674169
Bug-Debian: http://bugs.debian.org/674998

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- /dev/null
+++ vtk-5.8.0/VTKConfig-Java.cmake.in
@@ -0,0 +1,14 @@
+# The list of available languages.
+SET(VTK_LANGUAGES ${VTK_LANGUAGES} JAVA)
+
+SET(VTK_WRAP_JAVA 1)
+
+# The Java configuration.
+SET(VTK_JAVA_JAR "@VTK_JAVA_JAR_CONFIG@")
+SET(VTK_PARSE_JAVA_EXE "@VTK_PARSE_JAVA_EXE_CONFIG@")
+SET(VTK_WRAP_JAVA_EXE "@VTK_WRAP_JAVA_EXE_CONFIG@")
+SET(VTK_JAVA_INCLUDE_DIR "@JAVA_INCLUDE_PATH@;@JAVA_INCLUDE_PATH2@")
+SET(VTK_JAVA_AWT_LIBRARY "@JAVA_AWT_LIBRARY@")
+SET(VTK_JVM_LIBRARY "@JAVA_JVM_LIBRARY@")
+
+
--- /dev/null
+++ vtk-5.8.0/VTKConfig-Python.cmake.in
@@ -0,0 +1,14 @@
+# The list of available languages.
+SET(VTK_LANGUAGES ${VTK_LANGUAGES} PYTHON)
+
+SET(VTK_WRAP_PYTHON 1)
+
+# The Python configuration.
+# If VTK_CONFIGURATION_TYPES is set (see below) then the VTK_PYTHONPATH_DIRS
+# will have subdirectories for each configuration type.
+SET(VTK_PYTHONPATH_DIRS "@VTK_PYTHONPATH_DIRS_CONFIG@")
+SET(VTK_WRAP_PYTHON_EXE "@VTK_WRAP_PYTHON_EXE_CONFIG@")
+SET(VTK_WRAP_PYTHON_INIT_EXE "@VTK_WRAP_PYTHON_INIT_EXE_CONFIG@")
+SET(VTK_PYTHON_INCLUDE_DIR "@PYTHON_INCLUDE_DIR@")
+SET(VTK_PYTHON_LIBRARY "@PYTHON_LIBRARY@")
+
--- /dev/null
+++ vtk-5.8.0/VTKConfig-Tcl.cmake.in
@@ -0,0 +1,21 @@
+# The list of available languages.
+SET(VTK_LANGUAGES ${VTK_LANGUAGES} TCL)
+
+SET(VTK_WRAP_TCL 1)
+
+# The Tcl/Tk configuration.
+SET(VTK_TCL_TK_STATIC "@VTK_TCL_TK_STATIC@")
+SET(VTK_TCL_TK_COPY_SUPPORT_LIBRARY "@VTK_TCL_TK_COPY_SUPPORT_LIBRARY@")
+SET(VTK_TCL_SUPPORT_LIBRARY_PATH "@VTK_TCL_SUPPORT_LIBRARY_PATH_CONFIG@")
+SET(VTK_TK_SUPPORT_LIBRARY_PATH "@VTK_TK_SUPPORT_LIBRARY_PATH_CONFIG@")
+SET(VTK_TCL_TK_MACROS_MODULE "@VTK_TCL_TK_MACROS_MODULE_CONFIG@")
+SET(VTK_TCL_HOME "@VTK_TCL_HOME_CONFIG@")
+SET(VTK_WRAP_TCL_EXE "@VTK_WRAP_TCL_EXE_CONFIG@")
+SET(VTK_WRAP_TCL_INIT_EXE "@VTK_WRAP_TCL_INIT_EXE_CONFIG@")
+SET(VTK_TK_INTERNAL_DIR "@VTK_TK_INTERNAL_DIR_CONFIG@")
+SET(VTK_TK_RESOURCES_DIR "@VTK_TK_RESOURCES_DIR_CONFIG@")
+SET(VTK_TCL_INCLUDE_DIR "@TCL_INCLUDE_PATH@")
+SET(VTK_TCL_LIBRARY "@TCL_LIBRARY@")
+SET(VTK_TK_INCLUDE_DIR "@TK_INCLUDE_PATH@")
+SET(VTK_TK_LIBRARY "@TK_LIBRARY@")
+
--- vtk-5.8.0.orig/vtkGenerateVTKConfig.cmake
+++ vtk-5.8.0/vtkGenerateVTKConfig.cmake
@@ -147,9 +147,6 @@ SET(VTK_TCL_TK_MACROS_MODULE_CONFIG
     "${VTK_CMAKE_DIR}/vtkTclTkMacros.cmake")
 SET(VTK_CMAKE_EXTENSIONS_DIR_CONFIG ${VTK_BINARY_DIR}/CMake)
 
-# Export Targets file.
-SET(VTK_TARGETS_FILE "${VTK_BINARY_DIR}/${VTK_INSTALL_EXPORT_NAME}.cmake")
-
 # Build configuration information.
 SET(VTK_CONFIGURATION_TYPES_CONFIG ${CMAKE_CONFIGURATION_TYPES})
 SET(VTK_BUILD_TYPE_CONFIG ${CMAKE_BUILD_TYPE})
@@ -166,6 +163,12 @@ CONFIGURE_FILE(${VTK_SOURCE_DIR}/VTKConf
                ${VTK_BINARY_DIR}/VTKConfig.cmake @ONLY IMMEDIATE)
 CONFIGURE_FILE(${VTK_SOURCE_DIR}/VTKConfigVersion.cmake.in
                ${VTK_BINARY_DIR}/VTKConfigVersion.cmake @ONLY IMMEDIATE)
+CONFIGURE_FILE(${VTK_SOURCE_DIR}/VTKConfig-Java.cmake.in
+               ${VTK_BINARY_DIR}/VTKConfig-Java.cmake @ONLY IMMEDIATE)
+CONFIGURE_FILE(${VTK_SOURCE_DIR}/VTKConfig-Python.cmake.in
+               ${VTK_BINARY_DIR}/VTKConfig-Python.cmake @ONLY IMMEDIATE)
+CONFIGURE_FILE(${VTK_SOURCE_DIR}/VTKConfig-Tcl.cmake.in
+               ${VTK_BINARY_DIR}/VTKConfig-Tcl.cmake @ONLY IMMEDIATE)
 
 #-----------------------------------------------------------------------------
 # Settings specific to the install tree.
@@ -339,6 +342,15 @@ IF(CMAKE_CONFIGURATION_TYPES)
     CONFIGURE_FILE(${VTK_SOURCE_DIR}/VTKConfig.cmake.in
                    ${VTK_BINARY_DIR}/Utilities/${config}/VTKConfig.cmake
                    @ONLY IMMEDIATE)
+    CONFIGURE_FILE(${VTK_SOURCE_DIR}/VTKConfig-Java.cmake.in
+                   ${VTK_BINARY_DIR}/Utilities/${config}/VTKConfig-Java.cmake
+                   @ONLY IMMEDIATE)
+    CONFIGURE_FILE(${VTK_SOURCE_DIR}/VTKConfig-Python.cmake.in
+                   ${VTK_BINARY_DIR}/Utilities/${config}/VTKConfig-Python.cmake
+                   @ONLY IMMEDIATE)
+    CONFIGURE_FILE(${VTK_SOURCE_DIR}/VTKConfig-Tcl.cmake.in
+                   ${VTK_BINARY_DIR}/Utilities/${config}/VTKConfig-Tcl.cmake
+                   @ONLY IMMEDIATE)
   ENDFOREACH(config)
 
   # Install the config file corresponding to the build configuration
@@ -350,12 +362,39 @@ IF(CMAKE_CONFIGURATION_TYPES)
       DESTINATION ${VTK_INSTALL_PACKAGE_DIR_CM24}
       COMPONENT Development
       )
+    IF(VTK_WRAP_JAVA)
+      INSTALL(FILES
+        ${VTK_BINARY_DIR}/Utilities/${DOLLAR}{BUILD_TYPE}/VTKConfig-Java.cmake
+        DESTINATION ${VTK_INSTALL_PACKAGE_DIR_CM24}
+        COMPONENT Development
+        )
+    ENDIF(VTK_WRAP_JAVA)
+    IF(VTK_WRAP_PYTHON)
+      INSTALL(FILES
+        ${VTK_BINARY_DIR}/Utilities/${DOLLAR}{BUILD_TYPE}/VTKConfig-Python.cmake
+        DESTINATION ${VTK_INSTALL_PACKAGE_DIR_CM24}
+        COMPONENT Development
+        )
+    ENDIF(VTK_WRAP_PYTHON)
+    IF(VTK_WRAP_TCL)
+      INSTALL(FILES
+        ${VTK_BINARY_DIR}/Utilities/${DOLLAR}{BUILD_TYPE}/VTKConfig-Tcl.cmake
+        DESTINATION ${VTK_INSTALL_PACKAGE_DIR_CM24}
+        COMPONENT Development
+        )
+    ENDIF(VTK_WRAP_TCL)
   ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT)
 ELSE(CMAKE_CONFIGURATION_TYPES)
   # There is only one build configuration.  Configure one VTKConfig.cmake.
   SET(VTK_BUILD_TYPE_CONFIG ${CMAKE_BUILD_TYPE})
   CONFIGURE_FILE(${VTK_SOURCE_DIR}/VTKConfig.cmake.in
                  ${VTK_BINARY_DIR}/Utilities/VTKConfig.cmake @ONLY IMMEDIATE)
+  CONFIGURE_FILE(${VTK_SOURCE_DIR}/VTKConfig-Java.cmake.in
+                 ${VTK_BINARY_DIR}/Utilities/VTKConfig-Java.cmake @ONLY IMMEDIATE)
+  CONFIGURE_FILE(${VTK_SOURCE_DIR}/VTKConfig-Python.cmake.in
+                 ${VTK_BINARY_DIR}/Utilities/VTKConfig-Python.cmake @ONLY IMMEDIATE)
+  CONFIGURE_FILE(${VTK_SOURCE_DIR}/VTKConfig-Tcl.cmake.in
+                 ${VTK_BINARY_DIR}/Utilities/VTKConfig-Tcl.cmake @ONLY IMMEDIATE)
 
   # Setup an install rule for the config file.
   IF(NOT VTK_INSTALL_NO_DEVELOPMENT)
@@ -364,6 +403,27 @@ ELSE(CMAKE_CONFIGURATION_TYPES)
       DESTINATION ${VTK_INSTALL_PACKAGE_DIR_CM24}
       COMPONENT Development
       )
+    IF(VTK_WRAP_JAVA)
+      INSTALL(FILES
+        ${VTK_BINARY_DIR}/Utilities/VTKConfig-Java.cmake
+        DESTINATION ${VTK_INSTALL_PACKAGE_DIR_CM24}
+        COMPONENT Development
+        )
+    ENDIF(VTK_WRAP_JAVA)
+    IF(VTK_WRAP_PYTHON)
+      INSTALL(FILES
+        ${VTK_BINARY_DIR}/Utilities/VTKConfig-Python.cmake
+        DESTINATION ${VTK_INSTALL_PACKAGE_DIR_CM24}
+        COMPONENT Development
+        )
+    ENDIF(VTK_WRAP_PYTHON)
+    IF(VTK_WRAP_TCL)
+      INSTALL(FILES
+        ${VTK_BINARY_DIR}/Utilities/VTKConfig-Tcl.cmake
+        DESTINATION ${VTK_INSTALL_PACKAGE_DIR_CM24}
+        COMPONENT Development
+        )
+    ENDIF(VTK_WRAP_TCL)
   ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT)
 ENDIF(CMAKE_CONFIGURATION_TYPES)
 
--- vtk-5.8.0.orig/VTKConfig.cmake.in
+++ vtk-5.8.0/VTKConfig.cmake.in
@@ -99,8 +99,6 @@ SET(VTK_USE_ODBC "@VTK_USE_ODBC@")
 SET(VTK_USE_PARALLEL "@VTK_USE_PARALLEL@")
 SET(VTK_USE_PARALLEL_BGL "@VTK_USE_PARALLEL_BGL@")
 SET(VTK_USE_POSTGRES "@VTK_USE_POSTGRES@") 
-SET(VTK_USE_QVTK "@VTK_USE_QVTK@")
-SET(VTK_USE_QVTK_OPENGL "@VTK_USE_QVTK_OPENGL@")
 SET(VTK_USE_RENDERING "@VTK_USE_RENDERING@")
 SET(VTK_USE_TDX "@VTK_USE_TDX@")
 SET(VTK_USE_TEXT_ANALYSIS "@VTK_USE_TEXT_ANALYSIS@")
@@ -110,10 +108,16 @@ SET(VTK_USE_VIDEO_FOR_WINDOWS "@VTK_USE_
 SET(VTK_USE_VIEWS "@VTK_USE_VIEWS@")
 SET(VTK_USE_VOLUMEPRO_1000 "@VTK_USE_VOLUMEPRO_1000@")
 SET(VTK_USE_X "@VTK_USE_X@")
-SET(VTK_WRAP_JAVA "@VTK_WRAP_JAVA@")
-SET(VTK_WRAP_PYTHON "@VTK_WRAP_PYTHON@")
-SET(VTK_WRAP_TCL "@VTK_WRAP_TCL@")
-SET(VTK_WRAP_PYTHON_SIP "@VTK_WRAP_PYTHON_SIP@")
+
+SET(VTK_WRAP_JAVA 0)
+SET(VTK_WRAP_PYTHON 0)
+SET(VTK_WRAP_TCL 0)
+SET(VTK_WRAP_PYTHON_SIP 0)
+
+INCLUDE("${VTK_DIR}/VTKConfig-Java.cmake" OPTIONAL)
+INCLUDE("${VTK_DIR}/VTKConfig-Python.cmake" OPTIONAL)
+INCLUDE("${VTK_DIR}/VTKConfig-Tcl.cmake" OPTIONAL)
+# Python_sip is not provided by Debian packages
 
 # The Hybrid and VolumeRendering kits are now switched with Rendering.
 SET(VTK_USE_HYBRID "@VTK_USE_RENDERING@")
@@ -133,44 +137,11 @@ SET(VTK_MPI_SERVER_PREFLAGS "@VTK_MPI_SE
 SET(VTK_MPI_INCLUDE_DIR "@MPI_INCLUDE_PATH@")
 SET(VTK_MPI_LIBRARIES "@MPI_LIBRARY@;@MPI_EXTRA_LIBRARY@")
 
-# The Tcl/Tk configuration.
-SET(VTK_TCL_TK_STATIC "@VTK_TCL_TK_STATIC@")
-SET(VTK_TCL_TK_COPY_SUPPORT_LIBRARY "@VTK_TCL_TK_COPY_SUPPORT_LIBRARY@")
-SET(VTK_TCL_SUPPORT_LIBRARY_PATH "@VTK_TCL_SUPPORT_LIBRARY_PATH_CONFIG@")
-SET(VTK_TK_SUPPORT_LIBRARY_PATH "@VTK_TK_SUPPORT_LIBRARY_PATH_CONFIG@")
-SET(VTK_TCL_TK_MACROS_MODULE "@VTK_TCL_TK_MACROS_MODULE_CONFIG@")
-SET(VTK_TCL_HOME "@VTK_TCL_HOME_CONFIG@")
-SET(VTK_WRAP_TCL_EXE "@VTK_WRAP_TCL_EXE_CONFIG@")
-SET(VTK_WRAP_TCL_INIT_EXE "@VTK_WRAP_TCL_INIT_EXE_CONFIG@")
-SET(VTK_TK_INTERNAL_DIR "@VTK_TK_INTERNAL_DIR_CONFIG@")
-SET(VTK_TK_RESOURCES_DIR "@VTK_TK_RESOURCES_DIR_CONFIG@")
-SET(VTK_TCL_INCLUDE_DIR "@TCL_INCLUDE_PATH@")
-SET(VTK_TCL_LIBRARY "@TCL_LIBRARY@")
-SET(VTK_TK_INCLUDE_DIR "@TK_INCLUDE_PATH@")
-SET(VTK_TK_LIBRARY "@TK_LIBRARY@")
-
-# The Java configuration.
-SET(VTK_JAVA_JAR "@VTK_JAVA_JAR_CONFIG@")
-SET(VTK_PARSE_JAVA_EXE "@VTK_PARSE_JAVA_EXE_CONFIG@")
-SET(VTK_WRAP_JAVA_EXE "@VTK_WRAP_JAVA_EXE_CONFIG@")
-SET(VTK_JAVA_INCLUDE_DIR "@JAVA_INCLUDE_PATH@;@JAVA_INCLUDE_PATH2@")
-SET(VTK_JAVA_AWT_LIBRARY "@JAVA_AWT_LIBRARY@")
-SET(VTK_JVM_LIBRARY "@JAVA_JVM_LIBRARY@")
-
 # The Matlab configuration.
 SET(VTK_MATLAB_ROOT_DIR "@MATLAB_ROOT_DIR@")
 SET(VTK_MATLAB_INCLUDE_DIR "@MATLAB_INCLUDE_DIR@")
 SET(VTK_MATLAB_LIB_DIR "@MATLAB_LIB_DIR@")
 
-# The Python configuration.
-# If VTK_CONFIGURATION_TYPES is set (see below) then the VTK_PYTHONPATH_DIRS
-# will have subdirectories for each configuration type.
-SET(VTK_PYTHONPATH_DIRS "@VTK_PYTHONPATH_DIRS_CONFIG@")
-SET(VTK_WRAP_PYTHON_EXE "@VTK_WRAP_PYTHON_EXE_CONFIG@")
-SET(VTK_WRAP_PYTHON_INIT_EXE "@VTK_WRAP_PYTHON_INIT_EXE_CONFIG@")
-SET(VTK_PYTHON_INCLUDE_DIR "@PYTHON_INCLUDE_DIR@")
-SET(VTK_PYTHON_LIBRARY "@PYTHON_LIBRARY@")
-
 # Other executables
 SET(VTK_ENCODESTRING_EXE "@VTK_ENCODESTRING_EXE_CONFIG@")
 
@@ -196,9 +167,7 @@ SET(VTK_LIBPROJ4_LIBRARIES "@VTK_LIBPROJ
 SET(VTK_HDF5_LIBRARIES     "@VTK_HDF5_LIBRARIES@")
 
 # The VTK Qt configuration.
-IF(VTK_USE_QVTK)
-  INCLUDE(${VTK_DIR}/VTKConfigQt.cmake)
-ENDIF(VTK_USE_QVTK)
+INCLUDE("${VTK_DIR}/VTKConfigQt.cmake" OPTIONAL)
 
 # Relative install paths in the VTK install tree
 SET(VTK_INSTALL_BIN_DIR "@VTK_INSTALL_BIN_DIR@")
--- vtk-5.8.0.orig/CMake/KitCommonJavaWrapBlock.cmake
+++ vtk-5.8.0/CMake/KitCommonJavaWrapBlock.cmake
@@ -8,7 +8,7 @@ IF(NOT VTK_INSTALL_NO_LIBRARIES)
   INSTALL(TARGETS vtk${KIT}Java
     EXPORT ${VTK_INSTALL_EXPORT_NAME}
     RUNTIME DESTINATION ${VTK_INSTALL_BIN_DIR_CM24} COMPONENT RuntimeLibraries
-    LIBRARY DESTINATION ${VTK_INSTALL_LIB_DIR_CM24} COMPONENT RuntimeLibraries
+    LIBRARY DESTINATION "${VTK_INSTALL_LIB_DIR_CM24}/jni" COMPONENT RuntimeLibraries
     ARCHIVE DESTINATION ${VTK_INSTALL_LIB_DIR_CM24} COMPONENT Development)
 ENDIF(NOT VTK_INSTALL_NO_LIBRARIES)
 ADD_DEPENDENCIES(vtk${KIT}Java vtk${KIT})
--- vtk-5.8.0.orig/CMake/KitCommonPythonWrapBlock.cmake
+++ vtk-5.8.0/CMake/KitCommonPythonWrapBlock.cmake
@@ -80,6 +80,16 @@ IF(PYTHON_ENABLE_MODULE_vtk${KIT}Python)
   # vtkpython executable in the build tree should have the needed
   # RPATH anyway.
   SET_TARGET_PROPERTIES(vtk${KIT}Python PROPERTIES SKIP_BUILD_RPATH 1)
+
+  set_target_properties(vtk${KIT}PythonD
+      PROPERTIES
+      LINK_INTERFACE_LIBRARIES "${KIT_INTERFACE_LIBRARIES}"
+  )
+
+  set_target_properties(vtk${KIT}Python
+      PROPERTIES
+      LINK_INTERFACE_LIBRARIES ""
+  )
   
   IF(WIN32 OR APPLE)
     TARGET_LINK_LIBRARIES (vtk${KIT}Python ${VTK_PYTHON_LIBRARIES})
--- vtk-5.8.0.orig/CMake/KitCommonTclWrapBlock.cmake
+++ vtk-5.8.0/CMake/KitCommonTclWrapBlock.cmake
@@ -4,6 +4,14 @@ VTK_WRAP_TCL3(vtk${KIT}TCL KitTCL_SRCS
 VTK_ADD_LIBRARY(vtk${KIT}TCL ${KitTCL_SRCS} ${Kit_TCL_EXTRA_SRCS})
 SET(KIT_LIBRARY_TARGETS ${KIT_LIBRARY_TARGETS} vtk${KIT}TCL)
 TARGET_LINK_LIBRARIES (vtk${KIT}TCL vtk${KIT} ${KIT_TCL_LIBS})
+
+
+  set_target_properties(vtk${KIT}TCL
+      PROPERTIES
+      LINK_INTERFACE_LIBRARIES "${KIT_INTERFACE_LIBRARIES}"
+  )
+
+
 IF(NOT VTK_INSTALL_NO_LIBRARIES)
   INSTALL(TARGETS vtk${KIT}TCL
     EXPORT ${VTK_INSTALL_EXPORT_NAME}
--- vtk-5.8.0.orig/Charts/CMakeLists.txt
+++ vtk-5.8.0/Charts/CMakeLists.txt
@@ -98,9 +98,9 @@ IF(VTK_USE_QT)
   SET(QT_DONT_USE_QTGUI)
   INCLUDE(${QT_USE_FILE})
   IF (APPLE)
-    LIST (APPEND KIT_INTERFACE_LIBRARIES ${QT_LIBRARIES})
+    LIST (APPEND KIT_INTERFACE_LIBRARIES QtGui QtCore )
   ELSE (APPLE)
-    LIST (APPEND KIT_LIBS ${QT_LIBRARIES})
+    LIST (APPEND KIT_LIBS QtGui QtCore )
   ENDIF (APPLE)
 ENDIF(VTK_USE_QT)
 
--- vtk-5.8.0.orig/Common/vtkWin32Header.h
+++ vtk-5.8.0/Common/vtkWin32Header.h
@@ -102,9 +102,15 @@ Do_not_include_vtkWin32Header_directly__
 #  define vtkGetWindowLong GetWindowLong
 #  define vtkSetWindowLong SetWindowLong
 #  define vtkLONG LONG
+#  ifdef _WIN64
+#    define vtkGWL_WNDPROC GWLP_WNDPROC
+#    define vtkGWL_HINSTANCE GWLP_HINSTANCE
+#    define vtkGWL_USERDATA GWLP_USERDATA
+#  else
 #  define vtkGWL_WNDPROC GWL_WNDPROC
 #  define vtkGWL_HINSTANCE GWL_HINSTANCE
 #  define vtkGWL_USERDATA GWL_USERDATA
+#  endif
 #endif //
 
 #endif
--- vtk-5.8.0.orig/Examples/ParallelProcessing/Generic/Cxx/CMakeLists.txt
+++ vtk-5.8.0/Examples/ParallelProcessing/Generic/Cxx/CMakeLists.txt
@@ -1,7 +1,7 @@
 INCLUDE_REGULAR_EXPRESSION("^(lex|vtk|png|j|Task|Pipe).*$")
 
 IF (VTK_USE_MPI)
-  INCLUDE_DIRECTORIES("${MPI_INCLUDE_PATH}")
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
   IF (MPI_LIBRARY) 
     SET(MPI_LIBRARIES ${MPI_LIBRARY})   
   ENDIF (MPI_LIBRARY)   
--- vtk-5.8.0.orig/GUISupport/Qt/QVTKPaintEngine.cxx
+++ vtk-5.8.0/GUISupport/Qt/QVTKPaintEngine.cxx
@@ -46,7 +46,7 @@ bool QVTKPaintEngine::end()
 
 QPaintEngine::Type QVTKPaintEngine::type() const
 {
-  return QPaintEngine::User;
+  return QPaintEngine::OpenGL;
 }
 
 void QVTKPaintEngine::updateState(const QPaintEngineState&)
--- vtk-5.8.0.orig/GUISupport/Qt/VTKConfigQt.cmake.in
+++ vtk-5.8.0/GUISupport/Qt/VTKConfigQt.cmake.in
@@ -5,6 +5,9 @@
 # This file is configured by VTK and used by the VTKConfig.cmake module
 # to load VTK's Qt settings for an external project.
 
+SET(VTK_USE_QVTK "@VTK_USE_QVTK@")
+SET(VTK_USE_QVTK_OPENGL "@VTK_USE_QVTK_OPENGL@")
+
 # exports for Qt4
 SET(VTK_QT_RCC_EXECUTABLE "@QT_RCC_EXECUTABLE@")
 
--- vtk-5.8.0.orig/Hybrid/vtkPolyDataSilhouette.cxx
+++ vtk-5.8.0/Hybrid/vtkPolyDataSilhouette.cxx
@@ -255,9 +255,9 @@ int vtkPolyDataSilhouette::RequestData(
     }
 
   if( ( this->PreComp->mtime.GetMTime() > output->GetMTime() ) ||
-    ( this->Camera->GetMTime() > output->GetMTime() ) ||
-    ( this->Prop3D!=0 && this->Prop3D->GetMTime() > output->GetMTime() ) ||
-    vecChanged )
+      ( this->Camera && this->Camera->GetMTime() > output->GetMTime() ) ||
+      ( this->Prop3D && this->Prop3D->GetMTime() > output->GetMTime() ) ||
+      vecChanged )
     {
     vtkDebugMacro(<<"Extract edges\n");
 
--- vtk-5.8.0.orig/Hybrid/vtkVideoSource.cxx
+++ vtk-5.8.0/Hybrid/vtkVideoSource.cxx
@@ -32,9 +32,9 @@
 
 //---------------------------------------------------------------
 // Important FrameBufferMutex rules:
-// 
+//
 // The frame grabs are generally done asynchronously, and it is necessary
-// to ensure that when the frame buffer is valid when it is being written 
+// to ensure that when the frame buffer is valid when it is being written
 // to or read from
 //
 // The following information can only be changed within a mutex lock,
@@ -59,8 +59,8 @@
 //
 // AdvanceFrameBuffer()
 //
-// Any methods which might be called asynchronously must lock the 
-// mutex before reading the above information, and you must be very 
+// Any methods which might be called asynchronously must lock the
+// mutex before reading the above information, and you must be very
 // careful when accessing any information except for the above.
 // These methods include the following:
 //
@@ -74,13 +74,13 @@ vtkStandardNewMacro(vtkVideoSource);
 #if ( _MSC_VER >= 1300 ) // Visual studio .NET
 #pragma warning ( disable : 4311 )
 #pragma warning ( disable : 4312 )
-#endif 
+#endif
 
 //----------------------------------------------------------------------------
 vtkVideoSource::vtkVideoSource()
 {
   int i;
-  
+
   this->Initialized = 0;
 
   this->AutoAdvance = 1;
@@ -93,7 +93,7 @@ vtkVideoSource::vtkVideoSource()
     {
     this->FrameBufferExtent[i] = 0;
     }
-  
+
   this->Playing = 0;
   this->Recording = 0;
 
@@ -151,8 +151,8 @@ vtkVideoSource::vtkVideoSource()
 
 //----------------------------------------------------------------------------
 vtkVideoSource::~vtkVideoSource()
-{ 
-  // we certainly don't want to access a virtual 
+{
+  // we certainly don't want to access a virtual
   // function after the subclass has destructed!!
   this->vtkVideoSource::ReleaseSystemResources();
 
@@ -165,10 +165,10 @@ vtkVideoSource::~vtkVideoSource()
 void vtkVideoSource::PrintSelf(ostream& os, vtkIndent indent)
 {
   int idx;
-  
+
   this->Superclass::PrintSelf(os,indent);
-  
-  os << indent << "FrameSize: (" << this->FrameSize[0] << ", " 
+
+  os << indent << "FrameSize: (" << this->FrameSize[0] << ", "
      << this->FrameSize[1] << ", " << this->FrameSize[2] << ")\n";
 
   os << indent << "ClipRegion: (" << this->ClipRegion[0];
@@ -177,14 +177,14 @@ void vtkVideoSource::PrintSelf(ostream&
     os << ", " << this->ClipRegion[idx];
     }
   os << ")\n";
-  
+
   os << indent << "DataSpacing: (" << this->DataSpacing[0];
   for (idx = 1; idx < 3; ++idx)
     {
     os << ", " << this->DataSpacing[idx];
     }
   os << ")\n";
-  
+
   os << indent << "DataOrigin: (" << this->DataOrigin[0];
   for (idx = 1; idx < 3; ++idx)
     {
@@ -205,7 +205,7 @@ void vtkVideoSource::PrintSelf(ostream&
     os << ", " << this->OutputWholeExtent[idx];
     }
   os << ")\n";
-  
+
   os << indent << "FrameRate: " << this->FrameRate << "\n";
 
   os << indent << "FrameCount: " << this->FrameCount << "\n";
@@ -232,7 +232,7 @@ void vtkVideoSource::PrintSelf(ostream&
 
 //----------------------------------------------------------------------------
 // Update the FrameBuffers according to any changes in the FrameBuffer*
-// information. 
+// information.
 // This function should always be called from within a FrameBufferMutex lock
 // and should never be called asynchronously.
 // It sets up the FrameBufferExtent
@@ -246,10 +246,10 @@ void vtkVideoSource::UpdateFrameBuffer()
   for (i = 0; i < 3; i++)
     {
     oldExt = this->FrameBufferExtent[2*i+1] - this->FrameBufferExtent[2*i] + 1;
-    this->FrameBufferExtent[2*i] = ((this->ClipRegion[2*i] > 0) 
-                             ? this->ClipRegion[2*i] : 0);  
-    this->FrameBufferExtent[2*i+1] = ((this->ClipRegion[2*i+1] < 
-                                       this->FrameSize[i]-1) 
+    this->FrameBufferExtent[2*i] = ((this->ClipRegion[2*i] > 0)
+                             ? this->ClipRegion[2*i] : 0);
+    this->FrameBufferExtent[2*i+1] = ((this->ClipRegion[2*i+1] <
+                                       this->FrameSize[i]-1)
                              ? this->ClipRegion[2*i+1] : this->FrameSize[i]-1);
 
     ext[i] = this->FrameBufferExtent[2*i+1] - this->FrameBufferExtent[2*i] + 1;
@@ -318,20 +318,20 @@ void vtkVideoSource::ReleaseSystemResour
 //----------------------------------------------------------------------------
 void vtkVideoSource::SetFrameSize(int x, int y, int z)
 {
-  if (x == this->FrameSize[0] && 
-      y == this->FrameSize[1] && 
+  if (x == this->FrameSize[0] &&
+      y == this->FrameSize[1] &&
       z == this->FrameSize[2])
     {
     return;
     }
 
-  if (x < 1 || y < 1 || z < 1) 
+  if (x < 1 || y < 1 || z < 1)
     {
     vtkErrorMacro(<< "SetFrameSize: Illegal frame size");
     return;
     }
 
-  if (this->Initialized) 
+  if (this->Initialized)
     {
     this->FrameBufferMutex->Lock();
     this->FrameSize[0] = x;
@@ -349,7 +349,7 @@ void vtkVideoSource::SetFrameSize(int x,
 
   this->Modified();
 }
-    
+
 //----------------------------------------------------------------------------
 void vtkVideoSource::SetFrameRate(float rate)
 {
@@ -363,7 +363,7 @@ void vtkVideoSource::SetFrameRate(float
 }
 
 //----------------------------------------------------------------------------
-void vtkVideoSource::SetClipRegion(int x0, int x1, int y0, int y1, 
+void vtkVideoSource::SetClipRegion(int x0, int x1, int y0, int y1,
                                    int z0, int z1)
 {
   if (this->ClipRegion[0] != x0 || this->ClipRegion[1] != x1 ||
@@ -371,7 +371,7 @@ void vtkVideoSource::SetClipRegion(int x
       this->ClipRegion[4] != z0 || this->ClipRegion[5] != z1)
     {
     this->Modified();
-    if (this->Initialized) 
+    if (this->Initialized)
       { // modify the FrameBufferExtent
       this->FrameBufferMutex->Lock();
       this->ClipRegion[0] = x0; this->ClipRegion[1] = x1;
@@ -422,7 +422,7 @@ void vtkVideoSource::InternalGrab()
                      this->FrameBufferBitsPerPixel + 7)/8;
   bytesPerRow = ((bytesPerRow + this->FrameBufferRowAlignment - 1) /
                  this->FrameBufferRowAlignment)*this->FrameBufferRowAlignment;
-  int totalSize = bytesPerRow * 
+  int totalSize = bytesPerRow *
                    (this->FrameBufferExtent[3]-this->FrameBufferExtent[2]+1) *
                    (this->FrameBufferExtent[5]-this->FrameBufferExtent[4]+1);
 
@@ -432,7 +432,7 @@ void vtkVideoSource::InternalGrab()
   ptr = reinterpret_cast<vtkUnsignedCharArray *>(this->FrameBuffer[index])->GetPointer(0);
 
   // Somebody should check this:
-  lptr = (int *)(((((long)ptr) + 3)/4)*4);
+  lptr = (int *)(((((intptr_t)ptr) + 3)/4)*4);
   i = totalSize/4;
 
   while (--i >= 0)
@@ -482,7 +482,7 @@ static inline void vtkSleep(double durat
 
 //----------------------------------------------------------------------------
 // Sleep until the specified absolute time has arrived.
-// You must pass a handle to the current thread.  
+// You must pass a handle to the current thread.
 // If '0' is returned, then the thread was aborted before or during the wait.
 static int vtkThreadSleep(vtkMultiThreader::ThreadInfo *data, double time)
 {
@@ -506,7 +506,7 @@ static int vtkThreadSleep(vtkMultiThread
       remaining = 0.1;
       }
 
-    // check to see if we are being told to quit 
+    // check to see if we are being told to quit
     data->ActiveFlagLock->Lock();
     int activeFlag = *(data->ActiveFlag);
     data->ActiveFlagLock->Unlock();
@@ -527,7 +527,7 @@ static int vtkThreadSleep(vtkMultiThread
 static void *vtkVideoSourceRecordThread(vtkMultiThreader::ThreadInfo *data)
 {
   vtkVideoSource *self = (vtkVideoSource *)(data->UserData);
-  
+
   double startTime = vtkTimerLog::GetUniversalTime();
   double rate = self->GetFrameRate();
   int frame = 0;
@@ -544,7 +544,7 @@ static void *vtkVideoSourceRecordThread(
 
 //----------------------------------------------------------------------------
 // Set the source to grab frames continuously.
-// You should override this as appropriate for your device.  
+// You should override this as appropriate for your device.
 void vtkVideoSource::Record()
 {
   if (this->Playing)
@@ -559,19 +559,19 @@ void vtkVideoSource::Record()
     this->Recording = 1;
     this->FrameCount = 0;
     this->Modified();
-    this->PlayerThreadId = 
+    this->PlayerThreadId =
       this->PlayerThreader->SpawnThread((vtkThreadFunctionType)\
                                 &vtkVideoSourceRecordThread,this);
     }
 }
-    
+
 //----------------------------------------------------------------------------
 // this function runs in an alternate thread to 'play the tape' at the
 // specified frame rate.
 static void *vtkVideoSourcePlayThread(vtkMultiThreader::ThreadInfo *data)
 {
   vtkVideoSource *self = (vtkVideoSource *)(data->UserData);
- 
+
   double startTime = vtkTimerLog::GetUniversalTime();
   double rate = self->GetFrameRate();
   int frame = 0;
@@ -588,7 +588,7 @@ static void *vtkVideoSourcePlayThread(vt
 
 //----------------------------------------------------------------------------
 // Set the source to play back recorded frames.
-// You should override this as appropriate for your device.  
+// You should override this as appropriate for your device.
 void vtkVideoSource::Play()
 {
   if (this->Recording)
@@ -602,12 +602,12 @@ void vtkVideoSource::Play()
 
     this->Playing = 1;
     this->Modified();
-    this->PlayerThreadId = 
+    this->PlayerThreadId =
       this->PlayerThreader->SpawnThread((vtkThreadFunctionType)\
                                         &vtkVideoSourcePlayThread,this);
     }
 }
-    
+
 //----------------------------------------------------------------------------
 // Stop continuous grabbing or playback.  You will have to override this
 // if your class overrides Play() and Record()
@@ -621,7 +621,7 @@ void vtkVideoSource::Stop()
     this->Recording = 0;
     this->Modified();
     }
-} 
+}
 
 //----------------------------------------------------------------------------
 // Rewind back to the frame with the earliest timestamp.
@@ -665,7 +665,7 @@ void vtkVideoSource::Rewind()
     }
 
   this->FrameBufferMutex->Unlock();
-}  
+}
 
 //----------------------------------------------------------------------------
 // Fast-forward to the frame with the latest timestamp.
@@ -717,12 +717,12 @@ void vtkVideoSource::FastForward()
     }
 
   this->FrameBufferMutex->Unlock();
-}  
+}
 
 //----------------------------------------------------------------------------
 // Rotate the buffers
 void vtkVideoSource::Seek(int n)
-{ 
+{
   this->FrameBufferMutex->Lock();
   this->AdvanceFrameBuffer(n);
   this->FrameIndex = (this->FrameIndex + n) % this->FrameBufferSize;
@@ -731,7 +731,7 @@ void vtkVideoSource::Seek(int n)
     this->FrameIndex += this->FrameBufferSize;
     }
   this->FrameBufferMutex->Unlock();
-  this->Modified(); 
+  this->Modified();
 }
 
 //----------------------------------------------------------------------------
@@ -798,7 +798,7 @@ void vtkVideoSource::SetOutputFormat(int
 
 //----------------------------------------------------------------------------
 // set or change the circular buffer size
-// you will have to override this if you want the buffers 
+// you will have to override this if you want the buffers
 // to be device-specific (i.e. something other than vtkDataArray)
 void vtkVideoSource::SetFrameBufferSize(int bufsize)
 {
@@ -830,12 +830,12 @@ void vtkVideoSource::SetFrameBufferSize(
         {
         this->FrameBuffer[i] = vtkUnsignedCharArray::New();
         this->FrameBufferTimeStamps[i] = 0.0;
-        } 
+        }
       this->FrameBufferSize = bufsize;
       this->Modified();
       }
     }
-  else 
+  else
     {
     if (bufsize > 0)
       {
@@ -909,7 +909,7 @@ void vtkVideoSource::SetFrameBufferSize(
 void vtkVideoSource::AdvanceFrameBuffer(int n)
 {
   int i = (this->FrameBufferIndex - n) % this->FrameBufferSize;
-  while (i < 0) 
+  while (i < 0)
     {
     i += this->FrameBufferSize;
     }
@@ -918,7 +918,7 @@ void vtkVideoSource::AdvanceFrameBuffer(
 
 //----------------------------------------------------------------------------
 double vtkVideoSource::GetFrameTimeStamp(int frame)
-{ 
+{
   double timeStamp;
 
   this->FrameBufferMutex->Lock();
@@ -959,7 +959,7 @@ int vtkVideoSource::RequestInformation(
     // if 'flag' is set in output extent, use the FrameBufferExtent instead
     if (extent[2*i+1] < extent[2*i])
       {
-      extent[2*i] = 0; 
+      extent[2*i] = 0;
       extent[2*i+1] = \
         this->FrameBufferExtent[2*i+1] - this->FrameBufferExtent[2*i];
       }
@@ -981,7 +981,7 @@ int vtkVideoSource::RequestInformation(
   extent[5] = extent[4] + (extent[5]-extent[4]+1) * numFrames - 1;
 
   outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),extent,6);
-    
+
   // set the spacing
   outInfo->Set(vtkDataObject::SPACING(),this->DataSpacing,3);
 
@@ -989,7 +989,7 @@ int vtkVideoSource::RequestInformation(
   outInfo->Set(vtkDataObject::ORIGIN(),this->DataOrigin,3);
 
   // set default data type (8 bit greyscale)
-  vtkDataObject::SetPointDataActiveScalarInfo(outInfo, VTK_UNSIGNED_CHAR, 
+  vtkDataObject::SetPointDataActiveScalarInfo(outInfo, VTK_UNSIGNED_CHAR,
     this->NumberOfScalarComponents);
 
   return 1;
@@ -1000,7 +1000,7 @@ int vtkVideoSource::RequestInformation(
 // unusual pixel packing formats, such as XRGB XBRG BGRX BGR etc.
 // The version below assumes that the packing of the framebuffer is
 // identical to that of the output.
-void vtkVideoSource::UnpackRasterLine(char *outPtr, char *rowPtr, 
+void vtkVideoSource::UnpackRasterLine(char *outPtr, char *rowPtr,
                                       int start, int count)
 {
   char *inPtr = rowPtr + start*this->NumberOfScalarComponents;
@@ -1020,7 +1020,7 @@ void vtkVideoSource::UnpackRasterLine(ch
 //----------------------------------------------------------------------------
 // The Execute method is fairly complex, so I would not recommend overriding
 // it unless you have to.  Override the UnpackRasterLine() method instead.
-// You should only have to override it if you are using something other 
+// You should only have to override it if you are using something other
 // than 8-bit vtkUnsignedCharArray for the frame buffer.
 int vtkVideoSource::RequestData(
   vtkInformation *vtkNotUsed(request),
@@ -1037,9 +1037,9 @@ int vtkVideoSource::RequestData(
     {
     saveOutputExtent[i] = outputExtent[i];
     }
-  // clip to extent to the Z size of one frame  
-  outputExtent[4] = this->FrameOutputExtent[4]; 
-  outputExtent[5] = this->FrameOutputExtent[5]; 
+  // clip to extent to the Z size of one frame
+  outputExtent[4] = this->FrameOutputExtent[4];
+  outputExtent[5] = this->FrameOutputExtent[5];
 
   int frameExtentX = this->FrameBufferExtent[1]-this->FrameBufferExtent[0]+1;
   int frameExtentY = this->FrameBufferExtent[3]-this->FrameBufferExtent[2]+1;
@@ -1093,8 +1093,8 @@ int vtkVideoSource::RequestData(
     outPadY = 0;
     }
 
-  int outX = frameExtentX - inPadX; 
-  int outY = frameExtentY - inPadY; 
+  int outX = frameExtentX - inPadX;
+  int outY = frameExtentY - inPadY;
   int outZ; // do outZ later
 
   if (outX > extentX - outPadX)
@@ -1117,7 +1117,7 @@ int vtkVideoSource::RequestData(
     }
 
   // ditto for number of scalar components
-  if (data->GetNumberOfScalarComponents() != 
+  if (data->GetNumberOfScalarComponents() !=
       this->LastNumberOfScalarComponents)
     {
     this->LastNumberOfScalarComponents = data->GetNumberOfScalarComponents();
@@ -1132,7 +1132,7 @@ int vtkVideoSource::RequestData(
            (saveOutputExtent[3]-saveOutputExtent[2]+1)*
            (saveOutputExtent[5]-saveOutputExtent[4]+1)*outIncX);
     this->OutputNeedsInitialization = 0;
-    } 
+    }
 
   // we have to modify the outputExtent of the first frame,
   // because it might be complete (it will be restored after
@@ -1143,7 +1143,7 @@ int vtkVideoSource::RequestData(
   this->FrameBufferMutex->Lock();
 
   int index = this->FrameBufferIndex;
-  this->FrameTimeStamp = 
+  this->FrameTimeStamp =
     this->FrameBufferTimeStamps[index % this->FrameBufferSize];
 
   int frame;
@@ -1152,8 +1152,8 @@ int vtkVideoSource::RequestData(
     if (frame == finalFrame)
       {
       outputExtent[5] = finalOutputExtent5;
-      } 
-    
+      }
+
     vtkDataArray *frameBuffer = reinterpret_cast<vtkDataArray *>(this->FrameBuffer[(index + frame) % this->FrameBufferSize]);
 
     char *inPtr = reinterpret_cast<char*>(frameBuffer->GetVoidPointer(0));
@@ -1162,7 +1162,7 @@ int vtkVideoSource::RequestData(
     extentZ = outputExtent[5]-outputExtent[4]+1;
     inPadZ = 0;
     outPadZ = -outputExtent[4];
-    
+
     if (outPadZ < 0)
       {
       inPadZ -= outPadZ;
@@ -1209,7 +1209,7 @@ int vtkVideoSource::RequestData(
         outPtrTmp = outPtr;
         for (j = 0; j < outY; j++)
           {
-          if (outX > 0) 
+          if (outX > 0)
             {
             this->UnpackRasterLine(outPtrTmp,inPtrTmp,inPadX,outX);
             }
--- vtk-5.8.0.orig/IO/CMakeLists.txt
+++ vtk-5.8.0/IO/CMakeLists.txt
@@ -18,9 +18,9 @@ SET(KIT_TCL_LIBS vtkFilteringTCL)
 SET(KIT_PYTHON_LIBS vtkFilteringPythonD)
 SET(KIT_JAVA_LIBS vtkFilteringJava)
 SET(KIT_INTERFACE_LIBRARIES vtkFiltering)
-SET(KIT_LIBS vtkDICOMParser vtkNetCDF vtkNetCDF_cxx
-  ${_VTK_METAIO_LIB} vtksqlite
-  ${VTK_PNG_LIBRARIES} ${VTK_ZLIB_LIBRARIES} ${VTK_JPEG_LIBRARIES}
+SET(KIT_LIBS vtkDICOMParser netcdf netcdf_c++
+  ${_VTK_METAIO_LIB} sqlite3
+  ${VTK_PNG_LIBRARIES} ${VTK_JPEG_LIBRARIES}
   ${VTK_TIFF_LIBRARIES} ${VTK_EXPAT_LIBRARIES} ${VTK_OGGTHEORA_LIBRARIES}
   ${KWSYS_NAMESPACE})
 
--- vtk-5.8.0.orig/IO/vtkFFMPEGWriter.cxx
+++ vtk-5.8.0/IO/vtkFFMPEGWriter.cxx
@@ -123,7 +123,7 @@ int vtkFFMPEGWriterInternal::Start()
     }
 
   //choose avi media file format
-  this->avOutputFormat = guess_format("avi", NULL, NULL);
+  this->avOutputFormat = av_guess_format("avi", NULL, NULL);
   if (!this->avOutputFormat) 
     {
     vtkGenericWarningMacro (<< "Could not open the avi media file format.");
@@ -150,7 +150,7 @@ int vtkFFMPEGWriterInternal::Start()
   //Set up the codec.
   AVCodecContext *c = this->avStream->codec;
   c->codec_id = (CodecID)this->avOutputFormat->video_codec;
-  c->codec_type = CODEC_TYPE_VIDEO;
+  c->codec_type = AVMEDIA_TYPE_VIDEO;
   c->width = this->Dim[0];
   c->height = this->Dim[1];
   c->pix_fmt = PIX_FMT_YUVJ420P;
@@ -343,7 +343,7 @@ int vtkFFMPEGWriterInternal::Write(vtkIm
     pkt.stream_index = this->avStream->index;
     if (cc->coded_frame->key_frame) //treat keyframes well
       {
-      pkt.flags |= PKT_FLAG_KEY;
+      pkt.flags |= AV_PKT_FLAG_KEY;
       }
     pkt.duration = 0; //presentation duration in time_base units or 0 if NA
     pkt.pos = -1; //byte position in stream or -1 if NA
--- vtk-5.8.0.orig/IO/vtkSQLiteDatabase.cxx
+++ vtk-5.8.0/IO/vtkSQLiteDatabase.cxx
@@ -29,7 +29,7 @@
 #include <vtksys/ios/fstream>
 #include <vtksys/ios/sstream>
 
-#include <vtksqlite/vtk_sqlite3.h>
+#include <sqlite3.h>
 
 vtkStandardNewMacro(vtkSQLiteDatabase);
 
@@ -307,15 +307,15 @@ bool vtkSQLiteDatabase::Open(const char*
       }
     }
 
-  int result = vtk_sqlite3_open(this->DatabaseFileName, & (this->SQLiteInstance));
+  int result = sqlite3_open(this->DatabaseFileName, & (this->SQLiteInstance));
 
-  if (result != VTK_SQLITE_OK)
+  if (result != SQLITE_OK)
     {
     vtkDebugMacro(<<"SQLite open() failed.  Error code is "
                   << result << " and message is "
-                  << vtk_sqlite3_errmsg(this->SQLiteInstance) );
+                  << sqlite3_errmsg(this->SQLiteInstance) );
 
-    vtk_sqlite3_close(this->SQLiteInstance);
+    sqlite3_close(this->SQLiteInstance);
     return false;
     }
   else
@@ -334,8 +334,8 @@ void vtkSQLiteDatabase::Close()
     }
   else
     {
-    int result = vtk_sqlite3_close(this->SQLiteInstance);
-    if (result != VTK_SQLITE_OK)
+    int result = sqlite3_close(this->SQLiteInstance);
+    if (result != SQLITE_OK)
       {
       vtkWarningMacro(<< "Close(): SQLite returned result code " << result);
       }
@@ -374,7 +374,7 @@ vtkStringArray * vtkSQLiteDatabase::GetT
   if (!status)
     {
     vtkErrorMacro(<< "GetTables(): Database returned error: "
-                  << vtk_sqlite3_errmsg(this->SQLiteInstance) );
+                  << sqlite3_errmsg(this->SQLiteInstance) );
     query->Delete();
     return this->Tables;
     }
@@ -403,7 +403,7 @@ vtkStringArray * vtkSQLiteDatabase::GetR
   if (!status)
     {
     vtkErrorMacro(<< "GetRecord(" << table << "): Database returned error: "
-                  << vtk_sqlite3_errmsg(this->SQLiteInstance) );
+                  << sqlite3_errmsg(this->SQLiteInstance) );
     query->Delete();
     return NULL;
     }
@@ -467,10 +467,10 @@ bool vtkSQLiteDatabase::ParseURL(const c
 // ----------------------------------------------------------------------
 bool vtkSQLiteDatabase::HasError()
 {
-  return (vtk_sqlite3_errcode(this->SQLiteInstance)!=VTK_SQLITE_OK);
+  return (sqlite3_errcode(this->SQLiteInstance)!=SQLITE_OK);
 }
 
 const char* vtkSQLiteDatabase::GetLastErrorText()
 {
-  return vtk_sqlite3_errmsg(this->SQLiteInstance);
+  return sqlite3_errmsg(this->SQLiteInstance);
 }
--- vtk-5.8.0.orig/IO/vtkSQLiteDatabase.h
+++ vtk-5.8.0/IO/vtkSQLiteDatabase.h
@@ -48,7 +48,7 @@
 class vtkSQLQuery;
 class vtkSQLiteQuery;
 class vtkStringArray;
-struct vtk_sqlite3;
+struct sqlite3;
 
 class VTK_IO_EXPORT vtkSQLiteDatabase : public vtkSQLDatabase
 {
@@ -146,7 +146,7 @@ protected:
   virtual bool ParseURL(const char* url);
 
 private:
-  vtk_sqlite3 *SQLiteInstance;
+  sqlite3 *SQLiteInstance;
   
   // We want this to be private, a user of this class
   // should not be setting this for any reason
--- vtk-5.8.0.orig/IO/vtkSQLiteQuery.cxx
+++ vtk-5.8.0/IO/vtkSQLiteQuery.cxx
@@ -25,7 +25,7 @@
 #include "vtkVariant.h"
 #include "vtkVariantArray.h"
 
-#include <vtksqlite/vtk_sqlite3.h>
+#include <sqlite3.h>
 
 #include <assert.h>
 
@@ -43,7 +43,7 @@ vtkSQLiteQuery::vtkSQLiteQuery()
 {
   this->Statement = NULL;
   this->InitialFetch = true;
-  this->InitialFetchResult=VTK_SQLITE_DONE;
+  this->InitialFetchResult=SQLITE_DONE;
   this->LastErrorText = NULL;
   this->TransactionInProgress = false;
 }
@@ -61,7 +61,7 @@ vtkSQLiteQuery::~vtkSQLiteQuery()
     {
     if (this->Database != NULL)
       {
-      vtk_sqlite3_finalize(this->Statement);
+      sqlite3_finalize(this->Statement);
       this->Statement = NULL;
       }
     }
@@ -131,8 +131,8 @@ bool vtkSQLiteQuery::SetQuery(const char
   if (this->Statement)
     {
     vtkDebugMacro(<<"Finalizing old statement");
-    int finalizeStatus = vtk_sqlite3_finalize(this->Statement);
-    if (finalizeStatus != VTK_SQLITE_OK)
+    int finalizeStatus = sqlite3_finalize(this->Statement);
+    if (finalizeStatus != SQLITE_OK)
       {
       vtkWarningMacro(<<"SetQuery(): Finalize returned unexpected code "
                       << finalizeStatus);
@@ -151,19 +151,19 @@ bool vtkSQLiteQuery::SetQuery(const char
       return false;
       }
     
-    vtk_sqlite3 *db = dbContainer->SQLiteInstance;
+    sqlite3 *db = dbContainer->SQLiteInstance;
     const char *unused_statement;
     
-    int prepareStatus = vtk_sqlite3_prepare_v2(db, 
+    int prepareStatus = sqlite3_prepare_v2(db, 
                                                this->Query,
                                                static_cast<int>(strlen(this->Query)),
                                                &this->Statement,
                                                &unused_statement);
     
-    if (prepareStatus != VTK_SQLITE_OK)
+    if (prepareStatus != SQLITE_OK)
       {
-      this->SetLastErrorText(vtk_sqlite3_errmsg(db));
-      vtkWarningMacro(<<"SetQuery(): vtk_sqlite3_prepare_v2() failed with error message "
+      this->SetLastErrorText(sqlite3_errmsg(db));
+      vtkWarningMacro(<<"SetQuery(): sqlite3_prepare_v2() failed with error message "
                     << this->GetLastErrorText()
                     << " on statement: '"
                     << this->Query << "'");
@@ -194,31 +194,31 @@ bool vtkSQLiteQuery::Execute()
     }
   else
     {
-    vtk_sqlite3_reset(this->Statement);
+    sqlite3_reset(this->Statement);
     }
 
   vtkDebugMacro(<<"Execute(): Query ready to execute.");
 
   this->InitialFetch = true;
-  int result = vtk_sqlite3_step(this->Statement);
+  int result = sqlite3_step(this->Statement);
   this->InitialFetchResult = result;
 
-  if (result == VTK_SQLITE_DONE)
+  if (result == SQLITE_DONE)
     {
     this->SetLastErrorText(NULL);
     this->Active = true;
     return true;
     }
-  else if (result != VTK_SQLITE_ROW)
+  else if (result != SQLITE_ROW)
     {
     vtkSQLiteDatabase *dbContainer = 
       vtkSQLiteDatabase::SafeDownCast(this->Database);
     assert(dbContainer != NULL);
     
-    vtk_sqlite3 *db = dbContainer->SQLiteInstance;
+    sqlite3 *db = dbContainer->SQLiteInstance;
 
-    this->SetLastErrorText(vtk_sqlite3_errmsg(db));
-    vtkDebugMacro(<< "Execute(): vtk_sqlite3_step() returned error message "
+    this->SetLastErrorText(sqlite3_errmsg(db));
+    vtkDebugMacro(<< "Execute(): sqlite3_step() returned error message "
                   << this->GetLastErrorText());
     this->Active = false;
     return false;
@@ -239,7 +239,7 @@ int vtkSQLiteQuery::GetNumberOfFields()
     }
   else
     {
-    return vtk_sqlite3_column_count(this->Statement);
+    return sqlite3_column_count(this->Statement);
     }
 }
 
@@ -259,7 +259,7 @@ const char * vtkSQLiteQuery::GetFieldNam
     }
   else
     {
-    return vtk_sqlite3_column_name(this->Statement, column);
+    return sqlite3_column_name(this->Statement, column);
     }
 }
 
@@ -279,22 +279,22 @@ int vtkSQLiteQuery::GetFieldType(int col
     }
   else
     {
-    switch (vtk_sqlite3_column_type(this->Statement, column))
+    switch (sqlite3_column_type(this->Statement, column))
       {
-      case VTK_SQLITE_INTEGER:
+      case SQLITE_INTEGER:
         return VTK_INT; 
-      case VTK_SQLITE_FLOAT:
+      case SQLITE_FLOAT:
         return VTK_FLOAT;
-      case VTK_SQLITE_TEXT:
+      case SQLITE_TEXT:
         return VTK_STRING;
-      case VTK_SQLITE_BLOB:
+      case SQLITE_BLOB:
         return VTK_STRING; // until we have a BLOB type of our own
-      case VTK_SQLITE_NULL:
+      case SQLITE_NULL:
         return VTK_VOID; // ??? what makes sense here?
       default:
       {
       vtkErrorMacro(<<"GetFieldType(): Unknown data type " 
-                    << vtk_sqlite3_column_type(this->Statement, column)
+                    << sqlite3_column_type(this->Statement, column)
                     <<" from SQLite.");
       return VTK_VOID;
       }
@@ -315,7 +315,7 @@ bool vtkSQLiteQuery::NextRow()
     {
     vtkDebugMacro(<<"NextRow(): Initial fetch being handled.");
     this->InitialFetch = false;
-    if (this->InitialFetchResult == VTK_SQLITE_DONE)
+    if (this->InitialFetchResult == SQLITE_DONE)
       {
       return false;
       }
@@ -326,12 +326,12 @@ bool vtkSQLiteQuery::NextRow()
     }
   else
     {
-    int result = vtk_sqlite3_step(this->Statement);
-    if (result == VTK_SQLITE_DONE)
+    int result = sqlite3_step(this->Statement);
+    if (result == SQLITE_DONE)
       {
       return false;
       }
-    else if (result == VTK_SQLITE_ROW)
+    else if (result == SQLITE_ROW)
       {
       return true;
       }
@@ -339,8 +339,8 @@ bool vtkSQLiteQuery::NextRow()
       {
       vtkSQLiteDatabase *dbContainer = vtkSQLiteDatabase::SafeDownCast( this->Database );
       assert(dbContainer != NULL);
-      vtk_sqlite3 *db = dbContainer->SQLiteInstance;
-      this->SetLastErrorText(vtk_sqlite3_errmsg(db));
+      sqlite3 *db = dbContainer->SQLiteInstance;
+      this->SetLastErrorText(sqlite3_errmsg(db));
       vtkErrorMacro(<<"NextRow(): Database returned error code " 
                     << result << " with the following message: "
                     << this->GetLastErrorText());
@@ -366,33 +366,33 @@ vtkVariant vtkSQLiteQuery::DataValue(vtk
     }
   else
     {
-    switch (vtk_sqlite3_column_type(this->Statement, column))
+    switch (sqlite3_column_type(this->Statement, column))
       {
-      case VTK_SQLITE_INTEGER:
-        return vtkVariant(vtk_sqlite3_column_int(this->Statement, column));
+      case SQLITE_INTEGER:
+        return vtkVariant(sqlite3_column_int(this->Statement, column));
 
-      case VTK_SQLITE_FLOAT:
-        return vtkVariant(vtk_sqlite3_column_double(this->Statement, column));
+      case SQLITE_FLOAT:
+        return vtkVariant(sqlite3_column_double(this->Statement, column));
 
-      case VTK_SQLITE_TEXT:
+      case SQLITE_TEXT:
       {
       vtksys_ios::ostringstream str;
-      str << vtk_sqlite3_column_text(this->Statement, column);
+      str << sqlite3_column_text(this->Statement, column);
       return vtkVariant(vtkStdString(str.str()));
       }
 
-      case VTK_SQLITE_BLOB:
+      case SQLITE_BLOB:
       {
       // This is a hack ... by passing the BLOB to vtkStdString with an explicit
       // byte count, we ensure that the string will store all of the BLOB's bytes,
       // even if there are NULL values.
 
       return vtkVariant(vtkStdString(
-        static_cast<const char*>(vtk_sqlite3_column_blob(this->Statement, column)),
-        vtk_sqlite3_column_bytes(this->Statement, column)));
+        static_cast<const char*>(sqlite3_column_blob(this->Statement, column)),
+        sqlite3_column_bytes(this->Statement, column)));
       }
       
-      case VTK_SQLITE_NULL:
+      case SQLITE_NULL:
       default:
         return vtkVariant();
       }
@@ -423,11 +423,11 @@ bool vtkSQLiteQuery::BeginTransaction()
   vtkSQLiteDatabase *dbContainer = vtkSQLiteDatabase::SafeDownCast( this->Database );
   assert(dbContainer != NULL);
 
-  vtk_sqlite3 *db = dbContainer->SQLiteInstance;
+  sqlite3 *db = dbContainer->SQLiteInstance;
   char *errorMessage = NULL;
-  int result = vtk_sqlite3_exec(db, BEGIN_TRANSACTION, NULL, NULL, &errorMessage);
+  int result = sqlite3_exec(db, BEGIN_TRANSACTION, NULL, NULL, &errorMessage);
 
-  if (result == VTK_SQLITE_OK)
+  if (result == SQLITE_OK)
     {
     this->TransactionInProgress = true;
     this->SetLastErrorText(NULL);
@@ -451,7 +451,7 @@ bool vtkSQLiteQuery::CommitTransaction()
 {
   if (this->Statement)
     {
-    vtk_sqlite3_finalize(this->Statement);
+    sqlite3_finalize(this->Statement);
     this->Statement = NULL;
     }
 
@@ -463,11 +463,11 @@ bool vtkSQLiteQuery::CommitTransaction()
   
   vtkSQLiteDatabase *dbContainer = vtkSQLiteDatabase::SafeDownCast( this->Database );
   assert(dbContainer != NULL);
-  vtk_sqlite3 *db = dbContainer->SQLiteInstance;
+  sqlite3 *db = dbContainer->SQLiteInstance;
   char *errorMessage = NULL;
-  int result = vtk_sqlite3_exec(db, COMMIT_TRANSACTION, NULL, NULL, &errorMessage);
+  int result = sqlite3_exec(db, COMMIT_TRANSACTION, NULL, NULL, &errorMessage);
 
-  if (result == VTK_SQLITE_OK)
+  if (result == SQLITE_OK)
     {
     this->TransactionInProgress = false;
     this->SetLastErrorText(NULL);
@@ -499,11 +499,11 @@ bool vtkSQLiteQuery::RollbackTransaction
 
   vtkSQLiteDatabase *dbContainer = vtkSQLiteDatabase::SafeDownCast( this->Database );
   assert(dbContainer != NULL);
-  vtk_sqlite3 *db = dbContainer->SQLiteInstance;
+  sqlite3 *db = dbContainer->SQLiteInstance;
   char *errorMessage = NULL;
-  int result = vtk_sqlite3_exec(db, ROLLBACK_TRANSACTION, NULL, NULL, &errorMessage);
+  int result = sqlite3_exec(db, ROLLBACK_TRANSACTION, NULL, NULL, &errorMessage);
 
-  if (result == VTK_SQLITE_OK)
+  if (result == SQLITE_OK)
     {
     this->TransactionInProgress = false;
     this->SetLastErrorText(NULL);
@@ -647,11 +647,11 @@ bool vtkSQLiteQuery::BindIntegerParamete
   if (this->Active)
     {
     this->Active = false;
-    vtk_sqlite3_reset(this->Statement);
+    sqlite3_reset(this->Statement);
     }
-  int status = vtk_sqlite3_bind_int(this->Statement, index+1, value);
+  int status = sqlite3_bind_int(this->Statement, index+1, value);
 
-  if (status != VTK_SQLITE_OK)
+  if (status != SQLITE_OK)
     {
     vtksys_ios::ostringstream errormessage;
     errormessage << "sqlite_bind_int returned error: " << status;
@@ -676,11 +676,11 @@ bool vtkSQLiteQuery::BindInt64Parameter(
   if (this->Active)
     {
     this->Active = false;
-    vtk_sqlite3_reset(this->Statement);
+    sqlite3_reset(this->Statement);
     }
-  int status = vtk_sqlite3_bind_int(this->Statement, index+1, static_cast<vtk_sqlite_int64>(value));
+  int status = sqlite3_bind_int(this->Statement, index+1, static_cast<sqlite_int64>(value));
 
-  if (status != VTK_SQLITE_OK)
+  if (status != SQLITE_OK)
     {
     vtksys_ios::ostringstream errormessage;
     errormessage << "sqlite_bind_int64 returned error: " << status;
@@ -705,12 +705,12 @@ bool vtkSQLiteQuery::BindDoubleParameter
   if (this->Active)
     {
     this->Active = false;
-    vtk_sqlite3_reset(this->Statement);
+    sqlite3_reset(this->Statement);
     }
 
-  int status = vtk_sqlite3_bind_double(this->Statement, index+1, value);
+  int status = sqlite3_bind_double(this->Statement, index+1, value);
 
-  if (status != VTK_SQLITE_OK)
+  if (status != SQLITE_OK)
     {
     vtksys_ios::ostringstream errormessage;
     errormessage << "sqlite_bind_double returned error: " << status;
@@ -734,12 +734,12 @@ bool vtkSQLiteQuery::BindStringParameter
   if (this->Active)
     {
     this->Active = false;
-    vtk_sqlite3_reset(this->Statement);
+    sqlite3_reset(this->Statement);
     }
   
-  int status = vtk_sqlite3_bind_text(this->Statement, index+1, value, length, VTK_SQLITE_TRANSIENT);
+  int status = sqlite3_bind_text(this->Statement, index+1, value, length, SQLITE_TRANSIENT);
 
-  if (status != VTK_SQLITE_OK)
+  if (status != SQLITE_OK)
     {
     vtksys_ios::ostringstream errormessage;
     errormessage << "sqlite_bind_text returned error: " << status;
@@ -763,17 +763,17 @@ bool vtkSQLiteQuery::BindBlobParameter(i
   if (this->Active)
     {
     this->Active = false;
-    vtk_sqlite3_reset(this->Statement);
+    sqlite3_reset(this->Statement);
     }
   
   int status = 
-    vtk_sqlite3_bind_blob(this->Statement, 
+    sqlite3_bind_blob(this->Statement, 
                           index+1, 
                           data, 
                           length, 
-                          VTK_SQLITE_TRANSIENT);
+                          SQLITE_TRANSIENT);
 
-  if (status != VTK_SQLITE_OK)
+  if (status != SQLITE_OK)
     {
     vtksys_ios::ostringstream errormessage;
     errormessage << "sqlite_bind_blob returned error: " << status;
@@ -797,12 +797,12 @@ bool vtkSQLiteQuery::ClearParameterBindi
   if (this->Active)
     {
     this->Active = false;
-    vtk_sqlite3_reset(this->Statement);
+    sqlite3_reset(this->Statement);
     }
 
-  int status = vtk_sqlite3_clear_bindings(this->Statement);
+  int status = sqlite3_clear_bindings(this->Statement);
   
-  if (status != VTK_SQLITE_OK)
+  if (status != SQLITE_OK)
     {
     vtksys_ios::ostringstream errormessage;
     errormessage << "sqlite_clear_bindings returned error: " << status;
--- vtk-5.8.0.orig/IO/vtkSQLiteQuery.h
+++ vtk-5.8.0/IO/vtkSQLiteQuery.h
@@ -46,7 +46,7 @@
 class vtkSQLiteDatabase;
 class vtkVariant;
 class vtkVariantArray;
-struct vtk_sqlite3_stmt;
+struct sqlite3_stmt;
 
 class VTK_IO_EXPORT vtkSQLiteQuery : public vtkSQLQuery
 {
@@ -154,7 +154,7 @@ private:
   vtkSQLiteQuery(const vtkSQLiteQuery &); // Not implemented.
   void operator=(const vtkSQLiteQuery &); // Not implemented.
 
-  vtk_sqlite3_stmt *Statement;
+  sqlite3_stmt *Statement;
   bool InitialFetch;
   int InitialFetchResult;
   char *LastErrorText;
--- vtk-5.8.0.orig/Infovis/vtkBoostBreadthFirstSearchTree.cxx
+++ vtk-5.8.0/Infovis/vtkBoostBreadthFirstSearchTree.cxx
@@ -47,6 +47,23 @@ using namespace boost;
 vtkStandardNewMacro(vtkBoostBreadthFirstSearchTree);
 
 
+#if BOOST_VERSION >= 104800      // Boost 1.48.x
+namespace {
+  vtkIdType unwrap_edge_id(vtkEdgeType const &e)
+  {
+    return e.Id;
+  }
+  vtkIdType unwrap_edge_id(boost::detail::reverse_graph_edge_descriptor<vtkEdgeType> const &e)
+  {
+# if BOOST_VERSION == 104800
+    return e.underlying_desc.Id;
+# else
+    return e.underlying_descx.Id;
+# endif
+  }
+}
+#endif
+
 // Redefine the bfs visitor, the only visitor we
 // are using is the tree_edge visitor.
 template <typename IdMap>
@@ -95,7 +112,12 @@ public:
 
     // Copy the vertex and edge data from the graph to the tree.
     tree->GetVertexData()->CopyData(graph->GetVertexData(), v, tree_v);
+#if BOOST_VERSION < 104800      // Boost 1.48.x
     tree->GetEdgeData()->CopyData(graph->GetEdgeData(), e.Id, tree_e.Id);
+#else
+    tree->GetEdgeData()->CopyData(graph->GetEdgeData(),
+                                  unwrap_edge_id(e), tree_e.Id);
+#endif
   }
 
 private:
--- vtk-5.8.0.orig/Parallel/CMakeLists.txt
+++ vtk-5.8.0/Parallel/CMakeLists.txt
@@ -151,7 +151,7 @@ ENDIF(VTK_USE_RENDERING)
 IF (VTK_USE_MPI)
   INCLUDE (FindMPI)
 
-  INCLUDE_DIRECTORIES("${MPI_INCLUDE_PATH}")
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
 
   SET ( Kit_SRCS
     ${Kit_SRCS}
@@ -205,7 +205,7 @@ IF (VTK_USE_MPI)
     MESSAGE("Could not find the required MPI libraries")
   ENDIF (MPI_LIBRARY)   
   IF (MPI_EXTRA_LIBRARY)   
-    SET(KIT_LIBS ${KIT_LIBS} "${MPI_EXTRA_LIBRARY}")   
+    SET(KIT_LIBS ${KIT_LIBS} "${MPI_LIBRARY}")   
   ENDIF (MPI_EXTRA_LIBRARY) 
 ENDIF (VTK_USE_MPI)
 
@@ -240,6 +240,8 @@ FOREACH(file ${glsl_files})
 ENDFOREACH(file)
 ENDIF(VTK_USE_RENDERING)
 
+
+
 #-----------------------------------------------------------------------------
 # Include CMake code common to all kits.
 INCLUDE(${VTK_CMAKE_DIR}/KitCommonBlock.cmake)
--- vtk-5.8.0.orig/Rendering/CMakeLists.txt
+++ vtk-5.8.0/Rendering/CMakeLists.txt
@@ -9,9 +9,7 @@ IF (JAVA_AWT_LIBRARY)
 ENDIF (JAVA_AWT_LIBRARY)
 
 SET(KIT_INTERFACE_LIBRARIES vtkGraphics vtkImaging)
-SET(KIT_LIBS vtkIO vtkftgl
-  ${VTK_FREETYPE_LIBRARIES}
-)
+SET(KIT_LIBS vtkIO vtkftgl)
 #INCLUDE(${VTK_CMAKE_DIR}/vtkTestGL.cmake)
 #INCLUDE(${VTK_CMAKE_DIR}/vtkTestGLX.cmake)
 
@@ -440,9 +438,9 @@ IF(VTK_USE_QT)
   # path in install names. This workaround fixes the problem by forcing all libraries
   # and executables that depend on vtkRendering to also directly link to Qt libraries.
   IF (APPLE)
-    LIST (APPEND KIT_INTERFACE_LIBRARIES ${QT_LIBRARIES})
+    LIST (APPEND KIT_INTERFACE_LIBRARIES QtGui QtCore)
   ELSE (APPLE)
-    LIST (APPEND KIT_LIBS ${QT_LIBRARIES})
+    LIST (APPEND KIT_LIBS QtGui QtCore)
   ENDIF (APPLE)
 
 ENDIF(VTK_USE_QT)
@@ -538,7 +536,6 @@ ELSE (WIN32)
     INCLUDE(CheckFunctionExists)
     SET(VTK_SAVE_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
     SET(CMAKE_REQUIRED_LIBRARIES
-      ${OPENGL_LIBRARIES}
       ${CMAKE_THREAD_LIBS}
       ${CMAKE_REQUIRED_LIBRARIES}
       -lm
@@ -784,7 +781,7 @@ IF (VTK_WRAP_TCL AND VTK_USE_TK)
   # Use special interactor for X and Tk.
   IF(VTK_USE_X)
     SET(KitTCL_SRCS ${KitTCL_SRCS} vtkXRenderWindowTclInteractor.cxx)
-    SET(KIT_TCL_LIBS ${KIT_TCL_LIBS} ${X11_LIBRARIES})
+    SET(KIT_TCL_LIBS ${KIT_TCL_LIBS} X11)
   ENDIF(VTK_USE_X)
   IF(VTK_USE_CARBON)
     SET(KIT_TCL_LIBS ${KIT_TCL_LIBS} "-framework Carbon")
@@ -837,7 +834,7 @@ IF (VTK_WRAP_PYTHON AND VTK_USE_TK AND T
               ${RenderingPythonTkWidgets_SRCS})
   SET(VTK_PYTHONTK_LIBRARIES ${VTK_TK_LIBRARIES})
   IF(VTK_USE_X)
-    SET(VTK_PYTHONTK_LIBRARIES ${VTK_PYTHONTK_LIBRARIES} ${X11_LIBRARIES})
+    SET(VTK_PYTHONTK_LIBRARIES ${VTK_PYTHONTK_LIBRARIES} X11)
   ENDIF(VTK_USE_X)
   IF(VTK_USE_CARBON)
     SET(VTK_PYTHONTK_LIBRARIES ${VTK_PYTHONTK_LIBRARIES} "-framework Carbon")
@@ -874,7 +871,7 @@ IF(VTK_USE_X)
   IF (X11_Xt_LIB)
     TARGET_LINK_LIBRARIES(vtk${KIT} ${X11_Xt_LIB})
   ENDIF (X11_Xt_LIB)
-  TARGET_LINK_LIBRARIES(vtk${KIT} ${X11_LIBRARIES})
+  TARGET_LINK_LIBRARIES(vtk${KIT} X11)
   IF (VTK_USE_TK)
     # Definitely needed in case we are linking against a Tcl/Tk 8.5 static,
     # which by default seems to be missing Xss and Xft. It can not just be
@@ -883,12 +880,12 @@ IF(VTK_USE_X)
     FIND_LIBRARY(X11_Xscreensaver_LIB Xss ${X11_LIB_SEARCH_PATH})
     MARK_AS_ADVANCED(X11_Xscreensaver_LIB)
     IF(X11_Xscreensaver_LIB)
-      TARGET_LINK_LIBRARIES(vtk${KIT} ${X11_Xscreensaver_LIB})
+#      TARGET_LINK_LIBRARIES(vtk${KIT} ${X11_Xscreensaver_LIB})
     ENDIF(X11_Xscreensaver_LIB)
     FIND_LIBRARY(X11_Xft_LIB Xft ${X11_LIB_SEARCH_PATH})
     MARK_AS_ADVANCED(X11_Xft_LIB)
     IF(X11_Xft_LIB)
-      TARGET_LINK_LIBRARIES(vtk${KIT} ${X11_Xft_LIB})
+#      TARGET_LINK_LIBRARIES(vtk${KIT} ${X11_Xft_LIB})
     ENDIF(X11_Xft_LIB)
     IF(APPLE)
       FIND_LIBRARY(X11_fontconfig_LIB fontconfig ${X11_LIB_SEARCH_PATH})
--- vtk-5.8.0.orig/Rendering/vtkWin32OpenGLRenderWindow.cxx
+++ vtk-5.8.0/Rendering/vtkWin32OpenGLRenderWindow.cxx
@@ -75,9 +75,9 @@ vtkWin32OpenGLRenderWindow::~vtkWin32Ope
 void vtkWin32OpenGLRenderWindow::Clean()
 {
   GLuint id;
-  
+
   /* finish OpenGL rendering */
-  if (this->ContextId) 
+  if (this->ContextId)
     {
     this->MakeCurrent();
 
@@ -86,7 +86,7 @@ void vtkWin32OpenGLRenderWindow::Clean()
       {
       glDisable((GLenum)cur_light);
       }
-    
+
     /* now delete all textures */
     glDisable(GL_TEXTURE_2D);
     for (int i = 1; i < this->TextureResourceIds->GetNumberOfIds(); i++)
@@ -106,16 +106,16 @@ void vtkWin32OpenGLRenderWindow::Clean()
       }
 
     this->CleanUpRenderers();
-    
+
     // Note: wglMakeCurrent(NULL,NULL) is valid according to the documentation
     // and works with nVidia and ATI but not with Intel. Passing an existing
     // device context works in any case.
     // see VTK Bug 7119.
-    if(wglMakeCurrent(this->DeviceContext,NULL)!=TRUE) 
+    if(wglMakeCurrent(this->DeviceContext,NULL)!=TRUE)
       {
       vtkErrorMacro("wglMakeCurrent failed in Clean(), error: " << GetLastError());
       }
-    if (wglDeleteContext(this->ContextId) != TRUE) 
+    if (wglDeleteContext(this->ContextId) != TRUE)
       {
       vtkErrorMacro("wglDeleteContext failed in Clean(), error: " << GetLastError());
       }
@@ -136,7 +136,7 @@ void vtkWin32OpenGLRenderWindow::CleanUp
   // destructor)
   vtkRenderer *ren;
   vtkCollectionSimpleIterator rsit;
-  for (this->Renderers->InitTraversal(rsit); 
+  for (this->Renderers->InitTraversal(rsit);
        (ren = this->Renderers->GetNextRenderer(rsit));)
     {
     ren->SetRenderWindow(NULL);
@@ -144,13 +144,13 @@ void vtkWin32OpenGLRenderWindow::CleanUp
     }
 }
 
-LRESULT APIENTRY vtkWin32OpenGLRenderWindow::WndProc(HWND hWnd, UINT message, 
-                                                     WPARAM wParam, 
+LRESULT APIENTRY vtkWin32OpenGLRenderWindow::WndProc(HWND hWnd, UINT message,
+                                                     WPARAM wParam,
                                                      LPARAM lParam)
 {
   LRESULT res;
 
-  vtkWin32OpenGLRenderWindow *me = 
+  vtkWin32OpenGLRenderWindow *me =
     (vtkWin32OpenGLRenderWindow *)vtkGetWindowLong(hWnd,sizeof(vtkLONG));
 
   if (me && me->GetReferenceCount()>0)
@@ -199,7 +199,7 @@ int vtkWin32OpenGLRenderWindow::GetEvent
       return 1;
       }
     }
-  
+
   return 0;
 }
 
@@ -216,21 +216,21 @@ void vtkWin32OpenGLRenderWindow::MakeCur
                     " than the one doing the picking, this can causes crashes"
                     " and/or bad pick results");
       }
-    else 
+    else
       {
-      if (wglMakeCurrent(this->DeviceContext, this->ContextId) != TRUE) 
+      if (wglMakeCurrent(this->DeviceContext, this->ContextId) != TRUE)
         {
         LPVOID lpMsgBuf;
-        ::FormatMessage( 
-          FORMAT_MESSAGE_ALLOCATE_BUFFER | 
-          FORMAT_MESSAGE_FROM_SYSTEM | 
+        ::FormatMessage(
+          FORMAT_MESSAGE_ALLOCATE_BUFFER |
+          FORMAT_MESSAGE_FROM_SYSTEM |
           FORMAT_MESSAGE_IGNORE_INSERTS,
           NULL,
           GetLastError(),
           MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
           (LPTSTR) &lpMsgBuf,
           0,
-          NULL 
+          NULL
           );
         if(lpMsgBuf)
           {
@@ -243,7 +243,7 @@ void vtkWin32OpenGLRenderWindow::MakeCur
           delete [] wmsg;
           delete [] wtemp;
 #else
-          vtkErrorMacro("wglMakeCurrent failed in MakeCurrent(), error: " 
+          vtkErrorMacro("wglMakeCurrent failed in MakeCurrent(), error: "
                         << (LPCTSTR)lpMsgBuf);
 #endif
           ::LocalFree( lpMsgBuf );
@@ -289,13 +289,13 @@ void vtkWin32OpenGLRenderWindow::SetSize
           }
         }
       }
-    
+
     else if (this->Mapped)
       {
       if (!resizing)
         {
         resizing = 1;
-        
+
         if (this->ParentId)
           {
           SetWindowExtEx(this->DeviceContext,x,y,NULL);
@@ -330,7 +330,7 @@ void vtkWin32OpenGLRenderWindow::SetPosi
       if (!resizing)
         {
         resizing = 1;
-        
+
         SetWindowPos(this->WindowId,HWND_TOP,x,y,
                      0, 0, SWP_NOSIZE | SWP_NOZORDER);
         resizing = 0;
@@ -426,7 +426,7 @@ const char* vtkWin32OpenGLRenderWindow::
   if (pfd.cColorBits <= 8)
     {
     strm << "class:  PseudoColor" << endl;
-    } 
+    }
   else
     {
     strm << "class:  TrueColor" << endl;
@@ -447,14 +447,14 @@ const char* vtkWin32OpenGLRenderWindow::
   strm << "double buffer:  False" << endl;
   }
   if (pfd.dwFlags & PFD_STEREO) {
-  strm << "stereo:  True" << endl;  
+  strm << "stereo:  True" << endl;
   } else {
   strm << "stereo:  False" << endl;
   }
   if (pfd.dwFlags & PFD_GENERIC_FORMAT) {
-  strm << "hardware acceleration:  False" << endl; 
+  strm << "hardware acceleration:  False" << endl;
   } else {
-  strm << "hardware acceleration:  True" << endl; 
+  strm << "hardware acceleration:  True" << endl;
   }
   strm << "rgba:  redSize=" << static_cast<int>(pfd.cRedBits) << " greenSize=" << static_cast<int>(pfd.cGreenBits) << "blueSize=" << static_cast<int>(pfd.cBlueBits) << "alphaSize=" << static_cast<int>(pfd.cAlphaBits) << endl;
   strm << "aux buffers:  " << static_cast<int>(pfd.cAuxBuffers)<< endl;
@@ -463,17 +463,17 @@ const char* vtkWin32OpenGLRenderWindow::
   strm << "accum:  redSize=" << static_cast<int>(pfd.cAccumRedBits) << " greenSize=" << static_cast<int>(pfd.cAccumGreenBits) << "blueSize=" << static_cast<int>(pfd.cAccumBlueBits) << "alphaSize=" << static_cast<int>(pfd.cAccumAlphaBits) << endl;
 
   delete[] this->Capabilities;
-  
+
   size_t len = strm.str().length() + 1;
   this->Capabilities = new char[len];
   strncpy(this->Capabilities, strm.str().c_str(), len);
-  
+
   return this->Capabilities;
 }
 
- 
-void vtkWin32OpenGLRenderWindow::SetupPixelFormat(HDC hDC, DWORD dwFlags, 
-                                                  int debug, int bpp, 
+
+void vtkWin32OpenGLRenderWindow::SetupPixelFormat(HDC hDC, DWORD dwFlags,
+                                                  int debug, int bpp,
                                                   int zbpp)
 {
   PIXELFORMATDESCRIPTOR pfd = {
@@ -505,12 +505,12 @@ void vtkWin32OpenGLRenderWindow::SetupPi
     if (!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
       {
 #ifdef UNICODE
-      MessageBox(WindowFromDC(hDC), 
+      MessageBox(WindowFromDC(hDC),
                  L"Invalid pixel format, no OpenGL support",
                  L"Error",
                  MB_ICONERROR | MB_OK);
 #else
-      MessageBox(WindowFromDC(hDC), 
+      MessageBox(WindowFromDC(hDC),
                  "Invalid pixel format, no OpenGL support",
                  "Error",
                  MB_ICONERROR | MB_OK);
@@ -524,11 +524,11 @@ void vtkWin32OpenGLRenderWindow::SetupPi
         {
         exit(1);
         }
-      }         
+      }
     }
   else
     {
-    // hDC has no current PixelFormat, so 
+    // hDC has no current PixelFormat, so
     pixelFormat = ChoosePixelFormat(hDC, &pfd);
     if (pixelFormat == 0)
       {
@@ -549,8 +549,8 @@ void vtkWin32OpenGLRenderWindow::SetupPi
         exit(1);
         }
       }
-    DescribePixelFormat(hDC, pixelFormat,sizeof(pfd), &pfd); 
-    if (SetPixelFormat(hDC, pixelFormat, &pfd) != TRUE) 
+    DescribePixelFormat(hDC, pixelFormat,sizeof(pfd), &pfd);
+    if (SetPixelFormat(hDC, pixelFormat, &pfd) != TRUE)
       {
       // int err = GetLastError();
 #ifdef UNICODE
@@ -626,10 +626,10 @@ void vtkWin32OpenGLRenderWindow::SetupPa
 }
 
 
-LRESULT vtkWin32OpenGLRenderWindow::MessageProc(HWND hWnd, UINT message, 
+LRESULT vtkWin32OpenGLRenderWindow::MessageProc(HWND hWnd, UINT message,
                                                 WPARAM wParam, LPARAM lParam)
 {
-  switch (message) 
+  switch (message)
     {
     case WM_CREATE:
     {
@@ -648,18 +648,18 @@ LRESULT vtkWin32OpenGLRenderWindow::Mess
       return 0;
     case WM_SIZE:
       /* track window size changes */
-      if (this->ContextId) 
+      if (this->ContextId)
         {
         this->SetSize((int) LOWORD(lParam),(int) HIWORD(lParam));
         return 0;
         }
     case WM_PALETTECHANGED:
       /* realize palette if this is *not* the current window */
-      if (this->ContextId && this->Palette && (HWND) wParam != hWnd) 
+      if (this->ContextId && this->Palette && (HWND) wParam != hWnd)
         {
         SelectPalette(this->DeviceContext, this->OldPalette, FALSE);
         UnrealizeObject(this->Palette);
-        this->OldPalette = SelectPalette(this->DeviceContext, 
+        this->OldPalette = SelectPalette(this->DeviceContext,
                                          this->Palette, FALSE);
         RealizePalette(this->DeviceContext);
         this->Render();
@@ -667,11 +667,11 @@ LRESULT vtkWin32OpenGLRenderWindow::Mess
       break;
     case WM_QUERYNEWPALETTE:
       /* realize palette if this is the current window */
-      if (this->ContextId && this->Palette) 
+      if (this->ContextId && this->Palette)
         {
         SelectPalette(this->DeviceContext, this->OldPalette, FALSE);
         UnrealizeObject(this->Palette);
-        this->OldPalette = SelectPalette(this->DeviceContext, 
+        this->OldPalette = SelectPalette(this->DeviceContext,
                                          this->Palette, FALSE);
         RealizePalette(this->DeviceContext);
         this->Render();
@@ -682,7 +682,7 @@ LRESULT vtkWin32OpenGLRenderWindow::Mess
     {
     PAINTSTRUCT ps;
     BeginPaint(hWnd, &ps);
-    if (this->ContextId) 
+    if (this->ContextId)
       {
       this->Render();
       }
@@ -730,20 +730,20 @@ void vtkWin32OpenGLRenderWindow::CreateA
     {
     static int count = 1;
     char *windowName;
-    
+
     if (!this->WindowId)
       {
       WNDCLASS wndClass;
       this->DeviceContext = 0;
-      
-      int len = static_cast<int>(strlen("Visualization Toolkit - Win32OpenGL #")) 
+
+      int len = static_cast<int>(strlen("Visualization Toolkit - Win32OpenGL #"))
         + (int)ceil( (double) log10( (double)(count+1) ) )
-        + 1; 
+        + 1;
       windowName = new char [ len ];
       sprintf(windowName,"Visualization Toolkit - Win32OpenGL #%i",count++);
       this->SetWindowName(windowName);
       delete [] windowName;
-      
+
       // has the class been registered ?
 #ifdef UNICODE
       if (!GetClassInfo(this->ApplicationInstance,L"vtkOpenGL",&wndClass))
@@ -770,7 +770,7 @@ void vtkWin32OpenGLRenderWindow::CreateA
           wndClass.cbWndExtra = 2 * sizeof(vtkLONG);
           RegisterClass(&wndClass);
           }
-      
+
 #ifdef UNICODE
       wchar_t *wname = new wchar_t [mbstowcs(NULL, this->WindowName, 32000)+1];
       mbstowcs(wname, this->WindowName, 32000);
@@ -779,7 +779,7 @@ void vtkWin32OpenGLRenderWindow::CreateA
       int y = ((this->Position[1] >= 0) ? this->Position[1] : 5);
       int height = ((this->Size[1] > 0) ? this->Size[1] : 300);
       int width = ((this->Size[0] > 0) ? this->Size[0] : 300);
-      
+
       /* create window */
       if (this->ParentId)
         {
@@ -812,7 +812,7 @@ void vtkWin32OpenGLRenderWindow::CreateA
         this->WindowId = CreateWindow(
           L"vtkOpenGL", wname, style,
           x,y, width+2*GetSystemMetrics(SM_CXFRAME),
-          height+2*GetSystemMetrics(SM_CYFRAME) 
+          height+2*GetSystemMetrics(SM_CYFRAME)
           +GetSystemMetrics(SM_CYCAPTION),
           NULL, NULL, this->ApplicationInstance, NULL);
 #else
@@ -827,14 +827,14 @@ void vtkWin32OpenGLRenderWindow::CreateA
 #ifdef UNICODE
       delete [] wname;
 #endif
-      
+
       if (!this->WindowId)
         {
         vtkErrorMacro("Could not create window, error:  " << GetLastError());
         return;
         }
       // extract the create info
-      
+
       /* display window */
       if(!this->OffScreenRendering)
         {
@@ -842,7 +842,7 @@ void vtkWin32OpenGLRenderWindow::CreateA
         }
       //UpdateWindow(this->WindowId);
       this->OwnWindow = 1;
-      vtkSetWindowLong(this->WindowId,sizeof(vtkLONG),(vtkLONG)this);
+      vtkSetWindowLong(this->WindowId,sizeof(vtkLONG),(intptr_t)this);
       }
     if (!this->DeviceContext)
       {
@@ -862,16 +862,16 @@ void vtkWin32OpenGLRenderWindow::CreateA
       }
     this->SetupPalette(this->DeviceContext);
     this->ContextId = wglCreateContext(this->DeviceContext);
-    if (this->ContextId == NULL) 
+    if (this->ContextId == NULL)
       {
       vtkErrorMacro("wglCreateContext failed in CreateAWindow(), error: " << GetLastError());
       }
     this->MakeCurrent();
-    
+
     // wipe out any existing display lists
     vtkRenderer* ren;
     vtkCollectionSimpleIterator rsit;
-    for (this->Renderers->InitTraversal(rsit); 
+    for (this->Renderers->InitTraversal(rsit);
          (ren = this->Renderers->GetNextRenderer(rsit));)
       {
       ren->SetRenderWindow(0);
@@ -889,20 +889,20 @@ void vtkWin32OpenGLRenderWindow::CreateA
 
 // Initialize the window for rendering.
 void vtkWin32OpenGLRenderWindow::WindowInitialize()
-{ 
+{
   // create our own window if not already set
   this->OwnWindow = 0;
   if (!this->MFChandledWindow)
     {
     this->InitializeApplication();
     this->CreateAWindow();
-    }   
-  else 
+    }
+  else
     {
     this->MakeCurrent(); // hsr
     this->OpenGLInit();
     }
-  
+
   // set the DPI
   this->SetDPI(GetDeviceCaps(this->DeviceContext, LOGPIXELSY));
 }
@@ -910,7 +910,7 @@ void vtkWin32OpenGLRenderWindow::WindowI
 // Initialize the rendering window.
 void vtkWin32OpenGLRenderWindow::Initialize (void)
 {
-  // make sure we havent already been initialized 
+  // make sure we havent already been initialized
   if (!this->OffScreenRendering && !this->ContextId)
     {
     this->WindowInitialize();
@@ -955,7 +955,7 @@ void vtkWin32OpenGLRenderWindow::Destroy
         ReleaseDC(this->WindowId, this->DeviceContext);
         // can't set WindowId=NULL, needed for DestroyWindow
         this->DeviceContext = NULL;
-        
+
         // clear the extra data before calling destroy
         vtkSetWindowLong(this->WindowId,sizeof(vtkLONG),(vtkLONG)0);
         if(this->OwnWindow)
@@ -971,18 +971,18 @@ void vtkWin32OpenGLRenderWindow::Destroy
 // Get the current size of the window.
 int *vtkWin32OpenGLRenderWindow::GetSize(void)
 {
-  // if we aren't mapped then just return the ivar 
+  // if we aren't mapped then just return the ivar
   if (this->Mapped)
     {
     RECT rect;
 
-    //  Find the current window size 
+    //  Find the current window size
     if (GetClientRect(this->WindowId, &rect))
-      {    
+      {
       this->Size[0] = rect.right;
       this->Size[1] = rect.bottom;
       }
-    else 
+    else
       {
       this->Size[0] = 0;
       this->Size[1] = 0;
@@ -999,23 +999,23 @@ int *vtkWin32OpenGLRenderWindow::GetScre
   RECT rect;
 
   SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
-                            
+
   this->Size[0] = rect.right - rect.left;
   this->Size[1] = rect.bottom - rect.top;
-  
+
   return this->Size;
 }
 
 // Get the position in screen coordinates of the window.
 int *vtkWin32OpenGLRenderWindow::GetPosition(void)
 {
-  // if we aren't mapped then just return the ivar 
+  // if we aren't mapped then just return the ivar
   if (!this->Mapped)
     {
     return this->Position;
     }
 
-  //  Find the current window position 
+  //  Find the current window position
   //  x,y,&this->Position[0],&this->Position[1],&child);
 
   return this->Position;
@@ -1025,34 +1025,34 @@ int *vtkWin32OpenGLRenderWindow::GetPosi
 void vtkWin32OpenGLRenderWindow::SetFullScreen(int arg)
 {
   int *temp;
-  
+
   if (this->FullScreen == arg)
     {
     return;
     }
-  
+
   if (!this->Mapped)
     {
     this->PrefFullScreen();
     return;
     }
 
-  // set the mode 
+  // set the mode
   this->FullScreen = arg;
   if (this->FullScreen <= 0)
     {
     this->Position[0] = this->OldScreen[0];
     this->Position[1] = this->OldScreen[1];
-    this->Size[0] = this->OldScreen[2]; 
+    this->Size[0] = this->OldScreen[2];
     this->Size[1] = this->OldScreen[3];
     this->Borders = this->OldScreen[4];
     }
   else
     {
-    // if window already up get its values 
+    // if window already up get its values
     if (this->WindowId)
       {
-      temp = this->GetPosition();      
+      temp = this->GetPosition();
       this->OldScreen[0] = temp[0];
       this->OldScreen[1] = temp[1];
 
@@ -1060,8 +1060,8 @@ void vtkWin32OpenGLRenderWindow::SetFull
       this->PrefFullScreen();
       }
     }
-  
-  // remap the window 
+
+  // remap the window
   this->WindowRemap();
 
   this->Modified();
@@ -1092,14 +1092,14 @@ void vtkWin32OpenGLRenderWindow::PrefFul
 
   size = this->GetScreenSize();
 
-  // use full screen 
+  // use full screen
   this->Position[0] = 0;
   this->Position[1] = 0;
   this->Size[0] = size[0] - 2*GetSystemMetrics(SM_CXFRAME);
-  this->Size[1] = size[1] - 
+  this->Size[1] = size[1] -
     2*GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYCAPTION);
 
-  // don't show borders 
+  // don't show borders
   this->Borders = 0;
 }
 
@@ -1108,8 +1108,8 @@ void vtkWin32OpenGLRenderWindow::WindowR
 {
   // close everything down
   this->Finalize();
-  
-  // set the default windowid 
+
+  // set the default windowid
   this->WindowId = this->NextWindowId;
   this->NextWindowId = 0;
 
@@ -1129,7 +1129,7 @@ void vtkWin32OpenGLRenderWindow::PrintSe
 // Get the window id.
 HWND vtkWin32OpenGLRenderWindow::GetWindowId()
 {
-  vtkDebugMacro(<< "Returning WindowId of " << this->WindowId << "\n"); 
+  vtkDebugMacro(<< "Returning WindowId of " << this->WindowId << "\n");
 
   return this->WindowId;
 }
@@ -1138,11 +1138,11 @@ HWND vtkWin32OpenGLRenderWindow::GetWind
 void vtkWin32OpenGLRenderWindow::SetWindowId(HWND arg)
 {
   vtkDebugMacro(<< "Setting WindowId to " << arg << "\n");
-  
+
   if (arg != this->WindowId)
     {
     this->WindowId = arg;
-    if (this->ContextId) 
+    if (this->ContextId)
       {
       wglDeleteContext(this->ContextId);
       }
@@ -1155,24 +1155,24 @@ void vtkWin32OpenGLRenderWindow::SetWind
 void vtkWin32OpenGLRenderWindow::SetWindowInfo(char *info)
 {
   int tmp;
-  
+
   sscanf(info,"%i",&tmp);
 
   this->WindowId = (HWND)tmp;
-  vtkDebugMacro(<< "Setting WindowId to " << this->WindowId << "\n"); 
+  vtkDebugMacro(<< "Setting WindowId to " << this->WindowId << "\n");
 }
 
 void vtkWin32OpenGLRenderWindow::SetNextWindowInfo(char *info)
 {
   int tmp;
-  
+
   sscanf(info,"%i",&tmp);
 
   this->SetNextWindowId((HWND)tmp);
 }
 
 void vtkWin32OpenGLRenderWindow::SetDisplayId(void * arg)
-{ 
+{
   this->DeviceContext = (HDC) arg;
 }
 
@@ -1181,7 +1181,7 @@ void vtkWin32OpenGLRenderWindow::SetCont
   this->ContextId = arg;
 }
 
-void vtkWin32OpenGLRenderWindow::SetDeviceContext(HDC arg) 
+void vtkWin32OpenGLRenderWindow::SetDeviceContext(HDC arg)
 {
   this->DeviceContext = arg;
   this->MFChandledWindow = TRUE;
@@ -1191,17 +1191,17 @@ void vtkWin32OpenGLRenderWindow::SetDevi
 void vtkWin32OpenGLRenderWindow::SetParentInfo(char *info)
 {
   int tmp;
-  
+
   sscanf(info,"%i",&tmp);
 
   this->ParentId = (HWND)tmp;
-  vtkDebugMacro(<< "Setting ParentId to " << this->ParentId << "\n"); 
+  vtkDebugMacro(<< "Setting ParentId to " << this->ParentId << "\n");
 }
 
 // Set the window id to a pre-existing window.
 void vtkWin32OpenGLRenderWindow::SetParentId(HWND arg)
 {
-  vtkDebugMacro(<< "Setting ParentId to " << arg << "\n"); 
+  vtkDebugMacro(<< "Setting ParentId to " << arg << "\n");
 
   this->ParentId = arg;
 }
@@ -1209,7 +1209,7 @@ void vtkWin32OpenGLRenderWindow::SetPare
 // Set the window id of the new window once a WindowRemap is done.
 void vtkWin32OpenGLRenderWindow::SetNextWindowId(HWND arg)
 {
-  vtkDebugMacro(<< "Setting NextWindowId to " << arg << "\n"); 
+  vtkDebugMacro(<< "Setting NextWindowId to " << arg << "\n");
 
   this->NextWindowId = arg;
 }
@@ -1228,7 +1228,7 @@ void vtkWin32OpenGLRenderWindow::Start(v
     this->Initialize();
     }
 
-  // set the current window 
+  // set the current window
   this->MakeCurrent();
 }
 
@@ -1296,13 +1296,13 @@ void vtkWin32OpenGLRenderWindow::CreateO
     DeleteDC(dc);
     }
   this->CreatingOffScreenWindow = status;
-} 
+}
 
 void vtkWin32OpenGLRenderWindow::CreateOffScreenDC(int xsize, int ysize,
                                                    HDC aHdc)
 {
   int dataWidth = ((xsize*3+3)/4)*4;
-  
+
   this->MemoryDataHeader.bmiHeader.biSize = 40;
   this->MemoryDataHeader.bmiHeader.biWidth = xsize;
   this->MemoryDataHeader.bmiHeader.biHeight = ysize;
@@ -1314,7 +1314,7 @@ void vtkWin32OpenGLRenderWindow::CreateO
   this->MemoryDataHeader.bmiHeader.biSizeImage = dataWidth*ysize;
   this->MemoryDataHeader.bmiHeader.biXPelsPerMeter = 10000;
   this->MemoryDataHeader.bmiHeader.biYPelsPerMeter = 10000;
-  
+
   HBITMAP dib = CreateDIBSection(aHdc,
                                  &this->MemoryDataHeader, DIB_RGB_COLORS,
                                  (void **)(&(this->MemoryData)),  NULL, 0);
@@ -1330,13 +1330,13 @@ void vtkWin32OpenGLRenderWindow::CreateO
   GetObject(hbmp, sizeof(BITMAP), &bm);
 
   this->MemoryBuffer = hbmp;
-  
+
   // Create a compatible device context
   this->MemoryHdc = (HDC)CreateCompatibleDC(aHdc);
-  
+
   // Put the bitmap into the device context
   SelectObject(this->MemoryHdc, this->MemoryBuffer);
-  
+
   // Renderers will need to redraw anything cached in display lists
   this->CleanUpRenderers();
 
@@ -1344,15 +1344,15 @@ void vtkWin32OpenGLRenderWindow::CreateO
   this->Mapped =0;
   this->Size[0] = bm.bmWidth;
   this->Size[1] = bm.bmHeight;
-  
+
   this->DeviceContext = this->MemoryHdc;
   this->DoubleBuffer = 0;
-  this->SetupPixelFormat(this->DeviceContext, 
-                         PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI | 
+  this->SetupPixelFormat(this->DeviceContext,
+                         PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI |
                          PFD_DRAW_TO_BITMAP, this->GetDebug(), 24, 32);
   this->SetupPalette(this->DeviceContext);
   this->ContextId = wglCreateContext(this->DeviceContext);
-  if (this->ContextId == NULL) 
+  if (this->ContextId == NULL)
     {
     vtkErrorMacro("wglCreateContext failed in CreateOffScreenDC(), error: " << GetLastError());
     }
@@ -1391,7 +1391,7 @@ void vtkWin32OpenGLRenderWindow::SetupMe
   this->ScreenContextId = this->ContextId;
 
   this->CreateOffScreenDC(hbmp, dc);
-  DeleteDC(dc); 
+  DeleteDC(dc);
 }
 
 HDC vtkWin32OpenGLRenderWindow::GetMemoryDC()
@@ -1411,15 +1411,15 @@ void vtkWin32OpenGLRenderWindow::CleanUp
       {
       return;
       }
-      
+
     GdiFlush();
-      
+
     // we need to release resources
     this->CleanUpRenderers();
     DeleteDC(this->MemoryHdc);
     this->MemoryHdc = (HDC)0;
     DeleteObject(this->MemoryBuffer);
-    if (wglDeleteContext(this->ContextId) != TRUE) 
+    if (wglDeleteContext(this->ContextId) != TRUE)
       {
       vtkErrorMacro("wglDeleteContext failed in CleanUpOffScreenRendering(), error: " << GetLastError());
       }
@@ -1429,7 +1429,7 @@ void vtkWin32OpenGLRenderWindow::CleanUp
 
 void vtkWin32OpenGLRenderWindow::ResumeScreenRendering(void)
 {
-  // release OpenGL graphics resources before switch back to on-screen. 
+  // release OpenGL graphics resources before switch back to on-screen.
   if(this->ContextId!=0)
     {
       this->MakeCurrent();
@@ -1467,10 +1467,10 @@ void vtkWin32OpenGLRenderWindow::ShowCur
   this->CursorHidden = 0;
 
   ::ShowCursor(!this->CursorHidden);
-}                                  
+}
 
 //----------------------------------------------------------------------------
-void vtkWin32OpenGLRenderWindow::SetCursorPosition(int x, int y) 
+void vtkWin32OpenGLRenderWindow::SetCursorPosition(int x, int y)
 {
   int *size = this->GetSize();
 
@@ -1517,7 +1517,7 @@ void vtkWin32OpenGLRenderWindow::SetCurr
       cursorName = IDC_SIZEALL;
       break;
     case VTK_CURSOR_HAND:
-#if(WINVER >= 0x0500)      
+#if(WINVER >= 0x0500)
       cursorName = IDC_HAND;
 #else
       cursorName = IDC_ARROW;
@@ -1527,10 +1527,10 @@ void vtkWin32OpenGLRenderWindow::SetCurr
       cursorName = IDC_CROSS;
       break;
     }
-  
+
   if (cursorName)
     {
-    HANDLE cursor = 
+    HANDLE cursor =
       LoadImage(0,cursorName,IMAGE_CURSOR,0,0,LR_SHARED | LR_DEFAULTSIZE);
     SetCursor((HCURSOR)cursor);
     }
--- vtk-5.8.0.orig/Rendering/vtkWin32RenderWindowInteractor.cxx
+++ vtk-5.8.0/Rendering/vtkWin32RenderWindowInteractor.cxx
@@ -17,7 +17,10 @@
 #include <string.h>
 #include <math.h>
 
+
+#ifndef _WIN32_WINNT
 #define _WIN32_WINNT 0x0400  // for trackmouseevent support  requires Win95 with IE 3.0 or greater.
+#endif
 
 #include "vtkWin32OpenGLRenderWindow.h"
 
@@ -31,7 +34,7 @@
 #  define GET_WHEEL_DELTA_WPARAM(wparam) ((short)HIWORD (wparam))
 #endif  //GET_WHEEL_DELTA_WPARAM
 
-// MSVC does the right thing without the forward declaration when it 
+// MSVC does the right thing without the forward declaration when it
 // sees it in the friend decl in vtkWin32RenderWindowInteractor, but
 // GCC needs to see the declaration beforehand. It has to do with the
 // CALLBACK attribute.
@@ -60,42 +63,42 @@ void (*vtkWin32RenderWindowInteractor::C
 
 //----------------------------------------------------------------------------
 // Construct object so that light follows camera motion.
-vtkWin32RenderWindowInteractor::vtkWin32RenderWindowInteractor() 
+vtkWin32RenderWindowInteractor::vtkWin32RenderWindowInteractor()
 {
   this->WindowId           = 0;
   this->InstallMessageProc = 1;
   this->MouseInWindow = 0;
   this->StartedMessageLoop = 0;
-  
+
 #ifdef VTK_USE_TDX
   this->Device=vtkTDxWinDevice::New();
 #endif
 }
 
 //----------------------------------------------------------------------------
-vtkWin32RenderWindowInteractor::~vtkWin32RenderWindowInteractor() 
+vtkWin32RenderWindowInteractor::~vtkWin32RenderWindowInteractor()
 {
   vtkWin32OpenGLRenderWindow *tmp;
 
   // we need to release any hold we have on a windows event loop
-  if (this->WindowId && this->Enabled && this->InstallMessageProc) 
+  if (this->WindowId && this->Enabled && this->InstallMessageProc)
     {
     vtkWin32OpenGLRenderWindow *ren;
     ren = static_cast<vtkWin32OpenGLRenderWindow *>(this->RenderWindow);
     tmp = (vtkWin32OpenGLRenderWindow *)(vtkGetWindowLong(this->WindowId,sizeof(vtkLONG)));
     // watch for odd conditions
-    if ((tmp != ren) && (ren != NULL)) 
+    if ((tmp != ren) && (ren != NULL))
       {
       // OK someone else has a hold on our event handler
       // so lets have them handle this stuff
       // well send a USER message to the other
       // event handler so that it can properly
       // call this event handler if required
-      CallWindowProc(this->OldProc,this->WindowId,WM_USER+14,28,(LONG)this->OldProc);
+      CallWindowProc(this->OldProc,this->WindowId,WM_USER+14,28,(intptr_t)this->OldProc);
       }
-    else 
+    else
       {
-      vtkSetWindowLong(this->WindowId,vtkGWL_WNDPROC,(vtkLONG)this->OldProc);
+      vtkSetWindowLong(this->WindowId,vtkGWL_WNDPROC,(intptr_t)this->OldProc);
       }
     this->Enabled = 0;
     }
@@ -105,7 +108,7 @@ vtkWin32RenderWindowInteractor::~vtkWin3
 }
 
 //----------------------------------------------------------------------------
-void  vtkWin32RenderWindowInteractor::Start() 
+void  vtkWin32RenderWindowInteractor::Start()
 {
   // Let the compositing handle the event loop if it wants to.
   if (this->HasObserver(vtkCommand::StartEvent) && !this->HandleEventLoop)
@@ -132,18 +135,18 @@ void  vtkWin32RenderWindowInteractor::St
 
 //----------------------------------------------------------------------------
 // Begin processing keyboard strokes.
-void vtkWin32RenderWindowInteractor::Initialize() 
+void vtkWin32RenderWindowInteractor::Initialize()
 {
   vtkWin32OpenGLRenderWindow *ren;
   int *size;
 
   // make sure we have a RenderWindow and camera
-  if ( ! this->RenderWindow) 
+  if ( ! this->RenderWindow)
     {
     vtkErrorMacro(<<"No renderer defined!");
     return;
     }
-  if (this->Initialized) 
+  if (this->Initialized)
     {
     return;
     }
@@ -160,35 +163,35 @@ void vtkWin32RenderWindowInteractor::Ini
 }
 
 //----------------------------------------------------------------------------
-void vtkWin32RenderWindowInteractor::Enable() 
+void vtkWin32RenderWindowInteractor::Enable()
 {
   vtkWin32OpenGLRenderWindow *ren;
   vtkWin32OpenGLRenderWindow *tmp;
-  if (this->Enabled) 
+  if (this->Enabled)
     {
     return;
     }
-  if (this->InstallMessageProc) 
+  if (this->InstallMessageProc)
     {
     // add our callback
     ren = (vtkWin32OpenGLRenderWindow *)(this->RenderWindow);
     this->OldProc = (WNDPROC)vtkGetWindowLong(this->WindowId,vtkGWL_WNDPROC);
     tmp=(vtkWin32OpenGLRenderWindow *)vtkGetWindowLong(this->WindowId,sizeof(vtkLONG));
     // watch for odd conditions
-    if (tmp != ren) 
+    if (tmp != ren)
       {
       // OK someone else has a hold on our event handler
       // so lets have them handle this stuff
       // well send a USER message to the other
       // event handler so that it can properly
       // call this event handler if required
-      CallWindowProc(this->OldProc,this->WindowId,WM_USER+12,24,(LONG)vtkHandleMessage);
+      CallWindowProc(this->OldProc,this->WindowId,WM_USER+12,24,(intptr_t)vtkHandleMessage);
       }
-    else 
+    else
       {
-      vtkSetWindowLong(this->WindowId,vtkGWL_WNDPROC,(vtkLONG)vtkHandleMessage);
+      vtkSetWindowLong(this->WindowId,vtkGWL_WNDPROC,(intptr_t)vtkHandleMessage);
       }
-    
+
 #ifdef VTK_USE_TDX
     if(this->UseTDx)
       {
@@ -197,7 +200,7 @@ void vtkWin32RenderWindowInteractor::Ena
       this->Device->StartListening();
       }
 #endif
-    
+
     // in case the size of the window has changed while we were away
     int *size;
     size = ren->GetSize();
@@ -210,33 +213,33 @@ void vtkWin32RenderWindowInteractor::Ena
 
 
 //----------------------------------------------------------------------------
-void vtkWin32RenderWindowInteractor::Disable() 
+void vtkWin32RenderWindowInteractor::Disable()
 {
   vtkWin32OpenGLRenderWindow *tmp;
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
-  
-  if (this->InstallMessageProc && this->Enabled && this->WindowId) 
+
+  if (this->InstallMessageProc && this->Enabled && this->WindowId)
     {
     // we need to release any hold we have on a windows event loop
     vtkWin32OpenGLRenderWindow *ren;
     ren = (vtkWin32OpenGLRenderWindow *)(this->RenderWindow);
     tmp = (vtkWin32OpenGLRenderWindow *)vtkGetWindowLong(this->WindowId,sizeof(vtkLONG));
     // watch for odd conditions
-    if ((tmp != ren) && (ren != NULL)) 
+    if ((tmp != ren) && (ren != NULL))
       {
       // OK someone else has a hold on our event handler
       // so lets have them handle this stuff
       // well send a USER message to the other
       // event handler so that it can properly
       // call this event handler if required
-      CallWindowProc(this->OldProc,this->WindowId,WM_USER+14,28,(LONG)this->OldProc);
+      CallWindowProc(this->OldProc,this->WindowId,WM_USER+14,28,(intptr_t)this->OldProc);
       }
-    else 
+    else
       {
-      vtkSetWindowLong(this->WindowId,vtkGWL_WNDPROC,(vtkLONG)this->OldProc);
+      vtkSetWindowLong(this->WindowId,vtkGWL_WNDPROC,(intptr_t)this->OldProc);
       }
 #ifdef VTK_USE_TDX
     if(this->Device->GetInitialized())
@@ -270,7 +273,7 @@ int vtkWin32RenderWindowInteractor::Inte
 }
 
 //----------------------------------------------------------------------------
-int vtkWin32RenderWindowInteractor::InternalDestroyTimer(int platformTimerId) 
+int vtkWin32RenderWindowInteractor::InternalDestroyTimer(int platformTimerId)
 {
   return KillTimer(this->WindowId,platformTimerId);
 }
@@ -282,42 +285,42 @@ int vtkWin32RenderWindowInteractor::Inte
 // this ascii code to keysym table is meant to mimic Tk
 
 static const char *AsciiToKeySymTable[] = {
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-  "space", "exclam", "quotedbl", "numbersign", 
-  "dollar", "percent", "ampersand", "quoteright", 
-  "parenleft", "parenright", "asterisk", "plus", 
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  "space", "exclam", "quotedbl", "numbersign",
+  "dollar", "percent", "ampersand", "quoteright",
+  "parenleft", "parenright", "asterisk", "plus",
   "comma", "minus", "period", "slash",
-  "0", "1", "2", "3", "4", "5", "6", "7", 
+  "0", "1", "2", "3", "4", "5", "6", "7",
   "8", "9", "colon", "semicolon", "less", "equal", "greater", "question",
-  "at", "A", "B", "C", "D", "E", "F", "G", 
+  "at", "A", "B", "C", "D", "E", "F", "G",
   "H", "I", "J", "K", "L", "M", "N", "O",
   "P", "Q", "R", "S", "T", "U", "V", "W",
-  "X", "Y", "Z", "bracketleft", 
+  "X", "Y", "Z", "bracketleft",
   "backslash", "bracketright", "asciicircum", "underscore",
   "quoteleft", "a", "b", "c", "d", "e", "f", "g",
   "h", "i", "j", "k", "l", "m", "n", "o",
   "p", "q", "r", "s", "t", "u", "v", "w",
   "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "Delete",
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-  
+
 // this virtual key code to keysym table is meant to mimic Tk
 
 static const char *VKeyCodeToKeySymTable[] = {
   0, 0, 0, "Cancel", 0, 0, 0, 0,
   "BackSpace", "Tab", 0, 0, "Clear", "Return", 0, 0,
-  "Shift_L", "Control_L", "Alt_L", "Pause", "Caps_Lock", 0,0,0, 
+  "Shift_L", "Control_L", "Alt_L", "Pause", "Caps_Lock", 0,0,0,
   0, 0, 0, "Escape", 0, 0, 0, 0,
   "space", "Prior", "Next", "End", "Home", "Left", "Up", "Right",
   "Down", "Select", 0, "Execute", "Snapshot", "Insert", "Delete", "Help",
-  "0", "1", "2", "3", "4", "5", "6", "7", 
+  "0", "1", "2", "3", "4", "5", "6", "7",
   "8", "9", 0, 0, 0, 0, 0, 0,
   0, "a", "b", "c", "d", "e", "f", "g",
   "h", "i", "j", "k", "l", "m", "n", "o",
@@ -326,7 +329,7 @@ static const char *VKeyCodeToKeySymTable
   "KP_0", "KP_1", "KP_2", "KP_3", "KP_4", "KP_5", "KP_6", "KP_7",
   "KP_8", "KP_9", "asterisk", "plus", "bar", "minus", "period", "slash",
   "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8",
-  "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", 
+  "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16",
   "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24",
   0, 0, 0, 0, 0, 0, 0, 0,
   "Num_Lock", "Scroll_Lock", 0, 0, 0, 0, 0, 0,
@@ -341,20 +344,20 @@ static const char *VKeyCodeToKeySymTable
 //-------------------------------------------------------------
 // Event loop handlers
 //-------------------------------------------------------------
-void vtkWin32RenderWindowInteractor::OnMouseMove(HWND hWnd, UINT nFlags, 
-                                                 int X, int Y) 
+void vtkWin32RenderWindowInteractor::OnMouseMove(HWND hWnd, UINT nFlags,
+                                                 int X, int Y)
 {
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
 
-  this->SetEventInformationFlipY(X, 
-                                 Y, 
-                                 nFlags & MK_CONTROL, 
+  this->SetEventInformationFlipY(X,
+                                 Y,
+                                 nFlags & MK_CONTROL,
                                  nFlags & MK_SHIFT);
   this->SetAltKey(GetKeyState(VK_MENU) & (~1));
-  if (!this->MouseInWindow && 
+  if (!this->MouseInWindow &&
       (X >= 0 && X < this->Size[0] && Y >= 0 && Y < this->Size[1]))
     {
     this->InvokeEvent(vtkCommand::EnterEvent, NULL);
@@ -366,15 +369,15 @@ void vtkWin32RenderWindowInteractor::OnM
     tme.hwndTrack = hWnd;
     TrackMouseEvent(&tme);
     }
- 
+
   this->InvokeEvent(vtkCommand::MouseMoveEvent, NULL);
 }
 
 //----------------------------------------------------------------------------
-void vtkWin32RenderWindowInteractor::OnNCMouseMove(HWND, UINT nFlags, 
-                                                   int X, int Y) 
+void vtkWin32RenderWindowInteractor::OnNCMouseMove(HWND, UINT nFlags,
+                                                   int X, int Y)
 {
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
@@ -382,9 +385,9 @@ void vtkWin32RenderWindowInteractor::OnN
   int *pos = this->RenderWindow->GetPosition();
   if (this->MouseInWindow)
     {
-    this->SetEventInformationFlipY(X - pos[0], 
+    this->SetEventInformationFlipY(X - pos[0],
                                    Y - pos[1],
-                                   nFlags & MK_CONTROL, 
+                                   nFlags & MK_CONTROL,
                                    nFlags & MK_SHIFT);
     this->SetAltKey(GetKeyState(VK_MENU) & (~1));
     this->InvokeEvent(vtkCommand::LeaveEvent, NULL);
@@ -393,50 +396,50 @@ void vtkWin32RenderWindowInteractor::OnN
 }
 
 //----------------------------------------------------------------------------
-void vtkWin32RenderWindowInteractor::OnMouseWheelForward(HWND,UINT nFlags, 
-                                                   int X, int Y) 
+void vtkWin32RenderWindowInteractor::OnMouseWheelForward(HWND,UINT nFlags,
+                                                   int X, int Y)
 {
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
-  this->SetEventInformationFlipY(X, 
-                                 Y, 
-                                 nFlags & MK_CONTROL, 
+  this->SetEventInformationFlipY(X,
+                                 Y,
+                                 nFlags & MK_CONTROL,
                                  nFlags & MK_SHIFT);
   this->SetAltKey(GetKeyState(VK_MENU) & (~1));
   this->InvokeEvent(vtkCommand::MouseWheelForwardEvent,NULL);
 }
 
 //----------------------------------------------------------------------------
-void vtkWin32RenderWindowInteractor::OnMouseWheelBackward(HWND,UINT nFlags, 
-                                                   int X, int Y) 
+void vtkWin32RenderWindowInteractor::OnMouseWheelBackward(HWND,UINT nFlags,
+                                                   int X, int Y)
 {
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
-  this->SetEventInformationFlipY(X, 
-                                 Y, 
-                                 nFlags & MK_CONTROL, 
+  this->SetEventInformationFlipY(X,
+                                 Y,
+                                 nFlags & MK_CONTROL,
                                  nFlags & MK_SHIFT);
   this->SetAltKey(GetKeyState(VK_MENU) & (~1));
   this->InvokeEvent(vtkCommand::MouseWheelBackwardEvent,NULL);
 }
 
 //----------------------------------------------------------------------------
-void vtkWin32RenderWindowInteractor::OnLButtonDown(HWND wnd,UINT nFlags, 
-                                                   int X, int Y, int repeat) 
+void vtkWin32RenderWindowInteractor::OnLButtonDown(HWND wnd,UINT nFlags,
+                                                   int X, int Y, int repeat)
 {
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
   SetFocus(wnd);
   SetCapture(wnd);
-  this->SetEventInformationFlipY(X, 
-                                 Y, 
-                                 nFlags & MK_CONTROL, 
+  this->SetEventInformationFlipY(X,
+                                 Y,
+                                 nFlags & MK_CONTROL,
                                  nFlags & MK_SHIFT,
                                  0, repeat);
   this->SetAltKey(GetKeyState(VK_MENU) & (~1));
@@ -444,16 +447,16 @@ void vtkWin32RenderWindowInteractor::OnL
 }
 
 //----------------------------------------------------------------------------
-void vtkWin32RenderWindowInteractor::OnLButtonUp(HWND,UINT nFlags, 
-                                                 int X, int Y) 
+void vtkWin32RenderWindowInteractor::OnLButtonUp(HWND,UINT nFlags,
+                                                 int X, int Y)
 {
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
-  this->SetEventInformationFlipY(X, 
-                                 Y, 
-                                 nFlags & MK_CONTROL, 
+  this->SetEventInformationFlipY(X,
+                                 Y,
+                                 nFlags & MK_CONTROL,
                                  nFlags & MK_SHIFT);
   this->SetAltKey(GetKeyState(VK_MENU) & (~1));
   this->InvokeEvent(vtkCommand::LeftButtonReleaseEvent,NULL);
@@ -461,18 +464,18 @@ void vtkWin32RenderWindowInteractor::OnL
 }
 
 //----------------------------------------------------------------------------
-void vtkWin32RenderWindowInteractor::OnMButtonDown(HWND wnd,UINT nFlags, 
-                                                   int X, int Y, int repeat) 
+void vtkWin32RenderWindowInteractor::OnMButtonDown(HWND wnd,UINT nFlags,
+                                                   int X, int Y, int repeat)
 {
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
   SetFocus(wnd);
   SetCapture(wnd);
-  this->SetEventInformationFlipY(X, 
-                                 Y, 
-                                 nFlags & MK_CONTROL, 
+  this->SetEventInformationFlipY(X,
+                                 Y,
+                                 nFlags & MK_CONTROL,
                                  nFlags & MK_SHIFT,
                                  0, repeat);
   this->SetAltKey(GetKeyState(VK_MENU) & (~1));
@@ -480,16 +483,16 @@ void vtkWin32RenderWindowInteractor::OnM
 }
 
 //----------------------------------------------------------------------------
-void vtkWin32RenderWindowInteractor::OnMButtonUp(HWND,UINT nFlags, 
-                                                 int X, int Y) 
+void vtkWin32RenderWindowInteractor::OnMButtonUp(HWND,UINT nFlags,
+                                                 int X, int Y)
 {
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
-  this->SetEventInformationFlipY(X, 
-                                 Y, 
-                                 nFlags & MK_CONTROL, 
+  this->SetEventInformationFlipY(X,
+                                 Y,
+                                 nFlags & MK_CONTROL,
                                  nFlags & MK_SHIFT);
   this->SetAltKey(GetKeyState(VK_MENU) & (~1));
   this->InvokeEvent(vtkCommand::MiddleButtonReleaseEvent,NULL);
@@ -497,18 +500,18 @@ void vtkWin32RenderWindowInteractor::OnM
 }
 
 //----------------------------------------------------------------------------
-void vtkWin32RenderWindowInteractor::OnRButtonDown(HWND wnd,UINT nFlags, 
-                                                   int X, int Y, int repeat) 
+void vtkWin32RenderWindowInteractor::OnRButtonDown(HWND wnd,UINT nFlags,
+                                                   int X, int Y, int repeat)
 {
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
   SetFocus(wnd);
   SetCapture(wnd);
-  this->SetEventInformationFlipY(X, 
-                                 Y, 
-                                 nFlags & MK_CONTROL, 
+  this->SetEventInformationFlipY(X,
+                                 Y,
+                                 nFlags & MK_CONTROL,
                                  nFlags & MK_SHIFT,
                                  0, repeat);
   this->SetAltKey(GetKeyState(VK_MENU) & (~1));
@@ -516,16 +519,16 @@ void vtkWin32RenderWindowInteractor::OnR
 }
 
 //----------------------------------------------------------------------------
-void vtkWin32RenderWindowInteractor::OnRButtonUp(HWND,UINT nFlags, 
-                                                 int X, int Y) 
+void vtkWin32RenderWindowInteractor::OnRButtonUp(HWND,UINT nFlags,
+                                                 int X, int Y)
 {
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
-  this->SetEventInformationFlipY(X, 
-                                 Y, 
-                                 nFlags & MK_CONTROL, 
+  this->SetEventInformationFlipY(X,
+                                 Y,
+                                 nFlags & MK_CONTROL,
                                  nFlags & MK_SHIFT);
   this->SetAltKey(GetKeyState(VK_MENU) & (~1));
   this->InvokeEvent(vtkCommand::RightButtonReleaseEvent,NULL);
@@ -542,15 +545,15 @@ void vtkWin32RenderWindowInteractor::OnS
 }
 
 //----------------------------------------------------------------------------
-void vtkWin32RenderWindowInteractor::OnTimer(HWND,UINT timerId) 
+void vtkWin32RenderWindowInteractor::OnTimer(HWND,UINT timerId)
 {
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
   int tid = static_cast<int>(timerId);
   this->InvokeEvent(vtkCommand::TimerEvent,(void*)&tid);
-  
+
   // Here we deal with one-shot versus repeating timers
   if ( this->IsOneShotTimer(tid) )
     {
@@ -578,7 +581,7 @@ void vtkWin32RenderWindowInteractor::OnK
       nChar = 0;
       }
 #endif
-  } 
+  }
   const char *keysym = AsciiToKeySymTable[(unsigned char)nChar];
   if (keysym == 0)
     {
@@ -588,10 +591,10 @@ void vtkWin32RenderWindowInteractor::OnK
     {
     keysym = "None";
     }
-  this->SetKeyEventInformation(ctrl, 
-                               shift, 
-                               nChar, 
-                               nRepCnt, 
+  this->SetKeyEventInformation(ctrl,
+                               shift,
+                               nChar,
+                               nRepCnt,
                                keysym);
   this->SetAltKey(alt);
   this->InvokeEvent(vtkCommand::KeyPressEvent, NULL);
@@ -627,10 +630,10 @@ void vtkWin32RenderWindowInteractor::OnK
     {
     keysym = "None";
     }
-  this->SetKeyEventInformation(ctrl, 
-                               shift, 
-                               nChar, 
-                               nRepCnt, 
+  this->SetKeyEventInformation(ctrl,
+                               shift,
+                               nChar,
+                               nRepCnt,
                                keysym);
   this->SetAltKey(alt);
   this->InvokeEvent(vtkCommand::KeyReleaseEvent, NULL);
@@ -645,11 +648,11 @@ void vtkWin32RenderWindowInteractor::OnC
     return;
     }
   int ctrl  = GetKeyState(VK_CONTROL) & (~1);
-  int shift = GetKeyState(VK_SHIFT) & (~1); 
+  int shift = GetKeyState(VK_SHIFT) & (~1);
   int alt = GetKeyState(VK_MENU) & (~1);
-  this->SetKeyEventInformation(ctrl, 
-                               shift, 
-                               nChar, 
+  this->SetKeyEventInformation(ctrl,
+                               shift,
+                               nChar,
                                nRepCnt);
   this->SetAltKey(alt);
   this->InvokeEvent(vtkCommand::CharEvent, NULL);
@@ -658,11 +661,11 @@ void vtkWin32RenderWindowInteractor::OnC
 //----------------------------------------------------------------------------
 void vtkWin32RenderWindowInteractor::OnFocus(HWND,UINT)
 {
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
-  
+
 #ifdef VTK_USE_TDX
   if(this->Device->GetInitialized() && !this->Device->GetIsListening())
     {
@@ -674,7 +677,7 @@ void vtkWin32RenderWindowInteractor::OnF
 //----------------------------------------------------------------------------
 void vtkWin32RenderWindowInteractor::OnKillFocus(HWND,UINT)
 {
-  if (!this->Enabled) 
+  if (!this->Enabled)
     {
     return;
     }
@@ -688,8 +691,8 @@ void vtkWin32RenderWindowInteractor::OnK
 
 //----------------------------------------------------------------------------
 // This is only called when InstallMessageProc is true
-LRESULT CALLBACK vtkHandleMessage(HWND hWnd,UINT uMsg, WPARAM wParam, 
-                                  LPARAM lParam) 
+LRESULT CALLBACK vtkHandleMessage(HWND hWnd,UINT uMsg, WPARAM wParam,
+                                  LPARAM lParam)
 {
   LRESULT res = 0;
   vtkWin32OpenGLRenderWindow *ren;
@@ -713,33 +716,33 @@ LRESULT CALLBACK vtkHandleMessage(HWND h
 }
 
 #ifndef MAKEPOINTS
-#define MAKEPOINTS(l)   (*((POINTS FAR *) & (l))) 
+#define MAKEPOINTS(l)   (*((POINTS FAR *) & (l)))
 #endif
 
 //----------------------------------------------------------------------------
-LRESULT CALLBACK vtkHandleMessage2(HWND hWnd,UINT uMsg, WPARAM wParam, 
-                                   LPARAM lParam, 
-                                   vtkWin32RenderWindowInteractor *me) 
+LRESULT CALLBACK vtkHandleMessage2(HWND hWnd,UINT uMsg, WPARAM wParam,
+                                   LPARAM lParam,
+                                   vtkWin32RenderWindowInteractor *me)
 {
-  if ((uMsg == WM_USER+13)&&(wParam == 26)) 
+  if ((uMsg == WM_USER+13)&&(wParam == 26))
     {
     // someone is telling us to set our OldProc
     me->OldProc = (WNDPROC)lParam;
     return 1;
     }
-  
-  switch (uMsg) 
+
+  switch (uMsg)
     {
     case WM_PAINT:
       me->Render();
       return CallWindowProc(me->OldProc,hWnd,uMsg,wParam,lParam);
       break;
-      
+
     case WM_SIZE:
       me->OnSize(hWnd,wParam,LOWORD(lParam),HIWORD(lParam));
       return CallWindowProc(me->OldProc,hWnd,uMsg,wParam,lParam);
       break;
-      
+
     case WM_LBUTTONDBLCLK:
       me->OnLButtonDown(hWnd,wParam,MAKEPOINTS(lParam).x,MAKEPOINTS(lParam).y, 1);
       break;
@@ -747,7 +750,7 @@ LRESULT CALLBACK vtkHandleMessage2(HWND
     case WM_LBUTTONDOWN:
       me->OnLButtonDown(hWnd,wParam,MAKEPOINTS(lParam).x,MAKEPOINTS(lParam).y, 0);
       break;
-      
+
     case WM_LBUTTONUP:
       me->OnLButtonUp(hWnd,wParam,MAKEPOINTS(lParam).x,MAKEPOINTS(lParam).y);
       break;
@@ -759,11 +762,11 @@ LRESULT CALLBACK vtkHandleMessage2(HWND
     case WM_MBUTTONDOWN:
       me->OnMButtonDown(hWnd,wParam,MAKEPOINTS(lParam).x,MAKEPOINTS(lParam).y, 0);
       break;
-      
+
     case WM_MBUTTONUP:
       me->OnMButtonUp(hWnd,wParam,MAKEPOINTS(lParam).x,MAKEPOINTS(lParam).y);
       break;
-      
+
     case WM_RBUTTONDBLCLK:
       me->OnRButtonDown(hWnd,wParam,MAKEPOINTS(lParam).x,MAKEPOINTS(lParam).y, 1);
       break;
@@ -771,7 +774,7 @@ LRESULT CALLBACK vtkHandleMessage2(HWND
     case WM_RBUTTONDOWN:
       me->OnRButtonDown(hWnd,wParam,MAKEPOINTS(lParam).x,MAKEPOINTS(lParam).y, 0);
       break;
-      
+
     case WM_RBUTTONUP:
       me->OnRButtonUp(hWnd,wParam,MAKEPOINTS(lParam).x,MAKEPOINTS(lParam).y);
       break;
@@ -811,7 +814,7 @@ LRESULT CALLBACK vtkHandleMessage2(HWND
     case WM_CHAR:
       me->OnChar(hWnd,wParam,LOWORD(lParam),HIWORD(lParam));
       break;
-      
+
     case WM_KEYDOWN:
     case WM_SYSKEYDOWN:
       me->OnKeyDown(hWnd,wParam,LOWORD(lParam),HIWORD(lParam));
@@ -823,7 +826,7 @@ LRESULT CALLBACK vtkHandleMessage2(HWND
       break;
 
     case WM_TIMER:
-      me->OnTimer(hWnd,wParam);    
+      me->OnTimer(hWnd,wParam);
       break;
 
     case WM_ACTIVATE:
@@ -836,25 +839,25 @@ LRESULT CALLBACK vtkHandleMessage2(HWND
         me->OnFocus(hWnd,wParam);
         }
       break;
-      
+
     case WM_SETFOCUS:
       // occurs when SetFocus() is called on the current window
       me->OnFocus(hWnd,wParam);
       break;
-      
+
     case WM_KILLFOCUS:
       // occurs when the focus was on the current window and SetFocus() is
-      // called on another window. 
+      // called on another window.
       me->OnKillFocus(hWnd,wParam);
       break;
-      
+
     default:
-      if (me) 
+      if (me)
         {
         return CallWindowProc(me->OldProc,hWnd,uMsg,wParam,lParam);
         }
     };
-  
+
   return 0;
 }
 
--- vtk-5.8.0.orig/Rendering/vtkFreeTypeUtilities.cxx
+++ vtk-5.8.0/Rendering/vtkFreeTypeUtilities.cxx
@@ -32,6 +32,7 @@
 #include "fonts/vtkEmbeddedFonts.h"
 
 #include <sys/stat.h>
+#include <stdint.h>
 
 // Print debug info
 
@@ -337,7 +338,7 @@ vtkFreeTypeUtilitiesFaceRequester(FTC_Fa
   // Map the ID to a text property
 
   vtkTextProperty *tprop = vtkTextProperty::New();
-  self->MapIdToTextProperty(reinterpret_cast<unsigned long>(face_id), tprop);
+  self->MapIdToTextProperty(reinterpret_cast<intptr_t>(face_id), tprop);
 
   // Fonts, organized by [Family][Bold][Italic]
 
--- vtk-5.8.0.orig/Rendering/vtkFreeTypeTools.cxx
+++ vtk-5.8.0/Rendering/vtkFreeTypeTools.cxx
@@ -31,6 +31,8 @@
 // The embedded fonts
 #include "fonts/vtkEmbeddedFonts.h"
 
+#include <stdint.h>
+
 // Print debug info
 #define VTK_FTFC_DEBUG 0
 #define VTK_FTFC_DEBUG_CD 0
@@ -222,7 +224,7 @@ vtkFreeTypeToolsFaceRequester(FTC_FaceID
   // Map the ID to a text property
   vtkSmartPointer<vtkTextProperty> tprop =
       vtkSmartPointer<vtkTextProperty>::New();
-  self->MapIdToTextProperty(reinterpret_cast<unsigned long>(face_id), tprop);
+  self->MapIdToTextProperty(reinterpret_cast<intptr_t>(face_id), tprop);
 
   // Fonts, organized by [Family][Bold][Italic]
   static EmbeddedFontStruct EmbeddedFonts[3][2][2] =
--- vtk-5.8.0.orig/Utilities/CMakeLists.txt
+++ vtk-5.8.0/Utilities/CMakeLists.txt
@@ -18,7 +18,7 @@ VTK_THIRD_PARTY_SUBDIR(LIBXML2 vtklibxml
 VTK_THIRD_PARTY_SUBDIR(DICOMParser DICOMParser)
 VTK_THIRD_PARTY_SUBDIR(MATERIALLIBRARY MaterialLibrary)
 VTK_THIRD_PARTY_SUBDIR(LIBPROJ4 vtklibproj4)
-VTK_THIRD_PARTY_SUBDIR(MRMPI mrmpi)
+#VTK_THIRD_PARTY_SUBDIR(MRMPI mrmpi)
 IF(VTK_USE_OGGTHEORA_ENCODER)
   VTK_THIRD_PARTY_SUBDIR(OGGTHEORA vtkoggtheora)
 ENDIF(VTK_USE_OGGTHEORA_ENCODER)
@@ -37,12 +37,12 @@ SET( verdict_INSTALL_BIN_DIR ${VTK_INSTA
 SET( verdict_INSTALL_LIB_DIR ${VTK_INSTALL_LIB_DIR_CM24})
 ADD_SUBDIRECTORY(verdict)
 
-ADD_SUBDIRECTORY(vtknetcdf)
+#ADD_SUBDIRECTORY(vtknetcdf)
 IF(VTK_USE_METAIO)
   ADD_SUBDIRECTORY(vtkmetaio)
   SET_PROPERTY(GLOBAL APPEND PROPERTY VTK_TARGETS vtkmetaio)
 ENDIF(VTK_USE_METAIO)
-ADD_SUBDIRECTORY(vtksqlite)
+#ADD_SUBDIRECTORY(vtksqlite)
 
 IF(VTK_HAS_EXODUS)
   ADD_SUBDIRECTORY(vtkexodus2)
--- vtk-5.8.0.orig/Utilities/vtk_netcdf.h
+++ vtk-5.8.0/Utilities/vtk_netcdf.h
@@ -16,6 +16,9 @@
 #define __vtk_netcdf_h
 
 /* Use the netcdf library configured for VTK.  */
-#include <vtknetcdf/netcdf.h>
+//#include <vtknetcdf/netcdf.h>
+
+/* Use Debian's netcdf */
+#include <netcdf.h>
 
 #endif
--- vtk-5.8.0.orig/Utilities/vtk_netcdfcpp.h
+++ vtk-5.8.0/Utilities/vtk_netcdfcpp.h
@@ -16,6 +16,9 @@
 #define __vtk_netcdfcpp_h
 
 /* Use the netcdf library configured for VTK.  */
-#include <vtknetcdf/netcdfcpp.h>
+//#include <vtknetcdf/netcdfcpp.h>
+
+#include <netcdfcpp.h>
+
 
 #endif
--- vtk-5.8.0.orig/Utilities/Cosmo/CMakeLists.txt
+++ vtk-5.8.0/Utilities/Cosmo/CMakeLists.txt
@@ -5,7 +5,7 @@ project(Cosmo)
 
 SET(Cosmo_LIBS)
 IF(VTK_USE_MPI)
-  INCLUDE_DIRECTORIES("${MPI_INCLUDE_PATH}")
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
   IF(MPI_EXTRA_LIBRARY)
     SET(Cosmo_LIBS ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY})
   ELSE(MPI_EXTRA_LIBRARY)
@@ -43,6 +43,13 @@ IF(VTK_LIBRARY_PROPERTIES)
   SET_TARGET_PROPERTIES(Cosmo PROPERTIES ${VTK_LIBRARY_PROPERTIES})
 ENDIF(VTK_LIBRARY_PROPERTIES)
 
+# Apply user-defined properties to the library targets.
+IF(VTK_LIBRARY_PROPERTIES)
+  SET_TARGET_PROPERTIES(Cosmo PROPERTIES
+    ${VTK_LIBRARY_PROPERTIES}
+    )
+ENDIF(VTK_LIBRARY_PROPERTIES)
+
 IF(NOT VTK_INSTALL_NO_LIBRARIES)
   INSTALL(TARGETS Cosmo
     EXPORT ${VTK_INSTALL_EXPORT_NAME}
--- vtk-5.8.0.orig/Utilities/DICOMParser/DICOMParser.cxx
+++ vtk-5.8.0/Utilities/DICOMParser/DICOMParser.cxx
@@ -41,6 +41,7 @@
 
 #include <string.h>
 #include <string>
+#include <cstring>
 
 // Define DEBUG_DICOM to get debug messages sent to dicom_stream::cerr
 // #define DEBUG_DICOM
--- vtk-5.8.0.orig/Utilities/Doxygen/doxyfile.in
+++ vtk-5.8.0/Utilities/Doxygen/doxyfile.in
@@ -22,6 +22,7 @@ PDF_HYPERLINKS       = YES
 
 HAVE_DOT             = @HAVE_DOT_YESNO@
 DOT_PATH             = "@DOT_PATH@"
+DOT_IMAGE_FORMAT     = svg
 CLASS_GRAPH          = YES
 COLLABORATION_GRAPH  = YES
 TEMPLATE_RELATIONS   = YES
--- vtk-5.8.0.orig/Utilities/LastConfigureStep/CMakeLists.txt
+++ vtk-5.8.0/Utilities/LastConfigureStep/CMakeLists.txt
@@ -11,7 +11,7 @@
 #-----------------------------------------------------------------------------
 GET_PROPERTY(VTK_TARGETS GLOBAL PROPERTY VTK_TARGETS)
 EXPORT(TARGETS ${VTK_TARGETS} FILE ${VTK_BINARY_DIR}/${VTK_INSTALL_EXPORT_NAME}.cmake)
-INSTALL(EXPORT ${VTK_INSTALL_EXPORT_NAME} DESTINATION ${VTK_INSTALL_LIB_DIR_CM24})
+INSTALL(EXPORT ${VTK_INSTALL_EXPORT_NAME} DESTINATION ${VTK_INSTALL_PACKAGE_DIR_CM24})
 GET_PROPERTY(VTK_LIBRARIES GLOBAL PROPERTY VTK_LIBRARIES)
 #-----------------------------------------------------------------------------
 # Create the VTKConfig.cmake file containing the VTK configuration.
--- vtk-5.8.0.orig/Utilities/VPIC/CMakeLists.txt
+++ vtk-5.8.0/Utilities/VPIC/CMakeLists.txt
@@ -17,7 +17,7 @@ SET(VPIC_SOURCES
 )
 
 IF(VTK_USE_MPI)
-  INCLUDE_DIRECTORIES("${MPI_INCLUDE_PATH}")
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
   ADD_DEFINITIONS("-DUSE_PARALLEL_VPIC -DMPICH_IGNORE_CXX_SEEK")
 ENDIF(VTK_USE_MPI)
 
@@ -25,6 +25,14 @@ INCLUDE_DIRECTORIES (${VPIC_SOURCE_DIR}
 
 VTK_ADD_LIBRARY(VPIC ${VPIC_SOURCES})
 TARGET_LINK_LIBRARIES(VPIC vtksys )
+
+# Apply user-defined properties to the library targets.
+IF(VTK_LIBRARY_PROPERTIES)
+  SET_TARGET_PROPERTIES(VPIC PROPERTIES
+    ${VTK_LIBRARY_PROPERTIES}
+    )
+ENDIF(VTK_LIBRARY_PROPERTIES)
+
 IF(VTK_USE_MPI)
 TARGET_LINK_LIBRARIES(VPIC ${MPI_LIBRARY})
   IF(MPI_EXTRA_LIBRARY)
--- vtk-5.8.0.orig/Utilities/ftgl/CMakeLists.txt
+++ vtk-5.8.0/Utilities/ftgl/CMakeLists.txt
@@ -1,5 +1,7 @@
 PROJECT (VTKFTGL)
 
+INCLUDE(TestCXXAcceptsFlag)
+
 #
 # Dependency mask
 #
@@ -165,6 +167,39 @@ IF(NOT VTK_INSTALL_NO_LIBRARIES)
 ENDIF(NOT VTK_INSTALL_NO_LIBRARIES)
 
 #
+# To avoid name clashes (and the resulting crashes) between our FTGL and the
+# system FTGL, we configure the linker to add a prefix to all symbols.
+#
+
+if (CMAKE_COMPILER_IS_GNUCXX)
+
+  GET_TARGET_PROPERTY(VTKFTGL_LINK_FLAGS vtkftgl LINK_FLAGS)
+  IF(VTKFTGL_LINK_FLAGS)
+    SET(VTKFTGL_LINK_FLAGS "${VTKFTGL_LINK_FLAGS} ")
+  ELSE(VTKFTGL_LINK_FLAGS)
+    SET(VTKFTGL_LINK_FLAGS)
+  ENDIF(VTKFTGL_LINK_FLAGS)
+
+
+  set(_version_script_content "libvtkftgl { *; };")
+  set(_version_script "${CMAKE_CURRENT_BINARY_DIR}/version.script")
+  file(WRITE ${_version_script} "${_version_script_content}\n")
+
+  # Check if the linker supports version script (i.e. is GNU ld)
+  check_cxx_accepts_flag("-Wl,--version-script,${_version_script}"
+    LD_ACCEPTS_VERSION_SCRIPT)
+  if (LD_ACCEPTS_VERSION_SCRIPT)
+    set(_link_flags "-Wl,--version-script,'${_version_script}'")
+  endif (LD_ACCEPTS_VERSION_SCRIPT)
+
+  if (_link_flags)
+    SET_TARGET_PROPERTIES(vtkftgl PROPERTIES
+      LINK_FLAGS "${VTKFTGL_LINK_FLAGS}${_link_flags}")
+  endif (_link_flags)
+endif (CMAKE_COMPILER_IS_GNUCXX)
+
+
+#
 # Do not cover this lib
 #
 CONFIGURE_FILE (${VTKFTGL_SOURCE_DIR}/.NoDartCoverage
--- vtk-5.8.0.orig/Utilities/mrmpi/src/CMakeLists.txt
+++ vtk-5.8.0/Utilities/mrmpi/src/CMakeLists.txt
@@ -7,6 +7,9 @@ SET (mrmpi_SOURCES
         memory.cpp
         error.cpp)
 
+      INCLUDE_DIRECTORIES(
+        ${MPI_INCLUDE_PATH}
+        )
 VTK_ADD_LIBRARY (MapReduceMPI ${mrmpi_SOURCES})
 TARGET_LINK_LIBRARIES (MapReduceMPI ${mrmpi_LIBS})
 IF(VTK_LIBRARY_PROPERTIES)
--- vtk-5.8.0.orig/Utilities/vtkexodus2/CMakeLists.txt
+++ vtk-5.8.0/Utilities/vtkexodus2/CMakeLists.txt
@@ -213,7 +213,7 @@ ENDIF(APPLE)
 
 
 VTK_ADD_LIBRARY(vtkexoIIc ${cbind_SRCS})
-TARGET_LINK_LIBRARIES(vtkexoIIc vtkNetCDF)
+TARGET_LINK_LIBRARIES(vtkexoIIc netcdf)
 
 # Apply user-defined properties to the library target.
 IF(VTK_LIBRARY_PROPERTIES)
--- vtk-5.8.0.orig/Utilities/vtkexodus2/test/CMakeLists.txt
+++ vtk-5.8.0/Utilities/vtkexodus2/test/CMakeLists.txt
@@ -21,7 +21,7 @@ CREATE_TEST_SOURCELIST( ExoIICTests
   )
 
 ADD_EXECUTABLE( ExoIICTests ${ExoIICTests} )
-TARGET_LINK_LIBRARIES( ExoIICTests vtkCommon vtkexoIIc vtkNetCDF )
+TARGET_LINK_LIBRARIES( ExoIICTests vtkCommon vtkexoIIc netcdf )
 
 SET( TestsToRun ${ExoIICTests} )
 REMOVE( TestsToRun ExoIICTests.cxx )
--- vtk-5.8.0.orig/Utilities/vtkhdf5/ConfigureChecks.cmake
+++ vtk-5.8.0/Utilities/vtkhdf5/ConfigureChecks.cmake
@@ -75,14 +75,14 @@ IF (HDF5_WANT_DCONV_EXCEPTION)
 ENDIF (HDF5_WANT_DCONV_EXCEPTION)
 
 SET (LINUX_LFS 0)
-IF (CMAKE_SYSTEM MATCHES "Linux-([3-9]\\.[0-9]|2\\.[4-9])\\.")
+IF (CMAKE_SYSTEM MATCHES "Linux")
   # Linux Specific flags
   ADD_DEFINITIONS (-D_POSIX_SOURCE -D_BSD_SOURCE)
   OPTION (HDF5_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux." ON)
   IF (HDF5_ENABLE_LARGE_FILE)
     SET (LARGEFILE 1)
   ENDIF (HDF5_ENABLE_LARGE_FILE)
-ENDIF (CMAKE_SYSTEM MATCHES "Linux-([3-9]\\.[0-9]|2\\.[4-9])\\.")
+ENDIF (CMAKE_SYSTEM MATCHES "Linux")
 SET (HDF5_EXTRA_FLAGS)
 IF (LINUX_LFS)
   SET (HDF5_EXTRA_FLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE)
--- vtk-5.8.0.orig/VolumeRendering/vtkOpenGLGPUVolumeRayCastMapper.cxx
+++ vtk-5.8.0/VolumeRendering/vtkOpenGLGPUVolumeRayCastMapper.cxx
@@ -2076,7 +2076,7 @@ int vtkOpenGLGPUVolumeRayCastMapper::IsR
     }
   if(!this->LoadExtensionsSucceeded)
     {
-    vtkDebugMacro(
+    vtkErrorMacro(
       "The following OpenGL extensions are required but not supported: "
       << (this->UnsupportedRequiredExtensions->Stream.str()).c_str());
     return 0;
@@ -2169,6 +2169,8 @@ void vtkOpenGLGPUVolumeRayCastMapper::Lo
     // "framebuffer has bad draw buffer"
     // "render clipped 1 ERROR (x506) invalid framebuffer operation ext"
     this->LoadExtensionsSucceeded=0;
+    this->UnsupportedRequiredExtensions->Stream<<
+      " Intel cards and Mesa implementations are not supported";
     return;
     }
 
--- vtk-5.8.0.orig/Wrapping/Java/CMakeLists.txt
+++ vtk-5.8.0/Wrapping/Java/CMakeLists.txt
@@ -130,7 +130,7 @@ IF(JAVA_COMPILE)
       DEPENDS ${VTK_BUILD_ALL_DEPENDS}
       SOURCE ${VTK_BINARY_DIR}/java/vtk/vtkBuildAllDriver.java
       COMMAND ${JAVA_COMPILE}
-      ARGS -classpath ${VTK_JAVA_HOME}/.. -d ${VTK_JAVA_HOME}/.. 
+      ARGS -source 1.6 -classpath ${VTK_JAVA_HOME}/.. -d ${VTK_JAVA_HOME}/.. 
       ${VTK_BINARY_DIR}/java/vtk/vtkBuildAllDriver.java
       )
 
@@ -216,7 +216,7 @@ IF(JAVA_COMPILE)
         OUTPUTS ${class}
         DEPENDS ${VTK_JAVA_HOME}/vtkPanel.java
         COMMAND ${JAVA_COMPILE}
-        ARGS -classpath ${VTK_JAVA_HOME}/.. -d ${VTK_JAVA_HOME}/.. ${dst}
+        ARGS -source 1.6 -classpath ${VTK_JAVA_HOME}/.. -d ${VTK_JAVA_HOME}/.. ${dst}
         )
 
       SET(CLASS_FILES ${CLASS_FILES} ${class})
@@ -235,7 +235,7 @@ IF(JAVA_COMPILE)
         OUTPUTS ${class}
         DEPENDS ${VTK_JAVA_HOME}/vtkPanel.class
         COMMAND ${JAVA_COMPILE}
-        ARGS -classpath ${VTK_JAVA_HOME}/.. -d ${VTK_JAVA_HOME}/.. ${dst}
+        ARGS -source 1.6 -classpath ${VTK_JAVA_HOME}/.. -d ${VTK_JAVA_HOME}/.. ${dst}
         )
 
       SET(CLASS_FILES ${CLASS_FILES} ${class})
@@ -272,7 +272,7 @@ IF(JAVA_COMPILE)
         ADD_CUSTOM_COMMAND(
           SOURCE ${VTK_SOURCE_DIR}/Wrapping/Java/vtk/test/${jfile}.java
           COMMAND ${JAVA_COMPILE}
-          ARGS -classpath ${VTK_JAR_PATH}/vtk.jar${SEPARATOR}${VTK_BINARY_DIR}/Wrapping/Java
+          ARGS -source 1.6 -classpath ${VTK_JAR_PATH}/vtk.jar${SEPARATOR}${VTK_BINARY_DIR}/Wrapping/Java
           -sourcepath ${VTK_SOURCE_DIR}/Wrapping/Java
           -d ${VTK_BINARY_DIR}/Wrapping/Java
           ${VTK_SOURCE_DIR}/Wrapping/Java/vtk/test/${jfile}.java
@@ -362,7 +362,7 @@ IF(JAVA_COMPILE)
           ADD_CUSTOM_COMMAND(
             SOURCE ${VTK_SOURCE_DIR}/Wrapping/Java/vtk/test/${jfile}.java
             COMMAND ${JAVA_COMPILE}
-            ARGS -classpath ${VTK_JAR_PATH}/vtk.jar${SEPARATOR}${VTK_BINARY_DIR}/Wrapping/Java
+            ARGS -source 1.6 -classpath ${VTK_JAR_PATH}/vtk.jar${SEPARATOR}${VTK_BINARY_DIR}/Wrapping/Java
             -sourcepath ${VTK_SOURCE_DIR}/Wrapping/Java
             -d ${VTK_BINARY_DIR}/Wrapping/Java
             ${VTK_SOURCE_DIR}/Wrapping/Java/vtk/test/${jfile}.java
--- vtk-5.8.0.orig/Wrapping/Java/vtk/vtkJavaMemoryManager.java
+++ vtk-5.8.0/Wrapping/Java/vtk/vtkJavaMemoryManager.java
@@ -18,14 +18,12 @@ public interface vtkJavaMemoryManager {
      * Create or return an existing instance of the vtkObject that corresponds
      * to the pointer id vtkId.
      *
-     * @param <T>
-     *            Type of the object that we want to return.
      * @param vtkId
      *            is used to uniquely identify a vtkObject inside the C++ layer.
      *
      * @return a java object that map its underlying C++ instance.
      */
-    <T extends vtkObjectBase> T getJavaObject(Long vtkId);
+    vtkObjectBase getJavaObject(Long vtkId);
 
     /**
      * Store the Java instance of a vtkObject inside a weak pointer map.
--- vtk-5.8.0.orig/Wrapping/Java/vtk/vtkJavaMemoryManagerImpl.java
+++ vtk-5.8.0/Wrapping/Java/vtk/vtkJavaMemoryManagerImpl.java
@@ -29,9 +29,8 @@ public class vtkJavaMemoryManagerImpl im
     }
 
     @SuppressWarnings("unchecked")
-    @Override
     // Thread safe
-    public <T extends vtkObjectBase> T getJavaObject(Long vtkId) {
+    public vtkObjectBase getJavaObject(Long vtkId) {
         // Check pre-condition
         if (vtkId == null || vtkId.longValue() == 0) {
             throw new RuntimeException("Invalid ID, can not be null or equal to 0.");
@@ -53,7 +52,7 @@ public class vtkJavaMemoryManagerImpl im
                 value = objectMap.get(vtkId);
                 resultObject = (value == null) ? null : value.get();
                 if (resultObject != null) {
-                    return (T) resultObject;
+                    return resultObject;
                 }
 
                 // We need to do the work of the gc
@@ -65,9 +64,9 @@ public class vtkJavaMemoryManagerImpl im
                 if (resultObject == null) {
                     try {
                         String className = vtkObjectBase.VTKGetClassNameFromReference(vtkId.longValue());
-                        Class<T> c = (Class<T>) Class.forName("vtk." + className);
-                        Constructor<T> cons = c.getConstructor(new Class[] { long.class });
-                        resultObject = cons.newInstance(new Object[] { vtkId });
+                        Class c = Class.forName("vtk." + className);
+                        Constructor cons = c.getConstructor(new Class[] { long.class });
+                        resultObject = (vtkObjectBase) cons.newInstance(new Object[] { vtkId });
                     } catch (Exception e) {
                         e.printStackTrace();
                     }
@@ -76,10 +75,9 @@ public class vtkJavaMemoryManagerImpl im
                 this.lock.unlock();
             }
         }
-        return (T) resultObject;
+        return resultObject;
     }
 
-    @Override
     // Thread safe
     public void registerJavaObject(Long id, vtkObjectBase obj) {
         try {
@@ -91,7 +89,6 @@ public class vtkJavaMemoryManagerImpl im
         }
     }
 
-    @Override
     // Thread safe
     public void unRegisterJavaObject(Long id) {
         try {
@@ -110,7 +107,6 @@ public class vtkJavaMemoryManagerImpl im
         }
     }
 
-    @Override
     // Thread safe
     public vtkReferenceInformation gc(boolean debug) {
         System.gc();
@@ -134,12 +130,10 @@ public class vtkJavaMemoryManagerImpl im
         }
     }
 
-    @Override
     public vtkJavaGarbageCollector getAutoGarbageCollector() {
         return this.garbageCollector;
     }
 
-    @Override
     // Thread safe
     public int deleteAll() {
         int size = this.objectMap.size();
@@ -154,12 +148,10 @@ public class vtkJavaMemoryManagerImpl im
         return size;
     }
 
-    @Override
     public int getSize() {
         return objectMap.size();
     }
 
-    @Override
     public vtkReferenceInformation getLastReferenceInformation() {
         return this.lastGcResult;
     }
--- vtk-5.8.0.orig/Wrapping/Python/CMakeLists.txt
+++ vtk-5.8.0/Wrapping/Python/CMakeLists.txt
@@ -295,7 +295,7 @@ ENDIF(VTK_USE_MATLAB_MEX)
 SET(PVTKPYTHON_EXECUTABLE)
 # Create the pvtkpython Python wrapper executable with MPI support.
 IF (VTK_USE_PARALLEL AND VTK_USE_MPI)
-  INCLUDE_DIRECTORIES("${MPI_INCLUDE_PATH}")
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
   IF (MPI_LIBRARY)
     SET(MPI_LIBRARIES ${MPI_LIBRARY})
   ENDIF (MPI_LIBRARY)
--- vtk-5.8.0.orig/Wrapping/Tcl/CMakeLists.txt
+++ vtk-5.8.0/Wrapping/Tcl/CMakeLists.txt
@@ -74,7 +74,7 @@ ENDIF(VTK_USE_CARBON)
 
 IF (VTK_USE_RENDERING)
   TARGET_LINK_LIBRARIES(vtk vtkRenderingTCL)
-  TARGET_LINK_LIBRARIES(vtk vtkVolumeRenderingTCL)
+  TARGET_LINK_LIBRARIES(vtk vtkVolumeRenderingTCL vtkVolumeRendering)
   TARGET_LINK_LIBRARIES(vtk vtkHybridTCL)
   TARGET_LINK_LIBRARIES(vtk vtkWidgetsTCL)
 ENDIF (VTK_USE_RENDERING)
@@ -84,7 +84,7 @@ IF (VTK_USE_PARALLEL)
 ENDIF (VTK_USE_PARALLEL)
 
 IF (VTK_USE_GEOVIS)
-  TARGET_LINK_LIBRARIES(vtk vtkGeovisTCL)
+  TARGET_LINK_LIBRARIES(vtk vtkGeovisTCL vtkGeovis)
 ENDIF (VTK_USE_GEOVIS)
 
 IF (VTK_USE_INFOVIS)
@@ -135,7 +135,7 @@ ENDIF(NOT VTK_INSTALL_NO_RUNTIME)
 # Create the pvtk Tcl wrapper executable with MPI support.
 IF (VTK_USE_PARALLEL)
   IF (VTK_USE_MPI)
-    INCLUDE_DIRECTORIES("${MPI_INCLUDE_PATH}")
+    INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
     IF (MPI_LIBRARY) 
       SET(MPI_LIBRARIES ${MPI_LIBRARY})   
     ENDIF (MPI_LIBRARY)   
@@ -164,16 +164,22 @@ IF (VTK_USE_PARALLEL)
       vtkIOTCL
       vtkParallelTCL
       ${MPI_LIBRARIES}
+      ${VTK_TCL_LIBRARIES}
     )
 
+    IF (VTK_USE_TK)
+       TARGET_LINK_LIBRARIES(pvtk ${VTK_TK_LIBRARIES})
+    ENDIF (VTK_USE_TK)
+
     IF (VTK_USE_RENDERING)
       TARGET_LINK_LIBRARIES(pvtk vtkHybridTCL)
       TARGET_LINK_LIBRARIES(pvtk vtkWidgetsTCL)
-      TARGET_LINK_LIBRARIES(pvtk vtkVolumeRenderingTCL)
+      TARGET_LINK_LIBRARIES(pvtk vtkRenderingTCL)
+      TARGET_LINK_LIBRARIES(pvtk vtkVolumeRenderingTCL vtkVolumeRendering)
     ENDIF (VTK_USE_RENDERING)
 
     IF (VTK_USE_GEOVIS)
-      TARGET_LINK_LIBRARIES(pvtk vtkGeovisTCL)
+      TARGET_LINK_LIBRARIES(pvtk vtkGeovisTCL vtkGeovis)
     ENDIF (VTK_USE_GEOVIS)
 
     IF (VTK_USE_INFOVIS)
--- vtk-5.8.0.orig/Wrapping/Tcl/pkgIndex.tcl.in
+++ vtk-5.8.0/Wrapping/Tcl/pkgIndex.tcl.in
@@ -5,6 +5,7 @@ package ifneeded vtkinit {@VTK_MAJOR_VER
     proc load_library_package {libName libPath {libPrefix {@VTK_TCL_LIBNAME_PREFIX@}}} {
       set libExt [info sharedlibextension]
       set currentDirectory [pwd]
+      set libPath /usr/@VTK_INSTALL_LIB_DIR@/
       set libFile [file join $libPath "$libPrefix$libName$libExt"]
       if {[catch "cd {$libPath}; load {$libFile}" errorMessage]} {
         puts $errorMessage
--- vtk-5.8.0.orig/Wrapping/Tcl/vtkTkAppInit.cxx
+++ vtk-5.8.0/Wrapping/Tcl/vtkTkAppInit.cxx
@@ -228,6 +228,8 @@ int Tcl_AppInit(Tcl_Interp *interp)
   // Help Tcl find the Tcl/Tk helper files.
   const char* relative_dirs[] =
     {
+      "../share/tcltk",
+      "../../share/tcltk",
       "TclTk/lib",
       ".." VTK_INSTALL_TCL_DIR,
       0
