diff --git a/Graphics/Rendering/OpenGL/GL.hs b/Graphics/Rendering/OpenGL/GL.hs
--- a/Graphics/Rendering/OpenGL/GL.hs
+++ b/Graphics/Rendering/OpenGL/GL.hs
@@ -15,7 +15,7 @@
 
 module Graphics.Rendering.OpenGL.GL (
    -- * OpenGL Operation
-   module Graphics.Rendering.OpenGL.GL.BasicTypes,
+   module Graphics.Rendering.OpenGL.Raw.Core31,
    module Graphics.Rendering.OpenGL.GL.BeginEnd,
    module Graphics.Rendering.OpenGL.GL.VertexSpec,
    module Graphics.Rendering.OpenGL.GL.VertexArrays,
@@ -52,12 +52,16 @@
    module Graphics.Rendering.OpenGL.GL.Hints,
 
    -- * State and State Requests
-   module Graphics.Rendering.OpenGL.GL.StateVar,
+   module Data.StateVar,
+   module Data.Tensor,
    module Graphics.Rendering.OpenGL.GL.StringQueries,
    module Graphics.Rendering.OpenGL.GL.SavingState
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes
+import Graphics.Rendering.OpenGL.Raw.Core31 (
+   GLbitfield,  GLboolean,  GLbyte,  GLchar,  GLclampd,  GLclampf,  GLdouble,
+   GLenum,  GLfloat,  GLhalf,  GLint,  GLintptr,  GLshort,  GLsizei,
+   GLsizeiptr,  GLubyte,  GLuint,  GLushort )
 import Graphics.Rendering.OpenGL.GL.BeginEnd
 import Graphics.Rendering.OpenGL.GL.VertexSpec
 import Graphics.Rendering.OpenGL.GL.VertexArrays
@@ -90,6 +94,7 @@
 import Graphics.Rendering.OpenGL.GL.FlushFinish
 import Graphics.Rendering.OpenGL.GL.Hints
 
-import Graphics.Rendering.OpenGL.GL.StateVar
+import Data.StateVar
+import Data.Tensor
 import Graphics.Rendering.OpenGL.GL.StringQueries
 import Graphics.Rendering.OpenGL.GL.SavingState
diff --git a/Graphics/Rendering/OpenGL/GL/Antialiasing.hs b/Graphics/Rendering/OpenGL/GL/Antialiasing.hs
--- a/Graphics/Rendering/OpenGL/GL/Antialiasing.hs
+++ b/Graphics/Rendering/OpenGL/GL/Antialiasing.hs
@@ -17,13 +17,10 @@
    sampleBuffers, samples, multisample, subpixelBits
 ) where
 
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapMultisample), makeCapability )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLsizei, Capability )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetSampleBuffers,GetSamples,GetSubpixelBits), getSizei1 )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, StateVar )
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/BasicTypes.hs b/Graphics/Rendering/OpenGL/GL/BasicTypes.hs
deleted file mode 100644
--- a/Graphics/Rendering/OpenGL/GL/BasicTypes.hs
+++ /dev/null
@@ -1,110 +0,0 @@
---------------------------------------------------------------------------------
--- |
--- Module      :  Graphics.Rendering.OpenGL.GL.BasicTypes
--- Copyright   :  (c) Sven Panne 2002-2009
--- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
--- 
--- Maintainer  :  sven.panne@aedion.de
--- Stability   :  stable
--- Portability :  portable
---
--- This module corresponds to section 2.3 (GL Command Sytax) of the OpenGL 2.1
--- specs.
---
---------------------------------------------------------------------------------
-
-module Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLbyte, GLubyte, GLchar, GLshort, GLushort, GLint, GLuint,
-   GLsizei, GLenum, GLintptr, GLsizeiptr, GLbitfield, GLfloat, GLclampf,
-   GLdouble, GLclampd, Capability(..)
-) where
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLConfig.h"
-
---------------------------------------------------------------------------------
-
-import Data.Int
-import Data.Word
-
--- If we don't find modern OpenGL headers at configuration time, make some
--- educated guesses here.
-
-#if !defined(HTYPE_GLCHAR) || !defined(HTYPE_GLINTPTR) || !defined(HTYPE_GLSIZEIPTR)
-import Foreign.C.Types
-#endif
-
-#if !defined(HTYPE_GLCHAR)
-#define HTYPE_GLCHAR CChar
-#endif
-
-#if !defined(HTYPE_GLINTPTR)
-#define HTYPE_GLINTPTR CPtrdiff
-#endif
-
-#if !defined(HTYPE_GLSIZEIPTR)
-#define HTYPE_GLSIZEIPTR CPtrdiff
-#endif
-
---------------------------------------------------------------------------------
-
--- | Boolean (min. 1 bit)
-type GLboolean = HTYPE_GLBOOLEAN
-
--- | Signed 2\'s complement binary integer (min. 8 bits)
-type GLbyte = HTYPE_GLBYTE
-
--- | Unsigned binary integer (min. 8 bits)
-type GLubyte = HTYPE_GLUBYTE
-
--- | Characters making up strings
-type GLchar = HTYPE_GLCHAR
-
--- | Signed 2\'s complement binary integer (min. 16 bits)
-type GLshort = HTYPE_GLSHORT
-
--- | Unsigned binary integer (min. 16 bits)
-type GLushort = HTYPE_GLUSHORT
-
--- | Signed 2\'s complement binary integer (min. 32 bits)
-type GLint = HTYPE_GLINT
-
--- | Unsigned binary integer (min. 32 bits)
-type GLuint = HTYPE_GLUINT
-
--- | Non-negatitve binary integer size (min. 32 bits)
-type GLsizei = HTYPE_GLSIZEI
-
--- | Enumerated binary integer value (min. 32 bits)
-type GLenum = HTYPE_GLENUM
-
--- | Signed 2\'s complement binary integer (sufficiently large enough to hold
--- any address)
-type GLintptr = HTYPE_GLINTPTR
-
--- | Non-negatitve binary integer size (sufficiently large enough to hold any
--- address)
-type GLsizeiptr = HTYPE_GLSIZEIPTR
-
--- | Bit field (min. 32 bits)
-type GLbitfield = HTYPE_GLBITFIELD
-
--- | Floating-point value (min. 32 bits)
-type GLfloat = HTYPE_GLFLOAT
-
--- | Floating-point value clamped to [0,1] (min. 32 bits)
-type GLclampf = HTYPE_GLCLAMPF
-
--- | Floating-point value (min. 64 bits)
-type GLdouble = HTYPE_GLDOUBLE
-
--- | Floating-point value clamped to [0,1] (min. 64 bits)
-type GLclampd = HTYPE_GLCLAMPD
-
---------------------------------------------------------------------------------
-
-data Capability =
-     Disabled
-   | Enabled
-   deriving ( Eq, Ord, Show )
diff --git a/Graphics/Rendering/OpenGL/GL/BeginEnd.hs b/Graphics/Rendering/OpenGL/GL/BeginEnd.hs
--- a/Graphics/Rendering/OpenGL/GL/BeginEnd.hs
+++ b/Graphics/Rendering/OpenGL/GL/BeginEnd.hs
@@ -23,21 +23,13 @@
    edgeFlag
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLboolean )
-import Graphics.Rendering.OpenGL.GL.EdgeFlag (
-   EdgeFlag(..), marshalEdgeFlag, unmarshalEdgeFlag )
-import Graphics.Rendering.OpenGL.GL.Exception ( bracket_, unsafeBracket_ )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.PrimitiveMode (
-   PrimitiveMode(..), marshalPrimitiveMode )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   getBoolean1, GetPName(GetEdgeFlag) )
-import Graphics.Rendering.OpenGL.GL.StateVar ( StateVar, makeStateVar )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GL.EdgeFlag
+import Graphics.Rendering.OpenGL.GL.Exception
+import Graphics.Rendering.OpenGL.GL.PrimitiveMode
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility ( glBegin, glEnd, glEdgeFlag )
+import Graphics.Rendering.OpenGL.Raw.NV.PrimitiveRestart
 
 --------------------------------------------------------------------------------
 
@@ -110,16 +102,10 @@
 renderPrim brack_ beginMode =
    brack_ (glBegin (marshalPrimitiveMode beginMode)) glEnd
 
-foreign import CALLCONV unsafe "glBegin" glBegin :: GLenum -> IO ()
-
-foreign import CALLCONV unsafe "glEnd" glEnd :: IO ()
-
 --------------------------------------------------------------------------------
 
 primitiveRestart :: IO ()
-primitiveRestart = glPrimitiveRestartNV
-
-EXTENSION_ENTRY("GL_NV_primitive_restart",glPrimitiveRestartNV,IO ())
+primitiveRestart = glPrimitiveRestart
 
 --------------------------------------------------------------------------------
 
@@ -142,5 +128,3 @@
 edgeFlag =
    makeStateVar (getBoolean1 unmarshalEdgeFlag GetEdgeFlag)
                 (glEdgeFlag . marshalEdgeFlag)
-
-foreign import CALLCONV unsafe "glEdgeFlag" glEdgeFlag :: GLboolean -> IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/Bitmaps.hs b/Graphics/Rendering/OpenGL/GL/Bitmaps.hs
--- a/Graphics/Rendering/OpenGL/GL/Bitmaps.hs
+++ b/Graphics/Rendering/OpenGL/GL/Bitmaps.hs
@@ -16,17 +16,14 @@
    bitmap
 ) where
 
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLsizei, GLfloat )
-import Graphics.Rendering.OpenGL.GL.CoordTrans ( Size(..), Vector2(..) )
-import Graphics.Rendering.OpenGL.GL.VertexSpec ( Vertex2(..) )
+import Data.Tensor
+import Foreign.Ptr
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility ( glBitmap )
+import Graphics.Rendering.OpenGL.GL.CoordTrans
 
 --------------------------------------------------------------------------------
 
-bitmap :: Size -> (Vertex2 GLfloat) -> (Vector2 GLfloat) -> Ptr a -> IO ()
+bitmap :: Size -> (Vertex2 GLfloat) -> (Vector2 GLfloat) -> Ptr GLubyte -> IO ()
 bitmap (Size w h) (Vertex2 xbo ybo) (Vector2 xbi ybi) =
    glBitmap w h xbo ybo xbi ybi
-
-foreign import CALLCONV unsafe "glBitmap"
-   glBitmap :: GLsizei -> GLsizei -> GLfloat -> GLfloat -> GLfloat -> GLfloat
-            -> Ptr a -> IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/BlendingFactor.hs b/Graphics/Rendering/OpenGL/GL/BlendingFactor.hs
--- a/Graphics/Rendering/OpenGL/GL/BlendingFactor.hs
+++ b/Graphics/Rendering/OpenGL/GL/BlendingFactor.hs
@@ -17,7 +17,7 @@
    BlendingFactor(..), marshalBlendingFactor, unmarshalBlendingFactor
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -41,37 +41,37 @@
 
 marshalBlendingFactor :: BlendingFactor -> GLenum
 marshalBlendingFactor x = case x of
-   Zero -> 0x0
-   One -> 0x1
-   SrcColor -> 0x300
-   OneMinusSrcColor -> 0x301
-   DstColor -> 0x306
-   OneMinusDstColor -> 0x307
-   SrcAlpha -> 0x302
-   OneMinusSrcAlpha -> 0x303
-   DstAlpha -> 0x304
-   OneMinusDstAlpha -> 0x305
-   ConstantColor -> 0x8001
-   OneMinusConstantColor -> 0x8002
-   ConstantAlpha -> 0x8003
-   OneMinusConstantAlpha -> 0x8004
-   SrcAlphaSaturate -> 0x308
+   Zero -> gl_ZERO
+   One -> gl_ONE
+   SrcColor -> gl_SRC_COLOR
+   OneMinusSrcColor -> gl_ONE_MINUS_SRC_COLOR
+   DstColor -> gl_DST_COLOR
+   OneMinusDstColor -> gl_ONE_MINUS_DST_COLOR
+   SrcAlpha -> gl_SRC_ALPHA
+   OneMinusSrcAlpha -> gl_ONE_MINUS_SRC_ALPHA
+   DstAlpha -> gl_DST_ALPHA
+   OneMinusDstAlpha -> gl_ONE_MINUS_DST_ALPHA
+   ConstantColor -> gl_CONSTANT_COLOR
+   OneMinusConstantColor -> gl_ONE_MINUS_CONSTANT_COLOR
+   ConstantAlpha -> gl_CONSTANT_ALPHA
+   OneMinusConstantAlpha -> gl_ONE_MINUS_CONSTANT_ALPHA
+   SrcAlphaSaturate -> gl_SRC_ALPHA_SATURATE
 
 unmarshalBlendingFactor :: GLenum -> BlendingFactor
 unmarshalBlendingFactor x
-   | x == 0x0 = Zero
-   | x == 0x1 = One
-   | x == 0x300 = SrcColor
-   | x == 0x301 = OneMinusSrcColor
-   | x == 0x306 = DstColor
-   | x == 0x307 = OneMinusDstColor
-   | x == 0x302 = SrcAlpha
-   | x == 0x303 = OneMinusSrcAlpha
-   | x == 0x304 = DstAlpha
-   | x == 0x305 = OneMinusDstAlpha
-   | x == 0x8001 = ConstantColor
-   | x == 0x8002 = OneMinusConstantColor
-   | x == 0x8003 = ConstantAlpha
-   | x == 0x8004 = OneMinusConstantAlpha
-   | x == 0x308 = SrcAlphaSaturate
+   | x == gl_ZERO = Zero
+   | x == gl_ONE = One
+   | x == gl_SRC_COLOR = SrcColor
+   | x == gl_ONE_MINUS_SRC_COLOR = OneMinusSrcColor
+   | x == gl_DST_COLOR = DstColor
+   | x == gl_ONE_MINUS_DST_COLOR = OneMinusDstColor
+   | x == gl_SRC_ALPHA = SrcAlpha
+   | x == gl_ONE_MINUS_SRC_ALPHA = OneMinusSrcAlpha
+   | x == gl_DST_ALPHA = DstAlpha
+   | x == gl_ONE_MINUS_DST_ALPHA = OneMinusDstAlpha
+   | x == gl_CONSTANT_COLOR = ConstantColor
+   | x == gl_ONE_MINUS_CONSTANT_COLOR = OneMinusConstantColor
+   | x == gl_CONSTANT_ALPHA = ConstantAlpha
+   | x == gl_ONE_MINUS_CONSTANT_ALPHA = OneMinusConstantAlpha
+   | x == gl_SRC_ALPHA_SATURATE = SrcAlphaSaturate
    | otherwise = error ("unmarshalBlendingFactor: illegal value " ++ show x)
diff --git a/Graphics/Rendering/OpenGL/GL/BufferMode.hs b/Graphics/Rendering/OpenGL/GL/BufferMode.hs
--- a/Graphics/Rendering/OpenGL/GL/BufferMode.hs
+++ b/Graphics/Rendering/OpenGL/GL/BufferMode.hs
@@ -17,7 +17,8 @@
    BufferMode(..), marshalBufferMode, unmarshalBufferMode
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLsizei )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility ( gl_AUX0 )
 
 --------------------------------------------------------------------------------
 
@@ -63,31 +64,34 @@
 
 marshalBufferMode :: BufferMode -> Maybe GLenum
 marshalBufferMode x = case x of
-   NoBuffers -> Just 0x0
-   FrontLeftBuffer -> Just 0x400
-   FrontRightBuffer -> Just 0x401
-   BackLeftBuffer -> Just 0x402
-   BackRightBuffer -> Just 0x403
-   FrontBuffers -> Just 0x404
-   BackBuffers -> Just 0x405
-   LeftBuffers -> Just 0x406
-   RightBuffers -> Just 0x407
-   FrontAndBackBuffers -> Just 0x408
+   NoBuffers -> Just gl_NONE
+   FrontLeftBuffer -> Just gl_FRONT_LEFT
+   FrontRightBuffer -> Just gl_FRONT_RIGHT
+   BackLeftBuffer -> Just gl_BACK_LEFT
+   BackRightBuffer -> Just gl_BACK_RIGHT
+   FrontBuffers -> Just gl_FRONT
+   BackBuffers -> Just gl_BACK
+   LeftBuffers -> Just gl_LEFT
+   RightBuffers -> Just gl_RIGHT
+   FrontAndBackBuffers -> Just gl_FRONT_AND_BACK
    AuxBuffer i
-      | i <= 246  -> Just (0x409 + fromIntegral i)
+      | fromIntegral i <= maxAuxBuffer -> Just (gl_AUX0 + fromIntegral i)
       | otherwise -> Nothing
 
 unmarshalBufferMode :: GLenum -> BufferMode
 unmarshalBufferMode x
-   | x == 0x0 = NoBuffers
-   | x == 0x400 = FrontLeftBuffer
-   | x == 0x401 = FrontRightBuffer
-   | x == 0x402 = BackLeftBuffer
-   | x == 0x403 = BackRightBuffer
-   | x == 0x404 = FrontBuffers
-   | x == 0x405 = BackBuffers
-   | x == 0x406 = LeftBuffers
-   | x == 0x407 = RightBuffers
-   | x == 0x408 = FrontAndBackBuffers
-   | 0x409 <= x && x <= 0x4ff = AuxBuffer (fromIntegral x - 0x409)
+   | x == gl_NONE = NoBuffers
+   | x == gl_FRONT_LEFT = FrontLeftBuffer
+   | x == gl_FRONT_RIGHT = FrontRightBuffer
+   | x == gl_BACK_LEFT = BackLeftBuffer
+   | x == gl_BACK_RIGHT = BackRightBuffer
+   | x == gl_FRONT = FrontBuffers
+   | x == gl_BACK = BackBuffers
+   | x == gl_LEFT = LeftBuffers
+   | x == gl_RIGHT = RightBuffers
+   | x == gl_FRONT_AND_BACK = FrontAndBackBuffers
+   | gl_AUX0 <= x && x <= gl_AUX0 + maxAuxBuffer = AuxBuffer (fromIntegral (x - gl_AUX0))
    | otherwise = error ("unmarshalBufferMode: illegal value " ++ show x)
+
+maxAuxBuffer :: GLenum
+maxAuxBuffer = 246
diff --git a/Graphics/Rendering/OpenGL/GL/BufferObjects.hs b/Graphics/Rendering/OpenGL/GL/BufferObjects.hs
--- a/Graphics/Rendering/OpenGL/GL/BufferObjects.hs
+++ b/Graphics/Rendering/OpenGL/GL/BufferObjects.hs
@@ -15,7 +15,7 @@
 
 module Graphics.Rendering.OpenGL.GL.BufferObjects (
    -- * Object Names
-   ObjectName(..),
+   module Data.ObjectName,
 
    -- * Buffer Objects
    BufferObject(BufferObject),
@@ -33,47 +33,20 @@
    bufferAccess, bufferMapped
 ) where
 
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Marshal.Array ( withArrayLen, peekArray, allocaArray )
-import Foreign.Ptr ( Ptr )
-import Foreign.Storable ( Storable(peek) )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLenum, GLint, GLintptr, GLuint, GLsizei, GLsizeiptr )
-import Graphics.Rendering.OpenGL.GL.Exception ( finallyRet )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.GLboolean ( unmarshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1 )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetArrayBufferBinding,GetElementArrayBufferBinding,
-            GetVertexArrayBufferBinding,GetNormalArrayBufferBinding,
-            GetColorArrayBufferBinding,GetIndexArrayBufferBinding,
-            GetTextureCoordArrayBufferBinding,GetEdgeFlagArrayBufferBinding,
-            GetFogCoordArrayBufferBinding,GetSecondaryColorArrayBufferBinding,
-            GetPixelPackBufferBinding,GetPixelUnpackBufferBinding,
-            GetCopyReadBuffer,GetCopyWriteBuffer),
-   getInteger1, maybeNullPtr,
-   GetVertexAttribPName(GetVertexAttribArrayBufferBinding), getVertexAttribInteger1 )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.VertexArrays ( ClientArrayType(..) )
-import Graphics.Rendering.OpenGL.GL.VertexSpec ( AttribLocation )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal ( recordInvalidEnum )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
-
---------------------------------------------------------------------------------
-
--- | An 'ObjectName' corresponds to the general OpenGL notion of an explicitly
--- handled object name, e.g. a display list name, a texture object name, a
--- buffer object name, etc.
-
-class ObjectName a where
-   genObjectNames :: Int -> IO [a]
-   deleteObjectNames:: [a] -> IO ()
-   isObjectName :: a -> IO Bool
+import Data.ObjectName
+import Data.StateVar
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Array
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.Exception
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.VertexArrays
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -85,20 +58,14 @@
 instance ObjectName BufferObject where
    genObjectNames n =
       allocaArray n $ \buf -> do
-        glGenBuffersARB (fromIntegral n) buf
+        glGenBuffers (fromIntegral n) buf
         fmap (map BufferObject) $ peekArray n buf
 
    deleteObjectNames bufferObjects =
       withArrayLen (map bufferID bufferObjects) $
-         glDeleteBuffersARB . fromIntegral
-
-   isObjectName = fmap unmarshalGLboolean . glIsBufferARB . bufferID
-
-EXTENSION_ENTRY("GL_ARB_vertex_buffer_object or OpenGL 1.5",glGenBuffersARB,GLsizei -> Ptr GLuint -> IO ())
-
-EXTENSION_ENTRY("GL_ARB_vertex_buffer_object or OpenGL 1.5",glDeleteBuffersARB,GLsizei -> Ptr GLuint -> IO ())
+         glDeleteBuffers . fromIntegral
 
-EXTENSION_ENTRY("GL_ARB_vertex_buffer_object or OpenGL 1.5",glIsBufferARB,GLuint -> IO GLboolean)
+   isObjectName = fmap unmarshalGLboolean . glIsBuffer . bufferID
 
 --------------------------------------------------------------------------------
 
@@ -113,12 +80,12 @@
 
 marshalBufferTarget :: BufferTarget -> GLenum
 marshalBufferTarget x = case x of
-   ArrayBuffer -> 0x8892
-   CopyReadBuffer -> 0x8F36
-   CopyWriteBuffer -> 0x8F37
-   ElementArrayBuffer -> 0x8893
-   PixelPackBuffer -> 0x88eb
-   PixelUnpackBuffer -> 0x88ec
+   ArrayBuffer -> gl_ARRAY_BUFFER
+   CopyReadBuffer -> gl_COPY_READ_BUFFER
+   CopyWriteBuffer -> gl_COPY_WRITE_BUFFER
+   ElementArrayBuffer -> gl_ELEMENT_ARRAY_BUFFER
+   PixelPackBuffer -> gl_PIXEL_PACK_BUFFER
+   PixelUnpackBuffer -> gl_PIXEL_UNPACK_BUFFER
 
 bufferTargetToGetPName :: BufferTarget -> GetPName
 bufferTargetToGetPName x = case x of
@@ -145,27 +112,27 @@
 
 marshalBufferUsage :: BufferUsage -> GLenum
 marshalBufferUsage x = case x of
-   StreamDraw -> 0x88e0
-   StreamRead -> 0x88e1
-   StreamCopy -> 0x88e2
-   StaticDraw -> 0x88e4
-   StaticRead -> 0x88e5
-   StaticCopy -> 0x88e6
-   DynamicDraw -> 0x88e8
-   DynamicRead -> 0x88e9
-   DynamicCopy -> 0x88ea
+   StreamDraw -> gl_STREAM_DRAW
+   StreamRead -> gl_STREAM_READ
+   StreamCopy -> gl_STREAM_COPY
+   StaticDraw -> gl_STATIC_DRAW
+   StaticRead -> gl_STATIC_READ
+   StaticCopy -> gl_STATIC_COPY
+   DynamicDraw -> gl_DYNAMIC_DRAW
+   DynamicRead -> gl_DYNAMIC_READ
+   DynamicCopy -> gl_DYNAMIC_COPY
 
 unmarshalBufferUsage :: GLenum -> BufferUsage
 unmarshalBufferUsage x
-   | x == 0x88e0 = StreamDraw
-   | x == 0x88e1 = StreamRead
-   | x == 0x88e2 = StreamCopy
-   | x == 0x88e4 = StaticDraw
-   | x == 0x88e5 = StaticRead
-   | x == 0x88e6 = StaticCopy
-   | x == 0x88e8 = DynamicDraw
-   | x == 0x88e9 = DynamicRead
-   | x == 0x88ea = DynamicCopy
+   | x == gl_STREAM_DRAW = StreamDraw
+   | x == gl_STREAM_READ = StreamRead
+   | x == gl_STREAM_COPY = StreamCopy
+   | x == gl_STATIC_DRAW = StaticDraw
+   | x == gl_STATIC_READ = StaticRead
+   | x == gl_STATIC_COPY = StaticCopy
+   | x == gl_DYNAMIC_DRAW = DynamicDraw
+   | x == gl_DYNAMIC_READ = DynamicRead
+   | x == gl_DYNAMIC_COPY = DynamicCopy
    | otherwise = error ("unmarshalBufferUsage: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
@@ -178,15 +145,15 @@
 
 marshalBufferAccess :: BufferAccess -> GLenum
 marshalBufferAccess x = case x of
-   ReadOnly -> 0x88b8
-   WriteOnly -> 0x88b9
-   ReadWrite -> 0x88ba
+   ReadOnly -> gl_READ_ONLY
+   WriteOnly -> gl_WRITE_ONLY
+   ReadWrite -> gl_READ_WRITE
 
 unmarshalBufferAccess :: GLenum -> BufferAccess
 unmarshalBufferAccess x
-   | x == 0x88b8 = ReadOnly
-   | x == 0x88b9 = WriteOnly
-   | x == 0x88ba = ReadWrite
+   | x == gl_READ_ONLY = ReadOnly
+   | x == gl_WRITE_ONLY = WriteOnly
+   | x == gl_READ_WRITE = ReadWrite
    | otherwise = error ("unmarshalBufferAccess: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
@@ -207,9 +174,7 @@
 
 setBindBuffer :: BufferTarget -> Maybe BufferObject -> IO ()
 setBindBuffer t =
-   glBindBufferARB (marshalBufferTarget t) . bufferID . maybe noBufferObject id
-
-EXTENSION_ENTRY("GL_ARB_vertex_buffer_object or OpenGL 1.5",glBindBufferARB,GLenum -> GLuint -> IO ())
+   glBindBuffer (marshalBufferTarget t) . bufferID . maybe noBufferObject id
 
 clientArrayTypeToGetPName :: ClientArrayType -> GetPName
 clientArrayTypeToGetPName x = case x of
@@ -250,9 +215,7 @@
 
 setBufferData :: BufferTarget -> (GLsizeiptr, Ptr a, BufferUsage) -> IO ()
 setBufferData t (s, p, u) =
-   glBufferDataARB (marshalBufferTarget t) s p (marshalBufferUsage u)
-
-EXTENSION_ENTRY("GL_ARB_vertex_buffer_object or OpenGL 1.5",glBufferDataARB,GLenum -> GLsizeiptr -> Ptr a -> GLenum -> IO ())
+   glBufferData (marshalBufferTarget t) s p (marshalBufferUsage u)
 
 --------------------------------------------------------------------------------
 
@@ -263,12 +226,8 @@
 
 bufferSubData ::
    BufferTarget -> TransferDirection -> GLintptr -> GLsizeiptr -> Ptr a -> IO ()
-bufferSubData t WriteToBuffer = glBufferSubDataARB (marshalBufferTarget t)
-bufferSubData t ReadFromBuffer = glGetBufferSubDataARB (marshalBufferTarget t)
-
-EXTENSION_ENTRY("GL_ARB_vertex_buffer_object or OpenGL 1.5",glBufferSubDataARB,GLenum -> GLintptr -> GLsizeiptr -> Ptr a -> IO ())
-
-EXTENSION_ENTRY("GL_ARB_vertex_buffer_object or OpenGL 1.5",glGetBufferSubDataARB,GLenum -> GLintptr -> GLsizeiptr -> Ptr a -> IO ())
+bufferSubData t WriteToBuffer = glBufferSubData (marshalBufferTarget t)
+bufferSubData t ReadFromBuffer = glGetBufferSubData (marshalBufferTarget t)
 
 --------------------------------------------------------------------------------
 
@@ -280,29 +239,24 @@
 
 marshalGetBufferPName :: GetBufferPName -> GLenum
 marshalGetBufferPName x = case x of
-   GetBufferSize -> 0x8764
-   GetBufferUsage -> 0x8765
-   GetBufferAccess -> 0x88bb
-   GetBufferMapped -> 0x88bc
+   GetBufferSize -> gl_BUFFER_SIZE
+   GetBufferUsage -> gl_BUFFER_USAGE
+   GetBufferAccess -> gl_BUFFER_ACCESS
+   GetBufferMapped -> gl_BUFFER_MAPPED
 
 getBufferParameter :: BufferTarget -> (GLenum -> a) -> GetBufferPName -> IO a
 getBufferParameter t f p = alloca $ \buf -> do
-   glGetBufferParameterivARB (marshalBufferTarget t)
-                             (marshalGetBufferPName p) buf
+   glGetBufferParameteriv (marshalBufferTarget t)
+                          (marshalGetBufferPName p) buf
    peek1 (f . fromIntegral) buf
 
-EXTENSION_ENTRY("GL_ARB_vertex_buffer_object or OpenGL 1.5",glGetBufferParameterivARB,GLenum -> GLenum -> Ptr GLint -> IO ())
-
 --------------------------------------------------------------------------------
 
 getBufferPointer :: BufferTarget -> IO (Ptr a)
 getBufferPointer t = alloca $ \buf -> do
-   -- only one pname: GL_BUFFER_MAP_POINTER
-   glGetBufferPointervARB (marshalBufferTarget t) 0x88bd buf
+   glGetBufferPointerv (marshalBufferTarget t) gl_BUFFER_MAP_POINTER buf
    peek buf
 
-EXTENSION_ENTRY("GL_ARB_vertex_buffer_object or OpenGL 1.5",glGetBufferPointervARB,GLenum -> GLenum -> Ptr (Ptr a) -> IO ())
-
 --------------------------------------------------------------------------------
 
 data MappingFailure =
@@ -326,14 +280,10 @@
 mapBuffer t = fmap (maybeNullPtr Nothing Just) . mapBuffer_ t
 
 mapBuffer_ :: BufferTarget -> BufferAccess -> IO (Ptr a)
-mapBuffer_ t = glMapBufferARB (marshalBufferTarget t) . marshalBufferAccess
-
-EXTENSION_ENTRY("GL_ARB_vertex_buffer_object or OpenGL 1.5",glMapBufferARB,GLenum -> GLenum -> IO (Ptr a))
+mapBuffer_ t = glMapBuffer (marshalBufferTarget t) . marshalBufferAccess
 
 unmapBuffer :: BufferTarget -> IO Bool
-unmapBuffer = fmap unmarshalGLboolean . glUnmapBufferARB . marshalBufferTarget
-
-EXTENSION_ENTRY("GL_ARB_vertex_buffer_object or OpenGL 1.5",glUnmapBufferARB,GLenum -> IO GLboolean)
+unmapBuffer = fmap unmarshalGLboolean . glUnmapBuffer . marshalBufferTarget
 
 bufferAccess :: BufferTarget -> GettableStateVar BufferAccess
 bufferAccess t = makeGettableStateVar $
diff --git a/Graphics/Rendering/OpenGL/GL/Capability.hs b/Graphics/Rendering/OpenGL/GL/Capability.hs
--- a/Graphics/Rendering/OpenGL/GL/Capability.hs
+++ b/Graphics/Rendering/OpenGL/GL/Capability.hs
@@ -15,22 +15,47 @@
 --------------------------------------------------------------------------------
 
 module Graphics.Rendering.OpenGL.GL.Capability (
-   marshalCapability, unmarshalCapability,
+   Capability(..), marshalCapability, unmarshalCapability,
    EnableCap(..), makeCapability, makeStateVarMaybe
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLenum, GLsizei, Capability(..) )
-import Graphics.Rendering.OpenGL.GL.GLboolean (
-   marshalGLboolean, unmarshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   clipPlaneIndexToEnum, lightIndexToEnum )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   HasGetter(get), HasSetter(($=)), StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal ( recordInvalidEnum )
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   gl_ALPHA_TEST, gl_AUTO_NORMAL, gl_COLOR_ARRAY, gl_COLOR_MATERIAL,
+   gl_COLOR_SUM, gl_COLOR_TABLE, gl_CONVOLUTION_1D, gl_CONVOLUTION_2D,
+   gl_EDGE_FLAG_ARRAY, gl_FOG, gl_FOG_COORD_ARRAY, gl_HISTOGRAM, gl_INDEX_ARRAY,
+   gl_INDEX_LOGIC_OP, gl_LIGHTING, gl_LINE_STIPPLE, gl_MAP1_COLOR_4,
+   gl_MAP1_INDEX, gl_MAP1_NORMAL, gl_MAP1_TEXTURE_COORD_1,
+   gl_MAP1_TEXTURE_COORD_2, gl_MAP1_TEXTURE_COORD_3, gl_MAP1_TEXTURE_COORD_4,
+   gl_MAP1_VERTEX_3, gl_MAP1_VERTEX_4, gl_MAP2_COLOR_4, gl_MAP2_INDEX,
+   gl_MAP2_NORMAL, gl_MAP2_TEXTURE_COORD_1, gl_MAP2_TEXTURE_COORD_2,
+   gl_MAP2_TEXTURE_COORD_3, gl_MAP2_TEXTURE_COORD_4, gl_MAP2_VERTEX_3,
+   gl_MAP2_VERTEX_4, gl_MINMAX, gl_NORMALIZE, gl_NORMAL_ARRAY, gl_POINT_SMOOTH,
+   gl_POINT_SPRITE, gl_POLYGON_STIPPLE, gl_POST_COLOR_MATRIX_COLOR_TABLE,
+   gl_POST_CONVOLUTION_COLOR_TABLE, gl_RESCALE_NORMAL, gl_SECONDARY_COLOR_ARRAY,
+   gl_SEPARABLE_2D, gl_TEXTURE_COORD_ARRAY, gl_TEXTURE_GEN_Q, gl_TEXTURE_GEN_R,
+   gl_TEXTURE_GEN_S, gl_TEXTURE_GEN_T, gl_VERTEX_ARRAY,
+   gl_VERTEX_PROGRAM_TWO_SIDE )
+import Graphics.Rendering.OpenGL.Raw.ARB.MatrixPalette ( gl_MATRIX_INDEX_ARRAY, gl_MATRIX_PALETTE )
+import Graphics.Rendering.OpenGL.Raw.ARB.VertexBlend ( gl_WEIGHT_SUM_UNITY, gl_VERTEX_BLEND, gl_WEIGHT_ARRAY )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.EXT.DepthBoundsTest ( gl_DEPTH_BOUNDS_TEST )
+import Graphics.Rendering.OpenGL.Raw.EXT.SharedTexturePalette ( gl_SHARED_TEXTURE_PALETTE )
+import Graphics.Rendering.OpenGL.Raw.EXT.StencilTwoSide ( gl_STENCIL_TEST_TWO_SIDE )
+import Graphics.Rendering.OpenGL.Raw.NV.DepthClamp ( gl_DEPTH_CLAMP )
 
 --------------------------------------------------------------------------------
 
+data Capability =
+     Disabled
+   | Enabled
+   deriving ( Eq, Ord, Show )
+
+--------------------------------------------------------------------------------
+
 marshalCapability :: Capability -> GLboolean
 marshalCapability = marshalGLboolean . (Enabled ==)
 
@@ -121,7 +146,7 @@
    | CapMatrixPalette
    | CapDepthClamp
    | CapDepthBoundsTest
-   | CapPrimitiveRestart -- NOTE: client state!
+   | CapPrimitiveRestart
    | CapPointSprite
    | CapStencilTestTwoSide
    | CapRasterPositionUnclipped
@@ -131,94 +156,96 @@
 
 marshalEnableCap :: EnableCap -> Maybe GLenum
 marshalEnableCap x = case x of
-   CapFog -> Just 0xb60
-   CapLighting -> Just 0xb50
-   CapTexture1D -> Just 0xde0
-   CapTexture2D -> Just 0xde1
-   CapTextureRectangle -> Just 0x84F5
-   CapLineStipple -> Just 0xb24
-   CapPolygonStipple -> Just 0xb42
-   CapCullFace -> Just 0xb44
-   CapAlphaTest -> Just 0xbc0
-   CapBlend -> Just 0xbe2
-   CapIndexLogicOp -> Just 0xbf1
-   CapColorLogicOp -> Just 0xbf2
-   CapDither -> Just 0xbd0
-   CapStencilTest -> Just 0xb90
-   CapDepthTest -> Just 0xb71
+   CapFog -> Just gl_FOG
+   CapLighting -> Just gl_LIGHTING
+   CapTexture1D -> Just gl_TEXTURE_1D
+   CapTexture2D -> Just gl_TEXTURE_2D
+   CapTextureRectangle -> Just gl_TEXTURE_RECTANGLE
+   CapLineStipple -> Just gl_LINE_STIPPLE
+   CapPolygonStipple -> Just gl_POLYGON_STIPPLE
+   CapCullFace -> Just gl_CULL_FACE
+   CapAlphaTest -> Just gl_ALPHA_TEST
+   CapBlend -> Just gl_BLEND
+   CapIndexLogicOp -> Just gl_INDEX_LOGIC_OP
+   CapColorLogicOp -> Just gl_COLOR_LOGIC_OP
+   CapDither -> Just gl_DITHER
+   CapStencilTest -> Just gl_STENCIL_TEST
+   CapDepthTest -> Just gl_DEPTH_TEST
    CapClipPlane i -> clipPlaneIndexToEnum i
    CapLight i -> lightIndexToEnum i
-   CapTextureGenS -> Just 0xc60
-   CapTextureGenT -> Just 0xc61
-   CapTextureGenR -> Just 0xc62
-   CapTextureGenQ -> Just 0xc63
-   CapMap1Vertex3 -> Just 0xd97
-   CapMap1Vertex4 -> Just 0xd98
-   CapMap1Color4 -> Just 0xd90
-   CapMap1Index -> Just 0xd91
-   CapMap1Normal -> Just 0xd92
-   CapMap1TextureCoord1 -> Just 0xd93
-   CapMap1TextureCoord2 -> Just 0xd94
-   CapMap1TextureCoord3 -> Just 0xd95
-   CapMap1TextureCoord4 -> Just 0xd96
-   CapMap2Vertex3 -> Just 0xdb7
-   CapMap2Vertex4 -> Just 0xdb8
-   CapMap2Color4 -> Just 0xdb0
-   CapMap2Index -> Just 0xdb1
-   CapMap2Normal -> Just 0xdb2
-   CapMap2TextureCoord1 -> Just 0xdb3
-   CapMap2TextureCoord2 -> Just 0xdb4
-   CapMap2TextureCoord3 -> Just 0xdb5
-   CapMap2TextureCoord4 -> Just 0xdb6
-   CapPointSmooth -> Just 0xb10
-   CapLineSmooth -> Just 0xb20
-   CapPolygonSmooth -> Just 0xb41
-   CapScissorTest -> Just 0xc11
-   CapColorMaterial -> Just 0xb57
-   CapNormalize -> Just 0xba1
-   CapAutoNormal -> Just 0xd80
-   CapPolygonOffsetPoint -> Just 0x2a01
-   CapPolygonOffsetLine -> Just 0x2a02
-   CapPolygonOffsetFill -> Just 0x8037
-   CapVertexArray -> Just 0x8074
-   CapNormalArray -> Just 0x8075
-   CapColorArray -> Just 0x8076
-   CapIndexArray -> Just 0x8077
-   CapTextureCoordArray -> Just 0x8078
-   CapEdgeFlagArray -> Just 0x8079
-   CapFogCoordArray -> Just 0x8457
-   CapSecondaryColorArray -> Just 0x845e
-   CapMatrixIndexArray -> Just 0x8844
-   CapConvolution1D -> Just 0x8010
-   CapConvolution2D -> Just 0x8011
-   CapSeparable2D -> Just 0x8012
-   CapHistogram -> Just 0x8024
-   CapMinmax -> Just 0x802e
-   CapRescaleNormal -> Just 0x803a
-   CapSharedTexturePalette -> Just 0x81fb
-   CapTexture3D -> Just 0x806f
-   CapMultisample -> Just 0x809d
-   CapSampleAlphaToCoverage -> Just 0x809e
-   CapSampleAlphaToOne -> Just 0x809f
-   CapSampleCoverage -> Just 0x80a0
-   CapColorTable -> Just 0x80d0
-   CapPostConvolutionColorTable -> Just 0x80d1
-   CapPostColorMatrixColorTable -> Just 0x80d2
-   CapColorSum -> Just 0x8458
-   CapTextureCubeMap -> Just 0x8513
-   CapWeightSumUnity -> Just 0x86a6
-   CapVertexBlend -> Just 0x86a7
-   CapWeightArray -> Just 0x86ad
-   CapMatrixPalette -> Just 0x8840
-   CapDepthClamp -> Just 0x864f
-   CapDepthBoundsTest -> Just 0x8890
-   CapPrimitiveRestart -> Just 0x8558
-   CapPointSprite -> Just 0x8861
-   CapStencilTestTwoSide -> Just 0x8910
+   CapTextureGenS -> Just gl_TEXTURE_GEN_S
+   CapTextureGenT -> Just gl_TEXTURE_GEN_T
+   CapTextureGenR -> Just gl_TEXTURE_GEN_R
+   CapTextureGenQ -> Just gl_TEXTURE_GEN_Q
+   CapMap1Vertex3 -> Just gl_MAP1_VERTEX_3
+   CapMap1Vertex4 -> Just gl_MAP1_VERTEX_4
+   CapMap1Color4 -> Just gl_MAP1_COLOR_4
+   CapMap1Index -> Just gl_MAP1_INDEX
+   CapMap1Normal -> Just gl_MAP1_NORMAL
+   CapMap1TextureCoord1 -> Just gl_MAP1_TEXTURE_COORD_1
+   CapMap1TextureCoord2 -> Just gl_MAP1_TEXTURE_COORD_2
+   CapMap1TextureCoord3 -> Just gl_MAP1_TEXTURE_COORD_3
+   CapMap1TextureCoord4 -> Just gl_MAP1_TEXTURE_COORD_4
+   CapMap2Vertex3 -> Just gl_MAP2_VERTEX_3
+   CapMap2Vertex4 -> Just gl_MAP2_VERTEX_4
+   CapMap2Color4 -> Just gl_MAP2_COLOR_4
+   CapMap2Index -> Just gl_MAP2_INDEX
+   CapMap2Normal -> Just gl_MAP2_NORMAL
+   CapMap2TextureCoord1 -> Just gl_MAP2_TEXTURE_COORD_1
+   CapMap2TextureCoord2 -> Just gl_MAP2_TEXTURE_COORD_2
+   CapMap2TextureCoord3 -> Just gl_MAP2_TEXTURE_COORD_3
+   CapMap2TextureCoord4 -> Just gl_MAP2_TEXTURE_COORD_4
+   CapPointSmooth -> Just gl_POINT_SMOOTH
+   CapLineSmooth -> Just gl_LINE_SMOOTH
+   CapPolygonSmooth -> Just gl_POLYGON_SMOOTH
+   CapScissorTest -> Just gl_SCISSOR_TEST
+   CapColorMaterial -> Just gl_COLOR_MATERIAL
+   CapNormalize -> Just gl_NORMALIZE
+   CapAutoNormal -> Just gl_AUTO_NORMAL
+   CapPolygonOffsetPoint -> Just gl_POLYGON_OFFSET_POINT
+   CapPolygonOffsetLine -> Just gl_POLYGON_OFFSET_LINE
+   CapPolygonOffsetFill -> Just gl_POLYGON_OFFSET_FILL
+   CapVertexArray -> Just gl_VERTEX_ARRAY
+   CapNormalArray -> Just gl_NORMAL_ARRAY
+   CapColorArray -> Just gl_COLOR_ARRAY
+   CapIndexArray -> Just gl_INDEX_ARRAY
+   CapTextureCoordArray -> Just gl_TEXTURE_COORD_ARRAY
+   CapEdgeFlagArray -> Just gl_EDGE_FLAG_ARRAY
+   CapFogCoordArray -> Just gl_FOG_COORD_ARRAY
+   CapSecondaryColorArray -> Just gl_SECONDARY_COLOR_ARRAY
+   CapMatrixIndexArray -> Just gl_MATRIX_INDEX_ARRAY
+   CapConvolution1D -> Just gl_CONVOLUTION_1D
+   CapConvolution2D -> Just gl_CONVOLUTION_2D
+   CapSeparable2D -> Just gl_SEPARABLE_2D
+   CapHistogram -> Just gl_HISTOGRAM
+   CapMinmax -> Just gl_MINMAX
+   CapRescaleNormal -> Just gl_RESCALE_NORMAL
+   CapSharedTexturePalette -> Just gl_SHARED_TEXTURE_PALETTE
+   CapTexture3D -> Just gl_TEXTURE_3D
+   CapMultisample -> Just gl_MULTISAMPLE
+   CapSampleAlphaToCoverage -> Just gl_SAMPLE_ALPHA_TO_COVERAGE
+   CapSampleAlphaToOne -> Just gl_SAMPLE_ALPHA_TO_ONE
+   CapSampleCoverage -> Just gl_SAMPLE_COVERAGE
+   CapColorTable -> Just gl_COLOR_TABLE
+   CapPostConvolutionColorTable -> Just gl_POST_CONVOLUTION_COLOR_TABLE
+   CapPostColorMatrixColorTable -> Just gl_POST_COLOR_MATRIX_COLOR_TABLE
+   CapColorSum -> Just gl_COLOR_SUM
+   CapTextureCubeMap -> Just gl_TEXTURE_CUBE_MAP
+   CapWeightSumUnity -> Just gl_WEIGHT_SUM_UNITY
+   CapVertexBlend -> Just gl_VERTEX_BLEND
+   CapWeightArray -> Just gl_WEIGHT_ARRAY
+   CapMatrixPalette -> Just gl_MATRIX_PALETTE
+   CapDepthClamp -> Just gl_DEPTH_CLAMP
+   CapDepthBoundsTest -> Just gl_DEPTH_BOUNDS_TEST
+   CapPrimitiveRestart -> Just gl_PRIMITIVE_RESTART
+   CapPointSprite -> Just gl_POINT_SPRITE
+   CapStencilTestTwoSide -> Just gl_STENCIL_TEST_TWO_SIDE
+   -- TODO: use RASTER_POSITION_UNCLIPPED_IBM from IBM_rasterpos_clip extension
    CapRasterPositionUnclipped -> Just 0x19262
+   -- TODO: use TEXTURE_COLOR_TABLE_SGI from SGI_texture_color_table extension
    CapTextureColorTable -> Just 0x80bc
-   CapVertexProgramPointSize -> Just 0x8642
-   CapVertexProgramTwoSide -> Just 0x8643
+   CapVertexProgramPointSize -> Just gl_VERTEX_PROGRAM_POINT_SIZE
+   CapVertexProgramTwoSide -> Just gl_VERTEX_PROGRAM_TWO_SIDE
 
 --------------------------------------------------------------------------------
 
@@ -233,19 +260,12 @@
          (fmap unmarshalCapability . glIsEnabled) .
    marshalEnableCap
 
-foreign import CALLCONV unsafe "glIsEnabled" glIsEnabled ::
-   GLenum -> IO GLboolean
-
 --------------------------------------------------------------------------------
 
 enable :: EnableCap -> Capability -> IO ()
 enable cap state = maybe recordInvalidEnum (f state) (marshalEnableCap cap)
    where f Disabled = glDisable
          f Enabled  = glEnable
-
-foreign import CALLCONV unsafe "glDisable" glDisable :: GLenum -> IO ()
-
-foreign import CALLCONV unsafe "glEnable" glEnable :: GLenum -> IO ()
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/Clipping.hs b/Graphics/Rendering/OpenGL/GL/Clipping.hs
--- a/Graphics/Rendering/OpenGL/GL/Clipping.hs
+++ b/Graphics/Rendering/OpenGL/GL/Clipping.hs
@@ -16,20 +16,17 @@
    ClipPlaneName(..), clipPlane, maxClipPlanes
 ) where
 
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Marshal.Utils ( with )
-import Foreign.Ptr ( Ptr, castPtr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLsizei, GLdouble )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapClipPlane), makeStateVarMaybe )
-import Graphics.Rendering.OpenGL.GL.CoordTrans ( Plane(..) )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1 )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetClipPlane,GetMaxClipPlanes),
-   clipPlaneIndexToEnum, getDoublev, getSizei1 )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, StateVar )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal ( recordInvalidEnum )
+import Data.StateVar
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Utils
+import Foreign.Ptr
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.CoordTrans
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility ( glClipPlane )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -45,11 +42,11 @@
       (alloca $ \buf -> do
           getDoublev (GetClipPlane i) (castPtr buf)
           peek1 id (buf :: Ptr (Plane GLdouble)))
-      (\plane -> maybe recordInvalidEnum (with plane . glClipPlane)
+      (\plane -> maybe recordInvalidEnum (with plane . glClipPlane_)
                        (clipPlaneIndexToEnum i))
 
-foreign import CALLCONV unsafe "glClipPlane" glClipPlane ::
-   GLenum -> Ptr (Plane GLdouble) -> IO ()
+glClipPlane_ :: GLenum -> Ptr (Plane GLdouble) -> IO ()
+glClipPlane_ plane ptr = glClipPlane plane (castPtr ptr)
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/ColorSum.hs b/Graphics/Rendering/OpenGL/GL/ColorSum.hs
--- a/Graphics/Rendering/OpenGL/GL/ColorSum.hs
+++ b/Graphics/Rendering/OpenGL/GL/ColorSum.hs
@@ -16,10 +16,8 @@
    colorSum
 ) where
 
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapColorSum), makeCapability )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( Capability )
-import Graphics.Rendering.OpenGL.GL.StateVar ( StateVar )
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GL.Capability
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/Colors.hs b/Graphics/Rendering/OpenGL/GL/Colors.hs
--- a/Graphics/Rendering/OpenGL/GL/Colors.hs
+++ b/Graphics/Rendering/OpenGL/GL/Colors.hs
@@ -39,35 +39,31 @@
    ShadingModel(..), shadeModel
 ) where
 
-import Control.Monad ( liftM2, liftM3 )
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Marshal.Array ( allocaArray, withArray )
-import Foreign.Marshal.Utils ( with )
-import Foreign.Ptr ( Ptr )
-import Foreign.Storable ( Storable(peek) )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   marshalCapability, unmarshalCapability,
-   EnableCap(CapVertexProgramTwoSide,CapLighting,CapColorMaterial,CapLight),
-   makeCapability,
-   makeStateVarMaybe )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLenum, GLint, GLsizei, GLfloat,Capability )
-import Graphics.Rendering.OpenGL.GL.Face (
-   Face(..), marshalFace, unmarshalFace )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek3 )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetMaxLights, GetFrontFace,GetShadeModel,
-            GetLightModelAmbient, GetLightModelLocalViewer,
-            GetLightModelTwoSide, GetLightModelColorControl,
-            GetColorMaterialFace,GetColorMaterialParameter,
-            GetMaxShininess,GetMaxSpotExponent),
-   getBoolean1, getEnum1, getSizei1, getFloat1, getFloat4, lightIndexToEnum )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   HasGetter(get), HasSetter(($=)),
-   GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.VertexSpec (
-   Color4(..), Normal3(..), Vertex4(..), Index1(..) )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal ( recordInvalidEnum )
+import Control.Monad
+import Data.StateVar
+import Data.Tensor
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Array
+import Foreign.Marshal.Utils
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.Face
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glColorMaterial, glGetLightfv, glGetMaterialfv, glGetMaterialiv,
+   glLightModelfv, glLightModeli, glLightfv, glMaterialfv, glMaterialiv,
+   glShadeModel, gl_AMBIENT, gl_AMBIENT_AND_DIFFUSE, gl_COLOR_INDEXES,
+   gl_CONSTANT_ATTENUATION, gl_DIFFUSE, gl_EMISSION, gl_FLAT,
+   gl_LIGHT_MODEL_AMBIENT, gl_LIGHT_MODEL_COLOR_CONTROL,
+   gl_LIGHT_MODEL_LOCAL_VIEWER, gl_LIGHT_MODEL_TWO_SIDE, gl_LINEAR_ATTENUATION,
+   gl_POSITION, gl_QUADRATIC_ATTENUATION, gl_SEPARATE_SPECULAR_COLOR,
+   gl_SHININESS, gl_SINGLE_COLOR, gl_SMOOTH, gl_SPECULAR, gl_SPOT_CUTOFF,
+   gl_SPOT_DIRECTION, gl_SPOT_EXPONENT )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -99,13 +95,13 @@
 
 marshalFrontFaceDirection :: FrontFaceDirection -> GLenum
 marshalFrontFaceDirection x = case x of
-   CW -> 0x900
-   CCW -> 0x901
+   CW -> gl_CW
+   CCW -> gl_CCW
 
 unmarshalFrontFaceDirection :: GLenum -> FrontFaceDirection
 unmarshalFrontFaceDirection x
-   | x == 0x900 = CW
-   | x == 0x901 = CCW
+   | x == gl_CW = CW
+   | x == gl_CCW = CCW
    | otherwise = error ("unmarshalFrontFaceDirection: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
@@ -116,8 +112,6 @@
       (getEnum1 unmarshalFrontFaceDirection GetFrontFace)
       (glFrontFace . marshalFrontFaceDirection)
 
-foreign import CALLCONV unsafe "glFrontFace" glFrontFace :: GLenum -> IO ()
-
 --------------------------------------------------------------------------------
 
 data MaterialParameter =
@@ -131,13 +125,13 @@
 
 marshalMaterialParameter :: MaterialParameter -> GLenum
 marshalMaterialParameter x = case x of
-   MaterialEmission -> 0x1600
-   MaterialShininess -> 0x1601
-   MaterialAmbientAndDiffuse -> 0x1602
-   MaterialColorIndexes -> 0x1603
-   MaterialAmbient -> 0x1200
-   MaterialDiffuse -> 0x1201
-   MaterialSpecular -> 0x1202
+   MaterialEmission -> gl_EMISSION
+   MaterialShininess -> gl_SHININESS
+   MaterialAmbientAndDiffuse -> gl_AMBIENT_AND_DIFFUSE
+   MaterialColorIndexes -> gl_COLOR_INDEXES
+   MaterialAmbient -> gl_AMBIENT
+   MaterialDiffuse -> gl_DIFFUSE
+   MaterialSpecular -> gl_SPECULAR
 
 --------------------------------------------------------------------------------
 
@@ -171,11 +165,11 @@
    where mp = marshalMaterialParameter materialParameter
          f  = marshalFace face
 
-foreign import CALLCONV unsafe "glGetMaterialfv" glGetMaterialfvc ::
-   GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
+glGetMaterialfvc :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
+glGetMaterialfvc face pname ptr = glGetMaterialfv face pname (castPtr ptr)
 
-foreign import CALLCONV unsafe "glMaterialfv" glMaterialfvc ::
-   GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
+glMaterialfvc :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
+glMaterialfvc face pname ptr = glMaterialfv face pname (castPtr ptr)
 
 --------------------------------------------------------------------------------
 
@@ -183,11 +177,11 @@
 materialShininess =
    makeMaterialVar glGetMaterialfvf glMaterialff MaterialShininess
 
-foreign import CALLCONV unsafe "glGetMaterialfv" glGetMaterialfvf ::
-   GLenum -> GLenum -> Ptr GLfloat -> IO ()
+glGetMaterialfvf :: GLenum -> GLenum -> Ptr GLfloat -> IO ()
+glGetMaterialfvf face pname ptr = glGetMaterialfv face pname (castPtr ptr)
 
-foreign import CALLCONV unsafe "glMaterialfv" glMaterialff ::
-   GLenum -> GLenum -> Ptr GLfloat -> IO ()
+glMaterialff :: GLenum -> GLenum -> Ptr GLfloat -> IO ()
+glMaterialff face pname ptr = glMaterialfv face pname (castPtr ptr)
 
 maxShininess :: GettableStateVar GLfloat
 maxShininess = makeGettableStateVar $ getFloat1 id GetMaxShininess
@@ -210,9 +204,6 @@
                       buf
       peek3 (\a d s -> (Index1 a, Index1 d, Index1 s)) buf
 
-foreign import CALLCONV unsafe "glGetMaterialiv" glGetMaterialiv ::
-   GLenum -> GLenum -> Ptr GLint -> IO ()
-
 setMaterialColorIndexes ::
    Face -> (Index1 GLint, Index1 GLint, Index1 GLint) -> IO ()
 setMaterialColorIndexes face (Index1 a, Index1 d, Index1 s) =
@@ -220,9 +211,6 @@
       glMaterialiv (marshalFace face)
                    (marshalMaterialParameter MaterialColorIndexes)
 
-foreign import CALLCONV unsafe "glMaterialiv" glMaterialiv ::
-   GLenum -> GLenum -> Ptr GLint -> IO ()
-
 --------------------------------------------------------------------------------
 
 data LightParameter =
@@ -239,16 +227,16 @@
 
 marshalLightParameter :: LightParameter -> GLenum
 marshalLightParameter x = case x of
-   Ambient' -> 0x1200
-   Diffuse' -> 0x1201
-   Specular' -> 0x1202
-   Position -> 0x1203
-   SpotDirection -> 0x1204
-   SpotExponent -> 0x1205
-   SpotCutoff -> 0x1206
-   ConstantAttenuation -> 0x1207
-   LinearAttenuation -> 0x1208
-   QuadraticAttenuation -> 0x1209
+   Ambient' -> gl_AMBIENT
+   Diffuse' -> gl_DIFFUSE
+   Specular' -> gl_SPECULAR
+   Position -> gl_POSITION
+   SpotDirection -> gl_SPOT_DIRECTION
+   SpotExponent -> gl_SPOT_EXPONENT
+   SpotCutoff -> gl_SPOT_CUTOFF
+   ConstantAttenuation -> gl_CONSTANT_ATTENUATION
+   LinearAttenuation -> gl_LINEAR_ATTENUATION
+   QuadraticAttenuation -> gl_QUADRATIC_ATTENUATION
 
 --------------------------------------------------------------------------------
 
@@ -276,22 +264,22 @@
          getLightVar = \l -> alloca $ \buf -> do getter l lp buf ; peek buf
          setLightVar = \val l -> with val $ setter l lp
 
-foreign import CALLCONV unsafe "glGetLightfv" glGetLightfvc ::
-   GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
+glGetLightfvc :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
+glGetLightfvc l pname ptr = glGetLightfv l pname (castPtr ptr)
 
-foreign import CALLCONV unsafe "glLightfv" glLightfvc ::
-   GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
+glLightfvc :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
+glLightfvc l pname ptr = glLightfv l pname (castPtr ptr)
 
 --------------------------------------------------------------------------------
 
 position :: Light -> StateVar (Vertex4 GLfloat)
 position = makeLightVar glGetLightfvv glLightfvv Position (Vertex4 0 0 0 0)
 
-foreign import CALLCONV unsafe "glLightfv" glLightfvv ::
-   GLenum -> GLenum -> Ptr (Vertex4 GLfloat) -> IO ()
+glLightfvv :: GLenum -> GLenum -> Ptr (Vertex4 GLfloat) -> IO ()
+glLightfvv l pname ptr = glLightfv l pname (castPtr ptr)
 
-foreign import CALLCONV unsafe "glGetLightfv" glGetLightfvv ::
-   GLenum -> GLenum -> Ptr (Vertex4 GLfloat) -> IO ()
+glGetLightfvv :: GLenum -> GLenum -> Ptr (Vertex4 GLfloat) -> IO ()
+glGetLightfvv l pname ptr = glGetLightfv l pname (castPtr ptr)
 
 --------------------------------------------------------------------------------
 
@@ -299,23 +287,17 @@
 spotDirection =
    makeLightVar glGetLightfvn glLightfvn SpotDirection (Normal3 0 0 0)
 
-foreign import CALLCONV unsafe "glLightfv" glLightfvn ::
-   GLenum -> GLenum -> Ptr (Normal3 GLfloat) -> IO ()
+glLightfvn :: GLenum -> GLenum -> Ptr (Normal3 GLfloat) -> IO ()
+glLightfvn l pname ptr = glLightfv l pname (castPtr ptr)
 
-foreign import CALLCONV unsafe "glGetLightfv" glGetLightfvn ::
-   GLenum -> GLenum -> Ptr (Normal3 GLfloat) -> IO ()
+glGetLightfvn :: GLenum -> GLenum -> Ptr (Normal3 GLfloat) -> IO ()
+glGetLightfvn l pname ptr = glGetLightfv l pname (castPtr ptr)
 
 --------------------------------------------------------------------------------
 
 spotExponent :: Light -> StateVar GLfloat
 spotExponent = makeLightVar glGetLightfv glLightfv SpotExponent 0
 
-foreign import CALLCONV unsafe "glLightfv" glLightfv ::
-   GLenum -> GLenum -> Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glGetLightfv" glGetLightfv ::
-   GLenum -> GLenum -> Ptr GLfloat -> IO ()
-
 maxSpotExponent :: GettableStateVar GLfloat
 maxSpotExponent = makeGettableStateVar $ getFloat1 id GetMaxSpotExponent
 
@@ -357,10 +339,10 @@
 
 marshalLightModelParameter :: LightModelParameter -> GLenum
 marshalLightModelParameter x = case x of
-   LightModelAmbient -> 0xb53
-   LightModelLocalViewer -> 0xb51
-   LightModelTwoSide -> 0xb52
-   LightModelColorControl -> 0x81f8
+   LightModelAmbient -> gl_LIGHT_MODEL_AMBIENT
+   LightModelLocalViewer -> gl_LIGHT_MODEL_LOCAL_VIEWER
+   LightModelTwoSide -> gl_LIGHT_MODEL_TWO_SIDE
+   LightModelColorControl -> gl_LIGHT_MODEL_COLOR_CONTROL
 
 --------------------------------------------------------------------------------
 
@@ -369,10 +351,7 @@
    makeStateVar
       (getFloat4 Color4 GetLightModelAmbient)
       (\c -> with c $
-                glLightModelfv (marshalLightModelParameter LightModelAmbient))
-
-foreign import CALLCONV unsafe "glLightModelfv" glLightModelfv ::
-   GLenum -> Ptr (Color4 GLfloat) -> IO ()
+                glLightModelfv (marshalLightModelParameter LightModelAmbient) . castPtr)
 
 --------------------------------------------------------------------------------
 
@@ -387,9 +366,6 @@
       (glLightModeli (marshalLightModelParameter lightModelParameter) .
                      fromIntegral . marshalCapability)
 
-foreign import CALLCONV unsafe "glLightModeli" glLightModeli ::
-   GLenum -> GLint -> IO ()
-
 --------------------------------------------------------------------------------
 
 lightModelTwoSide :: StateVar Capability
@@ -407,13 +383,13 @@
 
 marshalLightModelColorControl :: LightModelColorControl -> GLenum
 marshalLightModelColorControl x = case x of
-   SingleColor -> 0x81f9
-   SeparateSpecularColor -> 0x81fa
+   SingleColor -> gl_SINGLE_COLOR
+   SeparateSpecularColor -> gl_SEPARATE_SPECULAR_COLOR
 
 unmarshalLightModelColorControl :: GLenum -> LightModelColorControl
 unmarshalLightModelColorControl x
-   | x == 0x81f9 = SingleColor
-   | x == 0x81fa = SeparateSpecularColor
+   | x == gl_SINGLE_COLOR = SingleColor
+   | x == gl_SEPARATE_SPECULAR_COLOR = SeparateSpecularColor
    | otherwise = error ("unmarshalLightModelColorControl: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
@@ -437,19 +413,19 @@
 
 marshalColorMaterialParameter :: ColorMaterialParameter -> GLenum
 marshalColorMaterialParameter x = case x of
-   Ambient -> 0x1200
-   Diffuse -> 0x1201
-   Specular -> 0x1202
-   Emission -> 0x1600
-   AmbientAndDiffuse -> 0x1602
+   Ambient -> gl_AMBIENT
+   Diffuse -> gl_DIFFUSE
+   Specular -> gl_SPECULAR
+   Emission -> gl_EMISSION
+   AmbientAndDiffuse -> gl_AMBIENT_AND_DIFFUSE
 
 unmarshalColorMaterialParameter :: GLenum -> ColorMaterialParameter
 unmarshalColorMaterialParameter x
-   | x == 0x1200 = Ambient
-   | x == 0x1201 = Diffuse
-   | x == 0x1202 = Specular
-   | x == 0x1600 = Emission
-   | x == 0x1602 = AmbientAndDiffuse
+   | x == gl_AMBIENT = Ambient
+   | x == gl_DIFFUSE = Diffuse
+   | x == gl_SPECULAR = Specular
+   | x == gl_EMISSION = Emission
+   | x == gl_AMBIENT_AND_DIFFUSE = AmbientAndDiffuse
    | otherwise = error ("unmarshalColorMaterialParameter: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
@@ -465,9 +441,6 @@
       (\(face, param) -> glColorMaterial (marshalFace face)
                                          (marshalColorMaterialParameter param))
 
-foreign import CALLCONV unsafe "glColorMaterial" glColorMaterial ::
-   GLenum -> GLenum -> IO ()
-
 --------------------------------------------------------------------------------
 
 data ShadingModel =
@@ -477,13 +450,13 @@
 
 marshalShadingModel :: ShadingModel -> GLenum
 marshalShadingModel x = case x of
-   Flat -> 0x1d00
-   Smooth -> 0x1d01
+   Flat -> gl_FLAT
+   Smooth -> gl_SMOOTH
 
 unmarshalShadingModel :: GLenum -> ShadingModel
 unmarshalShadingModel x
-   | x == 0x1d00 = Flat
-   | x == 0x1d01 = Smooth
+   | x == gl_FLAT = Flat
+   | x == gl_SMOOTH = Smooth
    | otherwise = error ("unmarshalShadingModel: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
@@ -493,5 +466,3 @@
    makeStateVar
       (getEnum1 unmarshalShadingModel GetShadeModel)
       (glShadeModel . marshalShadingModel)
-
-foreign import CALLCONV unsafe "glShadeModel" glShadeModel :: GLenum -> IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/ComparisonFunction.hs b/Graphics/Rendering/OpenGL/GL/ComparisonFunction.hs
--- a/Graphics/Rendering/OpenGL/GL/ComparisonFunction.hs
+++ b/Graphics/Rendering/OpenGL/GL/ComparisonFunction.hs
@@ -18,7 +18,7 @@
    unmarshalComparisonFunction
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -35,23 +35,23 @@
 
 marshalComparisonFunction :: ComparisonFunction -> GLenum
 marshalComparisonFunction x = case x of
-   Never -> 0x200
-   Less -> 0x201
-   Equal -> 0x202
-   Lequal -> 0x203
-   Greater -> 0x204
-   Notequal -> 0x205
-   Gequal -> 0x206
-   Always -> 0x207
+   Never -> gl_NEVER
+   Less -> gl_LESS
+   Equal -> gl_EQUAL
+   Lequal -> gl_LEQUAL
+   Greater -> gl_GREATER
+   Notequal -> gl_NOTEQUAL
+   Gequal -> gl_GEQUAL
+   Always -> gl_ALWAYS
 
 unmarshalComparisonFunction :: GLenum -> ComparisonFunction
 unmarshalComparisonFunction x
-   | x == 0x200 = Never
-   | x == 0x201 = Less
-   | x == 0x202 = Equal
-   | x == 0x203 = Lequal
-   | x == 0x204 = Greater
-   | x == 0x205 = Notequal
-   | x == 0x206 = Gequal
-   | x == 0x207 = Always
+   | x == gl_NEVER = Never
+   | x == gl_LESS = Less
+   | x == gl_EQUAL = Equal
+   | x == gl_LEQUAL = Lequal
+   | x == gl_GREATER = Greater
+   | x == gl_NOTEQUAL = Notequal
+   | x == gl_GEQUAL = Gequal
+   | x == gl_ALWAYS = Always
    | otherwise = error ("unmarshalComparisonFunction: illegal value " ++ show x)
diff --git a/Graphics/Rendering/OpenGL/GL/ControlPoint.hs b/Graphics/Rendering/OpenGL/GL/ControlPoint.hs
--- a/Graphics/Rendering/OpenGL/GL/ControlPoint.hs
+++ b/Graphics/Rendering/OpenGL/GL/ControlPoint.hs
@@ -17,15 +17,20 @@
    ControlPoint(..)
 ) where
 
-import Foreign.Ptr ( Ptr )
-import Foreign.Storable ( Storable(peek,poke) )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
-import Graphics.Rendering.OpenGL.GL.Capability ( EnableCap(..) )
-import Graphics.Rendering.OpenGL.GL.Domain ( Domain )
-import Graphics.Rendering.OpenGL.GL.VertexArrays ( Stride )
-import Graphics.Rendering.OpenGL.GL.VertexSpec (
-   Vertex3, Vertex4, Index1, Color4, Normal3, TexCoord1, TexCoord2, TexCoord3,
-   TexCoord4 )
+import Data.Tensor
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.Domain
+import Graphics.Rendering.OpenGL.GL.VertexArrays
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   gl_MAP1_COLOR_4, gl_MAP1_INDEX, gl_MAP1_NORMAL, gl_MAP1_TEXTURE_COORD_1,
+   gl_MAP1_TEXTURE_COORD_2, gl_MAP1_TEXTURE_COORD_3, gl_MAP1_TEXTURE_COORD_4,
+   gl_MAP1_VERTEX_3, gl_MAP2_COLOR_4, gl_MAP2_INDEX, gl_MAP2_NORMAL,
+   gl_MAP2_TEXTURE_COORD_1, gl_MAP2_TEXTURE_COORD_2, gl_MAP2_TEXTURE_COORD_3,
+   gl_MAP2_TEXTURE_COORD_4, gl_MAP2_VERTEX_3, gl_MAP2_VERTEX_4 )
 
 --------------------------------------------------------------------------------
 
@@ -143,21 +148,21 @@
 
 marshalMapTarget :: MapTarget -> GLenum
 marshalMapTarget x = case x of
-   Map1Color4 -> 0xd90
-   Map1Index -> 0xd91
-   Map1Normal -> 0xd92
-   Map1TextureCoord1 -> 0xd93
-   Map1TextureCoord2 -> 0xd94
-   Map1TextureCoord3 -> 0xd95
-   Map1TextureCoord4 -> 0xd96
-   Map1Vertex3 -> 0xd97
-   Map1Vertex4 -> 0xd98
-   Map2Color4 -> 0xdb0
-   Map2Index -> 0xdb1
-   Map2Normal -> 0xdb2
-   Map2TextureCoord1 -> 0xdb3
-   Map2TextureCoord2 -> 0xdb4
-   Map2TextureCoord3 -> 0xdb5
-   Map2TextureCoord4 -> 0xdb6
-   Map2Vertex3 -> 0xdb7
-   Map2Vertex4 -> 0xdb8
+   Map1Color4 -> gl_MAP1_COLOR_4
+   Map1Index -> gl_MAP1_INDEX
+   Map1Normal -> gl_MAP1_NORMAL
+   Map1TextureCoord1 -> gl_MAP1_TEXTURE_COORD_1
+   Map1TextureCoord2 -> gl_MAP1_TEXTURE_COORD_2
+   Map1TextureCoord3 -> gl_MAP1_TEXTURE_COORD_3
+   Map1TextureCoord4 -> gl_MAP1_TEXTURE_COORD_4
+   Map1Vertex3 -> gl_MAP1_VERTEX_3
+   Map1Vertex4 -> gl_MAP1_VERTEX_3
+   Map2Color4 -> gl_MAP2_COLOR_4
+   Map2Index -> gl_MAP2_INDEX
+   Map2Normal -> gl_MAP2_NORMAL
+   Map2TextureCoord1 -> gl_MAP2_TEXTURE_COORD_1
+   Map2TextureCoord2 -> gl_MAP2_TEXTURE_COORD_2
+   Map2TextureCoord3 -> gl_MAP2_TEXTURE_COORD_3
+   Map2TextureCoord4 -> gl_MAP2_TEXTURE_COORD_4
+   Map2Vertex3 -> gl_MAP2_VERTEX_3
+   Map2Vertex4 -> gl_MAP2_VERTEX_4
diff --git a/Graphics/Rendering/OpenGL/GL/CoordTrans.hs b/Graphics/Rendering/OpenGL/GL/CoordTrans.hs
--- a/Graphics/Rendering/OpenGL/GL/CoordTrans.hs
+++ b/Graphics/Rendering/OpenGL/GL/CoordTrans.hs
@@ -20,7 +20,6 @@
 
    -- * Matrices
    MatrixMode(..), matrixMode,
-   Vector1(..), Vector2(..), Vector3(..), Vector4(..),
    MatrixOrder(..), MatrixComponent(rotate,translate,scale), Matrix(..),
    currentMatrix, matrix, multMatrix, GLmatrix, loadIdentity,
    ortho, frustum, depthClamp,
@@ -35,49 +34,33 @@
    Plane(..), TextureCoordName(..), TextureGenMode(..), textureGenMode
 ) where
 
-import Foreign.ForeignPtr ( ForeignPtr, mallocForeignPtrArray, withForeignPtr )
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Marshal.Array ( allocaArray, peekArray, pokeArray, withArray )
-import Foreign.Marshal.Utils ( with )
-import Foreign.Ptr ( Ptr, castPtr )
-import Foreign.Storable ( Storable(..) )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapRescaleNormal, CapNormalize,CapDepthClamp,
-             CapTextureGenS, CapTextureGenT,
-             CapTextureGenR, CapTextureGenQ),
-   makeCapability, makeStateVarMaybe )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLenum, GLint, GLsizei, GLfloat, GLdouble, GLclampd, Capability(..) )
-import Graphics.Rendering.OpenGL.GL.Exception ( bracket, unsafeBracket_ )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1, peek4, poke4 )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetDepthRange,GetViewport,GetMaxViewportDims,GetMatrixMode,
-            GetModelviewMatrix,GetProjectionMatrix,
-            GetTextureMatrix, GetColorMatrix,GetMatrixPalette,GetActiveTexture,
-            GetCurrentMatrixStackDepth,GetModelviewStackDepth,
-            GetMaxModelviewStackDepth,GetProjectionStackDepth,
-            GetMaxProjectionStackDepth,GetTextureStackDepth,
-            GetMaxTextureStackDepth,GetColorMatrixStackDepth,
-            GetMaxColorMatrixStackDepth,GetMaxMatrixPaletteStackDepth),
-   getInteger2, getInteger4, getEnum1, getSizei1, getFloatv,
-   getDouble2, getDoublev, modelviewIndexToEnum, modelviewEnumToIndex )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, HasGetter(get), HasSetter(($=)),
-   StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.Tensor (
-   Vector1(..), Vector2(..), Vector3(..), Vector4(..) )
-import Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit (
-   marshalTextureUnit, unmarshalTextureUnit )
-import Graphics.Rendering.OpenGL.GL.VertexSpec ( TextureUnit )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal (
-   recordInvalidEnum, recordInvalidValue )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
-#include "HsOpenGLTypes.h"
+import Data.StateVar
+import Data.Tensor
+import Foreign.C.Types
+import Foreign.ForeignPtr
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Array
+import Foreign.Marshal.Utils
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.Exception
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glFrustum, glGetTexGendv, glGetTexGeniv, glLoadIdentity, glLoadMatrixd,
+   glLoadMatrixf, glLoadTransposeMatrixd, glLoadTransposeMatrixf, glMatrixMode,
+   glMultMatrixd, glMultMatrixf, glMultTransposeMatrixd, glMultTransposeMatrixf,
+   glOrtho, glPopMatrix, glPushMatrix, glRotated, glRotatef, glScaled, glScalef,
+   glTexGendv, glTexGeni, glTranslated, glTranslatef, gl_EYE_LINEAR,
+   gl_EYE_PLANE, gl_NORMAL_MAP, gl_OBJECT_LINEAR, gl_OBJECT_PLANE,
+   gl_PROJECTION, gl_Q, gl_R, gl_REFLECTION_MAP, gl_S, gl_SPHERE_MAP, gl_T,
+   gl_TEXTURE_GEN_MODE )
+import Graphics.Rendering.OpenGL.Raw.ARB.MatrixPalette ( gl_MATRIX_PALETTE )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -98,9 +81,6 @@
 depthRange :: StateVar (GLclampd, GLclampd)
 depthRange = makeStateVar (getDouble2 (,) GetDepthRange) (uncurry glDepthRange)
 
-foreign import CALLCONV unsafe "glDepthRange" glDepthRange ::
-   GLclampd -> GLclampd -> IO ()
-
 --------------------------------------------------------------------------------
 
 -- | A 2-dimensional position, measured in pixels.
@@ -133,9 +113,6 @@
                         (\(Position x y, Size w h) -> glViewport x y w h)
    where makeVp x y w h = (Position x y, Size (fromIntegral w) (fromIntegral h))
 
-foreign import CALLCONV unsafe "glViewport" glViewport ::
-   GLint -> GLint -> GLsizei -> GLsizei -> IO ()
-
 -- | The implementation-dependent maximum viewport width and height.
 
 maxViewportDims :: GettableStateVar Size
@@ -156,17 +133,17 @@
 marshalMatrixMode :: MatrixMode -> Maybe GLenum
 marshalMatrixMode x = case x of
    Modelview i -> modelviewIndexToEnum i
-   Projection -> Just 0x1701
-   Texture -> Just 0x1702
-   Color -> Just 0x1800
-   MatrixPalette -> Just 0x8840
+   Projection -> Just gl_PROJECTION
+   Texture -> Just gl_TEXTURE
+   Color -> Just gl_COLOR
+   MatrixPalette -> Just gl_MATRIX_PALETTE
 
 unmarshalMatrixMode :: GLenum -> MatrixMode
 unmarshalMatrixMode x
-   | x == 0x1701 = Projection
-   | x == 0x1702 = Texture
-   | x == 0x1800 = Color
-   | x == 0x8840 = MatrixPalette
+   | x == gl_PROJECTION = Projection
+   | x == gl_TEXTURE = Texture
+   | x == gl_COLOR = Color
+   | x == gl_MATRIX_PALETTE = MatrixPalette
    | otherwise =
         case modelviewEnumToIndex x of
            Just i -> Modelview i
@@ -206,8 +183,6 @@
    makeStateVar (getEnum1 unmarshalMatrixMode GetMatrixMode)
                 (maybe recordInvalidValue glMatrixMode . marshalMatrixMode)
 
-foreign import CALLCONV unsafe "glMatrixMode" glMatrixMode :: GLenum -> IO ()
-
 --------------------------------------------------------------------------------
 
 data MatrixOrder = ColumnMajor | RowMajor
@@ -225,51 +200,30 @@
    translate :: Vector3 c -> IO ()
    scale :: c -> c -> c -> IO ()
 
-instance MatrixComponent GLfloat_ where
+-- GLfloat instance
+instance MatrixComponent CFloat where
    getMatrix = getFloatv
    loadMatrix = glLoadMatrixf
-   loadTransposeMatrix = glLoadTransposeMatrixfARB
+   loadTransposeMatrix = glLoadTransposeMatrixf
    multMatrix_ = glMultMatrixf
-   multTransposeMatrix = glMultTransposeMatrixfARB
+   multTransposeMatrix = glMultTransposeMatrixf
    rotate a (Vector3 x y z) = glRotatef a x y z
    translate (Vector3 x y z) = glTranslatef x y z
    scale = glScalef
 
-instance MatrixComponent GLdouble_ where
+-- GLfloat instance
+instance MatrixComponent CDouble where
    getMatrix = getDoublev
    loadMatrix = glLoadMatrixd
-   loadTransposeMatrix = glLoadTransposeMatrixdARB
+   loadTransposeMatrix = glLoadTransposeMatrixd
    multMatrix_ = glMultMatrixd
-   multTransposeMatrix = glMultTransposeMatrixdARB
+   multTransposeMatrix = glMultTransposeMatrixd
    rotate a (Vector3 x y z) = glRotated a x y z
    translate (Vector3 x y z) = glTranslated x y z
    scale = glScaled
 
 --------------------------------------------------------------------------------
 
-foreign import CALLCONV unsafe "glLoadMatrixf" glLoadMatrixf :: Ptr GLfloat -> IO ()
-foreign import CALLCONV unsafe "glLoadMatrixd" glLoadMatrixd :: Ptr GLdouble -> IO ()
-
-EXTENSION_ENTRY("GL_ARB_transpose_matrix or OpenGL 1.3",glLoadTransposeMatrixfARB,Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_transpose_matrix or OpenGL 1.3",glLoadTransposeMatrixdARB,Ptr GLdouble -> IO ())
-
-foreign import CALLCONV unsafe "glMultMatrixf" glMultMatrixf :: Ptr GLfloat -> IO ()
-foreign import CALLCONV unsafe "glMultMatrixd" glMultMatrixd :: Ptr GLdouble -> IO ()
-
-EXTENSION_ENTRY("GL_ARB_transpose_matrix or OpenGL 1.3",glMultTransposeMatrixfARB,Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_transpose_matrix or OpenGL 1.3",glMultTransposeMatrixdARB,Ptr GLdouble -> IO ())
-
-foreign import CALLCONV unsafe "glRotatef" glRotatef :: GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ()
-foreign import CALLCONV unsafe "glRotated" glRotated :: GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glTranslatef" glTranslatef :: GLfloat -> GLfloat -> GLfloat -> IO ()
-foreign import CALLCONV unsafe "glTranslated" glTranslated :: GLdouble -> GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glScalef" glScalef :: GLfloat -> GLfloat -> GLfloat -> IO ()
-foreign import CALLCONV unsafe "glScaled" glScaled :: GLdouble -> GLdouble -> GLdouble -> IO ()
-
---------------------------------------------------------------------------------
-
 class Matrix m where
    -- | Create a new matrix of the given order (containing undefined elements)
    -- and call the action to fill it with 4x4 elements.
@@ -344,14 +298,7 @@
 --------------------------------------------------------------------------------
 
 data GLmatrix a = GLmatrix MatrixOrder (ForeignPtr a)
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq (GLmatrix a)
-instance Ord (GLmatrix a)
-instance Show (GLmatrix a)
-#else
    deriving ( Eq, Ord, Show )
-#endif
 
 instance Matrix GLmatrix where
    withNewMatrix order f = do
@@ -363,15 +310,16 @@
 
 --------------------------------------------------------------------------------
 
-foreign import CALLCONV unsafe "glLoadIdentity" loadIdentity :: IO ()
+loadIdentity :: IO ()
+loadIdentity = glLoadIdentity
 
 --------------------------------------------------------------------------------
 
-foreign import CALLCONV unsafe "glOrtho" ortho ::
-   GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
+ortho :: GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
+ortho = glOrtho
 
-foreign import CALLCONV unsafe "glFrustum" frustum ::
-   GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
+frustum :: GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
+frustum = glFrustum
 
 --------------------------------------------------------------------------------
 
@@ -382,9 +330,7 @@
 
 activeTexture :: StateVar TextureUnit
 activeTexture = makeStateVar (getEnum1 unmarshalTextureUnit GetActiveTexture)
-                             (glActiveTextureARB . marshalTextureUnit)
-
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glActiveTextureARB,GLenum -> IO ())   
+                             (glActiveTexture . marshalTextureUnit)
 
 --------------------------------------------------------------------------------
 
@@ -409,10 +355,6 @@
 unsafePreservingMatrix :: IO a -> IO a
 unsafePreservingMatrix = unsafeBracket_ glPushMatrix glPopMatrix
 
-foreign import CALLCONV unsafe "glPushMatrix" glPushMatrix :: IO ()
-
-foreign import CALLCONV unsafe "glPopMatrix" glPopMatrix :: IO ()
-
 --------------------------------------------------------------------------------
 
 stackDepth :: Maybe MatrixMode -> GettableStateVar GLsizei
@@ -468,10 +410,10 @@
 
 marshalTextureCoordName :: TextureCoordName -> GLenum
 marshalTextureCoordName x = case x of
-   S -> 0x2000
-   T -> 0x2001
-   R -> 0x2002
-   Q -> 0x2003
+   S -> gl_S
+   T -> gl_T
+   R -> gl_R
+   Q -> gl_Q
 
 --------------------------------------------------------------------------------
 
@@ -482,9 +424,9 @@
 
 marshalTextureGenParameter :: TextureGenParameter -> GLenum
 marshalTextureGenParameter x = case x of
-   TextureGenMode -> 0x2500
-   ObjectPlane -> 0x2501
-   EyePlane -> 0x2502
+   TextureGenMode -> gl_TEXTURE_GEN_MODE
+   ObjectPlane -> gl_OBJECT_PLANE
+   EyePlane -> gl_EYE_PLANE
 
 --------------------------------------------------------------------------------
 
@@ -496,21 +438,22 @@
    | ReflectionMap'
 
 marshalTextureGenMode' :: TextureGenMode' -> GLint
-marshalTextureGenMode' x = case x of
-   EyeLinear' -> 0x2400
-   ObjectLinear' -> 0x2401
-   SphereMap' -> 0x2402
-   NormalMap' -> 0x8511
-   ReflectionMap' -> 0x8512
+marshalTextureGenMode' x = fromIntegral $ case x of
+   EyeLinear' -> gl_EYE_LINEAR
+   ObjectLinear' -> gl_OBJECT_LINEAR
+   SphereMap' -> gl_SPHERE_MAP
+   NormalMap' -> gl_NORMAL_MAP
+   ReflectionMap' -> gl_REFLECTION_MAP
 
 unmarshalTextureGenMode' :: GLint -> TextureGenMode'
 unmarshalTextureGenMode' x
-   | x == 0x2400 = EyeLinear'
-   | x == 0x2401 = ObjectLinear'
-   | x == 0x2402 = SphereMap'
-   | x == 0x8511 = NormalMap'
-   | x == 0x8512 = ReflectionMap'
+   | y == gl_EYE_LINEAR = EyeLinear'
+   | y == gl_OBJECT_LINEAR = ObjectLinear'
+   | y == gl_SPHERE_MAP = SphereMap'
+   | y == gl_NORMAL_MAP = NormalMap'
+   | y == gl_REFLECTION_MAP = ReflectionMap'
    | otherwise = error ("unmarshalTextureGenMode': illegal value " ++ show x)
+   where y = fromIntegral x
 
 --------------------------------------------------------------------------------
 
@@ -568,36 +511,24 @@
                  buf
    peek1 unmarshalTextureGenMode' buf
 
-foreign import CALLCONV unsafe "glGetTexGeniv" glGetTexGeniv ::
-   GLenum -> GLenum -> Ptr GLint -> IO ()
-
 setMode :: TextureCoordName -> TextureGenMode -> IO ()
 setMode coord mode =
    glTexGeni (marshalTextureCoordName coord)
              (marshalTextureGenParameter TextureGenMode)
              (marshalTextureGenMode mode)
 
-foreign import CALLCONV unsafe "glTexGeni" glTexGeni ::
-    GLenum -> GLenum -> GLint -> IO ()
-
 --------------------------------------------------------------------------------
 
 getPlane :: TextureCoordName -> TextureGenParameter -> IO (Plane GLdouble)
 getPlane coord param = alloca $ \planeBuffer -> do
    glGetTexGendv (marshalTextureCoordName coord)
                  (marshalTextureGenParameter param)
-                 planeBuffer
+                 (castPtr planeBuffer)
    peek planeBuffer
 
-foreign import CALLCONV unsafe "glGetTexGendv" glGetTexGendv ::
-   GLenum -> GLenum -> Ptr (Plane GLdouble) -> IO ()
-
 setPlane :: TextureCoordName -> TextureGenParameter -> Plane GLdouble -> IO ()
 setPlane coord param plane =
    with plane $ \planeBuffer ->
       glTexGendv (marshalTextureCoordName coord)
                  (marshalTextureGenParameter param)
-                 planeBuffer
-
-foreign import CALLCONV unsafe "glTexGendv" glTexGendv ::
-   GLenum -> GLenum -> Ptr (Plane GLdouble) -> IO ()
+                 (castPtr planeBuffer)
diff --git a/Graphics/Rendering/OpenGL/GL/DataType.hs b/Graphics/Rendering/OpenGL/GL/DataType.hs
--- a/Graphics/Rendering/OpenGL/GL/DataType.hs
+++ b/Graphics/Rendering/OpenGL/GL/DataType.hs
@@ -17,7 +17,9 @@
    DataType(..), marshalDataType, unmarshalDataType
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   gl_2_BYTES, gl_3_BYTES, gl_4_BYTES, gl_BITMAP )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -58,69 +60,73 @@
 
 marshalDataType :: DataType -> GLenum
 marshalDataType x = case x of
-   UnsignedByte -> 0x1401
-   Byte -> 0x1400
-   UnsignedShort -> 0x1403
-   Short -> 0x1402
-   UnsignedInt -> 0x1405
-   Int -> 0x1404
-   HalfFloat -> 0x140B
-   Float -> 0x1406
-   UnsignedByte332 -> 0x8032
-   UnsignedByte233Rev -> 0x8362
-   UnsignedShort565 -> 0x8363
-   UnsignedShort565Rev -> 0x8364
-   UnsignedShort4444 -> 0x8033
-   UnsignedShort4444Rev -> 0x8365
-   UnsignedShort5551 -> 0x8034
-   UnsignedShort1555Rev -> 0x8366
-   UnsignedInt8888 -> 0x8035
-   UnsignedInt8888Rev -> 0x8367
-   UnsignedInt1010102 -> 0x8036
-   UnsignedInt2101010Rev -> 0x8368
-   UnsignedInt248 -> 0x84fa
-   UnsignedInt10f11f11fRev -> 0x8C3B
-   UnsignedInt5999Rev -> 0x8C3E
-   Float32UnsignedInt248Rev -> 0x8DAD
-   Bitmap -> 0x1a00
+   UnsignedByte -> gl_UNSIGNED_BYTE
+   Byte -> gl_BYTE
+   UnsignedShort -> gl_UNSIGNED_SHORT
+   Short -> gl_SHORT
+   UnsignedInt -> gl_UNSIGNED_INT
+   Int -> gl_INT
+   HalfFloat -> gl_HALF_FLOAT
+   Float -> gl_FLOAT
+   UnsignedByte332 -> gl_UNSIGNED_BYTE_3_3_2
+   UnsignedByte233Rev -> gl_UNSIGNED_BYTE_2_3_3_REV
+   UnsignedShort565 -> gl_UNSIGNED_SHORT_5_6_5
+   UnsignedShort565Rev -> gl_UNSIGNED_SHORT_5_6_5_REV
+   UnsignedShort4444 -> gl_UNSIGNED_SHORT_4_4_4_4
+   UnsignedShort4444Rev -> gl_UNSIGNED_SHORT_4_4_4_4_REV
+   UnsignedShort5551 -> gl_UNSIGNED_SHORT_5_5_5_1
+   UnsignedShort1555Rev -> gl_UNSIGNED_SHORT_1_5_5_5_REV
+   UnsignedInt8888 -> gl_UNSIGNED_INT_8_8_8_8
+   UnsignedInt8888Rev -> gl_UNSIGNED_INT_8_8_8_8_REV
+   UnsignedInt1010102 -> gl_UNSIGNED_INT_10_10_10_2
+   UnsignedInt2101010Rev -> gl_UNSIGNED_INT_2_10_10_10_REV
+   UnsignedInt248 -> gl_UNSIGNED_INT_24_8
+   UnsignedInt10f11f11fRev -> gl_UNSIGNED_INT_10F_11F_11F_REV
+   UnsignedInt5999Rev -> gl_UNSIGNED_INT_5_9_9_9_REV
+   Float32UnsignedInt248Rev -> gl_FLOAT_32_UNSIGNED_INT_24_8_REV
+   Bitmap -> gl_BITMAP
+   -- TODO: Use UNSIGNED_SHORT_8_8_APPLE from APPLE_ycbcr_422 extension
    UnsignedShort88 -> 0x85ba
+   -- TODO: Use UNSIGNED_SHORT_8_8_REV_APPLE from APPLE_ycbcr_422 extension
    UnsignedShort88Rev -> 0x85bb
-   Double -> 0x140a
-   TwoBytes -> 0x1407
-   ThreeBytes -> 0x1408
-   FourBytes -> 0x1409
+   Double -> gl_DOUBLE
+   TwoBytes -> gl_2_BYTES
+   ThreeBytes -> gl_3_BYTES
+   FourBytes -> gl_4_BYTES
 
 unmarshalDataType :: GLenum -> DataType
 unmarshalDataType x
-   | x == 0x1401 = UnsignedByte
-   | x == 0x1400 = Byte
-   | x == 0x1403 = UnsignedShort
-   | x == 0x1402 = Short
-   | x == 0x1405 = UnsignedInt
-   | x == 0x1404 = Int
-   | x == 0x140B = HalfFloat
-   | x == 0x1406 = Float
-   | x == 0x8032 = UnsignedByte332
-   | x == 0x8362 = UnsignedByte233Rev
-   | x == 0x8363 = UnsignedShort565
-   | x == 0x8364 = UnsignedShort565Rev
-   | x == 0x8033 = UnsignedShort4444
-   | x == 0x8365 = UnsignedShort4444Rev
-   | x == 0x8034 = UnsignedShort5551
-   | x == 0x8366 = UnsignedShort1555Rev
-   | x == 0x8035 = UnsignedInt8888
-   | x == 0x8367 = UnsignedInt8888Rev
-   | x == 0x8036 = UnsignedInt1010102
-   | x == 0x8368 = UnsignedInt2101010Rev
-   | x == 0x84fa = UnsignedInt248
-   | x == 0x8C3B = UnsignedInt10f11f11fRev
-   | x == 0x8C3E = UnsignedInt5999Rev
-   | x == 0x8DAD = Float32UnsignedInt248Rev
-   | x == 0x1a00 = Bitmap
+   | x == gl_UNSIGNED_BYTE = UnsignedByte
+   | x == gl_BYTE = Byte
+   | x == gl_UNSIGNED_SHORT = UnsignedShort
+   | x == gl_SHORT = Short
+   | x == gl_UNSIGNED_INT = UnsignedInt
+   | x == gl_INT = Int
+   | x == gl_HALF_FLOAT = HalfFloat
+   | x == gl_FLOAT = Float
+   | x == gl_UNSIGNED_BYTE_3_3_2 = UnsignedByte332
+   | x == gl_UNSIGNED_BYTE_2_3_3_REV = UnsignedByte233Rev
+   | x == gl_UNSIGNED_SHORT_5_6_5 = UnsignedShort565
+   | x == gl_UNSIGNED_SHORT_5_6_5_REV = UnsignedShort565Rev
+   | x == gl_UNSIGNED_SHORT_4_4_4_4 = UnsignedShort4444
+   | x == gl_UNSIGNED_SHORT_4_4_4_4_REV = UnsignedShort4444Rev
+   | x == gl_UNSIGNED_SHORT_5_5_5_1 = UnsignedShort5551
+   | x == gl_UNSIGNED_SHORT_1_5_5_5_REV = UnsignedShort1555Rev
+   | x == gl_UNSIGNED_INT_8_8_8_8 = UnsignedInt8888
+   | x == gl_UNSIGNED_INT_8_8_8_8_REV = UnsignedInt8888Rev
+   | x == gl_UNSIGNED_INT_10_10_10_2 = UnsignedInt1010102
+   | x == gl_UNSIGNED_INT_2_10_10_10_REV = UnsignedInt2101010Rev
+   | x == gl_UNSIGNED_INT_24_8 = UnsignedInt248
+   | x == gl_UNSIGNED_INT_10F_11F_11F_REV = UnsignedInt10f11f11fRev
+   | x == gl_UNSIGNED_INT_5_9_9_9_REV = UnsignedInt5999Rev
+   | x == gl_FLOAT_32_UNSIGNED_INT_24_8_REV = Float32UnsignedInt248Rev
+   | x == gl_BITMAP = Bitmap
+   -- TODO: Use UNSIGNED_SHORT_8_8_APPLE from APPLE_ycbcr_422 extension
    | x == 0x85ba = UnsignedShort88
+   -- TODO: Use UNSIGNED_SHORT_8_8_REV_APPLE from APPLE_ycbcr_422 extension
    | x == 0x85bb = UnsignedShort88Rev
-   | x == 0x140a = Double
-   | x == 0x1407 = TwoBytes
-   | x == 0x1408 = ThreeBytes
-   | x == 0x1409 = FourBytes
+   | x == gl_DOUBLE = Double
+   | x == gl_2_BYTES = TwoBytes
+   | x == gl_3_BYTES = ThreeBytes
+   | x == gl_4_BYTES = FourBytes
    | otherwise = error ("unmarshalDataType: illegal value " ++ show x)
diff --git a/Graphics/Rendering/OpenGL/GL/DisplayLists.hs b/Graphics/Rendering/OpenGL/GL/DisplayLists.hs
--- a/Graphics/Rendering/OpenGL/GL/DisplayLists.hs
+++ b/Graphics/Rendering/OpenGL/GL/DisplayLists.hs
@@ -25,20 +25,19 @@
    genLists, deleteLists, isList,
 ) where
 
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLuint, GLsizei, GLenum )
-import Graphics.Rendering.OpenGL.GL.BufferObjects ( ObjectName(..) )
-import Graphics.Rendering.OpenGL.GL.DataType ( marshalDataType )
-import Graphics.Rendering.OpenGL.GL.VertexArrays ( DataType )
-import Graphics.Rendering.OpenGL.GL.Exception ( bracket_ )
-import Graphics.Rendering.OpenGL.GL.GLboolean ( unmarshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetListIndex,GetListMode,GetMaxListNesting,GetListBase),
-   getEnum1, getSizei1 )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal ( recordOutOfMemory )
+import Data.ObjectName
+import Data.StateVar
+import Foreign.Ptr
+import Graphics.Rendering.OpenGL.GL.DataType
+import Graphics.Rendering.OpenGL.GL.Exception
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.VertexArrays
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+ glCallList, glCallLists, glDeleteLists, glEndList, glGenLists, glIsList,
+ glListBase, glNewList, gl_COMPILE, gl_COMPILE_AND_EXECUTE )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -64,8 +63,6 @@
               return []
       else return [ DisplayList l | l <- [ first .. first + fromIntegral n - 1 ] ]
 
-foreign import CALLCONV unsafe "glGenLists" glGenLists :: GLsizei -> IO GLuint
-
 --------------------------------------------------------------------------------
 
 {-# DEPRECATED deleteLists "use `deleteObjectNames' instead" #-}
@@ -75,12 +72,9 @@
 deleteLists_ :: [DisplayList] -> IO ()
 deleteLists_ = mapM_ (uncurry glDeleteLists) . combineConsecutive
 
-foreign import CALLCONV unsafe "glDeleteLists" glDeleteLists ::
-   DisplayList -> GLsizei -> IO ()
-
-combineConsecutive :: [DisplayList] -> [(DisplayList, GLsizei)]
+combineConsecutive :: [DisplayList] -> [(GLuint, GLsizei)]
 combineConsecutive []     = []
-combineConsecutive (z:zs) = (z, len) : combineConsecutive rest
+combineConsecutive (z@(DisplayList dl) :zs) = (dl, len) : combineConsecutive rest
    where (len, rest) = run (0 :: GLsizei) z zs
          run n x xs = case n + 1 of
                          m -> case xs of
@@ -96,10 +90,7 @@
 isList = isList_
 
 isList_ :: DisplayList -> IO Bool
-isList_ = fmap unmarshalGLboolean . glIsList
-
-foreign import CALLCONV unsafe "glIsList" glIsList ::
-   DisplayList -> IO GLboolean
+isList_ (DisplayList dl) = fmap unmarshalGLboolean (glIsList dl)
 
 --------------------------------------------------------------------------------
 
@@ -110,24 +101,19 @@
 
 marshalListMode :: ListMode -> GLenum
 marshalListMode x = case x of
-   Compile -> 0x1300
-   CompileAndExecute -> 0x1301
+   Compile -> gl_COMPILE
+   CompileAndExecute -> gl_COMPILE_AND_EXECUTE
 
 unmarshalListMode :: GLenum -> ListMode
 unmarshalListMode x
-   | x == 0x1300 = Compile
-   | x == 0x1301 = CompileAndExecute
+   | x == gl_COMPILE = Compile
+   | x == gl_COMPILE_AND_EXECUTE = CompileAndExecute
    | otherwise = error ("unmarshalListMode: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
 
 defineList :: DisplayList -> ListMode -> IO a -> IO a
-defineList lst mode = bracket_ (glNewList lst (marshalListMode mode)) glEndList
-
-foreign import CALLCONV unsafe "glNewList" glNewList ::
-   DisplayList -> GLenum -> IO ()
-
-foreign import CALLCONV unsafe "glEndList" glEndList :: IO ()
+defineList (DisplayList dl) mode = bracket_ (glNewList dl (marshalListMode mode)) glEndList
 
 defineNewList :: ListMode -> IO a -> IO DisplayList
 defineNewList mode action = do
@@ -158,17 +144,13 @@
 
 --------------------------------------------------------------------------------
 
-foreign import CALLCONV unsafe "glCallList" callList :: DisplayList -> IO ()
+callList :: DisplayList -> IO ()
+callList (DisplayList dl) = glCallList dl
 
 callLists :: GLsizei -> DataType -> Ptr a -> IO ()
 callLists n = glCallLists n . marshalDataType
 
-foreign import CALLCONV unsafe "glCallLists" glCallLists ::
-   GLsizei -> GLenum -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 listBase :: StateVar DisplayList
-listBase = makeStateVar (getEnum1 DisplayList GetListBase) glListBase
-
-foreign import CALLCONV unsafe "glListBase" glListBase :: DisplayList -> IO ()
+listBase = makeStateVar (getEnum1 DisplayList GetListBase) (\(DisplayList dl) -> glListBase dl)
diff --git a/Graphics/Rendering/OpenGL/GL/Domain.hs b/Graphics/Rendering/OpenGL/GL/Domain.hs
--- a/Graphics/Rendering/OpenGL/GL/Domain.hs
+++ b/Graphics/Rendering/OpenGL/GL/Domain.hs
@@ -17,16 +17,16 @@
    Domain(..)
 ) where
 
-import Foreign.Ptr ( Ptr )
-import Foreign.Storable ( Storable )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLenum, GLint, GLfloat, GLdouble )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName, getFloat2, getFloat4, getDouble2, getDouble4 )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLTypes.h"
+import Foreign.C.Types
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glEvalCoord1d, glEvalCoord1dv, glEvalCoord1f, glEvalCoord1fv, glEvalCoord2d,
+   glEvalCoord2dv, glEvalCoord2f, glEvalCoord2fv, glGetMapdv, glGetMapfv,
+   glMap1d, glMap1f, glMap2d, glMap2f, glMapGrid1d, glMapGrid1f, glMapGrid2d,
+   glMapGrid2f )
 
 --------------------------------------------------------------------------------
 
@@ -45,7 +45,8 @@
 
 --------------------------------------------------------------------------------
 
-instance Domain GLfloat_ where
+-- GLfloat instance
+instance Domain CFloat where
    glMap1      = glMap1f
    glMap2      = glMap2f
    glGetMapv   = glGetMapfv
@@ -58,41 +59,8 @@
    get2        = getFloat2
    get4        = getFloat4
 
-foreign import CALLCONV unsafe "glMap1f" glMap1f ::
-      GLenum
-   -> GLfloat -> GLfloat -> GLint -> GLint
-   -> Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glMap2f" glMap2f ::
-      GLenum
-   -> GLfloat -> GLfloat -> GLint -> GLint
-   -> GLfloat -> GLfloat -> GLint -> GLint
-   -> Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glGetMapfv" glGetMapfv ::
-   GLenum -> GLenum -> Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glEvalCoord1f" glEvalCoord1f ::
-   GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glEvalCoord1fv" glEvalCoord1fv ::
-   Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glEvalCoord2f" glEvalCoord2f ::
-   GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glEvalCoord2fv" glEvalCoord2fv ::
-   Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glMapGrid1f" glMapGrid1f ::
-   GLint -> GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glMapGrid2f" glMapGrid2f ::
-   GLint -> GLfloat -> GLfloat -> GLint -> GLfloat -> GLfloat -> IO ()
-
---------------------------------------------------------------------------------
-
-instance Domain GLdouble_ where
+-- GLdouble instance
+instance Domain CDouble where
    glMap1      = glMap1d
    glMap2      = glMap2d
    glGetMapv   = glGetMapdv
@@ -104,35 +72,3 @@
    glMapGrid2  = glMapGrid2d
    get2        = getDouble2
    get4        = getDouble4
-
-foreign import CALLCONV unsafe "glMap1d" glMap1d ::
-      GLenum
-   -> GLdouble -> GLdouble -> GLint -> GLint
-   -> Ptr GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glMap2d" glMap2d ::
-      GLenum
-   -> GLdouble -> GLdouble -> GLint -> GLint
-   -> GLdouble -> GLdouble -> GLint -> GLint
-   -> Ptr GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glGetMapdv" glGetMapdv ::
-   GLenum -> GLenum -> Ptr GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glEvalCoord1d" glEvalCoord1d ::
-   GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glEvalCoord1dv" glEvalCoord1dv ::
-   Ptr GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glEvalCoord2d" glEvalCoord2d ::
-   GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glEvalCoord2dv" glEvalCoord2dv ::
-   Ptr GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glMapGrid1d" glMapGrid1d ::
-   GLint -> GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glMapGrid2d" glMapGrid2d ::
-   GLint -> GLdouble -> GLdouble -> GLint -> GLdouble -> GLdouble -> IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/EdgeFlag.hs b/Graphics/Rendering/OpenGL/GL/EdgeFlag.hs
--- a/Graphics/Rendering/OpenGL/GL/EdgeFlag.hs
+++ b/Graphics/Rendering/OpenGL/GL/EdgeFlag.hs
@@ -17,9 +17,8 @@
    EdgeFlag(..), marshalEdgeFlag, unmarshalEdgeFlag
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLboolean )
-import Graphics.Rendering.OpenGL.GL.GLboolean (
-   marshalGLboolean, unmarshalGLboolean )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.GL.GLboolean
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/Evaluators.hs b/Graphics/Rendering/OpenGL/GL/Evaluators.hs
--- a/Graphics/Rendering/OpenGL/GL/Evaluators.hs
+++ b/Graphics/Rendering/OpenGL/GL/Evaluators.hs
@@ -43,33 +43,26 @@
    autoNormal
 ) where
 
-import Control.Monad ( zipWithM_ )
-import Data.List ( genericLength )
-import Foreign.ForeignPtr ( ForeignPtr, mallocForeignPtrArray, withForeignPtr )
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Marshal.Array ( allocaArray )
-import Foreign.Ptr ( Ptr, plusPtr )
-import Foreign.Storable ( Storable(peek,sizeOf) )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapAutoNormal), makeCapability, makeStateVarMaybe )
+import Control.Monad
+import Data.List
+import Data.StateVar
+import Foreign.ForeignPtr
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Array
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.Capability
 import Graphics.Rendering.OpenGL.GL.ControlPoint
 import Graphics.Rendering.OpenGL.GL.Domain
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLint, Capability )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek2, peek4 )
-import Graphics.Rendering.OpenGL.GL.PolygonMode ( marshalPolygonMode )
-import Graphics.Rendering.OpenGL.GL.Polygons ( PolygonMode )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetMaxEvalOrder,
-            GetMap1GridSegments,GetMap1GridDomain,
-            GetMap2GridSegments,GetMap2GridDomain),
-   getSizei1, getInteger1, getInteger2 )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.VertexArrays ( NumComponents, Stride )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLTypes.h"
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.PolygonMode
+import Graphics.Rendering.OpenGL.GL.Polygons
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.VertexArrays
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glEvalMesh1, glEvalMesh2, glEvalPoint1, glEvalPoint2, glGetMapiv, gl_COEFF,
+   gl_DOMAIN, gl_ORDER )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -176,14 +169,7 @@
 
 data (ControlPoint c, Domain d) => GLmap1 c d =
    GLmap1 (MapDescriptor d) (ForeignPtr d)
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq d => Eq (GLmap1 c d)
-instance Ord d => Ord (GLmap1 c d)
-instance Show d => Show (GLmap1 c d)
-#else
    deriving ( Eq, Ord, Show )
-#endif
 
 instance Map1 GLmap1 where
    withNewMap1 descriptor act = do
@@ -283,14 +269,7 @@
 
 data (ControlPoint c, Domain d) => GLmap2 c d =
    GLmap2 (MapDescriptor d)  (MapDescriptor d) (ForeignPtr d)
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq d => Eq (GLmap2 c d)
-instance Ord d => Ord (GLmap2 c d)
-instance Show d => Show (GLmap2 c d)
-#else
    deriving ( Eq, Ord, Show )
-#endif
 
 instance Map2 GLmap2 where
    withNewMap2 uDescriptor vDescriptor act = do
@@ -347,14 +326,9 @@
 
 marshalGetMapQuery :: GetMapQuery -> GLenum
 marshalGetMapQuery x = case x of
-   Coeff -> 0xa00
-   Order -> 0xa01
-   Domain -> 0xa02
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glGetMapiv" glGetMapiv ::
-   GLenum -> GLenum -> Ptr GLint -> IO ()
+   Coeff -> gl_COEFF
+   Order -> gl_ORDER
+   Domain -> gl_DOMAIN
 
 --------------------------------------------------------------------------------
 
@@ -379,25 +353,16 @@
 evalMesh1 :: PolygonMode -> (GLint, GLint) -> IO ()
 evalMesh1 m (p1, p2) = glEvalMesh1 (marshalPolygonMode m) p1 p2
 
-foreign import CALLCONV unsafe "glEvalMesh1" glEvalMesh1 ::
-   GLenum -> GLint -> GLint -> IO ()
-
 evalMesh2 :: PolygonMode -> (GLint, GLint) -> (GLint, GLint) -> IO ()
 evalMesh2 m (p1, p2) (q1, q2) = glEvalMesh2 (marshalPolygonMode m) p1 p2 q1 q2
 
-foreign import CALLCONV unsafe "glEvalMesh2" glEvalMesh2 ::
-   GLenum -> GLint -> GLint -> GLint -> GLint -> IO ()
-
 --------------------------------------------------------------------------------
 
-foreign import CALLCONV unsafe "glEvalPoint1" evalPoint1 ::
-   GLint -> IO ()
+evalPoint1 :: GLint -> IO ()
+evalPoint1 = glEvalPoint1
 
 evalPoint2 :: (GLint, GLint) -> IO ()
 evalPoint2 = uncurry glEvalPoint2
-
-foreign import CALLCONV unsafe "glEvalPoint2" glEvalPoint2 ::
-   GLint -> GLint -> IO ()
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/Exception.hs b/Graphics/Rendering/OpenGL/GL/Exception.hs
--- a/Graphics/Rendering/OpenGL/GL/Exception.hs
+++ b/Graphics/Rendering/OpenGL/GL/Exception.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 -- #hide
 --------------------------------------------------------------------------------
 -- |
diff --git a/Graphics/Rendering/OpenGL/GL/Extensions.hs b/Graphics/Rendering/OpenGL/GL/Extensions.hs
deleted file mode 100644
--- a/Graphics/Rendering/OpenGL/GL/Extensions.hs
+++ /dev/null
@@ -1,47 +0,0 @@
--- #hide
---------------------------------------------------------------------------------
--- |
--- Module      :  Graphics.Rendering.OpenGL.GL.Extensions
--- Copyright   :  (c) Sven Panne 2002-2009
--- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
--- 
--- Maintainer  :  sven.panne@aedion.de
--- Stability   :  stable
--- Portability :  portable
---
--- This is a purely internal module for handling the OpenGL extension
--- mechanism.
---
---------------------------------------------------------------------------------
-
-module Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO,
-   Invoker, getProcAddress   -- used only internally
-) where
-
-import Foreign.C.String ( CString, withCString )
-import Foreign.Ptr ( FunPtr, nullFunPtr )
-import System.IO.Unsafe ( unsafePerformIO )
-
-#ifdef __HUGS__
-{-# CFILES cbits/HsOpenGL.c #-}
-#endif
-
---------------------------------------------------------------------------------
-
-type Invoker a = FunPtr a -> a
-
-getProcAddress :: String -> String -> IO (FunPtr a)
-getProcAddress ext call =
-   throwIfNull ("unknown OpenGL call " ++ call ++ ", check for " ++ ext) $
-      withCString call hs_OpenGL_getProcAddress
-
-throwIfNull :: String -> IO (FunPtr a) -> IO (FunPtr a)
-throwIfNull msg act = do
-   res <- act
-   if res == nullFunPtr
-      then ioError (userError msg)
-      else return res
-
-foreign import ccall unsafe "hs_OpenGL_getProcAddress" hs_OpenGL_getProcAddress
-   :: CString -> IO (FunPtr a)
diff --git a/Graphics/Rendering/OpenGL/GL/Face.hs b/Graphics/Rendering/OpenGL/GL/Face.hs
--- a/Graphics/Rendering/OpenGL/GL/Face.hs
+++ b/Graphics/Rendering/OpenGL/GL/Face.hs
@@ -17,7 +17,7 @@
    Face(..), marshalFace, unmarshalFace
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -29,13 +29,13 @@
 
 marshalFace :: Face -> GLenum
 marshalFace x = case x of
-   Front -> 0x404
-   Back -> 0x405
-   FrontAndBack -> 0x408
+   Front -> gl_FRONT
+   Back -> gl_BACK
+   FrontAndBack -> gl_FRONT_AND_BACK
 
 unmarshalFace :: GLenum -> Face
 unmarshalFace x
-   | x == 0x404 = Front
-   | x == 0x405 = Back
-   | x == 0x408 = FrontAndBack
+   | x == gl_FRONT = Front
+   | x == gl_BACK = Back
+   | x == gl_FRONT_AND_BACK = FrontAndBack
    | otherwise = error ("unmarshalFace: illegal value " ++ show x)
diff --git a/Graphics/Rendering/OpenGL/GL/Feedback.hs b/Graphics/Rendering/OpenGL/GL/Feedback.hs
--- a/Graphics/Rendering/OpenGL/GL/Feedback.hs
+++ b/Graphics/Rendering/OpenGL/GL/Feedback.hs
@@ -17,20 +17,22 @@
    getFeedbackTokens, PassThroughValue(..), passThrough
 ) where
 
-import Control.Monad ( liftM2, liftM3, liftM4 )
-import Foreign.Marshal.Array ( allocaArray )
-import Foreign.Ptr ( Ptr, plusPtr )
-import Foreign.Storable ( Storable(sizeOf) )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLenum, GLint, GLsizei, GLfloat )
-import Graphics.Rendering.OpenGL.GL.IOState (
-   IOState, getIOState, peekIOState, evalIOState, nTimes )
-import Graphics.Rendering.OpenGL.GL.RenderMode ( withRenderMode )
-import Graphics.Rendering.OpenGL.GL.Selection ( RenderMode(Feedback) )
-import Graphics.Rendering.OpenGL.GL.StateVar ( HasGetter(get) )
-import Graphics.Rendering.OpenGL.GL.VertexSpec (
-   Vertex2(..), Vertex3(..), Vertex4(..), Index1(..), Color4(..),
-   TexCoord4(..), rgbaMode )
+import Control.Monad
+import Data.StateVar
+import Data.Tensor
+import Foreign.Marshal.Array
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.IOState
+import Graphics.Rendering.OpenGL.GL.RenderMode
+import Graphics.Rendering.OpenGL.GL.Selection
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glFeedbackBuffer, glPassThrough, gl_2D, gl_3D, gl_3D_COLOR,
+   gl_3D_COLOR_TEXTURE, gl_4D_COLOR_TEXTURE, gl_BITMAP_TOKEN,
+   gl_COPY_PIXEL_TOKEN, gl_DRAW_PIXEL_TOKEN, gl_LINE_RESET_TOKEN, gl_LINE_TOKEN,
+   gl_PASS_THROUGH_TOKEN, gl_POINT_TOKEN, gl_POLYGON_TOKEN )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -69,14 +71,14 @@
 
 unmarshalFeedbackTag :: GLenum -> FeedbackTag
 unmarshalFeedbackTag x
-   | x == 0x701 = PointTag
-   | x == 0x702 = LineTag
-   | x == 0x707 = LineResetTag
-   | x == 0x703 = PolygonTag
-   | x == 0x704 = BitmapTag
-   | x == 0x705 = DrawPixelTag
-   | x == 0x706 = CopyPixelTag
-   | x == 0x700 = PassThroughTag
+   | x == gl_POINT_TOKEN = PointTag
+   | x == gl_LINE_TOKEN = LineTag
+   | x == gl_LINE_RESET_TOKEN = LineResetTag
+   | x == gl_POLYGON_TOKEN = PolygonTag
+   | x == gl_BITMAP_TOKEN = BitmapTag
+   | x == gl_DRAW_PIXEL_TOKEN = DrawPixelTag
+   | x == gl_COPY_PIXEL_TOKEN = CopyPixelTag
+   | x == gl_PASS_THROUGH_TOKEN = PassThroughTag
    | otherwise = error ("unmarshalFeedbackTag: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
@@ -91,11 +93,11 @@
 
 marshalFeedbackType :: FeedbackType -> GLenum
 marshalFeedbackType x = case x of
-   TwoD -> 0x600
-   ThreeD -> 0x601
-   ThreeDColor -> 0x602
-   ThreeDColorTexture -> 0x603
-   FourDColorTexture -> 0x604
+   TwoD -> gl_2D
+   ThreeD -> gl_3D
+   ThreeDColor -> gl_3D_COLOR
+   ThreeDColorTexture -> gl_3D_COLOR_TEXTURE
+   FourDColorTexture -> gl_4D_COLOR_TEXTURE
 
 --------------------------------------------------------------------------------
 
@@ -108,9 +110,6 @@
       tokens <- parseFeedbackBuffer numValues buf feedbackType
       return (value, tokens)
 
-foreign import CALLCONV unsafe "glFeedbackBuffer" glFeedbackBuffer ::
-   GLsizei -> GLenum -> Ptr GLfloat -> IO ()
-
 --------------------------------------------------------------------------------
 
 parseFeedbackBuffer ::
@@ -199,5 +198,5 @@
 newtype PassThroughValue = PassThroughValue GLfloat
    deriving ( Eq, Ord, Show )
 
-foreign import CALLCONV unsafe "glPassThrough" passThrough ::
-   PassThroughValue -> IO ()
+passThrough :: PassThroughValue -> IO ()
+passThrough (PassThroughValue ptv) = glPassThrough ptv
diff --git a/Graphics/Rendering/OpenGL/GL/FlushFinish.hs b/Graphics/Rendering/OpenGL/GL/FlushFinish.hs
--- a/Graphics/Rendering/OpenGL/GL/FlushFinish.hs
+++ b/Graphics/Rendering/OpenGL/GL/FlushFinish.hs
@@ -17,6 +17,8 @@
    flush, finish      
 ) where
 
+import Graphics.Rendering.OpenGL.Raw.Core31
+
 --------------------------------------------------------------------------------
 
 -- | Different GL implementations buffer commands in several different
@@ -35,7 +37,8 @@
 -- Note that 'flush' can return at any time. It does not wait until the
 -- execution of all previously issued GL commands is complete.
 
-foreign import CALLCONV unsafe "glFlush" flush :: IO ()
+flush :: IO ()
+flush = glFlush
 
 -- | 'finish' does not return until the effects of all previously called GL
 -- commands are complete. Such effects include all changes to GL state, all
@@ -43,4 +46,5 @@
 -- 
 -- Note that 'finish' requires a round trip to the server.
 
-foreign import CALLCONV unsafe "glFinish" finish :: IO ()
+finish :: IO ()
+finish = glFinish
diff --git a/Graphics/Rendering/OpenGL/GL/Fog.hs b/Graphics/Rendering/OpenGL/GL/Fog.hs
--- a/Graphics/Rendering/OpenGL/GL/Fog.hs
+++ b/Graphics/Rendering/OpenGL/GL/Fog.hs
@@ -20,19 +20,17 @@
    FogDistanceMode(..), fogDistanceMode
 ) where
 
-import Foreign.Marshal.Utils ( with )
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapFog), makeCapability )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLenum, GLint, GLfloat, Capability )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetFogIndex,GetFogDensity,GetFogStart,GetFogEnd,GetFogMode,
-   GetFogColor,GetFogCoordSrc,GetFogDistanceMode),
-   getInteger1, getFloat1, getFloat4 )
-import Graphics.Rendering.OpenGL.GL.StateVar ( StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.VertexSpec (
-   Color4(Color4), Index1(Index1) )
+import Data.StateVar
+import Foreign.Marshal.Utils
+import Foreign.Ptr
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glFogf, glFogfv, glFogi, gl_EXP, gl_EXP2, gl_EYE_PLANE, gl_FOG_COLOR,
+   gl_FOG_COORD, gl_FOG_COORD_SRC, gl_FOG_DENSITY, gl_FOG_END, gl_FOG_INDEX,
+   gl_FOG_MODE, gl_FOG_START, gl_FRAGMENT_DEPTH )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -53,13 +51,14 @@
 
 marshalFogParameter :: FogParameter -> GLenum
 marshalFogParameter x = case x of
-   FogIndex -> 0xb61
-   FogDensity -> 0xb62
-   FogStart -> 0xb63
-   FogEnd -> 0xb64
-   FogMode -> 0xb65
-   FogColor -> 0xb66
-   FogCoordSrc -> 0x8450
+   FogIndex -> gl_FOG_INDEX
+   FogDensity -> gl_FOG_DENSITY
+   FogStart -> gl_FOG_START
+   FogEnd -> gl_FOG_END
+   FogMode -> gl_FOG_MODE
+   FogColor -> gl_FOG_COLOR
+   FogCoordSrc -> gl_FOG_COORD_SRC
+   -- TODO: Use FOG_DISTANCE_MODE_NV from NV_fog_distance extension
    FogDistanceMode -> 0x855a
 
 --------------------------------------------------------------------------------
@@ -70,17 +69,18 @@
    | Exp2'
 
 marshalFogMode' :: FogMode' -> GLint
-marshalFogMode' x = case x of
-   Linear' -> 0x2601
-   Exp' -> 0x800
-   Exp2' -> 0x801
+marshalFogMode' x = fromIntegral $ case x of
+   Linear' -> gl_LINEAR
+   Exp' -> gl_EXP
+   Exp2' -> gl_EXP2
 
 unmarshalFogMode' :: GLint -> FogMode'
 unmarshalFogMode' x
-   | x == 0x2601 = Linear'
-   | x == 0x800 = Exp'
-   | x == 0x801 = Exp2'
+   | y == gl_LINEAR = Linear'
+   | y == gl_EXP = Exp'
+   | y == gl_EXP2 = Exp2'
    | otherwise = error ("unmarshalFogMode': illegal value " ++ show x)
+   where y = fromIntegral x
 
 --------------------------------------------------------------------------------
 
@@ -123,18 +123,11 @@
 fogi :: FogParameter -> GLint -> IO ()
 fogi = glFogi . marshalFogParameter
 
-foreign import CALLCONV unsafe "glFogi" glFogi :: GLenum -> GLint -> IO ()
-
 fogf :: FogParameter -> GLfloat -> IO ()
 fogf = glFogf . marshalFogParameter
 
-foreign import CALLCONV unsafe "glFogf" glFogf :: GLenum -> GLfloat -> IO ()
-
 fogfv :: FogParameter -> Ptr (Color4 GLfloat) -> IO ()
-fogfv = glFogfv . marshalFogParameter
-
-foreign import CALLCONV unsafe "glFogfv" glFogfv ::
-   GLenum -> Ptr (Color4 GLfloat) -> IO ()
+fogfv param ptr = glFogfv (marshalFogParameter param) (castPtr ptr)
 
 --------------------------------------------------------------------------------
 
@@ -158,15 +151,16 @@
    deriving ( Eq, Ord, Show )
 
 marshalFogCoordSrc :: FogCoordSrc -> GLint
-marshalFogCoordSrc x = case x of
-   FogCoord -> 0x8451
-   FragmentDepth -> 0x8452
+marshalFogCoordSrc x = fromIntegral $ case x of
+   FogCoord -> gl_FOG_COORD
+   FragmentDepth -> gl_FRAGMENT_DEPTH
 
 unmarshalFogCoordSrc :: GLint -> FogCoordSrc
 unmarshalFogCoordSrc x
-   | x == 0x8451 = FogCoord
-   | x == 0x8452 = FragmentDepth
+   | y == gl_FOG_COORD = FogCoord
+   | y == gl_FRAGMENT_DEPTH = FragmentDepth
    | otherwise = error ("unmarshalFogCoordSrc: illegal value " ++ show x)
+   where y = fromIntegral x
 
 --------------------------------------------------------------------------------
 
@@ -185,17 +179,22 @@
    deriving ( Eq, Ord, Show )
 
 marshalFogDistanceMode :: FogDistanceMode -> GLint
-marshalFogDistanceMode x = case x of
+marshalFogDistanceMode x = fromIntegral $ case x of
+   -- TODO: Use EYE_RADIAL_NV from NV_fog_distance extension
    EyeRadial -> 0x855b
-   EyePlaneSigned -> 0x2502
+   EyePlaneSigned ->gl_EYE_PLANE
+   -- TODO: Use EYE_PLANE_ABSOLUTE_NV from NV_fog_distance extension
    EyePlaneAbsolute -> 0x855c
 
 unmarshalFogDistanceMode :: GLint -> FogDistanceMode
 unmarshalFogDistanceMode x
-   | x== 0x855b = EyeRadial
-   | x == 0x2502 = EyePlaneSigned
-   | x == 0x855c = EyePlaneAbsolute
+   -- TODO: Use EYE_RADIAL_NV from NV_fog_distance extension
+   | y == 0x855b = EyeRadial
+   | y == gl_EYE_PLANE = EyePlaneSigned
+   -- TODO: Use EYE_PLANE_ABSOLUTE_NV from NV_fog_distance extension
+   | y == 0x855c = EyePlaneAbsolute
    | otherwise = error ("unmarshalFogDistanceMode: illegal value " ++ show x)
+   where y = fromIntegral x
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/Framebuffer.hs b/Graphics/Rendering/OpenGL/GL/Framebuffer.hs
--- a/Graphics/Rendering/OpenGL/GL/Framebuffer.hs
+++ b/Graphics/Rendering/OpenGL/GL/Framebuffer.hs
@@ -32,50 +32,22 @@
    AccumOp(..), accum
 ) where
 
-import Control.Monad ( liftM4 )
-import Data.List ( genericLength )
-import Data.Maybe ( isJust, fromJust )
-import Foreign.Marshal.Array ( withArray )
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BufferMode (
-   BufferMode(..), marshalBufferMode, unmarshalBufferMode )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   marshalCapability, unmarshalCapability )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLenum, GLsizei, GLint, GLuint, GLbitfield, GLfloat, GLclampf,
-   GLclampd,
-#ifdef __HADDOCK__
-   Capability(..)
-#else
-   Capability
-#endif
-   )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.Face ( Face, marshalFace )
-import Graphics.Rendering.OpenGL.GL.GLboolean ( unmarshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetAuxBuffers,GetDoublebuffer,GetStereo,GetRedBits,GetGreenBits,
-            GetBlueBits,GetAlphaBits,GetStencilBits,GetDepthBits,
-            GetAccumRedBits,GetAccumGreenBits,GetAccumBlueBits,
-            GetAccumAlphaBits,GetRGBASignedComponents,GetDrawBuffer,
-            GetIndexWritemask,GetColorWritemask,GetDepthWritemask,
-            GetStencilWritemask,GetColorClearValue,GetIndexClearValue,
-            GetDepthClearValue,GetStencilClearValue,GetAccumClearValue,
-            GetMaxDrawBuffers,GetDrawBufferN),
-   getInteger1, getInteger4, getBoolean1, getBoolean4, getEnum1, getSizei1,
-   getFloat1, getFloat4, getDouble1 )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   HasGetter(get), GettableStateVar, makeGettableStateVar,
-   SettableStateVar, makeSettableStateVar,
-   StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.VertexSpec (
-   Color4(Color4), Index1(Index1) )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal ( recordInvalidValue )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
+import Control.Monad
+import Data.List
+import Data.Maybe
+import Data.StateVar
+import Foreign.Marshal.Array
+import Graphics.Rendering.OpenGL.GL.BufferMode
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.Face
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glAccum, glClearAccum, glClearIndex, glIndexMask, gl_ACCUM,
+   gl_ACCUM_BUFFER_BIT, gl_ADD, gl_LOAD, gl_MULT, gl_RETURN )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -150,9 +122,6 @@
       (getEnum1 unmarshalBufferMode GetDrawBuffer)
       (maybe recordInvalidValue glDrawBuffer . marshalBufferMode)
 
-foreign import CALLCONV unsafe "glDrawBuffer" glDrawBuffer ::
-   GLenum -> IO ()
-
 --------------------------------------------------------------------------------
 
 -- | 'drawBuffers' defines the draw buffers to which all fragment colors are
@@ -192,8 +161,6 @@
               glDrawBuffers (genericLength ms)
       else recordInvalidValue
 
-EXTENSION_ENTRY("GL_ARB_draw_buffers or OpenGL 2.0",glDrawBuffers,GLsizei -> Ptr GLenum -> IO ())
-
 --------------------------------------------------------------------------------
 
 -- | Contains the maximum number of buffers that can activated via 'drawBuffers'
@@ -221,8 +188,6 @@
 indexMask =
    makeStateVar (getInteger1 fromIntegral GetIndexWritemask) glIndexMask
 
-foreign import CALLCONV unsafe "glIndexMask" glIndexMask :: GLuint -> IO ()
-
 --------------------------------------------------------------------------------
 
 -- | Controls whether the individual color components in the framebuffer can or
@@ -248,9 +213,6 @@
                                         (marshalCapability b)
                                         (marshalCapability a))
 
-foreign import CALLCONV unsafe "glColorMask" glColorMask ::
-   GLboolean -> GLboolean -> GLboolean -> GLboolean -> IO ()
-
 --------------------------------------------------------------------------------
 
 -- | Controls whether the depth buffer is enabled for writing. The initial state
@@ -260,8 +222,6 @@
 depthMask = makeStateVar (getBoolean1 unmarshalCapability GetDepthWritemask)
                          (glDepthMask . marshalCapability)
 
-foreign import CALLCONV unsafe "glDepthMask" glDepthMask :: GLboolean -> IO ()
-
 --------------------------------------------------------------------------------
 
 -- | Controls the writing of individual bits in the stencil planes. The least
@@ -275,15 +235,11 @@
 stencilMask =
    makeStateVar (getInteger1 fromIntegral GetStencilWritemask) glStencilMask
 
-foreign import CALLCONV unsafe "glStencilMask" glStencilMask :: GLuint -> IO ()
-
 stencilMaskSeparate :: Face -> SettableStateVar GLuint
 stencilMaskSeparate face =
    makeSettableStateVar $
       glStencilMaskSeparate (marshalFace face)
 
-EXTENSION_ENTRY("OpenGL 2.0",glStencilMaskSeparate,GLenum -> GLuint -> IO ())
-
 --------------------------------------------------------------------------------
 
 -- | The buffers which can be cleared with 'clear'.
@@ -297,10 +253,10 @@
 
 marshalClearBuffer :: ClearBuffer -> GLbitfield
 marshalClearBuffer x = case x of
-   ColorBuffer -> 0x4000
-   AccumBuffer -> 0x200
-   StencilBuffer -> 0x400
-   DepthBuffer -> 0x100
+   ColorBuffer -> gl_COLOR_BUFFER_BIT
+   AccumBuffer -> gl_ACCUM_BUFFER_BIT
+   StencilBuffer -> gl_STENCIL_BUFFER_BIT
+   DepthBuffer -> gl_DEPTH_BUFFER_BIT
 
 --------------------------------------------------------------------------------
 
@@ -324,8 +280,6 @@
 clear :: [ClearBuffer] -> IO ()
 clear = glClear . sum . map marshalClearBuffer
 
-foreign import CALLCONV unsafe "glClear" glClear :: GLbitfield -> IO ()
-
 --------------------------------------------------------------------------------
 
 -- | Controls the red, green, blue, and alpha values used by 'clear' to clear
@@ -336,9 +290,6 @@
 clearColor = makeStateVar (getFloat4 Color4 GetColorClearValue)
                           (\(Color4 r g b a) -> glClearColor r g b a)
 
-foreign import CALLCONV unsafe "glClearColor" glClearColor ::
-    GLclampf -> GLclampf -> GLclampf -> GLclampf -> IO ()
-
 --------------------------------------------------------------------------------
 
 -- | Controls the index /c/ used by 'clear' to clear the color index buffers.
@@ -351,8 +302,6 @@
 clearIndex = makeStateVar (getFloat1 Index1 GetIndexClearValue)
                           (\(Index1 i) -> glClearIndex i)
 
-foreign import CALLCONV unsafe "glClearIndex" glClearIndex :: GLfloat -> IO ()
-
 --------------------------------------------------------------------------------
 
 -- | Controls the depth value used by 'clear' to clear the depth buffer. Values
@@ -362,8 +311,6 @@
 clearDepth :: StateVar GLclampd
 clearDepth = makeStateVar (getDouble1 id GetDepthClearValue) glClearDepth
 
-foreign import CALLCONV unsafe "glClearDepth" glClearDepth :: GLclampd -> IO ()
-
 --------------------------------------------------------------------------------
 
 -- | Controls the value /s/ used by 'clear' to clear the stencil buffer. /s/ is
@@ -373,8 +320,6 @@
 clearStencil :: StateVar GLint
 clearStencil = makeStateVar (getInteger1 id GetStencilClearValue) glClearStencil
 
-foreign import CALLCONV unsafe "glClearStencil" glClearStencil :: GLint -> IO ()
-
 --------------------------------------------------------------------------------
 
 -- | Controls the red, green, blue, and alpha values used by 'clear' to clear
@@ -386,9 +331,6 @@
    makeStateVar (getFloat4 Color4 GetAccumClearValue)
                 (\(Color4 r g b a) -> glClearAccum r g b a)
 
-foreign import CALLCONV unsafe "glClearAccum" glClearAccum ::
-   GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ()
-
 --------------------------------------------------------------------------------
 
 -- | An operation on the accumulation buffer.
@@ -430,11 +372,11 @@
 
 marshalAccumOp :: AccumOp -> GLenum
 marshalAccumOp x = case x of
-   Accum -> 0x100
-   Load -> 0x101
-   Return -> 0x102
-   Mult -> 0x103
-   Add -> 0x104
+   Accum -> gl_ACCUM
+   Load -> gl_LOAD
+   Return -> gl_RETURN
+   Mult -> gl_MULT
+   Add -> gl_ADD
 
 --------------------------------------------------------------------------------
 
@@ -466,5 +408,3 @@
 
 accum :: AccumOp -> GLfloat -> IO ()
 accum = glAccum . marshalAccumOp
-
-foreign import CALLCONV unsafe "glAccum" glAccum :: GLenum -> GLfloat -> IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/GLboolean.hs b/Graphics/Rendering/OpenGL/GL/GLboolean.hs
--- a/Graphics/Rendering/OpenGL/GL/GLboolean.hs
+++ b/Graphics/Rendering/OpenGL/GL/GLboolean.hs
@@ -17,11 +17,14 @@
    marshalGLboolean, unmarshalGLboolean
 ) where
 
+import Graphics.Rendering.OpenGL.Raw.Core31
+
 --------------------------------------------------------------------------------
 
 marshalGLboolean :: Num a => Bool -> a
-marshalGLboolean False = 0
-marshalGLboolean True  = 1
+marshalGLboolean x = fromIntegral $ case x of
+   False -> gl_FALSE
+   True -> gl_TRUE
 
-unmarshalGLboolean :: (Eq a, Num a) => a -> Bool
-unmarshalGLboolean = (/= 0)
+unmarshalGLboolean :: Num a => a -> Bool
+unmarshalGLboolean = (/= fromIntegral gl_FALSE)
diff --git a/Graphics/Rendering/OpenGL/GL/Hints.hs b/Graphics/Rendering/OpenGL/GL/Hints.hs
--- a/Graphics/Rendering/OpenGL/GL/Hints.hs
+++ b/Graphics/Rendering/OpenGL/GL/Hints.hs
@@ -16,13 +16,14 @@
    HintTarget(..), HintMode(..), hint
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetPerspectiveCorrectionHint,GetPointSmoothHint,GetLineSmoothHint,
-            GetPolygonSmoothHint,GetFogHint,GetGenerateMipmapHint,
-            GetTextureCompressionHint,GetPackCMYKHint,GetUnpackCMYKHint),
-   getEnum1 )
-import Graphics.Rendering.OpenGL.GL.StateVar ( StateVar, makeStateVar )
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   gl_FOG_HINT, gl_GENERATE_MIPMAP_HINT, gl_PERSPECTIVE_CORRECTION_HINT,
+   gl_POINT_SMOOTH_HINT )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.EXT.Cmyka (
+   gl_PACK_CMYK_HINT, gl_UNPACK_CMYK_HINT )
 
 --------------------------------------------------------------------------------
 
@@ -40,15 +41,15 @@
 
 marshalHintTarget :: HintTarget -> GLenum
 marshalHintTarget x = case x of
-   PerspectiveCorrection -> 0xc50
-   PointSmooth -> 0xc51
-   LineSmooth -> 0xc52
-   PolygonSmooth -> 0xc53
-   Fog -> 0xc54
-   GenerateMipmap -> 0x8192
-   TextureCompression -> 0x84ef
-   PackCMYK -> 0x800e
-   UnpackCMYK -> 0x800f
+   PerspectiveCorrection -> gl_PERSPECTIVE_CORRECTION_HINT
+   PointSmooth -> gl_POINT_SMOOTH_HINT
+   LineSmooth -> gl_LINE_SMOOTH_HINT
+   PolygonSmooth -> gl_POLYGON_SMOOTH_HINT
+   Fog -> gl_FOG_HINT
+   GenerateMipmap -> gl_GENERATE_MIPMAP_HINT
+   TextureCompression -> gl_TEXTURE_COMPRESSION_HINT
+   PackCMYK -> gl_PACK_CMYK_HINT
+   UnpackCMYK -> gl_UNPACK_CMYK_HINT
 
 hintTargetToGetPName :: HintTarget -> GetPName
 hintTargetToGetPName x = case x of
@@ -72,15 +73,15 @@
 
 marshalHintMode :: HintMode -> GLenum
 marshalHintMode x = case x of
-   DontCare -> 0x1100
-   Fastest -> 0x1101
-   Nicest -> 0x1102
+   DontCare -> gl_DONT_CARE
+   Fastest -> gl_FASTEST
+   Nicest -> gl_NICEST
 
 unmarshalHintMode :: GLenum -> HintMode
 unmarshalHintMode x
-   | x == 0x1100 = DontCare
-   | x == 0x1101 = Fastest
-   | x == 0x1102 = Nicest
+   | x == gl_DONT_CARE = DontCare
+   | x == gl_FASTEST = Fastest
+   | x == gl_NICEST = Nicest
    | otherwise = error ("unmarshalHintMode: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
@@ -90,5 +91,3 @@
    makeStateVar
       (getEnum1 unmarshalHintMode (hintTargetToGetPName t))
       (glHint (marshalHintTarget t) . marshalHintMode)
-
-foreign import CALLCONV unsafe "glHint" glHint :: GLenum -> GLenum -> IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/LineSegments.hs b/Graphics/Rendering/OpenGL/GL/LineSegments.hs
--- a/Graphics/Rendering/OpenGL/GL/LineSegments.hs
+++ b/Graphics/Rendering/OpenGL/GL/LineSegments.hs
@@ -27,18 +27,12 @@
    aliasedLineWidthRange, smoothLineWidthRange, smoothLineWidthGranularity
 ) where
 
-import Control.Monad ( liftM2 )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapLineSmooth,CapLineStipple), makeCapability, makeStateVarMaybe )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLint, GLushort, GLfloat, Capability )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetLineWidth,GetAliasedLineWidthRange,GetSmoothLineWidthRange,
-            GetSmoothLineWidthGranularity,GetLineStippleRepeat,
-            GetLineStipplePattern),
-   getInteger1, getFloat1, getFloat2 )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
+import Control.Monad
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility ( glLineStipple )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -88,8 +82,6 @@
 lineWidth :: StateVar GLfloat
 lineWidth = makeStateVar (getFloat1 id GetLineWidth) glLineWidth
 
-foreign import CALLCONV unsafe "glLineWidth" glLineWidth :: GLfloat -> IO ()
-
 --------------------------------------------------------------------------------
 
 -- | Line stippling masks out certain fragments produced by rasterization; those
@@ -129,13 +121,10 @@
                   (getInteger1 fromIntegral GetLineStipplePattern))
       (uncurry glLineStipple)
 
-foreign import CALLCONV unsafe "glLineStipple" glLineStipple ::
-   GLint -> GLushort -> IO ()
-
 --------------------------------------------------------------------------------
 
 -- | Controls whether line antialiasing is enabled. The initial state is
--- 'Graphics.Rendering.OpenGL.GL.BasicTypes.Disabled'.
+-- 'Graphics.Rendering.OpenGL.GL.Capability.Disabled'.
 
 lineSmooth :: StateVar Capability
 lineSmooth = makeCapability CapLineSmooth
diff --git a/Graphics/Rendering/OpenGL/GL/PeekPoke.hs b/Graphics/Rendering/OpenGL/GL/PeekPoke.hs
--- a/Graphics/Rendering/OpenGL/GL/PeekPoke.hs
+++ b/Graphics/Rendering/OpenGL/GL/PeekPoke.hs
@@ -19,8 +19,8 @@
    peek1M, peek2M, peek3M, peek4M
 ) where
 
-import Foreign.Ptr ( Ptr )
-import Foreign.Storable ( Storable(peekElemOff,pokeElemOff) )
+import Foreign.Ptr
+import Foreign.Storable
 
 --------------------------------------------------------------------------------
 -- The implementation is little bit verbose/redundant, but seems to generate
diff --git a/Graphics/Rendering/OpenGL/GL/PerFragment.hs b/Graphics/Rendering/OpenGL/GL/PerFragment.hs
--- a/Graphics/Rendering/OpenGL/GL/PerFragment.hs
+++ b/Graphics/Rendering/OpenGL/GL/PerFragment.hs
@@ -50,52 +50,26 @@
    LogicOp(..), logicOp
 ) where
 
-import Control.Monad ( liftM2, liftM3 )
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Marshal.Array ( withArrayLen, peekArray, allocaArray )
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BufferObjects ( ObjectName(..) )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapScissorTest,CapSampleAlphaToCoverage,CapSampleAlphaToOne,
-             CapSampleCoverage,CapDepthBoundsTest,CapAlphaTest,CapStencilTest,
-             CapStencilTestTwoSide,CapDepthTest,CapBlend,CapDither,
-             CapIndexLogicOp,CapColorLogicOp),
-   makeCapability, makeStateVarMaybe )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLint, GLuint, GLsizei, GLenum, GLclampf, GLclampd, Capability )
-import Graphics.Rendering.OpenGL.GL.BlendingFactor (
-   BlendingFactor(..), marshalBlendingFactor, unmarshalBlendingFactor )
-import Graphics.Rendering.OpenGL.GL.ComparisonFunction ( ComparisonFunction(..),
-   marshalComparisonFunction, unmarshalComparisonFunction )
-import Graphics.Rendering.OpenGL.GL.CoordTrans ( Position(..), Size(..) )
-import Graphics.Rendering.OpenGL.GL.Exception ( bracket_ )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.Face ( marshalFace, unmarshalFace )
-import Graphics.Rendering.OpenGL.GL.Colors ( Face )
-import Graphics.Rendering.OpenGL.GL.GLboolean (
-   marshalGLboolean, unmarshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1 )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetScissorBox,GetSampleCoverageValue,GetSampleCoverageInvert,
-            GetDepthBounds,GetAlphaTestFunc,GetAlphaTestRef,GetStencilFunc,
-            GetStencilRef,GetStencilValueMask,GetStencilFail,
-            GetStencilPassDepthFail,GetStencilPassDepthPass,
-            GetActiveStencilFace,GetDepthFunc,GetBlendEquation,
-            GetBlendEquationAlpha,GetBlendDstRGB,GetBlendSrcRGB,
-            GetBlendDstAlpha,GetBlendSrcAlpha,GetBlendSrc,GetBlendDst,
-            GetBlendColor,GetLogicOpMode),
-   getInteger1, getInteger4, getEnum1, getFloat1, getFloat4, getDouble2,
-   getBoolean1 )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   HasGetter(get), GettableStateVar, makeGettableStateVar,
-   SettableStateVar, makeSettableStateVar,
-   StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.VertexSpec ( Color4(..), rgbaMode )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
+import Control.Monad
+import Data.ObjectName
+import Data.StateVar
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Array
+import Graphics.Rendering.OpenGL.GL.BlendingFactor
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.ComparisonFunction
+import Graphics.Rendering.OpenGL.GL.CoordTrans
+import Graphics.Rendering.OpenGL.GL.Exception
+import Graphics.Rendering.OpenGL.GL.Face
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glAlphaFunc, gl_INDEX_LOGIC_OP )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.EXT.DepthBoundsTest ( glDepthBounds )
+import Graphics.Rendering.OpenGL.Raw.EXT.StencilTwoSide ( glActiveStencilFace )
 
 --------------------------------------------------------------------------------
 
@@ -106,9 +80,6 @@
       (getInteger4 makeSB GetScissorBox)
       (\(Position x y, Size w h) -> glScissor x y w h)
    where makeSB x y w h = (Position x y, Size (fromIntegral w) (fromIntegral h))
-       
-foreign import CALLCONV unsafe "glScissor" glScissor ::
-   GLint -> GLint -> GLsizei -> GLsizei -> IO ()
 
 --------------------------------------------------------------------------------
 
@@ -124,9 +95,7 @@
       (return CapSampleCoverage)
       (liftM2 (,) (getFloat1 id GetSampleCoverageValue)
                   (getBoolean1 unmarshalGLboolean GetSampleCoverageInvert))
-      (\(value, invert) -> glSampleCoverageARB value (marshalGLboolean invert))
-
-EXTENSION_ENTRY("GL_ARB_multisample or OpenGL 1.3",glSampleCoverageARB,GLclampf -> GLboolean -> IO ())
+      (\(value, invert) -> glSampleCoverage value (marshalGLboolean invert))
 
 --------------------------------------------------------------------------------
 
@@ -135,9 +104,7 @@
    makeStateVarMaybe
       (return CapDepthBoundsTest)
       (getDouble2 (,) GetDepthBounds)
-      (uncurry glDepthBoundsEXT)
-       
-EXTENSION_ENTRY("GL_EXT_depth_bounds_test",glDepthBoundsEXT,GLclampd -> GLclampd -> IO ())
+      (uncurry glDepthBounds)
 
 --------------------------------------------------------------------------------
 
@@ -149,9 +116,6 @@
                   (getFloat1 id GetAlphaTestRef))
       (uncurry (glAlphaFunc . marshalComparisonFunction))
 
-foreign import CALLCONV unsafe "glAlphaFunc" glAlphaFunc ::
-   GLenum -> GLclampf -> IO ()
-
 --------------------------------------------------------------------------------
 
 stencilTest :: StateVar Capability
@@ -168,16 +132,11 @@
       (\(func, ref, mask) ->
          glStencilFunc (marshalComparisonFunction func) ref mask)
 
-foreign import CALLCONV unsafe "glStencilFunc" glStencilFunc ::
-   GLenum -> GLint -> GLuint -> IO ()
-
 stencilFuncSeparate :: Face -> SettableStateVar (ComparisonFunction, GLint, GLuint)
 stencilFuncSeparate face =
    makeSettableStateVar $ \(func, ref, mask) ->
       glStencilFuncSeparate (marshalFace face) (marshalComparisonFunction func) ref mask
 
-EXTENSION_ENTRY("OpenGL 2.0",glStencilFuncSeparate,GLenum -> GLenum -> GLint -> GLuint -> IO ())
-
 --------------------------------------------------------------------------------
 
 data StencilOp =
@@ -193,25 +152,25 @@
 
 marshalStencilOp :: StencilOp -> GLenum
 marshalStencilOp x = case x of
-   OpZero -> 0x0
-   OpKeep -> 0x1e00
-   OpReplace -> 0x1e01
-   OpIncr -> 0x1e02
-   OpIncrWrap -> 0x8507
-   OpDecr -> 0x1e03
-   OpDecrWrap -> 0x8508
-   OpInvert -> 0x150a
+   OpZero -> gl_ZERO
+   OpKeep -> gl_KEEP
+   OpReplace -> gl_REPLACE
+   OpIncr -> gl_INCR
+   OpIncrWrap -> gl_INCR_WRAP
+   OpDecr -> gl_DECR
+   OpDecrWrap -> gl_DECR_WRAP
+   OpInvert -> gl_INVERT
 
 unmarshalStencilOp :: GLenum -> StencilOp
 unmarshalStencilOp x
-   | x == 0x0 = OpZero
-   | x == 0x1e00 = OpKeep
-   | x == 0x1e01 = OpReplace
-   | x == 0x1e02 = OpIncr
-   | x == 0x8507 = OpIncrWrap
-   | x == 0x1e03 = OpDecr
-   | x == 0x8508 = OpDecrWrap
-   | x == 0x150a = OpInvert
+   | x == gl_ZERO = OpZero
+   | x == gl_KEEP = OpKeep
+   | x == gl_REPLACE = OpReplace
+   | x == gl_INCR = OpIncr
+   | x == gl_INCR_WRAP = OpIncrWrap
+   | x == gl_DECR = OpDecr
+   | x == gl_DECR_WRAP = OpDecrWrap
+   | x == gl_INVERT = OpInvert
    | otherwise = error ("unmarshalStencilOp: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
@@ -226,9 +185,6 @@
                                         (marshalStencilOp spdf)
                                         (marshalStencilOp spdp))
 
-foreign import CALLCONV unsafe "glStencilOp" glStencilOp ::
-   GLenum -> GLenum -> GLenum -> IO ()
-
 stencilOpSeparate :: Face -> SettableStateVar (StencilOp, StencilOp, StencilOp)
 stencilOpSeparate face =
    makeSettableStateVar $ \(sf, spdf, spdp) ->
@@ -237,8 +193,6 @@
                           (marshalStencilOp spdf)
                           (marshalStencilOp spdp)
 
-EXTENSION_ENTRY("OpenGL 2.0",glStencilOpSeparate,GLenum -> GLenum -> GLenum -> GLenum -> IO ())
-
 --------------------------------------------------------------------------------
 
 activeStencilFace :: StateVar (Maybe Face)
@@ -246,9 +200,7 @@
    makeStateVarMaybe
       (return CapStencilTestTwoSide)
       (getEnum1 unmarshalFace GetActiveStencilFace)
-      (glActiveStencilFaceEXT . marshalFace)
-
-EXTENSION_ENTRY("GL_EXT_stencil_two_side",glActiveStencilFaceEXT,GLenum -> IO ())
+      (glActiveStencilFace . marshalFace)
 
 --------------------------------------------------------------------------------
 
@@ -259,8 +211,6 @@
       (getEnum1 unmarshalComparisonFunction GetDepthFunc)
       (glDepthFunc . marshalComparisonFunction)
 
-foreign import CALLCONV unsafe "glDepthFunc" glDepthFunc :: GLenum -> IO ()
-
 --------------------------------------------------------------------------------
 
 newtype QueryObject = QueryObject { queryID :: GLuint }
@@ -271,21 +221,14 @@
 instance ObjectName QueryObject where
    genObjectNames n =
       allocaArray n $ \buf -> do
-        glGenQueriesARB (fromIntegral n) buf
+        glGenQueries (fromIntegral n) buf
         fmap (map QueryObject) $ peekArray n buf
 
    deleteObjectNames queryObjects =
       withArrayLen (map queryID queryObjects) $
-         glDeleteQueriesARB . fromIntegral
-
-   isObjectName = fmap unmarshalGLboolean . glIsQueryARB . queryID
-
-
-EXTENSION_ENTRY("GL_ARB_occlusion_query or OpenGL 1.5",glGenQueriesARB,GLsizei -> Ptr GLuint -> IO ())
-
-EXTENSION_ENTRY("GL_ARB_occlusion_query or OpenGL 1.5",glDeleteQueriesARB,GLsizei -> Ptr GLuint -> IO ())
+         glDeleteQueries . fromIntegral
 
-EXTENSION_ENTRY("GL_ARB_occlusion_query or OpenGL 1.5",glIsQueryARB,GLuint -> IO GLboolean)
+   isObjectName = fmap unmarshalGLboolean . glIsQuery . queryID
 
 --------------------------------------------------------------------------------
 
@@ -295,19 +238,15 @@
 
 marshalQueryTarget :: QueryTarget -> GLenum
 marshalQueryTarget x = case x of
-   SamplesPassed -> 0x8914
+   SamplesPassed -> gl_SAMPLES_PASSED
 
 --------------------------------------------------------------------------------
 
 beginQuery :: QueryTarget -> QueryObject -> IO ()
-beginQuery t = glBeginQueryARB (marshalQueryTarget t) . queryID
-
-EXTENSION_ENTRY("GL_ARB_occlusion_query or OpenGL 1.5",glBeginQueryARB,GLenum -> GLuint -> IO ())
+beginQuery t = glBeginQuery (marshalQueryTarget t) . queryID
 
 endQuery :: QueryTarget -> IO ()
-endQuery = glEndQueryARB . marshalQueryTarget
-
-EXTENSION_ENTRY("GL_ARB_occlusion_query or OpenGL 1.5",glEndQueryARB,GLenum -> IO ())
+endQuery = glEndQuery . marshalQueryTarget
 
 -- | Convenience function for an exception-safe combination of 'beginQuery' and
 -- 'endQuery'.
@@ -322,8 +261,8 @@
 
 marshalGetQueryPName :: GetQueryPName -> GLenum
 marshalGetQueryPName x = case x of
-   QueryCounterBits -> 0x8864
-   CurrentQuery -> 0x8865
+   QueryCounterBits -> gl_QUERY_COUNTER_BITS
+   CurrentQuery -> gl_CURRENT_QUERY
 
 --------------------------------------------------------------------------------
 
@@ -340,11 +279,9 @@
 getQueryi f p t =
    makeGettableStateVar $
       alloca $ \buf -> do
-         glGetQueryivARB (marshalQueryTarget t) (marshalGetQueryPName p) buf
+         glGetQueryiv (marshalQueryTarget t) (marshalGetQueryPName p) buf
          peek1 f buf
 
-EXTENSION_ENTRY("GL_ARB_occlusion_query or OpenGL 1.5",glGetQueryivARB,GLenum -> GLenum -> Ptr GLint -> IO ())
-
 --------------------------------------------------------------------------------
 
 data GetQueryObjectPName =
@@ -353,8 +290,8 @@
 
 marshalGetQueryObjectPName :: GetQueryObjectPName -> GLenum
 marshalGetQueryObjectPName x = case x of
-   QueryResult -> 0x8866
-   QueryResultAvailable -> 0x8867
+   QueryResult -> gl_QUERY_RESULT
+   QueryResultAvailable -> gl_QUERY_RESULT_AVAILABLE
 
 --------------------------------------------------------------------------------
 
@@ -369,11 +306,9 @@
 getQueryObjectui f p q =
    makeGettableStateVar $
       alloca $ \buf -> do
-         glGetQueryObjectuivARB (queryID q) (marshalGetQueryObjectPName p) buf
+         glGetQueryObjectuiv (queryID q) (marshalGetQueryObjectPName p) buf
          peek1 f buf
 
-EXTENSION_ENTRY("GL_ARB_occlusion_query or OpenGL 1.5",glGetQueryObjectuivARB,GLuint -> GLenum -> Ptr GLuint -> IO ())
-
 --------------------------------------------------------------------------------
 
 blend :: StateVar Capability
@@ -392,21 +327,21 @@
 
 marshalBlendEquation :: BlendEquation -> GLenum
 marshalBlendEquation x = case x of
-   FuncAdd -> 0x8006
-   FuncSubtract -> 0x800a
-   FuncReverseSubtract -> 0x800b
-   Min -> 0x8007
-   Max -> 0x8008
-   LogicOp -> 0xbf1
+   FuncAdd -> gl_FUNC_ADD
+   FuncSubtract -> gl_FUNC_SUBTRACT
+   FuncReverseSubtract -> gl_FUNC_REVERSE_SUBTRACT
+   Min -> gl_MIN
+   Max -> gl_MAX
+   LogicOp -> gl_INDEX_LOGIC_OP
 
 unmarshalBlendEquation :: GLenum -> BlendEquation
 unmarshalBlendEquation x
-   | x == 0x8006 = FuncAdd
-   | x == 0x800a = FuncSubtract
-   | x == 0x800b = FuncReverseSubtract
-   | x == 0x8007 = Min
-   | x == 0x8008 = Max
-   | x == 0xbf1 = LogicOp
+   | x == gl_FUNC_ADD = FuncAdd
+   | x == gl_FUNC_SUBTRACT = FuncSubtract
+   | x == gl_FUNC_REVERSE_SUBTRACT = FuncReverseSubtract
+   | x == gl_MIN = Min
+   | x == gl_MAX = Max
+   | x == gl_INDEX_LOGIC_OP = LogicOp
    | otherwise = error ("unmarshalBlendEquation: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
@@ -415,9 +350,7 @@
 blendEquation =
    makeStateVar
       (getEnum1 unmarshalBlendEquation GetBlendEquation)
-      (glBlendEquationEXT . marshalBlendEquation)
-
-EXTENSION_ENTRY("GL_EXT_blend_minmax or GL_EXT_blend_subtract or OpenGL 1.4",glBlendEquationEXT,GLenum -> IO ())
+      (glBlendEquation . marshalBlendEquation)
 
 blendEquationSeparate :: StateVar (BlendEquation,BlendEquation)
 blendEquationSeparate =
@@ -428,8 +361,6 @@
           glBlendEquationSeparate (marshalBlendEquation funcRGB)
                                   (marshalBlendEquation funcAlpha))
 
-EXTENSION_ENTRY("GL_EXT_blend_equation_separate or OpenGL 2.0",glBlendEquationSeparate,GLenum -> GLenum -> IO ())
-
 --------------------------------------------------------------------------------
 
 blendFuncSeparate ::
@@ -442,12 +373,10 @@
           dstAlpha <- getEnum1 unmarshalBlendingFactor GetBlendDstAlpha
           return ((srcRGB, srcAlpha), (dstRGB, dstAlpha)))
       (\((srcRGB, srcAlpha), (dstRGB, dstAlpha)) ->
-         glBlendFuncSeparateEXT (marshalBlendingFactor srcRGB)
-                                (marshalBlendingFactor srcAlpha)
-                                (marshalBlendingFactor dstRGB)
-                                (marshalBlendingFactor dstAlpha))
-
-EXTENSION_ENTRY("GL_EXT_blend_func_separate or OpenGL 1.4",glBlendFuncSeparateEXT,GLenum -> GLenum -> GLenum -> GLenum -> IO ())
+         glBlendFuncSeparate (marshalBlendingFactor srcRGB)
+                             (marshalBlendingFactor srcAlpha)
+                             (marshalBlendingFactor dstRGB)
+                             (marshalBlendingFactor dstAlpha))
 
 blendFunc :: StateVar (BlendingFactor, BlendingFactor)
 blendFunc =
@@ -457,16 +386,11 @@
       (\(s, d) ->
          glBlendFunc (marshalBlendingFactor s) (marshalBlendingFactor d))
 
-foreign import CALLCONV unsafe "glBlendFunc" glBlendFunc ::
-   GLenum -> GLenum -> IO ()
-
 blendColor :: StateVar (Color4 GLclampf)
 blendColor =
    makeStateVar
       (getFloat4 Color4 GetBlendColor)
-      (\(Color4 r g b a) -> glBlendColorEXT r g b a)
-
-EXTENSION_ENTRY("GL_EXT_blend_color or OpenGL 1.4",glBlendColorEXT,GLclampf -> GLclampf -> GLclampf -> GLclampf -> IO ())
+      (\(Color4 r g b a) -> glBlendColor r g b a)
 
 --------------------------------------------------------------------------------
 
@@ -496,41 +420,41 @@
 
 marshalLogicOp :: LogicOp -> GLenum
 marshalLogicOp x = case x of
-   Clear -> 0x1500
-   And -> 0x1501
-   AndReverse -> 0x1502
-   Copy -> 0x1503
-   AndInverted -> 0x1504
-   Noop -> 0x1505
-   Xor -> 0x1506
-   Or -> 0x1507
-   Nor -> 0x1508
-   Equiv -> 0x1509
-   Invert -> 0x150a
-   OrReverse -> 0x150b
-   CopyInverted -> 0x150c
-   OrInverted -> 0x150d
-   Nand -> 0x150e
-   Set -> 0x150f
+   Clear -> gl_CLEAR
+   And -> gl_AND
+   AndReverse -> gl_AND_REVERSE
+   Copy -> gl_COPY
+   AndInverted -> gl_AND_INVERTED
+   Noop -> gl_NOOP
+   Xor -> gl_XOR
+   Or -> gl_OR
+   Nor -> gl_NOR
+   Equiv -> gl_EQUIV
+   Invert -> gl_INVERT
+   OrReverse -> gl_OR_REVERSE
+   CopyInverted -> gl_COPY_INVERTED
+   OrInverted -> gl_OR_INVERTED
+   Nand -> gl_NAND
+   Set -> gl_SET
 
 unmarshalLogicOp :: GLenum -> LogicOp
 unmarshalLogicOp x
-   | x == 0x1500 = Clear
-   | x == 0x1501 = And
-   | x == 0x1502 = AndReverse
-   | x == 0x1503 = Copy
-   | x == 0x1504 = AndInverted
-   | x == 0x1505 = Noop
-   | x == 0x1506 = Xor
-   | x == 0x1507 = Or
-   | x == 0x1508 = Nor
-   | x == 0x1509 = Equiv
-   | x == 0x150a = Invert
-   | x == 0x150b = OrReverse
-   | x == 0x150c = CopyInverted
-   | x == 0x150d = OrInverted
-   | x == 0x150e = Nand
-   | x == 0x150f = Set
+   | x == gl_CLEAR = Clear
+   | x == gl_AND = And
+   | x == gl_AND_REVERSE = AndReverse
+   | x == gl_COPY = Copy
+   | x == gl_AND_INVERTED = AndInverted
+   | x == gl_NOOP = Noop
+   | x == gl_XOR = Xor
+   | x == gl_OR = Or
+   | x == gl_NOR = Nor
+   | x == gl_EQUIV = Equiv
+   | x == gl_INVERT = Invert
+   | x == gl_OR_REVERSE = OrReverse
+   | x == gl_COPY_INVERTED = CopyInverted
+   | x == gl_OR_INVERTED = OrInverted
+   | x == gl_NAND = Nand
+   | x == gl_SET = Set
    | otherwise = error ("unmarshalLogicOp: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
@@ -542,5 +466,3 @@
           return $ if rgba then CapColorLogicOp else CapIndexLogicOp)
       (getEnum1 unmarshalLogicOp GetLogicOpMode)
       (glLogicOp . marshalLogicOp)
-
-foreign import CALLCONV unsafe "glLogicOp" glLogicOp :: GLenum -> IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/PixelData.hs b/Graphics/Rendering/OpenGL/GL/PixelData.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelData.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelData.hs
@@ -17,23 +17,15 @@
    PixelData(..), withPixelData
 ) where
 
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
-import Graphics.Rendering.OpenGL.GL.DataType ( DataType, marshalDataType )
-import Graphics.Rendering.OpenGL.GL.PixelFormat (
-   PixelFormat, marshalPixelFormat )
+import Foreign.Ptr
+import Graphics.Rendering.OpenGL.GL.DataType
+import Graphics.Rendering.OpenGL.GL.PixelFormat
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
 data PixelData a = PixelData PixelFormat DataType (Ptr a)
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq (PixelData a)
-instance Ord (PixelData a)
-instance Show (PixelData a)
-#else
    deriving ( Eq, Ord, Show )
-#endif
 
 withPixelData :: PixelData a -> (GLenum -> GLenum -> Ptr a -> b) -> b
 withPixelData (PixelData pixelFormat dataType ptr) f =
diff --git a/Graphics/Rendering/OpenGL/GL/PixelFormat.hs b/Graphics/Rendering/OpenGL/GL/PixelFormat.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelFormat.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelFormat.hs
@@ -17,7 +17,13 @@
    PixelFormat(..), marshalPixelFormat, unmarshalPixelFormat
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   gl_COLOR_INDEX, gl_LUMINANCE, gl_LUMINANCE_ALPHA )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.EXT.Abgr ( gl_ABGR )
+import Graphics.Rendering.OpenGL.Raw.EXT.Cmyka ( gl_CMYK, gl_CMYKA )
+import Graphics.Rendering.OpenGL.Raw.EXT.FourTwoTwoPixels (
+   gl_422, gl_422_AVERAGE, gl_422_REV, gl_422_REV_AVERAGE )
 
 --------------------------------------------------------------------------------
 
@@ -48,51 +54,53 @@
 
 marshalPixelFormat :: PixelFormat -> GLenum
 marshalPixelFormat x = case x of
-   ColorIndex -> 0x1900
-   StencilIndex -> 0x1901
-   DepthComponent -> 0x1902
-   Red -> 0x1903
-   Green -> 0x1904
-   Blue -> 0x1905
-   Alpha -> 0x1906
-   RGB -> 0x1907
-   RGBA -> 0x1908
-   Luminance -> 0x1909
-   LuminanceAlpha -> 0x190a
-   ABGR -> 0x8000
-   BGR -> 0x80E0
-   BGRA -> 0x80E1
-   CMYK -> 0x800C
-   CMYKA -> 0x800D
-   FourTwoTwo -> 0x80CC
-   FourTwoTwoRev -> 0x80CD
-   FourTwoTwoAverage -> 0x80CE
-   FourTwoTwoRevAverage -> 0x80CF
+   ColorIndex -> gl_COLOR_INDEX
+   StencilIndex -> gl_STENCIL_INDEX
+   DepthComponent -> gl_DEPTH_COMPONENT
+   Red -> gl_RED
+   Green -> gl_GREEN
+   Blue -> gl_BLUE
+   Alpha -> gl_ALPHA
+   RGB -> gl_RGB
+   RGBA -> gl_RGBA
+   Luminance -> gl_LUMINANCE
+   LuminanceAlpha -> gl_LUMINANCE_ALPHA
+   ABGR -> gl_ABGR
+   BGR -> gl_BGR
+   BGRA -> gl_BGRA
+   CMYK -> gl_CMYK
+   CMYKA -> gl_CMYKA
+   FourTwoTwo -> gl_422
+   FourTwoTwoRev -> gl_422_REV
+   FourTwoTwoAverage -> gl_422_AVERAGE
+   FourTwoTwoRevAverage -> gl_422_REV_AVERAGE
+   -- TODO: Use YCBCR_422_APPLE from APPLE_ycbcr_422 extension
    YCBCR422 -> 0x85B9
-   DepthStencil -> 0x84f9
+   DepthStencil -> gl_DEPTH_STENCIL
 
 unmarshalPixelFormat :: GLenum -> PixelFormat
 unmarshalPixelFormat x
-   | x == 0x1900 = ColorIndex
-   | x == 0x1901 = StencilIndex
-   | x == 0x1902 = DepthComponent
-   | x == 0x1903 = Red
-   | x == 0x1904 = Green
-   | x == 0x1905 = Blue
-   | x == 0x1906 = Alpha
-   | x == 0x1907 = RGB
-   | x == 0x1908 = RGBA
-   | x == 0x1909 = Luminance
-   | x == 0x190a = LuminanceAlpha
-   | x == 0x8000 = ABGR
-   | x == 0x80E0 = BGR
-   | x == 0x80E1 = BGRA
-   | x == 0x800C = CMYK
-   | x == 0x800D = CMYKA
-   | x == 0x80CC = FourTwoTwo
-   | x == 0x80CD = FourTwoTwoRev
-   | x == 0x80CE = FourTwoTwoAverage
-   | x == 0x80CF = FourTwoTwoRevAverage
+   | x == gl_COLOR_INDEX = ColorIndex
+   | x == gl_STENCIL_INDEX = StencilIndex
+   | x == gl_DEPTH_COMPONENT = DepthComponent
+   | x == gl_RED = Red
+   | x == gl_GREEN = Green
+   | x == gl_BLUE = Blue
+   | x == gl_ALPHA = Alpha
+   | x == gl_RGB = RGB
+   | x == gl_RGBA = RGBA
+   | x == gl_LUMINANCE = Luminance
+   | x == gl_LUMINANCE_ALPHA = LuminanceAlpha
+   | x == gl_ABGR = ABGR
+   | x == gl_BGR = BGR
+   | x == gl_BGRA = BGRA
+   | x == gl_CMYK = CMYK
+   | x == gl_CMYKA = CMYKA
+   | x == gl_422 = FourTwoTwo
+   | x == gl_422_REV = FourTwoTwoRev
+   | x == gl_422_AVERAGE = FourTwoTwoAverage
+   | x == gl_422_REV_AVERAGE = FourTwoTwoRevAverage
+   -- TODO: Use YCBCR_422_APPLE from APPLE_ycbcr_422 extension
    | x == 0x85B9 = YCBCR422
-   | x == 0x84f9 = DepthStencil
+   | x == gl_DEPTH_STENCIL = DepthStencil
    | otherwise = error ("unmarshalPixelFormat: illegal value " ++ show x)
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/ColorTable.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/ColorTable.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/ColorTable.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/ColorTable.hs
@@ -21,35 +21,33 @@
    colorTableRGBASizes, colorTableLuminanceSize, colorTableIntesitySize,
 ) where
 
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Marshal.Utils ( with )
-import Foreign.Ptr ( Ptr )
-import Foreign.Storable ( Storable(..) )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapColorTable,CapPostConvolutionColorTable,
-             CapPostColorMatrixColorTable,CapTextureColorTable),
-   makeCapability )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLenum, GLint, GLsizei, GLfloat, Capability )
-import Graphics.Rendering.OpenGL.GL.CoordTrans ( Position(..) )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1 )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles.Rasterization (
-    PixelData(..) )
-import Graphics.Rendering.OpenGL.GL.PixelData ( withPixelData )
-import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat (
-   PixelInternalFormat(..), marshalPixelInternalFormat',
-   unmarshalPixelInternalFormat )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.VertexSpec ( Color4(..) )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal (
-   recordInvalidEnum )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
+import Data.StateVar
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Utils
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.CoordTrans
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.PixelData
+import Graphics.Rendering.OpenGL.GL.PixelRectangles.Rasterization
+import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glColorSubTable, glColorTable, glColorTableParameterfv, glCopyColorSubTable,
+   glCopyColorTable, glGetColorTable, glGetColorTableParameterfv,
+   glGetColorTableParameteriv, gl_COLOR_TABLE, gl_COLOR_TABLE_ALPHA_SIZE,
+   gl_COLOR_TABLE_BIAS, gl_COLOR_TABLE_BLUE_SIZE, gl_COLOR_TABLE_FORMAT,
+   gl_COLOR_TABLE_GREEN_SIZE, gl_COLOR_TABLE_INTENSITY_SIZE,
+   gl_COLOR_TABLE_LUMINANCE_SIZE, gl_COLOR_TABLE_RED_SIZE, gl_COLOR_TABLE_SCALE,
+   gl_COLOR_TABLE_WIDTH, gl_POST_COLOR_MATRIX_COLOR_TABLE,
+   gl_POST_CONVOLUTION_COLOR_TABLE, gl_PROXY_COLOR_TABLE,
+   gl_PROXY_POST_COLOR_MATRIX_COLOR_TABLE,
+   gl_PROXY_POST_CONVOLUTION_COLOR_TABLE )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.EXT.SharedTexturePalette (
+   gl_SHARED_TEXTURE_PALETTE )
 
 --------------------------------------------------------------------------------
 
@@ -95,15 +93,16 @@
 
 marshalColorTable :: ColorTable -> GLenum
 marshalColorTable x = case x of
-   ColorTable -> 0x80d0
-   PostConvolutionColorTable -> 0x80d1
-   PostColorMatrixColorTable -> 0x80d2
-   Texture1DColorTable -> 0xde0
-   Texture2DColorTable -> 0xde1
-   Texture3DColorTable -> 0x806f
-   TextureCubeMapColorTable -> 0x8513
+   ColorTable -> gl_COLOR_TABLE
+   PostConvolutionColorTable -> gl_POST_CONVOLUTION_COLOR_TABLE
+   PostColorMatrixColorTable -> gl_POST_COLOR_MATRIX_COLOR_TABLE
+   Texture1DColorTable -> gl_TEXTURE_1D
+   Texture2DColorTable -> gl_TEXTURE_2D
+   Texture3DColorTable -> gl_TEXTURE_3D
+   TextureCubeMapColorTable -> gl_TEXTURE_CUBE_MAP
+   -- TODO: Use TEXTURE_COLOR_TABLE_SGI from SGI_texture_color_table extension
    TextureColorTable -> 0x80bc
-   SharedTexturePalette -> 0x81fb
+   SharedTexturePalette -> gl_SHARED_TEXTURE_PALETTE
 
 --------------------------------------------------------------------------------
 
@@ -117,13 +116,14 @@
 marshalProxyColorTable :: Proxy -> ColorTable -> Maybe GLenum
 marshalProxyColorTable NoProxy x = Just (marshalColorTable x)
 marshalProxyColorTable Proxy   x = case x of
-   ColorTable -> Just 0x80d3
-   PostConvolutionColorTable -> Just 0x80d4
-   PostColorMatrixColorTable -> Just 0x80d5
-   Texture1DColorTable -> Just 0x8063
-   Texture2DColorTable -> Just 0x8064
-   Texture3DColorTable -> Just 0x8070
-   TextureCubeMapColorTable -> Just 0x851b
+   ColorTable -> Just gl_PROXY_COLOR_TABLE
+   PostConvolutionColorTable -> Just gl_PROXY_POST_CONVOLUTION_COLOR_TABLE
+   PostColorMatrixColorTable -> Just gl_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
+   Texture1DColorTable -> Just gl_PROXY_TEXTURE_1D
+   Texture2DColorTable -> Just gl_PROXY_TEXTURE_2D
+   Texture3DColorTable -> Just gl_PROXY_TEXTURE_3D
+   TextureCubeMapColorTable -> Just gl_PROXY_TEXTURE_CUBE_MAP
+   -- TODO: Use PROXY_TEXTURE_COLOR_TABLE_SGI from SGI_texture_color_table extension
    TextureColorTable -> Just 0x80bd
    SharedTexturePalette -> Nothing
 
@@ -137,40 +137,30 @@
             glColorTable target (marshalPixelInternalFormat' int) w)
          (marshalProxyColorTable proxy ct)
 
-EXTENSION_ENTRY("GL_ARB_imaging",glColorTable,GLenum -> GLenum -> GLsizei -> GLenum -> GLenum -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 getColorTable :: ColorTable -> PixelData a -> IO ()
 getColorTable ct pd =
    withPixelData pd $ glGetColorTable (marshalColorTable ct)
 
-EXTENSION_ENTRY("GL_ARB_imaging",glGetColorTable,GLenum -> GLenum -> GLenum -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 copyColorTable :: ColorTable -> PixelInternalFormat -> Position -> GLsizei -> IO ()
 copyColorTable ct int (Position x y) =
    glCopyColorTable (marshalColorTable ct) (marshalPixelInternalFormat' int) x y
 
-EXTENSION_ENTRY("GL_ARB_imaging",glCopyColorTable,GLenum -> GLenum -> GLint -> GLint -> GLsizei -> IO ())
-
 --------------------------------------------------------------------------------
 
 colorSubTable :: ColorTable -> GLsizei -> GLsizei -> PixelData a -> IO ()
 colorSubTable ct start count pd =
    withPixelData pd $ glColorSubTable (marshalColorTable ct) start count
 
-EXTENSION_ENTRY("GL_ARB_imaging",glColorSubTable,GLenum -> GLsizei -> GLsizei -> GLenum -> GLenum -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 copyColorSubTable :: ColorTable -> GLsizei -> Position -> GLsizei -> IO ()
 copyColorSubTable ct start (Position x y) =
    glCopyColorSubTable (marshalColorTable ct) start x y
 
-EXTENSION_ENTRY("GL_ARB_imaging",glCopyColorSubTable,GLenum -> GLsizei -> GLint -> GLint -> GLsizei -> IO ())
-
 --------------------------------------------------------------------------------
 
 data ColorTablePName =
@@ -187,16 +177,16 @@
 
 marshalColorTablePName :: ColorTablePName -> GLenum
 marshalColorTablePName x = case x of
-   ColorTableScale -> 0x80d6
-   ColorTableBias -> 0x80d7
-   ColorTableFormat -> 0x80d8
-   ColorTableWidth -> 0x80d9
-   ColorTableRedSize -> 0x80da
-   ColorTableGreenSize -> 0x80db
-   ColorTableBlueSize -> 0x80dc
-   ColorTableAlphaSize -> 0x80dd
-   ColorTableLuminanceSize -> 0x80de
-   ColorTableIntensitySize -> 0x80df
+   ColorTableScale -> gl_COLOR_TABLE_SCALE
+   ColorTableBias -> gl_COLOR_TABLE_BIAS
+   ColorTableFormat -> gl_COLOR_TABLE_FORMAT
+   ColorTableWidth -> gl_COLOR_TABLE_WIDTH
+   ColorTableRedSize -> gl_COLOR_TABLE_RED_SIZE
+   ColorTableGreenSize -> gl_COLOR_TABLE_GREEN_SIZE
+   ColorTableBlueSize -> gl_COLOR_TABLE_BLUE_SIZE
+   ColorTableAlphaSize -> gl_COLOR_TABLE_ALPHA_SIZE
+   ColorTableLuminanceSize -> gl_COLOR_TABLE_LUMINANCE_SIZE
+   ColorTableIntensitySize -> gl_COLOR_TABLE_INTENSITY_SIZE
 
 --------------------------------------------------------------------------------
 
@@ -219,18 +209,14 @@
       glGetColorTableParameterfv
          (marshalColorTable ct)
          (marshalColorTablePName p)
-         buf
+         (castPtr buf)
       peek buf
 
-EXTENSION_ENTRY("GL_ARB_imaging",glGetColorTableParameterfv,GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
-
 colorTableParameterC4f ::
    ColorTable -> ColorTablePName -> Color4 GLfloat -> IO ()
 colorTableParameterC4f ct p c =
-   with c $
-      glColorTableParameterfv (marshalColorTable ct) (marshalColorTablePName p)
-
-EXTENSION_ENTRY("GL_ARB_imaging",glColorTableParameterfv,GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
+   with c $ \ptr -> 
+      glColorTableParameterfv (marshalColorTable ct) (marshalColorTablePName p) (castPtr ptr)
 
 --------------------------------------------------------------------------------
 
@@ -247,8 +233,6 @@
          (marshalColorTablePName p)
          buf
       peek1 f buf
-
-EXTENSION_ENTRY("GL_ARB_imaging",glGetColorTableParameteriv,GLenum -> GLenum -> Ptr GLint -> IO ())
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Convolution.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Convolution.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Convolution.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Convolution.hs
@@ -25,35 +25,31 @@
    convolutionFilterScale, convolutionFilterBias,
 ) where
 
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Marshal.Utils ( with )
-import Foreign.Ptr ( Ptr, nullPtr )
-import Foreign.Storable ( Storable(..) )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapConvolution1D, CapConvolution2D,CapSeparable2D),
-   makeCapability )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLenum, GLint, GLsizei, GLfloat, Capability )
-import Graphics.Rendering.OpenGL.GL.CoordTrans ( Position(..), Size(..) )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1 )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles.ColorTable (
-   PixelInternalFormat )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles.Rasterization (
-    PixelData(..) )
-import Graphics.Rendering.OpenGL.GL.PixelData ( withPixelData )
-import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat (
-   marshalPixelInternalFormat' )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.VertexSpec ( Color4(..) )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal (
-   recordInvalidValue )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
+import Data.StateVar
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Utils
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.CoordTrans
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.PixelData
+import Graphics.Rendering.OpenGL.GL.PixelRectangles.Rasterization
+import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glConvolutionFilter1D, glConvolutionFilter2D, glConvolutionParameterfv,
+   glConvolutionParameteri, glCopyConvolutionFilter1D,
+   glCopyConvolutionFilter2D, glGetConvolutionFilter,
+   glGetConvolutionParameterfv, glGetConvolutionParameteriv,
+   glGetSeparableFilter, glSeparableFilter2D, gl_CONSTANT_BORDER,
+   gl_CONVOLUTION_1D, gl_CONVOLUTION_2D, gl_CONVOLUTION_BORDER_COLOR,
+   gl_CONVOLUTION_BORDER_MODE, gl_CONVOLUTION_FILTER_BIAS,
+   gl_CONVOLUTION_FILTER_SCALE, gl_CONVOLUTION_FORMAT, gl_CONVOLUTION_HEIGHT,
+   gl_CONVOLUTION_WIDTH, gl_MAX_CONVOLUTION_HEIGHT, gl_MAX_CONVOLUTION_WIDTH,
+   gl_REDUCE, gl_REPLICATE_BORDER, gl_SEPARABLE_2D )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -65,9 +61,9 @@
 
 marshalConvolutionTarget :: ConvolutionTarget -> GLenum
 marshalConvolutionTarget x = case x of
-   Convolution1D -> 0x8010
-   Convolution2D -> 0x8011
-   Separable2D -> 0x8012
+   Convolution1D -> gl_CONVOLUTION_1D
+   Convolution2D -> gl_CONVOLUTION_2D
+   Separable2D -> gl_SEPARABLE_2D
 
 convolutionTargetToEnableCap :: ConvolutionTarget -> EnableCap
 convolutionTargetToEnableCap x = case x of
@@ -89,8 +85,6 @@
          (marshalConvolutionTarget Convolution1D)
          (marshalPixelInternalFormat' int) w
 
-EXTENSION_ENTRY("GL_ARB_imaging",glConvolutionFilter1D,GLenum -> GLenum -> GLsizei -> GLenum -> GLenum -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 getConvolutionFilter1D :: PixelData a -> IO ()
@@ -100,8 +94,6 @@
 getConvolutionFilter t pd =
    withPixelData pd $ glGetConvolutionFilter (marshalConvolutionTarget t)
 
-EXTENSION_ENTRY("GL_ARB_imaging",glGetConvolutionFilter,GLenum -> GLenum -> GLenum -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 convolutionFilter2D :: PixelInternalFormat -> Size -> PixelData a -> IO ()
@@ -111,8 +103,6 @@
          (marshalConvolutionTarget Convolution2D)
          (marshalPixelInternalFormat' int) w h
 
-EXTENSION_ENTRY("GL_ARB_imaging",glConvolutionFilter2D,GLenum -> GLenum -> GLsizei -> GLsizei -> GLenum -> GLenum -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 getConvolutionFilter2D :: PixelData a -> IO ()
@@ -131,8 +121,6 @@
                     (marshalPixelInternalFormat' int) w h f1 d1 p1 p2
             else recordInvalidValue
 
-EXTENSION_ENTRY("GL_ARB_imaging",glSeparableFilter2D,GLenum -> GLenum -> GLsizei -> GLsizei -> GLenum -> GLenum -> Ptr a -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 getSeparableFilter2D :: PixelData a -> PixelData a -> IO ()
@@ -144,8 +132,6 @@
                     (marshalConvolutionTarget Separable2D) f1 d1 p1 p2 nullPtr
             else recordInvalidValue
 
-EXTENSION_ENTRY("GL_ARB_imaging",glGetSeparableFilter,GLenum -> GLenum -> GLenum -> Ptr a -> Ptr a -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 copyConvolutionFilter1D :: PixelInternalFormat -> Position -> GLsizei -> IO ()
@@ -154,8 +140,6 @@
       (marshalConvolutionTarget Convolution1D) (marshalPixelInternalFormat' int)
       x y
 
-EXTENSION_ENTRY("GL_ARB_imaging",glCopyConvolutionFilter1D,GLenum -> GLenum -> GLint -> GLint -> GLsizei -> IO ())
-
 --------------------------------------------------------------------------------
 
 copyConvolutionFilter2D :: PixelInternalFormat -> Position -> Size -> IO ()
@@ -164,8 +148,6 @@
       (marshalConvolutionTarget Convolution2D) (marshalPixelInternalFormat' int)
       x y w h
 
-EXTENSION_ENTRY("GL_ARB_imaging",glCopyConvolutionFilter2D,GLenum -> GLenum -> GLint -> GLint -> GLsizei -> GLsizei -> IO ())
-
 --------------------------------------------------------------------------------
 
 data ConvolutionParameter =
@@ -182,15 +164,15 @@
 
 marshalConvolutionParameter :: ConvolutionParameter -> GLenum
 marshalConvolutionParameter x = case x of
-   ConvolutionBorderColor -> 0x8154
-   ConvolutionBorderMode -> 0x8013
-   ConvolutionFilterScale -> 0x8014
-   ConvolutionFilterBias -> 0x8015
-   ConvolutionFormat -> 0x8017
-   ConvolutionWidth -> 0x8018
-   ConvolutionHeight -> 0x8019
-   MaxConvolutionWidth -> 0x801a
-   MaxConvolutionHeight -> 0x801b
+   ConvolutionBorderColor -> gl_CONVOLUTION_BORDER_COLOR
+   ConvolutionBorderMode -> gl_CONVOLUTION_BORDER_MODE
+   ConvolutionFilterScale -> gl_CONVOLUTION_FILTER_SCALE
+   ConvolutionFilterBias -> gl_CONVOLUTION_FILTER_BIAS
+   ConvolutionFormat -> gl_CONVOLUTION_FORMAT
+   ConvolutionWidth -> gl_CONVOLUTION_WIDTH
+   ConvolutionHeight -> gl_CONVOLUTION_HEIGHT
+   MaxConvolutionWidth -> gl_MAX_CONVOLUTION_WIDTH
+   MaxConvolutionHeight -> gl_MAX_CONVOLUTION_HEIGHT
 
 --------------------------------------------------------------------------------
 
@@ -219,8 +201,6 @@
          (marshalConvolutionTarget t) (marshalConvolutionParameter p) buf
       peek1 f buf
 
-EXTENSION_ENTRY("GL_ARB_imaging",glGetConvolutionParameteriv,GLenum -> GLenum -> Ptr GLint -> IO ())
-
 --------------------------------------------------------------------------------
 
 data ConvolutionBorderMode' =
@@ -229,17 +209,18 @@
    | ReplicateBorder'
 
 marshalConvolutionBorderMode' :: ConvolutionBorderMode' -> GLint
-marshalConvolutionBorderMode' x = case x of
-   Reduce' -> 0x8016
-   ConstantBorder' -> 0x8151
-   ReplicateBorder' -> 0x8153
+marshalConvolutionBorderMode' x = fromIntegral $ case x of
+   Reduce' -> gl_REDUCE
+   ConstantBorder' -> gl_CONSTANT_BORDER
+   ReplicateBorder' -> gl_REPLICATE_BORDER
 
 unmarshalConvolutionBorderMode' :: GLint -> ConvolutionBorderMode'
 unmarshalConvolutionBorderMode' x
-   | x == 0x8016 = Reduce'
-   | x == 0x8151 = ConstantBorder'
-   | x == 0x8153 = ReplicateBorder'
+   | y == gl_REDUCE = Reduce'
+   | y == gl_CONSTANT_BORDER = ConstantBorder'
+   | y == gl_REPLICATE_BORDER = ReplicateBorder'
    | otherwise = error ("unmarshalConvolutionBorderMode': illegal value " ++ show x)
+   where y = fromIntegral x
 
 --------------------------------------------------------------------------------
 
@@ -283,8 +264,6 @@
    glConvolutionParameteri
       (marshalConvolutionTarget t) (marshalConvolutionParameter p) (f x)
 
-EXTENSION_ENTRY("GL_ARB_imaging",glConvolutionParameteri,GLenum -> GLenum -> GLint -> IO ())
-
 --------------------------------------------------------------------------------
 
 convolutionFilterScale :: ConvolutionTarget -> StateVar (Color4 GLfloat)
@@ -303,16 +282,12 @@
 getConvolutionParameterC4f t p =
    alloca $ \buf -> do
       glGetConvolutionParameterfv
-         (marshalConvolutionTarget t) (marshalConvolutionParameter p) buf
+         (marshalConvolutionTarget t) (marshalConvolutionParameter p) (castPtr buf)
       peek buf
 
-EXTENSION_ENTRY("GL_ARB_imaging",glGetConvolutionParameterfv,GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
-
 convolutionParameterC4f ::
    ConvolutionTarget -> ConvolutionParameter -> Color4 GLfloat -> IO ()
 convolutionParameterC4f t p c =
-   with c $
+   with c $ \ptr ->
       glConvolutionParameterfv
-         (marshalConvolutionTarget t) (marshalConvolutionParameter p)
-
-EXTENSION_ENTRY("GL_ARB_imaging",glConvolutionParameterfv,GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
+         (marshalConvolutionTarget t) (marshalConvolutionParameter p) (castPtr ptr)
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Histogram.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Histogram.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Histogram.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Histogram.hs
@@ -18,34 +18,25 @@
    histogramRGBASizes, histogramLuminanceSize
 ) where
 
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapHistogram), makeStateVarMaybe )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLenum, GLint, GLsizei )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1 )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles.Rasterization (
-    PixelData(..) )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles.ColorTable (
-   PixelInternalFormat )
-import Graphics.Rendering.OpenGL.GL.PixelData ( withPixelData )
-import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat (
-   marshalPixelInternalFormat', unmarshalPixelInternalFormat )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles.ColorTable ( Proxy(..) )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles.Sink (
-   Sink(..), marshalSink, unmarshalSink )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles.Reset (
-   Reset(..), marshalReset )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, StateVar )
-import Graphics.Rendering.OpenGL.GL.VertexSpec ( Color4(..) )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
+import Data.StateVar
+import Foreign.Marshal.Alloc
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.PixelData
+import Graphics.Rendering.OpenGL.GL.PixelRectangles.ColorTable
+import Graphics.Rendering.OpenGL.GL.PixelRectangles.ColorTable
+import Graphics.Rendering.OpenGL.GL.PixelRectangles.Rasterization
+import Graphics.Rendering.OpenGL.GL.PixelRectangles.Reset
+import Graphics.Rendering.OpenGL.GL.PixelRectangles.Sink
+import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glGetHistogram, glGetHistogramParameteriv, glHistogram, glResetHistogram,
+   gl_HISTOGRAM, gl_HISTOGRAM_ALPHA_SIZE, gl_HISTOGRAM_BLUE_SIZE,
+   gl_HISTOGRAM_FORMAT, gl_HISTOGRAM_GREEN_SIZE, gl_HISTOGRAM_LUMINANCE_SIZE,
+   gl_HISTOGRAM_RED_SIZE, gl_HISTOGRAM_SINK, gl_HISTOGRAM_WIDTH,
+   gl_PROXY_HISTOGRAM )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -55,8 +46,8 @@
 
 marshalHistogramTarget :: HistogramTarget -> GLenum
 marshalHistogramTarget x = case x of
-   Histogram -> 0x8024
-   ProxyHistogram -> 0x8025
+   Histogram -> gl_HISTOGRAM
+   ProxyHistogram -> gl_PROXY_HISTOGRAM
 
 proxyToHistogramTarget :: Proxy -> HistogramTarget
 proxyToHistogramTarget x = case x of
@@ -87,8 +78,6 @@
          buf
       peek1 f buf
 
-EXTENSION_ENTRY("GL_ARB_imaging",glGetHistogramParameteriv,GLenum -> GLenum -> Ptr GLint -> IO ())
-
 setHistogram :: Proxy -> (GLsizei, PixelInternalFormat, Sink) -> IO ()
 setHistogram proxy (w, int, sink) =
    glHistogram
@@ -96,8 +85,6 @@
       w
       (marshalPixelInternalFormat' int)
       (marshalSink sink)
-         
-EXTENSION_ENTRY("GL_ARB_imaging",glHistogram,GLenum -> GLsizei -> GLenum -> GLboolean -> IO ())
 
 --------------------------------------------------------------------------------
 
@@ -108,15 +95,11 @@
          (marshalHistogramTarget Histogram)
          (marshalReset reset)
 
-EXTENSION_ENTRY("GL_ARB_imaging",glGetHistogram,GLenum -> GLboolean -> GLenum -> GLenum -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 resetHistogram :: IO ()
 resetHistogram = glResetHistogram (marshalHistogramTarget Histogram)
 
-EXTENSION_ENTRY("GL_ARB_imaging",glResetHistogram,GLenum -> IO ())
-
 --------------------------------------------------------------------------------
 
 data GetHistogramParameterPName =
@@ -131,14 +114,14 @@
 
 marshalGetHistogramParameterPName :: GetHistogramParameterPName -> GLenum
 marshalGetHistogramParameterPName x = case x of
-   HistogramWidth -> 0x8026
-   HistogramFormat -> 0x8027
-   HistogramRedSize -> 0x8028
-   HistogramGreenSize -> 0x8029
-   HistogramBlueSize -> 0x802a
-   HistogramAlphaSize -> 0x802b
-   HistogramLuminanceSize -> 0x802c
-   HistogramSink -> 0x802d
+   HistogramWidth -> gl_HISTOGRAM_WIDTH
+   HistogramFormat -> gl_HISTOGRAM_FORMAT
+   HistogramRedSize -> gl_HISTOGRAM_RED_SIZE
+   HistogramGreenSize -> gl_HISTOGRAM_GREEN_SIZE
+   HistogramBlueSize -> gl_HISTOGRAM_BLUE_SIZE
+   HistogramAlphaSize -> gl_HISTOGRAM_ALPHA_SIZE
+   HistogramLuminanceSize -> gl_HISTOGRAM_LUMINANCE_SIZE
+   HistogramSink -> gl_HISTOGRAM_SINK
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Minmax.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Minmax.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Minmax.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Minmax.hs
@@ -17,32 +17,19 @@
    minmax, getMinmax, resetMinmax
 ) where
 
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapMinmax), makeStateVarMaybe )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLboolean, GLenum, GLint )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1 )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles.ColorTable (
-   PixelInternalFormat )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles.Rasterization (
-    PixelData(..) )
-import Graphics.Rendering.OpenGL.GL.PixelData ( withPixelData )
-import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat (
-   marshalPixelInternalFormat', unmarshalPixelInternalFormat )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles.Histogram (
-   Reset(..), Sink )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles.Reset (
-   marshalReset )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles.Sink (
-   marshalSink, unmarshalSink )
-import Graphics.Rendering.OpenGL.GL.StateVar ( StateVar )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
+import Data.StateVar
+import Foreign.Marshal.Alloc
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.PixelData
+import Graphics.Rendering.OpenGL.GL.PixelRectangles.Rasterization
+import Graphics.Rendering.OpenGL.GL.PixelRectangles.Reset
+import Graphics.Rendering.OpenGL.GL.PixelRectangles.Sink
+import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glGetMinmax, glGetMinmaxParameteriv, glMinmax, glResetMinmax, gl_MINMAX,
+   gl_MINMAX_FORMAT, gl_MINMAX_SINK )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -51,7 +38,7 @@
 
 marshalMinmaxTarget :: MinmaxTarget -> GLenum
 marshalMinmaxTarget x = case x of
-   Minmax -> 0x802e
+   Minmax -> gl_MINMAX
 
 --------------------------------------------------------------------------------
 
@@ -71,8 +58,6 @@
       (marshalPixelInternalFormat' int)
       (marshalSink sink)
 
-EXTENSION_ENTRY("GL_ARB_imaging",glMinmax,GLenum -> GLenum -> GLboolean -> IO ())
-
 --------------------------------------------------------------------------------
 
 getMinmax :: Reset -> PixelData a -> IO ()
@@ -80,15 +65,11 @@
    withPixelData pd $
       glGetMinmax (marshalMinmaxTarget Minmax) (marshalReset reset)
 
-EXTENSION_ENTRY("GL_ARB_imaging",glGetMinmax,GLenum -> GLboolean -> GLenum -> GLenum -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 resetMinmax :: IO ()
 resetMinmax = glResetMinmax (marshalMinmaxTarget Minmax)
 
-EXTENSION_ENTRY("GL_ARB_imaging",glResetMinmax,GLenum -> IO ())
-
 --------------------------------------------------------------------------------
 
 data GetMinmaxParameterPName =
@@ -97,8 +78,8 @@
 
 marshalGetMinmaxParameterPName :: GetMinmaxParameterPName -> GLenum
 marshalGetMinmaxParameterPName x = case x of
-   MinmaxFormat -> 0x802f
-   MinmaxSink -> 0x8030
+   MinmaxFormat -> gl_MINMAX_FORMAT
+   MinmaxSink -> gl_MINMAX_SINK
 
 --------------------------------------------------------------------------------
 
@@ -110,5 +91,3 @@
          (marshalGetMinmaxParameterPName p)
          buf
       peek1 f buf
-
-EXTENSION_ENTRY("GL_ARB_imaging",glGetMinmaxParameteriv,GLenum -> GLenum -> Ptr GLint -> IO ())
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelMap.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelMap.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelMap.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelMap.hs
@@ -18,28 +18,22 @@
    maxPixelMapTable, pixelMap, pixelMapIToRGBA, pixelMapRGBAToRGBA,
 ) where
 
-import Data.List ( zipWith4 )
-import Data.Word
-import Foreign.ForeignPtr ( ForeignPtr, mallocForeignPtrArray, withForeignPtr )
-import Foreign.Marshal.Array ( allocaArray, peekArray, pokeArray, withArrayLen )
-import Foreign.Ptr ( Ptr )
-import Foreign.Storable ( Storable(..) )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLenum, GLushort, GLuint, GLsizei, GLfloat )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetMaxPixelMapTable,GetPixelMapIToISize,GetPixelMapSToSSize,
-            GetPixelMapIToRSize,GetPixelMapIToGSize,GetPixelMapIToBSize,
-            GetPixelMapIToASize,GetPixelMapRToRSize,GetPixelMapGToGSize,
-            GetPixelMapBToBSize,GetPixelMapAToASize),
-   getInteger1, getSizei1 )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   HasSetter(($=)), HasGetter(get), GettableStateVar, makeGettableStateVar,
-   StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.VertexSpec ( Color4(..) )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLTypes.h"
+import Data.List
+import Data.StateVar
+import Foreign.C.Types
+import Foreign.ForeignPtr
+import Foreign.Marshal.Array
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glGetPixelMapfv, glGetPixelMapuiv, glGetPixelMapusv, glPixelMapfv,
+   glPixelMapuiv, glPixelMapusv, gl_PIXEL_MAP_A_TO_A, gl_PIXEL_MAP_B_TO_B,
+   gl_PIXEL_MAP_G_TO_G, gl_PIXEL_MAP_I_TO_A, gl_PIXEL_MAP_I_TO_B,
+   gl_PIXEL_MAP_I_TO_G, gl_PIXEL_MAP_I_TO_I, gl_PIXEL_MAP_I_TO_R,
+   gl_PIXEL_MAP_R_TO_R, gl_PIXEL_MAP_S_TO_S )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -57,16 +51,16 @@
 
 marshalPixelMapTarget :: PixelMapTarget -> GLenum
 marshalPixelMapTarget x = case x of
-   IToI -> 0xc70
-   SToS -> 0xc71
-   IToR -> 0xc72
-   IToG -> 0xc73
-   IToB -> 0xc74
-   IToA -> 0xc75
-   RToR -> 0xc76
-   GToG -> 0xc77
-   BToB -> 0xc78
-   AToA -> 0xc79
+   IToI -> gl_PIXEL_MAP_I_TO_I
+   SToS -> gl_PIXEL_MAP_S_TO_S
+   IToR -> gl_PIXEL_MAP_I_TO_R
+   IToG -> gl_PIXEL_MAP_I_TO_G
+   IToB -> gl_PIXEL_MAP_I_TO_B
+   IToA -> gl_PIXEL_MAP_I_TO_A
+   RToR -> gl_PIXEL_MAP_R_TO_R
+   GToG -> gl_PIXEL_MAP_G_TO_G
+   BToB -> gl_PIXEL_MAP_B_TO_B
+   AToA -> gl_PIXEL_MAP_A_TO_A
 
 pixelMapTargetToGetPName :: PixelMapTarget -> GetPName
 pixelMapTargetToGetPName x = case x of
@@ -92,36 +86,21 @@
    getPixelMapv :: GLenum -> Ptr c -> IO ()
    pixelMapv :: GLenum -> GLsizei -> Ptr c -> IO ()
 
-instance PixelMapComponent GLushort_ where
+-- GLushort instance
+instance PixelMapComponent CUShort where
    getPixelMapv = glGetPixelMapusv
    pixelMapv = glPixelMapusv
 
-foreign import CALLCONV unsafe "glGetPixelMapusv" glGetPixelMapusv ::
-   GLenum -> Ptr GLushort -> IO ()
-
-foreign import CALLCONV unsafe "glPixelMapusv" glPixelMapusv ::
-   GLenum -> GLsizei -> Ptr GLushort -> IO ()
-
-instance PixelMapComponent GLuint_ where
+-- GLuint instance
+instance PixelMapComponent CUInt where
    getPixelMapv = glGetPixelMapuiv
    pixelMapv = glPixelMapuiv
 
-foreign import CALLCONV unsafe "glGetPixelMapuiv" glGetPixelMapuiv ::
-   GLenum -> Ptr GLuint -> IO ()
-
-foreign import CALLCONV unsafe "glPixelMapuiv" glPixelMapuiv ::
-   GLenum -> GLsizei -> Ptr GLuint -> IO ()
-
-instance PixelMapComponent GLfloat_ where
+-- GLfloat instance
+instance PixelMapComponent CFloat where
    getPixelMapv = glGetPixelMapfv
    pixelMapv = glPixelMapfv
 
-foreign import CALLCONV unsafe "glGetPixelMapfv" glGetPixelMapfv ::
-   GLenum -> Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glPixelMapfv" glPixelMapfv ::
-   GLenum -> GLsizei -> Ptr GLfloat -> IO ()
-
 --------------------------------------------------------------------------------
 
 class PixelMap m where
@@ -151,14 +130,7 @@
 --------------------------------------------------------------------------------
 
 data GLpixelmap a = GLpixelmap Int (ForeignPtr a)
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq (GLpixelmap a)
-instance Ord (GLpixelmap a)
-instance Show (GLpixelmap a)
-#else
    deriving ( Eq, Ord, Show )
-#endif
 
 instance PixelMap GLpixelmap where
    withNewPixelMap size f = do
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelStorage.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelStorage.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelStorage.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelStorage.hs
@@ -18,17 +18,10 @@
    skipPixels, rowAlignment, imageHeight, skipImages
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLint )
-import Graphics.Rendering.OpenGL.GL.GLboolean (
-   marshalGLboolean, unmarshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetUnpackSwapBytes,GetUnpackLSBFirst,GetUnpackRowLength,
-            GetUnpackSkipRows,GetUnpackSkipPixels,GetUnpackAlignment,
-            GetUnpackImageHeight,GetUnpackSkipImages,GetPackSwapBytes,
-            GetPackLSBFirst,GetPackRowLength,GetPackSkipRows,GetPackSkipPixels,
-            GetPackAlignment,GetPackImageHeight,GetPackSkipImages),
-   getBoolean1, getInteger1 )
-import Graphics.Rendering.OpenGL.GL.StateVar ( StateVar, makeStateVar )
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -59,22 +52,22 @@
 
 marshalPixelStore :: PixelStore -> GLenum
 marshalPixelStore x = case x of
-   UnpackSwapBytes -> 0xcf0
-   UnpackLSBFirst -> 0xcf1
-   UnpackRowLength -> 0xcf2
-   UnpackSkipRows -> 0xcf3
-   UnpackSkipPixels -> 0xcf4
-   UnpackAlignment -> 0xcf5
-   PackSwapBytes -> 0xd00
-   PackLSBFirst -> 0xd01
-   PackRowLength -> 0xd02
-   PackSkipRows -> 0xd03
-   PackSkipPixels -> 0xd04
-   PackAlignment -> 0xd05
-   PackSkipImages -> 0x806b
-   PackImageHeight -> 0x806c
-   UnpackSkipImages -> 0x806d
-   UnpackImageHeight -> 0x806e
+   UnpackSwapBytes -> gl_UNPACK_SWAP_BYTES
+   UnpackLSBFirst -> gl_UNPACK_LSB_FIRST
+   UnpackRowLength -> gl_UNPACK_ROW_LENGTH
+   UnpackSkipRows -> gl_UNPACK_SKIP_ROWS
+   UnpackSkipPixels -> gl_UNPACK_SKIP_PIXELS
+   UnpackAlignment -> gl_UNPACK_ALIGNMENT
+   PackSwapBytes -> gl_PACK_SWAP_BYTES
+   PackLSBFirst -> gl_PACK_LSB_FIRST
+   PackRowLength -> gl_PACK_ROW_LENGTH
+   PackSkipRows -> gl_PACK_SKIP_ROWS
+   PackSkipPixels -> gl_PACK_SKIP_PIXELS
+   PackAlignment -> gl_PACK_ALIGNMENT
+   PackSkipImages -> gl_PACK_SKIP_IMAGES
+   PackImageHeight -> gl_PACK_IMAGE_HEIGHT
+   UnpackSkipImages -> gl_UNPACK_SKIP_IMAGES
+   UnpackImageHeight -> gl_UNPACK_IMAGE_HEIGHT
 
 --------------------------------------------------------------------------------
 
@@ -123,6 +116,3 @@
    makeStateVar
       (getInteger1 id pn)
       (glPixelStorei (marshalPixelStore ps))
-
-foreign import CALLCONV unsafe "glPixelStorei" glPixelStorei ::
-   GLenum -> GLint -> IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelTransfer.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelTransfer.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelTransfer.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelTransfer.hs
@@ -19,25 +19,24 @@
    rgbaScale, rgbaBias
 ) where
 
-import Graphics.Rendering.OpenGL.GL.Capability (
-   marshalCapability, unmarshalCapability )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLenum, GLint, GLfloat, Capability )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetMapColor,GetMapStencil,GetIndexShift,GetIndexOffset,
-            GetRedScale,GetGreenScale,GetBlueScale,GetAlphaScale,GetDepthScale,
-            GetRedBias,GetGreenBias,GetBlueBias,GetAlphaBias,GetDepthBias,
-            GetPostConvolutionRedScale,GetPostConvolutionGreenScale,
-            GetPostConvolutionBlueScale,GetPostConvolutionAlphaScale,
-            GetPostConvolutionRedBias,GetPostConvolutionGreenBias,
-            GetPostConvolutionBlueBias,GetPostConvolutionAlphaBias,
-            GetPostColorMatrixRedScale,GetPostColorMatrixGreenScale,
-            GetPostColorMatrixBlueScale,GetPostColorMatrixAlphaScale,
-            GetPostColorMatrixRedBias,GetPostColorMatrixGreenBias,
-            GetPostColorMatrixBlueBias,GetPostColorMatrixAlphaBias),
-   getBoolean1, getInteger1, getFloat1 )
-import Graphics.Rendering.OpenGL.GL.StateVar ( StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.VertexSpec ( Color4(..) )
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glPixelTransferf, glPixelTransferi, gl_ALPHA_BIAS, gl_ALPHA_SCALE,
+   gl_BLUE_BIAS, gl_BLUE_SCALE, gl_DEPTH_BIAS, gl_DEPTH_SCALE, gl_GREEN_BIAS,
+   gl_GREEN_SCALE, gl_INDEX_OFFSET, gl_INDEX_SHIFT, gl_MAP_COLOR,
+   gl_MAP_STENCIL, gl_POST_COLOR_MATRIX_ALPHA_BIAS,
+   gl_POST_COLOR_MATRIX_ALPHA_SCALE, gl_POST_COLOR_MATRIX_BLUE_BIAS,
+   gl_POST_COLOR_MATRIX_BLUE_SCALE, gl_POST_COLOR_MATRIX_GREEN_BIAS,
+   gl_POST_COLOR_MATRIX_GREEN_SCALE, gl_POST_COLOR_MATRIX_RED_BIAS,
+   gl_POST_COLOR_MATRIX_RED_SCALE, gl_POST_CONVOLUTION_ALPHA_BIAS,
+   gl_POST_CONVOLUTION_ALPHA_SCALE, gl_POST_CONVOLUTION_BLUE_BIAS,
+   gl_POST_CONVOLUTION_BLUE_SCALE, gl_POST_CONVOLUTION_GREEN_BIAS,
+   gl_POST_CONVOLUTION_GREEN_SCALE, gl_POST_CONVOLUTION_RED_BIAS,
+   gl_POST_CONVOLUTION_RED_SCALE, gl_RED_BIAS, gl_RED_SCALE )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -75,36 +74,36 @@
 
 marshalPixelTransfer :: PixelTransfer -> GLenum
 marshalPixelTransfer x = case x of
-   MapColor -> 0xd10
-   MapStencil -> 0xd11
-   IndexShift -> 0xd12
-   IndexOffset -> 0xd13
-   RedScale -> 0xd14
-   RedBias -> 0xd15
-   GreenScale -> 0xd18
-   GreenBias -> 0xd19
-   BlueScale -> 0xd1a
-   BlueBias -> 0xd1b
-   AlphaScale -> 0xd1c
-   AlphaBias -> 0xd1d
-   DepthScale -> 0xd1e
-   DepthBias -> 0xd1f
-   PostConvolutionRedScale -> 0x801c
-   PostConvolutionGreenScale -> 0x801d
-   PostConvolutionBlueScale -> 0x801e
-   PostConvolutionAlphaScale -> 0x801f
-   PostConvolutionRedBias -> 0x8020
-   PostConvolutionGreenBias -> 0x8021
-   PostConvolutionBlueBias -> 0x8022
-   PostConvolutionAlphaBias -> 0x8023
-   PostColorMatrixRedScale -> 0x80b4
-   PostColorMatrixGreenScale -> 0x80b5
-   PostColorMatrixBlueScale -> 0x80b6
-   PostColorMatrixAlphaScale -> 0x80b7
-   PostColorMatrixRedBias -> 0x80b8
-   PostColorMatrixGreenBias -> 0x80b9
-   PostColorMatrixBlueBias -> 0x80ba
-   PostColorMatrixAlphaBias -> 0x80bb
+   MapColor -> gl_MAP_COLOR
+   MapStencil -> gl_MAP_STENCIL
+   IndexShift -> gl_INDEX_SHIFT
+   IndexOffset -> gl_INDEX_OFFSET
+   RedScale -> gl_RED_SCALE
+   RedBias -> gl_RED_BIAS
+   GreenScale -> gl_GREEN_SCALE
+   GreenBias -> gl_GREEN_BIAS
+   BlueScale -> gl_BLUE_SCALE
+   BlueBias -> gl_BLUE_BIAS
+   AlphaScale -> gl_ALPHA_SCALE
+   AlphaBias -> gl_ALPHA_BIAS
+   DepthScale -> gl_DEPTH_SCALE
+   DepthBias -> gl_DEPTH_BIAS
+   PostConvolutionRedScale -> gl_POST_CONVOLUTION_RED_SCALE
+   PostConvolutionGreenScale -> gl_POST_CONVOLUTION_GREEN_SCALE
+   PostConvolutionBlueScale -> gl_POST_CONVOLUTION_BLUE_SCALE
+   PostConvolutionAlphaScale -> gl_POST_CONVOLUTION_ALPHA_SCALE
+   PostConvolutionRedBias -> gl_POST_CONVOLUTION_RED_BIAS
+   PostConvolutionGreenBias -> gl_POST_CONVOLUTION_GREEN_BIAS
+   PostConvolutionBlueBias -> gl_POST_CONVOLUTION_BLUE_BIAS
+   PostConvolutionAlphaBias -> gl_POST_CONVOLUTION_ALPHA_BIAS
+   PostColorMatrixRedScale -> gl_POST_COLOR_MATRIX_RED_SCALE
+   PostColorMatrixGreenScale -> gl_POST_COLOR_MATRIX_GREEN_SCALE
+   PostColorMatrixBlueScale -> gl_POST_COLOR_MATRIX_BLUE_SCALE
+   PostColorMatrixAlphaScale -> gl_POST_COLOR_MATRIX_ALPHA_SCALE
+   PostColorMatrixRedBias -> gl_POST_COLOR_MATRIX_RED_BIAS
+   PostColorMatrixGreenBias -> gl_POST_COLOR_MATRIX_GREEN_BIAS
+   PostColorMatrixBlueBias -> gl_POST_COLOR_MATRIX_BLUE_BIAS
+   PostColorMatrixAlphaBias -> gl_POST_COLOR_MATRIX_ALPHA_BIAS
 
 --------------------------------------------------------------------------------
 
@@ -223,9 +222,6 @@
       (getInteger1 id pn)
       (glPixelTransferi (marshalPixelTransfer pt))
 
-foreign import CALLCONV unsafe "glPixelTransferi" glPixelTransferi ::
-   GLenum -> GLint -> IO ()
-
 pixelTransferf :: GetPName -> PixelTransfer -> StateVar GLfloat
 pixelTransferf pn pt =
    makeStateVar
@@ -248,6 +244,3 @@
             glPixelTransferf (marshalPixelTransfer tg) g
             glPixelTransferf (marshalPixelTransfer tb) b
             glPixelTransferf (marshalPixelTransfer ta) a
-
-foreign import CALLCONV unsafe "glPixelTransferf" glPixelTransferf ::
-   GLenum -> GLfloat -> IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Rasterization.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Rasterization.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Rasterization.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Rasterization.hs
@@ -17,24 +17,21 @@
    PixelData(..), PixelFormat(..), drawPixels, pixelZoom
 ) where
 
-import Control.Monad ( liftM2 )
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLsizei, GLfloat )
-import Graphics.Rendering.OpenGL.GL.CoordTrans ( Size(..) )
-import Graphics.Rendering.OpenGL.GL.PixelData ( PixelData(..), withPixelData )
-import Graphics.Rendering.OpenGL.GL.PixelFormat ( PixelFormat(..) )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetZoomX,GetZoomY), getFloat1 )
-import Graphics.Rendering.OpenGL.GL.StateVar ( StateVar, makeStateVar )
+import Control.Monad
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GL.CoordTrans
+import Graphics.Rendering.OpenGL.GL.PixelData
+import Graphics.Rendering.OpenGL.GL.PixelFormat
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glDrawPixels, glPixelZoom )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
 drawPixels :: Size -> PixelData a -> IO ()
 drawPixels (Size w h) pd = withPixelData pd $ glDrawPixels w h
 
-foreign import CALLCONV unsafe "glDrawPixels" glDrawPixels ::
-   GLsizei -> GLsizei -> GLenum -> GLenum -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 pixelZoom :: StateVar (GLfloat, GLfloat)
@@ -42,6 +39,3 @@
    makeStateVar
       (liftM2 (,) (getFloat1 id GetZoomX) (getFloat1 id GetZoomY))
       (uncurry glPixelZoom)
-
-foreign import CALLCONV unsafe "glPixelZoom" glPixelZoom ::
-   GLfloat -> GLfloat -> IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Reset.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Reset.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Reset.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Reset.hs
@@ -17,8 +17,8 @@
    Reset(..), marshalReset
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLboolean )
-import Graphics.Rendering.OpenGL.GL.GLboolean ( marshalGLboolean )
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Sink.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Sink.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Sink.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Sink.hs
@@ -17,9 +17,8 @@
    Sink(..), marshalSink, unmarshalSink
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLboolean, GLint )
-import Graphics.Rendering.OpenGL.GL.GLboolean (
-   marshalGLboolean, unmarshalGLboolean )
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/PointParameter.hs b/Graphics/Rendering/OpenGL/GL/PointParameter.hs
--- a/Graphics/Rendering/OpenGL/GL/PointParameter.hs
+++ b/Graphics/Rendering/OpenGL/GL/PointParameter.hs
@@ -17,14 +17,10 @@
    PointParameter(..), pointParameterf, pointParameterfv
 ) where
 
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLfloat )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
+import Foreign.Ptr
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+ gl_POINT_DISTANCE_ATTENUATION, gl_POINT_SIZE_MAX, gl_POINT_SIZE_MIN )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -36,19 +32,15 @@
 
 marshalPointParameter :: PointParameter -> GLenum
 marshalPointParameter x = case x of
-   PointSizeMin -> 0x8126
-   PointSizeMax -> 0x8127
-   PointFadeThresholdSize -> 0x8128
-   PointDistanceAttenuation -> 0x8129
+   PointSizeMin -> gl_POINT_SIZE_MIN
+   PointSizeMax -> gl_POINT_SIZE_MAX
+   PointFadeThresholdSize -> gl_POINT_FADE_THRESHOLD_SIZE
+   PointDistanceAttenuation -> gl_POINT_DISTANCE_ATTENUATION
 
 --------------------------------------------------------------------------------
 
 pointParameterf :: PointParameter -> GLfloat -> IO ()
-pointParameterf = glPointParameterfARB . marshalPointParameter
-
-EXTENSION_ENTRY("GL_ARB_point_parameters or OpenGL 1.4",glPointParameterfARB,GLenum -> GLfloat -> IO ())
+pointParameterf = glPointParameterf . marshalPointParameter
 
 pointParameterfv :: PointParameter -> Ptr GLfloat -> IO ()
-pointParameterfv = glPointParameterfvARB . marshalPointParameter
-
-EXTENSION_ENTRY("GL_ARB_point_parameters or OpenGL 1.4",glPointParameterfvARB,GLenum -> Ptr GLfloat -> IO ())
+pointParameterfv = glPointParameterfv . marshalPointParameter
diff --git a/Graphics/Rendering/OpenGL/GL/Points.hs b/Graphics/Rendering/OpenGL/GL/Points.hs
--- a/Graphics/Rendering/OpenGL/GL/Points.hs
+++ b/Graphics/Rendering/OpenGL/GL/Points.hs
@@ -32,21 +32,13 @@
    aliasedPointSizeRange, smoothPointSizeRange, smoothPointSizeGranularity
 ) where
 
-import Control.Monad ( liftM2 )
-import Foreign.Marshal.Array ( withArray )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapVertexProgramPointSize,CapPointSmooth,CapPointSprite),
-   makeCapability )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLfloat, Capability )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetPointSize,GetAliasedPointSizeRange,GetSmoothPointSizeRange,
-            GetSmoothPointSizeGranularity,GetPointSizeMin,GetPointSizeMax,
-            GetPointDistanceAttenuation,GetPointFadeThresholdSize),
-   getFloat1, getFloat2, getFloat3 )
-import Graphics.Rendering.OpenGL.GL.PointParameter (
-   PointParameter(..), pointParameterf, pointParameterfv )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
+import Control.Monad
+import Data.StateVar
+import Foreign.Marshal.Array
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.PointParameter
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -136,8 +128,6 @@
 pointSize :: StateVar GLfloat
 pointSize = makeStateVar (getFloat1 id GetPointSize) glPointSize
 
-foreign import CALLCONV unsafe "glPointSize" glPointSize :: GLfloat -> IO ()
-
 --------------------------------------------------------------------------------
 
 vertexProgramPointSize :: StateVar Capability
@@ -191,7 +181,7 @@
 --------------------------------------------------------------------------------
 
 -- | Controls whether point antialiasing is enabled. The initial state is
--- 'Graphics.Rendering.OpenGL.GL.BasicTypes.Disabled'.
+-- 'Graphics.Rendering.OpenGL.GL.Capability.Disabled'.
 
 pointSmooth :: StateVar Capability
 pointSmooth = makeCapability CapPointSmooth
@@ -199,7 +189,7 @@
 --------------------------------------------------------------------------------
 
 -- | Controls whether point sprites are enabled. The initial state is
--- 'Graphics.Rendering.OpenGL.GL.BasicTypes.Disabled'. When point sprites are
+-- 'Graphics.Rendering.OpenGL.GL.Capability.Disabled'. When point sprites are
 -- enabled, the state of point antialiasing (i.e. 'pointSmooth') is ignored.
 
 pointSprite :: StateVar Capability
diff --git a/Graphics/Rendering/OpenGL/GL/PolygonMode.hs b/Graphics/Rendering/OpenGL/GL/PolygonMode.hs
--- a/Graphics/Rendering/OpenGL/GL/PolygonMode.hs
+++ b/Graphics/Rendering/OpenGL/GL/PolygonMode.hs
@@ -17,7 +17,7 @@
    PolygonMode(..), marshalPolygonMode, unmarshalPolygonMode
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -29,13 +29,13 @@
 
 marshalPolygonMode :: PolygonMode -> GLenum
 marshalPolygonMode x = case x of
-   Point -> 0x1b00
-   Line -> 0x1b01
-   Fill -> 0x1b02
+   Point -> gl_POINT
+   Line -> gl_LINE
+   Fill -> gl_FILL
 
 unmarshalPolygonMode :: GLenum -> PolygonMode
 unmarshalPolygonMode x
-   | x == 0x1b00 = Point
-   | x == 0x1b01 = Line
-   | x == 0x1b02 = Fill
+   | x == gl_POINT = Point
+   | x == gl_LINE = Line
+   | x == gl_FILL = Fill
    | otherwise = error ("unmarshalPolygonMode: illegal value " ++ show x)
diff --git a/Graphics/Rendering/OpenGL/GL/Polygons.hs b/Graphics/Rendering/OpenGL/GL/Polygons.hs
--- a/Graphics/Rendering/OpenGL/GL/Polygons.hs
+++ b/Graphics/Rendering/OpenGL/GL/Polygons.hs
@@ -19,30 +19,20 @@
    polygonOffsetPoint, polygonOffsetLine, polygonOffsetFill
 ) where
 
-import Control.Monad ( liftM2 )
-import Foreign.ForeignPtr ( ForeignPtr, mallocForeignPtrArray, withForeignPtr )
-import Foreign.Marshal.Array ( allocaArray, withArray, peekArray, pokeArray )
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapPolygonSmooth,CapCullFace,CapPolygonStipple,
-             CapPolygonOffsetPoint,CapPolygonOffsetLine,CapPolygonOffsetFill),
-   makeCapability, makeStateVarMaybe )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLenum, GLubyte, GLfloat, Capability )
-import Graphics.Rendering.OpenGL.GL.Face ( marshalFace, unmarshalFace )
-import Graphics.Rendering.OpenGL.GL.Colors ( Face(..) )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles (
-   PixelStoreDirection(..), rowLength, skipRows, skipPixels )
-import Graphics.Rendering.OpenGL.GL.PolygonMode (
-   PolygonMode(..), marshalPolygonMode, unmarshalPolygonMode )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetCullFaceMode,GetPolygonMode,GetPolygonOffsetFactor,
-            GetPolygonOffsetUnits),
-   getInteger2, getEnum1, getFloat1 )
-import Graphics.Rendering.OpenGL.GL.SavingState (
-   ClientAttributeGroup(PixelStoreAttributes), preservingClientAttrib )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   HasSetter(($=)), StateVar, makeStateVar )
+import Control.Monad
+import Data.StateVar
+import Foreign.ForeignPtr
+import Foreign.Marshal.Array
+import Foreign.Ptr
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.Face
+import Graphics.Rendering.OpenGL.GL.PixelRectangles
+import Graphics.Rendering.OpenGL.GL.PolygonMode
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.SavingState
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glPolygonStipple, glGetPolygonStipple )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -56,8 +46,6 @@
                              (getEnum1 unmarshalFace GetCullFaceMode)
                              (glCullFace . marshalFace)
 
-foreign import CALLCONV unsafe "glCullFace" glCullFace :: GLenum -> IO ()
-
 --------------------------------------------------------------------------------
 
 numPolygonStippleBytes :: Int
@@ -117,12 +105,6 @@
       skipPixels direction $= 0
       action
 
-foreign import CALLCONV unsafe "glGetPolygonStipple" glGetPolygonStipple ::
-   Ptr GLubyte -> IO ()
-
-foreign import CALLCONV unsafe "glPolygonStipple" glPolygonStipple ::
-   Ptr GLubyte -> IO ()
-
 --------------------------------------------------------------------------------
 
 polygonMode :: StateVar (PolygonMode, PolygonMode)
@@ -137,9 +119,6 @@
    glPolygonMode (marshalFace Front) (marshalPolygonMode front)
    glPolygonMode (marshalFace Back ) (marshalPolygonMode back )
 
-foreign import CALLCONV unsafe "glPolygonMode" glPolygonMode ::
-   GLenum -> GLenum -> IO ()
-
 --------------------------------------------------------------------------------
 
 polygonOffset :: StateVar (GLfloat, GLfloat)
@@ -147,9 +126,6 @@
    makeStateVar (liftM2 (,) (getFloat1 id GetPolygonOffsetFactor)
                             (getFloat1 id GetPolygonOffsetUnits))
                 (uncurry glPolygonOffset)
-
-foreign import CALLCONV unsafe "glPolygonOffset" glPolygonOffset ::
-   GLfloat -> GLfloat -> IO ()
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/PrimitiveMode.hs b/Graphics/Rendering/OpenGL/GL/PrimitiveMode.hs
--- a/Graphics/Rendering/OpenGL/GL/PrimitiveMode.hs
+++ b/Graphics/Rendering/OpenGL/GL/PrimitiveMode.hs
@@ -17,7 +17,9 @@
    PrimitiveMode(..), marshalPrimitiveMode, unmarshalPrimitiveMode
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   gl_QUADS, gl_QUAD_STRIP, gl_POLYGON )
 
 --------------------------------------------------------------------------------
 
@@ -70,27 +72,27 @@
 
 marshalPrimitiveMode :: PrimitiveMode -> GLenum
 marshalPrimitiveMode x = case x of
-   Points -> 0x0
-   Lines -> 0x1
-   LineLoop -> 0x2
-   LineStrip -> 0x3
-   Triangles -> 0x4
-   TriangleStrip -> 0x5
-   TriangleFan -> 0x6
-   Quads -> 0x7
-   QuadStrip -> 0x8
-   Polygon -> 0x9
+   Points -> gl_POINTS
+   Lines -> gl_LINES
+   LineLoop -> gl_LINE_LOOP
+   LineStrip -> gl_LINE_STRIP
+   Triangles -> gl_TRIANGLES
+   TriangleStrip -> gl_TRIANGLE_STRIP
+   TriangleFan -> gl_TRIANGLE_FAN
+   Quads -> gl_QUADS
+   QuadStrip -> gl_QUAD_STRIP
+   Polygon -> gl_POLYGON
 
 unmarshalPrimitiveMode :: GLenum -> PrimitiveMode
 unmarshalPrimitiveMode x
-   | x == 0x0 = Points
-   | x == 0x1 = Lines
-   | x == 0x2 = LineLoop
-   | x == 0x3 = LineStrip
-   | x == 0x4 = Triangles
-   | x == 0x5 = TriangleStrip
-   | x == 0x6 = TriangleFan
-   | x == 0x7 = Quads
-   | x == 0x8 = QuadStrip
-   | x == 0x9 = Polygon
+   | x == gl_POINTS = Points
+   | x == gl_LINES = Lines
+   | x == gl_LINE_LOOP = LineLoop
+   | x == gl_LINE_STRIP = LineStrip
+   | x == gl_TRIANGLES = Triangles
+   | x == gl_TRIANGLE_STRIP = TriangleStrip
+   | x == gl_TRIANGLE_FAN = TriangleFan
+   | x == gl_QUADS = Quads
+   | x == gl_QUAD_STRIP = QuadStrip
+   | x == gl_POLYGON = Polygon
    | otherwise = error ("unmarshalPrimitiveMode: illegal value " ++ show x)
diff --git a/Graphics/Rendering/OpenGL/GL/QueryUtils.hs b/Graphics/Rendering/OpenGL/GL/QueryUtils.hs
--- a/Graphics/Rendering/OpenGL/GL/QueryUtils.hs
+++ b/Graphics/Rendering/OpenGL/GL/QueryUtils.hs
@@ -30,20 +30,111 @@
    GetVertexAttribPointerPName(..), getVertexAttribPointer
 ) where
 
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Marshal.Array ( allocaArray )
-import Foreign.Ptr ( Ptr, nullPtr )
-import Foreign.Storable ( Storable(peek) )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLenum, GLint, GLsizei, GLuint, GLfloat, GLdouble )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1, peek2, peek3, peek4 )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal ( recordInvalidEnum )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Array
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   gl_ACCUM_ALPHA_BITS, gl_ACCUM_BLUE_BITS, gl_ACCUM_CLEAR_VALUE,
+   gl_ACCUM_GREEN_BITS, gl_ACCUM_RED_BITS, gl_ALIASED_POINT_SIZE_RANGE,
+   gl_ALPHA_BIAS, gl_ALPHA_BITS, gl_ALPHA_SCALE, gl_ALPHA_TEST,
+   gl_ALPHA_TEST_FUNC, gl_ALPHA_TEST_REF, gl_ATTRIB_STACK_DEPTH, gl_AUTO_NORMAL,
+   gl_AUX_BUFFERS, gl_BLUE_BIAS, gl_BLUE_BITS, gl_BLUE_SCALE,
+   gl_CLIENT_ACTIVE_TEXTURE, gl_CLIENT_ATTRIB_STACK_DEPTH, gl_COLOR_ARRAY,
+   gl_COLOR_ARRAY_BUFFER_BINDING, gl_COLOR_ARRAY_SIZE, gl_COLOR_ARRAY_STRIDE,
+   gl_COLOR_ARRAY_TYPE, gl_COLOR_MATERIAL, gl_COLOR_MATERIAL_FACE,
+   gl_COLOR_MATERIAL_PARAMETER, gl_COLOR_MATRIX, gl_COLOR_MATRIX_STACK_DEPTH,
+   gl_COLOR_SUM, gl_COLOR_TABLE, gl_CONVOLUTION_1D, gl_CONVOLUTION_2D,
+   gl_CURRENT_COLOR, gl_CURRENT_FOG_COORD, gl_CURRENT_INDEX, gl_CURRENT_NORMAL,
+   gl_CURRENT_RASTER_COLOR, gl_CURRENT_RASTER_DISTANCE, gl_CURRENT_RASTER_INDEX,
+   gl_CURRENT_RASTER_POSITION, gl_CURRENT_RASTER_POSITION_VALID,
+   gl_CURRENT_RASTER_SECONDARY_COLOR, gl_CURRENT_RASTER_TEXTURE_COORDS,
+   gl_CURRENT_SECONDARY_COLOR, gl_CURRENT_TEXTURE_COORDS, gl_DEPTH_BIAS,
+   gl_DEPTH_BITS, gl_DEPTH_SCALE, gl_EDGE_FLAG, gl_EDGE_FLAG_ARRAY,
+   gl_EDGE_FLAG_ARRAY_BUFFER_BINDING, gl_EDGE_FLAG_ARRAY_STRIDE,
+   gl_FEEDBACK_BUFFER_SIZE, gl_FEEDBACK_BUFFER_TYPE, gl_FOG, gl_FOG_COLOR,
+   gl_FOG_COORD_ARRAY, gl_FOG_COORD_ARRAY_BUFFER_BINDING,
+   gl_FOG_COORD_ARRAY_STRIDE, gl_FOG_COORD_ARRAY_TYPE, gl_FOG_COORD_SRC,
+   gl_FOG_DENSITY, gl_FOG_END, gl_FOG_HINT, gl_FOG_INDEX, gl_FOG_MODE,
+   gl_FOG_START, gl_GENERATE_MIPMAP_HINT, gl_GREEN_BIAS, gl_GREEN_BITS,
+   gl_GREEN_SCALE, gl_HISTOGRAM, gl_INDEX_ARRAY, gl_INDEX_ARRAY_BUFFER_BINDING,
+   gl_INDEX_ARRAY_STRIDE, gl_INDEX_ARRAY_TYPE, gl_INDEX_BITS,
+   gl_INDEX_CLEAR_VALUE, gl_INDEX_LOGIC_OP, gl_INDEX_MODE, gl_INDEX_OFFSET,
+   gl_INDEX_SHIFT, gl_INDEX_WRITEMASK, gl_LIGHT0, gl_LIGHTING,
+   gl_LIGHT_MODEL_AMBIENT, gl_LIGHT_MODEL_COLOR_CONTROL,
+   gl_LIGHT_MODEL_LOCAL_VIEWER, gl_LIGHT_MODEL_TWO_SIDE, gl_LINE_STIPPLE,
+   gl_LINE_STIPPLE_PATTERN, gl_LINE_STIPPLE_REPEAT, gl_LIST_BASE, gl_LIST_INDEX,
+   gl_LIST_MODE, gl_MAP1_COLOR_4, gl_MAP1_GRID_DOMAIN, gl_MAP1_GRID_SEGMENTS,
+   gl_MAP1_INDEX, gl_MAP1_NORMAL, gl_MAP1_TEXTURE_COORD_1,
+   gl_MAP1_TEXTURE_COORD_2, gl_MAP1_TEXTURE_COORD_3, gl_MAP1_TEXTURE_COORD_4,
+   gl_MAP1_VERTEX_3, gl_MAP1_VERTEX_4, gl_MAP2_COLOR_4, gl_MAP2_GRID_DOMAIN,
+   gl_MAP2_GRID_SEGMENTS, gl_MAP2_INDEX, gl_MAP2_NORMAL,
+   gl_MAP2_TEXTURE_COORD_1, gl_MAP2_TEXTURE_COORD_2, gl_MAP2_TEXTURE_COORD_3,
+   gl_MAP2_TEXTURE_COORD_4, gl_MAP2_VERTEX_3, gl_MAP2_VERTEX_4, gl_MAP_COLOR,
+   gl_MAP_STENCIL, gl_MATRIX_MODE, gl_MAX_ATTRIB_STACK_DEPTH,
+   gl_MAX_CLIENT_ATTRIB_STACK_DEPTH, gl_MAX_COLOR_MATRIX_STACK_DEPTH,
+   gl_MAX_CONVOLUTION_HEIGHT, gl_MAX_CONVOLUTION_WIDTH, gl_MAX_EVAL_ORDER,
+   gl_MAX_LIGHTS, gl_MAX_LIST_NESTING, gl_MAX_MODELVIEW_STACK_DEPTH,
+   gl_MAX_NAME_STACK_DEPTH, gl_MAX_PIXEL_MAP_TABLE,
+   gl_MAX_PROJECTION_STACK_DEPTH, gl_MAX_TEXTURE_COORDS,
+   gl_MAX_TEXTURE_STACK_DEPTH, gl_MAX_TEXTURE_UNITS, gl_MINMAX, gl_MODELVIEW,
+   gl_MODELVIEW_MATRIX, gl_MODELVIEW_STACK_DEPTH, gl_NAME_STACK_DEPTH,
+   gl_NORMALIZE, gl_NORMAL_ARRAY, gl_NORMAL_ARRAY_BUFFER_BINDING,
+   gl_NORMAL_ARRAY_STRIDE, gl_NORMAL_ARRAY_TYPE, gl_PERSPECTIVE_CORRECTION_HINT,
+   gl_PIXEL_MAP_A_TO_A_SIZE, gl_PIXEL_MAP_B_TO_B_SIZE, gl_PIXEL_MAP_G_TO_G_SIZE,
+   gl_PIXEL_MAP_I_TO_A_SIZE, gl_PIXEL_MAP_I_TO_B_SIZE, gl_PIXEL_MAP_I_TO_G_SIZE,
+   gl_PIXEL_MAP_I_TO_I_SIZE, gl_PIXEL_MAP_I_TO_R_SIZE, gl_PIXEL_MAP_R_TO_R_SIZE,
+   gl_PIXEL_MAP_S_TO_S_SIZE, gl_POINT_DISTANCE_ATTENUATION, gl_POINT_SIZE_MAX,
+   gl_POINT_SIZE_MIN, gl_POINT_SMOOTH, gl_POINT_SMOOTH_HINT, gl_POLYGON_MODE,
+   gl_POLYGON_STIPPLE, gl_POST_COLOR_MATRIX_ALPHA_BIAS,
+   gl_POST_COLOR_MATRIX_ALPHA_SCALE, gl_POST_COLOR_MATRIX_BLUE_BIAS,
+   gl_POST_COLOR_MATRIX_BLUE_SCALE, gl_POST_COLOR_MATRIX_COLOR_TABLE,
+   gl_POST_COLOR_MATRIX_GREEN_BIAS, gl_POST_COLOR_MATRIX_GREEN_SCALE,
+   gl_POST_COLOR_MATRIX_RED_BIAS, gl_POST_COLOR_MATRIX_RED_SCALE,
+   gl_POST_CONVOLUTION_ALPHA_BIAS, gl_POST_CONVOLUTION_ALPHA_SCALE,
+   gl_POST_CONVOLUTION_BLUE_BIAS, gl_POST_CONVOLUTION_BLUE_SCALE,
+   gl_POST_CONVOLUTION_COLOR_TABLE, gl_POST_CONVOLUTION_GREEN_BIAS,
+   gl_POST_CONVOLUTION_GREEN_SCALE, gl_POST_CONVOLUTION_RED_BIAS,
+   gl_POST_CONVOLUTION_RED_SCALE, gl_PROJECTION_MATRIX,
+   gl_PROJECTION_STACK_DEPTH, gl_RED_BIAS, gl_RED_BITS, gl_RED_SCALE,
+   gl_RENDER_MODE, gl_RESCALE_NORMAL, gl_RGBA_MODE, gl_SECONDARY_COLOR_ARRAY,
+   gl_SECONDARY_COLOR_ARRAY_BUFFER_BINDING, gl_SECONDARY_COLOR_ARRAY_SIZE,
+   gl_SECONDARY_COLOR_ARRAY_STRIDE, gl_SECONDARY_COLOR_ARRAY_TYPE,
+   gl_SELECTION_BUFFER_SIZE, gl_SEPARABLE_2D, gl_SHADE_MODEL, gl_STENCIL_BITS,
+   gl_TEXTURE_COORD_ARRAY, gl_TEXTURE_COORD_ARRAY_BUFFER_BINDING,
+   gl_TEXTURE_COORD_ARRAY_SIZE, gl_TEXTURE_COORD_ARRAY_STRIDE,
+   gl_TEXTURE_COORD_ARRAY_TYPE, gl_TEXTURE_GEN_Q, gl_TEXTURE_GEN_R,
+   gl_TEXTURE_GEN_S, gl_TEXTURE_GEN_T, gl_TEXTURE_MATRIX,
+   gl_TEXTURE_STACK_DEPTH, gl_TRANSPOSE_COLOR_MATRIX,
+   gl_TRANSPOSE_MODELVIEW_MATRIX, gl_TRANSPOSE_PROJECTION_MATRIX,
+   gl_TRANSPOSE_TEXTURE_MATRIX, gl_VERTEX_ARRAY, gl_VERTEX_ARRAY_BUFFER_BINDING,
+   gl_VERTEX_ARRAY_SIZE, gl_VERTEX_ARRAY_STRIDE, gl_VERTEX_ARRAY_TYPE,
+   gl_ZOOM_X, gl_ZOOM_Y )
+import Graphics.Rendering.OpenGL.Raw.ARB.FragmentProgram (
+   gl_CURRENT_MATRIX, gl_CURRENT_MATRIX_STACK_DEPTH )
+import Graphics.Rendering.OpenGL.Raw.ARB.MatrixPalette (
+   gl_CURRENT_MATRIX_INDEX, gl_CURRENT_PALETTE_MATRIX, gl_MATRIX_INDEX_ARRAY,
+   gl_MATRIX_INDEX_ARRAY_SIZE, gl_MATRIX_INDEX_ARRAY_STRIDE,
+   gl_MATRIX_INDEX_ARRAY_TYPE, gl_MATRIX_PALETTE,
+   gl_MAX_MATRIX_PALETTE_STACK_DEPTH, gl_MAX_PALETTE_MATRICES )
+import Graphics.Rendering.OpenGL.Raw.ARB.VertexBlend (
+   gl_ACTIVE_VERTEX_UNITS, gl_CURRENT_WEIGHT, gl_MAX_VERTEX_UNITS,
+   gl_MODELVIEW1, gl_MODELVIEW2, gl_MODELVIEW31, gl_VERTEX_BLEND,
+   gl_WEIGHT_ARRAY, gl_WEIGHT_ARRAY_SIZE, gl_WEIGHT_ARRAY_STRIDE,
+   gl_WEIGHT_ARRAY_TYPE, gl_WEIGHT_SUM_UNITY )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.EXT ( gl_RGBA_SIGNED_COMPONENTS )
+import Graphics.Rendering.OpenGL.Raw.EXT.Cmyka ( gl_PACK_CMYK_HINT, gl_UNPACK_CMYK_HINT )
+import Graphics.Rendering.OpenGL.Raw.EXT.CompiledVertexArray ( gl_ARRAY_ELEMENT_LOCK_FIRST, gl_ARRAY_ELEMENT_LOCK_COUNT )
+import Graphics.Rendering.OpenGL.Raw.EXT.DepthBoundsTest ( gl_DEPTH_BOUNDS, )
+import Graphics.Rendering.OpenGL.Raw.EXT.SharedTexturePalette ( gl_SHARED_TEXTURE_PALETTE )
+import Graphics.Rendering.OpenGL.Raw.EXT.StencilTwoSide ( gl_ACTIVE_STENCIL_FACE )
+import Graphics.Rendering.OpenGL.Raw.EXT.TextureFilterAnisotropic ( gl_MAX_TEXTURE_MAX_ANISOTROPY )
+import Graphics.Rendering.OpenGL.Raw.NV.FogDistance ( gl_FOG_DISTANCE_MODE )
+import Graphics.Rendering.OpenGL.Raw.NV.LightMaxExponent (  gl_MAX_SHININESS, gl_MAX_SPOT_EXPONENT )
+import Graphics.Rendering.OpenGL.Raw.NV.PrimitiveRestart ( gl_PRIMITIVE_RESTART_INDEX_NV, gl_PRIMITIVE_RESTART_NV )
 
 --------------------------------------------------------------------------------
 
@@ -398,6 +489,8 @@
    | GetFogDistanceMode
    | GetDepthBounds
    | GetPrimitiveRestartIndex
+   | GetPrimitiveRestartNV
+   | GetPrimitiveRestartIndexNV
    | GetActiveStencilFace
    | GetArrayBufferBinding
    | GetElementArrayBufferBinding
@@ -433,388 +526,390 @@
 
 marshalGetPName :: GetPName -> Maybe GLenum
 marshalGetPName x = case x of
-   GetCurrentColor -> Just 0xb00
-   GetCurrentIndex -> Just 0xb01
-   GetCurrentNormal -> Just 0xb02
-   GetCurrentTextureCoords -> Just 0xb03
-   GetCurrentRasterColor -> Just 0xb04
-   GetCurrentRasterSecondaryColor -> Just 0x845f
-   GetCurrentRasterIndex -> Just 0xb05
-   GetCurrentRasterTextureCoords -> Just 0xb06
-   GetCurrentRasterPosition -> Just 0xb07
-   GetCurrentRasterPositionValid -> Just 0xb08
-   GetCurrentRasterDistance -> Just 0xb09
-   GetCurrentMatrixIndex -> Just 0x8845
-   GetPointSmooth -> Just 0xb10
-   GetPointSize -> Just 0xb11
-   GetPointSizeRange -> Just 0xb12
-   GetPointSizeGranularity -> Just 0xb13
-   GetLineSmooth -> Just 0xb20
-   GetLineWidth -> Just 0xb21
-   GetLineWidthRange -> Just 0xb22
-   GetLineWidthGranularity -> Just 0xb23
-   GetLineStipple -> Just 0xb24
-   GetLineStipplePattern -> Just 0xb25
-   GetLineStippleRepeat -> Just 0xb26
-   GetSmoothPointSizeRange -> Just 0xb12
-   GetSmoothPointSizeGranularity -> Just 0xb13
-   GetSmoothLineWidthRange -> Just 0xb22
-   GetSmoothLineWidthGranularity -> Just 0xb23
-   GetAliasedPointSizeRange -> Just 0x846d
-   GetAliasedLineWidthRange -> Just 0x846e
-   GetListMode -> Just 0xb30
-   GetMaxListNesting -> Just 0xb31
-   GetListBase -> Just 0xb32
-   GetListIndex -> Just 0xb33
-   GetPolygonMode -> Just 0xb40
-   GetPolygonSmooth -> Just 0xb41
-   GetPolygonStipple -> Just 0xb42
-   GetEdgeFlag -> Just 0xb43
-   GetCullFace -> Just 0xb44
-   GetCullFaceMode -> Just 0xb45
-   GetFrontFace -> Just 0xb46
-   GetLighting -> Just 0xb50
-   GetLightModelLocalViewer -> Just 0xb51
-   GetLightModelTwoSide -> Just 0xb52
-   GetLightModelAmbient -> Just 0xb53
-   GetShadeModel -> Just 0xb54
-   GetColorMaterialFace -> Just 0xb55
-   GetColorMaterialParameter -> Just 0xb56
-   GetColorMaterial -> Just 0xb57
-   GetFog -> Just 0xb60
-   GetFogIndex -> Just 0xb61
-   GetFogDensity -> Just 0xb62
-   GetFogStart -> Just 0xb63
-   GetFogEnd -> Just 0xb64
-   GetFogMode -> Just 0xb65
-   GetFogColor -> Just 0xb66
-   GetFogCoordSrc -> Just 0x8450
-   GetCurrentFogCoord -> Just 0x8453
-   GetDepthRange -> Just 0xb70
-   GetDepthTest -> Just 0xb71
-   GetDepthWritemask -> Just 0xb72
-   GetDepthClearValue -> Just 0xb73
-   GetDepthFunc -> Just 0xb74
-   GetAccumClearValue -> Just 0xb80
-   GetStencilTest -> Just 0xb90
-   GetStencilClearValue -> Just 0xb91
-   GetStencilFunc -> Just 0xb92
-   GetStencilValueMask -> Just 0xb93
-   GetStencilFail -> Just 0xb94
-   GetStencilPassDepthFail -> Just 0xb95
-   GetStencilPassDepthPass -> Just 0xb96
-   GetStencilRef -> Just 0xb97
-   GetStencilWritemask -> Just 0xb98
-   GetMatrixMode -> Just 0xba0
-   GetNormalize -> Just 0xba1
-   GetViewport -> Just 0xba2
-   GetModelviewStackDepth -> Just 0xba3
-   GetProjectionStackDepth -> Just 0xba4
-   GetTextureStackDepth -> Just 0xba5
-   GetModelviewMatrix -> Just 0xba6
-   GetProjectionMatrix -> Just 0xba7
-   GetTextureMatrix -> Just 0xba8
-   GetAttribStackDepth -> Just 0xbb0
-   GetClientAttribStackDepth -> Just 0xbb1
-   GetAlphaTest -> Just 0xbc0
-   GetAlphaTestFunc -> Just 0xbc1
-   GetAlphaTestRef -> Just 0xbc2
-   GetDither -> Just 0xbd0
-   GetBlendDst -> Just 0xbe0
-   GetBlendSrc -> Just 0xbe1
-   GetBlend -> Just 0xbe2
-   GetLogicOpMode -> Just 0xbf0
-   GetIndexLogicOp -> Just 0xbf1
-   GetLogicOp -> Just 0xbf1
-   GetColorLogicOp -> Just 0xbf2
-   GetAuxBuffers -> Just 0xc00
-   GetDrawBuffer -> Just 0xc01
-   GetReadBuffer -> Just 0xc02
-   GetScissorBox -> Just 0xc10
-   GetScissorTest -> Just 0xc11
-   GetIndexClearValue -> Just 0xc20
-   GetIndexWritemask -> Just 0xc21
-   GetColorClearValue -> Just 0xc22
-   GetColorWritemask -> Just 0xc23
-   GetIndexMode -> Just 0xc30
-   GetRGBAMode -> Just 0xc31
-   GetDoublebuffer -> Just 0xc32
-   GetStereo -> Just 0xc33
-   GetRenderMode -> Just 0xc40
-   GetPerspectiveCorrectionHint -> Just 0xc50
-   GetPointSmoothHint -> Just 0xc51
-   GetLineSmoothHint -> Just 0xc52
-   GetPolygonSmoothHint -> Just 0xc53
-   GetFogHint -> Just 0xc54
-   GetGenerateMipmapHint -> Just 0x8192
-   GetTextureCompressionHint -> Just 0x84ef
-   GetTextureGenS -> Just 0xc60
-   GetTextureGenT -> Just 0xc61
-   GetTextureGenR -> Just 0xc62
-   GetTextureGenQ -> Just 0xc63
-   GetPixelMapIToISize -> Just 0xcb0
-   GetPixelMapSToSSize -> Just 0xcb1
-   GetPixelMapIToRSize -> Just 0xcb2
-   GetPixelMapIToGSize -> Just 0xcb3
-   GetPixelMapIToBSize -> Just 0xcb4
-   GetPixelMapIToASize -> Just 0xcb5
-   GetPixelMapRToRSize -> Just 0xcb6
-   GetPixelMapGToGSize -> Just 0xcb7
-   GetPixelMapBToBSize -> Just 0xcb8
-   GetPixelMapAToASize -> Just 0xcb9
-   GetUnpackSwapBytes -> Just 0xcf0
-   GetUnpackLSBFirst -> Just 0xcf1
-   GetUnpackRowLength -> Just 0xcf2
-   GetUnpackSkipRows -> Just 0xcf3
-   GetUnpackSkipPixels -> Just 0xcf4
-   GetUnpackAlignment -> Just 0xcf5
-   GetPackSwapBytes -> Just 0xd00
-   GetPackLSBFirst -> Just 0xd01
-   GetPackRowLength -> Just 0xd02
-   GetPackSkipRows -> Just 0xd03
-   GetPackSkipPixels -> Just 0xd04
-   GetPackAlignment -> Just 0xd05
-   GetMapColor -> Just 0xd10
-   GetMapStencil -> Just 0xd11
-   GetIndexShift -> Just 0xd12
-   GetIndexOffset -> Just 0xd13
-   GetRedScale -> Just 0xd14
-   GetRedBias -> Just 0xd15
-   GetZoomX -> Just 0xd16
-   GetZoomY -> Just 0xd17
-   GetGreenScale -> Just 0xd18
-   GetGreenBias -> Just 0xd19
-   GetBlueScale -> Just 0xd1a
-   GetBlueBias -> Just 0xd1b
-   GetAlphaScale -> Just 0xd1c
-   GetAlphaBias -> Just 0xd1d
-   GetDepthScale -> Just 0xd1e
-   GetDepthBias -> Just 0xd1f
-   GetMaxEvalOrder -> Just 0xd30
-   GetMaxLights -> Just 0xd31
-   GetMaxClipPlanes -> Just 0xd32
-   GetMaxTextureSize -> Just 0xd33
-   GetMaxPixelMapTable -> Just 0xd34
-   GetMaxAttribStackDepth -> Just 0xd35
-   GetMaxModelviewStackDepth -> Just 0xd36
-   GetMaxNameStackDepth -> Just 0xd37
-   GetMaxProjectionStackDepth -> Just 0xd38
-   GetMaxTextureStackDepth -> Just 0xd39
-   GetMaxViewportDims -> Just 0xd3a
-   GetMaxClientAttribStackDepth -> Just 0xd3b
-   GetSubpixelBits -> Just 0xd50
-   GetIndexBits -> Just 0xd51
-   GetRedBits -> Just 0xd52
-   GetGreenBits -> Just 0xd53
-   GetBlueBits -> Just 0xd54
-   GetAlphaBits -> Just 0xd55
-   GetDepthBits -> Just 0xd56
-   GetStencilBits -> Just 0xd57
-   GetAccumRedBits -> Just 0xd58
-   GetAccumGreenBits -> Just 0xd59
-   GetAccumBlueBits -> Just 0xd5a
-   GetAccumAlphaBits -> Just 0xd5b
-   GetNameStackDepth -> Just 0xd70
-   GetAutoNormal -> Just 0xd80
-   GetMap1Color4 -> Just 0xd90
-   GetMap1Index -> Just 0xd91
-   GetMap1Normal -> Just 0xd92
-   GetMap1TextureCoord1 -> Just 0xd93
-   GetMap1TextureCoord2 -> Just 0xd94
-   GetMap1TextureCoord3 -> Just 0xd95
-   GetMap1TextureCoord4 -> Just 0xd96
-   GetMap1Vertex3 -> Just 0xd97
-   GetMap1Vertex4 -> Just 0xd98
-   GetMap2Color4 -> Just 0xdb0
-   GetMap2Index -> Just 0xdb1
-   GetMap2Normal -> Just 0xdb2
-   GetMap2TextureCoord1 -> Just 0xdb3
-   GetMap2TextureCoord2 -> Just 0xdb4
-   GetMap2TextureCoord3 -> Just 0xdb5
-   GetMap2TextureCoord4 -> Just 0xdb6
-   GetMap2Vertex3 -> Just 0xdb7
-   GetMap2Vertex4 -> Just 0xdb8
-   GetMap1GridDomain -> Just 0xdd0
-   GetMap1GridSegments -> Just 0xdd1
-   GetMap2GridDomain -> Just 0xdd2
-   GetMap2GridSegments -> Just 0xdd3
-   GetTexture1D -> Just 0xde0
-   GetTexture2D -> Just 0xde1
-   GetFeedbackBufferSize -> Just 0xdf1
-   GetFeedbackBufferType -> Just 0xdf2
-   GetSelectionBufferSize -> Just 0xdf4
-   GetPolygonOffsetUnits -> Just 0x2a00
-   GetPolygonOffsetPoint -> Just 0x2a01
-   GetPolygonOffsetLine -> Just 0x2a02
-   GetPolygonOffsetFill -> Just 0x8037
-   GetPolygonOffsetFactor -> Just 0x8038
-   GetTextureBinding1D -> Just 0x8068
-   GetTextureBinding2D -> Just 0x8069
-   GetTextureBinding3D -> Just 0x806a
-   GetVertexArray -> Just 0x8074
-   GetNormalArray -> Just 0x8075
-   GetColorArray -> Just 0x8076
-   GetIndexArray -> Just 0x8077
-   GetTextureCoordArray -> Just 0x8078
-   GetEdgeFlagArray -> Just 0x8079
-   GetFogCoordArray -> Just 0x8457
-   GetSecondaryColorArray -> Just 0x845e
-   GetMatrixIndexArray -> Just 0x8844
-   GetVertexArraySize -> Just 0x807a
-   GetVertexArrayType -> Just 0x807b
-   GetVertexArrayStride -> Just 0x807c
-   GetNormalArrayType -> Just 0x807e
-   GetNormalArrayStride -> Just 0x807f
-   GetColorArraySize -> Just 0x8081
-   GetColorArrayType -> Just 0x8082
-   GetColorArrayStride -> Just 0x8083
-   GetIndexArrayType -> Just 0x8085
-   GetIndexArrayStride -> Just 0x8086
-   GetTextureCoordArraySize -> Just 0x8088
-   GetTextureCoordArrayType -> Just 0x8089
-   GetTextureCoordArrayStride -> Just 0x808a
-   GetEdgeFlagArrayStride -> Just 0x808c
-   GetFogCoordArrayType -> Just 0x8454
-   GetFogCoordArrayStride -> Just 0x8455
-   GetSecondaryColorArraySize -> Just 0x845a
-   GetSecondaryColorArrayType -> Just 0x845b
-   GetSecondaryColorArrayStride -> Just 0x845c
-   GetMatrixIndexArraySize -> Just 0x8846
-   GetMatrixIndexArrayType -> Just 0x8847
-   GetMatrixIndexArrayStride -> Just 0x8848
+   GetCurrentColor -> Just gl_CURRENT_COLOR
+   GetCurrentIndex -> Just gl_CURRENT_INDEX
+   GetCurrentNormal -> Just gl_CURRENT_NORMAL
+   GetCurrentTextureCoords -> Just gl_CURRENT_TEXTURE_COORDS
+   GetCurrentRasterColor -> Just gl_CURRENT_RASTER_COLOR
+   GetCurrentRasterSecondaryColor -> Just gl_CURRENT_RASTER_SECONDARY_COLOR
+   GetCurrentRasterIndex -> Just gl_CURRENT_RASTER_INDEX
+   GetCurrentRasterTextureCoords -> Just gl_CURRENT_RASTER_TEXTURE_COORDS
+   GetCurrentRasterPosition -> Just gl_CURRENT_RASTER_POSITION
+   GetCurrentRasterPositionValid -> Just gl_CURRENT_RASTER_POSITION_VALID
+   GetCurrentRasterDistance -> Just gl_CURRENT_RASTER_DISTANCE
+   GetCurrentMatrixIndex -> Just gl_CURRENT_MATRIX_INDEX
+   GetPointSmooth -> Just gl_POINT_SMOOTH
+   GetPointSize -> Just gl_POINT_SIZE
+   GetPointSizeRange -> Just gl_POINT_SIZE_RANGE
+   GetPointSizeGranularity -> Just gl_POINT_SIZE_GRANULARITY
+   GetLineSmooth -> Just gl_LINE_SMOOTH
+   GetLineWidth -> Just gl_LINE_WIDTH
+   GetLineWidthRange -> Just gl_SMOOTH_LINE_WIDTH_RANGE
+   GetLineWidthGranularity -> Just gl_SMOOTH_LINE_WIDTH_GRANULARITY
+   GetLineStipple -> Just gl_LINE_STIPPLE
+   GetLineStipplePattern -> Just gl_LINE_STIPPLE_PATTERN
+   GetLineStippleRepeat -> Just gl_LINE_STIPPLE_REPEAT
+   GetSmoothPointSizeRange -> Just gl_POINT_SIZE_RANGE
+   GetSmoothPointSizeGranularity -> Just gl_POINT_SIZE_GRANULARITY
+   GetSmoothLineWidthRange -> Just gl_SMOOTH_LINE_WIDTH_RANGE
+   GetSmoothLineWidthGranularity -> Just gl_SMOOTH_LINE_WIDTH_GRANULARITY
+   GetAliasedPointSizeRange -> Just gl_ALIASED_POINT_SIZE_RANGE
+   GetAliasedLineWidthRange -> Just gl_ALIASED_LINE_WIDTH_RANGE
+   GetListMode -> Just gl_LIST_MODE
+   GetMaxListNesting -> Just gl_MAX_LIST_NESTING
+   GetListBase -> Just gl_LIST_BASE
+   GetListIndex -> Just gl_LIST_INDEX
+   GetPolygonMode -> Just gl_POLYGON_MODE
+   GetPolygonSmooth -> Just gl_POLYGON_SMOOTH
+   GetPolygonStipple -> Just gl_POLYGON_STIPPLE
+   GetEdgeFlag -> Just gl_EDGE_FLAG
+   GetCullFace -> Just gl_CULL_FACE
+   GetCullFaceMode -> Just gl_CULL_FACE_MODE
+   GetFrontFace -> Just gl_FRONT_FACE
+   GetLighting -> Just gl_LIGHTING
+   GetLightModelLocalViewer -> Just gl_LIGHT_MODEL_LOCAL_VIEWER
+   GetLightModelTwoSide -> Just gl_LIGHT_MODEL_TWO_SIDE
+   GetLightModelAmbient -> Just gl_LIGHT_MODEL_AMBIENT
+   GetShadeModel -> Just gl_SHADE_MODEL
+   GetColorMaterialFace -> Just gl_COLOR_MATERIAL_FACE
+   GetColorMaterialParameter -> Just gl_COLOR_MATERIAL_PARAMETER
+   GetColorMaterial -> Just gl_COLOR_MATERIAL
+   GetFog -> Just gl_FOG
+   GetFogIndex -> Just gl_FOG_INDEX
+   GetFogDensity -> Just gl_FOG_DENSITY
+   GetFogStart -> Just gl_FOG_START
+   GetFogEnd -> Just gl_FOG_END
+   GetFogMode -> Just gl_FOG_MODE
+   GetFogColor -> Just gl_FOG_COLOR
+   GetFogCoordSrc -> Just gl_FOG_COORD_SRC
+   GetCurrentFogCoord -> Just gl_CURRENT_FOG_COORD
+   GetDepthRange -> Just gl_DEPTH_RANGE
+   GetDepthTest -> Just gl_DEPTH_TEST
+   GetDepthWritemask -> Just gl_DEPTH_WRITEMASK
+   GetDepthClearValue -> Just gl_DEPTH_CLEAR_VALUE
+   GetDepthFunc -> Just gl_DEPTH_FUNC
+   GetAccumClearValue -> Just gl_ACCUM_CLEAR_VALUE
+   GetStencilTest -> Just gl_STENCIL_TEST
+   GetStencilClearValue -> Just gl_STENCIL_CLEAR_VALUE
+   GetStencilFunc -> Just gl_STENCIL_FUNC
+   GetStencilValueMask -> Just gl_STENCIL_VALUE_MASK
+   GetStencilFail -> Just gl_STENCIL_FAIL
+   GetStencilPassDepthFail -> Just gl_STENCIL_PASS_DEPTH_FAIL
+   GetStencilPassDepthPass -> Just gl_STENCIL_PASS_DEPTH_PASS
+   GetStencilRef -> Just gl_STENCIL_REF
+   GetStencilWritemask -> Just gl_STENCIL_WRITEMASK
+   GetMatrixMode -> Just gl_MATRIX_MODE
+   GetNormalize -> Just gl_NORMALIZE
+   GetViewport -> Just gl_VIEWPORT
+   GetModelviewStackDepth -> Just gl_MODELVIEW_STACK_DEPTH
+   GetProjectionStackDepth -> Just gl_PROJECTION_STACK_DEPTH
+   GetTextureStackDepth -> Just gl_TEXTURE_STACK_DEPTH
+   GetModelviewMatrix -> Just gl_MODELVIEW_MATRIX
+   GetProjectionMatrix -> Just gl_PROJECTION_MATRIX
+   GetTextureMatrix -> Just gl_TEXTURE_MATRIX
+   GetAttribStackDepth -> Just gl_ATTRIB_STACK_DEPTH
+   GetClientAttribStackDepth -> Just gl_CLIENT_ATTRIB_STACK_DEPTH
+   GetAlphaTest -> Just gl_ALPHA_TEST
+   GetAlphaTestFunc -> Just gl_ALPHA_TEST_FUNC
+   GetAlphaTestRef -> Just gl_ALPHA_TEST_REF
+   GetDither -> Just gl_DITHER
+   GetBlendDst -> Just gl_BLEND_DST
+   GetBlendSrc -> Just gl_BLEND_SRC
+   GetBlend -> Just gl_BLEND
+   GetLogicOpMode -> Just gl_LOGIC_OP_MODE
+   GetIndexLogicOp -> Just gl_INDEX_LOGIC_OP
+   GetLogicOp -> Just gl_INDEX_LOGIC_OP
+   GetColorLogicOp -> Just gl_COLOR_LOGIC_OP
+   GetAuxBuffers -> Just gl_AUX_BUFFERS
+   GetDrawBuffer -> Just gl_DRAW_BUFFER
+   GetReadBuffer -> Just gl_READ_BUFFER
+   GetScissorBox -> Just gl_SCISSOR_BOX
+   GetScissorTest -> Just gl_SCISSOR_TEST
+   GetIndexClearValue -> Just gl_INDEX_CLEAR_VALUE
+   GetIndexWritemask -> Just gl_INDEX_WRITEMASK
+   GetColorClearValue -> Just gl_COLOR_CLEAR_VALUE
+   GetColorWritemask -> Just gl_COLOR_WRITEMASK
+   GetIndexMode -> Just gl_INDEX_MODE
+   GetRGBAMode -> Just gl_RGBA_MODE
+   GetDoublebuffer -> Just gl_DOUBLEBUFFER
+   GetStereo -> Just gl_STEREO
+   GetRenderMode -> Just gl_RENDER_MODE
+   GetPerspectiveCorrectionHint -> Just gl_PERSPECTIVE_CORRECTION_HINT
+   GetPointSmoothHint -> Just gl_POINT_SMOOTH_HINT
+   GetLineSmoothHint -> Just gl_LINE_SMOOTH_HINT
+   GetPolygonSmoothHint -> Just gl_POLYGON_SMOOTH_HINT
+   GetFogHint -> Just gl_FOG_HINT
+   GetGenerateMipmapHint -> Just gl_GENERATE_MIPMAP_HINT
+   GetTextureCompressionHint -> Just gl_TEXTURE_COMPRESSION_HINT
+   GetTextureGenS -> Just gl_TEXTURE_GEN_S
+   GetTextureGenT -> Just gl_TEXTURE_GEN_T
+   GetTextureGenR -> Just gl_TEXTURE_GEN_R
+   GetTextureGenQ -> Just gl_TEXTURE_GEN_Q
+   GetPixelMapIToISize -> Just gl_PIXEL_MAP_I_TO_I_SIZE
+   GetPixelMapSToSSize -> Just gl_PIXEL_MAP_S_TO_S_SIZE
+   GetPixelMapIToRSize -> Just gl_PIXEL_MAP_I_TO_R_SIZE
+   GetPixelMapIToGSize -> Just gl_PIXEL_MAP_I_TO_G_SIZE
+   GetPixelMapIToBSize -> Just gl_PIXEL_MAP_I_TO_B_SIZE
+   GetPixelMapIToASize -> Just gl_PIXEL_MAP_I_TO_A_SIZE
+   GetPixelMapRToRSize -> Just gl_PIXEL_MAP_R_TO_R_SIZE
+   GetPixelMapGToGSize -> Just gl_PIXEL_MAP_G_TO_G_SIZE
+   GetPixelMapBToBSize -> Just gl_PIXEL_MAP_B_TO_B_SIZE
+   GetPixelMapAToASize -> Just gl_PIXEL_MAP_A_TO_A_SIZE
+   GetUnpackSwapBytes -> Just gl_UNPACK_SWAP_BYTES
+   GetUnpackLSBFirst -> Just gl_UNPACK_LSB_FIRST
+   GetUnpackRowLength -> Just gl_UNPACK_ROW_LENGTH
+   GetUnpackSkipRows -> Just gl_UNPACK_SKIP_ROWS
+   GetUnpackSkipPixels -> Just gl_UNPACK_SKIP_PIXELS
+   GetUnpackAlignment -> Just gl_UNPACK_ALIGNMENT
+   GetPackSwapBytes -> Just gl_PACK_SWAP_BYTES
+   GetPackLSBFirst -> Just gl_PACK_LSB_FIRST
+   GetPackRowLength -> Just gl_PACK_ROW_LENGTH
+   GetPackSkipRows -> Just gl_PACK_SKIP_ROWS
+   GetPackSkipPixels -> Just gl_PACK_SKIP_PIXELS
+   GetPackAlignment -> Just gl_PACK_ALIGNMENT
+   GetMapColor -> Just gl_MAP_COLOR
+   GetMapStencil -> Just gl_MAP_STENCIL
+   GetIndexShift -> Just gl_INDEX_SHIFT
+   GetIndexOffset -> Just gl_INDEX_OFFSET
+   GetRedScale -> Just gl_RED_SCALE
+   GetRedBias -> Just gl_RED_BIAS
+   GetZoomX -> Just gl_ZOOM_X
+   GetZoomY -> Just gl_ZOOM_Y
+   GetGreenScale -> Just gl_GREEN_SCALE
+   GetGreenBias -> Just gl_GREEN_BIAS
+   GetBlueScale -> Just gl_BLUE_SCALE
+   GetBlueBias -> Just gl_BLUE_BIAS
+   GetAlphaScale -> Just gl_ALPHA_SCALE
+   GetAlphaBias -> Just gl_ALPHA_BIAS
+   GetDepthScale -> Just gl_DEPTH_SCALE
+   GetDepthBias -> Just gl_DEPTH_BIAS
+   GetMaxEvalOrder -> Just gl_MAX_EVAL_ORDER
+   GetMaxLights -> Just gl_MAX_LIGHTS
+   GetMaxClipPlanes -> Just gl_MAX_CLIP_DISTANCES
+   GetMaxTextureSize -> Just gl_MAX_TEXTURE_SIZE
+   GetMaxPixelMapTable -> Just gl_MAX_PIXEL_MAP_TABLE
+   GetMaxAttribStackDepth -> Just gl_MAX_ATTRIB_STACK_DEPTH
+   GetMaxModelviewStackDepth -> Just gl_MAX_MODELVIEW_STACK_DEPTH
+   GetMaxNameStackDepth -> Just gl_MAX_NAME_STACK_DEPTH
+   GetMaxProjectionStackDepth -> Just gl_MAX_PROJECTION_STACK_DEPTH
+   GetMaxTextureStackDepth -> Just gl_MAX_TEXTURE_STACK_DEPTH
+   GetMaxViewportDims -> Just gl_MAX_VIEWPORT_DIMS
+   GetMaxClientAttribStackDepth -> Just gl_MAX_CLIENT_ATTRIB_STACK_DEPTH
+   GetSubpixelBits -> Just gl_SUBPIXEL_BITS
+   GetIndexBits -> Just gl_INDEX_BITS
+   GetRedBits -> Just gl_RED_BITS
+   GetGreenBits -> Just gl_GREEN_BITS
+   GetBlueBits -> Just gl_BLUE_BITS
+   GetAlphaBits -> Just gl_ALPHA_BITS
+   GetDepthBits -> Just gl_DEPTH_BITS
+   GetStencilBits -> Just gl_STENCIL_BITS
+   GetAccumRedBits -> Just gl_ACCUM_RED_BITS
+   GetAccumGreenBits -> Just gl_ACCUM_GREEN_BITS
+   GetAccumBlueBits -> Just gl_ACCUM_BLUE_BITS
+   GetAccumAlphaBits -> Just gl_ACCUM_ALPHA_BITS
+   GetNameStackDepth -> Just gl_NAME_STACK_DEPTH
+   GetAutoNormal -> Just gl_AUTO_NORMAL
+   GetMap1Color4 -> Just gl_MAP1_COLOR_4
+   GetMap1Index -> Just gl_MAP1_INDEX
+   GetMap1Normal -> Just gl_MAP1_NORMAL
+   GetMap1TextureCoord1 -> Just gl_MAP1_TEXTURE_COORD_1
+   GetMap1TextureCoord2 -> Just gl_MAP1_TEXTURE_COORD_2
+   GetMap1TextureCoord3 -> Just gl_MAP1_TEXTURE_COORD_3
+   GetMap1TextureCoord4 -> Just gl_MAP1_TEXTURE_COORD_4
+   GetMap1Vertex3 -> Just gl_MAP1_VERTEX_3
+   GetMap1Vertex4 -> Just gl_MAP1_VERTEX_4
+   GetMap2Color4 -> Just gl_MAP2_COLOR_4
+   GetMap2Index -> Just gl_MAP2_INDEX
+   GetMap2Normal -> Just gl_MAP2_NORMAL
+   GetMap2TextureCoord1 -> Just gl_MAP2_TEXTURE_COORD_1
+   GetMap2TextureCoord2 -> Just gl_MAP2_TEXTURE_COORD_2
+   GetMap2TextureCoord3 -> Just gl_MAP2_TEXTURE_COORD_3
+   GetMap2TextureCoord4 -> Just gl_MAP2_TEXTURE_COORD_4
+   GetMap2Vertex3 -> Just gl_MAP2_VERTEX_3
+   GetMap2Vertex4 -> Just gl_MAP2_VERTEX_4
+   GetMap1GridDomain -> Just gl_MAP1_GRID_DOMAIN
+   GetMap1GridSegments -> Just gl_MAP1_GRID_SEGMENTS
+   GetMap2GridDomain -> Just gl_MAP2_GRID_DOMAIN
+   GetMap2GridSegments -> Just gl_MAP2_GRID_SEGMENTS
+   GetTexture1D -> Just gl_TEXTURE_1D
+   GetTexture2D -> Just gl_TEXTURE_2D
+   GetFeedbackBufferSize -> Just gl_FEEDBACK_BUFFER_SIZE
+   GetFeedbackBufferType -> Just gl_FEEDBACK_BUFFER_TYPE
+   GetSelectionBufferSize -> Just gl_SELECTION_BUFFER_SIZE
+   GetPolygonOffsetUnits -> Just gl_POLYGON_OFFSET_UNITS
+   GetPolygonOffsetPoint -> Just gl_POLYGON_OFFSET_POINT
+   GetPolygonOffsetLine -> Just gl_POLYGON_OFFSET_LINE
+   GetPolygonOffsetFill -> Just gl_POLYGON_OFFSET_FILL
+   GetPolygonOffsetFactor -> Just gl_POLYGON_OFFSET_FACTOR
+   GetTextureBinding1D -> Just gl_TEXTURE_BINDING_1D
+   GetTextureBinding2D -> Just gl_TEXTURE_BINDING_2D
+   GetTextureBinding3D -> Just gl_TEXTURE_BINDING_3D
+   GetVertexArray -> Just gl_VERTEX_ARRAY
+   GetNormalArray -> Just gl_NORMAL_ARRAY
+   GetColorArray -> Just gl_COLOR_ARRAY
+   GetIndexArray -> Just gl_INDEX_ARRAY
+   GetTextureCoordArray -> Just gl_TEXTURE_COORD_ARRAY
+   GetEdgeFlagArray -> Just gl_EDGE_FLAG_ARRAY
+   GetFogCoordArray -> Just gl_FOG_COORD_ARRAY
+   GetSecondaryColorArray -> Just gl_SECONDARY_COLOR_ARRAY
+   GetMatrixIndexArray -> Just gl_MATRIX_INDEX_ARRAY
+   GetVertexArraySize -> Just gl_VERTEX_ARRAY_SIZE
+   GetVertexArrayType -> Just gl_VERTEX_ARRAY_TYPE
+   GetVertexArrayStride -> Just gl_VERTEX_ARRAY_STRIDE
+   GetNormalArrayType -> Just gl_NORMAL_ARRAY_TYPE
+   GetNormalArrayStride -> Just gl_NORMAL_ARRAY_STRIDE
+   GetColorArraySize -> Just gl_COLOR_ARRAY_SIZE
+   GetColorArrayType -> Just gl_COLOR_ARRAY_TYPE
+   GetColorArrayStride -> Just gl_COLOR_ARRAY_STRIDE
+   GetIndexArrayType -> Just gl_INDEX_ARRAY_TYPE
+   GetIndexArrayStride -> Just gl_INDEX_ARRAY_STRIDE
+   GetTextureCoordArraySize -> Just gl_TEXTURE_COORD_ARRAY_SIZE
+   GetTextureCoordArrayType -> Just gl_TEXTURE_COORD_ARRAY_TYPE
+   GetTextureCoordArrayStride -> Just gl_TEXTURE_COORD_ARRAY_STRIDE
+   GetEdgeFlagArrayStride -> Just gl_EDGE_FLAG_ARRAY_STRIDE
+   GetFogCoordArrayType -> Just gl_FOG_COORD_ARRAY_TYPE
+   GetFogCoordArrayStride -> Just gl_FOG_COORD_ARRAY_STRIDE
+   GetSecondaryColorArraySize -> Just gl_SECONDARY_COLOR_ARRAY_SIZE
+   GetSecondaryColorArrayType -> Just gl_SECONDARY_COLOR_ARRAY_TYPE
+   GetSecondaryColorArrayStride -> Just gl_SECONDARY_COLOR_ARRAY_STRIDE
+   GetMatrixIndexArraySize -> Just gl_MATRIX_INDEX_ARRAY_SIZE
+   GetMatrixIndexArrayType -> Just gl_MATRIX_INDEX_ARRAY_TYPE
+   GetMatrixIndexArrayStride -> Just gl_MATRIX_INDEX_ARRAY_STRIDE
    GetClipPlane i -> clipPlaneIndexToEnum i
    GetLight i -> lightIndexToEnum i
-   GetTransposeModelviewMatrix -> Just 0x84e3
-   GetTransposeProjectionMatrix -> Just 0x84e4
-   GetTransposeTextureMatrix -> Just 0x84e5
-   GetTransposeColorMatrix -> Just 0x84e6
-   GetLightModelColorControl -> Just 0x81f8
-   GetBlendColor -> Just 0x8005
-   GetBlendEquation -> Just 0x8009
-   GetBlendEquationAlpha -> Just 0x883d
-   GetColorTable -> Just 0x80d0
-   GetPostConvolutionColorTable -> Just 0x80d1
-   GetPostColorMatrixColorTable -> Just 0x80d2
-   GetConvolution1D -> Just 0x8010
-   GetConvolution2D -> Just 0x8011
-   GetSeparable2D -> Just 0x8012
-   GetMaxConvolutionWidth -> Just 0x801a
-   GetMaxConvolutionHeight -> Just 0x801b
-   GetPostConvolutionRedScale -> Just 0x801c
-   GetPostConvolutionGreenScale -> Just 0x801d
-   GetPostConvolutionBlueScale -> Just 0x801e
-   GetPostConvolutionAlphaScale -> Just 0x801f
-   GetPostConvolutionRedBias -> Just 0x8020
-   GetPostConvolutionGreenBias -> Just 0x8021
-   GetPostConvolutionBlueBias -> Just 0x8022
-   GetPostConvolutionAlphaBias -> Just 0x8023
-   GetHistogram -> Just 0x8024
-   GetMinmax -> Just 0x802e
-   GetColorSum -> Just 0x8458
-   GetCurrentSecondaryColor -> Just 0x8459
-   GetRescaleNormal -> Just 0x803a
-   GetSharedTexturePalette -> Just 0x81fb
-   GetTexture3DBinding -> Just 0x806a
-   GetPackSkipImages -> Just 0x806b
-   GetPackImageHeight -> Just 0x806c
-   GetUnpackSkipImages -> Just 0x806d
-   GetUnpackImageHeight -> Just 0x806e
-   GetTexture3D -> Just 0x806f
-   GetMax3DTextureSize -> Just 0x8073
-   GetMaxTextureLODBias -> Just 0x84fd
-   GetMaxTextureMaxAnisotropy -> Just 0x84ff
-   GetMultisample -> Just 0x809d
-   GetSampleAlphaToCoverage -> Just 0x809e
-   GetSampleAlphaToOne -> Just 0x809f
-   GetSampleCoverage -> Just 0x80a0
-   GetSampleBuffers -> Just 0x80a8
-   GetSamples -> Just 0x80a9
-   GetSampleCoverageValue -> Just 0x80aa
-   GetSampleCoverageInvert -> Just 0x80ab
-   GetPointSizeMin -> Just 0x8126
-   GetPointSizeMax -> Just 0x8127
-   GetPointFadeThresholdSize -> Just 0x8128
-   GetPointDistanceAttenuation -> Just 0x8129
-   GetColorMatrix -> Just 0x80b1
-   GetColorMatrixStackDepth -> Just 0x80b2
-   GetMaxColorMatrixStackDepth -> Just 0x80b3
-   GetPostColorMatrixRedScale -> Just 0x80b4
-   GetPostColorMatrixGreenScale -> Just 0x80b5
-   GetPostColorMatrixBlueScale -> Just 0x80b6
-   GetPostColorMatrixAlphaScale -> Just 0x80b7
-   GetPostColorMatrixRedBias -> Just 0x80b8
-   GetPostColorMatrixGreenBias -> Just 0x80b9
-   GetPostColorMatrixBlueBias -> Just 0x80ba
-   GetPostColorMatrixAlphaBias -> Just 0x80bb
-   GetMaxElementsVertices -> Just 0x80e8
-   GetMaxElementsIndices -> Just 0x80e9
-   GetActiveTexture -> Just 0x84e0
-   GetClientActiveTexture -> Just 0x84e1
-   GetMaxTextureUnits -> Just 0x84e2
-   GetTextureCubeMap -> Just 0x8513
-   GetMaxCubeMapTextureSize -> Just 0x851c
-   GetMaxRectangleTextureSize -> Just 0x84F8
-   GetNumCompressedTextureFormats -> Just 0x86a2
-   GetCompressedTextureFormats -> Just 0x86a3
-   GetMaxVertexUnits -> Just 0x86a4
-   GetActiveVertexUnits -> Just 0x86a5
-   GetWeightSumUnity -> Just 0x86a6
-   GetVertexBlend -> Just 0x86a7
+   GetTransposeModelviewMatrix -> Just gl_TRANSPOSE_MODELVIEW_MATRIX
+   GetTransposeProjectionMatrix -> Just gl_TRANSPOSE_PROJECTION_MATRIX
+   GetTransposeTextureMatrix -> Just gl_TRANSPOSE_TEXTURE_MATRIX
+   GetTransposeColorMatrix -> Just gl_TRANSPOSE_COLOR_MATRIX
+   GetLightModelColorControl -> Just gl_LIGHT_MODEL_COLOR_CONTROL
+   GetBlendColor -> Just gl_BLEND_COLOR
+   GetBlendEquation -> Just gl_BLEND_EQUATION_RGB
+   GetBlendEquationAlpha -> Just gl_BLEND_EQUATION_ALPHA
+   GetColorTable -> Just gl_COLOR_TABLE
+   GetPostConvolutionColorTable -> Just gl_POST_CONVOLUTION_COLOR_TABLE
+   GetPostColorMatrixColorTable -> Just gl_POST_COLOR_MATRIX_COLOR_TABLE
+   GetConvolution1D -> Just gl_CONVOLUTION_1D
+   GetConvolution2D -> Just gl_CONVOLUTION_2D
+   GetSeparable2D -> Just gl_SEPARABLE_2D
+   GetMaxConvolutionWidth -> Just gl_MAX_CONVOLUTION_WIDTH
+   GetMaxConvolutionHeight -> Just gl_MAX_CONVOLUTION_HEIGHT
+   GetPostConvolutionRedScale -> Just gl_POST_CONVOLUTION_RED_SCALE
+   GetPostConvolutionGreenScale -> Just gl_POST_CONVOLUTION_GREEN_SCALE
+   GetPostConvolutionBlueScale -> Just gl_POST_CONVOLUTION_BLUE_SCALE
+   GetPostConvolutionAlphaScale -> Just gl_POST_CONVOLUTION_ALPHA_SCALE
+   GetPostConvolutionRedBias -> Just gl_POST_CONVOLUTION_RED_BIAS
+   GetPostConvolutionGreenBias -> Just gl_POST_CONVOLUTION_GREEN_BIAS
+   GetPostConvolutionBlueBias -> Just gl_POST_CONVOLUTION_BLUE_BIAS
+   GetPostConvolutionAlphaBias -> Just gl_POST_CONVOLUTION_ALPHA_BIAS
+   GetHistogram -> Just gl_HISTOGRAM
+   GetMinmax -> Just gl_MINMAX
+   GetColorSum -> Just gl_COLOR_SUM
+   GetCurrentSecondaryColor -> Just gl_CURRENT_SECONDARY_COLOR
+   GetRescaleNormal -> Just gl_RESCALE_NORMAL
+   GetSharedTexturePalette -> Just gl_SHARED_TEXTURE_PALETTE
+   GetTexture3DBinding -> Just gl_TEXTURE_BINDING_3D
+   GetPackSkipImages -> Just gl_PACK_SKIP_IMAGES
+   GetPackImageHeight -> Just gl_PACK_IMAGE_HEIGHT
+   GetUnpackSkipImages -> Just gl_UNPACK_SKIP_IMAGES
+   GetUnpackImageHeight -> Just gl_UNPACK_IMAGE_HEIGHT
+   GetTexture3D -> Just gl_TEXTURE_3D
+   GetMax3DTextureSize -> Just gl_MAX_3D_TEXTURE_SIZE
+   GetMaxTextureLODBias -> Just gl_MAX_TEXTURE_LOD_BIAS
+   GetMaxTextureMaxAnisotropy -> Just gl_MAX_TEXTURE_MAX_ANISOTROPY
+   GetMultisample -> Just gl_MULTISAMPLE
+   GetSampleAlphaToCoverage -> Just gl_SAMPLE_ALPHA_TO_COVERAGE
+   GetSampleAlphaToOne -> Just gl_SAMPLE_ALPHA_TO_ONE
+   GetSampleCoverage -> Just gl_SAMPLE_COVERAGE
+   GetSampleBuffers -> Just gl_SAMPLE_BUFFERS
+   GetSamples -> Just gl_SAMPLES
+   GetSampleCoverageValue -> Just gl_SAMPLE_COVERAGE_VALUE
+   GetSampleCoverageInvert -> Just gl_SAMPLE_COVERAGE_INVERT
+   GetPointSizeMin -> Just gl_POINT_SIZE_MIN
+   GetPointSizeMax -> Just gl_POINT_SIZE_MAX
+   GetPointFadeThresholdSize -> Just gl_POINT_FADE_THRESHOLD_SIZE
+   GetPointDistanceAttenuation -> Just gl_POINT_DISTANCE_ATTENUATION
+   GetColorMatrix -> Just gl_COLOR_MATRIX
+   GetColorMatrixStackDepth -> Just gl_COLOR_MATRIX_STACK_DEPTH
+   GetMaxColorMatrixStackDepth -> Just gl_MAX_COLOR_MATRIX_STACK_DEPTH
+   GetPostColorMatrixRedScale -> Just gl_POST_COLOR_MATRIX_RED_SCALE
+   GetPostColorMatrixGreenScale -> Just gl_POST_COLOR_MATRIX_GREEN_SCALE
+   GetPostColorMatrixBlueScale -> Just gl_POST_COLOR_MATRIX_BLUE_SCALE
+   GetPostColorMatrixAlphaScale -> Just gl_POST_COLOR_MATRIX_ALPHA_SCALE
+   GetPostColorMatrixRedBias -> Just gl_POST_COLOR_MATRIX_RED_BIAS
+   GetPostColorMatrixGreenBias -> Just gl_POST_COLOR_MATRIX_GREEN_BIAS
+   GetPostColorMatrixBlueBias -> Just gl_POST_COLOR_MATRIX_BLUE_BIAS
+   GetPostColorMatrixAlphaBias -> Just gl_POST_COLOR_MATRIX_ALPHA_BIAS
+   GetMaxElementsVertices -> Just gl_MAX_ELEMENTS_VERTICES
+   GetMaxElementsIndices -> Just gl_MAX_ELEMENTS_INDICES
+   GetActiveTexture -> Just gl_ACTIVE_TEXTURE
+   GetClientActiveTexture -> Just gl_CLIENT_ACTIVE_TEXTURE
+   GetMaxTextureUnits -> Just gl_MAX_TEXTURE_UNITS
+   GetTextureCubeMap -> Just gl_TEXTURE_CUBE_MAP
+   GetMaxCubeMapTextureSize -> Just gl_MAX_CUBE_MAP_TEXTURE_SIZE
+   GetMaxRectangleTextureSize -> Just gl_MAX_RECTANGLE_TEXTURE_SIZE
+   GetNumCompressedTextureFormats -> Just gl_NUM_COMPRESSED_TEXTURE_FORMATS
+   GetCompressedTextureFormats -> Just gl_COMPRESSED_TEXTURE_FORMATS
+   GetMaxVertexUnits -> Just gl_MAX_VERTEX_UNITS
+   GetActiveVertexUnits -> Just gl_ACTIVE_VERTEX_UNITS
+   GetWeightSumUnity -> Just gl_WEIGHT_SUM_UNITY
+   GetVertexBlend -> Just gl_VERTEX_BLEND
    GetModelview i -> modelviewIndexToEnum i
-   GetCurrentWeight -> Just 0x86a8
-   GetWeightArrayType -> Just 0x86a9
-   GetWeightArrayStride -> Just 0x86aa
-   GetWeightArraySize -> Just 0x86ab
-   GetWeightArray -> Just 0x86ad
-   GetMatrixPalette -> Just 0x8840
-   GetMaxMatrixPaletteStackDepth -> Just 0x8841
-   GetMaxPaletteMatrices -> Just 0x8842
-   GetCurrentPaletteMatrix -> Just 0x8843
-   GetBlendDstRGB -> Just 0x80c8
-   GetBlendSrcRGB -> Just 0x80c9
-   GetBlendDstAlpha -> Just 0x80ca
-   GetBlendSrcAlpha -> Just 0x80cb
-   GetPackCMYKHint -> Just 0x800e
-   GetUnpackCMYKHint -> Just 0x800f
-   GetArrayElementLockFirst -> Just 0x81a8
-   GetArrayElementLockCount -> Just 0x81a9
-   GetMaxShininess -> Just 0x8504
-   GetMaxSpotExponent -> Just 0x8505
-   GetFogDistanceMode -> Just 0x855a
-   GetDepthBounds -> Just 0x8891
-   GetPrimitiveRestartIndex -> Just 0x8559
-   GetActiveStencilFace -> Just 0x8911
-   GetArrayBufferBinding -> Just 0x8894
-   GetElementArrayBufferBinding -> Just 0x8895
-   GetVertexArrayBufferBinding -> Just 0x8896
-   GetNormalArrayBufferBinding -> Just 0x8897
-   GetColorArrayBufferBinding -> Just 0x8898
-   GetIndexArrayBufferBinding -> Just 0x8899
-   GetTextureCoordArrayBufferBinding -> Just 0x889a
-   GetEdgeFlagArrayBufferBinding -> Just 0x889b
-   GetSecondaryColorArrayBufferBinding -> Just 0x889c
-   GetFogCoordArrayBufferBinding -> Just 0x889d
-   GetTextureBindingCubeMap -> Just 0x8514
-   GetTextureBindingRectangle -> Just 0x84f6
-   GetCurrentMatrix -> Just 0x8641
-   GetCurrentMatrixStackDepth -> Just 0x8640
-   GetMaxCombinedTextureImageUnits -> Just 0x8b4d
-   GetMaxDrawBuffers -> Just 0x8824
-   GetMaxFragmentUniformComponents -> Just 0x8b49
-   GetMaxTextureCoords -> Just 0x8871
-   GetMaxTextureImageUnits -> Just 0x8872
-   GetMaxVaryingFloats -> Just 0x8b4b
-   GetMaxVertexAttribs -> Just 0x8869
-   GetMaxVertexTextureImageUnits -> Just 0x8b4c
-   GetMaxVertexUniformComponents -> Just 0x8b4a
-   GetCurrentProgram -> Just 0x8b8d
-   GetPixelPackBufferBinding -> Just 0x88ed
-   GetPixelUnpackBufferBinding -> Just 0x88EF
+   GetCurrentWeight -> Just gl_CURRENT_WEIGHT
+   GetWeightArrayType -> Just gl_WEIGHT_ARRAY_TYPE
+   GetWeightArrayStride -> Just gl_WEIGHT_ARRAY_STRIDE
+   GetWeightArraySize -> Just gl_WEIGHT_ARRAY_SIZE
+   GetWeightArray -> Just gl_WEIGHT_ARRAY
+   GetMatrixPalette -> Just gl_MATRIX_PALETTE
+   GetMaxMatrixPaletteStackDepth -> Just gl_MAX_MATRIX_PALETTE_STACK_DEPTH
+   GetMaxPaletteMatrices -> Just gl_MAX_PALETTE_MATRICES
+   GetCurrentPaletteMatrix -> Just gl_CURRENT_PALETTE_MATRIX
+   GetBlendDstRGB -> Just gl_BLEND_DST_RGB
+   GetBlendSrcRGB -> Just gl_BLEND_SRC_RGB
+   GetBlendDstAlpha -> Just gl_BLEND_DST_ALPHA
+   GetBlendSrcAlpha -> Just gl_BLEND_SRC_ALPHA
+   GetPackCMYKHint -> Just gl_PACK_CMYK_HINT
+   GetUnpackCMYKHint -> Just gl_UNPACK_CMYK_HINT
+   GetArrayElementLockFirst -> Just gl_ARRAY_ELEMENT_LOCK_FIRST
+   GetArrayElementLockCount -> Just gl_ARRAY_ELEMENT_LOCK_COUNT
+   GetMaxShininess -> Just gl_MAX_SHININESS
+   GetMaxSpotExponent -> Just gl_MAX_SPOT_EXPONENT
+   GetFogDistanceMode -> Just gl_FOG_DISTANCE_MODE
+   GetDepthBounds -> Just gl_DEPTH_BOUNDS
+   GetPrimitiveRestartIndex -> Just gl_PRIMITIVE_RESTART_INDEX
+   GetPrimitiveRestartNV -> Just gl_PRIMITIVE_RESTART_NV
+   GetPrimitiveRestartIndexNV -> Just gl_PRIMITIVE_RESTART_INDEX_NV
+   GetActiveStencilFace -> Just gl_ACTIVE_STENCIL_FACE
+   GetArrayBufferBinding -> Just gl_ARRAY_BUFFER_BINDING
+   GetElementArrayBufferBinding -> Just gl_ELEMENT_ARRAY_BUFFER_BINDING
+   GetVertexArrayBufferBinding -> Just gl_VERTEX_ARRAY_BUFFER_BINDING
+   GetNormalArrayBufferBinding -> Just gl_NORMAL_ARRAY_BUFFER_BINDING
+   GetColorArrayBufferBinding -> Just gl_COLOR_ARRAY_BUFFER_BINDING
+   GetIndexArrayBufferBinding -> Just gl_INDEX_ARRAY_BUFFER_BINDING
+   GetTextureCoordArrayBufferBinding -> Just gl_TEXTURE_COORD_ARRAY_BUFFER_BINDING
+   GetEdgeFlagArrayBufferBinding -> Just gl_EDGE_FLAG_ARRAY_BUFFER_BINDING
+   GetSecondaryColorArrayBufferBinding -> Just gl_SECONDARY_COLOR_ARRAY_BUFFER_BINDING
+   GetFogCoordArrayBufferBinding -> Just gl_FOG_COORD_ARRAY_BUFFER_BINDING
+   GetTextureBindingCubeMap -> Just gl_TEXTURE_BINDING_CUBE_MAP
+   GetTextureBindingRectangle -> Just gl_TEXTURE_BINDING_RECTANGLE
+   GetCurrentMatrix -> Just gl_CURRENT_MATRIX
+   GetCurrentMatrixStackDepth -> Just gl_CURRENT_MATRIX_STACK_DEPTH
+   GetMaxCombinedTextureImageUnits -> Just gl_MAX_COMBINED_TEXTURE_IMAGE_UNITS
+   GetMaxDrawBuffers -> Just gl_MAX_DRAW_BUFFERS
+   GetMaxFragmentUniformComponents -> Just gl_MAX_FRAGMENT_UNIFORM_COMPONENTS
+   GetMaxTextureCoords -> Just gl_MAX_TEXTURE_COORDS
+   GetMaxTextureImageUnits -> Just gl_MAX_TEXTURE_IMAGE_UNITS
+   GetMaxVaryingFloats -> Just gl_MAX_VARYING_COMPONENTS
+   GetMaxVertexAttribs -> Just gl_MAX_VERTEX_ATTRIBS
+   GetMaxVertexTextureImageUnits -> Just gl_MAX_VERTEX_TEXTURE_IMAGE_UNITS
+   GetMaxVertexUniformComponents -> Just gl_MAX_VERTEX_UNIFORM_COMPONENTS
+   GetCurrentProgram -> Just gl_CURRENT_PROGRAM
+   GetPixelPackBufferBinding -> Just gl_PIXEL_PACK_BUFFER_BINDING
+   GetPixelUnpackBufferBinding -> Just gl_PIXEL_UNPACK_BUFFER_BINDING
    GetDrawBufferN i -> drawBufferIndexToEnum i
-   GetRGBASignedComponents -> Just 0x8C3C
-   GetCopyReadBuffer -> Just 0x8F36
-   GetCopyWriteBuffer -> Just 0x8F37
-   -- GetWeightArrayBufferBinding -> Just 0x889e
+   GetRGBASignedComponents -> Just gl_RGBA_SIGNED_COMPONENTS
+   GetCopyReadBuffer -> Just gl_COPY_READ_BUFFER
+   GetCopyWriteBuffer -> Just gl_COPY_WRITE_BUFFER
+   -- GetWeightArrayBufferBinding -> Just gl_WEIGHT_ARRAY_BUFFER_BINDING
 
 --------------------------------------------------------------------------------
 
@@ -822,34 +917,40 @@
 
 clipPlaneIndexToEnum :: GLsizei -> Maybe GLenum
 clipPlaneIndexToEnum i
-   | 0 <= i && i <= 0xFFF = Just (0x3000 + fromIntegral i)
+   | 0 <= i && i <= maxClipPlaneIndex = Just (gl_CLIP_DISTANCE0 + fromIntegral i)
    | otherwise = Nothing
 
+maxClipPlaneIndex :: GLsizei
+maxClipPlaneIndex = 0xFFF
+
 --------------------------------------------------------------------------------
 
 -- 0x4000 through 0x4FFF are reserved for light numbers
 
 lightIndexToEnum :: GLsizei -> Maybe GLenum
 lightIndexToEnum i
-   | 0 <= i && i <= 0xFFF = Just (0x4000 + fromIntegral i)
+   | 0 <= i && i <= maxLightIndex = Just (gl_LIGHT0 + fromIntegral i)
    | otherwise = Nothing
 
+maxLightIndex :: GLsizei
+maxLightIndex = 0xFFF
+
 --------------------------------------------------------------------------------
 
 -- 0x1700, 0x850a, and 0x8722 through 0x873f are reserved for modelview matrices
 
 modelviewIndexToEnum :: GLsizei -> Maybe GLenum
-modelviewIndexToEnum 0 = Just 0x1700
-modelviewIndexToEnum 1 = Just 0x850a
+modelviewIndexToEnum 0 = Just gl_MODELVIEW
+modelviewIndexToEnum 1 = Just gl_MODELVIEW1
 modelviewIndexToEnum i
-   | 2 <= i && i <= 31 = Just (0x8720 + fromIntegral i)
+   | 2 <= i && i <= 31 = Just (gl_MODELVIEW2 - 2 + fromIntegral i)
    | otherwise = Nothing
 
 modelviewEnumToIndex :: GLenum -> Maybe GLsizei
 modelviewEnumToIndex x
-   | x == 0x1700 = Just 0
-   | x == 0x850a = Just 1
-   | 0x8722 <= x && x <= 0x873f = Just (fromIntegral x - 0x8720)
+   | x == gl_MODELVIEW = Just 0
+   | x == gl_MODELVIEW1 = Just 1
+   | gl_MODELVIEW2 <= x && x <= gl_MODELVIEW31 = Just (fromIntegral (x - (gl_MODELVIEW2 - 2)))
    | otherwise = Nothing
 
 --------------------------------------------------------------------------------
@@ -858,9 +959,12 @@
 
 drawBufferIndexToEnum :: GLsizei -> Maybe GLenum
 drawBufferIndexToEnum i
-   | 0 <= i && i <= 15 = Just (0x8825 + fromIntegral i)
+   | 0 <= i && i <= maxDrawBufferIndex = Just (gl_DRAW_BUFFER0 + fromIntegral i)
    | otherwise = Nothing
 
+maxDrawBufferIndex :: GLsizei
+maxDrawBufferIndex = fromIntegral (gl_DRAW_BUFFER15 - gl_DRAW_BUFFER0)
+
 --------------------------------------------------------------------------------
 
 getBoolean1 :: (GLboolean -> a) -> GetPName -> IO a
@@ -874,9 +978,6 @@
    getBooleanv n buf
    peek4 f buf
 
-foreign import CALLCONV unsafe "glGetBooleanv" glGetBooleanv ::
-   GLenum -> Ptr GLboolean -> IO ()
-
 getBooleanv :: GetPName -> Ptr GLboolean -> IO ()
 getBooleanv = makeGetter glGetBooleanv
 
@@ -904,9 +1005,6 @@
 getIntegerv :: GetPName -> Ptr GLint -> IO ()
 getIntegerv = maybe (const recordInvalidEnum) glGetIntegerv . marshalGetPName
 
-foreign import CALLCONV unsafe "glGetIntegerv" glGetIntegerv ::
-   GLenum -> Ptr GLint -> IO ()
-
 --------------------------------------------------------------------------------
 
 getEnum1 :: (GLenum -> a) -> GetPName -> IO a
@@ -941,9 +1039,6 @@
 getFloatv :: GetPName -> Ptr GLfloat -> IO ()
 getFloatv = maybe (const recordInvalidEnum) glGetFloatv . marshalGetPName
 
-foreign import CALLCONV unsafe "glGetFloatv" glGetFloatv ::
-   GLenum -> Ptr GLfloat -> IO ()
-
 --------------------------------------------------------------------------------
 
 getDouble1 :: (GLdouble -> a) -> GetPName -> IO a
@@ -965,9 +1060,6 @@
 getDoublev :: GetPName -> Ptr GLdouble -> IO ()
 getDoublev = maybe (const recordInvalidEnum) glGetDoublev . marshalGetPName
 
-foreign import CALLCONV unsafe "glGetDoublev" glGetDoublev ::
-   GLenum -> Ptr GLdouble -> IO ()
-
 --------------------------------------------------------------------------------
 
 maybeNullPtr :: b -> (Ptr a -> b) -> Ptr a -> b
@@ -992,20 +1084,20 @@
 
 marshalGetVertexAttribPName :: GetVertexAttribPName -> GLenum
 marshalGetVertexAttribPName x = case x of
-   GetVertexAttribArrayEnabled -> 0x8622
-   GetVertexAttribArraySize -> 0x8623
-   GetVertexAttribArrayStride -> 0x8624
-   GetVertexAttribArrayType -> 0x8625
-   GetVertexAttribArrayNormalized -> 0x886A
-   GetCurrentVertexAttrib -> 0x8626
-   GetVertexAttribArrayBufferBinding -> 0x889F
-   GetVertexAttribArrayInteger -> 0x88FD
+   GetVertexAttribArrayEnabled -> gl_VERTEX_ATTRIB_ARRAY_ENABLED
+   GetVertexAttribArraySize -> gl_VERTEX_ATTRIB_ARRAY_SIZE
+   GetVertexAttribArrayStride -> gl_VERTEX_ATTRIB_ARRAY_STRIDE
+   GetVertexAttribArrayType -> gl_VERTEX_ATTRIB_ARRAY_TYPE
+   GetVertexAttribArrayNormalized -> gl_VERTEX_ATTRIB_ARRAY_NORMALIZED
+   GetCurrentVertexAttrib -> gl_CURRENT_VERTEX_ATTRIB
+   GetVertexAttribArrayBufferBinding -> gl_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
+   GetVertexAttribArrayInteger -> gl_VERTEX_ATTRIB_ARRAY_INTEGER
 
 --------------------------------------------------------------------------------
 
 getVertexAttribInteger1 :: (GLint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
-getVertexAttribInteger1 f location n = alloca $ \buf -> do
-   glGetVertexAttribivARB location (marshalGetVertexAttribPName n) buf
+getVertexAttribInteger1 f (AttribLocation location) n = alloca $ \buf -> do
+   glGetVertexAttribiv location (marshalGetVertexAttribPName n) buf
    peek1 f buf
 
 getVertexAttribEnum1 :: (GLenum -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
@@ -1014,29 +1106,21 @@
 getVertexAttribBoolean1 :: (GLboolean -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
 getVertexAttribBoolean1 f = getVertexAttribInteger1 (f . fromIntegral)
 
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glGetVertexAttribivARB,AttribLocation -> GLenum -> Ptr GLint -> IO ())
-
 getVertexAttribFloat4 :: (GLfloat -> GLfloat -> GLfloat -> GLfloat -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
-getVertexAttribFloat4 f location n = alloca $ \buf -> do
-   glGetVertexAttribfvARB location (marshalGetVertexAttribPName n) buf
+getVertexAttribFloat4 f (AttribLocation location) n = alloca $ \buf -> do
+   glGetVertexAttribfv location (marshalGetVertexAttribPName n) buf
    peek4 f buf
 
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glGetVertexAttribfvARB,AttribLocation -> GLenum -> Ptr GLfloat -> IO ())
-
 getVertexAttribIInteger4 :: (GLint -> GLint -> GLint -> GLint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
-getVertexAttribIInteger4 f location n = alloca $ \buf -> do
-   glGetVertexAttribIivARB location (marshalGetVertexAttribPName n) buf
+getVertexAttribIInteger4 f (AttribLocation location) n = alloca $ \buf -> do
+   glGetVertexAttribIiv location (marshalGetVertexAttribPName n) buf
    peek4 f buf
 
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glGetVertexAttribIivARB,AttribLocation -> GLenum -> Ptr GLint -> IO ())
-
 getVertexAttribIuInteger4 :: (GLuint -> GLuint -> GLuint -> GLuint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
-getVertexAttribIuInteger4 f location n = alloca $ \buf -> do
-   glGetVertexAttribIuivARB location (marshalGetVertexAttribPName n) buf
+getVertexAttribIuInteger4 f (AttribLocation location) n = alloca $ \buf -> do
+   glGetVertexAttribIuiv location (marshalGetVertexAttribPName n) buf
    peek4 f buf
 
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glGetVertexAttribIuivARB,AttribLocation -> GLenum -> Ptr GLuint -> IO ())
-
 --------------------------------------------------------------------------------
 
 data GetVertexAttribPointerPName =
@@ -1044,13 +1128,11 @@
 
 marshalGetVertexAttribPointerPName :: GetVertexAttribPointerPName -> GLenum
 marshalGetVertexAttribPointerPName x = case x of
-   VertexAttribArrayPointer -> 0x8645
+   VertexAttribArrayPointer -> gl_VERTEX_ATTRIB_ARRAY_POINTER
 
 --------------------------------------------------------------------------------
 
 getVertexAttribPointer :: AttribLocation -> GetVertexAttribPointerPName -> IO (Ptr a)
-getVertexAttribPointer location n = alloca $ \buf -> do
-   glGetVertexAttribPointervARB location (marshalGetVertexAttribPointerPName n) buf
+getVertexAttribPointer (AttribLocation location) n = alloca $ \buf -> do
+   glGetVertexAttribPointerv location (marshalGetVertexAttribPointerPName n) buf
    peek buf
-
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glGetVertexAttribPointervARB,AttribLocation -> GLenum -> Ptr (Ptr a) -> IO ())
diff --git a/Graphics/Rendering/OpenGL/GL/RasterPos.hs b/Graphics/Rendering/OpenGL/GL/RasterPos.hs
--- a/Graphics/Rendering/OpenGL/GL/RasterPos.hs
+++ b/Graphics/Rendering/OpenGL/GL/RasterPos.hs
@@ -21,31 +21,24 @@
    rasterPositionUnclipped
 ) where
 
-import Data.Int
-import Foreign.Ptr ( Ptr, castPtr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLshort, GLint, GLfloat, GLdouble, Capability )
-import Graphics.Rendering.OpenGL.GL.GLboolean ( unmarshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapRasterPositionUnclipped), makeCapability )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetCurrentRasterPosition,GetCurrentRasterDistance,
-            GetCurrentRasterColor,GetCurrentRasterSecondaryColor,
-            GetCurrentRasterIndex,GetCurrentRasterTextureCoords,
-            GetCurrentRasterPositionValid),
-   getBoolean1, getInteger1, getFloat1, getFloat4 )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.VertexSpec (
-   Vertex2(..), Vertex3(..), Vertex4(..), TexCoord4(..),
-   Color4(..), Index1(..) )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
-#include "HsOpenGLTypes.h"
+import Data.StateVar
+import Data.Tensor
+import Foreign.C.Types
+import Foreign.Ptr
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glRasterPos2d, glRasterPos2dv, glRasterPos2f, glRasterPos2fv, glRasterPos2i,
+   glRasterPos2iv, glRasterPos2s, glRasterPos2sv, glRasterPos3d, glRasterPos3dv,
+   glRasterPos3f, glRasterPos3fv, glRasterPos3i, glRasterPos3iv, glRasterPos3s,
+   glRasterPos3sv, glRasterPos4d, glRasterPos4dv, glRasterPos4f, glRasterPos4fv,
+   glRasterPos4i, glRasterPos4iv, glRasterPos4s, glRasterPos4sv, glWindowPos2d,
+   glWindowPos2dv, glWindowPos2f, glWindowPos2fv, glWindowPos2i, glWindowPos2iv,
+   glWindowPos2s, glWindowPos2sv, glWindowPos3d, glWindowPos3dv, glWindowPos3f,
+   glWindowPos3fv, glWindowPos3i, glWindowPos3iv, glWindowPos3s, glWindowPos3sv )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -64,27 +57,8 @@
    rasterPos3v :: Ptr a -> IO ()
    rasterPos4v :: Ptr a -> IO ()
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glRasterPos2s" glRasterPos2s ::
-   GLshort -> GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos3s" glRasterPos3s ::
-   GLshort -> GLshort -> GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos4s" glRasterPos4s ::
-   GLshort -> GLshort -> GLshort -> GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos2sv" glRasterPos2sv ::
-   Ptr GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos3sv" glRasterPos3sv ::
-   Ptr GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos4sv" glRasterPos4sv ::
-   Ptr GLshort -> IO ()
-
-instance RasterPosComponent GLshort_ where
+-- GLshort instance
+instance RasterPosComponent CShort where
    rasterPos2 = glRasterPos2s
    rasterPos3 = glRasterPos3s
    rasterPos4 = glRasterPos4s
@@ -93,27 +67,8 @@
    rasterPos3v = glRasterPos3sv
    rasterPos4v = glRasterPos4sv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glRasterPos2i" glRasterPos2i ::
-   GLint -> GLint -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos3i" glRasterPos3i ::
-   GLint -> GLint -> GLint -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos4i" glRasterPos4i ::
-   GLint -> GLint -> GLint -> GLint -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos2iv" glRasterPos2iv ::
-   Ptr GLint -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos3iv" glRasterPos3iv ::
-   Ptr GLint -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos4iv" glRasterPos4iv ::
-   Ptr GLint -> IO ()
-
-instance RasterPosComponent GLint_ where
+-- GLint instance
+instance RasterPosComponent CInt where
    rasterPos2 = glRasterPos2i
    rasterPos3 = glRasterPos3i
    rasterPos4 = glRasterPos4i
@@ -122,27 +77,8 @@
    rasterPos3v = glRasterPos3iv
    rasterPos4v = glRasterPos4iv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glRasterPos2f" glRasterPos2f ::
-   GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos3f" glRasterPos3f ::
-   GLfloat -> GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos4f" glRasterPos4f ::
-   GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos2fv" glRasterPos2fv ::
-   Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos3fv" glRasterPos3fv ::
-   Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos4fv" glRasterPos4fv ::
-   Ptr GLfloat -> IO ()
-
-instance RasterPosComponent GLfloat_ where
+-- GLfloat instance
+instance RasterPosComponent CFloat where
    rasterPos2 = glRasterPos2f
    rasterPos3 = glRasterPos3f
    rasterPos4 = glRasterPos4f
@@ -151,27 +87,8 @@
    rasterPos3v = glRasterPos3fv
    rasterPos4v = glRasterPos4fv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glRasterPos2d" glRasterPos2d ::
-   GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos3d" glRasterPos3d ::
-   GLdouble -> GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos4d" glRasterPos4d ::
-   GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos2dv" glRasterPos2dv ::
-   Ptr GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos3dv" glRasterPos3dv ::
-   Ptr GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glRasterPos4dv" glRasterPos4dv ::
-   Ptr GLdouble -> IO ()
-
-instance RasterPosComponent GLdouble_ where
+-- GLdouble instance
+instance RasterPosComponent CDouble where
    rasterPos2 = glRasterPos2d
    rasterPos3 = glRasterPos3d
    rasterPos4 = glRasterPos4d
@@ -207,61 +124,37 @@
    windowPos2v :: Ptr a -> IO ()
    windowPos3v :: Ptr a -> IO ()
 
---------------------------------------------------------------------------------
-
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos2sARB,GLshort -> GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos3sARB,GLshort -> GLshort -> GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos2svARB,Ptr GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos3svARB,Ptr GLshort -> IO ())
-
-instance WindowPosComponent GLshort_ where
-   windowPos2 = glWindowPos2sARB
-   windowPos3 = glWindowPos3sARB
-
-   windowPos2v = glWindowPos2svARB
-   windowPos3v = glWindowPos3svARB
-
---------------------------------------------------------------------------------
-
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos2iARB,GLint -> GLint -> IO ())
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos3iARB,GLint -> GLint -> GLint -> IO ())
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos2ivARB,Ptr GLint -> IO ())
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos3ivARB,Ptr GLint -> IO ())
-
-instance WindowPosComponent GLint_ where
-   windowPos2 = glWindowPos2iARB
-   windowPos3 = glWindowPos3iARB
-
-   windowPos2v = glWindowPos2ivARB
-   windowPos3v = glWindowPos3ivARB
-
---------------------------------------------------------------------------------
+-- GLshort instance
+instance WindowPosComponent CShort where
+   windowPos2 = glWindowPos2s
+   windowPos3 = glWindowPos3s
 
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos2fARB,GLfloat -> GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos3fARB,GLfloat -> GLfloat -> GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos2fvARB,Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos3fvARB,Ptr GLfloat -> IO ())
+   windowPos2v = glWindowPos2sv
+   windowPos3v = glWindowPos3sv
 
-instance WindowPosComponent GLfloat_ where
-   windowPos2 = glWindowPos2fARB
-   windowPos3 = glWindowPos3fARB
+-- GLint instance
+instance WindowPosComponent CInt where
+   windowPos2 = glWindowPos2i
+   windowPos3 = glWindowPos3i
 
-   windowPos2v = glWindowPos2fvARB
-   windowPos3v = glWindowPos3fvARB
+   windowPos2v = glWindowPos2iv
+   windowPos3v = glWindowPos3iv
 
---------------------------------------------------------------------------------
+-- GLfloat instance
+instance WindowPosComponent CFloat where
+   windowPos2 = glWindowPos2f
+   windowPos3 = glWindowPos3f
 
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos2dARB,GLdouble -> GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos3dARB,GLdouble -> GLdouble -> GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos2dvARB,Ptr GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_window_pos or OpenGL 1.4",glWindowPos3dvARB,Ptr GLdouble -> IO ())
+   windowPos2v = glWindowPos2fv
+   windowPos3v = glWindowPos3fv
 
-instance WindowPosComponent GLdouble_ where
-   windowPos2 = glWindowPos2dARB
-   windowPos3 = glWindowPos3dARB
+-- GLdouble instance
+instance WindowPosComponent CDouble where
+   windowPos2 = glWindowPos2d
+   windowPos3 = glWindowPos3d
 
-   windowPos2v = glWindowPos2dvARB
-   windowPos3v = glWindowPos3dvARB
+   windowPos2v = glWindowPos2dv
+   windowPos3v = glWindowPos3dv
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/ReadCopyPixels.hs b/Graphics/Rendering/OpenGL/GL/ReadCopyPixels.hs
--- a/Graphics/Rendering/OpenGL/GL/ReadCopyPixels.hs
+++ b/Graphics/Rendering/OpenGL/GL/ReadCopyPixels.hs
@@ -21,18 +21,16 @@
    PixelCopyType(..), copyPixels
 ) where
 
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLint, GLsizei )
-import Graphics.Rendering.OpenGL.GL.BufferMode (
-   marshalBufferMode, unmarshalBufferMode )
-import Graphics.Rendering.OpenGL.GL.Framebuffer ( BufferMode(..) )
-import Graphics.Rendering.OpenGL.GL.CoordTrans ( Position(..), Size(..) )
-import Graphics.Rendering.OpenGL.GL.PixelData ( withPixelData )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles ( PixelData )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetReadBuffer), getEnum1 )
-import Graphics.Rendering.OpenGL.GL.StateVar ( StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal ( recordInvalidValue )
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GL.BufferMode
+import Graphics.Rendering.OpenGL.GL.CoordTrans
+import Graphics.Rendering.OpenGL.GL.Framebuffer
+import Graphics.Rendering.OpenGL.GL.PixelData
+import Graphics.Rendering.OpenGL.GL.PixelRectangles
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility ( glCopyPixels )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -40,9 +38,6 @@
 readPixels (Position x y) (Size w h) pd =
    withPixelData pd $ glReadPixels x y w h
 
-foreign import CALLCONV unsafe "glReadPixels" glReadPixels ::
-   GLint -> GLint -> GLsizei -> GLsizei -> GLenum -> GLenum -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 readBuffer :: StateVar BufferMode
@@ -51,8 +46,6 @@
       (getEnum1 unmarshalBufferMode GetReadBuffer)
       (maybe recordInvalidValue glReadBuffer . marshalBufferMode)
 
-foreign import CALLCONV unsafe "glReadBuffer" glReadBuffer :: GLenum -> IO ()
-
 --------------------------------------------------------------------------------
 
 data PixelCopyType =
@@ -63,15 +56,12 @@
 
 marshalPixelCopyType :: PixelCopyType -> GLenum
 marshalPixelCopyType x = case x of
-   CopyColor -> 0x1800
-   CopyDepth -> 0x1801
-   CopyStencil -> 0x1802
+   CopyColor -> gl_COLOR
+   CopyDepth -> gl_DEPTH
+   CopyStencil -> gl_STENCIL
 
 --------------------------------------------------------------------------------
 
 copyPixels :: Position -> Size -> PixelCopyType -> IO ()
 copyPixels (Position x y) (Size w h) t =
    glCopyPixels x y w h (marshalPixelCopyType t)
-
-foreign import CALLCONV unsafe "glCopyPixels" glCopyPixels ::
-   GLint -> GLint -> GLsizei -> GLsizei -> GLenum -> IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/Rectangles.hs b/Graphics/Rendering/OpenGL/GL/Rectangles.hs
--- a/Graphics/Rendering/OpenGL/GL/Rectangles.hs
+++ b/Graphics/Rendering/OpenGL/GL/Rectangles.hs
@@ -16,19 +16,11 @@
    Rect(..)
 ) where
 
-import Data.Int
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLshort, GLint, GLfloat, GLdouble )
-import Graphics.Rendering.OpenGL.GL.VertexSpec ( Vertex2(..) )
-#ifdef __HADDOCK__
-import Graphics.Rendering.OpenGL.GL.BeginEnd ( PrimitiveMode(Polygon) )
-#endif
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
-#include "HsOpenGLTypes.h"
+import Data.Tensor
+import Foreign.C.Types
+import Foreign.Ptr
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glRectd, glRectdv, glRectf, glRectfv, glRecti, glRectiv, glRects, glRectsv )
 
 --------------------------------------------------------------------------------
 
@@ -56,50 +48,22 @@
    rect  :: Vertex2 a -> Vertex2 a -> IO ()
    rectv :: Ptr     a -> Ptr     a -> IO ()
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glRects" glRects ::
-   GLshort -> GLshort -> GLshort -> GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glRectsv" glRectsv ::
-   Ptr GLshort -> Ptr GLshort -> IO ()
-
-instance Rect GLshort_ where
+-- GLshort instance
+instance Rect CShort where
    rect (Vertex2 x1 y1) (Vertex2 x2 y2) = glRects x1 y1 x2 y2
    rectv ptr1 ptr2 = glRectsv ptr1 ptr2
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glRecti" glRecti ::
-   GLint -> GLint -> GLint -> GLint -> IO ()
-
-foreign import CALLCONV unsafe "glRectiv" glRectiv ::
-   Ptr GLint -> Ptr GLint -> IO ()
-
-instance Rect GLint_ where
+-- GLint instance
+instance Rect CInt where
    rect (Vertex2 x1 y1) (Vertex2 x2 y2) = glRecti x1 y1 x2 y2
    rectv ptr1 ptr2 = glRectiv ptr1 ptr2
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glRectf" glRectf ::
-   GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glRectfv" glRectfv ::
-   Ptr GLfloat -> Ptr GLfloat -> IO ()
-
-instance Rect GLfloat_ where
+-- GLfloat instance
+instance Rect CFloat where
    rect (Vertex2 x1 y1) (Vertex2 x2 y2) = glRectf x1 y1 x2 y2
    rectv ptr1 ptr2 = glRectfv ptr1 ptr2
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glRectd" glRectd ::
-   GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glRectdv" glRectdv ::
-   Ptr GLdouble -> Ptr GLdouble -> IO ()
-
-instance Rect GLdouble_ where
+-- GLdouble instance
+instance Rect CDouble where
    rect (Vertex2 x1 y1) (Vertex2 x2 y2) = glRectd x1 y1 x2 y2
    rectv ptr1 ptr2 = glRectdv ptr1 ptr2
diff --git a/Graphics/Rendering/OpenGL/GL/RenderMode.hs b/Graphics/Rendering/OpenGL/GL/RenderMode.hs
--- a/Graphics/Rendering/OpenGL/GL/RenderMode.hs
+++ b/Graphics/Rendering/OpenGL/GL/RenderMode.hs
@@ -17,12 +17,12 @@
    RenderMode(..), withRenderMode, renderMode
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLint )
-import Graphics.Rendering.OpenGL.GL.Exception ( finallyRet )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetRenderMode), getEnum1 )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   HasGetter(get), GettableStateVar, makeGettableStateVar )
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GL.Exception
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glRenderMode, gl_FEEDBACK, gl_RENDER, gl_SELECT )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -34,15 +34,15 @@
 
 marshalRenderMode :: RenderMode -> GLenum
 marshalRenderMode x = case x of
-   Render -> 0x1c00
-   Feedback -> 0x1c01
-   Select -> 0x1c02
+   Render -> gl_RENDER
+   Feedback -> gl_FEEDBACK
+   Select -> gl_SELECT
 
 unmarshalRenderMode :: GLenum -> RenderMode
 unmarshalRenderMode x
-   | x == 0x1c00 = Render
-   | x == 0x1c01 = Feedback
-   | x == 0x1c02 = Select
+   | x == gl_RENDER = Render
+   | x == gl_FEEDBACK = Feedback
+   | x == gl_SELECT = Select
    | otherwise = error ("unmarshalRenderMode: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
@@ -55,8 +55,6 @@
 
 setRenderMode :: RenderMode -> IO GLint
 setRenderMode = glRenderMode . marshalRenderMode
-
-foreign import CALLCONV unsafe "glRenderMode" glRenderMode :: GLenum -> IO GLint
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/SavingState.hs b/Graphics/Rendering/OpenGL/GL/SavingState.hs
--- a/Graphics/Rendering/OpenGL/GL/SavingState.hs
+++ b/Graphics/Rendering/OpenGL/GL/SavingState.hs
@@ -18,8 +18,17 @@
    ClientAttributeGroup(..), preservingClientAttrib
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLbitfield )
 import Graphics.Rendering.OpenGL.GL.Exception ( bracket_ )
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glPopAttrib, glPopClientAttrib, glPushAttrib, glPushClientAttrib,
+   gl_ACCUM_BUFFER_BIT, gl_ALL_ATTRIB_BITS, gl_CLIENT_ALL_ATTRIB_BITS,
+   gl_CLIENT_PIXEL_STORE_BIT, gl_CLIENT_VERTEX_ARRAY_BIT,
+   gl_CURRENT_BIT, gl_ENABLE_BIT, gl_EVAL_BIT, gl_FOG_BIT,
+   gl_HINT_BIT, gl_LIGHTING_BIT, gl_LINE_BIT, gl_LIST_BIT,
+   gl_MULTISAMPLE_BIT, gl_PIXEL_MODE_BIT, gl_POINT_BIT,
+   gl_POLYGON_BIT, gl_POLYGON_STIPPLE_BIT, gl_SCISSOR_BIT,
+   gl_TEXTURE_BIT, gl_TRANSFORM_BIT, gl_VIEWPORT_BIT )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -50,28 +59,28 @@
 
 marshalServerAttributeGroup :: ServerAttributeGroup -> GLbitfield
 marshalServerAttributeGroup x = case x of
-   CurrentAttributes -> 0x1
-   PointAttributes -> 0x2
-   LineAttributes -> 0x4
-   PolygonAttributes -> 0x8
-   PolygonStippleAttributes -> 0x10
-   PixelModeAttributes -> 0x20
-   LightingAttributes -> 0x40
-   FogAttributes -> 0x80
-   DepthBufferAttributes -> 0x100
-   AccumBufferAttributes -> 0x200
-   StencilBufferAttributes -> 0x400
-   ViewportAttributes -> 0x800
-   TransformAttributes -> 0x1000
-   EnableAttributes -> 0x2000
-   ColorBufferAttributes -> 0x4000
-   HintAttributes -> 0x8000
-   EvalAttributes -> 0x10000
-   ListAttributes -> 0x20000
-   TextureAttributes -> 0x40000
-   ScissorAttributes -> 0x80000
-   MultisampleAttributes -> 0x20000000
-   AllServerAttributes -> 0xffffffff
+   CurrentAttributes -> gl_CURRENT_BIT
+   PointAttributes -> gl_POINT_BIT
+   LineAttributes -> gl_LINE_BIT
+   PolygonAttributes -> gl_POLYGON_BIT
+   PolygonStippleAttributes -> gl_POLYGON_STIPPLE_BIT
+   PixelModeAttributes -> gl_PIXEL_MODE_BIT
+   LightingAttributes -> gl_LIGHTING_BIT
+   FogAttributes -> gl_FOG_BIT
+   DepthBufferAttributes -> gl_DEPTH_BUFFER_BIT
+   AccumBufferAttributes -> gl_ACCUM_BUFFER_BIT
+   StencilBufferAttributes -> gl_STENCIL_BUFFER_BIT
+   ViewportAttributes -> gl_VIEWPORT_BIT
+   TransformAttributes -> gl_TRANSFORM_BIT
+   EnableAttributes -> gl_ENABLE_BIT
+   ColorBufferAttributes -> gl_COLOR_BUFFER_BIT
+   HintAttributes -> gl_HINT_BIT
+   EvalAttributes -> gl_EVAL_BIT
+   ListAttributes -> gl_LIST_BIT
+   TextureAttributes -> gl_TEXTURE_BIT
+   ScissorAttributes -> gl_SCISSOR_BIT
+   MultisampleAttributes -> gl_MULTISAMPLE_BIT
+   AllServerAttributes -> gl_ALL_ATTRIB_BITS
 
 --------------------------------------------------------------------------------
 
@@ -81,12 +90,6 @@
 pushAttrib :: [ServerAttributeGroup] -> IO ()
 pushAttrib = glPushAttrib . sum . map marshalServerAttributeGroup
 
-foreign import CALLCONV unsafe "glPushAttrib"
-   glPushAttrib :: GLbitfield -> IO ()
-
-foreign import CALLCONV unsafe "glPopAttrib"
-   glPopAttrib :: IO ()
-
 --------------------------------------------------------------------------------
 
 data ClientAttributeGroup =
@@ -97,9 +100,9 @@
 
 marshalClientAttributeGroup :: ClientAttributeGroup -> GLbitfield
 marshalClientAttributeGroup x = case x of
-   PixelStoreAttributes -> 0x1
-   VertexArrayAttributes -> 0x2
-   AllClientAttributes -> 0xffffffff
+   PixelStoreAttributes -> gl_CLIENT_PIXEL_STORE_BIT
+   VertexArrayAttributes -> gl_CLIENT_VERTEX_ARRAY_BIT
+   AllClientAttributes -> gl_CLIENT_ALL_ATTRIB_BITS
 
 --------------------------------------------------------------------------------
 
@@ -109,9 +112,3 @@
 
 pushClientAttrib :: [ClientAttributeGroup] -> IO ()
 pushClientAttrib = glPushClientAttrib . sum . map marshalClientAttributeGroup
-
-foreign import CALLCONV unsafe "glPushClientAttrib"
-   glPushClientAttrib :: GLbitfield -> IO ()
-
-foreign import CALLCONV unsafe "glPopClientAttrib"
-   glPopClientAttrib :: IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/Selection.hs b/Graphics/Rendering/OpenGL/GL/Selection.hs
--- a/Graphics/Rendering/OpenGL/GL/Selection.hs
+++ b/Graphics/Rendering/OpenGL/GL/Selection.hs
@@ -18,19 +18,16 @@
    RenderMode(..), renderMode
 ) where
 
-import Foreign.Marshal.Array ( allocaArray )
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLint, GLsizei, GLuint, GLfloat )
-import Graphics.Rendering.OpenGL.GL.Exception ( bracket_ )
-import Graphics.Rendering.OpenGL.GL.IOState (
-   IOState, peekIOState, evalIOState, nTimes )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetMaxNameStackDepth,GetNameStackDepth), getSizei1 )
-import Graphics.Rendering.OpenGL.GL.RenderMode (
-   RenderMode(..), withRenderMode, renderMode )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar )
+import Data.StateVar
+import Foreign.Marshal.Array
+import Foreign.Ptr
+import Graphics.Rendering.OpenGL.GL.Exception
+import Graphics.Rendering.OpenGL.GL.IOState
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.RenderMode
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glSelectBuffer, glInitNames, glPushName, glPopName, glLoadName )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -49,11 +46,6 @@
       hits <- parseSelectionBuffer numHits buf
       return (value, hits)
 
-foreign import CALLCONV unsafe "glInitNames" glInitNames :: IO ()
-
-foreign import CALLCONV unsafe "glSelectBuffer" glSelectBuffer ::
-   GLsizei -> Ptr GLuint -> IO ()
-
 --------------------------------------------------------------------------------
 
 parseSelectionBuffer :: GLint -> Ptr GLuint -> IO (Maybe [HitRecord])
@@ -86,13 +78,10 @@
    deriving ( Eq, Ord, Show )
 
 withName :: Name -> IO a -> IO a
-withName name = bracket_ (glPushName name) glPopName
-
-foreign import CALLCONV unsafe "glPopName" glPopName :: IO ()
-
-foreign import CALLCONV unsafe "glPushName" glPushName :: Name -> IO ()
+withName (Name name) = bracket_ (glPushName name) glPopName
 
-foreign import CALLCONV unsafe "glLoadName" loadName :: Name -> IO ()
+loadName :: Name -> IO ()
+loadName (Name n) = glLoadName n
 
 maxNameStackDepth :: GettableStateVar GLsizei
 maxNameStackDepth = makeGettableStateVar (getSizei1 id GetMaxNameStackDepth)
diff --git a/Graphics/Rendering/OpenGL/GL/Shaders.hs b/Graphics/Rendering/OpenGL/GL/Shaders.hs
--- a/Graphics/Rendering/OpenGL/GL/Shaders.hs
+++ b/Graphics/Rendering/OpenGL/GL/Shaders.hs
@@ -35,42 +35,24 @@
    maxFragmentUniformComponents, maxVertexAttribs, maxVaryingFloats
 ) where
 
-import Control.Monad ( replicateM, mapM_, foldM )
-import Control.Monad.Fix ( MonadFix(..) )
-import Data.Int
-import Data.List ( genericLength, (\\) )
-import Data.Word
-import Foreign.C.String ( peekCAStringLen, withCAStringLen, withCAString )
-import Foreign.Marshal.Alloc ( alloca, allocaBytes )
-import Foreign.Marshal.Array ( allocaArray, withArray, peekArray )
-import Foreign.Marshal.Utils ( withMany )
-import Foreign.Ptr ( Ptr, castPtr, nullPtr )
-import Foreign.Storable ( Storable(peek,sizeOf) )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLchar, GLint, GLuint, GLsizei, GLenum, GLfloat )
-import Graphics.Rendering.OpenGL.GL.BufferObjects ( ObjectName(..) )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.GLboolean ( unmarshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1 )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetMaxCombinedTextureImageUnits, GetMaxFragmentUniformComponents,
-            GetMaxTextureCoords, GetMaxTextureImageUnits,GetMaxVaryingFloats,
-            GetMaxVertexAttribs, GetMaxVertexTextureImageUnits,
-            GetMaxVertexUniformComponents, GetCurrentProgram),
-   getInteger1, getSizei1 )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   HasGetter(get), GettableStateVar, makeGettableStateVar, StateVar,
-   makeStateVar )
-import Graphics.Rendering.OpenGL.GL.VertexSpec (
-   AttribLocation(..), Vertex2(..), Vertex3(..), Vertex4(..), TexCoord1(..),
-   TexCoord2(..), TexCoord3(..), TexCoord4(..), Normal3(..), FogCoord1(..),
-   Color3(..), Color4(..), Index1(..) )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
-#include "HsOpenGLTypes.h"
+import Control.Monad
+import Control.Monad.Fix
+import Data.List
+import Data.ObjectName
+import Data.StateVar
+import Data.Tensor
+import Foreign.C.String
+import Foreign.C.Types
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Array
+import Foreign.Marshal.Utils
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -105,12 +87,12 @@
 instance Shader VertexShader where
    makeShader = VertexShader
    shaderID = vertexShaderID
-   shaderType = const 0x8B31
+   shaderType = const gl_VERTEX_SHADER
 
 instance Shader FragmentShader where
    makeShader = FragmentShader
    shaderID = fragmentShaderID
-   shaderType = const 0x8B30
+   shaderType = const gl_FRAGMENT_SHADER
 
 --------------------------------------------------------------------------------
 
@@ -136,17 +118,11 @@
 isShaderName :: Shader s => s -> IO Bool
 isShaderName = fmap unmarshalGLboolean . glIsShader . shaderID
 
-EXTENSION_ENTRY("OpenGL 2.0",glCreateShader,GLenum -> IO GLuint)
-EXTENSION_ENTRY("OpenGL 2.0",glDeleteShader,GLuint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glIsShader,GLuint -> IO GLboolean)
-
 --------------------------------------------------------------------------------
 
 compileShader :: Shader s => s -> IO ()
 compileShader = glCompileShader . shaderID
 
-EXTENSION_ENTRY("OpenGL 2.0",glCompileShader,GLuint -> IO ())
-
 --------------------------------------------------------------------------------
 
 shaderSource :: Shader s => s -> StateVar [String]
@@ -162,16 +138,12 @@
          withArray lengths $ \lengthsBuf ->
             glShaderSource (shaderID shader) len charBufsBuf lengthsBuf
 
-EXTENSION_ENTRY("OpenGL 2.0",glShaderSource,GLuint -> GLsizei -> Ptr (Ptr GLchar) -> Ptr GLint -> IO ())
-
 getShaderSource :: Shader s => s -> IO [String]
 getShaderSource shader = do
    src <- get (stringQuery (shaderSourceLength shader)
                            (glGetShaderSource (shaderID shader)))
    return [src]
 
-EXTENSION_ENTRY("OpenGL 2.0",glGetShaderSource,GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLchar -> IO ())
-
 stringQuery :: GettableStateVar GLsizei -> (GLsizei -> Ptr GLsizei -> Ptr GLchar -> IO ()) -> GettableStateVar String
 stringQuery lengthVar getStr =
    makeGettableStateVar $ do
@@ -188,8 +160,6 @@
 shaderInfoLog shader =
    stringQuery (shaderInfoLogLength shader) (glGetShaderInfoLog (shaderID shader))
 
-EXTENSION_ENTRY("OpenGL 2.0",glGetShaderInfoLog,GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLchar -> IO ())
-
 --------------------------------------------------------------------------------
 
 shaderDeleteStatus :: Shader s => s -> GettableStateVar Bool
@@ -218,11 +188,11 @@
 
 marshalGetShaderPName :: GetShaderPName -> GLenum
 marshalGetShaderPName x = case x of
-   ShaderDeleteStatus -> 0x8B80
-   CompileStatus -> 0x8B81
-   ShaderInfoLogLength -> 0x8B84
-   ShaderSourceLength -> 0x8B88
-   ShaderType -> 0x8B4F
+   ShaderDeleteStatus -> gl_DELETE_STATUS
+   CompileStatus -> gl_COMPILE_STATUS
+   ShaderInfoLogLength -> gl_INFO_LOG_LENGTH
+   ShaderSourceLength -> gl_SHADER_SOURCE_LENGTH
+   ShaderType -> gl_SHADER_TYPE
 
 shaderVar :: Shader s => (GLint -> a) -> GetShaderPName -> s -> GettableStateVar a
 shaderVar f p shader =
@@ -231,8 +201,6 @@
          glGetShaderiv (shaderID shader) (marshalGetShaderPName p) buf
          peek1 f buf
 
-EXTENSION_ENTRY("OpenGL 2.0",glGetShaderiv,GLuint -> GLenum -> Ptr GLint -> IO ())
-
 --------------------------------------------------------------------------------
 
 newtype Program = Program { programID :: GLuint }
@@ -243,10 +211,6 @@
    deleteObjectNames = mapM_ (glDeleteProgram . programID)
    isObjectName = fmap unmarshalGLboolean . glIsProgram . programID
 
-EXTENSION_ENTRY("OpenGL 2.0",glCreateProgram,IO GLuint)
-EXTENSION_ENTRY("OpenGL 2.0",glDeleteProgram,GLuint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glIsProgram,GLuint -> IO GLboolean)
-
 --------------------------------------------------------------------------------
 
 attachedShaders :: Program -> StateVar ([VertexShader],[FragmentShader])
@@ -263,8 +227,6 @@
       glGetAttachedShaders (programID program) numShaders nullPtr buf
       peekArray (fromIntegral numShaders) buf
 
-EXTENSION_ENTRY("OpenGL 2.0",glGetAttachedShaders,GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLuint -> IO ())
-
 splitShaderIDs :: [GLuint] -> IO ([VertexShader],[FragmentShader])
 splitShaderIDs ids = do
    (vs, fs) <- partitionM isVertexShaderID ids
@@ -282,28 +244,23 @@
             return $ if b then (x:ts, fs) else (ts, x:fs)
 
 setAttachedShaders :: Program -> ([VertexShader],[FragmentShader]) -> IO ()
-setAttachedShaders program (vs, fs) = do
-   currentIDs <- getAttachedShaderIDs program
+setAttachedShaders p@(Program program) (vs, fs) = do
+   currentIDs <- getAttachedShaderIDs p
    let newIDs = map shaderID vs ++ map shaderID fs
    mapM_ (glAttachShader program) (newIDs \\ currentIDs)
    mapM_ (glDetachShader program) (currentIDs \\ newIDs)
 
-EXTENSION_ENTRY("OpenGL 2.0",glAttachShader,Program -> GLuint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glDetachShader,Program -> GLuint -> IO ())
-
 --------------------------------------------------------------------------------
 
 linkProgram :: Program -> IO ()
-linkProgram = glLinkProgram
-
-EXTENSION_ENTRY("OpenGL 2.0",glLinkProgram,Program -> IO ())
+linkProgram (Program program) = glLinkProgram program
 
 currentProgram :: StateVar (Maybe Program)
 currentProgram =
    makeStateVar
       (do p <- getCurrentProgram
           return $ if p == noProgram then Nothing else Just p)
-      (glUseProgram . maybe noProgram id)
+      ((\(Program p) -> glUseProgram p) . maybe noProgram id)
 
 getCurrentProgram :: IO Program
 getCurrentProgram = fmap Program $ getInteger1 fromIntegral GetCurrentProgram
@@ -311,19 +268,13 @@
 noProgram :: Program
 noProgram = Program 0
 
-EXTENSION_ENTRY("OpenGL 2.0",glUseProgram,Program -> IO ())
-
 validateProgram :: Program -> IO ()
-validateProgram = glValidateProgram
-
-EXTENSION_ENTRY("OpenGL 2.0",glValidateProgram,Program -> IO ())
+validateProgram (Program program) = glValidateProgram program
 
 programInfoLog :: Program -> GettableStateVar String
 programInfoLog p =
    stringQuery (programInfoLogLength p) (glGetProgramInfoLog (programID p))
 
-EXTENSION_ENTRY("OpenGL 2.0",glGetProgramInfoLog,GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLchar -> IO ())
-
 --------------------------------------------------------------------------------
 
 programDeleteStatus :: Program -> GettableStateVar Bool
@@ -368,15 +319,15 @@
 
 marshalGetProgramPName :: GetProgramPName -> GLenum
 marshalGetProgramPName x = case x of
-   ProgramDeleteStatus -> 0x8B80
-   LinkStatus -> 0x8B82
-   ValidateStatus -> 0x8B83
-   ProgramInfoLogLength -> 0x8B84
-   AttachedShaders -> 0x8B85
-   ActiveAttributes -> 0x8B89
-   ActiveAttributeMaxLength -> 0x8B8A
-   ActiveUniforms -> 0x8B86
-   ActiveUniformMaxLength -> 0x8B87
+   ProgramDeleteStatus -> gl_DELETE_STATUS
+   LinkStatus -> gl_LINK_STATUS
+   ValidateStatus -> gl_VALIDATE_STATUS
+   ProgramInfoLogLength -> gl_INFO_LOG_LENGTH
+   AttachedShaders -> gl_ATTACHED_SHADERS
+   ActiveAttributes -> gl_ACTIVE_ATTRIBUTES
+   ActiveAttributeMaxLength -> gl_ACTIVE_ATTRIBUTE_MAX_LENGTH
+   ActiveUniforms -> gl_ACTIVE_UNIFORMS
+   ActiveUniformMaxLength -> gl_ACTIVE_UNIFORM_MAX_LENGTH
 
 programVar :: (GLint -> a) -> GetProgramPName -> Program -> GettableStateVar a
 programVar f p program =
@@ -385,8 +336,6 @@
          glGetProgramiv (programID program) (marshalGetProgramPName p) buf
          peek1 f buf
 
-EXTENSION_ENTRY("OpenGL 2.0",glGetProgramiv,GLuint -> GLenum -> Ptr GLint -> IO ())
-
 --------------------------------------------------------------------------------
 
 attribLocation :: Program -> String -> StateVar AttribLocation
@@ -395,20 +344,16 @@
                 (\location -> bindAttribLocation program location name)
 
 getAttribLocation :: Program -> String -> IO AttribLocation
-getAttribLocation program name =
+getAttribLocation (Program program) name =
    fmap (AttribLocation . fromIntegral) $
       withGLString name $
          glGetAttribLocation program
 
-EXTENSION_ENTRY("OpenGL 2.0",glGetAttribLocation,Program -> Ptr GLchar -> IO GLint)
-
 bindAttribLocation :: Program -> AttribLocation -> String -> IO ()
-bindAttribLocation program location name =
+bindAttribLocation (Program program) (AttribLocation location) name =
    withGLString name $
       glBindAttribLocation program location
 
-EXTENSION_ENTRY("OpenGL 2.0",glBindAttribLocation,Program -> AttribLocation -> Ptr GLchar -> IO ())
-
 --------------------------------------------------------------------------------
 
 -- Table 2.9 of the OpenGL 3.1 spec: OpenGL Shading Language type tokens
@@ -467,68 +412,68 @@
 
 unmarshalVariableType :: GLenum -> VariableType
 unmarshalVariableType x
-   | x == 0x1406 = Float'
-   | x == 0x8B50 = FloatVec2
-   | x == 0x8B51 = FloatVec3
-   | x == 0x8B52 = FloatVec4
-   | x == 0x1404 = Int'
-   | x == 0x8B53 = IntVec2
-   | x == 0x8B54 = IntVec3
-   | x == 0x8B55 = IntVec4
-   | x == 0x1405 = UnsignedInt'
-   | x == 0x8DC6 = UnsignedIntVec2
-   | x == 0x8DC7 = UnsignedIntVec3
-   | x == 0x8DC8 = UnsignedIntVec4
-   | x == 0x8B56 = Bool
-   | x == 0x8B57 = BoolVec2
-   | x == 0x8B58 = BoolVec3
-   | x == 0x8B59 = BoolVec4
-   | x == 0x8B5A = FloatMat2
-   | x == 0x8B5B = FloatMat3
-   | x == 0x8B5C = FloatMat4
-   | x == 0x8B65 = FloatMat2x3
-   | x == 0x8B66 = FloatMat2x4
-   | x == 0x8B67 = FloatMat3x2
-   | x == 0x8B68 = FloatMat3x4
-   | x == 0x8B69 = FloatMat4x2
-   | x == 0x8B6A = FloatMat4x3
-   | x == 0x8B5D = Sampler1D
-   | x == 0x8B5E = Sampler2D
-   | x == 0x8B5F = Sampler3D
-   | x == 0x8B60 = SamplerCube
-   | x == 0x8B61 = Sampler1DShadow
-   | x == 0x8B62 = Sampler2DShadow
-   | x == 0x8DC0 = Sampler1DArray
-   | x == 0x8DC1 = Sampler2DArray
-   | x == 0x8DC3 = Sampler1DArrayShadow
-   | x == 0x8DC4 = Sampler2DArrayShadow
-   | x == 0x8DC5 = SamplerCubeShadow
-   | x == 0x8B63 = Sampler2DRect
-   | x == 0x8B64 = Sampler2DRectShadow
-   | x == 0x8DC9 = IntSampler1D
-   | x == 0x8DCA = IntSampler2D
-   | x == 0x8DCB = IntSampler3D
-   | x == 0x8DCC = IntSamplerCube
-   | x == 0x8DCE = IntSampler1DArray
-   | x == 0x8DCF = IntSampler2DArray
-   | x == 0x8DD1 = UnsignedIntSampler1D
-   | x == 0x8DD2 = UnsignedIntSampler2D
-   | x == 0x8DD3 = UnsignedIntSampler3D
-   | x == 0x8DD4 = UnsignedIntSamplerCube
-   | x == 0x8DD6 = UnsignedIntSampler1DArray
-   | x == 0x8DD7 = UnsignedIntSampler2DArray
+   | x == gl_FLOAT = Float'
+   | x == gl_FLOAT_VEC2 = FloatVec2
+   | x == gl_FLOAT_VEC3 = FloatVec3
+   | x == gl_FLOAT_VEC4 = FloatVec4
+   | x == gl_INT = Int'
+   | x == gl_INT_VEC2 = IntVec2
+   | x == gl_INT_VEC3 = IntVec3
+   | x == gl_INT_VEC4 = IntVec4
+   | x == gl_UNSIGNED_INT = UnsignedInt'
+   | x == gl_UNSIGNED_INT_VEC2 = UnsignedIntVec2
+   | x == gl_UNSIGNED_INT_VEC3 = UnsignedIntVec3
+   | x == gl_UNSIGNED_INT_VEC4 = UnsignedIntVec4
+   | x == gl_BOOL = Bool
+   | x == gl_BOOL_VEC2 = BoolVec2
+   | x == gl_BOOL_VEC3 = BoolVec3
+   | x == gl_BOOL_VEC4 = BoolVec4
+   | x == gl_FLOAT_MAT2 = FloatMat2
+   | x == gl_FLOAT_MAT3 = FloatMat3
+   | x == gl_FLOAT_MAT4 = FloatMat4
+   | x == gl_FLOAT_MAT2x3 = FloatMat2x3
+   | x == gl_FLOAT_MAT2x4 = FloatMat2x4
+   | x == gl_FLOAT_MAT3x2 = FloatMat3x2
+   | x == gl_FLOAT_MAT3x4 = FloatMat3x4
+   | x == gl_FLOAT_MAT4x2 = FloatMat4x2
+   | x == gl_FLOAT_MAT4x3 = FloatMat4x3
+   | x == gl_SAMPLER_1D = Sampler1D
+   | x == gl_SAMPLER_2D = Sampler2D
+   | x == gl_SAMPLER_3D = Sampler3D
+   | x == gl_SAMPLER_CUBE = SamplerCube
+   | x == gl_SAMPLER_1D_SHADOW = Sampler1DShadow
+   | x == gl_SAMPLER_2D_SHADOW = Sampler2DShadow
+   | x == gl_SAMPLER_1D_ARRAY = Sampler1DArray
+   | x == gl_SAMPLER_2D_ARRAY = Sampler2DArray
+   | x == gl_SAMPLER_1D_ARRAY_SHADOW = Sampler1DArrayShadow
+   | x == gl_SAMPLER_2D_ARRAY_SHADOW = Sampler2DArrayShadow
+   | x == gl_SAMPLER_CUBE_SHADOW = SamplerCubeShadow
+   | x == gl_SAMPLER_2D_RECT = Sampler2DRect
+   | x == gl_SAMPLER_2D_RECT_SHADOW = Sampler2DRectShadow
+   | x == gl_INT_SAMPLER_1D = IntSampler1D
+   | x == gl_INT_SAMPLER_2D = IntSampler2D
+   | x == gl_INT_SAMPLER_3D = IntSampler3D
+   | x == gl_INT_SAMPLER_CUBE = IntSamplerCube
+   | x == gl_INT_SAMPLER_1D_ARRAY = IntSampler1DArray
+   | x == gl_INT_SAMPLER_2D_ARRAY = IntSampler2DArray
+   | x == gl_UNSIGNED_INT_SAMPLER_1D = UnsignedIntSampler1D
+   | x == gl_UNSIGNED_INT_SAMPLER_2D = UnsignedIntSampler2D
+   | x == gl_UNSIGNED_INT_SAMPLER_3D = UnsignedIntSampler3D
+   | x == gl_UNSIGNED_INT_SAMPLER_CUBE = UnsignedIntSamplerCube
+   | x == gl_UNSIGNED_INT_SAMPLER_1D_ARRAY = UnsignedIntSampler1DArray
+   | x == gl_UNSIGNED_INT_SAMPLER_2D_ARRAY = UnsignedIntSampler2DArray
    | otherwise = error ("unmarshalVariableType: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
 
 activeVars :: (Program -> GettableStateVar GLuint)
            -> (Program -> GettableStateVar GLsizei)
-           -> (Program -> GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLint -> Ptr GLenum -> Ptr GLchar -> IO ())
+           -> (GLuint -> GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLint -> Ptr GLenum -> Ptr GLchar -> IO ())
            -> Program -> GettableStateVar [(GLint,VariableType,String)]
-activeVars numVars maxLength getter program =
+activeVars numVars maxLength getter p@(Program program) =
    makeGettableStateVar $ do
-      numActiveVars <- get (numVars program)
-      maxLen <- get (maxLength program)
+      numActiveVars <- get (numVars p)
+      maxLen <- get (maxLength p)
       allocaArray (fromIntegral maxLen) $ \nameBuf ->
          alloca $ \nameLengthBuf ->
             alloca $ \sizeBuf ->
@@ -544,29 +489,23 @@
 activeAttribs :: Program -> GettableStateVar [(GLint,VariableType,String)]
 activeAttribs = activeVars activeAttributes activeAttributeMaxLength glGetActiveAttrib
 
-EXTENSION_ENTRY("OpenGL 2.0",glGetActiveAttrib,Program -> GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLint -> Ptr GLenum -> Ptr GLchar -> IO ())
-
 --------------------------------------------------------------------------------
 
 newtype UniformLocation = UniformLocation GLint
    deriving ( Eq, Ord, Show )
 
 uniformLocation :: Program -> String -> GettableStateVar UniformLocation
-uniformLocation program name =
+uniformLocation (Program program) name =
    makeGettableStateVar $
       fmap UniformLocation $
          withGLString name $
             glGetUniformLocation program
 
-EXTENSION_ENTRY("OpenGL 2.0",glGetUniformLocation,Program -> Ptr GLchar -> IO GLint)
-
 --------------------------------------------------------------------------------
 
 activeUniforms :: Program -> GettableStateVar [(GLint,VariableType,String)]
 activeUniforms = activeVars numActiveUniforms activeUniformMaxLength glGetActiveUniform
 
-EXTENSION_ENTRY("OpenGL 2.0",glGetActiveUniform,Program -> GLuint -> GLsizei -> Ptr GLsizei -> Ptr GLint -> Ptr GLenum -> Ptr GLchar -> IO ())
-
 --------------------------------------------------------------------------------
 
 class Storable a => UniformComponent a where
@@ -582,98 +521,47 @@
    uniform3v :: UniformLocation -> GLsizei -> Ptr a -> IO ()
    uniform4v :: UniformLocation -> GLsizei -> Ptr a -> IO ()
 
---------------------------------------------------------------------------------
-
-EXTENSION_ENTRY("OpenGL 2.0",glUniform1i,UniformLocation -> GLint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform2i,UniformLocation -> GLint -> GLint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform3i,UniformLocation -> GLint -> GLint -> GLint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform4i,UniformLocation -> GLint -> GLint -> GLint -> GLint -> IO ())
-
-EXTENSION_ENTRY("OpenGL 2.0",glGetUniformiv,Program -> UniformLocation -> Ptr GLint -> IO ())
-
-EXTENSION_ENTRY("OpenGL 2.0",glUniform1iv,UniformLocation -> GLsizei -> Ptr GLint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform2iv,UniformLocation -> GLsizei -> Ptr GLint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform3iv,UniformLocation -> GLsizei -> Ptr GLint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform4iv,UniformLocation -> GLsizei -> Ptr GLint -> IO ())
-
-instance UniformComponent GLint_ where
-   uniform1 = glUniform1i
-   uniform2 = glUniform2i
-   uniform3 = glUniform3i
-   uniform4 = glUniform4i
-
-   getUniform program location = glGetUniformiv program location . castPtr
-
-   uniform1v = glUniform1iv
-   uniform2v = glUniform2iv
-   uniform3v = glUniform3iv
-   uniform4v = glUniform4iv
-
---------------------------------------------------------------------------------
-
-EXTENSION_ENTRY("OpenGL 2.0",glUniform1ui,UniformLocation -> GLuint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform2ui,UniformLocation -> GLuint -> GLuint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform3ui,UniformLocation -> GLuint -> GLuint -> GLuint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform4ui,UniformLocation -> GLuint -> GLuint -> GLuint -> GLuint -> IO ())
-
-EXTENSION_ENTRY("OpenGL 2.0",glGetUniformuiv,Program -> UniformLocation -> Ptr GLuint -> IO ())
-
-EXTENSION_ENTRY("OpenGL 2.0",glUniform1uiv,UniformLocation -> GLsizei -> Ptr GLuint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform2uiv,UniformLocation -> GLsizei -> Ptr GLuint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform3uiv,UniformLocation -> GLsizei -> Ptr GLuint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform4uiv,UniformLocation -> GLsizei -> Ptr GLuint -> IO ())
-
-instance UniformComponent GLuint_ where
-   uniform1 = glUniform1ui
-   uniform2 = glUniform2ui
-   uniform3 = glUniform3ui
-   uniform4 = glUniform4ui
-
-   getUniform program location = glGetUniformuiv program location . castPtr
-
-   uniform1v = glUniform1uiv
-   uniform2v = glUniform2uiv
-   uniform3v = glUniform3uiv
-   uniform4v = glUniform4uiv
-
---------------------------------------------------------------------------------
+-- GLint instance
+instance UniformComponent CInt where
+   uniform1 (UniformLocation ul) = glUniform1i ul
+   uniform2 (UniformLocation ul) = glUniform2i ul
+   uniform3 (UniformLocation ul) = glUniform3i ul
+   uniform4 (UniformLocation ul) = glUniform4i ul
 
-EXTENSION_ENTRY("OpenGL 2.0",glUniform1f,UniformLocation -> GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform2f,UniformLocation -> GLfloat -> GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform3f,UniformLocation -> GLfloat -> GLfloat -> GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform4f,UniformLocation -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ())
+   getUniform (Program p) (UniformLocation ul) = glGetUniformiv p ul . castPtr
 
-EXTENSION_ENTRY("OpenGL 2.0",glGetUniformfv,Program -> UniformLocation -> Ptr GLfloat -> IO ())
+   uniform1v (UniformLocation ul) = glUniform1iv ul
+   uniform2v (UniformLocation ul) = glUniform2iv ul
+   uniform3v (UniformLocation ul) = glUniform3iv ul
+   uniform4v (UniformLocation ul) = glUniform4iv ul
 
-EXTENSION_ENTRY("OpenGL 2.0",glUniform1fv,UniformLocation -> GLsizei -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform2fv,UniformLocation -> GLsizei -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform3fv,UniformLocation -> GLsizei -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniform4fv,UniformLocation -> GLsizei -> Ptr GLfloat -> IO ())
+-- GLuint instance
+instance UniformComponent CUInt where
+   uniform1 (UniformLocation ul) = glUniform1ui ul
+   uniform2 (UniformLocation ul) = glUniform2ui ul
+   uniform3 (UniformLocation ul) = glUniform3ui ul
+   uniform4 (UniformLocation ul) = glUniform4ui ul
 
-instance UniformComponent GLfloat_ where
-   uniform1 = glUniform1f
-   uniform2 = glUniform2f
-   uniform3 = glUniform3f
-   uniform4 = glUniform4f
+   getUniform (Program p) (UniformLocation ul) = glGetUniformuiv p ul . castPtr
 
-   getUniform program location = glGetUniformfv program location . castPtr
+   uniform1v (UniformLocation ul) = glUniform1uiv ul
+   uniform2v (UniformLocation ul) = glUniform2uiv ul
+   uniform3v (UniformLocation ul) = glUniform3uiv ul
+   uniform4v (UniformLocation ul) = glUniform4uiv ul
 
-   uniform1v = glUniform1fv
-   uniform2v = glUniform2fv
-   uniform3v = glUniform3fv
-   uniform4v = glUniform4fv
+-- GLfloat instance
+instance UniformComponent CFloat where
+   uniform1 (UniformLocation ul) = glUniform1f ul
+   uniform2 (UniformLocation ul) = glUniform2f ul
+   uniform3 (UniformLocation ul) = glUniform3f ul
+   uniform4 (UniformLocation ul) = glUniform4f ul
 
---------------------------------------------------------------------------------
+   getUniform (Program p) (UniformLocation ul) = glGetUniformfv p ul . castPtr
 
-EXTENSION_ENTRY("OpenGL 2.0",glUniformMatrix2fv,UniformLocation -> GLsizei -> GLboolean -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniformMatrix3fv,UniformLocation -> GLsizei -> GLboolean -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glUniformMatrix4fv,UniformLocation -> GLsizei -> GLboolean -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.1",glUniformMatrix2x3fv,UniformLocation -> GLsizei -> GLboolean -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.1",glUniformMatrix3x2fv,UniformLocation -> GLsizei -> GLboolean -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.1",glUniformMatrix2x4fv,UniformLocation -> GLsizei -> GLboolean -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.1",glUniformMatrix4x2fv,UniformLocation -> GLsizei -> GLboolean -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.1",glUniformMatrix3x4fv,UniformLocation -> GLsizei -> GLboolean -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.1",glUniformMatrix4x3fv,UniformLocation -> GLsizei -> GLboolean -> Ptr GLfloat -> IO ())
+   uniform1v (UniformLocation ul) = glUniform1fv ul
+   uniform2v (UniformLocation ul) = glUniform2fv ul
+   uniform3v (UniformLocation ul) = glUniform3fv ul
+   uniform4v (UniformLocation ul) = glUniform4fv ul
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/StateVar.hs b/Graphics/Rendering/OpenGL/GL/StateVar.hs
deleted file mode 100644
--- a/Graphics/Rendering/OpenGL/GL/StateVar.hs
+++ /dev/null
@@ -1,101 +0,0 @@
---------------------------------------------------------------------------------
--- |
--- Module      :  Graphics.Rendering.OpenGL.GL.StateVar
--- Copyright   :  (c) Sven Panne 2002-2009
--- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
--- 
--- Maintainer  :  sven.panne@aedion.de
--- Stability   :  stable
--- Portability :  portable
---
---------------------------------------------------------------------------------
-
-module Graphics.Rendering.OpenGL.GL.StateVar (
-   HasGetter(..),
-   GettableStateVar, makeGettableStateVar,
-   HasSetter(..), set,
-   SettableStateVar, makeSettableStateVar,
-   StateVar, makeStateVar,
-   ($~), ($=!), ($~!)
-) where
-
-import Data.IORef ( IORef, readIORef, writeIORef )
-
---------------------------------------------------------------------------------
-
-infixr 2 $=
-
---------------------------------------------------------------------------------
-
-class HasGetter g where
-   get :: g a -> IO a
-
---------------------------------------------------------------------------------
-
-newtype GettableStateVar a = GettableStateVar (IO a)
-
-instance HasGetter GettableStateVar where
-   get (GettableStateVar g) = g
-
-makeGettableStateVar :: IO a -> GettableStateVar a
-makeGettableStateVar = GettableStateVar
-
---------------------------------------------------------------------------------
-
-class HasSetter s where
-   ($=) :: s a -> a -> IO ()
-
-{-# DEPRECATED set "use `sequence_' instead" #-}
-set :: [IO ()] -> IO ()
-set = sequence_
-
---------------------------------------------------------------------------------
-
-newtype SettableStateVar a = SettableStateVar (a -> IO ())
-
-instance HasSetter SettableStateVar where
-   ($=) (SettableStateVar s) a = s a
-
--- | A strict variant of '$='.
-($=!) :: HasSetter s => s a -> a -> IO ()
-v $=! x = x `seq` v $= x
-
-makeSettableStateVar :: (a -> IO ()) -> SettableStateVar a
-makeSettableStateVar = SettableStateVar
-
---------------------------------------------------------------------------------
-
-data StateVar a =
-   StateVar (GettableStateVar a) (SettableStateVar a)
-
-instance HasGetter StateVar where
-   get (StateVar g _) = get g
-
-instance HasSetter StateVar where
-   ($=) (StateVar _ s) a = s $= a
-
-makeStateVar :: IO a -> (a -> IO ()) -> StateVar a
-makeStateVar g s = StateVar (makeGettableStateVar g) (makeSettableStateVar s)
-
---------------------------------------------------------------------------------
-
--- | A modificator convenience function.
-
-($~) :: (HasGetter v, HasSetter v) => v a -> (a -> a) -> IO ()
-v $~ f = do
-   x <- get v
-   v $= f x
-
--- | A strict variant of '$~'.
-($~!) :: (HasGetter v, HasSetter v) => v a -> (a -> a) -> IO ()
-v $~! f = do
-   x <- get v
-   v $=! f x
-
---------------------------------------------------------------------------------
-
-instance HasGetter IORef where
-   get = readIORef
-
-instance HasSetter IORef where
-   ($=) = writeIORef
diff --git a/Graphics/Rendering/OpenGL/GL/StringQueries.hs b/Graphics/Rendering/OpenGL/GL/StringQueries.hs
--- a/Graphics/Rendering/OpenGL/GL/StringQueries.hs
+++ b/Graphics/Rendering/OpenGL/GL/StringQueries.hs
@@ -17,13 +17,12 @@
    vendor, renderer, glVersion, glExtensions, shadingLanguageVersion, majorMinor
 ) where
 
-import Data.Char ( isDigit )
-import Foreign.C.String ( peekCString )
-import Foreign.Ptr ( Ptr, castPtr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLubyte )
-import Graphics.Rendering.OpenGL.GL.QueryUtils ( maybeNullPtr )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   HasGetter(get), GettableStateVar, makeGettableStateVar )
+import Data.Char
+import Data.StateVar
+import Foreign.C.String
+import Foreign.Ptr
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -53,20 +52,17 @@
 
 marshalStringName :: StringName -> GLenum
 marshalStringName x = case x of
-   Vendor -> 0x1f00
-   Renderer -> 0x1f01
-   Version -> 0x1f02
-   Extensions -> 0x1f03
-   ShadingLanguageVersion -> 0x8b8c
+   Vendor -> gl_VENDOR
+   Renderer -> gl_RENDERER
+   Version -> gl_VERSION
+   Extensions -> gl_EXTENSIONS
+   ShadingLanguageVersion -> gl_SHADING_LANGUAGE_VERSION
 
 --------------------------------------------------------------------------------
 
 getString :: StringName -> IO String
 getString n = glGetString (marshalStringName n) >>=
               maybeNullPtr (return "") (peekCString . castPtr)
-
-foreign import CALLCONV unsafe "glGetString" glGetString ::
-   GLenum -> IO (Ptr GLubyte)
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/Tensor.hs b/Graphics/Rendering/OpenGL/GL/Tensor.hs
deleted file mode 100644
--- a/Graphics/Rendering/OpenGL/GL/Tensor.hs
+++ /dev/null
@@ -1,327 +0,0 @@
--- #hide
---------------------------------------------------------------------------------
--- |
--- Module      :  Graphics.Rendering.OpenGL.GL.Tensor
--- Copyright   :  (c) Sven Panne 2002-2009
--- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
--- 
--- Maintainer  :  sven.panne@aedion.de
--- Stability   :  stable
--- Portability :  portable
---
--- This is a purely internal module for points, vectors and matrices.
---
---------------------------------------------------------------------------------
-
-module Graphics.Rendering.OpenGL.GL.Tensor (
-   Vertex1(..), Vertex2(..), Vertex3(..), Vertex4(..),
-   Vector1(..), Vector2(..), Vector3(..), Vector4(..)
-) where
-
-import Control.Applicative ( Applicative(..) )
-import Control.Monad ( ap )
-import Data.Foldable ( Foldable(..) )
-import Data.Ix ( Ix )
-import Data.Traversable ( Traversable(..) )
-import Data.Typeable (
-   Typeable(..), mkTyCon, mkTyConApp, Typeable1(..), typeOfDefault )
-import Foreign.Ptr ( castPtr )
-import Foreign.Storable ( Storable(..) )
-import Graphics.Rendering.OpenGL.GL.PeekPoke (
-   poke1, poke2, poke3, poke4, peek1, peek2, peek3, peek4 )
-
---------------------------------------------------------------------------------
-
--- | A vertex with /y/=0, /z/=0 and /w/=1.
-newtype Vertex1 a = Vertex1 a
-   deriving (Eq, Ord, Ix, Bounded, Show, Read)
-
-instance Functor Vertex1 where
-   fmap f (Vertex1 x) = Vertex1 (f x)
-
-instance Applicative Vertex1 where
-   pure a = Vertex1 a
-   Vertex1 f <*> Vertex1 x = Vertex1 (f x)
-
-instance Foldable Vertex1 where
-   foldr f a (Vertex1 x) = x `f ` a
-   foldl f a (Vertex1 x) = a `f` x
-   foldr1 _ (Vertex1 x) = x
-   foldl1 _ (Vertex1 x) = x
-
-instance Traversable Vertex1 where
-   traverse f (Vertex1 x) = pure Vertex1 <*> f x
-   sequenceA (Vertex1 x) =  pure Vertex1 <*> x
-   mapM f (Vertex1 x) = return Vertex1 `ap` f x
-   sequence (Vertex1 x) = return Vertex1 `ap` x
-
-instance Typeable1 Vertex1 where
-   typeOf1 _ = mkTyConApp (mkTyCon "Vertex1") []
-
-instance Typeable a => Typeable (Vertex1 a) where
-   typeOf = typeOfDefault
-
-instance Storable a => Storable (Vertex1 a) where
-   sizeOf    ~(Vertex1 s) = sizeOf s
-   alignment ~(Vertex1 s) = alignment s
-   peek = peek1 Vertex1 . castPtr
-   poke ptr (Vertex1 s) = poke1 (castPtr ptr) s
-
---------------------------------------------------------------------------------
-
--- | A vertex with /z/=0 and /w/=1.
-data Vertex2 a = Vertex2 !a !a
-   deriving (Eq, Ord, Ix, Bounded, Show, Read)
-
-instance Functor Vertex2 where
-   fmap f (Vertex2 x y) = Vertex2 (f x) (f y)
-
-instance Applicative Vertex2 where
-   pure a = Vertex2 a a
-   Vertex2 f g <*> Vertex2 x y = Vertex2 (f x) (g y)
-
-instance Foldable Vertex2 where
-   foldr f a (Vertex2 x y) = x `f ` (y `f` a)
-   foldl f a (Vertex2 x y) = (a `f` x) `f` y
-   foldr1 f (Vertex2 x y) = x `f` y
-   foldl1 f (Vertex2 x y) = x `f` y
-
-instance Traversable Vertex2 where
-   traverse f (Vertex2 x y) = pure Vertex2 <*> f x <*> f y
-   sequenceA (Vertex2 x y) =  pure Vertex2 <*> x <*> y
-   mapM f (Vertex2 x y) = return Vertex2 `ap` f x `ap` f y
-   sequence (Vertex2 x y) = return Vertex2 `ap` x `ap` y
-
-instance Typeable1 Vertex2 where
-   typeOf1 _ = mkTyConApp (mkTyCon "Vertex2") []
-
-instance Typeable a => Typeable (Vertex2 a) where
-   typeOf = typeOfDefault
-
-instance Storable a => Storable (Vertex2 a) where
-   sizeOf ~(Vertex2 x _) = 2 * sizeOf x
-   alignment ~(Vertex2 x _) = alignment x
-   peek = peek2 Vertex2 . castPtr
-   poke ptr (Vertex2 x y) = poke2 (castPtr ptr) x y
-
---------------------------------------------------------------------------------
-
--- | A vertex with /w/=1.
-data Vertex3 a = Vertex3 !a !a !a
-   deriving (Eq, Ord, Ix, Bounded, Show, Read)
-
-instance Functor Vertex3 where
-   fmap f (Vertex3 x y z) = Vertex3 (f x) (f y) (f z)
-
-instance Applicative Vertex3 where
-   pure a = Vertex3 a a a
-   Vertex3 f g h <*> Vertex3 x y z = Vertex3 (f x) (g y) (h z)
-
-instance Foldable Vertex3 where
-   foldr f a (Vertex3 x y z) = x `f ` (y `f` (z `f` a))
-   foldl f a (Vertex3 x y z) = ((a `f` x) `f` y) `f` z
-   foldr1 f (Vertex3 x y z) = x `f` (y `f` z)
-   foldl1 f (Vertex3 x y z) = (x `f` y) `f` z
-
-instance Traversable Vertex3 where
-   traverse f (Vertex3 x y z) = pure Vertex3 <*> f x <*> f y <*> f z
-   sequenceA (Vertex3 x y z) =  pure Vertex3 <*> x <*> y <*> z
-   mapM f (Vertex3 x y z) = return Vertex3 `ap` f x `ap` f y `ap` f z
-   sequence (Vertex3 x y z) = return Vertex3 `ap` x `ap` y `ap` z
-
-instance Typeable1 Vertex3 where
-   typeOf1 _ = mkTyConApp (mkTyCon "Vertex3") []
-
-instance Typeable a => Typeable (Vertex3 a) where
-   typeOf = typeOfDefault
-
-instance Storable a => Storable (Vertex3 a) where
-   sizeOf ~(Vertex3 x _ _) = 3 * sizeOf x
-   alignment ~(Vertex3 x _ _) = alignment x
-   peek = peek3 Vertex3 . castPtr
-   poke ptr (Vertex3 x y z) = poke3 (castPtr ptr) x y z
-
---------------------------------------------------------------------------------
-
--- | A fully-fledged four-dimensional vertex.
-data Vertex4 a = Vertex4 !a !a !a !a
-   deriving (Eq, Ord, Ix, Bounded, Show, Read)
-
-instance Functor Vertex4 where
-   fmap f (Vertex4 x y z w) = Vertex4 (f x) (f y) (f z) (f w)
-
-instance Applicative Vertex4 where
-   pure a = Vertex4 a a a a
-   Vertex4 f g h i <*> Vertex4 x y z w = Vertex4 (f x) (g y) (h z) (i w)
-
-instance Foldable Vertex4 where
-   foldr f a (Vertex4 x y z w) = x `f ` (y `f` (z `f` (w `f` a)))
-   foldl f a (Vertex4 x y z w) = (((a `f` x) `f` y) `f` z) `f` w
-   foldr1 f (Vertex4 x y z w) = x `f` (y `f` (z `f` w))
-   foldl1 f (Vertex4 x y z w) = ((x `f` y) `f` z) `f` w
-
-instance Traversable Vertex4 where
-   traverse f (Vertex4 x y z w) = pure Vertex4 <*> f x <*> f y <*> f z <*> f w
-   sequenceA (Vertex4 x y z w) =  pure Vertex4 <*> x <*> y <*> z <*> w
-   mapM f (Vertex4 x y z w) = return Vertex4 `ap` f x `ap` f y `ap` f z `ap` f w
-   sequence (Vertex4 x y z w) = return Vertex4 `ap` x `ap` y `ap` z `ap` w
-
-instance Typeable1 Vertex4 where
-   typeOf1 _ = mkTyConApp (mkTyCon "Vertex4") []
-
-instance Typeable a => Typeable (Vertex4 a) where
-   typeOf = typeOfDefault
-
-instance Storable a => Storable (Vertex4 a) where
-   sizeOf ~(Vertex4 x _ _ _) = 4 * sizeOf x
-   alignment ~(Vertex4 x _ _ _) = alignment x
-   peek = peek4 Vertex4 . castPtr
-   poke ptr (Vertex4 x y z w) = poke4 (castPtr ptr) x y z w
-
---------------------------------------------------------------------------------
-
--- | A one-dimensional vector.
-newtype Vector1 a = Vector1 a
-   deriving (Eq, Ord, Ix, Bounded, Show, Read)
-
-instance Functor Vector1 where
-   fmap f (Vector1 x) = Vector1 (f x)
-
-instance Applicative Vector1 where
-   pure a = Vector1 a
-   Vector1 f <*> Vector1 x = Vector1 (f x)
-
-instance Foldable Vector1 where
-   foldr f a (Vector1 x) = x `f ` a
-   foldl f a (Vector1 x) = a `f` x
-   foldr1 _ (Vector1 x) = x
-   foldl1 _ (Vector1 x) = x
-
-instance Traversable Vector1 where
-   traverse f (Vector1 x) = pure Vector1 <*> f x
-   sequenceA (Vector1 x) =  pure Vector1 <*> x
-   mapM f (Vector1 x) = return Vector1 `ap` f x
-   sequence (Vector1 x) = return Vector1 `ap` x
-
-instance Typeable1 Vector1 where
-   typeOf1 _ = mkTyConApp (mkTyCon "Vector1") []
-
-instance Typeable a => Typeable (Vector1 a) where
-   typeOf = typeOfDefault
-
-instance Storable a => Storable (Vector1 a) where
-   sizeOf    ~(Vector1 s) = sizeOf s
-   alignment ~(Vector1 s) = alignment s
-   peek = peek1 Vector1 . castPtr
-   poke ptr (Vector1 s) = poke1 (castPtr ptr) s
-
---------------------------------------------------------------------------------
-
--- | A two-dimensional vector.
-data Vector2 a = Vector2 !a !a
-   deriving (Eq, Ord, Ix, Bounded, Show, Read)
-
-instance Functor Vector2 where
-   fmap f (Vector2 x y) = Vector2 (f x) (f y)
-
-instance Applicative Vector2 where
-   pure a = Vector2 a a
-   Vector2 f g <*> Vector2 x y = Vector2 (f x) (g y)
-
-instance Foldable Vector2 where
-   foldr f a (Vector2 x y) = x `f ` (y `f` a)
-   foldl f a (Vector2 x y) = (a `f` x) `f` y
-   foldr1 f (Vector2 x y) = x `f` y
-   foldl1 f (Vector2 x y) = x `f` y
-
-instance Traversable Vector2 where
-   traverse f (Vector2 x y) = pure Vector2 <*> f x <*> f y
-   sequenceA (Vector2 x y) =  pure Vector2 <*> x <*> y
-   mapM f (Vector2 x y) = return Vector2 `ap` f x `ap` f y
-   sequence (Vector2 x y) = return Vector2 `ap` x `ap` y
-
-instance Typeable1 Vector2 where
-   typeOf1 _ = mkTyConApp (mkTyCon "Vector2") []
-
-instance Typeable a => Typeable (Vector2 a) where
-   typeOf = typeOfDefault
-
-instance Storable a => Storable (Vector2 a) where
-   sizeOf ~(Vector2 x _) = 2 * sizeOf x
-   alignment ~(Vector2 x _) = alignment x
-   peek = peek2 Vector2 . castPtr
-   poke ptr (Vector2 x y) = poke2 (castPtr ptr) x y
-
---------------------------------------------------------------------------------
-
--- | A three-dimensional vector.
-data Vector3 a = Vector3 !a !a !a
-   deriving (Eq, Ord, Ix, Bounded, Show, Read)
-
-instance Functor Vector3 where
-   fmap f (Vector3 x y z) = Vector3 (f x) (f y) (f z)
-
-instance Applicative Vector3 where
-   pure a = Vector3 a a a
-   Vector3 f g h <*> Vector3 x y z = Vector3 (f x) (g y) (h z)
-
-instance Foldable Vector3 where
-   foldr f a (Vector3 x y z) = x `f ` (y `f` (z `f` a))
-   foldl f a (Vector3 x y z) = ((a `f` x) `f` y) `f` z
-   foldr1 f (Vector3 x y z) = x `f` (y `f` z)
-   foldl1 f (Vector3 x y z) = (x `f` y) `f` z
-
-instance Traversable Vector3 where
-   traverse f (Vector3 x y z) = pure Vector3 <*> f x <*> f y <*> f z
-   sequenceA (Vector3 x y z) =  pure Vector3 <*> x <*> y <*> z
-   mapM f (Vector3 x y z) = return Vector3 `ap` f x `ap` f y `ap` f z
-   sequence (Vector3 x y z) = return Vector3 `ap` x `ap` y `ap` z
-
-instance Typeable1 Vector3 where
-   typeOf1 _ = mkTyConApp (mkTyCon "Vector3") []
-
-instance Typeable a => Typeable (Vector3 a) where
-   typeOf = typeOfDefault
-
-instance Storable a => Storable (Vector3 a) where
-   sizeOf ~(Vector3 x _ _) = 3 * sizeOf x
-   alignment ~(Vector3 x _ _) = alignment x
-   peek = peek3 Vector3 . castPtr
-   poke ptr (Vector3 x y z) = poke3 (castPtr ptr) x y z
-
---------------------------------------------------------------------------------
-
--- | A four-dimensional vector.
-data Vector4 a = Vector4 !a !a !a !a
-   deriving (Eq, Ord, Ix, Bounded, Show, Read)
-
-instance Functor Vector4 where
-   fmap f (Vector4 x y z w) = Vector4 (f x) (f y) (f z) (f w)
-
-instance Applicative Vector4 where
-   pure a = Vector4 a a a a
-   Vector4 f g h i <*> Vector4 x y z w = Vector4 (f x) (g y) (h z) (i w)
-
-instance Foldable Vector4 where
-   foldr f a (Vector4 x y z w) = x `f ` (y `f` (z `f` (w `f` a)))
-   foldl f a (Vector4 x y z w) = (((a `f` x) `f` y) `f` z) `f` w
-   foldr1 f (Vector4 x y z w) = x `f` (y `f` (z `f` w))
-   foldl1 f (Vector4 x y z w) = ((x `f` y) `f` z) `f` w
-
-instance Traversable Vector4 where
-   traverse f (Vector4 x y z w) = pure Vector4 <*> f x <*> f y <*> f z <*> f w
-   sequenceA (Vector4 x y z w) =  pure Vector4 <*> x <*> y <*> z <*> w
-   mapM f (Vector4 x y z w) = return Vector4 `ap` f x `ap` f y `ap` f z `ap` f w
-   sequence (Vector4 x y z w) = return Vector4 `ap` x `ap` y `ap` z `ap` w
-
-instance Typeable1 Vector4 where
-   typeOf1 _ = mkTyConApp (mkTyCon "Vector4") []
-
-instance Typeable a => Typeable (Vector4 a) where
-   typeOf = typeOfDefault
-
-instance Storable a => Storable (Vector4 a) where
-   sizeOf ~(Vector4 x _ _ _) = 4 * sizeOf x
-   alignment ~(Vector4 x _ _ _) = alignment x
-   peek = peek4 Vector4 . castPtr
-   poke ptr (Vector4 x y z w) = poke4 (castPtr ptr) x y z w
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/Application.hs b/Graphics/Rendering/OpenGL/GL/Texturing/Application.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/Application.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/Application.hs
@@ -17,14 +17,9 @@
    texture
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( Capability )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapTexture1D,CapTexture2D,CapTexture3D,CapTextureCubeMap,
-             CapTextureRectangle),
-   makeCapability )
-import Graphics.Rendering.OpenGL.GL.StateVar ( StateVar )
-import Graphics.Rendering.OpenGL.GL.Texturing.Specification (
-   TextureTarget(..) )
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.Texturing.Specification
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/Environments.hs b/Graphics/Rendering/OpenGL/GL/Texturing/Environments.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/Environments.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/Environments.hs
@@ -21,22 +21,32 @@
    constantColor, textureUnitLODBias
 ) where
 
-import Control.Monad ( liftM2 )
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Ptr ( Ptr )
-import Foreign.Storable ( Storable )
-import Foreign.Marshal.Utils ( with )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLint, GLenum, GLfloat )
-import Graphics.Rendering.OpenGL.GL.BlendingFactor (
-   marshalBlendingFactor, unmarshalBlendingFactor )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1 )
-import Graphics.Rendering.OpenGL.GL.PerFragment ( BlendingFactor )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   HasGetter(get), HasSetter(($=)), StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.Texturing.Parameters ( LOD )
-import Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit (
-   marshalTextureUnit, unmarshalTextureUnit )
-import Graphics.Rendering.OpenGL.GL.VertexSpec( Color4(..), TextureUnit )
+import Control.Monad
+import Data.StateVar
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Utils
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.BlendingFactor
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.PerFragment
+import Graphics.Rendering.OpenGL.GL.Texturing.Parameters
+import Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glGetTexEnvfv, glGetTexEnviv, glTexEnvf, glTexEnvfv, glTexEnvi, gl_ADD,
+   gl_ADD_SIGNED, gl_ALPHA_SCALE, gl_COMBINE, gl_COMBINE_ALPHA, gl_COMBINE_RGB,
+   gl_CONSTANT, gl_DECAL, gl_DOT3_RGB, gl_DOT3_RGBA, gl_INTERPOLATE,
+   gl_MODULATE, gl_OPERAND0_ALPHA, gl_OPERAND0_RGB, gl_OPERAND1_ALPHA,
+   gl_OPERAND1_RGB, gl_OPERAND2_ALPHA, gl_OPERAND2_RGB, gl_POINT_SPRITE,
+   gl_PREVIOUS, gl_PRIMARY_COLOR, gl_RGB_SCALE, gl_SRC0_ALPHA, gl_SRC0_RGB,
+   gl_SRC1_ALPHA, gl_SRC1_RGB, gl_SRC2_ALPHA, gl_SRC2_RGB, gl_SUBTRACT,
+   gl_TEXTURE_ENV, gl_TEXTURE_ENV_COLOR, gl_TEXTURE_ENV_MODE,
+   gl_TEXTURE_FILTER_CONTROL )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.NV.TextureEnvCombine4 (
+   gl_COMBINE4, gl_OPERAND3_ALPHA, gl_OPERAND3_RGB, gl_SOURCE3_ALPHA,
+   gl_SOURCE3_RGB )
 
 --------------------------------------------------------------------------------
 
@@ -47,9 +57,9 @@
 
 marshalTextureEnvTarget :: TextureEnvTarget -> GLenum
 marshalTextureEnvTarget x = case x of
-   TextureEnv -> 0x2300
-   TextureFilterControl -> 0x8500
-   PointSprite -> 0x8861
+   TextureEnv -> gl_TEXTURE_ENV
+   TextureFilterControl -> gl_TEXTURE_FILTER_CONTROL
+   PointSprite -> gl_POINT_SPRITE
 
 --------------------------------------------------------------------------------
 
@@ -80,29 +90,29 @@
 
 marshalTextureEnvParameter :: TextureEnvParameter -> GLenum
 marshalTextureEnvParameter x = case x of
-   TexEnvParamTextureEnvMode -> 0x2200
-   TexEnvParamTextureEnvColor -> 0x2201
-   TexEnvParamCombineRGB -> 0x8571
-   TexEnvParamCombineAlpha -> 0x8572
-   TexEnvParamSrc0RGB -> 0x8580
-   TexEnvParamSrc1RGB -> 0x8581
-   TexEnvParamSrc2RGB -> 0x8582
-   TexEnvParamSrc3RGB -> 0x8583
-   TexEnvParamSrc0Alpha -> 0x8588
-   TexEnvParamSrc1Alpha -> 0x8589
-   TexEnvParamSrc2Alpha -> 0x858a
-   TexEnvParamSrc3Alpha -> 0x858b
-   TexEnvParamOperand0RGB -> 0x8590
-   TexEnvParamOperand1RGB -> 0x8591
-   TexEnvParamOperand2RGB -> 0x8592
-   TexEnvParamOperand3RGB -> 0x8593
-   TexEnvParamOperand0Alpha -> 0x8598
-   TexEnvParamOperand1Alpha -> 0x8599
-   TexEnvParamOperand2Alpha -> 0x859a
-   TexEnvParamOperand3Alpha -> 0x859b
-   TexEnvParamRGBScale -> 0x8573
-   TexEnvParamAlphaScale -> 0xd1c
-   TexEnvParamLODBias -> 0x8501
+   TexEnvParamTextureEnvMode -> gl_TEXTURE_ENV_MODE
+   TexEnvParamTextureEnvColor -> gl_TEXTURE_ENV_COLOR
+   TexEnvParamCombineRGB -> gl_COMBINE_RGB
+   TexEnvParamCombineAlpha -> gl_COMBINE_ALPHA
+   TexEnvParamSrc0RGB -> gl_SRC0_RGB
+   TexEnvParamSrc1RGB -> gl_SRC1_RGB
+   TexEnvParamSrc2RGB -> gl_SRC2_RGB
+   TexEnvParamSrc3RGB -> gl_SOURCE3_RGB
+   TexEnvParamSrc0Alpha -> gl_SRC0_ALPHA
+   TexEnvParamSrc1Alpha -> gl_SRC1_ALPHA
+   TexEnvParamSrc2Alpha -> gl_SRC2_ALPHA
+   TexEnvParamSrc3Alpha -> gl_SOURCE3_ALPHA
+   TexEnvParamOperand0RGB -> gl_OPERAND0_RGB
+   TexEnvParamOperand1RGB -> gl_OPERAND1_RGB
+   TexEnvParamOperand2RGB -> gl_OPERAND2_RGB
+   TexEnvParamOperand3RGB -> gl_OPERAND3_RGB
+   TexEnvParamOperand0Alpha -> gl_OPERAND0_ALPHA
+   TexEnvParamOperand1Alpha -> gl_OPERAND1_ALPHA
+   TexEnvParamOperand2Alpha -> gl_OPERAND2_ALPHA
+   TexEnvParamOperand3Alpha -> gl_OPERAND3_ALPHA
+   TexEnvParamRGBScale -> gl_RGB_SCALE
+   TexEnvParamAlphaScale -> gl_ALPHA_SCALE
+   TexEnvParamLODBias -> gl_TEXTURE_LOD_BIAS
 
 --------------------------------------------------------------------------------
 
@@ -113,15 +123,10 @@
    marshalAct x $
       glTexEnv (marshalTextureEnvTarget t) (marshalTextureEnvParameter p)
 
-foreign import CALLCONV unsafe "glTexEnvi"
-   glTexEnvi :: GLenum -> GLenum ->  GLint -> IO ()
+glTexEnvC4f :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
+glTexEnvC4f t p ptr = glTexEnvfv t p (castPtr ptr)
 
-foreign import CALLCONV unsafe "glTexEnvf"
-   glTexEnvf :: GLenum -> GLenum ->  GLfloat -> IO ()
 
-foreign import CALLCONV unsafe "glTexEnvfv"
-   glTexEnvC4f :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
-
 --------------------------------------------------------------------------------
 
 getTexEnv :: Storable b
@@ -133,14 +138,8 @@
      glGetTexEnv (marshalTextureEnvTarget t) (marshalTextureEnvParameter p) buf
      peek1 unmarshal buf
 
-foreign import CALLCONV unsafe "glGetTexEnviv"
-   glGetTexEnviv :: GLenum -> GLenum -> Ptr GLint -> IO ()
-
-foreign import CALLCONV unsafe "glGetTexEnvfv"
-   glGetTexEnvfv :: GLenum -> GLenum -> Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glGetTexEnvfv"
-   glGetTexEnvC4f :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
+glGetTexEnvC4f :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
+glGetTexEnvC4f t p ptr = glGetTexEnvfv t p (castPtr ptr)
 
 --------------------------------------------------------------------------------
 
@@ -180,25 +179,26 @@
    deriving ( Eq, Ord, Show )
 
 marshalTextureFunction :: TextureFunction -> GLint
-marshalTextureFunction x = case x of
-   Modulate -> 0x2100
-   Decal -> 0x2101
-   Blend -> 0xbe2
-   Replace -> 0x1e01
-   AddUnsigned -> 0x104
-   Combine -> 0x8570
-   Combine4 -> 0x8503
+marshalTextureFunction x = fromIntegral $ case x of
+   Modulate -> gl_MODULATE
+   Decal -> gl_DECAL
+   Blend -> gl_BLEND
+   Replace -> gl_REPLACE
+   AddUnsigned -> gl_ADD
+   Combine -> gl_COMBINE
+   Combine4 -> gl_COMBINE4
 
 unmarshalTextureFunction :: GLint -> TextureFunction
 unmarshalTextureFunction x
-   | x == 0x2100 = Modulate
-   | x == 0x2101 = Decal
-   | x == 0xbe2 = Blend
-   | x == 0x1e01 = Replace
-   | x == 0x104 = AddUnsigned
-   | x == 0x8570 = Combine
-   | x == 0x8503 = Combine4
+   | y == gl_MODULATE = Modulate
+   | y == gl_DECAL = Decal
+   | y == gl_BLEND = Blend
+   | y == gl_REPLACE = Replace
+   | y == gl_ADD = AddUnsigned
+   | y == gl_COMBINE = Combine
+   | y == gl_COMBINE4 = Combine4
    | otherwise = error ("unmarshalTextureFunction: illegal value " ++ show x)
+   where y = fromIntegral x
 
 --------------------------------------------------------------------------------
 
@@ -220,27 +220,28 @@
    deriving ( Eq, Ord, Show )
 
 marshalTextureCombineFunction :: TextureCombineFunction -> GLint
-marshalTextureCombineFunction x = case x of
-   Replace' -> 0x1e01
-   Modulate' -> 0x2100
-   AddUnsigned' -> 0x104
-   AddSigned -> 0x8574
-   Interpolate -> 0x8575
-   Subtract -> 0x84e7
-   Dot3RGB -> 0x86ae
-   Dot3RGBA -> 0x86af
+marshalTextureCombineFunction x = fromIntegral $ case x of
+   Replace' -> gl_REPLACE
+   Modulate' -> gl_MODULATE
+   AddUnsigned' -> gl_ADD
+   AddSigned -> gl_ADD_SIGNED
+   Interpolate -> gl_INTERPOLATE
+   Subtract -> gl_SUBTRACT
+   Dot3RGB -> gl_DOT3_RGB
+   Dot3RGBA -> gl_DOT3_RGBA
 
 unmarshalTextureCombineFunction :: GLint -> TextureCombineFunction
 unmarshalTextureCombineFunction x
-   | x == 0x1e01 = Replace'
-   | x == 0x2100 = Modulate'
-   | x == 0x104 = AddUnsigned'
-   | x == 0x8574 = AddSigned
-   | x == 0x8575 = Interpolate
-   | x == 0x84e7 = Subtract
-   | x == 0x86ae = Dot3RGB
-   | x == 0x86af = Dot3RGBA
+   | y == gl_REPLACE = Replace'
+   | y == gl_MODULATE = Modulate'
+   | y == gl_ADD = AddUnsigned'
+   | y == gl_ADD_SIGNED = AddSigned
+   | y == gl_INTERPOLATE = Interpolate
+   | y == gl_SUBTRACT = Subtract
+   | y == gl_DOT3_RGB = Dot3RGB
+   | y == gl_DOT3_RGBA = Dot3RGBA
    | otherwise = error ("unmarshalTextureCombineFunction: illegal value " ++ show x)
+   where y = fromIntegral x
 
 --------------------------------------------------------------------------------
 
@@ -307,20 +308,21 @@
    deriving ( Eq, Ord, Show )
 
 marshalSrc :: Src -> GLint
-marshalSrc x = case x of
-   CurrentUnit -> 0x1702
-   Previous -> 0x8578
+marshalSrc x = fromIntegral $ case x of
+   CurrentUnit -> gl_TEXTURE
+   Previous -> gl_PREVIOUS
    Crossbar u -> fromIntegral (marshalTextureUnit u)
-   Constant -> 0x8576
-   PrimaryColor -> 0x8577
+   Constant -> gl_CONSTANT
+   PrimaryColor -> gl_PRIMARY_COLOR
 
 unmarshalSrc :: GLint -> Src
 unmarshalSrc x
-   | x == 0x1702 = CurrentUnit
-   | x == 0x8578 = Previous
-   | x == 0x8576 = Constant
-   | x == 0x8577 = PrimaryColor
+   | y == gl_TEXTURE = CurrentUnit
+   | y == gl_PREVIOUS = Previous
+   | y == gl_CONSTANT = Constant
+   | y == gl_PRIMARY_COLOR = PrimaryColor
    | otherwise = Crossbar (unmarshalTextureUnit (fromIntegral x))
+   where y = fromIntegral x
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/Objects.hs b/Graphics/Rendering/OpenGL/GL/Texturing/Objects.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/Objects.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/Objects.hs
@@ -19,25 +19,17 @@
    TexturePriority, texturePriority, prioritizeTextures
 ) where
 
-import Data.List ( partition )
-import Foreign.Marshal.Array ( withArray, withArrayLen, peekArray, allocaArray )
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLuint, GLsizei, GLenum, GLclampf )
-import Graphics.Rendering.OpenGL.GL.BufferObjects ( ObjectName(..) )
-import Graphics.Rendering.OpenGL.GL.GLboolean ( unmarshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetTextureBinding1D,GetTextureBinding2D,GetTextureBinding3D,
-            GetTextureBindingCubeMap,GetTextureBindingRectangle),
-   getEnum1)
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.Texturing.TexParameter (
-   TexParameter(TextureResident,TexturePriority), texParamf, getTexParameteri )
-import Graphics.Rendering.OpenGL.GL.Texturing.Specification (
-   TextureTarget(..) )
-import Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget (
-   marshalTextureTarget )
+import Data.List
+import Data.ObjectName
+import Data.StateVar
+import Foreign.Marshal.Array
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.Texturing.TexParameter
+import Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+ glAreTexturesResident, glPrioritizeTextures )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -58,15 +50,6 @@
 
    isObjectName = fmap unmarshalGLboolean . glIsTexture . textureID
 
-foreign import CALLCONV unsafe "glGenTextures"
-   glGenTextures :: GLsizei -> Ptr GLuint -> IO ()
-
-foreign import CALLCONV unsafe "glDeleteTextures"
-   glDeleteTextures :: GLsizei -> Ptr GLuint -> IO ()
-
-foreign import CALLCONV unsafe "glIsTexture"
-   glIsTexture :: GLuint -> IO GLboolean
-
 --------------------------------------------------------------------------------
 
 textureBinding :: TextureTarget -> StateVar (Maybe TextureObject)
@@ -87,9 +70,6 @@
     TextureCubeMap -> GetTextureBindingCubeMap
     TextureRectangle -> GetTextureBindingRectangle
 
-foreign import CALLCONV unsafe "glBindTexture"
-   glBindTexture :: GLenum -> GLuint -> IO ()
-
 --------------------------------------------------------------------------------
 
 textureResident :: TextureTarget -> GettableStateVar Bool
@@ -110,9 +90,6 @@
                let (resident, nonResident) = partition (unmarshalGLboolean . snd) tr
                return (map fst resident, map fst nonResident)
 
-foreign import CALLCONV unsafe "glAreTexturesResident"
-   glAreTexturesResident :: GLsizei -> Ptr GLuint -> Ptr GLboolean -> IO GLboolean
-
 --------------------------------------------------------------------------------
 
 type TexturePriority = GLclampf
@@ -125,6 +102,3 @@
    withArrayLen (map (textureID . fst) tps) $ \len texObjsBuf ->
       withArray (map snd tps) $
          glPrioritizeTextures (fromIntegral len) texObjsBuf
-
-foreign import CALLCONV unsafe "glPrioritizeTextures"
-   glPrioritizeTextures :: GLsizei -> Ptr GLuint -> Ptr GLclampf -> IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/Parameters.hs b/Graphics/Rendering/OpenGL/GL/Texturing/Parameters.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/Parameters.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/Parameters.hs
@@ -23,35 +23,21 @@
    textureCompareFailValue, TextureCompareOperator(..), textureCompareOperator
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLint, GLfloat, GLclampf, Capability(..) )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   marshalCapability, unmarshalCapability )
-import Graphics.Rendering.OpenGL.GL.ComparisonFunction (
-   marshalComparisonFunction, unmarshalComparisonFunction )
-import Graphics.Rendering.OpenGL.GL.CoordTrans ( TextureCoordName(..) )
-import Graphics.Rendering.OpenGL.GL.PerFragment ( ComparisonFunction )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles (
-   PixelInternalFormat(..) )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetMaxTextureMaxAnisotropy,GetMaxTextureLODBias), getFloat1)
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar,
-   StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.Texturing.Specification (
-   Level, TextureTarget(..) )
-import Graphics.Rendering.OpenGL.GL.Texturing.TexParameter (
-   TexParameter(TextureMinFilter,TextureMagFilter,TextureWrapS,TextureWrapT,
-                TextureWrapR,TextureBorderColor,TextureMinLOD,TextureMaxLOD,
-                TextureBaseLevel,TextureMaxLevel,TextureMaxAnisotropy,
-                TextureLODBias,GenerateMipmap,DepthTextureMode,
-                TextureCompareMode,TextureCompareFunc,TextureCompareFailValue,
-                TextureCompare,TextureCompareOperator),
-   texParami, texParamf, texParamC4f, combineTexParams, combineTexParamsMaybe )
-import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat (
-   marshalPixelInternalFormat, unmarshalPixelInternalFormat )
-import Graphics.Rendering.OpenGL.GL.VertexSpec( Color4(..) )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal ( recordInvalidEnum )
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.ComparisonFunction
+import Graphics.Rendering.OpenGL.GL.CoordTrans
+import Graphics.Rendering.OpenGL.GL.PerFragment
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat
+import Graphics.Rendering.OpenGL.GL.Texturing.Specification
+import Graphics.Rendering.OpenGL.GL.Texturing.TexParameter
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility ( gl_CLAMP )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.EXT.TextureMirrorClamp (
+   gl_MIRROR_CLAMP, gl_MIRROR_CLAMP_TO_BORDER, gl_MIRROR_CLAMP_TO_EDGE )
 
 --------------------------------------------------------------------------------
 
@@ -73,26 +59,27 @@
 minToMag minFilter = error ("minToMag: illegal value " ++ show minFilter)
 
 marshalMinificationFilter :: MinificationFilter -> GLint
-marshalMinificationFilter x = case x of
-   (Nearest, Nothing     ) -> 0x2600
-   (Linear', Nothing     ) -> 0x2601
-   (Nearest, Just Nearest) -> 0x2700
-   (Linear', Just Nearest) -> 0x2701
-   (Nearest, Just Linear') -> 0x2702
-   (Linear', Just Linear') -> 0x2703
+marshalMinificationFilter x = fromIntegral $ case x of
+   (Nearest, Nothing     ) -> gl_NEAREST
+   (Linear', Nothing     ) -> gl_LINEAR
+   (Nearest, Just Nearest) -> gl_NEAREST_MIPMAP_NEAREST
+   (Linear', Just Nearest) -> gl_LINEAR_MIPMAP_NEAREST
+   (Nearest, Just Linear') -> gl_NEAREST_MIPMAP_LINEAR
+   (Linear', Just Linear') -> gl_LINEAR_MIPMAP_LINEAR
 
 marshalMagnificationFilter :: MagnificationFilter -> GLint
 marshalMagnificationFilter = marshalMinificationFilter . magToMin
 
 unmarshalMinificationFilter :: GLint -> MinificationFilter
 unmarshalMinificationFilter x
-   | x ==  0x2600 = (Nearest, Nothing     )
-   | x ==  0x2601 = (Linear', Nothing     )
-   | x ==  0x2700 = (Nearest, Just Nearest)
-   | x ==  0x2701 = (Linear', Just Nearest)
-   | x ==  0x2702 = (Nearest, Just Linear')
-   | x ==  0x2703 = (Linear', Just Linear')
+   | y ==  gl_NEAREST = (Nearest, Nothing)
+   | y ==  gl_LINEAR = (Linear', Nothing)
+   | y ==  gl_NEAREST_MIPMAP_NEAREST = (Nearest, Just Nearest)
+   | y ==  gl_LINEAR_MIPMAP_NEAREST = (Linear', Just Nearest)
+   | y ==  gl_NEAREST_MIPMAP_LINEAR = (Nearest, Just Linear')
+   | y ==  gl_LINEAR_MIPMAP_LINEAR = (Linear', Just Linear')
    | otherwise = error ("unmarshalMinificationFilter: illegal value " ++ show x)
+   where y = fromIntegral x
 
 unmarshalMagnificationFilter :: GLint -> MagnificationFilter
 unmarshalMagnificationFilter = minToMag . unmarshalMinificationFilter
@@ -120,27 +107,28 @@
    deriving ( Eq, Ord, Show )
 
 marshalTextureWrapMode :: (Repetition, Clamping) -> GLint
-marshalTextureWrapMode x = case x of
-   (Repeated, Clamp) -> 0x2900
-   (Repeated, Repeat) -> 0x2901
-   (Repeated, ClampToEdge) -> 0x812f
-   (Repeated, ClampToBorder) -> 0x812d
-   (Mirrored, Clamp) -> 0x8742
-   (Mirrored, Repeat) -> 0x8370
-   (Mirrored, ClampToEdge) -> 0x8743
-   (Mirrored, ClampToBorder) -> 0x8912
+marshalTextureWrapMode x = fromIntegral $ case x of
+   (Repeated, Clamp) -> gl_CLAMP
+   (Repeated, Repeat) -> gl_REPEAT
+   (Repeated, ClampToEdge) -> gl_CLAMP_TO_EDGE
+   (Repeated, ClampToBorder) -> gl_CLAMP_TO_BORDER
+   (Mirrored, Clamp) -> gl_MIRROR_CLAMP
+   (Mirrored, Repeat) -> gl_MIRRORED_REPEAT
+   (Mirrored, ClampToEdge) -> gl_MIRROR_CLAMP_TO_EDGE
+   (Mirrored, ClampToBorder) -> gl_MIRROR_CLAMP_TO_BORDER
 
 unmarshalTextureWrapMode :: GLint -> (Repetition, Clamping)
 unmarshalTextureWrapMode x
-   | x == 0x2900 = (Repeated, Clamp)
-   | x == 0x2901 = (Repeated, Repeat)
-   | x == 0x812f = (Repeated, ClampToEdge)
-   | x == 0x812d = (Repeated, ClampToBorder)
-   | x == 0x8742 = (Mirrored, Clamp)
-   | x == 0x8370 = (Mirrored, Repeat)
-   | x == 0x8743 = (Mirrored, ClampToEdge)
-   | x == 0x8912 = (Mirrored, ClampToBorder)
+   | y == gl_CLAMP = (Repeated, Clamp)
+   | y == gl_REPEAT = (Repeated, Repeat)
+   | y == gl_CLAMP_TO_EDGE = (Repeated, ClampToEdge)
+   | y == gl_CLAMP_TO_BORDER = (Repeated, ClampToBorder)
+   | y == gl_MIRROR_CLAMP = (Mirrored, Clamp)
+   | y == gl_MIRRORED_REPEAT = (Mirrored, Repeat)
+   | y == gl_MIRROR_CLAMP_TO_EDGE = (Mirrored, ClampToEdge)
+   | y == gl_MIRROR_CLAMP_TO_BORDER = (Mirrored, ClampToBorder)
    | otherwise = error ("unmarshalTextureWrapMode: illegal value " ++ show x)
+   where y = fromIntegral x
 
 --------------------------------------------------------------------------------
 
@@ -214,15 +202,16 @@
 --------------------------------------------------------------------------------
 
 marshalTextureCompareMode :: Capability -> GLint
-marshalTextureCompareMode x = case x of
-   Disabled -> 0x0     -- i.e. None
-   Enabled -> 0x884e   -- i.e. CompareRToTexture
+marshalTextureCompareMode x = fromIntegral $ case x of
+   Disabled -> gl_NONE
+   Enabled -> gl_COMPARE_REF_TO_TEXTURE
 
 unmarshalTextureCompareMode :: GLint -> Capability
 unmarshalTextureCompareMode x
-   | x == 0x0 = Disabled
-   | x == 0x884e = Enabled
+   | y == gl_NONE = Disabled
+   | y == gl_COMPARE_REF_TO_TEXTURE = Enabled
    | otherwise = error ("unmarshalTextureCompareMode: illegal value " ++ show x)
+   where y = fromIntegral x
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/PixelInternalFormat.hs b/Graphics/Rendering/OpenGL/GL/Texturing/PixelInternalFormat.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/PixelInternalFormat.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/PixelInternalFormat.hs
@@ -18,7 +18,18 @@
    marshalPixelInternalFormat', unmarshalPixelInternalFormat,
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLint, GLenum )
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   gl_ALPHA12, gl_ALPHA16, gl_ALPHA4, gl_ALPHA8, gl_COMPRESSED_ALPHA,
+   gl_COMPRESSED_INTENSITY, gl_COMPRESSED_LUMINANCE,
+   gl_COMPRESSED_LUMINANCE_ALPHA, gl_COMPRESSED_SLUMINANCE,
+   gl_COMPRESSED_SLUMINANCE_ALPHA, gl_INTENSITY, gl_INTENSITY12, gl_INTENSITY16,
+   gl_INTENSITY4, gl_INTENSITY8, gl_LUMINANCE, gl_LUMINANCE12,
+   gl_LUMINANCE12_ALPHA12, gl_LUMINANCE12_ALPHA4, gl_LUMINANCE16,
+   gl_LUMINANCE16_ALPHA16, gl_LUMINANCE4, gl_LUMINANCE4_ALPHA4,
+   gl_LUMINANCE6_ALPHA2, gl_LUMINANCE8, gl_LUMINANCE8_ALPHA8,
+   gl_LUMINANCE_ALPHA, gl_SLUMINANCE, gl_SLUMINANCE8, gl_SLUMINANCE8_ALPHA8,
+   gl_SLUMINANCE_ALPHA )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -90,71 +101,71 @@
    deriving ( Eq, Ord, Show )
 
 marshalPixelInternalFormat :: PixelInternalFormat -> GLint
-marshalPixelInternalFormat x = case x of
-   Alpha' -> 0x1906
-   DepthComponent' -> 0x1902
-   Luminance' -> 0x1909
-   LuminanceAlpha' -> 0x190a
-   RGB' -> 0x1907
-   RGBA' -> 0x1908
-   SRGB -> 0x8c40
-   SRGBAlpha -> 0x8c42
-   SLuminance -> 0x8c46
-   SLuminanceAlpha -> 0x8c44
-   Alpha4 -> 0x803b
-   Alpha8 -> 0x803c
-   Alpha12 -> 0x803d
-   Alpha16 -> 0x803e
-   DepthComponent16 -> 0x81a5
-   DepthComponent24 -> 0x81a6
-   DepthComponent32 -> 0x81a7
-   Luminance4 -> 0x803f
-   Luminance8 -> 0x8040
-   Luminance12 -> 0x8041
-   Luminance16 -> 0x8042
-   Luminance4Alpha4 -> 0x8043
-   Luminance6Alpha2 -> 0x8044
-   Luminance8Alpha8 -> 0x8045
-   Luminance12Alpha4 -> 0x8046
-   Luminance12Alpha12 -> 0x8047
-   Luminance16Alpha16 -> 0x8048
-   Intensity -> 0x8049
-   Intensity4 -> 0x804a
-   Intensity8 -> 0x804b
-   Intensity12 -> 0x804c
-   Intensity16 -> 0x804d
-   R3G3B2 -> 0x2a10
-   RGB4 -> 0x804f
-   RGB5 -> 0x8050
-   RGB8 -> 0x8051
-   RGB10 -> 0x8052
-   RGB12 -> 0x8053
-   RGB16 -> 0x8054
-   RGBA2 -> 0x8055
-   RGBA4 -> 0x8056
-   RGB5A1 -> 0x8057
-   RGBA8 -> 0x8058
-   RGB10A2 -> 0x8059
-   RGBA12 -> 0x805a
-   RGBA16 -> 0x805b
-   SRGB8 -> 0x8c41
-   SRGB8Alpha8 -> 0x8c43
-   SLuminance8 -> 0x8c47
-   SLuminance8Alpha8 -> 0x8c45
-   CompressedAlpha -> 0x84e9
-   CompressedLuminance -> 0x84ea
-   CompressedLuminanceAlpha -> 0x84eb
-   CompressedIntensity -> 0x84ec
-   CompressedRGB -> 0x84ed
-   CompressedRGBA -> 0x84ee
-   CompressedSRGB -> 0x8c48
-   CompressedSRGBAlpha -> 0x8c49
-   CompressedSLuminance -> 0x8c4a
-   CompressedSLuminanceAlpha -> 0x8c4b
-   DepthComponent32f -> 0x8CAC
-   Depth32fStencil8 -> 0x8CAD
-   RGB9E5 -> 0x8C3D
-   R11fG11fB10f -> 0x8C3A
+marshalPixelInternalFormat x = fromIntegral $ case x of
+   Alpha' -> gl_ALPHA
+   DepthComponent' -> gl_DEPTH_COMPONENT
+   Luminance' -> gl_LUMINANCE
+   LuminanceAlpha' -> gl_LUMINANCE_ALPHA
+   RGB' -> gl_RGB
+   RGBA' -> gl_RGBA
+   SRGB -> gl_SRGB
+   SRGBAlpha -> gl_SRGB_ALPHA
+   SLuminance -> gl_SLUMINANCE
+   SLuminanceAlpha -> gl_SLUMINANCE_ALPHA
+   Alpha4 -> gl_ALPHA4
+   Alpha8 -> gl_ALPHA8
+   Alpha12 -> gl_ALPHA12
+   Alpha16 -> gl_ALPHA16
+   DepthComponent16 -> gl_DEPTH_COMPONENT16
+   DepthComponent24 -> gl_DEPTH_COMPONENT24
+   DepthComponent32 -> gl_DEPTH_COMPONENT32
+   Luminance4 -> gl_LUMINANCE4
+   Luminance8 -> gl_LUMINANCE8
+   Luminance12 -> gl_LUMINANCE12
+   Luminance16 -> gl_LUMINANCE16
+   Luminance4Alpha4 -> gl_LUMINANCE4_ALPHA4
+   Luminance6Alpha2 -> gl_LUMINANCE6_ALPHA2
+   Luminance8Alpha8 -> gl_LUMINANCE8_ALPHA8
+   Luminance12Alpha4 -> gl_LUMINANCE12_ALPHA4
+   Luminance12Alpha12 -> gl_LUMINANCE12_ALPHA12
+   Luminance16Alpha16 -> gl_LUMINANCE16_ALPHA16
+   Intensity -> gl_INTENSITY
+   Intensity4 -> gl_INTENSITY4
+   Intensity8 -> gl_INTENSITY8
+   Intensity12 -> gl_INTENSITY12
+   Intensity16 -> gl_INTENSITY16
+   R3G3B2 -> gl_R3_G3_B2
+   RGB4 -> gl_RGB4
+   RGB5 -> gl_RGB5
+   RGB8 -> gl_RGB8
+   RGB10 -> gl_RGB10
+   RGB12 -> gl_RGB12
+   RGB16 -> gl_RGB16
+   RGBA2 -> gl_RGBA2
+   RGBA4 -> gl_RGBA4
+   RGB5A1 -> gl_RGB5_A1
+   RGBA8 -> gl_RGBA8
+   RGB10A2 -> gl_RGB10_A2
+   RGBA12 -> gl_RGBA12
+   RGBA16 -> gl_RGBA16
+   SRGB8 -> gl_SRGB8
+   SRGB8Alpha8 -> gl_SRGB8_ALPHA8
+   SLuminance8 -> gl_SLUMINANCE8
+   SLuminance8Alpha8 -> gl_SLUMINANCE8_ALPHA8
+   CompressedAlpha -> gl_COMPRESSED_ALPHA
+   CompressedLuminance -> gl_COMPRESSED_LUMINANCE
+   CompressedLuminanceAlpha -> gl_COMPRESSED_LUMINANCE_ALPHA
+   CompressedIntensity -> gl_COMPRESSED_INTENSITY
+   CompressedRGB -> gl_COMPRESSED_RGB
+   CompressedRGBA -> gl_COMPRESSED_RGBA
+   CompressedSRGB -> gl_COMPRESSED_SRGB
+   CompressedSRGBAlpha -> gl_COMPRESSED_SRGB_ALPHA
+   CompressedSLuminance -> gl_COMPRESSED_SLUMINANCE
+   CompressedSLuminanceAlpha -> gl_COMPRESSED_SLUMINANCE_ALPHA
+   DepthComponent32f -> gl_DEPTH_COMPONENT32F
+   Depth32fStencil8 -> gl_DEPTH32F_STENCIL8
+   RGB9E5 -> gl_RGB9_E5
+   R11fG11fB10f -> gl_R11F_G11F_B10F
 
 -- *sigh* The OpenGL API is sometimes a bit creative in its usage of types...
 marshalPixelInternalFormat' :: PixelInternalFormat -> GLenum
@@ -162,75 +173,76 @@
 
 unmarshalPixelInternalFormat :: GLint -> PixelInternalFormat
 unmarshalPixelInternalFormat x
-   | x == 0x1906 = Alpha'
-   | x == 0x1902 = DepthComponent'
-   | x == 0x1909 = Luminance'
-   | x == 0x190a = LuminanceAlpha'
-   | x == 0x1907 = RGB'
-   | x == 0x1908 = RGBA'
-   | x == 0x8c40 = SRGB
-   | x == 0x8c42 = SRGBAlpha
-   | x == 0x8c46 = SLuminance
-   | x == 0x8c44 = SLuminanceAlpha
-   | x == 0x803b = Alpha4
-   | x == 0x803c = Alpha8
-   | x == 0x803d = Alpha12
-   | x == 0x803e = Alpha16
-   | x == 0x81a5 = DepthComponent16
-   | x == 0x81a6 = DepthComponent24
-   | x == 0x81a7 = DepthComponent32
-   | x == 0x803f = Luminance4
-   | x == 0x8040 = Luminance8
-   | x == 0x8041 = Luminance12
-   | x == 0x8042 = Luminance16
-   | x == 0x8043 = Luminance4Alpha4
-   | x == 0x8044 = Luminance6Alpha2
-   | x == 0x8045 = Luminance8Alpha8
-   | x == 0x8046 = Luminance12Alpha4
-   | x == 0x8047 = Luminance12Alpha12
-   | x == 0x8048 = Luminance16Alpha16
-   | x == 0x8049 = Intensity
-   | x == 0x804a = Intensity4
-   | x == 0x804b = Intensity8
-   | x == 0x804c = Intensity12
-   | x == 0x804d = Intensity16
-   | x == 0x2a10 = R3G3B2
-   | x == 0x804f = RGB4
-   | x == 0x8050 = RGB5
-   | x == 0x8051 = RGB8
-   | x == 0x8052 = RGB10
-   | x == 0x8053 = RGB12
-   | x == 0x8054 = RGB16
-   | x == 0x8055 = RGBA2
-   | x == 0x8056 = RGBA4
-   | x == 0x8057 = RGB5A1
-   | x == 0x8058 = RGBA8
-   | x == 0x8059 = RGB10A2
-   | x == 0x805a = RGBA12
-   | x == 0x805b = RGBA16
-   | x == 0x8c41 = SRGB8
-   | x == 0x8c43 = SRGB8Alpha8
-   | x == 0x8c47 = SLuminance8
-   | x == 0x8c45 = SLuminance8Alpha8
-   | x == 0x84e9 = CompressedAlpha
-   | x == 0x84ea = CompressedLuminance
-   | x == 0x84eb = CompressedLuminanceAlpha
-   | x == 0x84ec = CompressedIntensity
-   | x == 0x84ed = CompressedRGB
-   | x == 0x84ee = CompressedRGBA
-   | x == 0x8c48 = CompressedSRGB
-   | x == 0x8c49 = CompressedSRGBAlpha
-   | x == 0x8c4a = CompressedSLuminance
-   | x == 0x8c4b = CompressedSLuminanceAlpha
-   | x == 0x8CAC = DepthComponent32f
-   | x == 0x8CAD = Depth32fStencil8
-   | x == 0x8C3D = RGB9E5
+   | y == gl_ALPHA = Alpha'
+   | y == gl_DEPTH_COMPONENT = DepthComponent'
+   | y == gl_LUMINANCE = Luminance'
+   | y == gl_LUMINANCE_ALPHA = LuminanceAlpha'
+   | y == gl_RGB = RGB'
+   | y == gl_RGBA = RGBA'
+   | y == gl_SRGB = SRGB
+   | y == gl_SRGB_ALPHA = SRGBAlpha
+   | y == gl_SLUMINANCE = SLuminance
+   | y == gl_SLUMINANCE_ALPHA = SLuminanceAlpha
+   | y == gl_ALPHA4 = Alpha4
+   | y == gl_ALPHA8 = Alpha8
+   | y == gl_ALPHA12 = Alpha12
+   | y == gl_ALPHA16 = Alpha16
+   | y == gl_DEPTH_COMPONENT16 = DepthComponent16
+   | y == gl_DEPTH_COMPONENT24 = DepthComponent24
+   | y == gl_DEPTH_COMPONENT32 = DepthComponent32
+   | y == gl_LUMINANCE4 = Luminance4
+   | y == gl_LUMINANCE8 = Luminance8
+   | y == gl_LUMINANCE12 = Luminance12
+   | y == gl_LUMINANCE16 = Luminance16
+   | y == gl_LUMINANCE4_ALPHA4 = Luminance4Alpha4
+   | y == gl_LUMINANCE6_ALPHA2 = Luminance6Alpha2
+   | y == gl_LUMINANCE8_ALPHA8 = Luminance8Alpha8
+   | y == gl_LUMINANCE12_ALPHA4 = Luminance12Alpha4
+   | y == gl_LUMINANCE12_ALPHA12 = Luminance12Alpha12
+   | y == gl_LUMINANCE16_ALPHA16 = Luminance16Alpha16
+   | y == gl_INTENSITY = Intensity
+   | y == gl_INTENSITY4 = Intensity4
+   | y == gl_INTENSITY8 = Intensity8
+   | y == gl_INTENSITY12 = Intensity12
+   | y == gl_INTENSITY16 = Intensity16
+   | y == gl_R3_G3_B2 = R3G3B2
+   | y == gl_RGB4 = RGB4
+   | y == gl_RGB5 = RGB5
+   | y == gl_RGB8 = RGB8
+   | y == gl_RGB10 = RGB10
+   | y == gl_RGB12 = RGB12
+   | y == gl_RGB16 = RGB16
+   | y == gl_RGBA2 = RGBA2
+   | y == gl_RGBA4 = RGBA4
+   | y == gl_RGB5_A1 = RGB5A1
+   | y == gl_RGBA8 = RGBA8
+   | y == gl_RGB10_A2 = RGB10A2
+   | y == gl_RGBA12 = RGBA12
+   | y == gl_RGBA16 = RGBA16
+   | y == gl_SRGB8 = SRGB8
+   | y == gl_SRGB8_ALPHA8 = SRGB8Alpha8
+   | y == gl_SLUMINANCE8 = SLuminance8
+   | y == gl_SLUMINANCE8_ALPHA8 = SLuminance8Alpha8
+   | y == gl_COMPRESSED_ALPHA = CompressedAlpha
+   | y == gl_COMPRESSED_LUMINANCE = CompressedLuminance
+   | y == gl_COMPRESSED_LUMINANCE_ALPHA = CompressedLuminanceAlpha
+   | y == gl_COMPRESSED_INTENSITY = CompressedIntensity
+   | y == gl_COMPRESSED_RGB = CompressedRGB
+   | y == gl_COMPRESSED_RGBA = CompressedRGBA
+   | y == gl_COMPRESSED_SRGB = CompressedSRGB
+   | y == gl_COMPRESSED_SRGB_ALPHA = CompressedSRGBAlpha
+   | y == gl_COMPRESSED_SLUMINANCE = CompressedSLuminance
+   | y == gl_COMPRESSED_SLUMINANCE_ALPHA = CompressedSLuminanceAlpha
+   | y == gl_DEPTH_COMPONENT32F = DepthComponent32f
+   | y == gl_DEPTH32F_STENCIL8 = Depth32fStencil8
+   | y == gl_RGB9_E5 = RGB9E5
    -- legacy values
-   | x == 1 = Luminance'
-   | x == 2 = LuminanceAlpha'
-   | x == 3 = RGB'
-   | x == 4 = RGBA'
+   | y == 1 = Luminance'
+   | y == 2 = LuminanceAlpha'
+   | y == 3 = RGB'
+   | y == 4 = RGBA'
    | otherwise = error ("unmarshalPixelInternalFormat: illegal value " ++ show x)
+   where y = fromIntegral x
 
 -- Note: The following formats are still missing, it's a bit unclear how to
 -- handle these nicely. From the EXT_texture_sRGB spec:
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/Queries.hs b/Graphics/Rendering/OpenGL/GL/Texturing/Queries.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/Queries.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/Queries.hs
@@ -19,24 +19,21 @@
    textureDepthBits, textureCompressedImageSize, textureProxyOK
 ) where
 
-import Control.Monad ( liftM2, liftM3, liftM4 )
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLint, GLsizei, GLenum )
-import Graphics.Rendering.OpenGL.GL.GLboolean ( unmarshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1 )
-import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat (
-   unmarshalPixelInternalFormat )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles (
-   Proxy(..), PixelInternalFormat(..) )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar )
-import Graphics.Rendering.OpenGL.GL.Texturing.Specification (
-   TextureTarget(..), CubeMapTarget, Level, Border,
-   TextureSize1D(..), TextureSize2D(..), TextureSize3D(..) )
-import Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget (
-   marshalProxyTextureTarget, marshalCubeMapTarget )
-import Graphics.Rendering.OpenGL.GL.VertexSpec( Color4(..) )
+import Control.Monad
+import Data.StateVar
+import Foreign.Marshal.Alloc
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.PixelRectangles
+import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat
+import Graphics.Rendering.OpenGL.GL.Texturing.Specification
+import Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   gl_TEXTURE_INTENSITY_SIZE, gl_TEXTURE_LUMINANCE_SIZE, gl_DEPTH_BITS )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.EXT.PalettedTexture (
+   gl_TEXTURE_INDEX_SIZE )
 
 --------------------------------------------------------------------------------
 
@@ -60,22 +57,22 @@
 
 marshalTexLevelParameter :: TexLevelParameter -> GLenum
 marshalTexLevelParameter x = case x of
-   TextureInternalFormat -> 0x1003
-   TextureWidth -> 0x1000
-   TextureHeight -> 0x1001
-   TextureDepth -> 0x8071
-   TextureBorder -> 0x1005
-   TextureRedSize -> 0x805C
-   TextureGreenSize -> 0x805D
-   TextureBlueSize -> 0x805E
-   TextureAlphaSize -> 0x805F
-   TextureIntensitySize -> 0x8061
-   TextureLuminanceSize -> 0x8060
-   TextureIndexSize -> 0x80ED
-   DepthBits -> 0x0D56
-   TextureCompressedImageSize -> 0x86A0
-   TextureCompressed -> 0x86A1
-   TextureSharedSize -> 0x8C3F
+   TextureInternalFormat -> gl_TEXTURE_INTERNAL_FORMAT
+   TextureWidth -> gl_TEXTURE_WIDTH
+   TextureHeight -> gl_TEXTURE_HEIGHT
+   TextureDepth -> gl_TEXTURE_DEPTH
+   TextureBorder -> gl_TEXTURE_BORDER
+   TextureRedSize -> gl_TEXTURE_RED_SIZE
+   TextureGreenSize -> gl_TEXTURE_GREEN_SIZE
+   TextureBlueSize -> gl_TEXTURE_BLUE_SIZE
+   TextureAlphaSize -> gl_TEXTURE_ALPHA_SIZE
+   TextureIntensitySize -> gl_TEXTURE_INTENSITY_SIZE
+   TextureLuminanceSize -> gl_TEXTURE_LUMINANCE_SIZE
+   TextureIndexSize -> gl_TEXTURE_INDEX_SIZE
+   DepthBits -> gl_DEPTH_BITS
+   TextureCompressedImageSize -> gl_TEXTURE_COMPRESSED_IMAGE_SIZE
+   TextureCompressed -> gl_TEXTURE_COMPRESSED
+   TextureSharedSize -> gl_TEXTURE_SHARED_SIZE
 
 --------------------------------------------------------------------------------
 
@@ -163,6 +160,3 @@
    alloca $ \buf -> do
       glGetTexLevelParameteriv (either (marshalProxyTextureTarget proxy) (\c -> if proxy == Proxy then marshalProxyTextureTarget Proxy TextureCubeMap else marshalCubeMapTarget c) t) level (marshalTexLevelParameter p) buf
       peek1 f buf
-
-foreign import CALLCONV unsafe "glGetTexLevelParameteriv"
-   glGetTexLevelParameteriv :: GLenum -> GLint -> GLenum -> Ptr GLint -> IO ()
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/Specification.hs b/Graphics/Rendering/OpenGL/GL/Texturing/Specification.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/Specification.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/Specification.hs
@@ -40,31 +40,16 @@
   maxTextureSize
 ) where
 
-import Foreign.Marshal.Array ( peekArray, allocaArray )
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLint, GLsizei, GLenum )
-import Graphics.Rendering.OpenGL.GL.CoordTrans ( Position(..) )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.PixelData ( withPixelData )
-import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat (
-   marshalPixelInternalFormat, marshalPixelInternalFormat' )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles (
-   PixelInternalFormat, PixelData, Proxy(..) )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetNumCompressedTextureFormats,GetCompressedTextureFormats,
-            GetMaxTextureSize,GetMax3DTextureSize,GetMaxCubeMapTextureSize,
-            GetMaxRectangleTextureSize),
-   getInteger1, getIntegerv)
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar )
-import Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget (
-   TextureTarget(..), marshalTextureTarget, marshalProxyTextureTarget,
-   CubeMapTarget(..), marshalCubeMapTarget )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
+import Data.StateVar
+import Foreign.Marshal.Array
+import Foreign.Ptr
+import Graphics.Rendering.OpenGL.GL.CoordTrans
+import Graphics.Rendering.OpenGL.GL.PixelData
+import Graphics.Rendering.OpenGL.GL.PixelRectangles
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat
+import Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -99,9 +84,6 @@
          (marshalProxyTextureTarget proxy Texture1D)
          level (marshalPixelInternalFormat int) w border
 
-foreign import CALLCONV unsafe "glTexImage1D"
-   glTexImage1D :: GLenum -> GLint -> GLint -> GLsizei -> GLint -> GLenum -> GLenum -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 texImage2D :: Maybe CubeMapTarget -> Proxy -> Level -> PixelInternalFormat -> TextureSize2D -> Border -> PixelData a -> IO ()
@@ -113,9 +95,6 @@
                 mbCubeMap)
          level (marshalPixelInternalFormat int) w h border
 
-foreign import CALLCONV unsafe "glTexImage2D"
-   glTexImage2D :: GLenum -> GLint -> GLint -> GLsizei -> GLsizei -> GLint -> GLenum -> GLenum -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 texImage3D :: Proxy -> Level -> PixelInternalFormat -> TextureSize3D -> Border -> PixelData a -> IO ()
@@ -125,8 +104,6 @@
          (marshalProxyTextureTarget proxy Texture3D)
          level (marshalPixelInternalFormat int) w h d border
 
-EXTENSION_ENTRY("GL_EXT_texture3D or OpenGL 1.2",glTexImage3D,GLenum -> GLint -> GLint -> GLsizei -> GLsizei -> GLsizei -> GLint -> GLenum -> GLenum -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 getTexImage :: Either TextureTarget CubeMapTarget -> Level -> PixelData a -> IO ()
@@ -134,9 +111,6 @@
    withPixelData pd $
       glGetTexImage (either marshalTextureTarget marshalCubeMapTarget t) level
 
-foreign import CALLCONV unsafe "glGetTexImage"
-   glGetTexImage :: GLenum -> GLint -> GLenum -> GLenum -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 copyTexImage1D :: Level -> PixelInternalFormat -> Position -> TextureSize1D -> Border -> IO ()
@@ -145,9 +119,6 @@
       (marshalTextureTarget Texture1D) level
       (marshalPixelInternalFormat' int) x y w border
 
-foreign import CALLCONV unsafe "glCopyTexImage1D"
-   glCopyTexImage1D :: GLenum -> GLint -> GLenum -> GLint -> GLint -> GLsizei -> GLint -> IO ()
-
 --------------------------------------------------------------------------------
 
 copyTexImage2D :: Maybe CubeMapTarget -> Level -> PixelInternalFormat -> Position -> TextureSize2D -> Border -> IO ()
@@ -156,9 +127,6 @@
       (maybe (marshalTextureTarget Texture2D) marshalCubeMapTarget mbCubeMap) level
       (marshalPixelInternalFormat' int) x y w h border
 
-foreign import CALLCONV unsafe "glCopyTexImage2D"
-   glCopyTexImage2D :: GLenum -> GLint -> GLenum -> GLint -> GLint -> GLsizei -> GLsizei -> GLint -> IO ()
-
 --------------------------------------------------------------------------------
 
 texSubImage1D :: Level -> TexturePosition1D -> TextureSize1D -> PixelData a -> IO ()
@@ -166,9 +134,6 @@
    withPixelData pd $
       glTexSubImage1D (marshalTextureTarget Texture1D) level xOff w
 
-foreign import CALLCONV unsafe "glTexSubImage1D"
-   glTexSubImage1D :: GLenum -> GLint -> GLint -> GLsizei -> GLenum -> GLenum -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 texSubImage2D :: Maybe CubeMapTarget -> Level -> TexturePosition2D -> TextureSize2D -> PixelData a -> IO ()
@@ -176,9 +141,6 @@
    withPixelData pd $
       glTexSubImage2D (maybe (marshalTextureTarget Texture2D) marshalCubeMapTarget mbCubeMap) level xOff yOff w h
 
-foreign import CALLCONV unsafe "glTexSubImage2D"
-   glTexSubImage2D :: GLenum -> GLint -> GLint -> GLint -> GLsizei -> GLsizei -> GLenum -> GLenum -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 texSubImage3D :: Level -> TexturePosition3D -> TextureSize3D -> PixelData a -> IO ()
@@ -186,34 +148,24 @@
    withPixelData pd $
       glTexSubImage3D (marshalTextureTarget Texture3D) level xOff yOff zOff w h d
 
-EXTENSION_ENTRY("GL_EXT_texture3D or OpenGL 1.2",glTexSubImage3D,GLenum -> GLint -> GLint -> GLint -> GLint -> GLsizei -> GLsizei -> GLsizei -> GLenum -> GLenum -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 copyTexSubImage1D :: Level -> TexturePosition1D -> Position -> TextureSize1D -> IO ()
 copyTexSubImage1D level (TexturePosition1D xOff) (Position x y) (TextureSize1D w) =
    glCopyTexSubImage1D (marshalTextureTarget Texture1D) level xOff x y w
 
-foreign import CALLCONV unsafe "glCopyTexSubImage1D"
-   glCopyTexSubImage1D :: GLenum -> GLint -> GLint -> GLint -> GLint -> GLsizei -> IO ()
-
 --------------------------------------------------------------------------------
 
 copyTexSubImage2D :: Maybe CubeMapTarget -> Level -> TexturePosition2D -> Position -> TextureSize2D -> IO ()
 copyTexSubImage2D mbCubeMap level (TexturePosition2D xOff yOff) (Position x y) (TextureSize2D w h) =
    glCopyTexSubImage2D (maybe (marshalTextureTarget Texture2D) marshalCubeMapTarget mbCubeMap) level xOff yOff x y w h
 
-foreign import CALLCONV unsafe "glCopyTexSubImage2D"
-   glCopyTexSubImage2D :: GLenum -> GLint -> GLint -> GLint -> GLint -> GLint -> GLsizei -> GLsizei -> IO ()
-
 --------------------------------------------------------------------------------
 
 copyTexSubImage3D :: Level -> TexturePosition3D -> Position -> TextureSize2D -> IO ()
 copyTexSubImage3D level (TexturePosition3D xOff yOff zOff) (Position x y) (TextureSize2D w h) =
    glCopyTexSubImage3D (marshalTextureTarget Texture3D) level xOff yOff zOff x y w h
 
-EXTENSION_ENTRY("GL_EXT_texture3D or OpenGL 1.2",glCopyTexSubImage3D,GLenum -> GLint -> GLint -> GLint -> GLint -> GLint -> GLint -> GLsizei -> GLsizei -> IO ())
-
 --------------------------------------------------------------------------------
 
 newtype CompressedTextureFormat = CompressedTextureFormat GLenum
@@ -231,14 +183,7 @@
 
 data CompressedPixelData a =
      CompressedPixelData !CompressedTextureFormat GLsizei (Ptr a)
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq (CompressedPixelData a)
-instance Ord (CompressedPixelData a)
-instance Show (CompressedPixelData a)
-#else
    deriving ( Eq, Ord, Show )
-#endif
 
 withCompressedPixelData ::
    CompressedPixelData a -> (GLenum -> GLsizei -> Ptr a -> b) -> b
@@ -251,67 +196,53 @@
 compressedTexImage1D :: Proxy -> Level -> TextureSize1D -> Border -> CompressedPixelData a -> IO ()
 compressedTexImage1D proxy level (TextureSize1D w) border cpd =
    withCompressedPixelData cpd $ \fmt ->
-      glCompressedTexImage1DARB
+      glCompressedTexImage1D
          (marshalProxyTextureTarget proxy Texture1D) level fmt w border
 
-EXTENSION_ENTRY("GL_ARB_texture_compression or OpenGL 1.3",glCompressedTexImage1DARB,GLenum -> GLint -> GLenum -> GLsizei -> GLint -> GLsizei -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 compressedTexImage2D :: Maybe CubeMapTarget -> Proxy -> Level -> TextureSize2D -> Border -> CompressedPixelData a -> IO ()
 compressedTexImage2D mbCubeMap proxy level (TextureSize2D w h) border cpd =
    withCompressedPixelData cpd $ \fmt ->
-      glCompressedTexImage2DARB
+      glCompressedTexImage2D
          (maybe (marshalProxyTextureTarget proxy Texture2D)
                 (\c -> if proxy == Proxy then marshalProxyTextureTarget Proxy TextureCubeMap else marshalCubeMapTarget c)
                 mbCubeMap)
          level fmt w h border
 
-EXTENSION_ENTRY("GL_ARB_texture_compression or OpenGL 1.3",glCompressedTexImage2DARB,GLenum -> GLint -> GLenum -> GLsizei -> GLsizei ->GLint -> GLsizei -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 compressedTexImage3D :: Proxy -> Level -> TextureSize3D -> Border -> CompressedPixelData a -> IO ()
 compressedTexImage3D proxy level (TextureSize3D w h d) border cpd =
    withCompressedPixelData cpd $ \fmt ->
-      glCompressedTexImage3DARB
+      glCompressedTexImage3D
          (marshalProxyTextureTarget proxy Texture3D) level fmt w h d border
 
-EXTENSION_ENTRY("GL_ARB_texture_compression or OpenGL 1.3",glCompressedTexImage3DARB,GLenum -> GLint -> GLenum -> GLsizei -> GLsizei -> GLsizei -> GLint -> GLsizei -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 getCompressedTexImage :: Either TextureTarget CubeMapTarget -> Level -> Ptr a -> IO ()
-getCompressedTexImage = glGetCompressedTexImageARB . either marshalTextureTarget marshalCubeMapTarget
-
-EXTENSION_ENTRY("GL_ARB_texture_compression or OpenGL 1.3",glGetCompressedTexImageARB,GLenum -> GLint -> Ptr a -> IO ())
+getCompressedTexImage = glGetCompressedTexImage . either marshalTextureTarget marshalCubeMapTarget
 
 --------------------------------------------------------------------------------
 
 compressedTexSubImage1D :: Level -> TexturePosition1D -> TextureSize1D -> CompressedPixelData a -> IO ()
 compressedTexSubImage1D level (TexturePosition1D xOff) (TextureSize1D w) cpd =
    withCompressedPixelData cpd $
-      glCompressedTexSubImage1DARB (marshalTextureTarget Texture1D) level xOff w
-
-EXTENSION_ENTRY("GL_ARB_texture_compression or OpenGL 1.3",glCompressedTexSubImage1DARB,GLenum -> GLint -> GLint -> GLsizei -> GLenum -> GLsizei -> Ptr a -> IO ())
+      glCompressedTexSubImage1D (marshalTextureTarget Texture1D) level xOff w
 
 --------------------------------------------------------------------------------
 
 compressedTexSubImage2D :: Maybe CubeMapTarget -> Level -> TexturePosition2D -> TextureSize2D -> CompressedPixelData a -> IO ()
 compressedTexSubImage2D mbCubeMap level (TexturePosition2D xOff yOff) (TextureSize2D w h) cpd =
    withCompressedPixelData cpd $
-      glCompressedTexSubImage2DARB (maybe (marshalTextureTarget Texture2D) marshalCubeMapTarget mbCubeMap) level xOff yOff w h
-
-EXTENSION_ENTRY("GL_ARB_texture_compression or OpenGL 1.3",glCompressedTexSubImage2DARB,GLenum -> GLint -> GLint -> GLint -> GLsizei -> GLsizei -> GLenum -> GLsizei -> Ptr a-> IO ())
+      glCompressedTexSubImage2D (maybe (marshalTextureTarget Texture2D) marshalCubeMapTarget mbCubeMap) level xOff yOff w h
 
 --------------------------------------------------------------------------------
 
 compressedTexSubImage3D :: Level -> TexturePosition3D -> TextureSize3D -> CompressedPixelData a -> IO ()
 compressedTexSubImage3D level (TexturePosition3D xOff yOff zOff) (TextureSize3D w h d) cpd =
    withCompressedPixelData cpd $
-      glCompressedTexSubImage3DARB (marshalTextureTarget Texture3D) level xOff yOff zOff w h d
-
-EXTENSION_ENTRY("GL_ARB_texture_compression or OpenGL 1.3",glCompressedTexSubImage3DARB,GLenum -> GLint -> GLint -> GLint -> GLint -> GLsizei -> GLsizei -> GLsizei -> GLenum -> GLsizei -> Ptr a -> IO ())
+      glCompressedTexSubImage3D (marshalTextureTarget Texture3D) level xOff yOff zOff w h d
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/TexParameter.hs b/Graphics/Rendering/OpenGL/GL/Texturing/TexParameter.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/TexParameter.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/TexParameter.hs
@@ -18,19 +18,24 @@
    combineTexParams, combineTexParamsMaybe
 ) where
 
-import Control.Monad ( liftM2 )
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Marshal.Utils ( with )
-import Foreign.Storable ( Storable )
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLint, GLenum, GLfloat, Capability(..) )
-import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1 )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   HasGetter(get), HasSetter(($=)), StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget (
-   TextureTarget(..), marshalTextureTarget )
-import Graphics.Rendering.OpenGL.GL.VertexSpec( Color4(..) )
+import Control.Monad
+import Data.StateVar
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Utils
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   gl_DEPTH_TEXTURE_MODE, gl_GENERATE_MIPMAP, gl_TEXTURE_PRIORITY,
+   gl_TEXTURE_RESIDENT )
+import Graphics.Rendering.OpenGL.Raw.ARB.ShadowAmbient (
+   gl_TEXTURE_COMPARE_FAIL_VALUE )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.EXT.TextureFilterAnisotropic (
+   gl_TEXTURE_MAX_ANISOTROPY )
 
 --------------------------------------------------------------------------------
 
@@ -59,27 +64,27 @@
 
 marshalTexParameter :: TexParameter -> GLenum
 marshalTexParameter x = case x of
-   TextureMinFilter -> 0x2801
-   TextureMagFilter -> 0x2800
-   TextureWrapS -> 0x2802
-   TextureWrapT -> 0x2803
-   TextureWrapR -> 0x8072
-   TextureBorderColor -> 0x1004
-   TextureMinLOD -> 0x813A
-   TextureMaxLOD -> 0x813B
-   TextureBaseLevel -> 0x813C
-   TextureMaxLevel -> 0x813D
-   TexturePriority -> 0x8066
-   TextureMaxAnisotropy -> 0x84FE
+   TextureMinFilter -> gl_TEXTURE_MIN_FILTER
+   TextureMagFilter -> gl_TEXTURE_MAG_FILTER
+   TextureWrapS -> gl_TEXTURE_WRAP_S
+   TextureWrapT -> gl_TEXTURE_WRAP_T
+   TextureWrapR -> gl_TEXTURE_WRAP_R
+   TextureBorderColor -> gl_TEXTURE_BORDER_COLOR
+   TextureMinLOD -> gl_TEXTURE_MIN_LOD
+   TextureMaxLOD -> gl_TEXTURE_MAX_LOD
+   TextureBaseLevel -> gl_TEXTURE_BASE_LEVEL
+   TextureMaxLevel -> gl_TEXTURE_MAX_LEVEL
+   TexturePriority -> gl_TEXTURE_PRIORITY
+   TextureMaxAnisotropy -> gl_TEXTURE_MAX_ANISOTROPY
    TextureCompare -> 0x819A
    TextureCompareOperator -> 0x819B
-   TextureCompareFailValue -> 0x80BF
-   GenerateMipmap -> 0x8191
-   TextureCompareMode -> 0x884C
-   TextureCompareFunc -> 0x884D
-   DepthTextureMode -> 0x884B
-   TextureLODBias -> 0x8501
-   TextureResident -> 0x8067
+   TextureCompareFailValue -> gl_TEXTURE_COMPARE_FAIL_VALUE
+   GenerateMipmap -> gl_GENERATE_MIPMAP
+   TextureCompareMode -> gl_TEXTURE_COMPARE_MODE
+   TextureCompareFunc -> gl_TEXTURE_COMPARE_FUNC
+   DepthTextureMode -> gl_DEPTH_TEXTURE_MODE
+   TextureLODBias -> gl_TEXTURE_LOD_BIAS
+   TextureResident -> gl_TEXTURE_RESIDENT
 
 --------------------------------------------------------------------------------
 
@@ -90,15 +95,6 @@
    marshalAct x $
       glTexParameter (marshalTextureTarget t) (marshalTexParameter p)
 
-foreign import CALLCONV unsafe "glTexParameteri"
-   glTexParameteri :: GLenum -> GLenum ->  GLint -> IO ()
-
-foreign import CALLCONV unsafe "glTexParameterf"
-   glTexParameterf :: GLenum -> GLenum ->  GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glTexParameterfv"
-   glTexParameterC4f :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
-
 --------------------------------------------------------------------------------
 
 getTexParameter :: Storable b
@@ -110,15 +106,6 @@
      glGetTexParameter (marshalTextureTarget t) (marshalTexParameter p) buf
      peek1 unmarshal buf
 
-foreign import CALLCONV unsafe "glGetTexParameteriv"
-   glGetTexParameteriv :: GLenum -> GLenum -> Ptr GLint -> IO ()
-
-foreign import CALLCONV unsafe "glGetTexParameterfv"
-   glGetTexParameterfv :: GLenum -> GLenum -> Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glGetTexParameterfv"
-   glGetTexParameterC4f :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
-
 --------------------------------------------------------------------------------
 
 m2a :: (a -> b) -> a -> (b -> IO ()) -> IO ()
@@ -143,6 +130,12 @@
    makeStateVar
       (getTexParameter glGetTexParameterC4f id   t p)
       (texParameter    glTexParameterC4f    with t p)
+
+glTexParameterC4f :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
+glTexParameterC4f target pname ptr = glTexParameterfv target pname (castPtr ptr)
+
+glGetTexParameterC4f :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
+glGetTexParameterC4f target pname ptr = glGetTexParameterfv target pname (castPtr ptr)
 
 getTexParameteri :: (GLint -> a) -> TextureTarget -> TexParameter -> IO a
 getTexParameteri = getTexParameter glGetTexParameteriv
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/TextureTarget.hs b/Graphics/Rendering/OpenGL/GL/Texturing/TextureTarget.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/TextureTarget.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/TextureTarget.hs
@@ -18,8 +18,8 @@
    CubeMapTarget(..), marshalCubeMapTarget
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
-import Graphics.Rendering.OpenGL.GL.PixelRectangles ( Proxy(..) )
+import Graphics.Rendering.OpenGL.GL.PixelRectangles
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -33,20 +33,20 @@
 
 marshalTextureTarget :: TextureTarget -> GLenum
 marshalTextureTarget x = case x of
-   Texture1D -> 0xde0
-   Texture2D -> 0xde1
-   Texture3D -> 0x806f
-   TextureCubeMap -> 0x8513
-   TextureRectangle -> 0x84f5
+   Texture1D -> gl_TEXTURE_1D
+   Texture2D -> gl_TEXTURE_2D
+   Texture3D -> gl_TEXTURE_3D
+   TextureCubeMap -> gl_TEXTURE_CUBE_MAP
+   TextureRectangle -> gl_TEXTURE_RECTANGLE
 
 marshalProxyTextureTarget :: Proxy -> TextureTarget -> GLenum
 marshalProxyTextureTarget NoProxy x = marshalTextureTarget x
 marshalProxyTextureTarget Proxy   x = case x of
-   Texture1D -> 0x8063
-   Texture2D -> 0x8064
-   Texture3D -> 0x8070
-   TextureCubeMap -> 0x851b
-   TextureRectangle -> 0x84f7
+   Texture1D -> gl_PROXY_TEXTURE_1D
+   Texture2D -> gl_PROXY_TEXTURE_2D
+   Texture3D -> gl_PROXY_TEXTURE_3D
+   TextureCubeMap -> gl_PROXY_TEXTURE_CUBE_MAP
+   TextureRectangle -> gl_PROXY_TEXTURE_RECTANGLE
 
 --------------------------------------------------------------------------------
 
@@ -61,9 +61,9 @@
 
 marshalCubeMapTarget :: CubeMapTarget -> GLenum
 marshalCubeMapTarget x = case x of
-   TextureCubeMapPositiveX -> 0x8515
-   TextureCubeMapNegativeX -> 0x8516
-   TextureCubeMapPositiveY -> 0x8517
-   TextureCubeMapNegativeY -> 0x8518
-   TextureCubeMapPositiveZ -> 0x8519
-   TextureCubeMapNegativeZ -> 0x851a
+   TextureCubeMapPositiveX -> gl_TEXTURE_CUBE_MAP_POSITIVE_X
+   TextureCubeMapNegativeX -> gl_TEXTURE_CUBE_MAP_NEGATIVE_X
+   TextureCubeMapPositiveY -> gl_TEXTURE_CUBE_MAP_POSITIVE_Y
+   TextureCubeMapNegativeY -> gl_TEXTURE_CUBE_MAP_NEGATIVE_Y
+   TextureCubeMapPositiveZ -> gl_TEXTURE_CUBE_MAP_POSITIVE_Z
+   TextureCubeMapNegativeZ -> gl_TEXTURE_CUBE_MAP_NEGATIVE_Z
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/TextureUnit.hs b/Graphics/Rendering/OpenGL/GL/Texturing/TextureUnit.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/TextureUnit.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/TextureUnit.hs
@@ -17,7 +17,7 @@
    TextureUnit(..), marshalTextureUnit, unmarshalTextureUnit
 ) where
 
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLuint )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -28,7 +28,7 @@
    deriving ( Eq, Ord, Show )
 
 marshalTextureUnit :: TextureUnit -> GLenum
-marshalTextureUnit (TextureUnit x) = 0x84c0 + fromIntegral x
+marshalTextureUnit (TextureUnit x) = gl_TEXTURE0 + fromIntegral x
 
 unmarshalTextureUnit :: GLenum -> TextureUnit
-unmarshalTextureUnit x = TextureUnit (fromIntegral (x - 0x84c0))
+unmarshalTextureUnit x = TextureUnit (fromIntegral (x - gl_TEXTURE0))
diff --git a/Graphics/Rendering/OpenGL/GL/VertexArrays.hs b/Graphics/Rendering/OpenGL/GL/VertexArrays.hs
--- a/Graphics/Rendering/OpenGL/GL/VertexArrays.hs
+++ b/Graphics/Rendering/OpenGL/GL/VertexArrays.hs
@@ -18,6 +18,7 @@
    NumComponents, DataType(..), Stride, VertexArrayDescriptor(..),
 
    -- * Specifying Data for the Arrays
+   Capability(..),
    ClientArrayType(..), arrayPointer,
    InterleavedArrays(..), interleavedArrays,
 
@@ -28,58 +29,44 @@
    ArrayIndex, NumArrayIndices, NumIndexBlocks,
    arrayElement, drawArrays, multiDrawArrays, drawElements, multiDrawElements,
    drawRangeElements, maxElementsVertices, maxElementsIndices, lockArrays,
-   primitiveRestartIndex,
+   primitiveRestartIndex, primitiveRestartIndexNV,
 
    -- * Generic Vertex Attribute Arrays
    vertexAttribPointer, vertexAttribArray
 ) where
 
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Ptr ( Ptr, nullPtr )
-import Foreign.Storable ( Storable(peek) )
-import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapVertexArray,CapNormalArray,CapColorArray,CapIndexArray,
-             CapTextureCoordArray,CapEdgeFlagArray,CapFogCoordArray,
-             CapSecondaryColorArray,CapMatrixIndexArray,CapPrimitiveRestart),
-   makeCapability, unmarshalCapability )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLenum, GLint, GLuint, GLsizei, Capability(Disabled,Enabled) )
-import Graphics.Rendering.OpenGL.GL.DataType (
-   DataType(..), marshalDataType, unmarshalDataType )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.GLboolean (
-   marshalGLboolean, unmarshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetVertexArraySize,GetVertexArrayType,GetVertexArrayStride,
-            GetNormalArrayType,GetNormalArrayStride,GetColorArraySize,
-            GetColorArrayType,GetColorArrayStride,GetSecondaryColorArraySize,
-            GetSecondaryColorArrayType,GetSecondaryColorArrayStride,
-            GetIndexArrayType,GetIndexArrayStride,
-            GetFogCoordArrayType,GetFogCoordArrayStride,
-            GetTextureCoordArraySize,GetTextureCoordArrayType,
-            GetTextureCoordArrayStride,GetEdgeFlagArrayStride,
-            GetMaxElementsVertices,GetMaxElementsIndices,
-            GetClientActiveTexture,GetArrayElementLockFirst,
-            GetArrayElementLockCount,GetPrimitiveRestartIndex),
-   getInteger1, getEnum1, getSizei1, AttribLocation,
-   GetVertexAttribPName(..),
-   getVertexAttribInteger1, getVertexAttribEnum1, getVertexAttribBoolean1,
-   GetVertexAttribPointerPName(..), getVertexAttribPointer )
-import Graphics.Rendering.OpenGL.GL.PrimitiveMode ( marshalPrimitiveMode )
-import Graphics.Rendering.OpenGL.GL.BeginEnd ( PrimitiveMode )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   HasGetter(get),
-   GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit (
-   TextureUnit, marshalTextureUnit, unmarshalTextureUnit )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal (
-   recordInvalidEnum, recordInvalidValue )
-import Graphics.Rendering.OpenGL.GL.VertexSpec ( IntegerHandling(..) )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
+import Data.StateVar
+import Foreign.Marshal.Alloc
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.Capability
+import Graphics.Rendering.OpenGL.GL.DataType
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GL.PrimitiveMode
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glArrayElement, glClientActiveTexture, glColorPointer, glDisableClientState,
+   glEdgeFlagPointer, glEnableClientState, glFogCoordPointer, glIndexPointer,
+   glInterleavedArrays, glNormalPointer, glSecondaryColorPointer,
+   glTexCoordPointer, glVertexPointer, gl_C3F_V3F, gl_C4F_N3F_V3F, gl_C4UB_V2F,
+   gl_C4UB_V3F, gl_COLOR_ARRAY, gl_COLOR_ARRAY_POINTER, gl_EDGE_FLAG_ARRAY,
+   gl_EDGE_FLAG_ARRAY_POINTER, gl_FEEDBACK_BUFFER_POINTER, gl_FOG_COORD_ARRAY,
+   gl_FOG_COORD_ARRAY_POINTER, gl_INDEX_ARRAY, gl_INDEX_ARRAY_POINTER,
+   gl_N3F_V3F, gl_NORMAL_ARRAY, gl_NORMAL_ARRAY_POINTER,
+   gl_SECONDARY_COLOR_ARRAY, gl_SECONDARY_COLOR_ARRAY_POINTER,
+   gl_SELECTION_BUFFER_POINTER, gl_T2F_C3F_V3F, gl_T2F_C4F_N3F_V3F,
+   gl_T2F_C4UB_V3F, gl_T2F_N3F_V3F, gl_T2F_V3F, gl_T4F_C4F_N3F_V4F, gl_T4F_V4F,
+   gl_TEXTURE_COORD_ARRAY, gl_TEXTURE_COORD_ARRAY_POINTER, gl_V2F, gl_V3F,
+   gl_VERTEX_ARRAY, gl_VERTEX_ARRAY_POINTER )
+import Graphics.Rendering.OpenGL.Raw.ARB.MatrixPalette (
+   gl_MATRIX_INDEX_ARRAY, gl_MATRIX_INDEX_ARRAY_POINTER )
+import Graphics.Rendering.OpenGL.Raw.ARB.VertexBlend ( gl_WEIGHT_ARRAY_POINTER )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.Raw.EXT.CompiledVertexArray
+import Graphics.Rendering.OpenGL.Raw.NV.PrimitiveRestart
 
 --------------------------------------------------------------------------------
 
@@ -89,14 +76,7 @@
 
 data VertexArrayDescriptor a =
    VertexArrayDescriptor !NumComponents !DataType !Stride !(Ptr a)
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq (VertexArrayDescriptor a)
-instance Ord (VertexArrayDescriptor a)
-instance Show (VertexArrayDescriptor a)
-#else
    deriving ( Eq, Ord, Show )
-#endif
 
 noVertexArrayDescriptor :: VertexArrayDescriptor a
 noVertexArrayDescriptor = VertexArrayDescriptor 0 Byte 0 nullPtr
@@ -117,15 +97,15 @@
 
 marshalClientArrayType :: ClientArrayType -> GLenum
 marshalClientArrayType x = case x of
-   VertexArray -> 0x8074
-   NormalArray -> 0x8075
-   ColorArray -> 0x8076
-   IndexArray -> 0x8077
-   TextureCoordArray -> 0x8078
-   EdgeFlagArray -> 0x8079
-   FogCoordArray -> 0x8457
-   SecondaryColorArray -> 0x845e
-   MatrixIndexArray -> 0x8844
+   VertexArray -> gl_VERTEX_ARRAY
+   NormalArray -> gl_NORMAL_ARRAY
+   ColorArray -> gl_COLOR_ARRAY
+   IndexArray -> gl_INDEX_ARRAY
+   TextureCoordArray -> gl_TEXTURE_COORD_ARRAY
+   EdgeFlagArray -> gl_EDGE_FLAG_ARRAY
+   FogCoordArray -> gl_FOG_COORD_ARRAY
+   SecondaryColorArray -> gl_SECONDARY_COLOR_ARRAY
+   MatrixIndexArray -> gl_MATRIX_INDEX_ARRAY
 
 -- Hmmm...
 clientArrayTypeToEnableCap :: ClientArrayType -> EnableCap
@@ -177,9 +157,6 @@
 setVertexPointer (VertexArrayDescriptor n d s p) =
    glVertexPointer n (marshalDataType d) s p
 
-foreign import CALLCONV unsafe "glVertexPointer" glVertexPointer ::
-   GLint -> GLenum -> GLsizei -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 normalPointer :: StateVar (VertexArrayDescriptor a)
@@ -196,9 +173,6 @@
 setNormalPointer (VertexArrayDescriptor n d s p) =
    check (n == 3) $ glNormalPointer (marshalDataType d) s p
 
-foreign import CALLCONV unsafe "glNormalPointer" glNormalPointer ::
-   GLenum -> GLsizei -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 colorPointer :: StateVar (VertexArrayDescriptor a)
@@ -216,9 +190,6 @@
 setColorPointer (VertexArrayDescriptor n d s p) =
    check (n == 3 || n == 4) $ glColorPointer n (marshalDataType d) s p
 
-foreign import CALLCONV unsafe "glColorPointer" glColorPointer ::
-   GLint -> GLenum -> GLsizei -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 indexPointer :: StateVar (VertexArrayDescriptor a)
@@ -235,9 +206,6 @@
 setIndexPointer (VertexArrayDescriptor n d s p) =
    check (n == 1) $ glIndexPointer (marshalDataType d) s p
 
-foreign import CALLCONV unsafe "glIndexPointer" glIndexPointer ::
-   GLenum -> GLsizei -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 texCoordPointer :: StateVar (VertexArrayDescriptor a)
@@ -255,9 +223,6 @@
 setTexCoordPointer (VertexArrayDescriptor n d s p) =
    glTexCoordPointer n (marshalDataType d) s p
 
-foreign import CALLCONV unsafe "glTexCoordPointer" glTexCoordPointer ::
-   GLint -> GLenum -> GLsizei -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 edgeFlagPointer :: StateVar (VertexArrayDescriptor a)
@@ -273,9 +238,6 @@
 setEdgeFlagPointer (VertexArrayDescriptor n d s p) =
    check (n == 1 && d == UnsignedByte) $ glEdgeFlagPointer s p
 
-foreign import CALLCONV unsafe "glEdgeFlagPointer" glEdgeFlagPointer ::
-   GLsizei -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 fogCoordPointer :: StateVar (VertexArrayDescriptor a)
@@ -290,9 +252,7 @@
 
 setFogCoordPointer :: VertexArrayDescriptor a -> IO ()
 setFogCoordPointer (VertexArrayDescriptor n d s p) =
-   check (n == 1) $ glFogCoordPointerEXT (marshalDataType d) s p
-
-EXTENSION_ENTRY("GL_EXT_fog_coord or OpenGL 1.4",glFogCoordPointerEXT,GLenum -> GLsizei -> Ptr a -> IO ())
+   check (n == 1) $ glFogCoordPointer (marshalDataType d) s p
 
 --------------------------------------------------------------------------------
 
@@ -310,9 +270,7 @@
 
 setSecondaryColorPointer :: (VertexArrayDescriptor a) -> IO ()
 setSecondaryColorPointer (VertexArrayDescriptor n d s p) =
-   glSecondaryColorPointerEXT n (marshalDataType d) s p
-
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColorPointerEXT,GLint -> GLenum -> GLsizei -> Ptr a -> IO ())
+   glSecondaryColorPointer n (marshalDataType d) s p
 
 --------------------------------------------------------------------------------
 
@@ -335,29 +293,26 @@
 
 marshalInterleavedArrays :: InterleavedArrays -> GLenum
 marshalInterleavedArrays x = case x of
-   V2f -> 0x2a20
-   V3f -> 0x2a21
-   C4ubV2f -> 0x2a22
-   C4ubV3f -> 0x2a23
-   C3fV3f -> 0x2a24
-   N3fV3f -> 0x2a25
-   C4fN3fV3f -> 0x2a26
-   T2fV3f -> 0x2a27
-   T4fV4f -> 0x2a28
-   T2fC4ubV3f -> 0x2a29
-   T2fC3fV3f -> 0x2a2a
-   T2fN3fV3f -> 0x2a2b
-   T2fC4fN3fV3f -> 0x2a2c
-   T4fC4fN3fV4f -> 0x2a2d
+   V2f -> gl_V2F
+   V3f -> gl_V3F
+   C4ubV2f -> gl_C4UB_V2F
+   C4ubV3f -> gl_C4UB_V3F
+   C3fV3f -> gl_C3F_V3F
+   N3fV3f -> gl_N3F_V3F
+   C4fN3fV3f -> gl_C4F_N3F_V3F
+   T2fV3f -> gl_T2F_V3F
+   T4fV4f -> gl_T4F_V4F
+   T2fC4ubV3f -> gl_T2F_C4UB_V3F
+   T2fC3fV3f -> gl_T2F_C3F_V3F
+   T2fN3fV3f -> gl_T2F_N3F_V3F
+   T2fC4fN3fV3f -> gl_T2F_C4F_N3F_V3F
+   T4fC4fN3fV4f -> gl_T4F_C4F_N3F_V4F
 
 --------------------------------------------------------------------------------
 
 interleavedArrays :: InterleavedArrays -> Stride -> Ptr a -> IO ()
 interleavedArrays = glInterleavedArrays . marshalInterleavedArrays
 
-foreign import CALLCONV unsafe "glInterleavedArrays" glInterleavedArrays ::
-   GLenum -> GLsizei -> Ptr a -> IO ()
-
 --------------------------------------------------------------------------------
 
 clientState :: ClientArrayType -> StateVar Capability
@@ -372,20 +327,12 @@
    (if val == Enabled then glEnableClientState else glDisableClientState)
       (marshalClientArrayType arrayType)
 
-foreign import CALLCONV unsafe "glEnableClientState" glEnableClientState ::
-   GLenum -> IO ()
-
-foreign import CALLCONV unsafe "glDisableClientState" glDisableClientState ::
-   GLenum -> IO ()
-
 --------------------------------------------------------------------------------
 
 clientActiveTexture :: StateVar TextureUnit
 clientActiveTexture =
    makeStateVar (getEnum1 unmarshalTextureUnit GetClientActiveTexture)
-                (glClientActiveTextureARB . marshalTextureUnit)
-
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glClientActiveTextureARB,GLenum -> IO ())
+                (glClientActiveTexture . marshalTextureUnit)
 
 --------------------------------------------------------------------------------
 
@@ -400,43 +347,29 @@
 arrayElement :: ArrayIndex -> IO ()
 arrayElement = glArrayElement
 
-foreign import CALLCONV unsafe "glArrayElement" glArrayElement :: GLint -> IO ()
-
 drawArrays :: PrimitiveMode -> ArrayIndex -> NumArrayIndices -> IO ()
 drawArrays = glDrawArrays . marshalPrimitiveMode
 
-foreign import CALLCONV unsafe "glDrawArrays" glDrawArrays ::
-   GLenum -> GLint -> GLsizei -> IO ()
-
 multiDrawArrays ::
       PrimitiveMode -> Ptr ArrayIndex -> Ptr NumArrayIndices -> NumIndexBlocks
    -> IO ()
-multiDrawArrays = glMultiDrawArraysEXT . marshalPrimitiveMode
-
-EXTENSION_ENTRY("GL_EXT_multi_draw_arrays or OpenGL 1.4",glMultiDrawArraysEXT,GLenum -> Ptr ArrayIndex -> Ptr GLsizei -> GLsizei -> IO ())
+multiDrawArrays = glMultiDrawArrays . marshalPrimitiveMode
 
 drawElements :: PrimitiveMode -> NumArrayIndices -> DataType -> Ptr a -> IO ()
 drawElements m c = glDrawElements (marshalPrimitiveMode m) c . marshalDataType
 
-foreign import CALLCONV unsafe "glDrawElements" glDrawElements ::
-   GLenum -> GLsizei -> GLenum -> Ptr a -> IO ()
-
 multiDrawElements ::
       PrimitiveMode -> Ptr NumArrayIndices -> DataType -> Ptr (Ptr a)
    -> NumIndexBlocks -> IO ()
 multiDrawElements m c =
-   glMultiDrawElementsEXT (marshalPrimitiveMode m) c . marshalDataType
-
-EXTENSION_ENTRY("GL_EXT_multi_draw_arrays or OpenGL 1.4",glMultiDrawElementsEXT,GLenum -> Ptr GLsizei -> GLenum -> Ptr (Ptr a) -> GLsizei -> IO ())
+   glMultiDrawElements (marshalPrimitiveMode m) c . marshalDataType
 
 drawRangeElements ::
       PrimitiveMode -> (ArrayIndex, ArrayIndex) -> NumArrayIndices -> DataType
    -> Ptr a -> IO ()
 drawRangeElements m (s, e) c =
-   glDrawRangeElementsEXT (marshalPrimitiveMode m) (fromIntegral s)
-                          (fromIntegral e) c . marshalDataType
-
-EXTENSION_ENTRY("GL_EXT_draw_range_elements or OpenGL 1.2",glDrawRangeElementsEXT,GLenum -> GLuint -> GLuint -> GLsizei -> GLenum -> Ptr a -> IO ())
+   glDrawRangeElements (marshalPrimitiveMode m) (fromIntegral s)
+                       (fromIntegral e) c . marshalDataType
 
 maxElementsVertices :: GettableStateVar NumArrayIndices
 maxElementsVertices = makeGettableStateVar (getSizei1 id GetMaxElementsVertices)
@@ -458,35 +391,38 @@
       else return Nothing
 
 setLockArrays :: Maybe (ArrayIndex, NumArrayIndices) -> IO ()
-setLockArrays = maybe glUnlockArraysEXT (uncurry glLockArraysEXT)
+setLockArrays = maybe glUnlockArrays (uncurry glLockArrays)
 
-EXTENSION_ENTRY("GL_EXT_compiled_vertex_array",glLockArraysEXT,GLint -> GLsizei -> IO ())
-EXTENSION_ENTRY("GL_EXT_compiled_vertex_array",glUnlockArraysEXT,IO ())
+--------------------------------------------------------------------------------
 
+primitiveRestartIndex :: StateVar (Maybe ArrayIndex)
+primitiveRestartIndex =
+   makeStateVarMaybe
+      (return CapPrimitiveRestart)
+      (getInteger1 id GetPrimitiveRestartIndex)
+      (glPrimitiveRestartIndex . fromIntegral)
+
 --------------------------------------------------------------------------------
 
 -- We almost could use makeStateVarMaybe below, but, alas, this is client state.
 
-primitiveRestartIndex :: StateVar (Maybe ArrayIndex)
-primitiveRestartIndex =
-   makeStateVar getPrimitiverestartIndex setPrimitiverestartIndex
+primitiveRestartIndexNV :: StateVar (Maybe ArrayIndex)
+primitiveRestartIndexNV =
+   makeStateVar getPrimitiveRestartIndexNV setPrimitiveRestartIndexNV
 
-getPrimitiverestartIndex :: IO (Maybe ArrayIndex)
-getPrimitiverestartIndex = do
-   state <- get (makeCapability CapPrimitiveRestart)
-   if state == Enabled
-      then fmap Just $ getInteger1 fromIntegral GetPrimitiveRestartIndex
+getPrimitiveRestartIndexNV :: IO (Maybe ArrayIndex)
+getPrimitiveRestartIndexNV = do
+   on <- getBoolean1 unmarshalGLboolean GetPrimitiveRestartNV
+   if on
+      then fmap Just $ getInteger1 fromIntegral GetPrimitiveRestartIndexNV
       else return Nothing
 
-setPrimitiverestartIndex :: Maybe ArrayIndex -> IO ()
-setPrimitiverestartIndex maybeIdx = case maybeIdx of
-   Nothing  -> glDisableClientState primitiveRestartNV
-   Just idx -> do glEnableClientState primitiveRestartNV
+setPrimitiveRestartIndexNV :: Maybe ArrayIndex -> IO ()
+setPrimitiveRestartIndexNV maybeIdx = case maybeIdx of
+   Nothing  -> glDisableClientState gl_PRIMITIVE_RESTART_NV
+   Just idx -> do glEnableClientState gl_PRIMITIVE_RESTART_NV
                   glPrimitiveRestartIndexNV (fromIntegral idx)
-   where primitiveRestartNV = 0x8558   -- ToDo: HACK!
 
-EXTENSION_ENTRY("GL_NV_primitive_restart",glPrimitiveRestartIndexNV,GLuint -> IO ())
-
 --------------------------------------------------------------------------------
 
 data GetPointervPName =
@@ -505,18 +441,18 @@
 
 marshalGetPointervPName :: GetPointervPName -> GLenum
 marshalGetPointervPName x = case x of
-   VertexArrayPointer -> 0x808e
-   NormalArrayPointer -> 0x808f
-   ColorArrayPointer -> 0x8090
-   IndexArrayPointer -> 0x8091
-   TextureCoordArrayPointer -> 0x8092
-   EdgeFlagArrayPointer -> 0x8093
-   FogCoordArrayPointer -> 0x8456
-   SecondaryColorArrayPointer -> 0x845d
-   FeedbackBufferPointer -> 0xdf0
-   SelectionBufferPointer -> 0xdf3
-   WeightArrayPointer -> 0x86ac
-   MatrixIndexArrayPointer -> 0x8849
+   VertexArrayPointer -> gl_VERTEX_ARRAY_POINTER
+   NormalArrayPointer -> gl_NORMAL_ARRAY_POINTER
+   ColorArrayPointer -> gl_COLOR_ARRAY_POINTER
+   IndexArrayPointer -> gl_INDEX_ARRAY_POINTER
+   TextureCoordArrayPointer -> gl_TEXTURE_COORD_ARRAY_POINTER
+   EdgeFlagArrayPointer -> gl_EDGE_FLAG_ARRAY_POINTER
+   FogCoordArrayPointer -> gl_FOG_COORD_ARRAY_POINTER
+   SecondaryColorArrayPointer -> gl_SECONDARY_COLOR_ARRAY_POINTER
+   FeedbackBufferPointer -> gl_FEEDBACK_BUFFER_POINTER
+   SelectionBufferPointer -> gl_SELECTION_BUFFER_POINTER
+   WeightArrayPointer -> gl_WEIGHT_ARRAY_POINTER
+   MatrixIndexArrayPointer -> gl_MATRIX_INDEX_ARRAY_POINTER
 
 --------------------------------------------------------------------------------
 
@@ -525,13 +461,10 @@
    glGetPointerv (marshalGetPointervPName n) buf
    peek buf
 
-foreign import CALLCONV unsafe "glGetPointerv" glGetPointerv ::
-   GLenum -> Ptr (Ptr a) -> IO ()
-
 --------------------------------------------------------------------------------
 
 vertexAttribPointer :: AttribLocation -> StateVar (IntegerHandling, VertexArrayDescriptor a)
-vertexAttribPointer location = undefined
+vertexAttribPointer location =
    makeStateVar (getVertexAttribPointer_ location) (setVertexAttribPointer location)
 
 getVertexAttribPointer_ :: AttribLocation -> IO (IntegerHandling, VertexArrayDescriptor a)
@@ -548,15 +481,12 @@
    return (h, VertexArrayDescriptor n d s p)
 
 setVertexAttribPointer :: AttribLocation -> (IntegerHandling, VertexArrayDescriptor a) -> IO ()
-setVertexAttribPointer location (h, VertexArrayDescriptor n d s p) = case h of
-   ToFloat -> glVertexAttribPointerARB location n md (marshalGLboolean False) s p
-   ToNormalizedFloat -> glVertexAttribPointerARB location n md (marshalGLboolean True) s p
+setVertexAttribPointer (AttribLocation location) (h, VertexArrayDescriptor n d s p) = case h of
+   ToFloat -> glVertexAttribPointer location n md (marshalGLboolean False) s p
+   ToNormalizedFloat -> glVertexAttribPointer location n md (marshalGLboolean True) s p
    KeepIntegral -> glVertexAttribIPointer location n md s p
   where md = marshalDataType d
 
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttribPointerARB,AttribLocation -> GLint -> GLenum -> GLboolean -> GLsizei -> Ptr a -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribIPointer,AttribLocation -> GLint -> GLenum -> GLsizei -> Ptr a -> IO ())
-
 --------------------------------------------------------------------------------
 
 vertexAttribArray :: AttribLocation -> StateVar Capability
@@ -568,8 +498,5 @@
    getVertexAttribBoolean1 unmarshalCapability location GetVertexAttribArrayEnabled
 
 setVertexAttribArray :: Capability -> AttribLocation -> IO ()
-setVertexAttribArray Disabled = glDisableVertexAttribArrayARB
-setVertexAttribArray Enabled = glEnableVertexAttribArrayARB
-
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glDisableVertexAttribArrayARB,AttribLocation -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glEnableVertexAttribArrayARB,AttribLocation -> IO ())
+setVertexAttribArray Disabled (AttribLocation location) = glDisableVertexAttribArray location
+setVertexAttribArray Enabled (AttribLocation location) = glEnableVertexAttribArray location
diff --git a/Graphics/Rendering/OpenGL/GL/VertexAttributes.hs b/Graphics/Rendering/OpenGL/GL/VertexAttributes.hs
--- a/Graphics/Rendering/OpenGL/GL/VertexAttributes.hs
+++ b/Graphics/Rendering/OpenGL/GL/VertexAttributes.hs
@@ -21,17 +21,15 @@
    Index1(..)
 ) where
 
-import Control.Applicative ( Applicative(..) )
-import Control.Monad ( ap )
-import Data.Foldable ( Foldable(..) )
-import Data.Ix ( Ix )
-import Data.Traversable ( Traversable(..) )
-import Data.Typeable (
-   Typeable(..), mkTyCon, mkTyConApp, Typeable1(..), typeOfDefault )
-import Foreign.Ptr ( castPtr )
-import Foreign.Storable ( Storable(..) )
-import Graphics.Rendering.OpenGL.GL.PeekPoke (
-   peek1, poke2, poke3, poke4, poke1, peek2, peek3, peek4 )
+import Control.Applicative
+import Control.Monad
+import Data.Foldable
+import Data.Ix
+import Data.Traversable
+import Data.Typeable
+import Foreign.Marshal.Array
+import Foreign.Ptr
+import Foreign.Storable
 
 --------------------------------------------------------------------------------
 
@@ -67,8 +65,8 @@
 instance Storable a => Storable (TexCoord1 a) where
    sizeOf    ~(TexCoord1 s) = sizeOf s
    alignment ~(TexCoord1 s) = alignment s
-   peek = peek1 TexCoord1 . castPtr
-   poke ptr (TexCoord1 s) = poke1 (castPtr ptr) s
+   peek = peekApplicativeTraversable
+   poke = pokeFoldable
 
 --------------------------------------------------------------------------------
 
@@ -104,8 +102,8 @@
 instance Storable a => Storable (TexCoord2 a) where
    sizeOf ~(TexCoord2 x _) = 2 * sizeOf x
    alignment ~(TexCoord2 x _) = alignment x
-   peek = peek2 TexCoord2 . castPtr
-   poke ptr (TexCoord2 x y) = poke2 (castPtr ptr) x y
+   peek = peekApplicativeTraversable
+   poke = pokeFoldable
 
 --------------------------------------------------------------------------------
 
@@ -141,8 +139,8 @@
 instance Storable a => Storable (TexCoord3 a) where
    sizeOf ~(TexCoord3 x _ _) = 3 * sizeOf x
    alignment ~(TexCoord3 x _ _) = alignment x
-   peek = peek3 TexCoord3 . castPtr
-   poke ptr (TexCoord3 x y z) = poke3 (castPtr ptr) x y z
+   peek = peekApplicativeTraversable
+   poke = pokeFoldable
 
 --------------------------------------------------------------------------------
 
@@ -178,8 +176,8 @@
 instance Storable a => Storable (TexCoord4 a) where
    sizeOf ~(TexCoord4 x _ _ _) = 4 * sizeOf x
    alignment ~(TexCoord4 x _ _ _) = alignment x
-   peek = peek4 TexCoord4 . castPtr
-   poke ptr (TexCoord4 x y z w) = poke4 (castPtr ptr) x y z w
+   peek = peekApplicativeTraversable
+   poke = pokeFoldable
 
 --------------------------------------------------------------------------------
 
@@ -214,8 +212,8 @@
 instance Storable a => Storable (Normal3 a) where
    sizeOf ~(Normal3 x _ _) = 3 * sizeOf x
    alignment ~(Normal3 x _ _) = alignment x
-   peek = peek3 Normal3 . castPtr
-   poke ptr (Normal3 x y z) = poke3 (castPtr ptr) x y z
+   peek = peekApplicativeTraversable
+   poke = pokeFoldable
 
 --------------------------------------------------------------------------------
 
@@ -251,8 +249,8 @@
 instance Storable a => Storable (FogCoord1 a) where
    sizeOf    ~(FogCoord1 s) = sizeOf s
    alignment ~(FogCoord1 s) = alignment s
-   peek = peek1 FogCoord1 . castPtr
-   poke ptr (FogCoord1 s) = poke1 (castPtr ptr) s
+   peek = peekApplicativeTraversable
+   poke = pokeFoldable
 
 --------------------------------------------------------------------------------
 
@@ -288,8 +286,8 @@
 instance Storable a => Storable (Color3 a) where
    sizeOf ~(Color3 x _ _) = 3 * sizeOf x
    alignment ~(Color3 x _ _) = alignment x
-   peek = peek3 Color3 . castPtr
-   poke ptr (Color3 x y z) = poke3 (castPtr ptr) x y z
+   peek = peekApplicativeTraversable
+   poke = pokeFoldable
 
 --------------------------------------------------------------------------------
 
@@ -325,8 +323,8 @@
 instance Storable a => Storable (Color4 a) where
    sizeOf ~(Color4 x _ _ _) = 4 * sizeOf x
    alignment ~(Color4 x _ _ _) = alignment x
-   peek = peek4 Color4 . castPtr
-   poke ptr (Color4 x y z w) = poke4 (castPtr ptr) x y z w
+   peek = peekApplicativeTraversable
+   poke = pokeFoldable
 
 --------------------------------------------------------------------------------
 
@@ -362,5 +360,26 @@
 instance Storable a => Storable (Index1 a) where
    sizeOf    ~(Index1 s) = sizeOf s
    alignment ~(Index1 s) = alignment s
-   peek = peek1 Index1 . castPtr
-   poke ptr (Index1 s) = poke1 (castPtr ptr) s
+   peek = peekApplicativeTraversable
+   poke = pokeFoldable
+
+--------------------------------------------------------------------------------
+
+peekApplicativeTraversable :: (Applicative t, Traversable t, Storable a) => Ptr (t a) -> IO (t a)
+peekApplicativeTraversable = Data.Traversable.mapM peek . addresses
+
+addresses :: (Applicative t, Traversable t, Storable a) => Ptr (t a) -> t (Ptr a)
+addresses = snd . mapAccumL nextPtr 0 . pure . castPtr
+
+nextPtr :: Storable a => Int -> Ptr a -> (Int, Ptr a)
+nextPtr offset ptr = (offset + 1, advancePtr ptr offset)
+
+--------------------------------------------------------------------------------
+
+pokeFoldable :: (Foldable t, Storable a) => Ptr (t a) -> t a -> IO ()
+pokeFoldable ptr xs = foldlM pokeAndAdvance (castPtr ptr) xs >> return ()
+
+pokeAndAdvance :: Storable a => Ptr a -> a -> IO (Ptr a)
+pokeAndAdvance ptr value = do
+   poke ptr value
+   return $ ptr `plusPtr` sizeOf value
diff --git a/Graphics/Rendering/OpenGL/GL/VertexSpec.hs b/Graphics/Rendering/OpenGL/GL/VertexSpec.hs
--- a/Graphics/Rendering/OpenGL/GL/VertexSpec.hs
+++ b/Graphics/Rendering/OpenGL/GL/VertexSpec.hs
@@ -17,7 +17,6 @@
    -- * Vertex Coordinates
    Vertex(..),
    VertexComponent,
-   Vertex1(..), Vertex2(..), Vertex3(..), Vertex4(..),
 
    -- * Auxiliary Vertex Attributes
    -- $AuxiliaryVertexAttributes
@@ -57,42 +56,53 @@
    TextureUnit(..), maxTextureUnit
 ) where
 
-import Data.Int
-import Data.Word
-import Foreign.Marshal.Array ( allocaArray )
-import Foreign.Ptr ( Ptr, castPtr )
-import Foreign.Storable ( Storable(..) )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLenum, GLbyte, GLshort, GLint, GLubyte, GLushort, GLuint, GLfloat,
-   GLdouble )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.GLboolean ( unmarshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.PeekPoke (
-   poke4, peek1M, peek2M, peek3M, peek4M )
-import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   AttribLocation(..),
-   GetPName(GetCurrentTextureCoords, GetCurrentNormal, GetCurrentFogCoord,
-            GetCurrentColor, GetCurrentSecondaryColor, GetCurrentIndex,
-            GetMaxTextureUnits,GetRGBAMode),
-   getBoolean1, getInteger1, getEnum1, getFloat1, getFloat3, getFloat4,
-   GetVertexAttribPName(GetCurrentVertexAttrib),
-   getVertexAttribFloat4, getVertexAttribIInteger4, getVertexAttribIuInteger4  )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
-import Graphics.Rendering.OpenGL.GL.Tensor (
-   Vertex1(..), Vertex2(..), Vertex3(..), Vertex4(..),
-   Vector1(..), Vector2(..), Vector3(..), Vector4(..) )
-import Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit (
-   TextureUnit(..), marshalTextureUnit, unmarshalTextureUnit )
-import Graphics.Rendering.OpenGL.GL.VertexAttributes (
-   TexCoord1(..), TexCoord2(..), TexCoord3(..), TexCoord4(..),
-   Normal3(..), FogCoord1(..), Color3(..), Color4(..), Index1(..) )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
-#include "HsOpenGLTypes.h"
+import Data.StateVar
+import Data.Tensor
+import Foreign.C.Types
+import Foreign.Marshal.Array
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GL.PeekPoke
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit
+import Graphics.Rendering.OpenGL.GL.VertexAttributes
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility (
+   glColor3b, glColor3bv, glColor3d, glColor3dv, glColor3f, glColor3fv,
+   glColor3i, glColor3iv, glColor3s, glColor3sv, glColor3ub, glColor3ubv,
+   glColor3ui, glColor3uiv, glColor3us, glColor3usv, glColor4b, glColor4bv,
+   glColor4d, glColor4dv, glColor4f, glColor4fv, glColor4i, glColor4iv,
+   glColor4s, glColor4sv, glColor4ub, glColor4ubv, glColor4ui, glColor4uiv,
+   glColor4us, glColor4usv, glFogCoordd, glFogCoorddv, glFogCoordf,
+   glFogCoordfv, glIndexd, glIndexdv, glIndexf, glIndexfv, glIndexi, glIndexiv,
+   glIndexs, glIndexsv, glIndexub, glIndexubv, glMultiTexCoord1d,
+   glMultiTexCoord1dv, glMultiTexCoord1f, glMultiTexCoord1fv, glMultiTexCoord1i,
+   glMultiTexCoord1iv, glMultiTexCoord1s, glMultiTexCoord1sv, glMultiTexCoord2d,
+   glMultiTexCoord2dv, glMultiTexCoord2f, glMultiTexCoord2fv, glMultiTexCoord2i,
+   glMultiTexCoord2iv, glMultiTexCoord2s, glMultiTexCoord2sv, glMultiTexCoord3d,
+   glMultiTexCoord3dv, glMultiTexCoord3f, glMultiTexCoord3fv, glMultiTexCoord3i,
+   glMultiTexCoord3iv, glMultiTexCoord3s, glMultiTexCoord3sv, glMultiTexCoord4d,
+   glMultiTexCoord4dv, glMultiTexCoord4f, glMultiTexCoord4fv, glMultiTexCoord4i,
+   glMultiTexCoord4iv, glMultiTexCoord4s, glMultiTexCoord4sv, glNormal3b,
+   glNormal3bv, glNormal3d, glNormal3dv, glNormal3f, glNormal3fv, glNormal3i,
+   glNormal3iv, glNormal3s, glNormal3sv, glSecondaryColor3b,
+   glSecondaryColor3bv, glSecondaryColor3d, glSecondaryColor3dv,
+   glSecondaryColor3f, glSecondaryColor3fv, glSecondaryColor3i,
+   glSecondaryColor3iv, glSecondaryColor3s, glSecondaryColor3sv,
+   glSecondaryColor3ub, glSecondaryColor3ubv, glSecondaryColor3ui,
+   glSecondaryColor3uiv, glSecondaryColor3us, glSecondaryColor3usv,
+   glTexCoord1d, glTexCoord1dv, glTexCoord1f, glTexCoord1fv, glTexCoord1i,
+   glTexCoord1iv, glTexCoord1s, glTexCoord1sv, glTexCoord2d, glTexCoord2dv,
+   glTexCoord2f, glTexCoord2fv, glTexCoord2i, glTexCoord2iv, glTexCoord2s,
+   glTexCoord2sv, glTexCoord3d, glTexCoord3dv, glTexCoord3f, glTexCoord3fv,
+   glTexCoord3i, glTexCoord3iv, glTexCoord3s, glTexCoord3sv, glTexCoord4d,
+   glTexCoord4dv, glTexCoord4f, glTexCoord4fv, glTexCoord4i, glTexCoord4iv,
+   glTexCoord4s, glTexCoord4sv, glVertex2d, glVertex2dv, glVertex2f,
+   glVertex2fv, glVertex2i, glVertex2iv, glVertex2s, glVertex2sv, glVertex3d,
+   glVertex3dv, glVertex3f, glVertex3fv, glVertex3i, glVertex3iv, glVertex3s,
+   glVertex3sv, glVertex4d, glVertex4dv, glVertex4f, glVertex4fv, glVertex4i,
+   glVertex4iv, glVertex4s, glVertex4sv )
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -107,27 +117,8 @@
    vertex3v :: Ptr a -> IO ()
    vertex4v :: Ptr a -> IO ()
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glVertex2s" glVertex2s ::
-   GLshort -> GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glVertex3s" glVertex3s ::
-   GLshort -> GLshort -> GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glVertex4s" glVertex4s ::
-   GLshort -> GLshort -> GLshort -> GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glVertex2sv" glVertex2sv ::
-   Ptr GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glVertex3sv" glVertex3sv ::
-   Ptr GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glVertex4sv" glVertex4sv ::
-   Ptr GLshort -> IO ()
-
-instance VertexComponent GLshort_ where
+-- GLshort instance
+instance VertexComponent CShort where
    vertex2 = glVertex2s
    vertex3 = glVertex3s
    vertex4 = glVertex4s
@@ -136,27 +127,8 @@
    vertex3v = glVertex3sv
    vertex4v = glVertex4sv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glVertex2i" glVertex2i ::
-   GLint -> GLint -> IO ()
-
-foreign import CALLCONV unsafe "glVertex3i" glVertex3i ::
-   GLint -> GLint -> GLint -> IO ()
-
-foreign import CALLCONV unsafe "glVertex4i" glVertex4i ::
-   GLint -> GLint -> GLint -> GLint -> IO ()
-
-foreign import CALLCONV unsafe "glVertex2iv" glVertex2iv ::
-   Ptr GLint -> IO ()
-
-foreign import CALLCONV unsafe "glVertex3iv" glVertex3iv ::
-   Ptr GLint -> IO ()
-
-foreign import CALLCONV unsafe "glVertex4iv" glVertex4iv ::
-   Ptr GLint -> IO ()
-
-instance VertexComponent GLint_ where
+-- GLint instance
+instance VertexComponent CInt where
    vertex2 = glVertex2i
    vertex3 = glVertex3i
    vertex4 = glVertex4i
@@ -165,27 +137,8 @@
    vertex3v = glVertex3iv
    vertex4v = glVertex4iv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glVertex2f" glVertex2f ::
-   GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glVertex3f" glVertex3f ::
-   GLfloat -> GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glVertex4f" glVertex4f ::
-   GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glVertex2fv" glVertex2fv ::
-   Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glVertex3fv" glVertex3fv ::
-   Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glVertex4fv" glVertex4fv ::
-   Ptr GLfloat -> IO ()
-
-instance VertexComponent GLfloat_ where
+-- GLfloat instance
+instance VertexComponent CFloat where
    vertex2 = glVertex2f
    vertex3 = glVertex3f
    vertex4 = glVertex4f
@@ -194,27 +147,8 @@
    vertex3v = glVertex3fv
    vertex4v = glVertex4fv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glVertex2d" glVertex2d ::
-   GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glVertex3d" glVertex3d ::
-   GLdouble -> GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glVertex4d" glVertex4d ::
-   GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glVertex2dv" glVertex2dv ::
-   Ptr GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glVertex3dv" glVertex3dv ::
-   Ptr GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glVertex4dv" glVertex4dv ::
-   Ptr GLdouble -> IO ()
-
-instance VertexComponent GLdouble_ where
+-- GLdouble instance
+instance VertexComponent CDouble where
    vertex2 = glVertex2d
    vertex3 = glVertex3d
    vertex4 = glVertex4d
@@ -302,43 +236,8 @@
    multiTexCoord3v :: GLenum -> Ptr a -> IO ()
    multiTexCoord4v :: GLenum -> Ptr a -> IO ()
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glTexCoord1s" glTexCoord1s ::
-   GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord2s" glTexCoord2s ::
-   GLshort -> GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord3s" glTexCoord3s ::
-   GLshort -> GLshort -> GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord4s" glTexCoord4s ::
-   GLshort -> GLshort -> GLshort -> GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord1sv" glTexCoord1sv ::
-   Ptr GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord2sv" glTexCoord2sv ::
-   Ptr GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord3sv" glTexCoord3sv ::
-   Ptr GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord4sv" glTexCoord4sv ::
-   Ptr GLshort -> IO ()
-
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord1sARB,GLenum -> GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord2sARB,GLenum -> GLshort -> GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord3sARB,GLenum -> GLshort -> GLshort -> GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord4sARB,GLenum -> GLshort -> GLshort -> GLshort -> GLshort -> IO ())
-
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord1svARB,GLenum -> Ptr GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord2svARB,GLenum -> Ptr GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord3svARB,GLenum -> Ptr GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord4svARB,GLenum -> Ptr GLshort -> IO ())
-
-instance TexCoordComponent GLshort_ where
+-- GLshort instance
+instance TexCoordComponent CShort where
    texCoord1 = glTexCoord1s
    texCoord2 = glTexCoord2s
    texCoord3 = glTexCoord3s
@@ -349,53 +248,18 @@
    texCoord3v = glTexCoord3sv
    texCoord4v = glTexCoord4sv
 
-   multiTexCoord1 = glMultiTexCoord1sARB
-   multiTexCoord2 = glMultiTexCoord2sARB
-   multiTexCoord3 = glMultiTexCoord3sARB
-   multiTexCoord4 = glMultiTexCoord4sARB
-
-   multiTexCoord1v = glMultiTexCoord1svARB
-   multiTexCoord2v = glMultiTexCoord2svARB
-   multiTexCoord3v = glMultiTexCoord3svARB
-   multiTexCoord4v = glMultiTexCoord4svARB
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glTexCoord1i" glTexCoord1i ::
-   GLint -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord2i" glTexCoord2i ::
-   GLint -> GLint -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord3i" glTexCoord3i ::
-   GLint -> GLint -> GLint -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord4i" glTexCoord4i ::
-   GLint -> GLint -> GLint -> GLint -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord1iv" glTexCoord1iv ::
-   Ptr GLint -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord2iv" glTexCoord2iv ::
-   Ptr GLint -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord3iv" glTexCoord3iv ::
-   Ptr GLint -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord4iv" glTexCoord4iv ::
-   Ptr GLint -> IO ()
-
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord1iARB,GLenum -> GLint -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord2iARB,GLenum -> GLint -> GLint -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord3iARB,GLenum -> GLint -> GLint -> GLint -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord4iARB,GLenum -> GLint -> GLint -> GLint -> GLint -> IO ())
+   multiTexCoord1 = glMultiTexCoord1s
+   multiTexCoord2 = glMultiTexCoord2s
+   multiTexCoord3 = glMultiTexCoord3s
+   multiTexCoord4 = glMultiTexCoord4s
 
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord1ivARB,GLenum -> Ptr GLint -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord2ivARB,GLenum -> Ptr GLint -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord3ivARB,GLenum -> Ptr GLint -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord4ivARB,GLenum -> Ptr GLint -> IO ())
+   multiTexCoord1v = glMultiTexCoord1sv
+   multiTexCoord2v = glMultiTexCoord2sv
+   multiTexCoord3v = glMultiTexCoord3sv
+   multiTexCoord4v = glMultiTexCoord4sv
 
-instance TexCoordComponent GLint_ where
+-- GLint instance
+instance TexCoordComponent CInt where
    texCoord1 = glTexCoord1i
    texCoord2 = glTexCoord2i
    texCoord3 = glTexCoord3i
@@ -406,53 +270,18 @@
    texCoord3v = glTexCoord3iv
    texCoord4v = glTexCoord4iv
 
-   multiTexCoord1 = glMultiTexCoord1iARB
-   multiTexCoord2 = glMultiTexCoord2iARB
-   multiTexCoord3 = glMultiTexCoord3iARB
-   multiTexCoord4 = glMultiTexCoord4iARB
-
-   multiTexCoord1v = glMultiTexCoord1ivARB
-   multiTexCoord2v = glMultiTexCoord2ivARB
-   multiTexCoord3v = glMultiTexCoord3ivARB
-   multiTexCoord4v = glMultiTexCoord4ivARB
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glTexCoord1f" glTexCoord1f ::
-   GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord2f" glTexCoord2f ::
-   GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord3f" glTexCoord3f ::
-   GLfloat -> GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord4f" glTexCoord4f ::
-   GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord1fv" glTexCoord1fv ::
-   Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord2fv" glTexCoord2fv ::
-   Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord3fv" glTexCoord3fv ::
-   Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord4fv" glTexCoord4fv ::
-   Ptr GLfloat -> IO ()
-
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord1fARB,GLenum -> GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord2fARB,GLenum -> GLfloat -> GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord3fARB,GLenum -> GLfloat -> GLfloat -> GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord4fARB,GLenum -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ())
+   multiTexCoord1 = glMultiTexCoord1i
+   multiTexCoord2 = glMultiTexCoord2i
+   multiTexCoord3 = glMultiTexCoord3i
+   multiTexCoord4 = glMultiTexCoord4i
 
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord1fvARB,GLenum -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord2fvARB,GLenum -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord3fvARB,GLenum -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord4fvARB,GLenum -> Ptr GLfloat -> IO ())
+   multiTexCoord1v = glMultiTexCoord1iv
+   multiTexCoord2v = glMultiTexCoord2iv
+   multiTexCoord3v = glMultiTexCoord3iv
+   multiTexCoord4v = glMultiTexCoord4iv
 
-instance TexCoordComponent GLfloat_ where
+-- GLfloat instance
+instance TexCoordComponent CFloat where
    texCoord1 = glTexCoord1f
    texCoord2 = glTexCoord2f
    texCoord3 = glTexCoord3f
@@ -463,53 +292,18 @@
    texCoord3v = glTexCoord3fv
    texCoord4v = glTexCoord4fv
 
-   multiTexCoord1 = glMultiTexCoord1fARB
-   multiTexCoord2 = glMultiTexCoord2fARB
-   multiTexCoord3 = glMultiTexCoord3fARB
-   multiTexCoord4 = glMultiTexCoord4fARB
-
-   multiTexCoord1v = glMultiTexCoord1fvARB
-   multiTexCoord2v = glMultiTexCoord2fvARB
-   multiTexCoord3v = glMultiTexCoord3fvARB
-   multiTexCoord4v = glMultiTexCoord4fvARB
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glTexCoord1d" glTexCoord1d ::
-   GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord2d" glTexCoord2d ::
-   GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord3d" glTexCoord3d ::
-   GLdouble -> GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord4d" glTexCoord4d ::
-   GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord1dv" glTexCoord1dv ::
-   Ptr GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord2dv" glTexCoord2dv ::
-   Ptr GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord3dv" glTexCoord3dv ::
-   Ptr GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glTexCoord4dv" glTexCoord4dv ::
-   Ptr GLdouble -> IO ()
-
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord1dARB,GLenum -> GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord2dARB,GLenum -> GLdouble -> GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord3dARB,GLenum -> GLdouble -> GLdouble -> GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord4dARB,GLenum -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ())
+   multiTexCoord1 = glMultiTexCoord1f
+   multiTexCoord2 = glMultiTexCoord2f
+   multiTexCoord3 = glMultiTexCoord3f
+   multiTexCoord4 = glMultiTexCoord4f
 
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord1dvARB,GLenum -> Ptr GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord2dvARB,GLenum -> Ptr GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord3dvARB,GLenum -> Ptr GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_multitexture or OpenGL 1.3",glMultiTexCoord4dvARB,GLenum -> Ptr GLdouble -> IO ())
+   multiTexCoord1v = glMultiTexCoord1fv
+   multiTexCoord2v = glMultiTexCoord2fv
+   multiTexCoord3v = glMultiTexCoord3fv
+   multiTexCoord4v = glMultiTexCoord4fv
 
-instance TexCoordComponent GLdouble_ where
+-- GLdouble instance
+instance TexCoordComponent CDouble where
    texCoord1 = glTexCoord1d
    texCoord2 = glTexCoord2d
    texCoord3 = glTexCoord3d
@@ -520,15 +314,15 @@
    texCoord3v = glTexCoord3dv
    texCoord4v = glTexCoord4dv
 
-   multiTexCoord1 = glMultiTexCoord1dARB
-   multiTexCoord2 = glMultiTexCoord2dARB
-   multiTexCoord3 = glMultiTexCoord3dARB
-   multiTexCoord4 = glMultiTexCoord4dARB
+   multiTexCoord1 = glMultiTexCoord1d
+   multiTexCoord2 = glMultiTexCoord2d
+   multiTexCoord3 = glMultiTexCoord3d
+   multiTexCoord4 = glMultiTexCoord4d
 
-   multiTexCoord1v = glMultiTexCoord1dvARB
-   multiTexCoord2v = glMultiTexCoord2dvARB
-   multiTexCoord3v = glMultiTexCoord3dvARB
-   multiTexCoord4v = glMultiTexCoord4dvARB
+   multiTexCoord1v = glMultiTexCoord1dv
+   multiTexCoord2v = glMultiTexCoord2dv
+   multiTexCoord3v = glMultiTexCoord3dv
+   multiTexCoord4v = glMultiTexCoord4dv
 
 --------------------------------------------------------------------------------
 
@@ -589,63 +383,28 @@
    normal3 :: a -> a -> a -> IO ()
    normal3v :: Ptr a -> IO ()
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glNormal3b" glNormal3b ::
-   GLbyte -> GLbyte -> GLbyte -> IO ()
-
-foreign import CALLCONV unsafe "glNormal3bv" glNormal3bv ::
-   Ptr GLbyte -> IO ()
-
-instance NormalComponent GLbyte_ where
+-- GLbyte instance
+instance NormalComponent CSChar where
    normal3 = glNormal3b
    normal3v = glNormal3bv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glNormal3s" glNormal3s ::
-   GLshort -> GLshort -> GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glNormal3sv" glNormal3sv ::
-   Ptr GLshort -> IO ()
-
-instance NormalComponent GLshort_ where
+-- GLshort instance
+instance NormalComponent CShort where
    normal3 = glNormal3s
    normal3v = glNormal3sv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glNormal3i" glNormal3i ::
-   GLint -> GLint -> GLint -> IO ()
-
-foreign import CALLCONV unsafe "glNormal3iv" glNormal3iv ::
-   Ptr GLint -> IO ()
-
-instance NormalComponent GLint_ where
+-- GLint instance
+instance NormalComponent CInt where
    normal3 = glNormal3i
    normal3v = glNormal3iv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glNormal3f" glNormal3f ::
-   GLfloat -> GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glNormal3fv" glNormal3fv ::
-   Ptr GLfloat -> IO ()
-
-instance NormalComponent GLfloat_ where
+-- GLfloat instance
+instance NormalComponent CFloat where
    normal3 = glNormal3f
    normal3v = glNormal3fv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glNormal3d" glNormal3d ::
-   GLdouble -> GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glNormal3dv" glNormal3dv ::
-   Ptr GLdouble -> IO ()
-
-instance NormalComponent GLdouble_ where
+-- GLdouble instance
+instance NormalComponent CDouble where
    normal3 = glNormal3d
    normal3v = glNormal3dv
 
@@ -691,23 +450,15 @@
    fogCoord1 :: a -> IO ()
    fogCoord1v :: Ptr a -> IO ()
 
---------------------------------------------------------------------------------
-
-EXTENSION_ENTRY("GL_EXT_fog_coord or OpenGL 1.4",glFogCoordfEXT,GLfloat -> IO ())
-EXTENSION_ENTRY("GL_EXT_fog_coord or OpenGL 1.4",glFogCoordfvEXT,Ptr GLfloat -> IO ())
-
-instance FogCoordComponent GLfloat_ where
-   fogCoord1 = glFogCoordfEXT
-   fogCoord1v = glFogCoordfvEXT
-
---------------------------------------------------------------------------------
-
-EXTENSION_ENTRY("GL_EXT_fog_coord or OpenGL 1.4",glFogCoorddEXT,GLdouble -> IO ())
-EXTENSION_ENTRY("GL_EXT_fog_coord or OpenGL 1.4",glFogCoorddvEXT,Ptr GLdouble -> IO ())
+-- GLfloat instance
+instance FogCoordComponent CFloat where
+   fogCoord1 = glFogCoordf
+   fogCoord1v = glFogCoordfv
 
-instance FogCoordComponent GLdouble_ where
-   fogCoord1 = glFogCoorddEXT
-   fogCoord1v = glFogCoorddvEXT
+-- GLdouble instance
+instance FogCoordComponent CDouble where
+   fogCoord1 = glFogCoordd
+   fogCoord1v = glFogCoorddv
 
 --------------------------------------------------------------------------------
 
@@ -764,222 +515,93 @@
    secondaryColor3  :: a -> a -> a -> IO ()
    secondaryColor3v :: Ptr a -> IO ()
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glColor3b" glColor3b ::
-   GLbyte -> GLbyte -> GLbyte -> IO ()
-
-foreign import CALLCONV unsafe "glColor4b" glColor4b ::
-   GLbyte -> GLbyte -> GLbyte -> GLbyte -> IO ()
-
-foreign import CALLCONV unsafe "glColor3bv" glColor3bv ::
-   Ptr GLbyte -> IO ()
-
-foreign import CALLCONV unsafe "glColor4bv" glColor4bv ::
-   Ptr GLbyte -> IO ()
-
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3bEXT,GLbyte -> GLbyte -> GLbyte -> IO ())
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3bvEXT,Ptr GLbyte -> IO ())
-
-instance ColorComponent GLbyte_ where
+-- GLbyte instance
+instance ColorComponent CSChar where
    color3 = glColor3b
    color4 = glColor4b
 
    color3v = glColor3bv
    color4v = glColor4bv
 
-   secondaryColor3 = glSecondaryColor3bEXT
-   secondaryColor3v = glSecondaryColor3bvEXT
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glColor3s" glColor3s ::
-   GLshort -> GLshort -> GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glColor4s" glColor4s ::
-   GLshort -> GLshort -> GLshort -> GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glColor3sv" glColor3sv ::
-   Ptr GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glColor4sv" glColor4sv ::
-   Ptr GLshort -> IO ()
-
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3sEXT,GLshort -> GLshort -> GLshort -> IO ())
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3svEXT,Ptr GLshort -> IO ())
+   secondaryColor3 = glSecondaryColor3b
+   secondaryColor3v = glSecondaryColor3bv
 
-instance ColorComponent GLshort_ where
+-- GLshort instance
+instance ColorComponent CShort where
    color3 = glColor3s
    color4 = glColor4s
 
    color3v = glColor3sv
    color4v = glColor4sv
 
-   secondaryColor3 = glSecondaryColor3sEXT
-   secondaryColor3v = glSecondaryColor3svEXT
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glColor3i" glColor3i ::
-   GLint -> GLint -> GLint -> IO ()
-
-foreign import CALLCONV unsafe "glColor4i" glColor4i ::
-   GLint -> GLint -> GLint -> GLint -> IO ()
-
-foreign import CALLCONV unsafe "glColor3iv" glColor3iv ::
-   Ptr GLint -> IO ()
-
-foreign import CALLCONV unsafe "glColor4iv" glColor4iv ::
-   Ptr GLint -> IO ()
-
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3iEXT,GLint -> GLint -> GLint -> IO ())
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3ivEXT,Ptr GLint -> IO ())
+   secondaryColor3 = glSecondaryColor3s
+   secondaryColor3v = glSecondaryColor3sv
 
-instance ColorComponent GLint_ where
+-- GLint instance
+instance ColorComponent CInt where
    color3 = glColor3i
    color4 = glColor4i
 
    color3v = glColor3iv
    color4v = glColor4iv
 
-   secondaryColor3 = glSecondaryColor3iEXT
-   secondaryColor3v = glSecondaryColor3ivEXT
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glColor3f" glColor3f ::
-   GLfloat -> GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glColor4f" glColor4f ::
-   GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glColor3fv" glColor3fv ::
-   Ptr GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glColor4fv" glColor4fv ::
-   Ptr GLfloat -> IO ()
-
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3fEXT,GLfloat -> GLfloat -> GLfloat -> IO ())
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3fvEXT,Ptr GLfloat -> IO ())
+   secondaryColor3 = glSecondaryColor3i
+   secondaryColor3v = glSecondaryColor3iv
 
-instance ColorComponent GLfloat_ where
+-- GLfloat instance
+instance ColorComponent CFloat where
    color3 = glColor3f
    color4 = glColor4f
 
    color3v = glColor3fv
    color4v = glColor4fv
 
-   secondaryColor3 = glSecondaryColor3fEXT
-   secondaryColor3v = glSecondaryColor3fvEXT
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glColor3d" glColor3d ::
-   GLdouble -> GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glColor4d" glColor4d ::
-   GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glColor3dv" glColor3dv ::
-   Ptr GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glColor4dv" glColor4dv ::
-   Ptr GLdouble -> IO ()
-
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3dEXT,GLdouble -> GLdouble -> GLdouble -> IO ())
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3dvEXT,Ptr GLdouble -> IO ())
+   secondaryColor3 = glSecondaryColor3f
+   secondaryColor3v = glSecondaryColor3fv
 
-instance ColorComponent GLdouble_ where
+-- GLdouble instance
+instance ColorComponent CDouble where
    color3 = glColor3d
    color4 = glColor4d
 
    color3v = glColor3dv
    color4v = glColor4dv
 
-   secondaryColor3 = glSecondaryColor3dEXT
-   secondaryColor3v = glSecondaryColor3dvEXT
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glColor3ub" glColor3ub ::
-   GLubyte -> GLubyte -> GLubyte -> IO ()
-
-foreign import CALLCONV unsafe "glColor4ub" glColor4ub ::
-   GLubyte -> GLubyte -> GLubyte -> GLubyte -> IO ()
-
-
-foreign import CALLCONV unsafe "glColor3ubv" glColor3ubv ::
-   Ptr GLubyte -> IO ()
-
-foreign import CALLCONV unsafe "glColor4ubv" glColor4ubv ::
-   Ptr GLubyte -> IO ()
-
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3ubEXT,GLubyte -> GLubyte -> GLubyte -> IO ())
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3ubvEXT,Ptr GLubyte -> IO ())
+   secondaryColor3 = glSecondaryColor3d
+   secondaryColor3v = glSecondaryColor3dv
 
-instance ColorComponent GLubyte_ where
+-- GLubyte instance
+instance ColorComponent CUChar where
    color3 = glColor3ub
    color4 = glColor4ub
 
    color3v = glColor3ubv
    color4v = glColor4ubv
 
-   secondaryColor3 = glSecondaryColor3ubEXT
-   secondaryColor3v = glSecondaryColor3ubvEXT
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glColor3us" glColor3us ::
-   GLushort -> GLushort -> GLushort -> IO ()
-
-foreign import CALLCONV unsafe "glColor4us" glColor4us ::
-   GLushort -> GLushort -> GLushort -> GLushort -> IO ()
-
-foreign import CALLCONV unsafe "glColor3usv" glColor3usv ::
-   Ptr GLushort -> IO ()
-
-foreign import CALLCONV unsafe "glColor4usv" glColor4usv ::
-   Ptr GLushort -> IO ()
-
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3usEXT,GLushort -> GLushort -> GLushort -> IO ())
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3usvEXT,Ptr GLushort -> IO ())
+   secondaryColor3 = glSecondaryColor3ub
+   secondaryColor3v = glSecondaryColor3ubv
 
-instance ColorComponent GLushort_ where
+-- GLushort instance
+instance ColorComponent CUShort where
    color3 = glColor3us
    color4 = glColor4us
 
    color3v = glColor3usv
    color4v = glColor4usv
 
-   secondaryColor3 = glSecondaryColor3usEXT
-   secondaryColor3v = glSecondaryColor3usvEXT
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glColor3ui" glColor3ui ::
-   GLuint -> GLuint -> GLuint -> IO ()
-
-foreign import CALLCONV unsafe "glColor4ui" glColor4ui ::
-   GLuint -> GLuint -> GLuint -> GLuint -> IO ()
-
-foreign import CALLCONV unsafe "glColor3uiv" glColor3uiv ::
-   Ptr GLuint -> IO ()
-
-foreign import CALLCONV unsafe "glColor4uiv" glColor4uiv ::
-   Ptr GLuint -> IO ()
-
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3uiEXT,GLuint -> GLuint -> GLuint -> IO ())
-EXTENSION_ENTRY("GL_EXT_secondary_color or OpenGL 1.4",glSecondaryColor3uivEXT,Ptr GLuint -> IO ())
+   secondaryColor3 = glSecondaryColor3us
+   secondaryColor3v = glSecondaryColor3usv
 
-instance ColorComponent GLuint_ where
+-- GLuint instance
+instance ColorComponent CUInt where
    color3 = glColor3ui
    color4 = glColor4ui
 
    color3v = glColor3uiv
    color4v = glColor4uiv
 
-   secondaryColor3 = glSecondaryColor3uiEXT
-   secondaryColor3v = glSecondaryColor3uivEXT
+   secondaryColor3 = glSecondaryColor3ui
+   secondaryColor3v = glSecondaryColor3uiv
 
 --------------------------------------------------------------------------------
 
@@ -1025,63 +647,28 @@
    index1 :: a -> IO ()
    index1v :: Ptr a -> IO ()
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glIndexs" glIndexs ::
-   GLshort -> IO ()
-
-foreign import CALLCONV unsafe "glIndexsv" glIndexsv ::
-   Ptr GLshort -> IO ()
-
-instance IndexComponent GLshort_ where
+-- GLshort instance
+instance IndexComponent CShort where
    index1 = glIndexs
    index1v = glIndexsv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glIndexi" glIndexi ::
-   GLint -> IO ()
-
-foreign import CALLCONV unsafe "glIndexiv" glIndexiv ::
-   Ptr GLint -> IO ()
-
-instance IndexComponent GLint_ where
+-- GLint instance
+instance IndexComponent CInt where
    index1 = glIndexi
    index1v = glIndexiv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glIndexf" glIndexf ::
-   GLfloat -> IO ()
-
-foreign import CALLCONV unsafe "glIndexfv" glIndexfv ::
-   Ptr GLfloat -> IO ()
-
-instance IndexComponent GLfloat_ where
+-- GLfloat instance
+instance IndexComponent CFloat where
    index1 = glIndexf
    index1v = glIndexfv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glIndexd" glIndexd ::
-   GLdouble -> IO ()
-
-foreign import CALLCONV unsafe "glIndexdv" glIndexdv ::
-   Ptr GLdouble -> IO ()
-
-instance IndexComponent GLdouble_ where
+-- GLdouble instance
+instance IndexComponent CDouble where
    index1 = glIndexd
    index1v = glIndexdv
 
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "glIndexub" glIndexub ::
-   GLubyte -> IO ()
-
-foreign import CALLCONV unsafe "glIndexubv" glIndexubv ::
-   Ptr GLubyte -> IO ()
-
-instance IndexComponent GLubyte_ where
+-- GLubyte instance
+instance IndexComponent CUChar where
    index1 = glIndexub
    index1v = glIndexubv
 
@@ -1197,156 +784,84 @@
    vertexAttrib2Iv location = peek2M $ vertexAttrib2I location
    vertexAttrib3Iv location = peek3M $ vertexAttrib3I location
 
---------------------------------------------------------------------------------
-
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4bvARB,AttribLocation -> Ptr GLbyte -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NbvARB,AttribLocation -> Ptr GLbyte -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4bv,AttribLocation -> Ptr GLbyte -> IO ())
-
-instance VertexAttribComponent GLbyte_ where
-   vertexAttrib4v = glVertexAttrib4bvARB
-   vertexAttrib4Nv = glVertexAttrib4NbvARB
-   vertexAttrib4Iv = glVertexAttribI4bv
-
---------------------------------------------------------------------------------
-
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NubARB,AttribLocation -> GLubyte -> GLubyte -> GLubyte -> GLubyte -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4ubvARB,AttribLocation -> Ptr GLubyte -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NubvARB,AttribLocation -> Ptr GLubyte -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4ubv,AttribLocation -> Ptr GLubyte -> IO ())
-
-instance VertexAttribComponent GLubyte_ where
-   vertexAttrib4N = glVertexAttrib4NubARB
-   vertexAttrib4v = glVertexAttrib4ubvARB
-   vertexAttrib4Nv = glVertexAttrib4NubvARB
-   vertexAttrib4Iv = glVertexAttribI4ubv
-
---------------------------------------------------------------------------------
-
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib1sARB,AttribLocation -> GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib2sARB,AttribLocation -> GLshort -> GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib3sARB,AttribLocation -> GLshort -> GLshort -> GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4sARB,AttribLocation -> GLshort -> GLshort -> GLshort -> GLshort -> IO ())
-
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib1svARB,AttribLocation -> Ptr GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib2svARB,AttribLocation -> Ptr GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib3svARB,AttribLocation -> Ptr GLshort -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4svARB,AttribLocation -> Ptr GLshort -> IO ())
-
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NsvARB,AttribLocation -> Ptr GLshort -> IO ())
-
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4sv,AttribLocation -> Ptr GLshort -> IO ())
-
-instance VertexAttribComponent GLshort_ where
-   vertexAttrib1 = glVertexAttrib1sARB
-   vertexAttrib2 = glVertexAttrib2sARB
-   vertexAttrib3 = glVertexAttrib3sARB
-   vertexAttrib4 = glVertexAttrib4sARB
-
-   vertexAttrib1v = glVertexAttrib1svARB
-   vertexAttrib2v = glVertexAttrib2svARB
-   vertexAttrib3v = glVertexAttrib3svARB
-   vertexAttrib4v = glVertexAttrib4svARB
-
-   vertexAttrib4Nv = glVertexAttrib4NsvARB
-
-   vertexAttrib4Iv = glVertexAttribI4sv
-
---------------------------------------------------------------------------------
-
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4usvARB,AttribLocation -> Ptr GLushort -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NusvARB,AttribLocation -> Ptr GLushort -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4usv,AttribLocation -> Ptr GLushort -> IO ())
-
-instance VertexAttribComponent GLushort_ where
-   vertexAttrib4v = glVertexAttrib4usvARB
-   vertexAttrib4Nv = glVertexAttrib4NusvARB
-   vertexAttrib4Iv = glVertexAttribI4usv
-
---------------------------------------------------------------------------------
-
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI1i,AttribLocation -> GLint -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI2i,AttribLocation -> GLint -> GLint -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI3i,AttribLocation -> GLint -> GLint -> GLint -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4i,AttribLocation -> GLint -> GLint -> GLint -> GLint -> IO ())
-
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4ivARB,AttribLocation -> Ptr GLint -> IO ())
-
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NivARB,AttribLocation -> Ptr GLint -> IO ())
-
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI1iv,AttribLocation -> Ptr GLint -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI2iv,AttribLocation -> Ptr GLint -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI3iv,AttribLocation -> Ptr GLint -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4iv,AttribLocation -> Ptr GLint -> IO ())
-
-instance VertexAttribComponent GLint_ where
-   vertexAttrib1I = glVertexAttribI1i
-   vertexAttrib2I = glVertexAttribI2i
-   vertexAttrib3I = glVertexAttribI3i
-   vertexAttrib4I = glVertexAttribI4i
-
-   vertexAttrib4v = glVertexAttrib4ivARB
+-- GLbyte instance
+instance VertexAttribComponent CSChar where
+   vertexAttrib4v (AttribLocation al) = glVertexAttrib4bv al
+   vertexAttrib4Nv (AttribLocation al) = glVertexAttrib4Nbv al
+   vertexAttrib4Iv (AttribLocation al) = glVertexAttribI4bv al
 
-   vertexAttrib4Nv = glVertexAttrib4NivARB
+-- GLubyte instance
+instance VertexAttribComponent CUChar where
+   vertexAttrib4N (AttribLocation al) = glVertexAttrib4Nub al
+   vertexAttrib4v (AttribLocation al) = glVertexAttrib4ubv al
+   vertexAttrib4Nv (AttribLocation al) = glVertexAttrib4Nubv al
+   vertexAttrib4Iv (AttribLocation al) = glVertexAttribI4ubv al
 
-   vertexAttrib1Iv = glVertexAttribI1iv
-   vertexAttrib2Iv = glVertexAttribI2iv
-   vertexAttrib3Iv = glVertexAttribI3iv
-   vertexAttrib4Iv = glVertexAttribI4iv
+-- GLshort instance
+instance VertexAttribComponent CShort where
+   vertexAttrib1 (AttribLocation al) = glVertexAttrib1s al
+   vertexAttrib2 (AttribLocation al) = glVertexAttrib2s al
+   vertexAttrib3 (AttribLocation al) = glVertexAttrib3s al
+   vertexAttrib4 (AttribLocation al) = glVertexAttrib4s al
 
---------------------------------------------------------------------------------
+   vertexAttrib1v (AttribLocation al) = glVertexAttrib1sv al
+   vertexAttrib2v (AttribLocation al) = glVertexAttrib2sv al
+   vertexAttrib3v (AttribLocation al) = glVertexAttrib3sv al
+   vertexAttrib4v (AttribLocation al) = glVertexAttrib4sv al
 
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI1ui,AttribLocation -> GLuint -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI2ui,AttribLocation -> GLuint -> GLuint -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI3ui,AttribLocation -> GLuint -> GLuint -> GLuint -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4ui,AttribLocation -> GLuint -> GLuint -> GLuint -> GLuint -> IO ())
+   vertexAttrib4Nv (AttribLocation al) = glVertexAttrib4Nsv al
 
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4uivARB,AttribLocation -> Ptr GLuint -> IO ())
+   vertexAttrib4Iv (AttribLocation al) = glVertexAttribI4sv al
 
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NuivARB,AttribLocation -> Ptr GLuint -> IO ())
+-- GLushort instance
+instance VertexAttribComponent CUShort where
+   vertexAttrib4v (AttribLocation al) = glVertexAttrib4usv al
+   vertexAttrib4Nv (AttribLocation al) = glVertexAttrib4Nusv al
+   vertexAttrib4Iv (AttribLocation al) = glVertexAttribI4usv al
 
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI1uiv,AttribLocation -> Ptr GLuint -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI2uiv,AttribLocation -> Ptr GLuint -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI3uiv,AttribLocation -> Ptr GLuint -> IO ())
-EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4uiv,AttribLocation -> Ptr GLuint -> IO ())
+-- GLint instance
+instance VertexAttribComponent CInt where
+   vertexAttrib1I (AttribLocation al) = glVertexAttribI1i al
+   vertexAttrib2I (AttribLocation al) = glVertexAttribI2i al
+   vertexAttrib3I (AttribLocation al) = glVertexAttribI3i al
+   vertexAttrib4I (AttribLocation al) = glVertexAttribI4i al
 
-instance VertexAttribComponent GLuint_ where
-   vertexAttrib1I = glVertexAttribI1ui
-   vertexAttrib2I = glVertexAttribI2ui
-   vertexAttrib3I = glVertexAttribI3ui
-   vertexAttrib4I = glVertexAttribI4ui
+   vertexAttrib4v (AttribLocation al) = glVertexAttrib4iv al
 
-   vertexAttrib4v = glVertexAttrib4uivARB
+   vertexAttrib4Nv (AttribLocation al) = glVertexAttrib4Niv al
 
-   vertexAttrib4Nv = glVertexAttrib4NuivARB
+   vertexAttrib1Iv (AttribLocation al) = glVertexAttribI1iv al
+   vertexAttrib2Iv (AttribLocation al) = glVertexAttribI2iv al
+   vertexAttrib3Iv (AttribLocation al) = glVertexAttribI3iv al
+   vertexAttrib4Iv (AttribLocation al) = glVertexAttribI4iv al
 
-   vertexAttrib1Iv = glVertexAttribI1uiv
-   vertexAttrib2Iv = glVertexAttribI2uiv
-   vertexAttrib3Iv = glVertexAttribI3uiv
-   vertexAttrib4Iv = glVertexAttribI4uiv
+-- GLuint instance
+instance VertexAttribComponent CUInt where
+   vertexAttrib1I (AttribLocation al) = glVertexAttribI1ui al
+   vertexAttrib2I (AttribLocation al) = glVertexAttribI2ui al
+   vertexAttrib3I (AttribLocation al) = glVertexAttribI3ui al
+   vertexAttrib4I (AttribLocation al) = glVertexAttribI4ui al
 
---------------------------------------------------------------------------------
+   vertexAttrib4v (AttribLocation al) = glVertexAttrib4uiv al
 
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib1fARB,AttribLocation -> GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib2fARB,AttribLocation -> GLfloat -> GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib3fARB,AttribLocation -> GLfloat -> GLfloat -> GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4fARB,AttribLocation -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ())
+   vertexAttrib4Nv (AttribLocation al) = glVertexAttrib4Nuiv al
 
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib1fvARB,AttribLocation -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib2fvARB,AttribLocation -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib3fvARB,AttribLocation -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4fvARB,AttribLocation -> Ptr GLfloat -> IO ())
+   vertexAttrib1Iv (AttribLocation al) = glVertexAttribI1uiv al
+   vertexAttrib2Iv (AttribLocation al) = glVertexAttribI2uiv al
+   vertexAttrib3Iv (AttribLocation al) = glVertexAttribI3uiv al
+   vertexAttrib4Iv (AttribLocation al) = glVertexAttribI4uiv al
 
-instance VertexAttribComponent GLfloat_ where
-   vertexAttrib1 = glVertexAttrib1fARB
-   vertexAttrib2 = glVertexAttrib2fARB
-   vertexAttrib3 = glVertexAttrib3fARB
-   vertexAttrib4 = glVertexAttrib4fARB
+-- GLfloat instance
+instance VertexAttribComponent CFloat where
+   vertexAttrib1 (AttribLocation al) = glVertexAttrib1f al
+   vertexAttrib2 (AttribLocation al) = glVertexAttrib2f al
+   vertexAttrib3 (AttribLocation al) = glVertexAttrib3f al
+   vertexAttrib4 (AttribLocation al) = glVertexAttrib4f al
 
-   vertexAttrib1v = glVertexAttrib1fvARB
-   vertexAttrib2v = glVertexAttrib2fvARB
-   vertexAttrib3v = glVertexAttrib3fvARB
-   vertexAttrib4v = glVertexAttrib4fvARB
+   vertexAttrib1v (AttribLocation al) = glVertexAttrib1fv al
+   vertexAttrib2v (AttribLocation al) = glVertexAttrib2fv al
+   vertexAttrib3v (AttribLocation al) = glVertexAttrib3fv al
+   vertexAttrib4v (AttribLocation al) = glVertexAttrib4fv al
 
    vertexAttrib4Nv = vertexAttrib4v
 
@@ -1361,28 +876,17 @@
 toGLint = truncate . (fromIntegral (maxBound :: GLint) *). clamp
    where clamp = max (-1.0) . min 1.0
 
---------------------------------------------------------------------------------
-
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib1dARB,AttribLocation -> GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib2dARB,AttribLocation -> GLdouble -> GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib3dARB,AttribLocation -> GLdouble -> GLdouble -> GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4dARB,AttribLocation -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ())
-
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib1dvARB,AttribLocation -> Ptr GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib2dvARB,AttribLocation -> Ptr GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib3dvARB,AttribLocation -> Ptr GLdouble -> IO ())
-EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4dvARB,AttribLocation -> Ptr GLdouble -> IO ())
-
-instance VertexAttribComponent GLdouble_ where
-   vertexAttrib1 = glVertexAttrib1dARB
-   vertexAttrib2 = glVertexAttrib2dARB
-   vertexAttrib3 = glVertexAttrib3dARB
-   vertexAttrib4 = glVertexAttrib4dARB
+-- GLdouble instance
+instance VertexAttribComponent CDouble where
+   vertexAttrib1 (AttribLocation al) = glVertexAttrib1d al
+   vertexAttrib2 (AttribLocation al) = glVertexAttrib2d al
+   vertexAttrib3 (AttribLocation al) = glVertexAttrib3d al
+   vertexAttrib4 (AttribLocation al) = glVertexAttrib4d al
 
-   vertexAttrib1v = glVertexAttrib1dvARB
-   vertexAttrib2v = glVertexAttrib2dvARB
-   vertexAttrib3v = glVertexAttrib3dvARB
-   vertexAttrib4v = glVertexAttrib4dvARB
+   vertexAttrib1v (AttribLocation al) = glVertexAttrib1dv al
+   vertexAttrib2v (AttribLocation al) = glVertexAttrib2dv al
+   vertexAttrib3v (AttribLocation al) = glVertexAttrib3dv al
+   vertexAttrib4v (AttribLocation al) = glVertexAttrib4dv al
 
    vertexAttrib4Nv = vertexAttrib4v
 
diff --git a/Graphics/Rendering/OpenGL/GLU/Errors.hs b/Graphics/Rendering/OpenGL/GLU/Errors.hs
--- a/Graphics/Rendering/OpenGL/GLU/Errors.hs
+++ b/Graphics/Rendering/OpenGL/GLU/Errors.hs
@@ -18,10 +18,8 @@
    Error(..), ErrorCategory(..), errors
 ) where
 
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal (
-   Error(..), ErrorCategory(..), getErrors )
+import Data.StateVar
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GLU/ErrorsInternal.hs b/Graphics/Rendering/OpenGL/GLU/ErrorsInternal.hs
--- a/Graphics/Rendering/OpenGL/GLU/ErrorsInternal.hs
+++ b/Graphics/Rendering/OpenGL/GLU/ErrorsInternal.hs
@@ -21,78 +21,13 @@
    recordErrorCode, recordInvalidEnum, recordInvalidValue, recordOutOfMemory
 ) where
 
-import Foreign.Ptr ( Ptr, castPtr )
+import Foreign.Ptr ( castPtr )
 import Foreign.C.String ( peekCString )
 import Data.IORef ( IORef, newIORef, readIORef, writeIORef )
 import System.IO.Unsafe ( unsafePerformIO )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLubyte )
-
---------------------------------------------------------------------------------
--- Alas, GL and GLU define error enumerants with the same names, so we have to
--- rename these to avoid name clashes. Ugly, ugly, ugly...
-
-data GL_ErrorCode =
-     GL_NoError
-   | GL_InvalidEnum
-   | GL_InvalidValue
-   | GL_InvalidOperation
-   | GL_InvalidFramebufferOperation
-   | GL_OutOfMemory
-   | GL_StackOverflow
-   | GL_StackUnderflow
-   | GL_TableTooLarge
-
-gl_marshalErrorCode :: GL_ErrorCode -> GLenum
-gl_marshalErrorCode x = case x of
-   GL_NoError -> 0x0
-   GL_InvalidEnum -> 0x500
-   GL_InvalidValue -> 0x501
-   GL_InvalidOperation -> 0x502
-   GL_InvalidFramebufferOperation -> 0x0506
-   GL_OutOfMemory -> 0x505
-   GL_StackOverflow -> 0x503
-   GL_StackUnderflow -> 0x504
-   GL_TableTooLarge -> 0x8031
-
---------------------------------------------------------------------------------
--- See comment above
-
-data GLU_ErrorCode =
-     GLU_InvalidEnum
-   | GLU_InvalidValue
-   | GLU_OutOfMemory
-   | GLU_InvalidOperation
-
-glu_marshalErrorCode :: GLU_ErrorCode -> GLenum
-glu_marshalErrorCode x = case x of
-   GLU_InvalidEnum -> 0x18a24
-   GLU_InvalidValue -> 0x18a25
-   GLU_OutOfMemory -> 0x18a26
-   GLU_InvalidOperation -> 0x18a28
-
---------------------------------------------------------------------------------
-
--- only the errors with the smallest and the largsest enum value
-data NurbsError =
-     NurbsError1
-   | NurbsError37
-
-marshalNurbsError :: NurbsError -> GLenum
-marshalNurbsError x = case x of
-   NurbsError1 -> 0x1879b
-   NurbsError37 -> 0x187bf
-
---------------------------------------------------------------------------------
-
--- only the errors with the smallest and the largsest enum value
-data TessError =
-     TessError1
-   | TessError8
-
-marshalTessError :: TessError -> GLenum
-marshalTessError x = case x of
-   TessError1 -> 0x18737
-   TessError8 -> 0x1873e
+import Graphics.Rendering.GLU.Raw
+import Graphics.Rendering.OpenGL.Raw.ARB.Compatibility
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
@@ -134,50 +69,34 @@
    | otherwise = error "unmarshalErrorCategory"
 
 isInvalidEnum :: GLenum -> Bool
-isInvalidEnum c =
-   c == gl_marshalErrorCode  GL_InvalidEnum ||
-   c == glu_marshalErrorCode GLU_InvalidEnum
+isInvalidEnum c = c == gl_INVALID_ENUM || c == glu_INVALID_ENUM
 
 isInvalidValue :: GLenum -> Bool
-isInvalidValue c =
-   c == gl_marshalErrorCode  GL_InvalidValue ||
-   c == glu_marshalErrorCode GLU_InvalidValue
+isInvalidValue c = c == gl_INVALID_VALUE || c == glu_INVALID_VALUE
 
 isInvalidOperation :: GLenum -> Bool
-isInvalidOperation c =
-   c == gl_marshalErrorCode  GL_InvalidOperation ||
-   c == glu_marshalErrorCode GLU_InvalidOperation
+isInvalidOperation c = c == gl_INVALID_OPERATION || c == glu_INVALID_OPERATION
 
 isInvalidFramebufferOperation :: GLenum -> Bool
-isInvalidFramebufferOperation c =
-   c == gl_marshalErrorCode GL_InvalidFramebufferOperation
+isInvalidFramebufferOperation c = c == gl_INVALID_FRAMEBUFFER_OPERATION
 
 isOutOfMemory :: GLenum -> Bool
-isOutOfMemory c =
-   c == gl_marshalErrorCode  GL_OutOfMemory ||
-   c == glu_marshalErrorCode GLU_OutOfMemory
+isOutOfMemory c = c == gl_OUT_OF_MEMORY || c == glu_OUT_OF_MEMORY
 
 isStackOverflow :: GLenum -> Bool
-isStackOverflow c =
-   c == gl_marshalErrorCode GL_StackOverflow
+isStackOverflow c = c == gl_STACK_OVERFLOW
 
 isStackUnderflow :: GLenum -> Bool
-isStackUnderflow c =
-   c == gl_marshalErrorCode GL_StackUnderflow
+isStackUnderflow c = c == gl_STACK_UNDERFLOW
 
 isTableTooLarge :: GLenum -> Bool
-isTableTooLarge c =
-   c == gl_marshalErrorCode GL_TableTooLarge
+isTableTooLarge c = c == gl_TABLE_TOO_LARGE
 
 isTesselatorError :: GLenum -> Bool
-isTesselatorError c =
-   marshalTessError TessError1 <= c &&
-   c <= marshalTessError TessError8
+isTesselatorError c = glu_TESS_ERROR1 <= c && c <= glu_TESS_ERROR8
 
 isNURBSError :: GLenum -> Bool
-isNURBSError c =
-   marshalNurbsError NurbsError1 <= c &&
-   c <= marshalNurbsError NurbsError37
+isNURBSError c = glu_NURBS_ERROR1 <= c && c <= glu_NURBS_ERROR37
 
 --------------------------------------------------------------------------------
 
@@ -191,9 +110,6 @@
    description <- peekCString (castPtr ptr)
    return $ Error category description
 
-foreign import CALLCONV unsafe "gluErrorString" gluErrorString ::
-   GLenum -> IO (Ptr GLubyte)
-
 --------------------------------------------------------------------------------
 
 -- This seems to be a common Haskell hack nowadays: A plain old global variable
@@ -221,9 +137,7 @@
                else return $ reverse acc
 
 isError :: GLenum -> Bool
-isError = (/= gl_marshalErrorCode GL_NoError)
-
-foreign import CALLCONV unsafe "glGetError" glGetError :: IO GLenum
+isError = (/= gl_NO_ERROR)
 
 --------------------------------------------------------------------------------
 
@@ -238,13 +152,13 @@
    return ()
 
 recordInvalidEnum :: IO ()
-recordInvalidEnum = recordErrorCode (gl_marshalErrorCode GL_InvalidEnum)
+recordInvalidEnum = recordErrorCode gl_INVALID_ENUM
 
 recordInvalidValue :: IO ()
-recordInvalidValue = recordErrorCode (gl_marshalErrorCode GL_InvalidValue)
+recordInvalidValue = recordErrorCode gl_INVALID_VALUE
 
 recordOutOfMemory :: IO ()
-recordOutOfMemory = recordErrorCode (glu_marshalErrorCode GLU_OutOfMemory)
+recordOutOfMemory = recordErrorCode gl_OUT_OF_MEMORY
 
 -- ToDo: Make this thread-safe
 getErrorCodesAux :: ([GLenum] -> ([GLenum],Bool)) -> IO [GLenum]
diff --git a/Graphics/Rendering/OpenGL/GLU/Initialization.hs b/Graphics/Rendering/OpenGL/GLU/Initialization.hs
--- a/Graphics/Rendering/OpenGL/GLU/Initialization.hs
+++ b/Graphics/Rendering/OpenGL/GLU/Initialization.hs
@@ -16,38 +16,21 @@
    gluVersion, gluExtensions
 ) where
 
-import Foreign.Ptr ( Ptr, castPtr )
-import Foreign.C.String ( peekCString )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum, GLubyte )
-import Graphics.Rendering.OpenGL.GL.QueryUtils ( maybeNullPtr )
-import Graphics.Rendering.OpenGL.GL.StateVar (
-   GettableStateVar, makeGettableStateVar )
+import Data.StateVar
+import Foreign.C.String
+import Foreign.Ptr
+import Graphics.Rendering.GLU.Raw
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 
 gluVersion :: GettableStateVar String
-gluVersion = makeGettableStateVar (getString Version)
+gluVersion = makeGettableStateVar (getString glu_VERSION)
 
 gluExtensions :: GettableStateVar [String]
-gluExtensions = makeGettableStateVar (fmap words $ getString Extensions)
-
---------------------------------------------------------------------------------
-
-data StringName =
-     Version
-   | Extensions
-   deriving ( Eq, Ord, Show )
-
-marshalStringName :: StringName -> GLenum
-marshalStringName x = case x of
-   Version -> 0x189c0
-   Extensions -> 0x189c1
-
---------------------------------------------------------------------------------
+gluExtensions = makeGettableStateVar (fmap words $ getString glu_EXTENSIONS)
 
-getString :: StringName -> IO String
-getString n = gluGetString (marshalStringName n) >>=
+getString :: GLenum -> IO String
+getString n = gluGetString n >>=
               maybeNullPtr (return "") (peekCString . castPtr)
-
-foreign import CALLCONV unsafe "gluGetString" gluGetString ::
-   GLenum -> IO (Ptr GLubyte)
diff --git a/Graphics/Rendering/OpenGL/GLU/Matrix.hs b/Graphics/Rendering/OpenGL/GLU/Matrix.hs
--- a/Graphics/Rendering/OpenGL/GLU/Matrix.hs
+++ b/Graphics/Rendering/OpenGL/GLU/Matrix.hs
@@ -17,51 +17,37 @@
    project, unProject, unProject4
 ) where
 
-import Foreign.Marshal.Alloc ( alloca )
-import Foreign.Marshal.Array ( withArray )
-import Foreign.Ptr ( Ptr )
-import Foreign.Storable ( Storable(peek,peekElemOff) )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLint, GLdouble, GLclampd )
-import Graphics.Rendering.OpenGL.GL.CoordTrans (
-   MatrixOrder(..), Matrix(..), MatrixComponent,
-   Vector3(..), Position(..), Size(..) )
-import Graphics.Rendering.OpenGL.GL.Extensions (
-   FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.GLboolean ( unmarshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.VertexSpec ( Vertex3(..), Vertex4(..) )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal ( recordInvalidValue )
-
---------------------------------------------------------------------------------
-
-#include "HsOpenGLExt.h"
+import Data.Tensor
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Array
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.GLU.Raw
+import Graphics.Rendering.OpenGL.GL.CoordTrans
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+import Graphics.Rendering.OpenGL.Raw.Core31
 
 --------------------------------------------------------------------------------
 -- matrix setup
 
-foreign import CALLCONV unsafe "gluOrtho2D" ortho2D ::
-   GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
+ortho2D :: GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
+ortho2D = gluOrtho2D
 
-foreign import CALLCONV unsafe "gluPerspective" perspective ::
-   GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
 
+perspective :: GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
+perspective = gluPerspective
+
 lookAt :: Vertex3 GLdouble -> Vertex3 GLdouble -> Vector3 GLdouble -> IO ()
 lookAt (Vertex3 eyeX    eyeY    eyeZ)
        (Vertex3 centerX centerY centerZ)
        (Vector3 upX     upY     upZ) =
    gluLookAt eyeX eyeY eyeZ centerX centerY centerZ upX upY upZ
 
-foreign import CALLCONV unsafe "gluLookAt" gluLookAt ::
-      GLdouble -> GLdouble -> GLdouble
-   -> GLdouble -> GLdouble -> GLdouble
-   -> GLdouble -> GLdouble -> GLdouble -> IO ()
-
 pickMatrix ::
    (GLdouble, GLdouble) -> (GLdouble, GLdouble) -> (Position, Size) -> IO ()
-pickMatrix (x, y) (w, h) viewport =
-   withViewport viewport $ gluPickMatrix x y w h
-
-foreign import CALLCONV unsafe "gluPickMatrix" gluPickMatrix ::
-   GLdouble -> GLdouble -> GLdouble -> GLdouble -> Ptr GLint -> IO ()
+pickMatrix (x, y) (w, h) viewPort =
+   withViewport viewPort $ gluPickMatrix x y w h
 
 --------------------------------------------------------------------------------
 -- coordinate projection
@@ -70,45 +56,33 @@
       Matrix m
    => Vertex3 GLdouble -> m GLdouble -> m GLdouble -> (Position, Size)
    -> IO (Vertex3 GLdouble)
-project (Vertex3 objX objY objZ) model proj viewport =
+project (Vertex3 objX objY objZ) model proj viewPort =
    withColumnMajor model $ \modelBuf ->
    withColumnMajor proj $ \projBuf ->
-   withViewport viewport $ \viewBuf ->
+   withViewport viewPort $ \viewBuf ->
    getVertex3 $ gluProject objX objY objZ modelBuf projBuf viewBuf
 
-foreign import CALLCONV unsafe "gluProject" gluProject ::
-      GLdouble -> GLdouble -> GLdouble
-   -> Ptr GLdouble -> Ptr GLdouble -> Ptr GLint
-   -> Ptr GLdouble -> Ptr GLdouble -> Ptr GLdouble -> IO GLint
-
 unProject ::
       Matrix m
    => Vertex3 GLdouble -> m GLdouble -> m GLdouble -> (Position, Size)
    -> IO (Vertex3 GLdouble)
-unProject (Vertex3 objX objY objZ) model proj viewport =
+unProject (Vertex3 objX objY objZ) model proj viewPort =
    withColumnMajor model $ \modelBuf ->
    withColumnMajor proj $ \projBuf ->
-   withViewport viewport $ \viewBuf ->
+   withViewport viewPort $ \viewBuf ->
    getVertex3 $ gluUnProject objX objY objZ modelBuf projBuf viewBuf
 
-foreign import CALLCONV unsafe "gluUnProject" gluUnProject ::
-      GLdouble -> GLdouble -> GLdouble
-   -> Ptr GLdouble -> Ptr GLdouble -> Ptr GLint
-   -> Ptr GLdouble -> Ptr GLdouble -> Ptr GLdouble -> IO GLint
-
 unProject4 ::
       Matrix m
    => Vertex4 GLdouble -> m GLdouble -> m GLdouble -> (Position, Size)
    -> GLclampd -> GLclampd
    -> IO (Vertex4 GLdouble)
-unProject4 (Vertex4 objX objY objZ clipW) model proj viewport near far =
+unProject4 (Vertex4 objX objY objZ clipW) model proj viewPort near far =
    withColumnMajor model $ \modelBuf ->
    withColumnMajor proj $ \projBuf ->
-   withViewport viewport $ \viewBuf ->
+   withViewport viewPort $ \viewBuf ->
    getVertex4 $
       gluUnProject4 objX objY objZ clipW modelBuf projBuf viewBuf near far
-
-EXTENSION_ENTRY("GLU 1.3",gluUnProject4,GLdouble -> GLdouble -> GLdouble -> GLdouble -> Ptr GLdouble -> Ptr GLdouble -> Ptr GLint -> GLclampd -> GLclampd -> Ptr GLdouble -> Ptr GLdouble -> Ptr GLdouble -> Ptr GLdouble -> IO GLint)
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GLU/Mipmapping.hs b/Graphics/Rendering/OpenGL/GLU/Mipmapping.hs
--- a/Graphics/Rendering/OpenGL/GLU/Mipmapping.hs
+++ b/Graphics/Rendering/OpenGL/GLU/Mipmapping.hs
@@ -16,8 +16,8 @@
    scaleImage, build1DMipmaps, build2DMipmaps
 ) where
 
-import Foreign.Ptr ( Ptr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLsizei, GLint, GLenum )
+import Graphics.Rendering.GLU.Raw
+import Graphics.Rendering.OpenGL.Raw.Core31
 import Graphics.Rendering.OpenGL.GL.CoordTrans ( Size(..) )
 import Graphics.Rendering.OpenGL.GL.PixelData ( PixelData, withPixelData )
 import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat (
@@ -34,14 +34,11 @@
    withPixelData pdIn $ \fIn dIn pIn ->
       withPixelData pdOut $ \fOut dOut pOut ->
          if fIn == fOut
-            then gluScaleImage
-                    fIn widthIn heightIn dIn pIn widthOut heightOut dOut pOut
+            then do gluScaleImage
+                      fIn widthIn heightIn dIn pIn widthOut heightOut dOut pOut
+                    return ()   -- TODO: Should we use the return value?
             else recordInvalidValue
 
-foreign import CALLCONV unsafe "gluScaleImage" gluScaleImage ::
-   GLenum -> GLsizei -> GLsizei -> GLenum -> Ptr a
-          -> GLsizei -> GLsizei -> GLenum -> Ptr b -> IO ()
-
 --------------------------------------------------------------------------------
 -- Section 3.2 (Automatic Mipmapping)
 -- Missing for GLU 1.3: gluBuild3DMipmaps, gluBuild{1,2,3}DMipmapLevels
@@ -56,9 +53,6 @@
          height
    return ()   -- TODO: Should we use the return value?
 
-foreign import CALLCONV unsafe "gluBuild1DMipmaps" gluBuild1DMipmaps ::
-      GLenum -> GLint -> GLsizei -> GLenum -> GLenum -> Ptr a -> IO GLint
-
 --------------------------------------------------------------------------------
 
 build2DMipmaps :: TextureTarget -> PixelInternalFormat -> GLsizei -> GLsizei
@@ -70,6 +64,3 @@
          (marshalPixelInternalFormat internalFormat)
          width height
    return ()   -- TODO: Should we use the return value?
-
-foreign import CALLCONV unsafe "gluBuild2DMipmaps" gluBuild2DMipmaps ::
-      GLenum -> GLint -> GLsizei -> GLsizei -> GLenum -> GLenum -> Ptr a -> IO GLint
diff --git a/Graphics/Rendering/OpenGL/GLU/NURBS.hs b/Graphics/Rendering/OpenGL/GLU/NURBS.hs
--- a/Graphics/Rendering/OpenGL/GLU/NURBS.hs
+++ b/Graphics/Rendering/OpenGL/GLU/NURBS.hs
@@ -30,66 +30,33 @@
    DisplayMode'(..), setDisplayMode'
 ) where
 
-import Control.Monad ( unless )
-import Foreign.Marshal.Array ( withArray )
-import Foreign.Ptr ( Ptr, nullPtr, castPtr, FunPtr, freeHaskellFunPtr )
-import Foreign.Storable ( Storable(..) )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLenum, GLint, GLfloat, Capability )
-import Graphics.Rendering.OpenGL.GL.Capability ( marshalCapability )
+import Control.Monad
+import Data.Tensor
+import Foreign.Marshal.Array
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.Rendering.GLU.Raw hiding (
+   NURBSBeginCallback, NURBSVertexCallback, NURBSNormalCallback,
+   NURBSColorCallback, NURBSEndCallback )
+import Graphics.Rendering.OpenGL.Raw.Core31
+import Graphics.Rendering.OpenGL.GL.Capability
 import Graphics.Rendering.OpenGL.GL.ControlPoint
-import Graphics.Rendering.OpenGL.GL.CoordTrans (
-   Position(..), Size(..), MatrixOrder(ColumnMajor), MatrixComponent, Matrix(..) )
-import Graphics.Rendering.OpenGL.GL.Exception ( bracket, bracket_ )
-import Graphics.Rendering.OpenGL.GL.GLboolean ( marshalGLboolean )
-import Graphics.Rendering.OpenGL.GL.PrimitiveMode ( unmarshalPrimitiveMode )
-import Graphics.Rendering.OpenGL.GL.BeginEnd ( PrimitiveMode )
-import Graphics.Rendering.OpenGL.GL.VertexSpec (
-   Vertex2, Vertex3, Normal3, Color4 )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal (
-   recordErrorCode, recordOutOfMemory )
-
---------------------------------------------------------------------------------
-
-data NURBSCallback =
-     Error
-   | Begin
-   | Vertex
-   | Normal
-   | Color
-   | TextureCoord
-   | End
-   | BeginData
-   | VertexData
-   | NormalData
-   | ColorData
-   | TextureCoordData
-   | EndData
-
-marshalNURBSCallback :: NURBSCallback -> GLenum
-marshalNURBSCallback x = case x of
-   Error -> 100103
-   Begin -> 100164
-   Vertex -> 100165
-   Normal -> 100166
-   Color -> 100167
-   TextureCoord -> 100168
-   End -> 100169
-   BeginData -> 100170
-   VertexData -> 100171
-   NormalData -> 100172
-   ColorData -> 100173
-   TextureCoordData -> 100174
-   EndData -> 100175
+import Graphics.Rendering.OpenGL.GL.CoordTrans
+import Graphics.Rendering.OpenGL.GL.Exception
+import Graphics.Rendering.OpenGL.GL.GLboolean
+import Graphics.Rendering.OpenGL.GL.PrimitiveMode
+import Graphics.Rendering.OpenGL.GL.BeginEnd
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
 
 --------------------------------------------------------------------------------
 -- chapter 7.1: The NURBS Object
 
 -- an opaque pointer to a NURBS object
-newtype NURBSObj = NURBSObj (Ptr NURBSObj)
+type NURBSObj = Ptr GLUnurbs
 
 isNullNURBSObj :: NURBSObj -> Bool
-isNullNURBSObj (NURBSObj ptr) = ptr == nullPtr
+isNullNURBSObj = (nullPtr ==)
 
 withNURBSObj :: a -> (NURBSObj -> IO a) -> IO a
 withNURBSObj failureValue action =
@@ -99,96 +66,58 @@
                                     return failureValue
                             else action nurbsObj)
 
-foreign import CALLCONV safe "gluNewNurbsRenderer"
-   gluNewNurbsRenderer :: IO NURBSObj
-
 safeDeleteNurbsRenderer :: NURBSObj -> IO ()
 safeDeleteNurbsRenderer nurbsObj =
    unless (isNullNURBSObj nurbsObj) $ gluDeleteNurbsRenderer nurbsObj
 
-foreign import CALLCONV safe "gluDeleteNurbsRenderer"
-   gluDeleteNurbsRenderer :: NURBSObj -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 7.2: Callbacks (begin)
 
 type NURBSBeginCallback = PrimitiveMode -> IO ()
 
-type BeginCallback' = GLenum -> IO ()
-
 withNURBSBeginCallback :: NURBSObj -> NURBSBeginCallback -> IO a -> IO a
 withNURBSBeginCallback nurbsObj beginCallback action =
-   bracket (makeBeginCallback (beginCallback . unmarshalPrimitiveMode))
+   bracket (makeNURBSBeginCallback (beginCallback . unmarshalPrimitiveMode))
            freeHaskellFunPtr $ \callbackPtr -> do
-      setBeginCallback nurbsObj (marshalNURBSCallback Begin) callbackPtr
+      gluNurbsCallback nurbsObj glu_NURBS_BEGIN callbackPtr
       action
 
-foreign import CALLCONV "wrapper" makeBeginCallback ::
-   BeginCallback' -> IO (FunPtr BeginCallback')
-
-foreign import CALLCONV safe "gluNurbsCallback"
-   setBeginCallback :: NURBSObj -> GLenum -> FunPtr BeginCallback' -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 7.2: Callbacks (vertex)
 
 type NURBSVertexCallback = Vertex3 GLfloat -> IO ()
 
-type VertexCallback' = Ptr (Vertex3 GLfloat) -> IO ()
-
 withNURBSVertexCallback :: NURBSObj -> NURBSVertexCallback -> IO a -> IO a
 withNURBSVertexCallback nurbsObj vertexCallback action =
-   bracket (makeVertexCallback (\p -> peek p >>= vertexCallback))
+   bracket (makeNURBSVertexCallback (\p -> peek (castPtr p) >>= vertexCallback))
            freeHaskellFunPtr $ \callbackPtr -> do
-      setVertexCallback nurbsObj (marshalNURBSCallback Vertex) callbackPtr
+      gluNurbsCallback nurbsObj glu_NURBS_VERTEX callbackPtr
       action
 
-foreign import CALLCONV "wrapper" makeVertexCallback ::
-   VertexCallback' -> IO (FunPtr VertexCallback')
-
-foreign import CALLCONV safe "gluNurbsCallback"
-   setVertexCallback :: NURBSObj -> GLenum -> FunPtr VertexCallback' -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 7.2: Callbacks (normal)
 
 type NURBSNormalCallback = Normal3 GLfloat -> IO ()
 
-type NormalCallback' = Ptr (Normal3 GLfloat) -> IO ()
-
 withNURBSNormalCallback :: NURBSObj -> NURBSNormalCallback -> IO a -> IO a
 withNURBSNormalCallback nurbsObj normalCallback action =
-   bracket (makeNormalCallback (\p -> peek p >>= normalCallback))
+   bracket (makeNURBSNormalCallback (\p -> peek (castPtr p) >>= normalCallback))
            freeHaskellFunPtr $ \callbackPtr -> do
-      setNormalCallback nurbsObj (marshalNURBSCallback Normal) callbackPtr
+      gluNurbsCallback nurbsObj glu_NURBS_NORMAL callbackPtr
       action
 
-foreign import CALLCONV "wrapper" makeNormalCallback ::
-   NormalCallback' -> IO (FunPtr NormalCallback')
-
-foreign import CALLCONV safe "gluNurbsCallback"
-   setNormalCallback :: NURBSObj -> GLenum -> FunPtr NormalCallback' -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 7.2: Callbacks (color)
 
 type NURBSColorCallback = Color4 GLfloat -> IO ()
 
-type ColorCallback' = Ptr (Color4 GLfloat) -> IO ()
-
 withNURBSColorCallback :: NURBSObj -> NURBSColorCallback -> IO a -> IO a
 withNURBSColorCallback nurbsObj colorCallback action =
-   bracket (makeColorCallback (\p -> peek p >>= colorCallback))
+   bracket (makeNURBSColorCallback (\p -> peek (castPtr p) >>= colorCallback))
            freeHaskellFunPtr $ \callbackPtr -> do
-      setColorCallback nurbsObj (marshalNURBSCallback Color) callbackPtr
+      gluNurbsCallback nurbsObj glu_NURBS_COLOR callbackPtr
       action
 
-foreign import CALLCONV "wrapper" makeColorCallback ::
-   ColorCallback' -> IO (FunPtr ColorCallback')
-
-foreign import CALLCONV safe "gluNurbsCallback"
-   setColorCallback :: NURBSObj -> GLenum -> FunPtr ColorCallback' -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 7.2: Callbacks (end)
 
@@ -196,17 +125,11 @@
 
 withNURBSEndCallback :: NURBSObj -> NURBSEndCallback -> IO a -> IO a
 withNURBSEndCallback nurbsObj endCallback action =
-   bracket (makeEndCallback endCallback)
+   bracket (makeNURBSEndCallback endCallback)
            freeHaskellFunPtr $ \callbackPtr -> do
-      setEndCallback nurbsObj (marshalNURBSCallback End) callbackPtr
+      gluNurbsCallback nurbsObj glu_NURBS_END callbackPtr
       action
 
-foreign import CALLCONV "wrapper" makeEndCallback ::
-   NURBSEndCallback -> IO (FunPtr NURBSEndCallback)
-
-foreign import CALLCONV safe "gluNurbsCallback"
-   setEndCallback :: NURBSObj -> GLenum -> FunPtr NURBSEndCallback -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 7.2: Callbacks (error)
 
@@ -214,17 +137,11 @@
 
 withErrorCallback :: NURBSObj -> ErrorCallback -> IO a -> IO a
 withErrorCallback nurbsObj errorCallback action =
-   bracket (makeErrorCallback errorCallback)
+   bracket (makeNURBSErrorCallback errorCallback)
            freeHaskellFunPtr $ \callbackPtr -> do
-      setErrorCallback nurbsObj (marshalNURBSCallback Error) callbackPtr
+      gluNurbsCallback nurbsObj glu_NURBS_ERROR callbackPtr
       action
 
-foreign import CALLCONV "wrapper" makeErrorCallback ::
-   ErrorCallback -> IO (FunPtr ErrorCallback)
-
-foreign import CALLCONV safe "gluNurbsCallback"
-   setErrorCallback :: NURBSObj -> GLenum -> FunPtr ErrorCallback -> IO ()
-
 checkForNURBSError :: NURBSObj -> IO a -> IO a
 checkForNURBSError nurbsObj = withErrorCallback nurbsObj recordErrorCode
 
@@ -235,8 +152,6 @@
 nurbsBeginEndCurve nurbsObj =
    bracket_ (gluBeginCurve nurbsObj) (gluEndCurve nurbsObj)
 
-foreign import CALLCONV safe "gluBeginCurve"
-   gluBeginCurve :: NURBSObj -> IO ()
 
 nurbsCurve :: ControlPoint c => NURBSObj -> GLint -> Ptr GLfloat -> GLint -> Ptr (c GLfloat) -> GLint -> IO ()
 nurbsCurve nurbsObj knotCount knots stride control order =
@@ -245,12 +160,6 @@
 pseudoPeek :: Ptr (c GLfloat) -> c GLfloat
 pseudoPeek _ = undefined
 
-foreign import CALLCONV safe "gluNurbsCurve"
-   gluNurbsCurve :: NURBSObj -> GLint -> Ptr GLfloat -> GLint -> Ptr GLfloat -> GLint -> GLenum -> IO ()
-
-foreign import CALLCONV safe "gluEndCurve"
-   gluEndCurve :: NURBSObj -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 7.4: NURBS Surfaces
 
@@ -258,19 +167,11 @@
 nurbsBeginEndSurface nurbsObj =
    bracket_ (gluBeginSurface nurbsObj) (gluEndSurface nurbsObj)
 
-foreign import CALLCONV safe "gluBeginSurface"
-   gluBeginSurface :: NURBSObj -> IO ()
 
 nurbsSurface :: ControlPoint c => NURBSObj -> GLint -> Ptr GLfloat -> GLint -> Ptr GLfloat -> GLint -> GLint -> Ptr (c GLfloat) -> GLint -> GLint -> IO ()
 nurbsSurface nurbsObj sKnotCount sKnots tKnotCount tKnots sStride tStride control sOrder tOrder =
    gluNurbsSurface nurbsObj sKnotCount sKnots tKnotCount tKnots sStride tStride (castPtr control) sOrder tOrder (map2Target (pseudoPeek control))
 
-foreign import CALLCONV safe "gluNurbsSurface"
-   gluNurbsSurface :: NURBSObj -> GLint -> Ptr GLfloat -> GLint -> Ptr GLfloat -> GLint -> GLint -> Ptr GLfloat -> GLint -> GLint -> GLenum -> IO ()
-
-foreign import CALLCONV safe "gluEndSurface"
-   gluEndSurface :: NURBSObj -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 7.5: Trimming
 
@@ -278,94 +179,42 @@
    trimmingTarget :: p GLfloat -> GLenum
 
 instance TrimmingPoint Vertex2 where
-   trimmingTarget = marshalNURBSTrim . const Map1Trim2
+   trimmingTarget = const glu_MAP1_TRIM_2
 
 instance TrimmingPoint Vertex3 where
-   trimmingTarget = marshalNURBSTrim . const Map1Trim3
-
-data NURBSTrim =
-     Map1Trim2
-   | Map1Trim3
-
-marshalNURBSTrim :: NURBSTrim -> GLenum
-marshalNURBSTrim x = case x of
-   Map1Trim2 -> 100210
-   Map1Trim3 -> 100211
+   trimmingTarget = const glu_MAP1_TRIM_3
 
 nurbsBeginEndTrim :: NURBSObj -> IO a -> IO a
 nurbsBeginEndTrim nurbsObj =
    bracket_ (gluBeginTrim nurbsObj) (gluEndTrim nurbsObj)
 
-foreign import CALLCONV safe "gluBeginTrim"
-   gluBeginTrim :: NURBSObj -> IO ()
-
 pwlCurve :: TrimmingPoint p => NURBSObj -> GLint -> Ptr (p GLfloat) -> GLint -> IO ()
 pwlCurve nurbsObj count points stride =
    gluPwlCurve nurbsObj count (castPtr points) stride (trimmingTarget (pseudoPeek points))
 
-foreign import CALLCONV safe "gluPwlCurve"
-   gluPwlCurve :: NURBSObj -> GLint -> Ptr GLfloat -> GLint -> GLenum -> IO ()
-
 trimmingCurve :: TrimmingPoint c => NURBSObj -> GLint -> Ptr GLfloat -> GLint -> Ptr (c GLfloat) -> GLint -> IO ()
 trimmingCurve nurbsObj knotCount knots stride control order =
    gluNurbsCurve nurbsObj knotCount knots stride (castPtr control) order (trimmingTarget (pseudoPeek control))
 
-foreign import CALLCONV safe "gluEndTrim"
-   gluEndTrim :: NURBSObj -> IO ()
-
 --------------------------------------------------------------------------------
--- chapter 7.6: NURBS Properties
 
-data NURBSProperty =
-     AutoLoadMatrix
-   | Culling
-   | ParametricTolerance
-   | SamplingTolerance
-   | DisplayMode'
-   | SamplingMethod
-   | UStep
-   | VStep
-   | NURBSMode
-
-marshalNURBSProperty :: NURBSProperty -> GLenum
-marshalNURBSProperty x = case x of
-   AutoLoadMatrix -> 100200
-   Culling -> 100201
-   ParametricTolerance -> 100202
-   SamplingTolerance -> 100203
-   DisplayMode' -> 100204
-   SamplingMethod -> 100205
-   UStep -> 100206
-   VStep -> 100207
-   NURBSMode -> 100160
-
---------------------------------------------------------------------------------
-
-setNURBSProperty :: NURBSObj -> NURBSProperty -> GLfloat -> IO ()
-setNURBSProperty nurbsObj = gluNurbsProperty nurbsObj . marshalNURBSProperty
-
-foreign import CALLCONV safe "gluNurbsProperty"
-   gluNurbsProperty :: NURBSObj -> GLenum -> GLfloat -> IO ()
-
---------------------------------------------------------------------------------
-
 data NURBSMode =
      NURBSTessellator
    | NURBSRenderer
    deriving ( Eq, Ord, Show )
 
 marshalNURBSMode :: NURBSMode -> GLfloat
-marshalNURBSMode x = case x of
-   NURBSTessellator -> 100161
-   NURBSRenderer -> 100162
+marshalNURBSMode x = fromIntegral $ case x of
+   NURBSTessellator -> glu_NURBS_TESSELLATOR
+   NURBSRenderer -> glu_NURBS_RENDERER
 
 setNURBSMode :: NURBSObj -> NURBSMode -> IO ()
-setNURBSMode nurbsObj = setNURBSProperty nurbsObj NURBSMode . marshalNURBSMode
+setNURBSMode nurbsObj = gluNurbsProperty nurbsObj glu_NURBS_MODE . marshalNURBSMode
 
 --------------------------------------------------------------------------------
 
 setNURBSCulling :: NURBSObj -> Capability -> IO ()
-setNURBSCulling nurbsObj = setNURBSProperty nurbsObj Culling . fromIntegral . marshalCapability
+setNURBSCulling nurbsObj = gluNurbsProperty nurbsObj glu_CULLING . fromIntegral . marshalCapability
 
 --------------------------------------------------------------------------------
 
@@ -377,15 +226,15 @@
    | ObjectParametricError'
 
 marshalSamplingMethod' :: SamplingMethod' -> GLfloat
-marshalSamplingMethod' x = case x of
-   PathLength' -> 100215
-   ParametricError' -> 100216
-   DomainDistance' -> 100217
-   ObjectPathLength' -> 100209
-   ObjectParametricError' -> 100208
+marshalSamplingMethod' x = fromIntegral $ case x of
+   PathLength' -> glu_PATH_LENGTH
+   ParametricError' -> glu_PARAMETRIC_TOLERANCE
+   DomainDistance' -> glu_DOMAIN_DISTANCE
+   ObjectPathLength' -> glu_OBJECT_PATH_LENGTH
+   ObjectParametricError' -> glu_OBJECT_PARAMETRIC_ERROR
 
 setSamplingMethod' :: NURBSObj -> SamplingMethod' -> IO ()
-setSamplingMethod' nurbsObj = setNURBSProperty nurbsObj SamplingMethod . marshalSamplingMethod'
+setSamplingMethod' nurbsObj = gluNurbsProperty nurbsObj glu_SAMPLING_METHOD . marshalSamplingMethod'
 
 --------------------------------------------------------------------------------
 
@@ -400,26 +249,26 @@
 setSamplingMethod :: NURBSObj -> SamplingMethod -> IO ()
 setSamplingMethod nurbsObj x = case x of
    PathLength s -> do
-      setNURBSProperty nurbsObj SamplingTolerance s
+      gluNurbsProperty nurbsObj glu_SAMPLING_TOLERANCE s
       setSamplingMethod' nurbsObj PathLength'
    ParametricError p -> do
-      setNURBSProperty nurbsObj ParametricTolerance p
+      gluNurbsProperty nurbsObj glu_PARAMETRIC_TOLERANCE p
       setSamplingMethod' nurbsObj ParametricError'
    DomainDistance u v -> do
-      setNURBSProperty nurbsObj UStep u
-      setNURBSProperty nurbsObj VStep v
+      gluNurbsProperty nurbsObj glu_U_STEP u
+      gluNurbsProperty nurbsObj glu_V_STEP v
       setSamplingMethod' nurbsObj DomainDistance'
    ObjectPathLength s -> do
-      setNURBSProperty nurbsObj SamplingTolerance s
+      gluNurbsProperty nurbsObj glu_SAMPLING_TOLERANCE s
       setSamplingMethod' nurbsObj ObjectPathLength'
    ObjectParametricError p -> do
-      setNURBSProperty nurbsObj ParametricTolerance p
+      gluNurbsProperty nurbsObj glu_PARAMETRIC_TOLERANCE p
       setSamplingMethod' nurbsObj ObjectParametricError'
 
 --------------------------------------------------------------------------------
 
 setAutoLoadMatrix :: NURBSObj -> Bool -> IO ()
-setAutoLoadMatrix nurbsObj = setNURBSProperty nurbsObj AutoLoadMatrix . marshalGLboolean
+setAutoLoadMatrix nurbsObj = gluNurbsProperty nurbsObj glu_AUTO_LOAD_MATRIX . marshalGLboolean
 
 loadSamplingMatrices :: (Matrix m1, Matrix m2) => NURBSObj -> Maybe (m1 GLfloat, m2 GLfloat, (Position, Size)) -> IO ()
 loadSamplingMatrices nurbsObj =
@@ -444,9 +293,6 @@
                                             3, 7, 11, 15 ]
             withArray elems act
 
-foreign import CALLCONV safe "gluLoadSamplingMatrices"
-   gluLoadSamplingMatrices :: NURBSObj -> Ptr GLfloat -> Ptr GLfloat -> Ptr GLint -> IO ()
-
 --------------------------------------------------------------------------------
 
 data DisplayMode' =
@@ -456,10 +302,10 @@
    deriving ( Eq, Ord, Show )
 
 marshalDisplayMode' :: DisplayMode' -> GLfloat
-marshalDisplayMode' x = case x of
-   Fill' -> 100012
-   OutlinePolygon -> 100240
-   OutlinePatch -> 100241
+marshalDisplayMode' x = fromIntegral $ case x of
+   Fill' -> glu_FILL
+   OutlinePolygon -> glu_OUTLINE_POLYGON
+   OutlinePatch -> glu_OUTLINE_PATCH
 
 setDisplayMode' :: NURBSObj -> DisplayMode' -> IO ()
-setDisplayMode' nurbsObj = setNURBSProperty nurbsObj DisplayMode' . marshalDisplayMode'
+setDisplayMode' nurbsObj = gluNurbsProperty nurbsObj glu_DISPLAY_MODE . marshalDisplayMode'
diff --git a/Graphics/Rendering/OpenGL/GLU/Quadrics.hs b/Graphics/Rendering/OpenGL/GLU/Quadrics.hs
--- a/Graphics/Rendering/OpenGL/GLU/Quadrics.hs
+++ b/Graphics/Rendering/OpenGL/GLU/Quadrics.hs
@@ -20,9 +20,9 @@
 ) where
 
 import Control.Monad ( unless )
-import Foreign.Ptr ( Ptr, nullPtr, FunPtr, freeHaskellFunPtr )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLenum, GLint, GLdouble )
+import Foreign.Ptr ( Ptr, nullPtr, freeHaskellFunPtr )
+import Graphics.Rendering.GLU.Raw
+import Graphics.Rendering.OpenGL.Raw.Core31
 import Graphics.Rendering.OpenGL.GL.Colors ( ShadingModel(Smooth,Flat) )
 import Graphics.Rendering.OpenGL.GL.Exception ( bracket )
 import Graphics.Rendering.OpenGL.GL.GLboolean ( marshalGLboolean )
@@ -40,29 +40,19 @@
 
 marshalQuadricDrawStyle :: QuadricDrawStyle -> GLenum
 marshalQuadricDrawStyle x = case x of
-   PointStyle -> 0x186aa
-   LineStyle -> 0x186ab
-   FillStyle -> 0x186ac
-   SilhouetteStyle -> 0x186ad
-
---------------------------------------------------------------------------------
-
-data QuadricCallback =
-     Error'2
-   deriving ( Eq, Ord, Show )
-
-marshalQuadricCallback :: QuadricCallback -> GLenum
-marshalQuadricCallback x = case x of
-   Error'2 -> 0x18707
+   PointStyle -> glu_POINT
+   LineStyle -> glu_LINE
+   FillStyle -> glu_FILL
+   SilhouetteStyle -> glu_SILHOUETTE
 
 --------------------------------------------------------------------------------
 
 type QuadricNormal = Maybe ShadingModel
 
 marshalQuadricNormal :: QuadricNormal -> GLenum
-marshalQuadricNormal (Just Smooth) = 0x186a0
-marshalQuadricNormal (Just Flat  ) = 0x186a1
-marshalQuadricNormal Nothing       = 0x186a2
+marshalQuadricNormal (Just Smooth) = glu_SMOOTH
+marshalQuadricNormal (Just Flat  ) = glu_FLAT
+marshalQuadricNormal Nothing       = glu_NONE
 
 --------------------------------------------------------------------------------
 
@@ -73,8 +63,8 @@
 
 marshalQuadricOrientation :: QuadricOrientation -> GLenum
 marshalQuadricOrientation x = case x of
-   Outside -> 0x186b4
-   Inside -> 0x186b5
+   Outside -> glu_OUTSIDE
+   Inside -> glu_INSIDE
 
 --------------------------------------------------------------------------------
 
@@ -130,10 +120,14 @@
                               then failure
                               else success quadricObj)
 
-withErrorCallback :: QuadricObj -> QuadricCallback' -> IO a -> IO a
+safeDeleteQuadric :: QuadricObj -> IO ()
+safeDeleteQuadric quadricObj =
+   unless (isNullQuadricObj quadricObj) $ gluDeleteQuadric quadricObj
+
+withErrorCallback :: QuadricObj -> QuadricCallback -> IO a -> IO a
 withErrorCallback quadricObj callback action =
    bracket (makeQuadricCallback callback) freeHaskellFunPtr $ \callbackPtr -> do
-      gluQuadricCallback quadricObj (marshalQuadricCallback Error'2) callbackPtr
+      gluQuadricCallback quadricObj glu_ERROR callbackPtr
       action
 
 setStyle :: QuadricObj -> QuadricStyle -> IO ()
@@ -155,58 +149,7 @@
 
 --------------------------------------------------------------------------------
 
--- 'Char' is a fake here, any marshalable type would do
-newtype QuadricObj = QuadricObj (Ptr Char)
-   deriving ( Eq )
+type QuadricObj = Ptr GLUquadric
 
 isNullQuadricObj :: QuadricObj -> Bool
-isNullQuadricObj = (QuadricObj nullPtr ==)
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "gluNewQuadric" gluNewQuadric :: IO QuadricObj
-
-safeDeleteQuadric :: QuadricObj -> IO ()
-safeDeleteQuadric quadricObj =
-   unless (isNullQuadricObj quadricObj) $ gluDeleteQuadric quadricObj
-
-foreign import CALLCONV unsafe "gluDeleteQuadric" gluDeleteQuadric ::
-   QuadricObj -> IO ()
-
---------------------------------------------------------------------------------
-
-type QuadricCallback' = GLenum -> IO ()
-
-foreign import CALLCONV "wrapper" makeQuadricCallback ::
-   QuadricCallback' -> IO (FunPtr QuadricCallback')
-
-foreign import CALLCONV unsafe "gluQuadricCallback" gluQuadricCallback ::
-   QuadricObj -> GLenum -> FunPtr QuadricCallback' -> IO ()
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV unsafe "gluQuadricNormals" gluQuadricNormals ::
-   QuadricObj -> GLenum -> IO ()
-
-foreign import CALLCONV unsafe "gluQuadricTexture" gluQuadricTexture ::
-   QuadricObj -> GLboolean -> IO ()
-
-foreign import CALLCONV unsafe "gluQuadricOrientation" gluQuadricOrientation ::
-   QuadricObj -> GLenum -> IO ()
-
-foreign import CALLCONV unsafe "gluQuadricDrawStyle" gluQuadricDrawStyle ::
-   QuadricObj -> GLenum -> IO ()
-
---------------------------------------------------------------------------------
-
-foreign import CALLCONV safe "gluSphere" gluSphere ::
-   QuadricObj -> Radius -> Slices -> Stacks -> IO ()
-
-foreign import CALLCONV safe "gluCylinder" gluCylinder ::
-  QuadricObj -> Radius -> Radius -> Height -> Slices -> Stacks -> IO ()
-
-foreign import CALLCONV safe "gluDisk" gluDisk ::
-   QuadricObj -> Radius -> Radius -> Slices -> Loops -> IO ()
-
-foreign import CALLCONV safe "gluPartialDisk" gluPartialDisk ::
-   QuadricObj -> Radius -> Radius -> Slices -> Loops -> Angle -> Angle -> IO ()
+isNullQuadricObj = (nullPtr ==)
diff --git a/Graphics/Rendering/OpenGL/GLU/Tessellation.hs b/Graphics/Rendering/OpenGL/GLU/Tessellation.hs
--- a/Graphics/Rendering/OpenGL/GLU/Tessellation.hs
+++ b/Graphics/Rendering/OpenGL/GLU/Tessellation.hs
@@ -38,78 +38,23 @@
 import Control.Monad ( foldM, unless )
 import Data.IORef ( newIORef, readIORef, writeIORef, modifyIORef )
 import Data.Maybe ( fromJust )
+import Data.Tensor
 import Foreign.Marshal.Alloc ( allocaBytes )
 import Foreign.Marshal.Array ( peekArray, pokeArray )
 import Foreign.Marshal.Pool ( Pool, withPool, pooledNew )
-import Foreign.Ptr ( Ptr, nullPtr, plusPtr, castPtr, FunPtr, freeHaskellFunPtr )
+import Foreign.Ptr ( Ptr, nullPtr, plusPtr, castPtr, freeHaskellFunPtr )
 import Foreign.Storable ( Storable(..) )
-import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLclampf, GLdouble, GLenum )
+import Graphics.Rendering.GLU.Raw
+import Graphics.Rendering.OpenGL.Raw.Core31
 import Graphics.Rendering.OpenGL.GL.EdgeFlag ( unmarshalEdgeFlag )
 import Graphics.Rendering.OpenGL.GL.Exception ( bracket )
 import Graphics.Rendering.OpenGL.GL.GLboolean ( marshalGLboolean )
 import Graphics.Rendering.OpenGL.GL.PrimitiveMode ( unmarshalPrimitiveMode )
 import Graphics.Rendering.OpenGL.GL.BeginEnd (
    PrimitiveMode, EdgeFlag(BeginsInteriorEdge) )
-import Graphics.Rendering.OpenGL.GL.VertexSpec (
-   Vertex3(..), Normal3(..) )
-import Graphics.Rendering.OpenGL.GL.QueryUtils ( maybeNullPtr )
-import Graphics.Rendering.OpenGL.GLU.ErrorsInternal (
-   recordErrorCode, recordOutOfMemory )
-
---------------------------------------------------------------------------------
-
-data TessCallback =
-     TessBegin
-   | Begin
-   | TessVertex
-   | Vertex
-   | TessEnd
-   | End
-   | TessError
-   | Error'
-   | TessEdgeFlag
-   | EdgeFlag
-   | TessCombine
-   | TessBeginData
-   | TessVertexData
-   | TessEndData
-   | TessErrorData
-   | TessEdgeFlagData
-   | TessCombineData
-
-marshalTessCallback :: TessCallback -> GLenum
-marshalTessCallback x = case x of
-   TessBegin -> 0x18704
-   Begin -> 0x18704
-   TessVertex -> 0x18705
-   Vertex -> 0x18705
-   TessEnd -> 0x18706
-   End -> 0x18706
-   TessError -> 0x18707
-   Error' -> 0x18707
-   TessEdgeFlag -> 0x18708
-   EdgeFlag -> 0x18708
-   TessCombine -> 0x18709
-   TessBeginData -> 0x1870a
-   TessVertexData -> 0x1870b
-   TessEndData -> 0x1870c
-   TessErrorData -> 0x1870d
-   TessEdgeFlagData -> 0x1870e
-   TessCombineData -> 0x1870f
-
---------------------------------------------------------------------------------
-
-data TessProperty =
-     TessWindingRule
-   | TessBoundaryOnly
-   | TessTolerance
-
-marshalTessProperty :: TessProperty -> GLenum
-marshalTessProperty x = case x of
-   TessWindingRule -> 0x1872c
-   TessBoundaryOnly -> 0x1872d
-   TessTolerance -> 0x1872e
+import Graphics.Rendering.OpenGL.GL.VertexSpec
+import Graphics.Rendering.OpenGL.GL.QueryUtils
+import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
 
 --------------------------------------------------------------------------------
 
@@ -123,11 +68,11 @@
 
 marshalTessWinding :: TessWinding -> GLenum
 marshalTessWinding x = case x of
-   TessWindingOdd -> 0x18722
-   TessWindingNonzero -> 0x18723
-   TessWindingPositive -> 0x18724
-   TessWindingNegative -> 0x18725
-   TessWindingAbsGeqTwo -> 0x18726
+   TessWindingOdd -> glu_TESS_WINDING_ODD
+   TessWindingNonzero -> glu_TESS_WINDING_NONZERO
+   TessWindingPositive -> glu_TESS_WINDING_POSITIVE
+   TessWindingNegative -> glu_TESS_WINDING_NEGATIVE
+   TessWindingAbsGeqTwo -> glu_TESS_WINDING_ABS_GEQ_TWO
 
 --------------------------------------------------------------------------------
 
@@ -135,13 +80,7 @@
 -- property, e.g. color, texture coordinates, etc.
 
 data AnnotatedVertex v = AnnotatedVertex (Vertex3 GLdouble) v
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq v => Eq (AnnotatedVertex v)
-instance Ord v => Ord (AnnotatedVertex v)
-#else
    deriving ( Eq, Ord )
-#endif
 
 offsetOfProperty :: Storable v => v -> Int
 offsetOfProperty v = alignOffset v (3 * sizeOf x)
@@ -180,13 +119,7 @@
 -- | A complex contour, which can be self-intersecting and\/or concave.
 
 newtype ComplexContour v = ComplexContour [AnnotatedVertex v]
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq v => Eq (ComplexContour v)
-instance Ord v => Ord (ComplexContour v)
-#else
    deriving ( Eq, Ord )
-#endif
 
 sizeOfComplexContour :: Storable v => ComplexContour v -> Int
 sizeOfComplexContour (ComplexContour vs) =
@@ -203,13 +136,7 @@
 -- and possibly intersecting contours.
 
 newtype ComplexPolygon v = ComplexPolygon [ComplexContour v]
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq v => Eq (ComplexPolygon v)
-instance Ord v => Ord (ComplexPolygon v)
-#else
    deriving ( Eq, Ord )
-#endif
 
 sizeOfComplexPolygon :: Storable v => ComplexPolygon v -> Int
 sizeOfComplexPolygon (ComplexPolygon complexContours) =
@@ -240,13 +167,7 @@
                         (GLclampf, v)
                         (GLclampf, v)
                         (GLclampf, v)
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq v => Eq (WeightedProperties v)
-instance Ord v => Ord (WeightedProperties v)
-#else
    deriving ( Eq, Ord )
-#endif
 
 -- | A function combining given vertex properties into a property for a newly
 -- generated vertex
@@ -287,28 +208,16 @@
 -- | A simple, non-self-intersecting contour
 
 newtype SimpleContour v = SimpleContour [AnnotatedVertex v]
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq v => Eq (SimpleContour v)
-instance Ord v => Ord (SimpleContour v)
-#else
    deriving ( Eq, Ord )
-#endif
 
 -- | The contours of a complex polygon, represented by one or more
 -- non-intersecting simple contours
 
 newtype PolygonContours v = PolygonContours [SimpleContour v]
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq v => Eq (PolygonContours v)
-instance Ord v => Ord (PolygonContours v)
-#else
    deriving ( Eq, Ord )
-#endif
 
 extractContours :: Storable v => Tessellator PolygonContours v
-extractContours windingRule tolerance normal combiner complexPoly = do
+extractContours windingRule tolerance theNormal combiner complexPoly = do
 
    vertices <- newIORef []
    let addVertex v = modifyIORef vertices (v:)
@@ -322,7 +231,7 @@
        getContours = fmap (PolygonContours . reverse) (readIORef contours)
 
    withTessellatorObj (PolygonContours [])$ \tessObj -> do
-      setTessellatorProperties tessObj windingRule tolerance normal True
+      setTessellatorProperties tessObj windingRule tolerance theNormal True
       withVertexCallback tessObj addVertex $
          withEndCallback tessObj finishContour $
             checkForError tessObj $
@@ -340,27 +249,15 @@
 
 data Triangle v
    = Triangle (TriangleVertex v) (TriangleVertex v) (TriangleVertex v)
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq v => Eq (Triangle v)
-instance Ord v => Ord (Triangle v)
-#else
    deriving ( Eq, Ord )
-#endif
 
 -- | A triangulation of a complex polygon
 
 newtype Triangulation v = Triangulation [Triangle v]
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq v => Eq (Triangulation v)
-instance Ord v => Ord (Triangulation v)
-#else
    deriving ( Eq, Ord )
-#endif
 
 triangulate :: Storable v => Tessellator Triangulation v
-triangulate windingRule tolerance normal combiner complexPoly = do
+triangulate windingRule tolerance theNormal combiner complexPoly = do
 
    edgeFlagState <- newIORef BeginsInteriorEdge
    let registerEdgeFlag = writeIORef edgeFlagState
@@ -375,7 +272,7 @@
           return $ Triangulation (collectTriangles (reverse vs))
 
    withTessellatorObj (Triangulation []) $ \tessObj -> do
-      setTessellatorProperties tessObj windingRule tolerance normal False
+      setTessellatorProperties tessObj windingRule tolerance theNormal False
       withEdgeFlagCallback tessObj registerEdgeFlag $
          withVertexCallback tessObj addVertex $
             checkForError tessObj $
@@ -391,25 +288,13 @@
 --------------------------------------------------------------------------------
 
 data Primitive v = Primitive PrimitiveMode [AnnotatedVertex v]
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq v => Eq (Primitive v)
-instance Ord v => Ord (Primitive v)
-#else
    deriving ( Eq, Ord )
-#endif
 
 newtype SimplePolygon v = SimplePolygon [Primitive v]
-#ifdef __HADDOCK__
--- Help Haddock a bit, because it doesn't do any instance inference.
-instance Eq v => Eq (SimplePolygon v)
-instance Ord v => Ord (SimplePolygon v)
-#else
    deriving ( Eq, Ord )
-#endif
 
 tessellate :: Storable v => Tessellator SimplePolygon v
-tessellate windingRule tolerance normal combiner complexPoly = do
+tessellate windingRule tolerance theNormal combiner complexPoly = do
 
    beginModeState <- newIORef undefined
    let setPrimitiveMode = writeIORef beginModeState
@@ -427,7 +312,7 @@
        getSimplePolygon = fmap (SimplePolygon . reverse) (readIORef primitives)
 
    withTessellatorObj (SimplePolygon []) $ \tessObj -> do
-      setTessellatorProperties tessObj windingRule tolerance normal False
+      setTessellatorProperties tessObj windingRule tolerance theNormal False
       withBeginCallback tessObj setPrimitiveMode $
          withVertexCallback tessObj addVertex $
             withEndCallback tessObj finishPrimitive $
@@ -440,10 +325,10 @@
 -- chapter 5.1: The Tessellation Object
 
 -- an opaque pointer to a tessellator object
-newtype TessellatorObj = TessellatorObj (Ptr TessellatorObj)
+type TessellatorObj = Ptr GLUtesselator
 
 isNullTesselatorObj :: TessellatorObj -> Bool
-isNullTesselatorObj (TessellatorObj ptr) = ptr == nullPtr
+isNullTesselatorObj = (nullPtr ==)
 
 withTessellatorObj :: a -> (TessellatorObj -> IO a) -> IO a
 withTessellatorObj failureValue action =
@@ -453,15 +338,10 @@
                                    return failureValue
                            else action tessObj)
 
-foreign import CALLCONV unsafe "gluNewTess" gluNewTess :: IO TessellatorObj
-
 safeDeleteTess :: TessellatorObj -> IO ()
 safeDeleteTess tessObj =
    unless (isNullTesselatorObj tessObj) $ gluDeleteTess tessObj
 
-foreign import CALLCONV unsafe "gluDeleteTess" gluDeleteTess ::
-   TessellatorObj -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 5.2: Polygon Definition (polygons)
 
@@ -482,12 +362,6 @@
    gluTessEndPolygon tessObj
    return res
 
-foreign import CALLCONV safe "gluTessBeginPolygon" gluTessBeginPolygon ::
-   TessellatorObj -> Ptr p -> IO ()
-
-foreign import CALLCONV safe "gluTessEndPolygon" gluTessEndPolygon ::
-   TessellatorObj -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 5.2: Polygon Definition (contours)
 
@@ -508,82 +382,49 @@
    gluTessEndContour tessObj
    return res
 
-foreign import CALLCONV safe "gluTessBeginContour" gluTessBeginContour ::
-   TessellatorObj -> IO ()
-
-foreign import CALLCONV safe "gluTessEndContour" gluTessEndContour ::
-   TessellatorObj -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 5.2: Polygon Definition (vertices)
 
 defineVertex :: TessellatorObj -> Ptr (AnnotatedVertex v) -> IO ()
 defineVertex tessObj ptr = gluTessVertex tessObj (castPtr ptr) ptr
 
-foreign import CALLCONV safe "gluTessVertex" gluTessVertex ::
-   TessellatorObj -> Ptr (Vertex3 GLdouble) -> Ptr (AnnotatedVertex v) -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 5.3: Callbacks (begin)
 
 type BeginCallback  = PrimitiveMode -> IO ()
 
-type BeginCallback' = GLenum -> IO ()
-
 withBeginCallback :: TessellatorObj -> BeginCallback -> IO a -> IO a
 withBeginCallback tessObj beginCallback action =
-   bracket (makeBeginCallback (beginCallback . unmarshalPrimitiveMode))
+   bracket (makeTessBeginCallback (beginCallback . unmarshalPrimitiveMode))
            freeHaskellFunPtr $ \callbackPtr -> do
-      setBeginCallback tessObj (marshalTessCallback TessBegin) callbackPtr
+      gluTessCallback tessObj glu_TESS_BEGIN callbackPtr
       action
 
-foreign import CALLCONV "wrapper" makeBeginCallback ::
-   BeginCallback' -> IO (FunPtr BeginCallback')
-
-foreign import CALLCONV unsafe "gluTessCallback" setBeginCallback ::
-   TessellatorObj -> GLenum -> FunPtr BeginCallback' -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 5.3: Callbacks (edgeFlag)
 
 type EdgeFlagCallback  = EdgeFlag -> IO ()
 
-type EdgeFlagCallback' = GLboolean -> IO ()
-
 withEdgeFlagCallback :: TessellatorObj -> EdgeFlagCallback -> IO a -> IO a
 withEdgeFlagCallback tessObj edgeFlagCallback action =
-   bracket (makeEdgeFlagCallback (edgeFlagCallback . unmarshalEdgeFlag))
+   bracket (makeTessEdgeFlagCallback (edgeFlagCallback . unmarshalEdgeFlag))
            freeHaskellFunPtr $ \callbackPtr -> do
-      setEdgeFlagCallback tessObj (marshalTessCallback TessEdgeFlag) callbackPtr
+      gluTessCallback tessObj glu_TESS_EDGE_FLAG callbackPtr
       action
 
-foreign import CALLCONV "wrapper" makeEdgeFlagCallback ::
-   EdgeFlagCallback' -> IO (FunPtr EdgeFlagCallback')
-
-foreign import CALLCONV unsafe "gluTessCallback" setEdgeFlagCallback ::
-   TessellatorObj -> GLenum -> FunPtr EdgeFlagCallback' -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 5.3: Callbacks (vertex)
 
 type VertexCallback v = AnnotatedVertex v -> IO ()
 
-type VertexCallback' v = Ptr (AnnotatedVertex v) -> IO ()
-
 withVertexCallback ::
    Storable v => TessellatorObj -> VertexCallback v -> IO a -> IO a
 withVertexCallback tessObj vertexCallback action =
-   bracket (makeVertexCallback (\p -> peek p >>= vertexCallback))
+   bracket (makeTessVertexCallback (\p -> peek p >>= vertexCallback))
            freeHaskellFunPtr $ \callbackPtr -> do
-      setVertexCallback tessObj (marshalTessCallback TessVertex) callbackPtr
+      gluTessCallback tessObj glu_TESS_VERTEX callbackPtr
       action
 
-foreign import CALLCONV "wrapper" makeVertexCallback ::
-   VertexCallback' v -> IO (FunPtr (VertexCallback' v))
-
-foreign import CALLCONV unsafe "gluTessCallback" setVertexCallback ::
-   TessellatorObj -> GLenum -> FunPtr (VertexCallback' v) -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 5.3: Callbacks (end)
 
@@ -591,16 +432,10 @@
 
 withEndCallback :: TessellatorObj -> EndCallback -> IO a -> IO a
 withEndCallback tessObj endCallback action =
-   bracket (makeEndCallback endCallback) freeHaskellFunPtr $ \callbackPtr -> do
-      setEndCallback tessObj (marshalTessCallback TessEnd) callbackPtr
+   bracket (makeTessEndCallback endCallback) freeHaskellFunPtr $ \callbackPtr -> do
+      gluTessCallback tessObj glu_TESS_END callbackPtr
       action
 
-foreign import CALLCONV "wrapper" makeEndCallback ::
-   EndCallback -> IO (FunPtr EndCallback)
-
-foreign import CALLCONV unsafe "gluTessCallback" setEndCallback ::
-   TessellatorObj -> GLenum -> FunPtr EndCallback -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 5.3: Callbacks (error)
 
@@ -608,17 +443,11 @@
 
 withErrorCallback :: TessellatorObj -> ErrorCallback -> IO a -> IO a
 withErrorCallback tessObj errorCallback action =
-   bracket (makeErrorCallback errorCallback)
+   bracket (makeTessErrorCallback errorCallback)
            freeHaskellFunPtr $ \callbackPtr -> do
-      setErrorCallback tessObj (marshalTessCallback TessError) callbackPtr
+      gluTessCallback tessObj glu_TESS_ERROR callbackPtr
       action
 
-foreign import CALLCONV "wrapper" makeErrorCallback ::
-   ErrorCallback -> IO (FunPtr ErrorCallback)
-
-foreign import CALLCONV unsafe "gluTessCallback" setErrorCallback ::
-   TessellatorObj -> GLenum -> FunPtr ErrorCallback -> IO ()
-
 checkForError :: TessellatorObj -> IO a -> IO a
 checkForError tessObj = withErrorCallback tessObj recordErrorCode
 
@@ -626,7 +455,7 @@
 -- chapter 5.3: Callbacks (combine)
 
 type CombineCallback v =
-      Ptr (Vertex3 GLdouble)
+      Ptr GLdouble
    -> Ptr (Ptr (AnnotatedVertex v))
    -> Ptr GLclampf
    -> Ptr (Ptr (AnnotatedVertex v))
@@ -636,9 +465,9 @@
    Storable v => TessellatorObj -> Combiner v -> IO a -> IO a
 withCombineCallback tessObj combiner action =
    withPool $ \vertexPool ->
-      bracket (makeCombineCallback (combineProperties vertexPool combiner))
+      bracket (makeTessCombineCallback (combineProperties vertexPool combiner))
               freeHaskellFunPtr $ \callbackPtr -> do
-         setCombineCallback tessObj (marshalTessCallback TessCombine) callbackPtr
+         gluTessCallback tessObj glu_TESS_COMBINE callbackPtr
          action 
 
 -- NOTE: SGI's tesselator has a bug, sometimes passing NULL for the last two
@@ -647,7 +476,7 @@
 -- corresponding weight is 0.
 combineProperties :: Storable v => Pool -> Combiner v -> CombineCallback v
 combineProperties pool combiner newVertexPtr propertyPtrs weights result = do
-   newVertex <- peek newVertexPtr
+   newVertex <- peek (castPtr newVertexPtr :: Ptr (Vertex3 GLdouble))
    [v0, v1, v2, v3] <- mapM (getProperty propertyPtrs) [0..3]
    [w0, w1, w2, w3] <- peekArray 4 weights
    let defaultProperty = fromJust v0
@@ -665,45 +494,28 @@
    AnnotatedVertex _ v <- peek ptr
    return (Just v)
 
-foreign import CALLCONV "wrapper" makeCombineCallback ::
-   CombineCallback v -> IO (FunPtr (CombineCallback v))
-
-foreign import CALLCONV unsafe "gluTessCallback" setCombineCallback ::
-   TessellatorObj -> GLenum -> FunPtr (CombineCallback v) -> IO ()
-
 --------------------------------------------------------------------------------
 -- chapter 5.4: Control over Tessellation
 
 setTessellatorProperties ::
     TessellatorObj -> TessWinding -> Tolerance -> Normal3 GLdouble -> Bool
  -> IO ()
-setTessellatorProperties tessObj windingRule tolerance normal boundaryOnly = do
+setTessellatorProperties tessObj windingRule tolerance theNormal boundaryOnly = do
    setWindingRule tessObj windingRule
    setTolerance tessObj tolerance
-   setNormal tessObj normal
+   setNormal tessObj theNormal
    setBoundaryOnly tessObj boundaryOnly
 
 setWindingRule :: TessellatorObj -> TessWinding -> IO ()
 setWindingRule tessObj =
-   tessProperty tessObj TessWindingRule . fromIntegral . marshalTessWinding
+   gluTessProperty tessObj glu_TESS_WINDING_RULE . fromIntegral . marshalTessWinding
 
 setBoundaryOnly :: TessellatorObj -> Bool -> IO ()
 setBoundaryOnly tessObj =
-   tessProperty tessObj TessBoundaryOnly . marshalGLboolean
+   gluTessProperty tessObj glu_TESS_BOUNDARY_ONLY . marshalGLboolean
 
 setTolerance :: TessellatorObj -> Tolerance -> IO ()
-setTolerance tessObj =
-   tessProperty tessObj TessTolerance
-
-tessProperty :: TessellatorObj -> TessProperty -> GLdouble -> IO ()
-tessProperty tessObj =
-   gluTessProperty tessObj . marshalTessProperty
-
-foreign import CALLCONV unsafe "gluTessProperty" gluTessProperty ::
-   TessellatorObj -> GLenum -> GLdouble -> IO ()
+setTolerance tessObj = gluTessProperty tessObj glu_TESS_TOLERANCE
 
 setNormal :: TessellatorObj -> Normal3 GLdouble -> IO ()
 setNormal tessObj (Normal3 x y z) = gluTessNormal tessObj x y z
-
-foreign import CALLCONV unsafe "gluTessNormal" gluTessNormal ::
-   TessellatorObj -> GLdouble -> GLdouble -> GLdouble -> IO ()
diff --git a/OpenGL.buildinfo.in b/OpenGL.buildinfo.in
deleted file mode 100644
--- a/OpenGL.buildinfo.in
+++ /dev/null
@@ -1,8 +0,0 @@
--- @configure_input@
--- System-dependent values used by Distribution.Simple.defaultUserHooks
---
-buildable: @BUILD_PACKAGE_BOOL@
-ghc-options: -DCALLCONV=@CALLCONV@
-cc-options: -DCALLCONV=@CALLCONV@ @GLU_CFLAGS@
-ld-options: @GLU_LIBS@
-frameworks: @GLU_FRAMEWORKS@
diff --git a/OpenGL.cabal b/OpenGL.cabal
--- a/OpenGL.cabal
+++ b/OpenGL.cabal
@@ -1,119 +1,107 @@
-name:		OpenGL
-version:	2.2.3.1
-license:	BSD3
-license-file:	LICENSE
-maintainer:	Sven Panne <sven.panne@aedion.de>
-bug-reports:	mailto:hopengl@haskell.org
-homepage:	http://www.haskell.org/HOpenGL/
-category:	Graphics
-synopsis:	A binding for the OpenGL graphics system
+name: OpenGL
+version: 2.3.0.0
+license: BSD3
+license-file: LICENSE
+maintainer: Sven Panne <sven.panne@aedion.de>
+bug-reports: mailto:hopengl@haskell.org
+homepage: http://www.haskell.org/HOpenGL/
+category: Graphics
+synopsis: A binding for the OpenGL graphics system
 description:
-	A Haskell binding for the OpenGL graphics system (GL, version
-	2.1) and its accompanying utility library (GLU, version 1.3).
-	OpenGL is the industry's most widely used and supported 2D and 3D
-	graphics application programming interface (API), incorporating
-	a broad set of rendering, texture mapping, special effects, and
-	other powerful visualization functions.  For more information
-	about OpenGL, please see: <http://www.opengl.org/>.
-build-type:     Configure
-extra-source-files:
-	OpenGL.buildinfo.in README aclocal.m4 config.guess config.sub configure
-	configure.ac include/HsOpenGL.h.in include/HsOpenGLExt.h
-	include/HsOpenGLTypes.h install-sh include/HsOpenGLConfig.h.in
-extra-tmp-files:
-	config.log config.status autom4te.cache
-	OpenGL.buildinfo include/HsOpenGLConfig.h include/HsOpenGL.h
+   A Haskell binding for the OpenGL graphics system (GL, version 2.1) and its
+   accompanying utility library (GLU, version 1.3).
+   .
+   OpenGL is the industry's most widely used and supported 2D and 3D graphics
+   application programming interface (API), incorporating a broad set of
+   rendering, texture mapping, special effects, and other powerful visualization
+   functions. For more information about OpenGL and its various extensions,
+   please see <http://www.opengl.org/>
+   and <http://www.opengl.org/registry/>.
+build-type: Simple
 exposed-modules:
-	Graphics.Rendering.OpenGL.GL.Antialiasing,
-	Graphics.Rendering.OpenGL.GL.BasicTypes,
-	Graphics.Rendering.OpenGL.GL.BeginEnd,
-	Graphics.Rendering.OpenGL.GL.Bitmaps,
-	Graphics.Rendering.OpenGL.GL.BufferObjects,
-	Graphics.Rendering.OpenGL.GL.Clipping,
-	Graphics.Rendering.OpenGL.GL.Colors,
-	Graphics.Rendering.OpenGL.GL.ColorSum,
-	Graphics.Rendering.OpenGL.GL.CoordTrans,
-	Graphics.Rendering.OpenGL.GL.DisplayLists,
-	Graphics.Rendering.OpenGL.GL.Evaluators,
-	Graphics.Rendering.OpenGL.GL.Feedback,
-	Graphics.Rendering.OpenGL.GL.FlushFinish,
-	Graphics.Rendering.OpenGL.GL.Fog,
-	Graphics.Rendering.OpenGL.GL.Framebuffer,
-	Graphics.Rendering.OpenGL.GL.Hints,
-	Graphics.Rendering.OpenGL.GL,
-	Graphics.Rendering.OpenGL.GL.LineSegments,
-	Graphics.Rendering.OpenGL.GL.PerFragment,
-	Graphics.Rendering.OpenGL.GL.PixelRectangles.ColorTable,
-	Graphics.Rendering.OpenGL.GL.PixelRectangles.Convolution,
-	Graphics.Rendering.OpenGL.GL.PixelRectangles.Histogram,
-	Graphics.Rendering.OpenGL.GL.PixelRectangles,
-	Graphics.Rendering.OpenGL.GL.PixelRectangles.Minmax,
-	Graphics.Rendering.OpenGL.GL.PixelRectangles.PixelMap,
-	Graphics.Rendering.OpenGL.GL.PixelRectangles.PixelStorage,
-	Graphics.Rendering.OpenGL.GL.PixelRectangles.PixelTransfer,
-	Graphics.Rendering.OpenGL.GL.PixelRectangles.Rasterization,
-	Graphics.Rendering.OpenGL.GL.Points,
-	Graphics.Rendering.OpenGL.GL.Polygons,
-	Graphics.Rendering.OpenGL.GL.RasterPos,
-	Graphics.Rendering.OpenGL.GL.ReadCopyPixels,
-	Graphics.Rendering.OpenGL.GL.Rectangles,
-	Graphics.Rendering.OpenGL.GL.SavingState,
-	Graphics.Rendering.OpenGL.GL.Selection,
-	Graphics.Rendering.OpenGL.GL.Shaders,
-	Graphics.Rendering.OpenGL.GL.StateVar,
-	Graphics.Rendering.OpenGL.GL.StringQueries,
-	Graphics.Rendering.OpenGL.GL.Texturing.Application,
-	Graphics.Rendering.OpenGL.GL.Texturing.Environments,
-	Graphics.Rendering.OpenGL.GL.Texturing,
-	Graphics.Rendering.OpenGL.GL.Texturing.Objects,
-	Graphics.Rendering.OpenGL.GL.Texturing.Parameters,
-	Graphics.Rendering.OpenGL.GL.Texturing.Queries,
-	Graphics.Rendering.OpenGL.GL.Texturing.Specification,
-	Graphics.Rendering.OpenGL.GLU.Errors,
-	Graphics.Rendering.OpenGL.GLU,
-	Graphics.Rendering.OpenGL.GLU.Initialization,
-	Graphics.Rendering.OpenGL.GLU.Matrix,
-	Graphics.Rendering.OpenGL.GLU.Mipmapping,
-	Graphics.Rendering.OpenGL.GLU.NURBS,
-	Graphics.Rendering.OpenGL.GLU.Quadrics,
-	Graphics.Rendering.OpenGL.GLU.Tessellation,
-	Graphics.Rendering.OpenGL.GL.VertexArrays,
-	Graphics.Rendering.OpenGL.GL.VertexSpec,
-	Graphics.Rendering.OpenGL
+   Graphics.Rendering.OpenGL.GL.Antialiasing,
+   Graphics.Rendering.OpenGL.GL.BeginEnd,
+   Graphics.Rendering.OpenGL.GL.Bitmaps,
+   Graphics.Rendering.OpenGL.GL.BufferObjects,
+   Graphics.Rendering.OpenGL.GL.Clipping,
+   Graphics.Rendering.OpenGL.GL.Colors,
+   Graphics.Rendering.OpenGL.GL.ColorSum,
+   Graphics.Rendering.OpenGL.GL.CoordTrans,
+   Graphics.Rendering.OpenGL.GL.DisplayLists,
+   Graphics.Rendering.OpenGL.GL.Evaluators,
+   Graphics.Rendering.OpenGL.GL.Feedback,
+   Graphics.Rendering.OpenGL.GL.FlushFinish,
+   Graphics.Rendering.OpenGL.GL.Fog,
+   Graphics.Rendering.OpenGL.GL.Framebuffer,
+   Graphics.Rendering.OpenGL.GL.Hints,
+   Graphics.Rendering.OpenGL.GL,
+   Graphics.Rendering.OpenGL.GL.LineSegments,
+   Graphics.Rendering.OpenGL.GL.PerFragment,
+   Graphics.Rendering.OpenGL.GL.PixelRectangles.ColorTable,
+   Graphics.Rendering.OpenGL.GL.PixelRectangles.Convolution,
+   Graphics.Rendering.OpenGL.GL.PixelRectangles.Histogram,
+   Graphics.Rendering.OpenGL.GL.PixelRectangles,
+   Graphics.Rendering.OpenGL.GL.PixelRectangles.Minmax,
+   Graphics.Rendering.OpenGL.GL.PixelRectangles.PixelMap,
+   Graphics.Rendering.OpenGL.GL.PixelRectangles.PixelStorage,
+   Graphics.Rendering.OpenGL.GL.PixelRectangles.PixelTransfer,
+   Graphics.Rendering.OpenGL.GL.PixelRectangles.Rasterization,
+   Graphics.Rendering.OpenGL.GL.Points,
+   Graphics.Rendering.OpenGL.GL.Polygons,
+   Graphics.Rendering.OpenGL.GL.RasterPos,
+   Graphics.Rendering.OpenGL.GL.ReadCopyPixels,
+   Graphics.Rendering.OpenGL.GL.Rectangles,
+   Graphics.Rendering.OpenGL.GL.SavingState,
+   Graphics.Rendering.OpenGL.GL.Selection,
+   Graphics.Rendering.OpenGL.GL.Shaders,
+   Graphics.Rendering.OpenGL.GL.StringQueries,
+   Graphics.Rendering.OpenGL.GL.Texturing.Application,
+   Graphics.Rendering.OpenGL.GL.Texturing.Environments,
+   Graphics.Rendering.OpenGL.GL.Texturing,
+   Graphics.Rendering.OpenGL.GL.Texturing.Objects,
+   Graphics.Rendering.OpenGL.GL.Texturing.Parameters,
+   Graphics.Rendering.OpenGL.GL.Texturing.Queries,
+   Graphics.Rendering.OpenGL.GL.Texturing.Specification,
+   Graphics.Rendering.OpenGL.GLU.Errors,
+   Graphics.Rendering.OpenGL.GLU,
+   Graphics.Rendering.OpenGL.GLU.Initialization,
+   Graphics.Rendering.OpenGL.GLU.Matrix,
+   Graphics.Rendering.OpenGL.GLU.Mipmapping,
+   Graphics.Rendering.OpenGL.GLU.NURBS,
+   Graphics.Rendering.OpenGL.GLU.Quadrics,
+   Graphics.Rendering.OpenGL.GLU.Tessellation,
+   Graphics.Rendering.OpenGL.GL.VertexArrays,
+   Graphics.Rendering.OpenGL.GL.VertexSpec,
+   Graphics.Rendering.OpenGL
 other-modules:
-	Graphics.Rendering.OpenGL.GL.BlendingFactor,
-	Graphics.Rendering.OpenGL.GL.BufferMode,
-	Graphics.Rendering.OpenGL.GL.Capability,
-	Graphics.Rendering.OpenGL.GL.ComparisonFunction,
-	Graphics.Rendering.OpenGL.GL.ControlPoint,
-	Graphics.Rendering.OpenGL.GL.DataType,
-	Graphics.Rendering.OpenGL.GL.Domain,
-	Graphics.Rendering.OpenGL.GL.EdgeFlag,
-	Graphics.Rendering.OpenGL.GL.Exception,
-	Graphics.Rendering.OpenGL.GL.Extensions,
-	Graphics.Rendering.OpenGL.GL.Face,
-	Graphics.Rendering.OpenGL.GL.GLboolean,
-	Graphics.Rendering.OpenGL.GL.IOState,
-	Graphics.Rendering.OpenGL.GL.PeekPoke,
-	Graphics.Rendering.OpenGL.GL.PixelData,
-	Graphics.Rendering.OpenGL.GL.PixelFormat,
-	Graphics.Rendering.OpenGL.GL.PixelRectangles.Reset,
-	Graphics.Rendering.OpenGL.GL.PixelRectangles.Sink,
-	Graphics.Rendering.OpenGL.GL.PointParameter,
-	Graphics.Rendering.OpenGL.GL.PolygonMode,
-	Graphics.Rendering.OpenGL.GL.PrimitiveMode,
-	Graphics.Rendering.OpenGL.GL.QueryUtils,
-	Graphics.Rendering.OpenGL.GL.RenderMode,
-	Graphics.Rendering.OpenGL.GL.Tensor,
-	Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat,
-	Graphics.Rendering.OpenGL.GL.Texturing.TexParameter,
-	Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget,
-	Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit,
-	Graphics.Rendering.OpenGL.GL.VertexAttributes,
-	Graphics.Rendering.OpenGL.GLU.ErrorsInternal
-c-sources:	cbits/HsOpenGL.c
-include-dirs:	include
-includes: HsOpenGL.h
-install-includes: HsOpenGL.h
-build-depends:	base < 5
-extensions:	CPP, ForeignFunctionInterface
+   Graphics.Rendering.OpenGL.GL.BlendingFactor,
+   Graphics.Rendering.OpenGL.GL.BufferMode,
+   Graphics.Rendering.OpenGL.GL.Capability,
+   Graphics.Rendering.OpenGL.GL.ComparisonFunction,
+   Graphics.Rendering.OpenGL.GL.ControlPoint,
+   Graphics.Rendering.OpenGL.GL.DataType,
+   Graphics.Rendering.OpenGL.GL.Domain,
+   Graphics.Rendering.OpenGL.GL.EdgeFlag,
+   Graphics.Rendering.OpenGL.GL.Exception,
+   Graphics.Rendering.OpenGL.GL.Face,
+   Graphics.Rendering.OpenGL.GL.GLboolean,
+   Graphics.Rendering.OpenGL.GL.IOState,
+   Graphics.Rendering.OpenGL.GL.PeekPoke,
+   Graphics.Rendering.OpenGL.GL.PixelData,
+   Graphics.Rendering.OpenGL.GL.PixelFormat,
+   Graphics.Rendering.OpenGL.GL.PixelRectangles.Reset,
+   Graphics.Rendering.OpenGL.GL.PixelRectangles.Sink,
+   Graphics.Rendering.OpenGL.GL.PointParameter,
+   Graphics.Rendering.OpenGL.GL.PolygonMode,
+   Graphics.Rendering.OpenGL.GL.PrimitiveMode,
+   Graphics.Rendering.OpenGL.GL.QueryUtils,
+   Graphics.Rendering.OpenGL.GL.RenderMode,
+   Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat,
+   Graphics.Rendering.OpenGL.GL.Texturing.TexParameter,
+   Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget,
+   Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit,
+   Graphics.Rendering.OpenGL.GL.VertexAttributes,
+   Graphics.Rendering.OpenGL.GLU.ErrorsInternal
+ghc-options: -Wall
+build-depends:
+   base >= 3 && < 5, OpenGLRaw >= 1.0.1.0, GLURaw, StateVar, ObjectName, Tensor
diff --git a/README b/README
deleted file mode 100644
--- a/README
+++ /dev/null
@@ -1,4 +0,0 @@
-To build this package using Cabal directly from darcs, you must run
-"autoreconf" before the usual Cabal build steps (configure/build/install).
-autoreconf is included in the GNU autoconf tools.  There is no need to run
-the "configure" script: the "setup configure" step will do this for you.
diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,6 +1,2 @@
-module Main (main) where
-
 import Distribution.Simple
-
-main :: IO ()
-main = defaultMainWithHooks autoconfUserHooks
+main = defaultMain
diff --git a/aclocal.m4 b/aclocal.m4
deleted file mode 100644
--- a/aclocal.m4
+++ /dev/null
@@ -1,288 +0,0 @@
-# Extra autoconf macros for the Glasgow fptools
-#
-# To be a good autoconf citizen, names of local macros have prefixed with FP_ to
-# ensure we don't clash with any pre-supplied autoconf ones.
-
-dnl ** Map an arithmetic C type to a Haskell type.
-dnl    Based on autconf's AC_CHECK_SIZEOF.
-
-dnl FPTOOLS_CHECK_HTYPE(TYPE [, DEFAULT_VALUE, [, VALUE-FOR-CROSS-COMPILATION])
-AC_DEFUN([FPTOOLS_CHECK_HTYPE],
-[changequote(<<, >>)dnl
-dnl The name to #define.
-define(<<AC_TYPE_NAME>>, translit(htype_$1, [a-z *], [A-Z_P]))dnl
-dnl The cache variable name.
-define(<<AC_CV_NAME>>, translit(fptools_cv_htype_$1, [ *], [_p]))dnl
-define(<<AC_CV_NAME_supported>>, translit(fptools_cv_htype_sup_$1, [ *], [_p]))dnl
-changequote([, ])dnl
-AC_MSG_CHECKING(Haskell type for $1)
-AC_CACHE_VAL(AC_CV_NAME,
-[AC_CV_NAME_supported=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef $1 testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}]])],[AC_CV_NAME=`cat conftestval`],
-[ifelse([$2], , [AC_CV_NAME=NotReallyAType; AC_CV_NAME_supported=no], [AC_CV_NAME=$2])],
-[ifelse([$3], , [AC_CV_NAME=NotReallyATypeCross; AC_CV_NAME_supported=no], [AC_CV_NAME=$3])])
-CPPFLAGS="$fp_check_htype_save_cppflags"]) dnl
-if test "$AC_CV_NAME_supported" = yes; then
-  AC_MSG_RESULT($AC_CV_NAME)
-  AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [Define to Haskell type for $1])
-else
-  AC_MSG_RESULT([not supported])
-fi
-undefine([AC_TYPE_NAME])dnl
-undefine([AC_CV_NAME])dnl
-undefine([AC_CV_NAME_supported])dnl
-])
-
-
-# FP_ARG_OPENGL
-# -------------
-AC_DEFUN([FP_ARG_OPENGL],
-[AC_ARG_ENABLE([opengl],
-  [AC_HELP_STRING([--enable-opengl],
-    [build a Haskell binding for OpenGL (GL/GLU). On Mac OS X, use
-     --enable-opengl=x11 to use X11 instead of the "native" libraries.
-     (default=autodetect)])],
-  [enable_opengl=$enableval],
-  [enable_opengl=yes])
-])# FP_ARG_OPENGL
-
-
-# FP_CHECK_QUARTZ_OPENGL
-# ----------------------
-AC_DEFUN([FP_CHECK_QUARTZ_OPENGL],
-[AC_REQUIRE([FP_ARG_OPENGL])
-AC_REQUIRE([AC_CANONICAL_TARGET])
-
-use_quartz_opengl=no
-if test x"$enable_opengl" = xyes; then
-  case $target_os in
-  darwin*)
-    AC_DEFINE([USE_QUARTZ_OPENGL], [1],
-              [Define to 1 if native OpenGL should be used on Mac OS X])
-    use_quartz_opengl=yes
-    ;;
-  esac
-fi
-
-GLU_FRAMEWORKS=
-GLUT_FRAMEWORKS=
-if test x"$use_quartz_opengl" = xyes; then
-  GLU_FRAMEWORKS=OpenGL
-  GLUT_FRAMEWORKS=GLUT
-fi
-AC_SUBST([GLU_FRAMEWORKS])
-AC_SUBST([GLUT_FRAMEWORKS])
-])# FP_CHECK_QUARTZ_OPENGL
-
-
-# FP_CHECK_WIN32
-# --------------
-# If Windows is the target platform (e.g. MinGW/MSYS or Cygwin with
-# -mno-cygwin), the variable "fp_is_win32" is set to "yes", otherwise (e.g. *nix
-# systems or plain Cygwin) it is set to "no".
-AC_DEFUN([FP_CHECK_WIN32],
-[AC_CACHE_CHECK([for Windows environment], [fp_cv_is_win32],
-  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
-#if !_WIN32
-   syntax error;
-#endif
-])], [fp_cv_is_win32=yes], [fp_cv_is_win32=no])])
-fp_is_win32="$fp_cv_is_win32"[]dnl
-])# FP_CHECK_WIN32
-
-
-# FP_PATH_XTRA
-# ------------
-# Same as AC_PATH_XTRA, but works even for broken Cygwins which try to include
-# the non-existant <gl/mesa_wgl.h> header when -mno-cygwin is used.
-AC_DEFUN([FP_PATH_XTRA],
-[AC_REQUIRE([FP_CHECK_WIN32])
-if test x"$fp_is_win32" = xyes; then
-  no_x=yes
-else
-  AC_PATH_XTRA
-fi
-])# FP_PATH_XTRA
-
-
-# FP_CHECK_GL_HELPER(LIBNAME, LIBS, INCLUDES, FUNCTION-BODY)
-# ----------------------------------------------------------
-# Try each library in LIBS to successfully link INCLUDES plus FUNCTION-BODY,
-# setting LIBNAME_CFLAGS and LIBNAME_LIBS to the corresponding values. Sets
-# no_LIBNAME to "yes" if no suitable library was found. (LIBNAME_CFLAGS0
-# contains the value of LIBNAME_CFLAGS without CPPFLAGS, and LIBNAME_LIBS0
-# contains the value of LIBNAME_LIBS without LDFLAGS, but these are only
-# used internally.)
-AC_DEFUN([FP_CHECK_GL_HELPER],
-[AC_CACHE_CHECK([for $1 library], [fp_cv_check_$1_lib],
-  [fp_cv_check_$1_lib="no"
-  fp_save_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS ${$1_CFLAGS}"
-  fp_save_LIBS="$LIBS"
-  for fp_try_lib in $2; do
-    # transform "-lfoo" to "foo.lib" when using cl
-    if test x"$CC" = xcl; then
-      fp_try_lib=`echo $fp_try_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
-    fi
-    LIBS="$fp_try_lib ${$1_LIBS} $fp_save_LIBS"
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([$3], [$4])], [fp_cv_check_$1_lib="$fp_try_lib ${$1_LIBS}"; break])
-  done
-  LIBS="$fp_save_LIBS"
-  CPPFLAGS="$fp_save_CPPFLAGS"])
-
-  if test x"$fp_cv_check_$1_lib" = xno; then
-    no_$1=yes
-    $1_CFLAGS=
-    $1_LIBS=
-  else
-    $1_CFLAGS0="${$1_CFLAGS}"
-    $1_CFLAGS="$CPPFLAGS ${$1_CFLAGS0}"
-    $1_LIBS0="$fp_cv_check_$1_lib"
-    $1_LIBS="$LDFLAGS ${$1_LIBS0}"
-  fi
-])# FP_CHECK_GL_HELPER
-
-
-# FP_CHECK_GL
-# -----------
-AC_DEFUN([FP_CHECK_GL],
-[AC_REQUIRE([FP_PATH_XTRA])
-AC_REQUIRE([FP_CHECK_QUARTZ_OPENGL])
-AC_REQUIRE([FP_CHECK_WIN32])
-
-if test x"$use_quartz_opengl" = xno; then
-  AC_CHECK_FUNC(atan,[fp_libm_not_needed=yes],[fp_libm_not_needed=dunno])
-  if test x"$fp_libm_not_needed" = xdunno; then
-     AC_CHECK_LIB([m], [atan], [GL_LIBS="-lm $GL_LIBS"])
-  fi
-
-  if test x"$no_x" != xyes; then
-    test -n "$x_includes" && GL_CFLAGS="-I$x_includes $GL_CFLAGS"
-    test -n "$x_libraries" && GL_LIBS="-L$x_libraries -lX11 $GL_LIBS"
-  fi
-
-  FP_CHECK_GL_HELPER([GL], [-lGL -lopengl32], [@%:@include <GL/gl.h>], [glEnd()])
-
-  if test x"$fp_is_win32" = xyes; then
-    # Ugly: To get wglGetProcAddress on Windows, we have to link with
-    # opengl32.dll, too, even when we are using Cygwin with X11.
-    case "$GL_LIBS" in
-      *-lopengl32*|*opengl32.lib*) ;;
-      *) fp_save_LIBS="$LIBS"
-         LIBS="$LIBS -lopengl32"
-         AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <GL/gl.h>]], [[glEnd()]])],
-           [GL_LIBS="$GL_LIBS -lopengl32"; GL_LIBS0="$GL_LIBS0 -lopengl32"])
-         LIBS="$fp_save_LIBS"
-         ;;
-    esac
-  fi
-fi
-AC_SUBST([GL_CFLAGS])
-AC_SUBST([GL_LIBS])
-])# FP_CHECK_GL
-
-
-# FP_CHECK_GLU
-# ------------
-AC_DEFUN([FP_CHECK_GLU],
-[AC_REQUIRE([FP_CHECK_GL])dnl
-GLU_CFLAGS="$GL_CFLAGS0"
-GLU_LIBS="$GL_LIBS0"
-
-if test x"$use_quartz_opengl" = xno; then
-  FP_CHECK_GL_HELPER([GLU], [-lglu32 -lGLU], [@%:@include <GL/glu.h>], [gluNewQuadric()])
-fi
-
-AC_SUBST([GLU_CFLAGS])
-AC_SUBST([GLU_LIBS])
-])# FP_CHECK_GLU
-
-
-# FP_ARG_COMPILER
-# -------------
-AC_DEFUN([FP_ARG_COMPILER],
-[AC_ARG_WITH([compiler],
-  [AC_HELP_STRING([--with-compiler@<:@=HC@:>@],
-    [use the given Haskell compiler (default=ghc)])],
-  [with_compiler=$withval],
-  [with_compiler=ghc])
-])# FP_ARG_COMPILER
diff --git a/cbits/HsOpenGL.c b/cbits/HsOpenGL.c
deleted file mode 100644
--- a/cbits/HsOpenGL.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -----------------------------------------------------------------------------
- *
- * Module      :  C support for Graphics.Rendering.OpenGL.GL.Extensions
- * Copyright   :  (c) Sven Panne 2002-2005
- * License     :  BSD-style (see the file libraries/GLUT/LICENSE)
- * 
- * Maintainer  :  sven.panne@aedion.de
- * Stability   :  experimental
- * Portability :  portable
- *
- * -------------------------------------------------------------------------- */
-
-#include "HsOpenGL.h"
-#include <string.h>
-
-#if defined(_WIN32)
-#define hs_OpenGL_gpa(x) wglGetProcAddress((LPCSTR)(x))
-#elif defined(USE_QUARTZ_OPENGL)
-#include <mach-o/dyld.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-static void*
-hs_OpenGL_gpa(const char *name)
-{
-  NSSymbol symbol;
-
-  /* Prepend a '_' for the Unix C symbol mangling convention */
-  char* symbolName = (char*)malloc(strlen(name) + 2);
-  if (!symbolName) {
-    fprintf(stderr, "Failed to allocate memory for NSGLGetProcAddress\n");
-    return NULL;
-  }
-  symbolName[0] = '_';
-  strcpy(symbolName + 1, name);
-
-  if (!NSIsSymbolNameDefined(symbolName)) {
-    free(symbolName);
-    return NULL;
-  }
-
-  symbol = NSLookupAndBindSymbol(symbolName);
-  free(symbolName);
-  if (!symbol) {
-    return NULL;
-  }
-
-  return NSAddressOfSymbol(symbol);
-}
-
-/* ToDo: This should really be based on a feature test. */
-#elif defined(__sgi) || defined (__sun)
-#include <dlfcn.h>
-
-static const char* gpaNames[] = {
-  "glXGetProcAddress", "glXGetProcAddressARB", "glXGetProcAddressEXT",
-  "_glXGetProcAddress", "_glXGetProcAddressARB", "_glXGetProcAddressEXT"
-};
-
-static void*
-hs_OpenGL_gpa(const char *name)
-{
-  static int firstTime = 1;
-  static void *handle = NULL;
-  static void *gpa = NULL;
-
-  if (firstTime) {
-    firstTime = 0;
-
-    /* Get a handle for our executable. */
-    handle = dlopen(NULL, RTLD_LAZY);
-    /* If fail this early, there's not much we can do about it. */
-    if (!handle) {
-      return NULL;
-    }
-
-    {
-      /* Let's see if our platform supports a glXGetProcAddress() variant. */
-      int numNames = (int)(sizeof(gpaNames) / sizeof(gpaNames[0]));
-      int i;
-      for (i = 0;   (!gpa) && (i < numNames);   ++i) {
-        gpa = dlsym(handle, gpaNames[i]);
-      }
-    }
-  }
-
-  if (gpa) {
-    /* Fine, we seem to have some kind of glXGetProcAddress(), so use it. */
-    return ((void *(*)(const GLubyte *))gpa)(name);
-  } else if (handle) {
-    /* Fallback to dlsym() if we have no glXGetProcAddress(), although we then
-       ignore the fact that OpenGL entry points could be context dependent. */
-    return dlsym(handle, name);
-  } else {
-    return NULL;
-  }
-}
-
-#else
-#define hs_OpenGL_gpa(x) glXGetProcAddressARB((const GLubyte*)(x))
-#endif
-
-
-/* procName is really a const char*, but currently we can't specify this in
-   Haskell's FFI and consequently get a warning from the C compiler. */
-void*
-hs_OpenGL_getProcAddress(char *procName)
-{
-  void* addr = hs_OpenGL_gpa(procName);
-  if (addr) {
-    return addr;
-  }
-  /* There is no way to get GLU extensions at runtime so we fake this, being
-     careful about GLU headers on WinDoze, which have a bad habit of lying
-     about their actual version. */
-#if defined(GLU_VERSION_1_3) && !defined(_WIN32)
-  if (strcmp(procName, "gluUnProject4") == 0) {
-    return gluUnProject4;
-  }
-  if (strcmp(procName, "gluBuild3DMipmapLevels") == 0) {
-    return gluBuild3DMipmapLevels;
-  }
-#endif
-  return NULL;
-}
diff --git a/config.guess b/config.guess
deleted file mode 100644
--- a/config.guess
+++ /dev/null
@@ -1,1497 +0,0 @@
-#! /bin/sh
-# Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2006-02-23'
-
-# This file is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner <per@bothner.com>.
-# Please send patches to <config-patches@gnu.org>.  Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# This script attempts to guess a canonical system name similar to
-# config.sub.  If it succeeds, it prints the system name on stdout, and
-# exits with 0.  Otherwise, it exits with 1.
-#
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION]
-
-Output the configuration name of the system \`$me' is run on.
-
-Operation modes:
-  -h, --help         print this help, then exit
-  -t, --time-stamp   print date of last modification, then exit
-  -v, --version      print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.guess ($timestamp)
-
-Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions.  There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
-  case $1 in
-    --time-stamp | --time* | -t )
-       echo "$timestamp" ; exit ;;
-    --version | -v )
-       echo "$version" ; exit ;;
-    --help | --h* | -h )
-       echo "$usage"; exit ;;
-    -- )     # Stop option processing
-       shift; break ;;
-    - )	# Use stdin as input.
-       break ;;
-    -* )
-       echo "$me: invalid option $1$help" >&2
-       exit 1 ;;
-    * )
-       break ;;
-  esac
-done
-
-if test $# != 0; then
-  echo "$me: too many arguments$help" >&2
-  exit 1
-fi
-
-trap 'exit 1' 1 2 15
-
-# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
-# compiler to aid in system detection is discouraged as it requires
-# temporary files to be created and, as you can see below, it is a
-# headache to deal with in a portable fashion.
-
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-# use `HOST_CC' if defined, but it is deprecated.
-
-# Portable tmp directory creation inspired by the Autoconf team.
-
-set_cc_for_build='
-trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
-trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
-: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
-dummy=$tmp/dummy ;
-tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,)    echo "int x;" > $dummy.c ;
-	for c in cc gcc c89 c99 ; do
-	  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
-	     CC_FOR_BUILD="$c"; break ;
-	  fi ;
-	done ;
-	if test x"$CC_FOR_BUILD" = x ; then
-	  CC_FOR_BUILD=no_compiler_found ;
-	fi
-	;;
- ,,*)   CC_FOR_BUILD=$CC ;;
- ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
-esac ; set_cc_for_build= ;'
-
-# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi@noc.rutgers.edu 1994-08-24)
-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
-	PATH=$PATH:/.attbin ; export PATH
-fi
-
-UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
-UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
-UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-
-# Note: order is significant - the case branches are not exclusive.
-
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
-    *:NetBSD:*:*)
-	# NetBSD (nbsd) targets should (where applicable) match one or
-	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
-	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
-	# switched to ELF, *-*-netbsd* would select the old
-	# object file format.  This provides both forward
-	# compatibility and a consistent mechanism for selecting the
-	# object file format.
-	#
-	# Note: NetBSD doesn't particularly care about the vendor
-	# portion of the name.  We always set it to "unknown".
-	sysctl="sysctl -n hw.machine_arch"
-	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
-	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
-	case "${UNAME_MACHINE_ARCH}" in
-	    armeb) machine=armeb-unknown ;;
-	    arm*) machine=arm-unknown ;;
-	    sh3el) machine=shl-unknown ;;
-	    sh3eb) machine=sh-unknown ;;
-	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
-	esac
-	# The Operating System including object format, if it has switched
-	# to ELF recently, or will in the future.
-	case "${UNAME_MACHINE_ARCH}" in
-	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
-		eval $set_cc_for_build
-		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
-			| grep __ELF__ >/dev/null
-		then
-		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
-		    # Return netbsd for either.  FIX?
-		    os=netbsd
-		else
-		    os=netbsdelf
-		fi
-		;;
-	    *)
-	        os=netbsd
-		;;
-	esac
-	# The OS release
-	# Debian GNU/NetBSD machines have a different userland, and
-	# thus, need a distinct triplet. However, they do not need
-	# kernel version information, so it can be replaced with a
-	# suitable tag, in the style of linux-gnu.
-	case "${UNAME_VERSION}" in
-	    Debian*)
-		release='-gnu'
-		;;
-	    *)
-		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-		;;
-	esac
-	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
-	# contains redundant information, the shorter form:
-	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
-	echo "${machine}-${os}${release}"
-	exit ;;
-    *:OpenBSD:*:*)
-	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
-	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
-	exit ;;
-    *:ekkoBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
-	exit ;;
-    *:SolidBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
-	exit ;;
-    macppc:MirBSD:*:*)
-	echo powerppc-unknown-mirbsd${UNAME_RELEASE}
-	exit ;;
-    *:MirBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
-	exit ;;
-    alpha:OSF1:*:*)
-	case $UNAME_RELEASE in
-	*4.0)
-		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
-		;;
-	*5.*)
-	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
-		;;
-	esac
-	# According to Compaq, /usr/sbin/psrinfo has been available on
-	# OSF/1 and Tru64 systems produced since 1995.  I hope that
-	# covers most systems running today.  This code pipes the CPU
-	# types through head -n 1, so we only detect the type of CPU 0.
-	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
-	case "$ALPHA_CPU_TYPE" in
-	    "EV4 (21064)")
-		UNAME_MACHINE="alpha" ;;
-	    "EV4.5 (21064)")
-		UNAME_MACHINE="alpha" ;;
-	    "LCA4 (21066/21068)")
-		UNAME_MACHINE="alpha" ;;
-	    "EV5 (21164)")
-		UNAME_MACHINE="alphaev5" ;;
-	    "EV5.6 (21164A)")
-		UNAME_MACHINE="alphaev56" ;;
-	    "EV5.6 (21164PC)")
-		UNAME_MACHINE="alphapca56" ;;
-	    "EV5.7 (21164PC)")
-		UNAME_MACHINE="alphapca57" ;;
-	    "EV6 (21264)")
-		UNAME_MACHINE="alphaev6" ;;
-	    "EV6.7 (21264A)")
-		UNAME_MACHINE="alphaev67" ;;
-	    "EV6.8CB (21264C)")
-		UNAME_MACHINE="alphaev68" ;;
-	    "EV6.8AL (21264B)")
-		UNAME_MACHINE="alphaev68" ;;
-	    "EV6.8CX (21264D)")
-		UNAME_MACHINE="alphaev68" ;;
-	    "EV6.9A (21264/EV69A)")
-		UNAME_MACHINE="alphaev69" ;;
-	    "EV7 (21364)")
-		UNAME_MACHINE="alphaev7" ;;
-	    "EV7.9 (21364A)")
-		UNAME_MACHINE="alphaev79" ;;
-	esac
-	# A Pn.n version is a patched version.
-	# A Vn.n version is a released version.
-	# A Tn.n version is a released field test version.
-	# A Xn.n version is an unreleased experimental baselevel.
-	# 1.2 uses "1.2" for uname -r.
-	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-	exit ;;
-    Alpha\ *:Windows_NT*:*)
-	# How do we know it's Interix rather than the generic POSIX subsystem?
-	# Should we change UNAME_MACHINE based on the output of uname instead
-	# of the specific Alpha model?
-	echo alpha-pc-interix
-	exit ;;
-    21064:Windows_NT:50:3)
-	echo alpha-dec-winnt3.5
-	exit ;;
-    Amiga*:UNIX_System_V:4.0:*)
-	echo m68k-unknown-sysv4
-	exit ;;
-    *:[Aa]miga[Oo][Ss]:*:*)
-	echo ${UNAME_MACHINE}-unknown-amigaos
-	exit ;;
-    *:[Mm]orph[Oo][Ss]:*:*)
-	echo ${UNAME_MACHINE}-unknown-morphos
-	exit ;;
-    *:OS/390:*:*)
-	echo i370-ibm-openedition
-	exit ;;
-    *:z/VM:*:*)
-	echo s390-ibm-zvmoe
-	exit ;;
-    *:OS400:*:*)
-        echo powerpc-ibm-os400
-	exit ;;
-    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
-	echo arm-acorn-riscix${UNAME_RELEASE}
-	exit ;;
-    arm:riscos:*:*|arm:RISCOS:*:*)
-	echo arm-unknown-riscos
-	exit ;;
-    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
-	echo hppa1.1-hitachi-hiuxmpp
-	exit ;;
-    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
-	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
-	if test "`(/bin/universe) 2>/dev/null`" = att ; then
-		echo pyramid-pyramid-sysv3
-	else
-		echo pyramid-pyramid-bsd
-	fi
-	exit ;;
-    NILE*:*:*:dcosx)
-	echo pyramid-pyramid-svr4
-	exit ;;
-    DRS?6000:unix:4.0:6*)
-	echo sparc-icl-nx6
-	exit ;;
-    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
-	case `/usr/bin/uname -p` in
-	    sparc) echo sparc-icl-nx7; exit ;;
-	esac ;;
-    sun4H:SunOS:5.*:*)
-	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit ;;
-    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
-	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit ;;
-    i86pc:SunOS:5.*:*)
-	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit ;;
-    sun4*:SunOS:6*:*)
-	# According to config.sub, this is the proper way to canonicalize
-	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
-	# it's likely to be more like Solaris than SunOS4.
-	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit ;;
-    sun4*:SunOS:*:*)
-	case "`/usr/bin/arch -k`" in
-	    Series*|S4*)
-		UNAME_RELEASE=`uname -v`
-		;;
-	esac
-	# Japanese Language versions have a version number like `4.1.3-JL'.
-	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
-	exit ;;
-    sun3*:SunOS:*:*)
-	echo m68k-sun-sunos${UNAME_RELEASE}
-	exit ;;
-    sun*:*:4.2BSD:*)
-	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
-	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
-	case "`/bin/arch`" in
-	    sun3)
-		echo m68k-sun-sunos${UNAME_RELEASE}
-		;;
-	    sun4)
-		echo sparc-sun-sunos${UNAME_RELEASE}
-		;;
-	esac
-	exit ;;
-    aushp:SunOS:*:*)
-	echo sparc-auspex-sunos${UNAME_RELEASE}
-	exit ;;
-    # The situation for MiNT is a little confusing.  The machine name
-    # can be virtually everything (everything which is not
-    # "atarist" or "atariste" at least should have a processor
-    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
-    # to the lowercase version "mint" (or "freemint").  Finally
-    # the system name "TOS" denotes a system which is actually not
-    # MiNT.  But MiNT is downward compatible to TOS, so this should
-    # be no problem.
-    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
-	exit ;;
-    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
-	echo m68k-atari-mint${UNAME_RELEASE}
-        exit ;;
-    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
-	exit ;;
-    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-        echo m68k-milan-mint${UNAME_RELEASE}
-        exit ;;
-    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-        echo m68k-hades-mint${UNAME_RELEASE}
-        exit ;;
-    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-        echo m68k-unknown-mint${UNAME_RELEASE}
-        exit ;;
-    m68k:machten:*:*)
-	echo m68k-apple-machten${UNAME_RELEASE}
-	exit ;;
-    powerpc:machten:*:*)
-	echo powerpc-apple-machten${UNAME_RELEASE}
-	exit ;;
-    RISC*:Mach:*:*)
-	echo mips-dec-mach_bsd4.3
-	exit ;;
-    RISC*:ULTRIX:*:*)
-	echo mips-dec-ultrix${UNAME_RELEASE}
-	exit ;;
-    VAX*:ULTRIX*:*:*)
-	echo vax-dec-ultrix${UNAME_RELEASE}
-	exit ;;
-    2020:CLIX:*:* | 2430:CLIX:*:*)
-	echo clipper-intergraph-clix${UNAME_RELEASE}
-	exit ;;
-    mips:*:*:UMIPS | mips:*:*:RISCos)
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-#ifdef __cplusplus
-#include <stdio.h>  /* for printf() prototype */
-	int main (int argc, char *argv[]) {
-#else
-	int main (argc, argv) int argc; char *argv[]; {
-#endif
-	#if defined (host_mips) && defined (MIPSEB)
-	#if defined (SYSTYPE_SYSV)
-	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
-	#endif
-	#if defined (SYSTYPE_SVR4)
-	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
-	#endif
-	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
-	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
-	#endif
-	#endif
-	  exit (-1);
-	}
-EOF
-	$CC_FOR_BUILD -o $dummy $dummy.c &&
-	  dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
-	  SYSTEM_NAME=`$dummy $dummyarg` &&
-	    { echo "$SYSTEM_NAME"; exit; }
-	echo mips-mips-riscos${UNAME_RELEASE}
-	exit ;;
-    Motorola:PowerMAX_OS:*:*)
-	echo powerpc-motorola-powermax
-	exit ;;
-    Motorola:*:4.3:PL8-*)
-	echo powerpc-harris-powermax
-	exit ;;
-    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
-	echo powerpc-harris-powermax
-	exit ;;
-    Night_Hawk:Power_UNIX:*:*)
-	echo powerpc-harris-powerunix
-	exit ;;
-    m88k:CX/UX:7*:*)
-	echo m88k-harris-cxux7
-	exit ;;
-    m88k:*:4*:R4*)
-	echo m88k-motorola-sysv4
-	exit ;;
-    m88k:*:3*:R3*)
-	echo m88k-motorola-sysv3
-	exit ;;
-    AViiON:dgux:*:*)
-        # DG/UX returns AViiON for all architectures
-        UNAME_PROCESSOR=`/usr/bin/uname -p`
-	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
-	then
-	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
-	       [ ${TARGET_BINARY_INTERFACE}x = x ]
-	    then
-		echo m88k-dg-dgux${UNAME_RELEASE}
-	    else
-		echo m88k-dg-dguxbcs${UNAME_RELEASE}
-	    fi
-	else
-	    echo i586-dg-dgux${UNAME_RELEASE}
-	fi
- 	exit ;;
-    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
-	echo m88k-dolphin-sysv3
-	exit ;;
-    M88*:*:R3*:*)
-	# Delta 88k system running SVR3
-	echo m88k-motorola-sysv3
-	exit ;;
-    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
-	echo m88k-tektronix-sysv3
-	exit ;;
-    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
-	echo m68k-tektronix-bsd
-	exit ;;
-    *:IRIX*:*:*)
-	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
-	exit ;;
-    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
-	echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
-	exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
-    i*86:AIX:*:*)
-	echo i386-ibm-aix
-	exit ;;
-    ia64:AIX:*:*)
-	if [ -x /usr/bin/oslevel ] ; then
-		IBM_REV=`/usr/bin/oslevel`
-	else
-		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
-	fi
-	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
-	exit ;;
-    *:AIX:2:3)
-	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
-		eval $set_cc_for_build
-		sed 's/^		//' << EOF >$dummy.c
-		#include <sys/systemcfg.h>
-
-		main()
-			{
-			if (!__power_pc())
-				exit(1);
-			puts("powerpc-ibm-aix3.2.5");
-			exit(0);
-			}
-EOF
-		if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
-		then
-			echo "$SYSTEM_NAME"
-		else
-			echo rs6000-ibm-aix3.2.5
-		fi
-	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
-		echo rs6000-ibm-aix3.2.4
-	else
-		echo rs6000-ibm-aix3.2
-	fi
-	exit ;;
-    *:AIX:*:[45])
-	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
-	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
-		IBM_ARCH=rs6000
-	else
-		IBM_ARCH=powerpc
-	fi
-	if [ -x /usr/bin/oslevel ] ; then
-		IBM_REV=`/usr/bin/oslevel`
-	else
-		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
-	fi
-	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
-	exit ;;
-    *:AIX:*:*)
-	echo rs6000-ibm-aix
-	exit ;;
-    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
-	echo romp-ibm-bsd4.4
-	exit ;;
-    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
-	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
-	exit ;;                             # report: romp-ibm BSD 4.3
-    *:BOSX:*:*)
-	echo rs6000-bull-bosx
-	exit ;;
-    DPX/2?00:B.O.S.:*:*)
-	echo m68k-bull-sysv3
-	exit ;;
-    9000/[34]??:4.3bsd:1.*:*)
-	echo m68k-hp-bsd
-	exit ;;
-    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
-	echo m68k-hp-bsd4.4
-	exit ;;
-    9000/[34678]??:HP-UX:*:*)
-	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-	case "${UNAME_MACHINE}" in
-	    9000/31? )            HP_ARCH=m68000 ;;
-	    9000/[34]?? )         HP_ARCH=m68k ;;
-	    9000/[678][0-9][0-9])
-		if [ -x /usr/bin/getconf ]; then
-		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
-                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
-                    case "${sc_cpu_version}" in
-                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
-                      532)                      # CPU_PA_RISC2_0
-                        case "${sc_kernel_bits}" in
-                          32) HP_ARCH="hppa2.0n" ;;
-                          64) HP_ARCH="hppa2.0w" ;;
-			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
-                        esac ;;
-                    esac
-		fi
-		if [ "${HP_ARCH}" = "" ]; then
-		    eval $set_cc_for_build
-		    sed 's/^              //' << EOF >$dummy.c
-
-              #define _HPUX_SOURCE
-              #include <stdlib.h>
-              #include <unistd.h>
-
-              int main ()
-              {
-              #if defined(_SC_KERNEL_BITS)
-                  long bits = sysconf(_SC_KERNEL_BITS);
-              #endif
-                  long cpu  = sysconf (_SC_CPU_VERSION);
-
-                  switch (cpu)
-              	{
-              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
-              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
-              	case CPU_PA_RISC2_0:
-              #if defined(_SC_KERNEL_BITS)
-              	    switch (bits)
-              		{
-              		case 64: puts ("hppa2.0w"); break;
-              		case 32: puts ("hppa2.0n"); break;
-              		default: puts ("hppa2.0"); break;
-              		} break;
-              #else  /* !defined(_SC_KERNEL_BITS) */
-              	    puts ("hppa2.0"); break;
-              #endif
-              	default: puts ("hppa1.0"); break;
-              	}
-                  exit (0);
-              }
-EOF
-		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
-		    test -z "$HP_ARCH" && HP_ARCH=hppa
-		fi ;;
-	esac
-	if [ ${HP_ARCH} = "hppa2.0w" ]
-	then
-	    eval $set_cc_for_build
-
-	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
-	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
-	    # generating 64-bit code.  GNU and HP use different nomenclature:
-	    #
-	    # $ CC_FOR_BUILD=cc ./config.guess
-	    # => hppa2.0w-hp-hpux11.23
-	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
-	    # => hppa64-hp-hpux11.23
-
-	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
-		grep __LP64__ >/dev/null
-	    then
-		HP_ARCH="hppa2.0w"
-	    else
-		HP_ARCH="hppa64"
-	    fi
-	fi
-	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
-	exit ;;
-    ia64:HP-UX:*:*)
-	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-	echo ia64-hp-hpux${HPUX_REV}
-	exit ;;
-    3050*:HI-UX:*:*)
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#include <unistd.h>
-	int
-	main ()
-	{
-	  long cpu = sysconf (_SC_CPU_VERSION);
-	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
-	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
-	     results, however.  */
-	  if (CPU_IS_PA_RISC (cpu))
-	    {
-	      switch (cpu)
-		{
-		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
-		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
-		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
-		  default: puts ("hppa-hitachi-hiuxwe2"); break;
-		}
-	    }
-	  else if (CPU_IS_HP_MC68K (cpu))
-	    puts ("m68k-hitachi-hiuxwe2");
-	  else puts ("unknown-hitachi-hiuxwe2");
-	  exit (0);
-	}
-EOF
-	$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
-		{ echo "$SYSTEM_NAME"; exit; }
-	echo unknown-hitachi-hiuxwe2
-	exit ;;
-    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
-	echo hppa1.1-hp-bsd
-	exit ;;
-    9000/8??:4.3bsd:*:*)
-	echo hppa1.0-hp-bsd
-	exit ;;
-    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
-	echo hppa1.0-hp-mpeix
-	exit ;;
-    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
-	echo hppa1.1-hp-osf
-	exit ;;
-    hp8??:OSF1:*:*)
-	echo hppa1.0-hp-osf
-	exit ;;
-    i*86:OSF1:*:*)
-	if [ -x /usr/sbin/sysversion ] ; then
-	    echo ${UNAME_MACHINE}-unknown-osf1mk
-	else
-	    echo ${UNAME_MACHINE}-unknown-osf1
-	fi
-	exit ;;
-    parisc*:Lites*:*:*)
-	echo hppa1.1-hp-lites
-	exit ;;
-    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
-	echo c1-convex-bsd
-        exit ;;
-    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
-	if getsysinfo -f scalar_acc
-	then echo c32-convex-bsd
-	else echo c2-convex-bsd
-	fi
-        exit ;;
-    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
-	echo c34-convex-bsd
-        exit ;;
-    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
-	echo c38-convex-bsd
-        exit ;;
-    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
-	echo c4-convex-bsd
-        exit ;;
-    CRAY*Y-MP:*:*:*)
-	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
-    CRAY*[A-Z]90:*:*:*)
-	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
-	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-	      -e 's/\.[^.]*$/.X/'
-	exit ;;
-    CRAY*TS:*:*:*)
-	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
-    CRAY*T3E:*:*:*)
-	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
-    CRAY*SV1:*:*:*)
-	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
-    *:UNICOS/mp:*:*)
-	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
-    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
-	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-        exit ;;
-    5000:UNIX_System_V:4.*:*)
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
-        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-	exit ;;
-    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
-	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
-	exit ;;
-    sparc*:BSD/OS:*:*)
-	echo sparc-unknown-bsdi${UNAME_RELEASE}
-	exit ;;
-    *:BSD/OS:*:*)
-	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
-	exit ;;
-    *:FreeBSD:*:*)
-	case ${UNAME_MACHINE} in
-	    pc98)
-		echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
-	    *)
-		echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
-	esac
-	exit ;;
-    i*:CYGWIN*:*)
-	echo ${UNAME_MACHINE}-pc-cygwin
-	exit ;;
-    i*:MINGW*:*)
-	echo ${UNAME_MACHINE}-pc-mingw32
-	exit ;;
-    i*:MSYS_NT-*:*:*)
-	echo ${UNAME_MACHINE}-pc-mingw32
-	exit ;;
-    i*:windows32*:*)
-    	# uname -m includes "-pc" on this system.
-    	echo ${UNAME_MACHINE}-mingw32
-	exit ;;
-    i*:PW*:*)
-	echo ${UNAME_MACHINE}-pc-pw32
-	exit ;;
-    x86:Interix*:[345]*)
-	echo i586-pc-interix${UNAME_RELEASE}
-	exit ;;
-    EM64T:Interix*:[345]*)
-	echo x86_64-unknown-interix${UNAME_RELEASE}
-	exit ;;
-    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
-	echo i${UNAME_MACHINE}-pc-mks
-	exit ;;
-    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
-	# How do we know it's Interix rather than the generic POSIX subsystem?
-	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
-	# UNAME_MACHINE based on the output of uname instead of i386?
-	echo i586-pc-interix
-	exit ;;
-    i*:UWIN*:*)
-	echo ${UNAME_MACHINE}-pc-uwin
-	exit ;;
-    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
-	echo x86_64-unknown-cygwin
-	exit ;;
-    p*:CYGWIN*:*)
-	echo powerpcle-unknown-cygwin
-	exit ;;
-    prep*:SunOS:5.*:*)
-	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit ;;
-    *:GNU:*:*)
-	# the GNU system
-	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
-	exit ;;
-    *:GNU/*:*:*)
-	# other systems with GNU libc and userland
-	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
-	exit ;;
-    i*86:Minix:*:*)
-	echo ${UNAME_MACHINE}-pc-minix
-	exit ;;
-    arm*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    cris:Linux:*:*)
-	echo cris-axis-linux-gnu
-	exit ;;
-    crisv32:Linux:*:*)
-	echo crisv32-axis-linux-gnu
-	exit ;;
-    frv:Linux:*:*)
-    	echo frv-unknown-linux-gnu
-	exit ;;
-    ia64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    m32r*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    m68*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    mips:Linux:*:*)
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#undef CPU
-	#undef mips
-	#undef mipsel
-	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
-	CPU=mipsel
-	#else
-	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
-	CPU=mips
-	#else
-	CPU=
-	#endif
-	#endif
-EOF
-	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
-	    /^CPU/{
-		s: ::g
-		p
-	    }'`"
-	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
-	;;
-    mips64:Linux:*:*)
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#undef CPU
-	#undef mips64
-	#undef mips64el
-	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
-	CPU=mips64el
-	#else
-	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
-	CPU=mips64
-	#else
-	CPU=
-	#endif
-	#endif
-EOF
-	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
-	    /^CPU/{
-		s: ::g
-		p
-	    }'`"
-	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
-	;;
-    or32:Linux:*:*)
-	echo or32-unknown-linux-gnu
-	exit ;;
-    ppc:Linux:*:*)
-	echo powerpc-unknown-linux-gnu
-	exit ;;
-    ppc64:Linux:*:*)
-	echo powerpc64-unknown-linux-gnu
-	exit ;;
-    alpha:Linux:*:*)
-	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
-	  EV5)   UNAME_MACHINE=alphaev5 ;;
-	  EV56)  UNAME_MACHINE=alphaev56 ;;
-	  PCA56) UNAME_MACHINE=alphapca56 ;;
-	  PCA57) UNAME_MACHINE=alphapca56 ;;
-	  EV6)   UNAME_MACHINE=alphaev6 ;;
-	  EV67)  UNAME_MACHINE=alphaev67 ;;
-	  EV68*) UNAME_MACHINE=alphaev68 ;;
-        esac
-	objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
-	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
-	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
-	exit ;;
-    parisc:Linux:*:* | hppa:Linux:*:*)
-	# Look for CPU level
-	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
-	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
-	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
-	  *)    echo hppa-unknown-linux-gnu ;;
-	esac
-	exit ;;
-    parisc64:Linux:*:* | hppa64:Linux:*:*)
-	echo hppa64-unknown-linux-gnu
-	exit ;;
-    s390:Linux:*:* | s390x:Linux:*:*)
-	echo ${UNAME_MACHINE}-ibm-linux
-	exit ;;
-    sh64*:Linux:*:*)
-    	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    sh*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    sparc:Linux:*:* | sparc64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    vax:Linux:*:*)
-	echo ${UNAME_MACHINE}-dec-linux-gnu
-	exit ;;
-    x86_64:Linux:*:*)
-	echo x86_64-unknown-linux-gnu
-	exit ;;
-    i*86:Linux:*:*)
-	# The BFD linker knows what the default object file format is, so
-	# first see if it will tell us. cd to the root directory to prevent
-	# problems with other programs or directories called `ld' in the path.
-	# Set LC_ALL=C to ensure ld outputs messages in English.
-	ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
-			 | sed -ne '/supported targets:/!d
-				    s/[ 	][ 	]*/ /g
-				    s/.*supported targets: *//
-				    s/ .*//
-				    p'`
-        case "$ld_supported_targets" in
-	  elf32-i386)
-		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
-		;;
-	  a.out-i386-linux)
-		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
-		exit ;;
-	  coff-i386)
-		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
-		exit ;;
-	  "")
-		# Either a pre-BFD a.out linker (linux-gnuoldld) or
-		# one that does not give us useful --help.
-		echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
-		exit ;;
-	esac
-	# Determine whether the default compiler is a.out or elf
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#include <features.h>
-	#ifdef __ELF__
-	# ifdef __GLIBC__
-	#  if __GLIBC__ >= 2
-	LIBC=gnu
-	#  else
-	LIBC=gnulibc1
-	#  endif
-	# else
-	LIBC=gnulibc1
-	# endif
-	#else
-	#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__sun)
-	LIBC=gnu
-	#else
-	LIBC=gnuaout
-	#endif
-	#endif
-	#ifdef __dietlibc__
-	LIBC=dietlibc
-	#endif
-EOF
-	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
-	    /^LIBC/{
-		s: ::g
-		p
-	    }'`"
-	test x"${LIBC}" != x && {
-		echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
-		exit
-	}
-	test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
-	;;
-    i*86:DYNIX/ptx:4*:*)
-	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
-	# earlier versions are messed up and put the nodename in both
-	# sysname and nodename.
-	echo i386-sequent-sysv4
-	exit ;;
-    i*86:UNIX_SV:4.2MP:2.*)
-        # Unixware is an offshoot of SVR4, but it has its own version
-        # number series starting with 2...
-        # I am not positive that other SVR4 systems won't match this,
-	# I just have to hope.  -- rms.
-        # Use sysv4.2uw... so that sysv4* matches it.
-	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
-	exit ;;
-    i*86:OS/2:*:*)
-	# If we were able to find `uname', then EMX Unix compatibility
-	# is probably installed.
-	echo ${UNAME_MACHINE}-pc-os2-emx
-	exit ;;
-    i*86:XTS-300:*:STOP)
-	echo ${UNAME_MACHINE}-unknown-stop
-	exit ;;
-    i*86:atheos:*:*)
-	echo ${UNAME_MACHINE}-unknown-atheos
-	exit ;;
-    i*86:syllable:*:*)
-	echo ${UNAME_MACHINE}-pc-syllable
-	exit ;;
-    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
-	echo i386-unknown-lynxos${UNAME_RELEASE}
-	exit ;;
-    i*86:*DOS:*:*)
-	echo ${UNAME_MACHINE}-pc-msdosdjgpp
-	exit ;;
-    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
-	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
-	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
-		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
-	else
-		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
-	fi
-	exit ;;
-    i*86:*:5:[678]*)
-    	# UnixWare 7.x, OpenUNIX and OpenServer 6.
-	case `/bin/uname -X | grep "^Machine"` in
-	    *486*)	     UNAME_MACHINE=i486 ;;
-	    *Pentium)	     UNAME_MACHINE=i586 ;;
-	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
-	esac
-	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
-	exit ;;
-    i*86:*:3.2:*)
-	if test -f /usr/options/cb.name; then
-		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
-		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
-	elif /bin/uname -X 2>/dev/null >/dev/null ; then
-		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
-		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
-		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
-			&& UNAME_MACHINE=i586
-		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
-			&& UNAME_MACHINE=i686
-		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
-			&& UNAME_MACHINE=i686
-		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
-	else
-		echo ${UNAME_MACHINE}-pc-sysv32
-	fi
-	exit ;;
-    pc:*:*:*)
-	# Left here for compatibility:
-        # uname -m prints for DJGPP always 'pc', but it prints nothing about
-        # the processor, so we play safe by assuming i386.
-	echo i386-pc-msdosdjgpp
-        exit ;;
-    Intel:Mach:3*:*)
-	echo i386-pc-mach3
-	exit ;;
-    paragon:*:*:*)
-	echo i860-intel-osf1
-	exit ;;
-    i860:*:4.*:*) # i860-SVR4
-	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
-	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
-	else # Add other i860-SVR4 vendors below as they are discovered.
-	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
-	fi
-	exit ;;
-    mini*:CTIX:SYS*5:*)
-	# "miniframe"
-	echo m68010-convergent-sysv
-	exit ;;
-    mc68k:UNIX:SYSTEM5:3.51m)
-	echo m68k-convergent-sysv
-	exit ;;
-    M680?0:D-NIX:5.3:*)
-	echo m68k-diab-dnix
-	exit ;;
-    M68*:*:R3V[5678]*:*)
-	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
-    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
-	OS_REL=''
-	test -r /etc/.relid \
-	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
-	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-	  && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
-	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
-    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
-        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-          && { echo i486-ncr-sysv4; exit; } ;;
-    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
-	echo m68k-unknown-lynxos${UNAME_RELEASE}
-	exit ;;
-    mc68030:UNIX_System_V:4.*:*)
-	echo m68k-atari-sysv4
-	exit ;;
-    TSUNAMI:LynxOS:2.*:*)
-	echo sparc-unknown-lynxos${UNAME_RELEASE}
-	exit ;;
-    rs6000:LynxOS:2.*:*)
-	echo rs6000-unknown-lynxos${UNAME_RELEASE}
-	exit ;;
-    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
-	echo powerpc-unknown-lynxos${UNAME_RELEASE}
-	exit ;;
-    SM[BE]S:UNIX_SV:*:*)
-	echo mips-dde-sysv${UNAME_RELEASE}
-	exit ;;
-    RM*:ReliantUNIX-*:*:*)
-	echo mips-sni-sysv4
-	exit ;;
-    RM*:SINIX-*:*:*)
-	echo mips-sni-sysv4
-	exit ;;
-    *:SINIX-*:*:*)
-	if uname -p 2>/dev/null >/dev/null ; then
-		UNAME_MACHINE=`(uname -p) 2>/dev/null`
-		echo ${UNAME_MACHINE}-sni-sysv4
-	else
-		echo ns32k-sni-sysv
-	fi
-	exit ;;
-    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
-                      # says <Richard.M.Bartel@ccMail.Census.GOV>
-        echo i586-unisys-sysv4
-        exit ;;
-    *:UNIX_System_V:4*:FTX*)
-	# From Gerald Hewes <hewes@openmarket.com>.
-	# How about differentiating between stratus architectures? -djm
-	echo hppa1.1-stratus-sysv4
-	exit ;;
-    *:*:*:FTX*)
-	# From seanf@swdc.stratus.com.
-	echo i860-stratus-sysv4
-	exit ;;
-    i*86:VOS:*:*)
-	# From Paul.Green@stratus.com.
-	echo ${UNAME_MACHINE}-stratus-vos
-	exit ;;
-    *:VOS:*:*)
-	# From Paul.Green@stratus.com.
-	echo hppa1.1-stratus-vos
-	exit ;;
-    mc68*:A/UX:*:*)
-	echo m68k-apple-aux${UNAME_RELEASE}
-	exit ;;
-    news*:NEWS-OS:6*:*)
-	echo mips-sony-newsos6
-	exit ;;
-    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
-	if [ -d /usr/nec ]; then
-	        echo mips-nec-sysv${UNAME_RELEASE}
-	else
-	        echo mips-unknown-sysv${UNAME_RELEASE}
-	fi
-        exit ;;
-    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
-	echo powerpc-be-beos
-	exit ;;
-    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
-	echo powerpc-apple-beos
-	exit ;;
-    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
-	echo i586-pc-beos
-	exit ;;
-    SX-4:SUPER-UX:*:*)
-	echo sx4-nec-superux${UNAME_RELEASE}
-	exit ;;
-    SX-5:SUPER-UX:*:*)
-	echo sx5-nec-superux${UNAME_RELEASE}
-	exit ;;
-    SX-6:SUPER-UX:*:*)
-	echo sx6-nec-superux${UNAME_RELEASE}
-	exit ;;
-    Power*:Rhapsody:*:*)
-	echo powerpc-apple-rhapsody${UNAME_RELEASE}
-	exit ;;
-    *:Rhapsody:*:*)
-	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
-	exit ;;
-    *:Darwin:*:*)
-	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
-	case $UNAME_PROCESSOR in
-	    unknown) UNAME_PROCESSOR=powerpc ;;
-	esac
-	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
-	exit ;;
-    *:procnto*:*:* | *:QNX:[0123456789]*:*)
-	UNAME_PROCESSOR=`uname -p`
-	if test "$UNAME_PROCESSOR" = "x86"; then
-		UNAME_PROCESSOR=i386
-		UNAME_MACHINE=pc
-	fi
-	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
-	exit ;;
-    *:QNX:*:4*)
-	echo i386-pc-qnx
-	exit ;;
-    NSE-?:NONSTOP_KERNEL:*:*)
-	echo nse-tandem-nsk${UNAME_RELEASE}
-	exit ;;
-    NSR-?:NONSTOP_KERNEL:*:*)
-	echo nsr-tandem-nsk${UNAME_RELEASE}
-	exit ;;
-    *:NonStop-UX:*:*)
-	echo mips-compaq-nonstopux
-	exit ;;
-    BS2000:POSIX*:*:*)
-	echo bs2000-siemens-sysv
-	exit ;;
-    DS/*:UNIX_System_V:*:*)
-	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
-	exit ;;
-    *:Plan9:*:*)
-	# "uname -m" is not consistent, so use $cputype instead. 386
-	# is converted to i386 for consistency with other x86
-	# operating systems.
-	if test "$cputype" = "386"; then
-	    UNAME_MACHINE=i386
-	else
-	    UNAME_MACHINE="$cputype"
-	fi
-	echo ${UNAME_MACHINE}-unknown-plan9
-	exit ;;
-    *:TOPS-10:*:*)
-	echo pdp10-unknown-tops10
-	exit ;;
-    *:TENEX:*:*)
-	echo pdp10-unknown-tenex
-	exit ;;
-    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
-	echo pdp10-dec-tops20
-	exit ;;
-    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
-	echo pdp10-xkl-tops20
-	exit ;;
-    *:TOPS-20:*:*)
-	echo pdp10-unknown-tops20
-	exit ;;
-    *:ITS:*:*)
-	echo pdp10-unknown-its
-	exit ;;
-    SEI:*:*:SEIUX)
-        echo mips-sei-seiux${UNAME_RELEASE}
-	exit ;;
-    *:DragonFly:*:*)
-	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
-	exit ;;
-    *:*VMS:*:*)
-    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
-	case "${UNAME_MACHINE}" in
-	    A*) echo alpha-dec-vms ; exit ;;
-	    I*) echo ia64-dec-vms ; exit ;;
-	    V*) echo vax-dec-vms ; exit ;;
-	esac ;;
-    *:XENIX:*:SysV)
-	echo i386-pc-xenix
-	exit ;;
-    i*86:skyos:*:*)
-	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
-	exit ;;
-    i*86:rdos:*:*)
-	echo ${UNAME_MACHINE}-pc-rdos
-	exit ;;
-esac
-
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
-  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
-     I don't know....  */
-  printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
-  printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
-          "4"
-#else
-	  ""
-#endif
-         ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
-  printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
-  printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
-  int version;
-  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
-  if (version < 4)
-    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
-  else
-    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
-  exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
-  printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
-  printf ("ns32k-encore-mach\n"); exit (0);
-#else
-  printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
-  printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
-  printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
-  printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
-    struct utsname un;
-
-    uname(&un);
-
-    if (strncmp(un.version, "V2", 2) == 0) {
-	printf ("i386-sequent-ptx2\n"); exit (0);
-    }
-    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
-	printf ("i386-sequent-ptx1\n"); exit (0);
-    }
-    printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-#  include <sys/param.h>
-#  if defined (BSD)
-#   if BSD == 43
-      printf ("vax-dec-bsd4.3\n"); exit (0);
-#   else
-#    if BSD == 199006
-      printf ("vax-dec-bsd4.3reno\n"); exit (0);
-#    else
-      printf ("vax-dec-bsd\n"); exit (0);
-#    endif
-#   endif
-#  else
-    printf ("vax-dec-bsd\n"); exit (0);
-#  endif
-# else
-    printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
-  printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
-  exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
-	{ echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
-    case `getsysinfo -f cpu_type` in
-    c1*)
-	echo c1-convex-bsd
-	exit ;;
-    c2*)
-	if getsysinfo -f scalar_acc
-	then echo c32-convex-bsd
-	else echo c2-convex-bsd
-	fi
-	exit ;;
-    c34*)
-	echo c34-convex-bsd
-	exit ;;
-    c38*)
-	echo c38-convex-bsd
-	exit ;;
-    c4*)
-	echo c4-convex-bsd
-	exit ;;
-    esac
-fi
-
-cat >&2 <<EOF
-$0: unable to guess system type
-
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
-
-  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
-and
-  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
-
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
-
-config.guess timestamp = $timestamp
-
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
-/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
-
-hostinfo               = `(hostinfo) 2>/dev/null`
-/bin/universe          = `(/bin/universe) 2>/dev/null`
-/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
-/bin/arch              = `(/bin/arch) 2>/dev/null`
-/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
-
-UNAME_MACHINE = ${UNAME_MACHINE}
-UNAME_RELEASE = ${UNAME_RELEASE}
-UNAME_SYSTEM  = ${UNAME_SYSTEM}
-UNAME_VERSION = ${UNAME_VERSION}
-EOF
-
-exit 1
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/config.sub b/config.sub
deleted file mode 100644
--- a/config.sub
+++ /dev/null
@@ -1,1608 +0,0 @@
-#! /bin/sh
-# Configuration validation subroutine script.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2006-02-23'
-
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine.  It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Please send patches to <config-patches@gnu.org>.  Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# Configuration subroutine to validate and canonicalize a configuration type.
-# Supply the specified configuration type as an argument.
-# If it is invalid, we print an error message on stderr and exit with code 1.
-# Otherwise, we print the canonical config type on stdout and succeed.
-
-# This file is supposed to be the same for all GNU packages
-# and recognize all the CPU types, system types and aliases
-# that are meaningful with *any* GNU software.
-# Each package is responsible for reporting which valid configurations
-# it does not support.  The user should be able to distinguish
-# a failure to support a valid configuration from a meaningless
-# configuration.
-
-# The goal of this file is to map all the various variations of a given
-# machine specification into a single specification in the form:
-#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or in some cases, the newer four-part form:
-#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-# It is wrong to echo any other type of specification.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
-       $0 [OPTION] ALIAS
-
-Canonicalize a configuration name.
-
-Operation modes:
-  -h, --help         print this help, then exit
-  -t, --time-stamp   print date of last modification, then exit
-  -v, --version      print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.sub ($timestamp)
-
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions.  There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
-  case $1 in
-    --time-stamp | --time* | -t )
-       echo "$timestamp" ; exit ;;
-    --version | -v )
-       echo "$version" ; exit ;;
-    --help | --h* | -h )
-       echo "$usage"; exit ;;
-    -- )     # Stop option processing
-       shift; break ;;
-    - )	# Use stdin as input.
-       break ;;
-    -* )
-       echo "$me: invalid option $1$help"
-       exit 1 ;;
-
-    *local*)
-       # First pass through any local machine types.
-       echo $1
-       exit ;;
-
-    * )
-       break ;;
-  esac
-done
-
-case $# in
- 0) echo "$me: missing argument$help" >&2
-    exit 1;;
- 1) ;;
- *) echo "$me: too many arguments$help" >&2
-    exit 1;;
-esac
-
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
-  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
-  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
-  storm-chaos* | os2-emx* | rtmk-nova*)
-    os=-$maybe_os
-    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
-    ;;
-  *)
-    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
-    if [ $basic_machine != $1 ]
-    then os=`echo $1 | sed 's/.*-/-/'`
-    else os=; fi
-    ;;
-esac
-
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work.  We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
-	-sun*os*)
-		# Prevent following clause from handling this invalid input.
-		;;
-	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-	-apple | -axis | -knuth | -cray)
-		os=
-		basic_machine=$1
-		;;
-	-sim | -cisco | -oki | -wec | -winbond)
-		os=
-		basic_machine=$1
-		;;
-	-scout)
-		;;
-	-wrs)
-		os=-vxworks
-		basic_machine=$1
-		;;
-	-chorusos*)
-		os=-chorusos
-		basic_machine=$1
-		;;
- 	-chorusrdb)
- 		os=-chorusrdb
-		basic_machine=$1
- 		;;
-	-hiux*)
-		os=-hiuxwe2
-		;;
-	-sco6)
-		os=-sco5v6
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-sco5)
-		os=-sco3.2v5
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-sco4)
-		os=-sco3.2v4
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-sco3.2.[4-9]*)
-		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-sco3.2v[4-9]*)
-		# Don't forget version if it is 3.2v4 or newer.
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-sco5v6*)
-		# Don't forget version if it is 3.2v4 or newer.
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-sco*)
-		os=-sco3.2v2
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-udk*)
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-isc)
-		os=-isc2.2
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-clix*)
-		basic_machine=clipper-intergraph
-		;;
-	-isc*)
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-lynx*)
-		os=-lynxos
-		;;
-	-ptx*)
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
-		;;
-	-windowsnt*)
-		os=`echo $os | sed -e 's/windowsnt/winnt/'`
-		;;
-	-psos*)
-		os=-psos
-		;;
-	-mint | -mint[0-9]*)
-		basic_machine=m68k-atari
-		os=-mint
-		;;
-esac
-
-# Decode aliases for certain CPU-COMPANY combinations.
-case $basic_machine in
-	# Recognize the basic CPU types without company name.
-	# Some are omitted here because they have special meanings below.
-	1750a | 580 \
-	| a29k \
-	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
-	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
-	| am33_2.0 \
-	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
-	| bfin \
-	| c4x | clipper \
-	| d10v | d30v | dlx | dsp16xx \
-	| fr30 | frv \
-	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
-	| i370 | i860 | i960 | ia64 \
-	| ip2k | iq2000 \
-	| m32r | m32rle | m68000 | m68k | m88k | maxq | mb | microblaze | mcore \
-	| mips | mipsbe | mipseb | mipsel | mipsle \
-	| mips16 \
-	| mips64 | mips64el \
-	| mips64vr | mips64vrel \
-	| mips64orion | mips64orionel \
-	| mips64vr4100 | mips64vr4100el \
-	| mips64vr4300 | mips64vr4300el \
-	| mips64vr5000 | mips64vr5000el \
-	| mips64vr5900 | mips64vr5900el \
-	| mipsisa32 | mipsisa32el \
-	| mipsisa32r2 | mipsisa32r2el \
-	| mipsisa64 | mipsisa64el \
-	| mipsisa64r2 | mipsisa64r2el \
-	| mipsisa64sb1 | mipsisa64sb1el \
-	| mipsisa64sr71k | mipsisa64sr71kel \
-	| mipstx39 | mipstx39el \
-	| mn10200 | mn10300 \
-	| mt \
-	| msp430 \
-	| nios | nios2 \
-	| ns16k | ns32k \
-	| or32 \
-	| pdp10 | pdp11 | pj | pjl \
-	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
-	| pyramid \
-	| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
-	| sh64 | sh64le \
-	| sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
-	| sparcv8 | sparcv9 | sparcv9b \
-	| strongarm \
-	| tahoe | thumb | tic4x | tic80 | tron \
-	| v850 | v850e \
-	| we32k \
-	| x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
-	| z8k)
-		basic_machine=$basic_machine-unknown
-		;;
-	m32c)
-		basic_machine=$basic_machine-unknown
-		;;
-	m6811 | m68hc11 | m6812 | m68hc12)
-		# Motorola 68HC11/12.
-		basic_machine=$basic_machine-unknown
-		os=-none
-		;;
-	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
-		;;
-	ms1)
-		basic_machine=mt-unknown
-		;;
-
-	# We use `pc' rather than `unknown'
-	# because (1) that's what they normally are, and
-	# (2) the word "unknown" tends to confuse beginning users.
-	i*86 | x86_64)
-	  basic_machine=$basic_machine-pc
-	  ;;
-	# Object if more than one company name word.
-	*-*-*)
-		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
-		exit 1
-		;;
-	# Recognize the basic CPU types with company name.
-	580-* \
-	| a29k-* \
-	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
-	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
-	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
-	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
-	| avr-* \
-	| bfin-* | bs2000-* \
-	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
-	| clipper-* | craynv-* | cydra-* \
-	| d10v-* | d30v-* | dlx-* \
-	| elxsi-* \
-	| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
-	| h8300-* | h8500-* \
-	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
-	| i*86-* | i860-* | i960-* | ia64-* \
-	| ip2k-* | iq2000-* \
-	| m32r-* | m32rle-* \
-	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-	| m88110-* | m88k-* | maxq-* | mcore-* \
-	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
-	| mips16-* \
-	| mips64-* | mips64el-* \
-	| mips64vr-* | mips64vrel-* \
-	| mips64orion-* | mips64orionel-* \
-	| mips64vr4100-* | mips64vr4100el-* \
-	| mips64vr4300-* | mips64vr4300el-* \
-	| mips64vr5000-* | mips64vr5000el-* \
-	| mips64vr5900-* | mips64vr5900el-* \
-	| mipsisa32-* | mipsisa32el-* \
-	| mipsisa32r2-* | mipsisa32r2el-* \
-	| mipsisa64-* | mipsisa64el-* \
-	| mipsisa64r2-* | mipsisa64r2el-* \
-	| mipsisa64sb1-* | mipsisa64sb1el-* \
-	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
-	| mipstx39-* | mipstx39el-* \
-	| mmix-* \
-	| mt-* \
-	| msp430-* \
-	| nios-* | nios2-* \
-	| none-* | np1-* | ns16k-* | ns32k-* \
-	| orion-* \
-	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
-	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
-	| pyramid-* \
-	| romp-* | rs6000-* \
-	| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
-	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
-	| sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
-	| sparclite-* \
-	| sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
-	| tahoe-* | thumb-* \
-	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
-	| tron-* \
-	| v850-* | v850e-* | vax-* \
-	| we32k-* \
-	| x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
-	| xstormy16-* | xtensa-* \
-	| ymp-* \
-	| z8k-*)
-		;;
-	m32c-*)
-		;;
-	# Recognize the various machine names and aliases which stand
-	# for a CPU type and a company and sometimes even an OS.
-	386bsd)
-		basic_machine=i386-unknown
-		os=-bsd
-		;;
-	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
-		basic_machine=m68000-att
-		;;
-	3b*)
-		basic_machine=we32k-att
-		;;
-	a29khif)
-		basic_machine=a29k-amd
-		os=-udi
-		;;
-    	abacus)
-		basic_machine=abacus-unknown
-		;;
-	adobe68k)
-		basic_machine=m68010-adobe
-		os=-scout
-		;;
-	alliant | fx80)
-		basic_machine=fx80-alliant
-		;;
-	altos | altos3068)
-		basic_machine=m68k-altos
-		;;
-	am29k)
-		basic_machine=a29k-none
-		os=-bsd
-		;;
-	amd64)
-		basic_machine=x86_64-pc
-		;;
-	amd64-*)
-		basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	amdahl)
-		basic_machine=580-amdahl
-		os=-sysv
-		;;
-	amiga | amiga-*)
-		basic_machine=m68k-unknown
-		;;
-	amigaos | amigados)
-		basic_machine=m68k-unknown
-		os=-amigaos
-		;;
-	amigaunix | amix)
-		basic_machine=m68k-unknown
-		os=-sysv4
-		;;
-	apollo68)
-		basic_machine=m68k-apollo
-		os=-sysv
-		;;
-	apollo68bsd)
-		basic_machine=m68k-apollo
-		os=-bsd
-		;;
-	aux)
-		basic_machine=m68k-apple
-		os=-aux
-		;;
-	balance)
-		basic_machine=ns32k-sequent
-		os=-dynix
-		;;
-	c90)
-		basic_machine=c90-cray
-		os=-unicos
-		;;
-	convex-c1)
-		basic_machine=c1-convex
-		os=-bsd
-		;;
-	convex-c2)
-		basic_machine=c2-convex
-		os=-bsd
-		;;
-	convex-c32)
-		basic_machine=c32-convex
-		os=-bsd
-		;;
-	convex-c34)
-		basic_machine=c34-convex
-		os=-bsd
-		;;
-	convex-c38)
-		basic_machine=c38-convex
-		os=-bsd
-		;;
-	cray | j90)
-		basic_machine=j90-cray
-		os=-unicos
-		;;
-	craynv)
-		basic_machine=craynv-cray
-		os=-unicosmp
-		;;
-	cr16c)
-		basic_machine=cr16c-unknown
-		os=-elf
-		;;
-	crds | unos)
-		basic_machine=m68k-crds
-		;;
-	crisv32 | crisv32-* | etraxfs*)
-		basic_machine=crisv32-axis
-		;;
-	cris | cris-* | etrax*)
-		basic_machine=cris-axis
-		;;
-	crx)
-		basic_machine=crx-unknown
-		os=-elf
-		;;
-	da30 | da30-*)
-		basic_machine=m68k-da30
-		;;
-	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
-		basic_machine=mips-dec
-		;;
-	decsystem10* | dec10*)
-		basic_machine=pdp10-dec
-		os=-tops10
-		;;
-	decsystem20* | dec20*)
-		basic_machine=pdp10-dec
-		os=-tops20
-		;;
-	delta | 3300 | motorola-3300 | motorola-delta \
-	      | 3300-motorola | delta-motorola)
-		basic_machine=m68k-motorola
-		;;
-	delta88)
-		basic_machine=m88k-motorola
-		os=-sysv3
-		;;
-	djgpp)
-		basic_machine=i586-pc
-		os=-msdosdjgpp
-		;;
-	dpx20 | dpx20-*)
-		basic_machine=rs6000-bull
-		os=-bosx
-		;;
-	dpx2* | dpx2*-bull)
-		basic_machine=m68k-bull
-		os=-sysv3
-		;;
-	ebmon29k)
-		basic_machine=a29k-amd
-		os=-ebmon
-		;;
-	elxsi)
-		basic_machine=elxsi-elxsi
-		os=-bsd
-		;;
-	encore | umax | mmax)
-		basic_machine=ns32k-encore
-		;;
-	es1800 | OSE68k | ose68k | ose | OSE)
-		basic_machine=m68k-ericsson
-		os=-ose
-		;;
-	fx2800)
-		basic_machine=i860-alliant
-		;;
-	genix)
-		basic_machine=ns32k-ns
-		;;
-	gmicro)
-		basic_machine=tron-gmicro
-		os=-sysv
-		;;
-	go32)
-		basic_machine=i386-pc
-		os=-go32
-		;;
-	h3050r* | hiux*)
-		basic_machine=hppa1.1-hitachi
-		os=-hiuxwe2
-		;;
-	h8300hms)
-		basic_machine=h8300-hitachi
-		os=-hms
-		;;
-	h8300xray)
-		basic_machine=h8300-hitachi
-		os=-xray
-		;;
-	h8500hms)
-		basic_machine=h8500-hitachi
-		os=-hms
-		;;
-	harris)
-		basic_machine=m88k-harris
-		os=-sysv3
-		;;
-	hp300-*)
-		basic_machine=m68k-hp
-		;;
-	hp300bsd)
-		basic_machine=m68k-hp
-		os=-bsd
-		;;
-	hp300hpux)
-		basic_machine=m68k-hp
-		os=-hpux
-		;;
-	hp3k9[0-9][0-9] | hp9[0-9][0-9])
-		basic_machine=hppa1.0-hp
-		;;
-	hp9k2[0-9][0-9] | hp9k31[0-9])
-		basic_machine=m68000-hp
-		;;
-	hp9k3[2-9][0-9])
-		basic_machine=m68k-hp
-		;;
-	hp9k6[0-9][0-9] | hp6[0-9][0-9])
-		basic_machine=hppa1.0-hp
-		;;
-	hp9k7[0-79][0-9] | hp7[0-79][0-9])
-		basic_machine=hppa1.1-hp
-		;;
-	hp9k78[0-9] | hp78[0-9])
-		# FIXME: really hppa2.0-hp
-		basic_machine=hppa1.1-hp
-		;;
-	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
-		# FIXME: really hppa2.0-hp
-		basic_machine=hppa1.1-hp
-		;;
-	hp9k8[0-9][13679] | hp8[0-9][13679])
-		basic_machine=hppa1.1-hp
-		;;
-	hp9k8[0-9][0-9] | hp8[0-9][0-9])
-		basic_machine=hppa1.0-hp
-		;;
-	hppa-next)
-		os=-nextstep3
-		;;
-	hppaosf)
-		basic_machine=hppa1.1-hp
-		os=-osf
-		;;
-	hppro)
-		basic_machine=hppa1.1-hp
-		os=-proelf
-		;;
-	i370-ibm* | ibm*)
-		basic_machine=i370-ibm
-		;;
-# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
-	i*86v32)
-		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-		os=-sysv32
-		;;
-	i*86v4*)
-		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-		os=-sysv4
-		;;
-	i*86v)
-		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-		os=-sysv
-		;;
-	i*86sol2)
-		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-		os=-solaris2
-		;;
-	i386mach)
-		basic_machine=i386-mach
-		os=-mach
-		;;
-	i386-vsta | vsta)
-		basic_machine=i386-unknown
-		os=-vsta
-		;;
-	iris | iris4d)
-		basic_machine=mips-sgi
-		case $os in
-		    -irix*)
-			;;
-		    *)
-			os=-irix4
-			;;
-		esac
-		;;
-	isi68 | isi)
-		basic_machine=m68k-isi
-		os=-sysv
-		;;
-	m88k-omron*)
-		basic_machine=m88k-omron
-		;;
-	magnum | m3230)
-		basic_machine=mips-mips
-		os=-sysv
-		;;
-	merlin)
-		basic_machine=ns32k-utek
-		os=-sysv
-		;;
-	mingw32)
-		basic_machine=i386-pc
-		os=-mingw32
-		;;
-	miniframe)
-		basic_machine=m68000-convergent
-		;;
-	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
-		basic_machine=m68k-atari
-		os=-mint
-		;;
-	mips3*-*)
-		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
-		;;
-	mips3*)
-		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
-		;;
-	monitor)
-		basic_machine=m68k-rom68k
-		os=-coff
-		;;
-	morphos)
-		basic_machine=powerpc-unknown
-		os=-morphos
-		;;
-	msdos)
-		basic_machine=i386-pc
-		os=-msdos
-		;;
-	ms1-*)
-		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
-		;;
-	mvs)
-		basic_machine=i370-ibm
-		os=-mvs
-		;;
-	ncr3000)
-		basic_machine=i486-ncr
-		os=-sysv4
-		;;
-	netbsd386)
-		basic_machine=i386-unknown
-		os=-netbsd
-		;;
-	netwinder)
-		basic_machine=armv4l-rebel
-		os=-linux
-		;;
-	news | news700 | news800 | news900)
-		basic_machine=m68k-sony
-		os=-newsos
-		;;
-	news1000)
-		basic_machine=m68030-sony
-		os=-newsos
-		;;
-	news-3600 | risc-news)
-		basic_machine=mips-sony
-		os=-newsos
-		;;
-	necv70)
-		basic_machine=v70-nec
-		os=-sysv
-		;;
-	next | m*-next )
-		basic_machine=m68k-next
-		case $os in
-		    -nextstep* )
-			;;
-		    -ns2*)
-		      os=-nextstep2
-			;;
-		    *)
-		      os=-nextstep3
-			;;
-		esac
-		;;
-	nh3000)
-		basic_machine=m68k-harris
-		os=-cxux
-		;;
-	nh[45]000)
-		basic_machine=m88k-harris
-		os=-cxux
-		;;
-	nindy960)
-		basic_machine=i960-intel
-		os=-nindy
-		;;
-	mon960)
-		basic_machine=i960-intel
-		os=-mon960
-		;;
-	nonstopux)
-		basic_machine=mips-compaq
-		os=-nonstopux
-		;;
-	np1)
-		basic_machine=np1-gould
-		;;
-	nsr-tandem)
-		basic_machine=nsr-tandem
-		;;
-	op50n-* | op60c-*)
-		basic_machine=hppa1.1-oki
-		os=-proelf
-		;;
-	openrisc | openrisc-*)
-		basic_machine=or32-unknown
-		;;
-	os400)
-		basic_machine=powerpc-ibm
-		os=-os400
-		;;
-	OSE68000 | ose68000)
-		basic_machine=m68000-ericsson
-		os=-ose
-		;;
-	os68k)
-		basic_machine=m68k-none
-		os=-os68k
-		;;
-	pa-hitachi)
-		basic_machine=hppa1.1-hitachi
-		os=-hiuxwe2
-		;;
-	paragon)
-		basic_machine=i860-intel
-		os=-osf
-		;;
-	pbd)
-		basic_machine=sparc-tti
-		;;
-	pbb)
-		basic_machine=m68k-tti
-		;;
-	pc532 | pc532-*)
-		basic_machine=ns32k-pc532
-		;;
-	pc98)
-		basic_machine=i386-pc
-		;;
-	pc98-*)
-		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	pentium | p5 | k5 | k6 | nexgen | viac3)
-		basic_machine=i586-pc
-		;;
-	pentiumpro | p6 | 6x86 | athlon | athlon_*)
-		basic_machine=i686-pc
-		;;
-	pentiumii | pentium2 | pentiumiii | pentium3)
-		basic_machine=i686-pc
-		;;
-	pentium4)
-		basic_machine=i786-pc
-		;;
-	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
-		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	pentiumpro-* | p6-* | 6x86-* | athlon-*)
-		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
-		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	pentium4-*)
-		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	pn)
-		basic_machine=pn-gould
-		;;
-	power)	basic_machine=power-ibm
-		;;
-	ppc)	basic_machine=powerpc-unknown
-		;;
-	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	ppcle | powerpclittle | ppc-le | powerpc-little)
-		basic_machine=powerpcle-unknown
-		;;
-	ppcle-* | powerpclittle-*)
-		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	ppc64)	basic_machine=powerpc64-unknown
-		;;
-	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
-		basic_machine=powerpc64le-unknown
-		;;
-	ppc64le-* | powerpc64little-*)
-		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	ps2)
-		basic_machine=i386-ibm
-		;;
-	pw32)
-		basic_machine=i586-unknown
-		os=-pw32
-		;;
-	rdos)
-		basic_machine=i386-pc
-		os=-rdos
-		;;
-	rom68k)
-		basic_machine=m68k-rom68k
-		os=-coff
-		;;
-	rm[46]00)
-		basic_machine=mips-siemens
-		;;
-	rtpc | rtpc-*)
-		basic_machine=romp-ibm
-		;;
-	s390 | s390-*)
-		basic_machine=s390-ibm
-		;;
-	s390x | s390x-*)
-		basic_machine=s390x-ibm
-		;;
-	sa29200)
-		basic_machine=a29k-amd
-		os=-udi
-		;;
-	sb1)
-		basic_machine=mipsisa64sb1-unknown
-		;;
-	sb1el)
-		basic_machine=mipsisa64sb1el-unknown
-		;;
-	sei)
-		basic_machine=mips-sei
-		os=-seiux
-		;;
-	sequent)
-		basic_machine=i386-sequent
-		;;
-	sh)
-		basic_machine=sh-hitachi
-		os=-hms
-		;;
-	sh64)
-		basic_machine=sh64-unknown
-		;;
-	sparclite-wrs | simso-wrs)
-		basic_machine=sparclite-wrs
-		os=-vxworks
-		;;
-	sps7)
-		basic_machine=m68k-bull
-		os=-sysv2
-		;;
-	spur)
-		basic_machine=spur-unknown
-		;;
-	st2000)
-		basic_machine=m68k-tandem
-		;;
-	stratus)
-		basic_machine=i860-stratus
-		os=-sysv4
-		;;
-	sun2)
-		basic_machine=m68000-sun
-		;;
-	sun2os3)
-		basic_machine=m68000-sun
-		os=-sunos3
-		;;
-	sun2os4)
-		basic_machine=m68000-sun
-		os=-sunos4
-		;;
-	sun3os3)
-		basic_machine=m68k-sun
-		os=-sunos3
-		;;
-	sun3os4)
-		basic_machine=m68k-sun
-		os=-sunos4
-		;;
-	sun4os3)
-		basic_machine=sparc-sun
-		os=-sunos3
-		;;
-	sun4os4)
-		basic_machine=sparc-sun
-		os=-sunos4
-		;;
-	sun4sol2)
-		basic_machine=sparc-sun
-		os=-solaris2
-		;;
-	sun3 | sun3-*)
-		basic_machine=m68k-sun
-		;;
-	sun4)
-		basic_machine=sparc-sun
-		;;
-	sun386 | sun386i | roadrunner)
-		basic_machine=i386-sun
-		;;
-	sv1)
-		basic_machine=sv1-cray
-		os=-unicos
-		;;
-	symmetry)
-		basic_machine=i386-sequent
-		os=-dynix
-		;;
-	t3e)
-		basic_machine=alphaev5-cray
-		os=-unicos
-		;;
-	t90)
-		basic_machine=t90-cray
-		os=-unicos
-		;;
-	tic54x | c54x*)
-		basic_machine=tic54x-unknown
-		os=-coff
-		;;
-	tic55x | c55x*)
-		basic_machine=tic55x-unknown
-		os=-coff
-		;;
-	tic6x | c6x*)
-		basic_machine=tic6x-unknown
-		os=-coff
-		;;
-	tx39)
-		basic_machine=mipstx39-unknown
-		;;
-	tx39el)
-		basic_machine=mipstx39el-unknown
-		;;
-	toad1)
-		basic_machine=pdp10-xkl
-		os=-tops20
-		;;
-	tower | tower-32)
-		basic_machine=m68k-ncr
-		;;
-	tpf)
-		basic_machine=s390x-ibm
-		os=-tpf
-		;;
-	udi29k)
-		basic_machine=a29k-amd
-		os=-udi
-		;;
-	ultra3)
-		basic_machine=a29k-nyu
-		os=-sym1
-		;;
-	v810 | necv810)
-		basic_machine=v810-nec
-		os=-none
-		;;
-	vaxv)
-		basic_machine=vax-dec
-		os=-sysv
-		;;
-	vms)
-		basic_machine=vax-dec
-		os=-vms
-		;;
-	vpp*|vx|vx-*)
-		basic_machine=f301-fujitsu
-		;;
-	vxworks960)
-		basic_machine=i960-wrs
-		os=-vxworks
-		;;
-	vxworks68)
-		basic_machine=m68k-wrs
-		os=-vxworks
-		;;
-	vxworks29k)
-		basic_machine=a29k-wrs
-		os=-vxworks
-		;;
-	w65*)
-		basic_machine=w65-wdc
-		os=-none
-		;;
-	w89k-*)
-		basic_machine=hppa1.1-winbond
-		os=-proelf
-		;;
-	xbox)
-		basic_machine=i686-pc
-		os=-mingw32
-		;;
-	xps | xps100)
-		basic_machine=xps100-honeywell
-		;;
-	ymp)
-		basic_machine=ymp-cray
-		os=-unicos
-		;;
-	z8k-*-coff)
-		basic_machine=z8k-unknown
-		os=-sim
-		;;
-	none)
-		basic_machine=none-none
-		os=-none
-		;;
-
-# Here we handle the default manufacturer of certain CPU types.  It is in
-# some cases the only manufacturer, in others, it is the most popular.
-	w89k)
-		basic_machine=hppa1.1-winbond
-		;;
-	op50n)
-		basic_machine=hppa1.1-oki
-		;;
-	op60c)
-		basic_machine=hppa1.1-oki
-		;;
-	romp)
-		basic_machine=romp-ibm
-		;;
-	mmix)
-		basic_machine=mmix-knuth
-		;;
-	rs6000)
-		basic_machine=rs6000-ibm
-		;;
-	vax)
-		basic_machine=vax-dec
-		;;
-	pdp10)
-		# there are many clones, so DEC is not a safe bet
-		basic_machine=pdp10-unknown
-		;;
-	pdp11)
-		basic_machine=pdp11-dec
-		;;
-	we32k)
-		basic_machine=we32k-att
-		;;
-	sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
-		basic_machine=sh-unknown
-		;;
-	sparc | sparcv8 | sparcv9 | sparcv9b)
-		basic_machine=sparc-sun
-		;;
-	cydra)
-		basic_machine=cydra-cydrome
-		;;
-	orion)
-		basic_machine=orion-highlevel
-		;;
-	orion105)
-		basic_machine=clipper-highlevel
-		;;
-	mac | mpw | mac-mpw)
-		basic_machine=m68k-apple
-		;;
-	pmac | pmac-mpw)
-		basic_machine=powerpc-apple
-		;;
-	*-unknown)
-		# Make sure to match an already-canonicalized machine name.
-		;;
-	*)
-		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
-		exit 1
-		;;
-esac
-
-# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
-	*-digital*)
-		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
-		;;
-	*-commodore*)
-		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
-		;;
-	*)
-		;;
-esac
-
-# Decode manufacturer-specific aliases for certain operating systems.
-
-if [ x"$os" != x"" ]
-then
-case $os in
-        # First match some system type aliases
-        # that might get confused with valid system types.
-	# -solaris* is a basic system type, with this one exception.
-	-solaris1 | -solaris1.*)
-		os=`echo $os | sed -e 's|solaris1|sunos4|'`
-		;;
-	-solaris)
-		os=-solaris2
-		;;
-	-svr4*)
-		os=-sysv4
-		;;
-	-unixware*)
-		os=-sysv4.2uw
-		;;
-	-gnu/linux*)
-		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
-		;;
-	# First accept the basic system types.
-	# The portable systems comes first.
-	# Each alternative MUST END IN A *, to match a version number.
-	# -sysv* is not here because it comes later, after sysvr4.
-	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
-	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
-	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
-	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-	      | -aos* \
-	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
-	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
-	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
-	      | -openbsd* | -solidbsd* \
-	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
-	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
-	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
-	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-	      | -chorusos* | -chorusrdb* \
-	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
-	      | -uxpv* | -beos* | -mpeix* | -udk* \
-	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
-	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
-	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
-	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
-	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
-	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-	      | -skyos* | -haiku* | -rdos*)
-	# Remember, each alternative MUST END IN *, to match a version number.
-		;;
-	-qnx*)
-		case $basic_machine in
-		    x86-* | i*86-*)
-			;;
-		    *)
-			os=-nto$os
-			;;
-		esac
-		;;
-	-nto-qnx*)
-		;;
-	-nto*)
-		os=`echo $os | sed -e 's|nto|nto-qnx|'`
-		;;
-	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
-	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
-	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
-		;;
-	-mac*)
-		os=`echo $os | sed -e 's|mac|macos|'`
-		;;
-	-linux-dietlibc)
-		os=-linux-dietlibc
-		;;
-	-linux*)
-		os=`echo $os | sed -e 's|linux|linux-gnu|'`
-		;;
-	-sunos5*)
-		os=`echo $os | sed -e 's|sunos5|solaris2|'`
-		;;
-	-sunos6*)
-		os=`echo $os | sed -e 's|sunos6|solaris3|'`
-		;;
-	-opened*)
-		os=-openedition
-		;;
-        -os400*)
-		os=-os400
-		;;
-	-wince*)
-		os=-wince
-		;;
-	-osfrose*)
-		os=-osfrose
-		;;
-	-osf*)
-		os=-osf
-		;;
-	-utek*)
-		os=-bsd
-		;;
-	-dynix*)
-		os=-bsd
-		;;
-	-acis*)
-		os=-aos
-		;;
-	-atheos*)
-		os=-atheos
-		;;
-	-syllable*)
-		os=-syllable
-		;;
-	-386bsd)
-		os=-bsd
-		;;
-	-ctix* | -uts*)
-		os=-sysv
-		;;
-	-nova*)
-		os=-rtmk-nova
-		;;
-	-ns2 )
-		os=-nextstep2
-		;;
-	-nsk*)
-		os=-nsk
-		;;
-	# Preserve the version number of sinix5.
-	-sinix5.*)
-		os=`echo $os | sed -e 's|sinix|sysv|'`
-		;;
-	-sinix*)
-		os=-sysv4
-		;;
-        -tpf*)
-		os=-tpf
-		;;
-	-triton*)
-		os=-sysv3
-		;;
-	-oss*)
-		os=-sysv3
-		;;
-	-svr4)
-		os=-sysv4
-		;;
-	-svr3)
-		os=-sysv3
-		;;
-	-sysvr4)
-		os=-sysv4
-		;;
-	# This must come after -sysvr4.
-	-sysv*)
-		;;
-	-ose*)
-		os=-ose
-		;;
-	-es1800*)
-		os=-ose
-		;;
-	-xenix)
-		os=-xenix
-		;;
-	-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
-		os=-mint
-		;;
-	-aros*)
-		os=-aros
-		;;
-	-kaos*)
-		os=-kaos
-		;;
-	-zvmoe)
-		os=-zvmoe
-		;;
-	-none)
-		;;
-	*)
-		# Get rid of the `-' at the beginning of $os.
-		os=`echo $os | sed 's/[^-]*-//'`
-		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
-		exit 1
-		;;
-esac
-else
-
-# Here we handle the default operating systems that come with various machines.
-# The value should be what the vendor currently ships out the door with their
-# machine or put another way, the most popular os provided with the machine.
-
-# Note that if you're going to try to match "-MANUFACTURER" here (say,
-# "-sun"), then you have to tell the case statement up towards the top
-# that MANUFACTURER isn't an operating system.  Otherwise, code above
-# will signal an error saying that MANUFACTURER isn't an operating
-# system, and we'll never get to this point.
-
-case $basic_machine in
-	*-acorn)
-		os=-riscix1.2
-		;;
-	arm*-rebel)
-		os=-linux
-		;;
-	arm*-semi)
-		os=-aout
-		;;
-    c4x-* | tic4x-*)
-        os=-coff
-        ;;
-	# This must come before the *-dec entry.
-	pdp10-*)
-		os=-tops20
-		;;
-	pdp11-*)
-		os=-none
-		;;
-	*-dec | vax-*)
-		os=-ultrix4.2
-		;;
-	m68*-apollo)
-		os=-domain
-		;;
-	i386-sun)
-		os=-sunos4.0.2
-		;;
-	m68000-sun)
-		os=-sunos3
-		# This also exists in the configure program, but was not the
-		# default.
-		# os=-sunos4
-		;;
-	m68*-cisco)
-		os=-aout
-		;;
-	mips*-cisco)
-		os=-elf
-		;;
-	mips*-*)
-		os=-elf
-		;;
-	or32-*)
-		os=-coff
-		;;
-	*-tti)	# must be before sparc entry or we get the wrong os.
-		os=-sysv3
-		;;
-	sparc-* | *-sun)
-		os=-sunos4.1.1
-		;;
-	*-be)
-		os=-beos
-		;;
-	*-haiku)
-		os=-haiku
-		;;
-	*-ibm)
-		os=-aix
-		;;
-    	*-knuth)
-		os=-mmixware
-		;;
-	*-wec)
-		os=-proelf
-		;;
-	*-winbond)
-		os=-proelf
-		;;
-	*-oki)
-		os=-proelf
-		;;
-	*-hp)
-		os=-hpux
-		;;
-	*-hitachi)
-		os=-hiux
-		;;
-	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
-		os=-sysv
-		;;
-	*-cbm)
-		os=-amigaos
-		;;
-	*-dg)
-		os=-dgux
-		;;
-	*-dolphin)
-		os=-sysv3
-		;;
-	m68k-ccur)
-		os=-rtu
-		;;
-	m88k-omron*)
-		os=-luna
-		;;
-	*-next )
-		os=-nextstep
-		;;
-	*-sequent)
-		os=-ptx
-		;;
-	*-crds)
-		os=-unos
-		;;
-	*-ns)
-		os=-genix
-		;;
-	i370-*)
-		os=-mvs
-		;;
-	*-next)
-		os=-nextstep3
-		;;
-	*-gould)
-		os=-sysv
-		;;
-	*-highlevel)
-		os=-bsd
-		;;
-	*-encore)
-		os=-bsd
-		;;
-	*-sgi)
-		os=-irix
-		;;
-	*-siemens)
-		os=-sysv4
-		;;
-	*-masscomp)
-		os=-rtu
-		;;
-	f30[01]-fujitsu | f700-fujitsu)
-		os=-uxpv
-		;;
-	*-rom68k)
-		os=-coff
-		;;
-	*-*bug)
-		os=-coff
-		;;
-	*-apple)
-		os=-macos
-		;;
-	*-atari*)
-		os=-mint
-		;;
-	*)
-		os=-none
-		;;
-esac
-fi
-
-# Here we handle the case where we know the os, and the CPU type, but not the
-# manufacturer.  We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
-	*-unknown)
-		case $os in
-			-riscix*)
-				vendor=acorn
-				;;
-			-sunos*)
-				vendor=sun
-				;;
-			-aix*)
-				vendor=ibm
-				;;
-			-beos*)
-				vendor=be
-				;;
-			-hpux*)
-				vendor=hp
-				;;
-			-mpeix*)
-				vendor=hp
-				;;
-			-hiux*)
-				vendor=hitachi
-				;;
-			-unos*)
-				vendor=crds
-				;;
-			-dgux*)
-				vendor=dg
-				;;
-			-luna*)
-				vendor=omron
-				;;
-			-genix*)
-				vendor=ns
-				;;
-			-mvs* | -opened*)
-				vendor=ibm
-				;;
-			-os400*)
-				vendor=ibm
-				;;
-			-ptx*)
-				vendor=sequent
-				;;
-			-tpf*)
-				vendor=ibm
-				;;
-			-vxsim* | -vxworks* | -windiss*)
-				vendor=wrs
-				;;
-			-aux*)
-				vendor=apple
-				;;
-			-hms*)
-				vendor=hitachi
-				;;
-			-mpw* | -macos*)
-				vendor=apple
-				;;
-			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
-				vendor=atari
-				;;
-			-vos*)
-				vendor=stratus
-				;;
-		esac
-		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
-		;;
-esac
-
-echo $basic_machine$os
-exit
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/configure b/configure
deleted file mode 100644
--- a/configure
+++ /dev/null
@@ -1,8007 +0,0 @@
-#! /bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for Haskell OpenGL package 2.2.3.0.
-#
-# Report bugs to <sven.panne@aedion.de>.
-#
-#
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
-#
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
-
-# Be more Bourne compatible
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
-fi
-
-
-as_nl='
-'
-export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='printf %s\n'
-  as_echo_n='printf %s'
-else
-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
-    as_echo_n='/usr/ucb/echo -n'
-  else
-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-    as_echo_n_body='eval
-      arg=$1;
-      case $arg in #(
-      *"$as_nl"*)
-	expr "X$arg" : "X\\(.*\\)$as_nl";
-	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-      esac;
-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-    '
-    export as_echo_n_body
-    as_echo_n='sh -c $as_echo_n_body as_echo'
-  fi
-  export as_echo_body
-  as_echo='sh -c $as_echo_body as_echo'
-fi
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  PATH_SEPARATOR=:
-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
-    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
-      PATH_SEPARATOR=';'
-  }
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.  Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" ""	$as_nl"
-
-# Find who we are.  Look in the path if we contain no directory separator.
-as_myself=
-case $0 in #((
-  *[\\/]* ) as_myself=$0 ;;
-  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-  done
-IFS=$as_save_IFS
-
-     ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
-  as_myself=$0
-fi
-if test ! -f "$as_myself"; then
-  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-  exit 1
-fi
-
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-if test "x$CONFIG_SHELL" = x; then
-  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '\${1+\"\$@\"}'='\"\$@\"'
-  setopt NO_GLOB_SUBST
-else
-  case \`(set -o) 2>/dev/null\` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
-fi
-"
-  as_required="as_fn_return () { (exit \$1); }
-as_fn_success () { as_fn_return 0; }
-as_fn_failure () { as_fn_return 1; }
-as_fn_ret_success () { return 0; }
-as_fn_ret_failure () { return 1; }
-
-exitcode=0
-as_fn_success || { exitcode=1; echo as_fn_success failed.; }
-as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
-as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
-as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
-if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
-
-else
-  exitcode=1; echo positional parameters were not saved.
-fi
-test x\$exitcode = x0 || exit 1"
-  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
-  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
-  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
-  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
-test \$(( 1 + 1 )) = 2 || exit 1"
-  if (eval "$as_required") 2>/dev/null; then :
-  as_have_required=yes
-else
-  as_have_required=no
-fi
-  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
-
-else
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-as_found=false
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  as_found=:
-  case $as_dir in #(
-	 /*)
-	   for as_base in sh bash ksh sh5; do
-	     # Try only shells that exist, to save several forks.
-	     as_shell=$as_dir/$as_base
-	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
-		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
-  CONFIG_SHELL=$as_shell as_have_required=yes
-		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
-  break 2
-fi
-fi
-	   done;;
-       esac
-  as_found=false
-done
-$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
-	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
-  CONFIG_SHELL=$SHELL as_have_required=yes
-fi; }
-IFS=$as_save_IFS
-
-
-      if test "x$CONFIG_SHELL" != x; then :
-  # We cannot yet assume a decent shell, so we have to provide a
-	# neutralization value for shells without unset; and this also
-	# works around shells that cannot unset nonexistent variables.
-	# Preserve -v and -x to the replacement shell.
-	BASH_ENV=/dev/null
-	ENV=/dev/null
-	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-	export CONFIG_SHELL
-	case $- in # ((((
-	  *v*x* | *x*v* ) as_opts=-vx ;;
-	  *v* ) as_opts=-v ;;
-	  *x* ) as_opts=-x ;;
-	  * ) as_opts= ;;
-	esac
-	exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
-fi
-
-    if test x$as_have_required = xno; then :
-  $as_echo "$0: This script requires a shell more modern than all"
-  $as_echo "$0: the shells that I found on your system."
-  if test x${ZSH_VERSION+set} = xset ; then
-    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
-    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
-  else
-    $as_echo "$0: Please tell bug-autoconf@gnu.org and
-$0: sven.panne@aedion.de about your system, including any
-$0: error possibly output before this message. Then install
-$0: a modern shell, or manually run the script under such a
-$0: shell if you do have one."
-  fi
-  exit 1
-fi
-fi
-fi
-SHELL=${CONFIG_SHELL-/bin/sh}
-export SHELL
-# Unset more variables known to interfere with behavior of common tools.
-CLICOLOR_FORCE= GREP_OPTIONS=
-unset CLICOLOR_FORCE GREP_OPTIONS
-
-## --------------------- ##
-## M4sh Shell Functions. ##
-## --------------------- ##
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
-  { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
-  return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
-  set +e
-  as_fn_set_status $1
-  exit $1
-} # as_fn_exit
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
-  case $as_dir in #(
-  -*) as_dir=./$as_dir;;
-  esac
-  test -d "$as_dir" || eval $as_mkdir_p || {
-    as_dirs=
-    while :; do
-      case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-      *) as_qdir=$as_dir;;
-      esac
-      as_dirs="'$as_qdir' $as_dirs"
-      as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-      test -d "$as_dir" && break
-    done
-    test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
-  eval 'as_fn_append ()
-  {
-    eval $1+=\$2
-  }'
-else
-  as_fn_append ()
-  {
-    eval $1=\$$1\$2
-  }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
-  eval 'as_fn_arith ()
-  {
-    as_val=$(( $* ))
-  }'
-else
-  as_fn_arith ()
-  {
-    as_val=`expr "$@" || test $? -eq 1`
-  }
-fi # as_fn_arith
-
-
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
-as_fn_error ()
-{
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-  fi
-  $as_echo "$as_me: error: $2" >&2
-  as_fn_exit $as_status
-} # as_fn_error
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
-   test "X`expr 00001 : '.*\(...\)'`" = X001; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
-  as_basename=basename
-else
-  as_basename=false
-fi
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-  as_dirname=dirname
-else
-  as_dirname=false
-fi
-
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-
-  as_lineno_1=$LINENO as_lineno_1a=$LINENO
-  as_lineno_2=$LINENO as_lineno_2a=$LINENO
-  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
-  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
-  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
-  sed -n '
-    p
-    /[$]LINENO/=
-  ' <$as_myself |
-    sed '
-      s/[$]LINENO.*/&-/
-      t lineno
-      b
-      :lineno
-      N
-      :loop
-      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
-      t loop
-      s/-\n.*//
-    ' >$as_me.lineno &&
-  chmod +x "$as_me.lineno" ||
-    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
-
-  # Don't try to exec as it changes $[0], causing all sort of problems
-  # (the dirname of $[0] is not the place where we might find the
-  # original and so on.  Autoconf is especially sensitive to this).
-  . "./$as_me.lineno"
-  # Exit status is that of the last command.
-  exit
-}
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
--n*)
-  case `echo 'xy\c'` in
-  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
-  xy)  ECHO_C='\c';;
-  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
-       ECHO_T='	';;
-  esac;;
-*)
-  ECHO_N='-n';;
-esac
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
-  rm -f conf$$.dir/conf$$.file
-else
-  rm -f conf$$.dir
-  mkdir conf$$.dir 2>/dev/null
-fi
-if (echo >conf$$.file) 2>/dev/null; then
-  if ln -s conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s='ln -s'
-    # ... but there are two gotchas:
-    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
-    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
-    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
-  elif ln conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s=ln
-  else
-    as_ln_s='cp -p'
-  fi
-else
-  as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-if mkdir -p . 2>/dev/null; then
-  as_mkdir_p='mkdir -p "$as_dir"'
-else
-  test -d ./-p && rmdir ./-p
-  as_mkdir_p=false
-fi
-
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-test -n "$DJDIR" || exec 7<&0 </dev/null
-exec 6>&1
-
-# Name of the host.
-# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
-# so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-#
-# Initializations.
-#
-ac_default_prefix=/usr/local
-ac_clean_files=
-ac_config_libobj_dir=.
-LIBOBJS=
-cross_compiling=no
-subdirs=
-MFLAGS=
-MAKEFLAGS=
-
-# Identity of this package.
-PACKAGE_NAME='Haskell OpenGL package'
-PACKAGE_TARNAME='OpenGL'
-PACKAGE_VERSION='2.2.3.0'
-PACKAGE_STRING='Haskell OpenGL package 2.2.3.0'
-PACKAGE_BUGREPORT='sven.panne@aedion.de'
-PACKAGE_URL=''
-
-ac_unique_file="include/HsOpenGL.h.in"
-# Factoring default headers for most tests.
-ac_includes_default="\
-#include <stdio.h>
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
-#endif
-#ifdef HAVE_STRING_H
-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
-#  include <memory.h>
-# endif
-# include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif"
-
-ac_subst_vars='LTLIBOBJS
-LIBOBJS
-CALLCONV
-BUILD_PACKAGE_BOOL
-EGREP
-GREP
-GLU_LIBS
-GLU_CFLAGS
-GL_LIBS
-GL_CFLAGS
-GLUT_FRAMEWORKS
-GLU_FRAMEWORKS
-target_os
-target_vendor
-target_cpu
-target
-host_os
-host_vendor
-host_cpu
-host
-build_os
-build_vendor
-build_cpu
-build
-X_EXTRA_LIBS
-X_LIBS
-X_PRE_LIBS
-X_CFLAGS
-CPP
-XMKMF
-OBJEXT
-EXEEXT
-ac_ct_CC
-CPPFLAGS
-LDFLAGS
-CFLAGS
-CC
-target_alias
-host_alias
-build_alias
-LIBS
-ECHO_T
-ECHO_N
-ECHO_C
-DEFS
-mandir
-localedir
-libdir
-psdir
-pdfdir
-dvidir
-htmldir
-infodir
-docdir
-oldincludedir
-includedir
-localstatedir
-sharedstatedir
-sysconfdir
-datadir
-datarootdir
-libexecdir
-sbindir
-bindir
-program_transform_name
-prefix
-exec_prefix
-PACKAGE_URL
-PACKAGE_BUGREPORT
-PACKAGE_STRING
-PACKAGE_VERSION
-PACKAGE_TARNAME
-PACKAGE_NAME
-PATH_SEPARATOR
-SHELL'
-ac_subst_files=''
-ac_user_opts='
-enable_option_checking
-with_compiler
-enable_opengl
-with_x
-'
-      ac_precious_vars='build_alias
-host_alias
-target_alias
-CC
-CFLAGS
-LDFLAGS
-LIBS
-CPPFLAGS
-XMKMF
-CPP
-CPPFLAGS'
-
-
-# Initialize some variables set by options.
-ac_init_help=
-ac_init_version=false
-ac_unrecognized_opts=
-ac_unrecognized_sep=
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-cache_file=/dev/null
-exec_prefix=NONE
-no_create=
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-verbose=
-x_includes=NONE
-x_libraries=NONE
-
-# Installation directory options.
-# These are left unexpanded so users can "make install exec_prefix=/foo"
-# and all the variables that are supposed to be based on exec_prefix
-# by default will actually change.
-# Use braces instead of parens because sh, perl, etc. also accept them.
-# (The list follows the same order as the GNU Coding Standards.)
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datarootdir='${prefix}/share'
-datadir='${datarootdir}'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
-infodir='${datarootdir}/info'
-htmldir='${docdir}'
-dvidir='${docdir}'
-pdfdir='${docdir}'
-psdir='${docdir}'
-libdir='${exec_prefix}/lib'
-localedir='${datarootdir}/locale'
-mandir='${datarootdir}/man'
-
-ac_prev=
-ac_dashdash=
-for ac_option
-do
-  # If the previous option needs an argument, assign it.
-  if test -n "$ac_prev"; then
-    eval $ac_prev=\$ac_option
-    ac_prev=
-    continue
-  fi
-
-  case $ac_option in
-  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
-  *=)   ac_optarg= ;;
-  *)    ac_optarg=yes ;;
-  esac
-
-  # Accept the important Cygnus configure options, so we can diagnose typos.
-
-  case $ac_dashdash$ac_option in
-  --)
-    ac_dashdash=yes ;;
-
-  -bindir | --bindir | --bindi | --bind | --bin | --bi)
-    ac_prev=bindir ;;
-  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
-    bindir=$ac_optarg ;;
-
-  -build | --build | --buil | --bui | --bu)
-    ac_prev=build_alias ;;
-  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
-    build_alias=$ac_optarg ;;
-
-  -cache-file | --cache-file | --cache-fil | --cache-fi \
-  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
-    ac_prev=cache_file ;;
-  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
-  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
-    cache_file=$ac_optarg ;;
-
-  --config-cache | -C)
-    cache_file=config.cache ;;
-
-  -datadir | --datadir | --datadi | --datad)
-    ac_prev=datadir ;;
-  -datadir=* | --datadir=* | --datadi=* | --datad=*)
-    datadir=$ac_optarg ;;
-
-  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
-  | --dataroo | --dataro | --datar)
-    ac_prev=datarootdir ;;
-  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
-  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
-    datarootdir=$ac_optarg ;;
-
-  -disable-* | --disable-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"enable_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
-	 ac_unrecognized_sep=', ';;
-    esac
-    eval enable_$ac_useropt=no ;;
-
-  -docdir | --docdir | --docdi | --doc | --do)
-    ac_prev=docdir ;;
-  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
-    docdir=$ac_optarg ;;
-
-  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
-    ac_prev=dvidir ;;
-  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
-    dvidir=$ac_optarg ;;
-
-  -enable-* | --enable-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"enable_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
-	 ac_unrecognized_sep=', ';;
-    esac
-    eval enable_$ac_useropt=\$ac_optarg ;;
-
-  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
-  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
-  | --exec | --exe | --ex)
-    ac_prev=exec_prefix ;;
-  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
-  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
-  | --exec=* | --exe=* | --ex=*)
-    exec_prefix=$ac_optarg ;;
-
-  -gas | --gas | --ga | --g)
-    # Obsolete; use --with-gas.
-    with_gas=yes ;;
-
-  -help | --help | --hel | --he | -h)
-    ac_init_help=long ;;
-  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
-    ac_init_help=recursive ;;
-  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
-    ac_init_help=short ;;
-
-  -host | --host | --hos | --ho)
-    ac_prev=host_alias ;;
-  -host=* | --host=* | --hos=* | --ho=*)
-    host_alias=$ac_optarg ;;
-
-  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
-    ac_prev=htmldir ;;
-  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
-  | --ht=*)
-    htmldir=$ac_optarg ;;
-
-  -includedir | --includedir | --includedi | --included | --include \
-  | --includ | --inclu | --incl | --inc)
-    ac_prev=includedir ;;
-  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
-  | --includ=* | --inclu=* | --incl=* | --inc=*)
-    includedir=$ac_optarg ;;
-
-  -infodir | --infodir | --infodi | --infod | --info | --inf)
-    ac_prev=infodir ;;
-  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
-    infodir=$ac_optarg ;;
-
-  -libdir | --libdir | --libdi | --libd)
-    ac_prev=libdir ;;
-  -libdir=* | --libdir=* | --libdi=* | --libd=*)
-    libdir=$ac_optarg ;;
-
-  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
-  | --libexe | --libex | --libe)
-    ac_prev=libexecdir ;;
-  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
-  | --libexe=* | --libex=* | --libe=*)
-    libexecdir=$ac_optarg ;;
-
-  -localedir | --localedir | --localedi | --localed | --locale)
-    ac_prev=localedir ;;
-  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
-    localedir=$ac_optarg ;;
-
-  -localstatedir | --localstatedir | --localstatedi | --localstated \
-  | --localstate | --localstat | --localsta | --localst | --locals)
-    ac_prev=localstatedir ;;
-  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
-  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
-    localstatedir=$ac_optarg ;;
-
-  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
-    ac_prev=mandir ;;
-  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
-    mandir=$ac_optarg ;;
-
-  -nfp | --nfp | --nf)
-    # Obsolete; use --without-fp.
-    with_fp=no ;;
-
-  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
-  | --no-cr | --no-c | -n)
-    no_create=yes ;;
-
-  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
-  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
-    no_recursion=yes ;;
-
-  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
-  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
-  | --oldin | --oldi | --old | --ol | --o)
-    ac_prev=oldincludedir ;;
-  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
-  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
-  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
-    oldincludedir=$ac_optarg ;;
-
-  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
-    ac_prev=prefix ;;
-  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
-    prefix=$ac_optarg ;;
-
-  -program-prefix | --program-prefix | --program-prefi | --program-pref \
-  | --program-pre | --program-pr | --program-p)
-    ac_prev=program_prefix ;;
-  -program-prefix=* | --program-prefix=* | --program-prefi=* \
-  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
-    program_prefix=$ac_optarg ;;
-
-  -program-suffix | --program-suffix | --program-suffi | --program-suff \
-  | --program-suf | --program-su | --program-s)
-    ac_prev=program_suffix ;;
-  -program-suffix=* | --program-suffix=* | --program-suffi=* \
-  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
-    program_suffix=$ac_optarg ;;
-
-  -program-transform-name | --program-transform-name \
-  | --program-transform-nam | --program-transform-na \
-  | --program-transform-n | --program-transform- \
-  | --program-transform | --program-transfor \
-  | --program-transfo | --program-transf \
-  | --program-trans | --program-tran \
-  | --progr-tra | --program-tr | --program-t)
-    ac_prev=program_transform_name ;;
-  -program-transform-name=* | --program-transform-name=* \
-  | --program-transform-nam=* | --program-transform-na=* \
-  | --program-transform-n=* | --program-transform-=* \
-  | --program-transform=* | --program-transfor=* \
-  | --program-transfo=* | --program-transf=* \
-  | --program-trans=* | --program-tran=* \
-  | --progr-tra=* | --program-tr=* | --program-t=*)
-    program_transform_name=$ac_optarg ;;
-
-  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
-    ac_prev=pdfdir ;;
-  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
-    pdfdir=$ac_optarg ;;
-
-  -psdir | --psdir | --psdi | --psd | --ps)
-    ac_prev=psdir ;;
-  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
-    psdir=$ac_optarg ;;
-
-  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-  | -silent | --silent | --silen | --sile | --sil)
-    silent=yes ;;
-
-  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
-    ac_prev=sbindir ;;
-  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
-  | --sbi=* | --sb=*)
-    sbindir=$ac_optarg ;;
-
-  -sharedstatedir | --sharedstatedir | --sharedstatedi \
-  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
-  | --sharedst | --shareds | --shared | --share | --shar \
-  | --sha | --sh)
-    ac_prev=sharedstatedir ;;
-  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
-  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
-  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
-  | --sha=* | --sh=*)
-    sharedstatedir=$ac_optarg ;;
-
-  -site | --site | --sit)
-    ac_prev=site ;;
-  -site=* | --site=* | --sit=*)
-    site=$ac_optarg ;;
-
-  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
-    ac_prev=srcdir ;;
-  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
-    srcdir=$ac_optarg ;;
-
-  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
-  | --syscon | --sysco | --sysc | --sys | --sy)
-    ac_prev=sysconfdir ;;
-  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
-  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
-    sysconfdir=$ac_optarg ;;
-
-  -target | --target | --targe | --targ | --tar | --ta | --t)
-    ac_prev=target_alias ;;
-  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
-    target_alias=$ac_optarg ;;
-
-  -v | -verbose | --verbose | --verbos | --verbo | --verb)
-    verbose=yes ;;
-
-  -version | --version | --versio | --versi | --vers | -V)
-    ac_init_version=: ;;
-
-  -with-* | --with-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"with_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
-	 ac_unrecognized_sep=', ';;
-    esac
-    eval with_$ac_useropt=\$ac_optarg ;;
-
-  -without-* | --without-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"with_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
-	 ac_unrecognized_sep=', ';;
-    esac
-    eval with_$ac_useropt=no ;;
-
-  --x)
-    # Obsolete; use --with-x.
-    with_x=yes ;;
-
-  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
-  | --x-incl | --x-inc | --x-in | --x-i)
-    ac_prev=x_includes ;;
-  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
-  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
-    x_includes=$ac_optarg ;;
-
-  -x-libraries | --x-libraries | --x-librarie | --x-librari \
-  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
-    ac_prev=x_libraries ;;
-  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
-  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
-    x_libraries=$ac_optarg ;;
-
-  -*) as_fn_error $? "unrecognized option: \`$ac_option'
-Try \`$0 --help' for more information"
-    ;;
-
-  *=*)
-    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
-    # Reject names that are not valid shell variable names.
-    case $ac_envvar in #(
-      '' | [0-9]* | *[!_$as_cr_alnum]* )
-      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
-    esac
-    eval $ac_envvar=\$ac_optarg
-    export $ac_envvar ;;
-
-  *)
-    # FIXME: should be removed in autoconf 3.0.
-    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
-    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
-    : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
-    ;;
-
-  esac
-done
-
-if test -n "$ac_prev"; then
-  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-  as_fn_error $? "missing argument to $ac_option"
-fi
-
-if test -n "$ac_unrecognized_opts"; then
-  case $enable_option_checking in
-    no) ;;
-    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
-    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
-  esac
-fi
-
-# Check all directory arguments for consistency.
-for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
-		datadir sysconfdir sharedstatedir localstatedir includedir \
-		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
-do
-  eval ac_val=\$$ac_var
-  # Remove trailing slashes.
-  case $ac_val in
-    */ )
-      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
-      eval $ac_var=\$ac_val;;
-  esac
-  # Be sure to have absolute directory names.
-  case $ac_val in
-    [\\/$]* | ?:[\\/]* )  continue;;
-    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
-  esac
-  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
-done
-
-# There might be people who depend on the old broken behavior: `$host'
-# used to hold the argument of --host etc.
-# FIXME: To remove some day.
-build=$build_alias
-host=$host_alias
-target=$target_alias
-
-# FIXME: To remove some day.
-if test "x$host_alias" != x; then
-  if test "x$build_alias" = x; then
-    cross_compiling=maybe
-    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used" >&2
-  elif test "x$build_alias" != "x$host_alias"; then
-    cross_compiling=yes
-  fi
-fi
-
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
-test "$silent" = yes && exec 6>/dev/null
-
-
-ac_pwd=`pwd` && test -n "$ac_pwd" &&
-ac_ls_di=`ls -di .` &&
-ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-  as_fn_error $? "working directory cannot be determined"
-test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
-  as_fn_error $? "pwd does not report name of working directory"
-
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
-  ac_srcdir_defaulted=yes
-  # Try the directory containing this script, then the parent directory.
-  ac_confdir=`$as_dirname -- "$as_myself" ||
-$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_myself" : 'X\(//\)[^/]' \| \
-	 X"$as_myself" : 'X\(//\)$' \| \
-	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_myself" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-  srcdir=$ac_confdir
-  if test ! -r "$srcdir/$ac_unique_file"; then
-    srcdir=..
-  fi
-else
-  ac_srcdir_defaulted=no
-fi
-if test ! -r "$srcdir/$ac_unique_file"; then
-  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
-  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
-fi
-ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
-ac_abs_confdir=`(
-	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
-	pwd)`
-# When building in place, set srcdir=.
-if test "$ac_abs_confdir" = "$ac_pwd"; then
-  srcdir=.
-fi
-# Remove unnecessary trailing slashes from srcdir.
-# Double slashes in file names in object file debugging info
-# mess up M-x gdb in Emacs.
-case $srcdir in
-*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
-esac
-for ac_var in $ac_precious_vars; do
-  eval ac_env_${ac_var}_set=\${${ac_var}+set}
-  eval ac_env_${ac_var}_value=\$${ac_var}
-  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
-  eval ac_cv_env_${ac_var}_value=\$${ac_var}
-done
-
-#
-# Report the --help message.
-#
-if test "$ac_init_help" = "long"; then
-  # Omit some internal or obsolete options to make the list less imposing.
-  # This message is too long to be a string in the A/UX 3.1 sh.
-  cat <<_ACEOF
-\`configure' configures Haskell OpenGL package 2.2.3.0 to adapt to many kinds of systems.
-
-Usage: $0 [OPTION]... [VAR=VALUE]...
-
-To assign environment variables (e.g., CC, CFLAGS...), specify them as
-VAR=VALUE.  See below for descriptions of some of the useful variables.
-
-Defaults for the options are specified in brackets.
-
-Configuration:
-  -h, --help              display this help and exit
-      --help=short        display options specific to this package
-      --help=recursive    display the short help of all the included packages
-  -V, --version           display version information and exit
-  -q, --quiet, --silent   do not print \`checking ...' messages
-      --cache-file=FILE   cache test results in FILE [disabled]
-  -C, --config-cache      alias for \`--cache-file=config.cache'
-  -n, --no-create         do not create output files
-      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
-
-Installation directories:
-  --prefix=PREFIX         install architecture-independent files in PREFIX
-                          [$ac_default_prefix]
-  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
-                          [PREFIX]
-
-By default, \`make install' will install all the files in
-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
-an installation prefix other than \`$ac_default_prefix' using \`--prefix',
-for instance \`--prefix=\$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
-  --bindir=DIR            user executables [EPREFIX/bin]
-  --sbindir=DIR           system admin executables [EPREFIX/sbin]
-  --libexecdir=DIR        program executables [EPREFIX/libexec]
-  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
-  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
-  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --libdir=DIR            object code libraries [EPREFIX/lib]
-  --includedir=DIR        C header files [PREFIX/include]
-  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
-  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
-  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
-  --infodir=DIR           info documentation [DATAROOTDIR/info]
-  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
-  --mandir=DIR            man documentation [DATAROOTDIR/man]
-  --docdir=DIR            documentation root [DATAROOTDIR/doc/OpenGL]
-  --htmldir=DIR           html documentation [DOCDIR]
-  --dvidir=DIR            dvi documentation [DOCDIR]
-  --pdfdir=DIR            pdf documentation [DOCDIR]
-  --psdir=DIR             ps documentation [DOCDIR]
-_ACEOF
-
-  cat <<\_ACEOF
-
-X features:
-  --x-includes=DIR    X include files are in DIR
-  --x-libraries=DIR   X library files are in DIR
-
-System types:
-  --build=BUILD     configure for building on BUILD [guessed]
-  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
-  --target=TARGET   configure for building compilers for TARGET [HOST]
-_ACEOF
-fi
-
-if test -n "$ac_init_help"; then
-  case $ac_init_help in
-     short | recursive ) echo "Configuration of Haskell OpenGL package 2.2.3.0:";;
-   esac
-  cat <<\_ACEOF
-
-Optional Features:
-  --disable-option-checking  ignore unrecognized --enable/--with options
-  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
-  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --enable-opengl         build a Haskell binding for OpenGL (GL/GLU). On Mac
-                          OS X, use --enable-opengl=x11 to use X11 instead of
-                          the "native" libraries. (default=autodetect)
-
-Optional Packages:
-  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --with-compiler[=HC]    use the given Haskell compiler (default=ghc)
-  --with-x                use the X Window System
-
-Some influential environment variables:
-  CC          C compiler command
-  CFLAGS      C compiler flags
-  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
-              nonstandard directory <lib dir>
-  LIBS        libraries to pass to the linker, e.g. -l<library>
-  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
-              you have headers in a nonstandard directory <include dir>
-  XMKMF       Path to xmkmf, Makefile generator for X Window System
-  CPP         C preprocessor
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-Report bugs to <sven.panne@aedion.de>.
-_ACEOF
-ac_status=$?
-fi
-
-if test "$ac_init_help" = "recursive"; then
-  # If there are subdirs, report their specific --help.
-  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
-    test -d "$ac_dir" ||
-      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
-      continue
-    ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
-  # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
-  case $ac_top_builddir_sub in
-  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
-  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
-  esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
-  .)  # We are building in place.
-    ac_srcdir=.
-    ac_top_srcdir=$ac_top_builddir_sub
-    ac_abs_top_srcdir=$ac_pwd ;;
-  [\\/]* | ?:[\\/]* )  # Absolute name.
-    ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir
-    ac_abs_top_srcdir=$srcdir ;;
-  *) # Relative name.
-    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_build_prefix$srcdir
-    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
-    cd "$ac_dir" || { ac_status=$?; continue; }
-    # Check for guested configure.
-    if test -f "$ac_srcdir/configure.gnu"; then
-      echo &&
-      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
-    elif test -f "$ac_srcdir/configure"; then
-      echo &&
-      $SHELL "$ac_srcdir/configure" --help=recursive
-    else
-      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
-    fi || ac_status=$?
-    cd "$ac_pwd" || { ac_status=$?; break; }
-  done
-fi
-
-test -n "$ac_init_help" && exit $ac_status
-if $ac_init_version; then
-  cat <<\_ACEOF
-Haskell OpenGL package configure 2.2.3.0
-generated by GNU Autoconf 2.68
-
-Copyright (C) 2010 Free Software Foundation, Inc.
-This configure script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it.
-_ACEOF
-  exit
-fi
-
-## ------------------------ ##
-## Autoconf initialization. ##
-## ------------------------ ##
-
-# ac_fn_c_try_compile LINENO
-# --------------------------
-# Try to compile conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
-  if { { ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_compile
-
-# ac_fn_c_try_cpp LINENO
-# ----------------------
-# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_cpp ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } > conftest.i && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-    ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_cpp
-
-# ac_fn_c_try_link LINENO
-# -----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_link ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext conftest$ac_exeext
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
-  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
-  # interfere with the next link command; also delete a directory that is
-  # left behind by Apple's compiler.  We do this before executing the actions.
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_link
-
-# ac_fn_c_check_func LINENO FUNC VAR
-# ----------------------------------
-# Tests whether FUNC exists, setting the cache variable VAR accordingly
-ac_fn_c_check_func ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $2 innocuous_$2
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $2 (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $2
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char $2 ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined __stub_$2 || defined __stub___$2
-choke me
-#endif
-
-int
-main ()
-{
-return $2 ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_func
-
-# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists, giving a warning if it cannot be compiled using
-# the include files in INCLUDES and setting the cache variable VAR
-# accordingly.
-ac_fn_c_check_header_mongrel ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if eval \${$3+:} false; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-else
-  # Is the header compilable?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
-$as_echo_n "checking $2 usability... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_header_compiler=yes
-else
-  ac_header_compiler=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
-$as_echo "$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
-$as_echo_n "checking $2 presence... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <$2>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  ac_header_preproc=yes
-else
-  ac_header_preproc=no
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
-$as_echo "$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
-  yes:no: )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
-$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-    ;;
-  no:yes:* )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
-$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
-$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
-$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
-$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-( $as_echo "## ----------------------------------- ##
-## Report this to sven.panne@aedion.de ##
-## ----------------------------------- ##"
-     ) | sed "s/^/$as_me: WARNING:     /" >&2
-    ;;
-esac
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  eval "$3=\$ac_header_compiler"
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_mongrel
-
-# ac_fn_c_try_run LINENO
-# ----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
-# that executables *can* be run.
-ac_fn_c_try_run ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-       $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_retval=$ac_status
-fi
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_run
-
-# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists and can be compiled using the include files in
-# INCLUDES, setting the cache variable VAR accordingly.
-ac_fn_c_check_header_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_compile
-cat >config.log <<_ACEOF
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-
-It was created by Haskell OpenGL package $as_me 2.2.3.0, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
-
-  $ $0 $@
-
-_ACEOF
-exec 5>>config.log
-{
-cat <<_ASUNAME
-## --------- ##
-## Platform. ##
-## --------- ##
-
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
-/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
-
-/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
-/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
-/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
-/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
-/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
-
-_ASUNAME
-
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    $as_echo "PATH: $as_dir"
-  done
-IFS=$as_save_IFS
-
-} >&5
-
-cat >&5 <<_ACEOF
-
-
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
-
-
-# Keep a trace of the command line.
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Strip out --silent because we don't want to record it for future runs.
-# Also quote any args containing shell meta-characters.
-# Make two passes to allow for proper duplicate-argument suppression.
-ac_configure_args=
-ac_configure_args0=
-ac_configure_args1=
-ac_must_keep_next=false
-for ac_pass in 1 2
-do
-  for ac_arg
-  do
-    case $ac_arg in
-    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
-    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-    | -silent | --silent | --silen | --sile | --sil)
-      continue ;;
-    *\'*)
-      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    esac
-    case $ac_pass in
-    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
-    2)
-      as_fn_append ac_configure_args1 " '$ac_arg'"
-      if test $ac_must_keep_next = true; then
-	ac_must_keep_next=false # Got value, back to normal.
-      else
-	case $ac_arg in
-	  *=* | --config-cache | -C | -disable-* | --disable-* \
-	  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
-	  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
-	  | -with-* | --with-* | -without-* | --without-* | --x)
-	    case "$ac_configure_args0 " in
-	      "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
-	    esac
-	    ;;
-	  -* ) ac_must_keep_next=true ;;
-	esac
-      fi
-      as_fn_append ac_configure_args " '$ac_arg'"
-      ;;
-    esac
-  done
-done
-{ ac_configure_args0=; unset ac_configure_args0;}
-{ ac_configure_args1=; unset ac_configure_args1;}
-
-# When interrupted or exit'd, cleanup temporary files, and complete
-# config.log.  We remove comments because anyway the quotes in there
-# would cause problems or look ugly.
-# WARNING: Use '\'' to represent an apostrophe within the trap.
-# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
-trap 'exit_status=$?
-  # Save into config.log some information that might help in debugging.
-  {
-    echo
-
-    $as_echo "## ---------------- ##
-## Cache variables. ##
-## ---------------- ##"
-    echo
-    # The following way of writing the cache mishandles newlines in values,
-(
-  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
-    eval ac_val=\$$ac_var
-    case $ac_val in #(
-    *${as_nl}*)
-      case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
-      esac
-      case $ac_var in #(
-      _ | IFS | as_nl) ;; #(
-      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-      *) { eval $ac_var=; unset $ac_var;} ;;
-      esac ;;
-    esac
-  done
-  (set) 2>&1 |
-    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
-    *${as_nl}ac_space=\ *)
-      sed -n \
-	"s/'\''/'\''\\\\'\'''\''/g;
-	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
-      ;; #(
-    *)
-      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
-      ;;
-    esac |
-    sort
-)
-    echo
-
-    $as_echo "## ----------------- ##
-## Output variables. ##
-## ----------------- ##"
-    echo
-    for ac_var in $ac_subst_vars
-    do
-      eval ac_val=\$$ac_var
-      case $ac_val in
-      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
-      esac
-      $as_echo "$ac_var='\''$ac_val'\''"
-    done | sort
-    echo
-
-    if test -n "$ac_subst_files"; then
-      $as_echo "## ------------------- ##
-## File substitutions. ##
-## ------------------- ##"
-      echo
-      for ac_var in $ac_subst_files
-      do
-	eval ac_val=\$$ac_var
-	case $ac_val in
-	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
-	esac
-	$as_echo "$ac_var='\''$ac_val'\''"
-      done | sort
-      echo
-    fi
-
-    if test -s confdefs.h; then
-      $as_echo "## ----------- ##
-## confdefs.h. ##
-## ----------- ##"
-      echo
-      cat confdefs.h
-      echo
-    fi
-    test "$ac_signal" != 0 &&
-      $as_echo "$as_me: caught signal $ac_signal"
-    $as_echo "$as_me: exit $exit_status"
-  } >&5
-  rm -f core *.core core.conftest.* &&
-    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
-    exit $exit_status
-' 0
-for ac_signal in 1 2 13 15; do
-  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
-done
-ac_signal=0
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -f -r conftest* confdefs.h
-
-$as_echo "/* confdefs.h */" > confdefs.h
-
-# Predefined preprocessor variables.
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_URL "$PACKAGE_URL"
-_ACEOF
-
-
-# Let the site file select an alternate cache file if it wants to.
-# Prefer an explicitly selected file to automatically selected ones.
-ac_site_file1=NONE
-ac_site_file2=NONE
-if test -n "$CONFIG_SITE"; then
-  # We do not want a PATH search for config.site.
-  case $CONFIG_SITE in #((
-    -*)  ac_site_file1=./$CONFIG_SITE;;
-    */*) ac_site_file1=$CONFIG_SITE;;
-    *)   ac_site_file1=./$CONFIG_SITE;;
-  esac
-elif test "x$prefix" != xNONE; then
-  ac_site_file1=$prefix/share/config.site
-  ac_site_file2=$prefix/etc/config.site
-else
-  ac_site_file1=$ac_default_prefix/share/config.site
-  ac_site_file2=$ac_default_prefix/etc/config.site
-fi
-for ac_site_file in "$ac_site_file1" "$ac_site_file2"
-do
-  test "x$ac_site_file" = xNONE && continue
-  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
-$as_echo "$as_me: loading site script $ac_site_file" >&6;}
-    sed 's/^/| /' "$ac_site_file" >&5
-    . "$ac_site_file" \
-      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "failed to load site script $ac_site_file
-See \`config.log' for more details" "$LINENO" 5; }
-  fi
-done
-
-if test -r "$cache_file"; then
-  # Some versions of bash will fail to source /dev/null (special files
-  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
-  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
-$as_echo "$as_me: loading cache $cache_file" >&6;}
-    case $cache_file in
-      [\\/]* | ?:[\\/]* ) . "$cache_file";;
-      *)                      . "./$cache_file";;
-    esac
-  fi
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
-$as_echo "$as_me: creating cache $cache_file" >&6;}
-  >$cache_file
-fi
-
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in $ac_precious_vars; do
-  eval ac_old_set=\$ac_cv_env_${ac_var}_set
-  eval ac_new_set=\$ac_env_${ac_var}_set
-  eval ac_old_val=\$ac_cv_env_${ac_var}_value
-  eval ac_new_val=\$ac_env_${ac_var}_value
-  case $ac_old_set,$ac_new_set in
-    set,)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
-      ac_cache_corrupted=: ;;
-    ,set)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
-      ac_cache_corrupted=: ;;
-    ,);;
-    *)
-      if test "x$ac_old_val" != "x$ac_new_val"; then
-	# differences in whitespace do not lead to failure.
-	ac_old_val_w=`echo x $ac_old_val`
-	ac_new_val_w=`echo x $ac_new_val`
-	if test "$ac_old_val_w" != "$ac_new_val_w"; then
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
-$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
-	  ac_cache_corrupted=:
-	else
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
-$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
-	  eval $ac_var=\$ac_old_val
-	fi
-	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
-$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
-	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
-$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
-      fi;;
-  esac
-  # Pass precious variables to config.status.
-  if test "$ac_new_set" = set; then
-    case $ac_new_val in
-    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
-    *) ac_arg=$ac_var=$ac_new_val ;;
-    esac
-    case " $ac_configure_args " in
-      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
-      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
-    esac
-  fi
-done
-if $ac_cache_corrupted; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
-$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
-fi
-## -------------------- ##
-## Main body of script. ##
-## -------------------- ##
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-# Safety check: Ensure that we are in the correct source directory.
-
-
-# The first file mentioned below will be generated by autoheader and contains
-# defines which are needed during package build time only. The second header
-# contains all kinds of stuff which is needed for using this package.
-ac_config_headers="$ac_config_headers include/HsOpenGLConfig.h include/HsOpenGL.h"
-
-
-# we do not really care about this here, but this avoids a warning about an
-# unknown option
-
-# Check whether --with-compiler was given.
-if test "${with_compiler+set}" = set; then :
-  withval=$with_compiler; with_compiler=$withval
-else
-  with_compiler=ghc
-fi
-
-
-
-# We set this to "yes" later when we have found OpenGL libs and headers.
-GL_BUILD_PACKAGE=no
-
-# Shall we build this package at all?
-# Check whether --enable-opengl was given.
-if test "${enable_opengl+set}" = set; then :
-  enableval=$enable_opengl; enable_opengl=$enableval
-else
-  enable_opengl=yes
-fi
-
-
-
-if test x"$enable_opengl" != xno; then
-
-# Check for OpenGL include paths and libraries
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CC="${ac_tool_prefix}gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_CC"; then
-  ac_ct_CC=$CC
-  # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_CC="gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_CC" = x; then
-    CC=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CC=$ac_ct_CC
-  fi
-else
-  CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
-          if test -n "$ac_tool_prefix"; then
-    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CC="${ac_tool_prefix}cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  fi
-fi
-if test -z "$CC"; then
-  # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-  ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
-       ac_prog_rejected=yes
-       continue
-     fi
-    ac_cv_prog_CC="cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-if test $ac_prog_rejected = yes; then
-  # We found a bogon in the path, so make sure we never use it.
-  set dummy $ac_cv_prog_CC
-  shift
-  if test $# != 0; then
-    # We chose a different compiler from the bogus one.
-    # However, it has the same basename, so the bogon will be chosen
-    # first if we set CC to just the basename; use the full file name.
-    shift
-    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
-  fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$CC"; then
-  if test -n "$ac_tool_prefix"; then
-  for ac_prog in cl.exe
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-    test -n "$CC" && break
-  done
-fi
-if test -z "$CC"; then
-  ac_ct_CC=$CC
-  for ac_prog in cl.exe
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_CC="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$ac_ct_CC" && break
-done
-
-  if test "x$ac_ct_CC" = x; then
-    CC=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CC=$ac_ct_CC
-  fi
-fi
-
-fi
-
-
-test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5; }
-
-# Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
-set X $ac_compile
-ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
-  { { ac_try="$ac_compiler $ac_option >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    sed '10a\
-... rest of stderr output deleted ...
-         10q' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-  fi
-  rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-done
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-$as_echo_n "checking whether the C compiler works... " >&6; }
-ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-
-# The possible output files:
-ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
-
-ac_rmfiles=
-for ac_file in $ac_files
-do
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
-    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
-  esac
-done
-rm -f $ac_rmfiles
-
-if { { ac_try="$ac_link_default"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link_default") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
-# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
-# in a Makefile.  We should not override ac_cv_exeext if it was cached,
-# so that the user can short-circuit this test for compilers unknown to
-# Autoconf.
-for ac_file in $ac_files ''
-do
-  test -f "$ac_file" || continue
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
-	;;
-    [ab].out )
-	# We found the default executable, but exeext='' is most
-	# certainly right.
-	break;;
-    *.* )
-	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
-	then :; else
-	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	fi
-	# We set ac_cv_exeext here because the later test for it is not
-	# safe: cross compilers may not add the suffix if given an `-o'
-	# argument, so we may need to know it at that point already.
-	# Even if this section looks crufty: it has the advantage of
-	# actually working.
-	break;;
-    * )
-	break;;
-  esac
-done
-test "$ac_cv_exeext" = no && ac_cv_exeext=
-
-else
-  ac_file=''
-fi
-if test -z "$ac_file"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-$as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "C compiler cannot create executables
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
-$as_echo_n "checking for C compiler default output file name... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-$as_echo "$ac_file" >&6; }
-ac_exeext=$ac_cv_exeext
-
-rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
-$as_echo_n "checking for suffix of executables... " >&6; }
-if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
-  test -f "$ac_file" || continue
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
-    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	  break;;
-    * ) break;;
-  esac
-done
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-rm -f conftest conftest$ac_cv_exeext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
-$as_echo "$ac_cv_exeext" >&6; }
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-int
-main ()
-{
-FILE *f = fopen ("conftest.out", "w");
- return ferror (f) || fclose (f) != 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-ac_clean_files="$ac_clean_files conftest.out"
-# Check that the compiler produces executables we can run.  If not, either
-# the compiler is broken, or we cross compile.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-$as_echo_n "checking whether we are cross compiling... " >&6; }
-if test "$cross_compiling" != yes; then
-  { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-  if { ac_try='./conftest$ac_cv_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then
-    cross_compiling=no
-  else
-    if test "$cross_compiling" = maybe; then
-	cross_compiling=yes
-    else
-	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details" "$LINENO" 5; }
-    fi
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-$as_echo "$cross_compiling" >&6; }
-
-rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
-$as_echo_n "checking for suffix of object files... " >&6; }
-if ${ac_cv_objext+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { { ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  for ac_file in conftest.o conftest.obj conftest.*; do
-  test -f "$ac_file" || continue;
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
-    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
-       break;;
-  esac
-done
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
-$as_echo "$ac_cv_objext" >&6; }
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
-$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if ${ac_cv_c_compiler_gnu+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-#ifndef __GNUC__
-       choke me
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_compiler_gnu=yes
-else
-  ac_compiler_gnu=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
-$as_echo "$ac_cv_c_compiler_gnu" >&6; }
-if test $ac_compiler_gnu = yes; then
-  GCC=yes
-else
-  GCC=
-fi
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
-$as_echo_n "checking whether $CC accepts -g... " >&6; }
-if ${ac_cv_prog_cc_g+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_save_c_werror_flag=$ac_c_werror_flag
-   ac_c_werror_flag=yes
-   ac_cv_prog_cc_g=no
-   CFLAGS="-g"
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_g=yes
-else
-  CFLAGS=""
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-else
-  ac_c_werror_flag=$ac_save_c_werror_flag
-	 CFLAGS="-g"
-	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_g=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   ac_c_werror_flag=$ac_save_c_werror_flag
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
-$as_echo "$ac_cv_prog_cc_g" >&6; }
-if test "$ac_test_CFLAGS" = set; then
-  CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
-  if test "$GCC" = yes; then
-    CFLAGS="-g -O2"
-  else
-    CFLAGS="-g"
-  fi
-else
-  if test "$GCC" = yes; then
-    CFLAGS="-O2"
-  else
-    CFLAGS=
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
-$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if ${ac_cv_prog_cc_c89+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_prog_cc_c89=no
-ac_save_CC=$CC
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
-{
-  return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
-  char *s;
-  va_list v;
-  va_start (v,p);
-  s = g (p, va_arg (v,int));
-  va_end (v);
-  return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
-   function prototypes and stuff, but not '\xHH' hex character constants.
-   These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std is added to get
-   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
-   array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std.  */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
-   inside strings and character constants.  */
-#define FOO(x) 'x'
-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
-  ;
-  return 0;
-}
-_ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
-  CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_c89=$ac_arg
-fi
-rm -f core conftest.err conftest.$ac_objext
-  test "x$ac_cv_prog_cc_c89" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c89" in
-  x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
-  xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_c89"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
-$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c89" != xno; then :
-
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Windows environment" >&5
-$as_echo_n "checking for Windows environment... " >&6; }
-if ${fp_cv_is_win32+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-#if !_WIN32
-   syntax error;
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  fp_cv_is_win32=yes
-else
-  fp_cv_is_win32=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $fp_cv_is_win32" >&5
-$as_echo "$fp_cv_is_win32" >&6; }
-fp_is_win32="$fp_cv_is_win32"
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
-$as_echo_n "checking how to run the C preprocessor... " >&6; }
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
-fi
-if test -z "$CPP"; then
-  if ${ac_cv_prog_CPP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-      # Double quotes because CPP needs to be expanded
-    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
-    do
-      ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
-else
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-  break
-fi
-
-    done
-    ac_cv_prog_CPP=$CPP
-
-fi
-  CPP=$ac_cv_prog_CPP
-else
-  ac_cv_prog_CPP=$CPP
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
-$as_echo "$CPP" >&6; }
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
-else
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for X" >&5
-$as_echo_n "checking for X... " >&6; }
-
-
-# Check whether --with-x was given.
-if test "${with_x+set}" = set; then :
-  withval=$with_x;
-fi
-
-# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
-if test "x$with_x" = xno; then
-  # The user explicitly disabled X.
-  have_x=disabled
-else
-  case $x_includes,$x_libraries in #(
-    *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #(
-    *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  # One or both of the vars are not set, and there is no cached value.
-ac_x_includes=no ac_x_libraries=no
-rm -f -r conftest.dir
-if mkdir conftest.dir; then
-  cd conftest.dir
-  cat >Imakefile <<'_ACEOF'
-incroot:
-	@echo incroot='${INCROOT}'
-usrlibdir:
-	@echo usrlibdir='${USRLIBDIR}'
-libdir:
-	@echo libdir='${LIBDIR}'
-_ACEOF
-  if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then
-    # GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
-    for ac_var in incroot usrlibdir libdir; do
-      eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`"
-    done
-    # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
-    for ac_extension in a so sl dylib la dll; do
-      if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" &&
-	 test -f "$ac_im_libdir/libX11.$ac_extension"; then
-	ac_im_usrlibdir=$ac_im_libdir; break
-      fi
-    done
-    # Screen out bogus values from the imake configuration.  They are
-    # bogus both because they are the default anyway, and because
-    # using them would break gcc on systems where it needs fixed includes.
-    case $ac_im_incroot in
-	/usr/include) ac_x_includes= ;;
-	*) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
-    esac
-    case $ac_im_usrlibdir in
-	/usr/lib | /usr/lib64 | /lib | /lib64) ;;
-	*) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
-    esac
-  fi
-  cd ..
-  rm -f -r conftest.dir
-fi
-
-# Standard set of common directories for X headers.
-# Check X11 before X11Rn because it is often a symlink to the current release.
-ac_x_header_dirs='
-/usr/X11/include
-/usr/X11R7/include
-/usr/X11R6/include
-/usr/X11R5/include
-/usr/X11R4/include
-
-/usr/include/X11
-/usr/include/X11R7
-/usr/include/X11R6
-/usr/include/X11R5
-/usr/include/X11R4
-
-/usr/local/X11/include
-/usr/local/X11R7/include
-/usr/local/X11R6/include
-/usr/local/X11R5/include
-/usr/local/X11R4/include
-
-/usr/local/include/X11
-/usr/local/include/X11R7
-/usr/local/include/X11R6
-/usr/local/include/X11R5
-/usr/local/include/X11R4
-
-/usr/X386/include
-/usr/x386/include
-/usr/XFree86/include/X11
-
-/usr/include
-/usr/local/include
-/usr/unsupported/include
-/usr/athena/include
-/usr/local/x11r5/include
-/usr/lpp/Xamples/include
-
-/usr/openwin/include
-/usr/openwin/share/include'
-
-if test "$ac_x_includes" = no; then
-  # Guess where to find include files, by looking for Xlib.h.
-  # First, try using that file with no special directory specified.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <X11/Xlib.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # We can compile using X headers with no special include directory.
-ac_x_includes=
-else
-  for ac_dir in $ac_x_header_dirs; do
-  if test -r "$ac_dir/X11/Xlib.h"; then
-    ac_x_includes=$ac_dir
-    break
-  fi
-done
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-fi # $ac_x_includes = no
-
-if test "$ac_x_libraries" = no; then
-  # Check for the libraries.
-  # See if we find them without any special options.
-  # Don't add to $LIBS permanently.
-  ac_save_LIBS=$LIBS
-  LIBS="-lX11 $LIBS"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <X11/Xlib.h>
-int
-main ()
-{
-XrmInitialize ()
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  LIBS=$ac_save_LIBS
-# We can link X programs with no special library path.
-ac_x_libraries=
-else
-  LIBS=$ac_save_LIBS
-for ac_dir in `$as_echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
-do
-  # Don't even attempt the hair of trying to link an X program!
-  for ac_extension in a so sl dylib la dll; do
-    if test -r "$ac_dir/libX11.$ac_extension"; then
-      ac_x_libraries=$ac_dir
-      break 2
-    fi
-  done
-done
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi # $ac_x_libraries = no
-
-case $ac_x_includes,$ac_x_libraries in #(
-  no,* | *,no | *\'*)
-    # Didn't find X, or a directory has "'" in its name.
-    ac_cv_have_x="have_x=no";; #(
-  *)
-    # Record where we found X for the cache.
-    ac_cv_have_x="have_x=yes\
-	ac_x_includes='$ac_x_includes'\
-	ac_x_libraries='$ac_x_libraries'"
-esac
-fi
-;; #(
-    *) have_x=yes;;
-  esac
-  eval "$ac_cv_have_x"
-fi # $with_x != no
-
-if test "$have_x" != yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_x" >&5
-$as_echo "$have_x" >&6; }
-  no_x=yes
-else
-  # If each of the values was on the command line, it overrides each guess.
-  test "x$x_includes" = xNONE && x_includes=$ac_x_includes
-  test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
-  # Update the cache value to reflect the command line values.
-  ac_cv_have_x="have_x=yes\
-	ac_x_includes='$x_includes'\
-	ac_x_libraries='$x_libraries'"
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: libraries $x_libraries, headers $x_includes" >&5
-$as_echo "libraries $x_libraries, headers $x_includes" >&6; }
-fi
-
-
-if test x"$fp_is_win32" = xyes; then
-  no_x=yes
-else
-  if test "$no_x" = yes; then
-  # Not all programs may use this symbol, but it does not hurt to define it.
-
-$as_echo "#define X_DISPLAY_MISSING 1" >>confdefs.h
-
-  X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
-else
-  if test -n "$x_includes"; then
-    X_CFLAGS="$X_CFLAGS -I$x_includes"
-  fi
-
-  # It would also be nice to do this for all -L options, not just this one.
-  if test -n "$x_libraries"; then
-    X_LIBS="$X_LIBS -L$x_libraries"
-    # For Solaris; some versions of Sun CC require a space after -R and
-    # others require no space.  Words are not sufficient . . . .
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -R must be followed by a space" >&5
-$as_echo_n "checking whether -R must be followed by a space... " >&6; }
-    ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
-    ac_xsave_c_werror_flag=$ac_c_werror_flag
-    ac_c_werror_flag=yes
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-       X_LIBS="$X_LIBS -R$x_libraries"
-else
-  LIBS="$ac_xsave_LIBS -R $x_libraries"
-       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-	  X_LIBS="$X_LIBS -R $x_libraries"
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: neither works" >&5
-$as_echo "neither works" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-    ac_c_werror_flag=$ac_xsave_c_werror_flag
-    LIBS=$ac_xsave_LIBS
-  fi
-
-  # Check for system-dependent libraries X programs must link with.
-  # Do this before checking for the system-independent R6 libraries
-  # (-lICE), since we may need -lsocket or whatever for X linking.
-
-  if test "$ISC" = yes; then
-    X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
-  else
-    # Martyn Johnson says this is needed for Ultrix, if the X
-    # libraries were built with DECnet support.  And Karl Berry says
-    # the Alpha needs dnet_stub (dnet does not exist).
-    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XOpenDisplay ();
-int
-main ()
-{
-return XOpenDisplay ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet" >&5
-$as_echo_n "checking for dnet_ntoa in -ldnet... " >&6; }
-if ${ac_cv_lib_dnet_dnet_ntoa+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldnet  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dnet_ntoa ();
-int
-main ()
-{
-return dnet_ntoa ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_dnet_dnet_ntoa=yes
-else
-  ac_cv_lib_dnet_dnet_ntoa=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
-$as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; }
-if test "x$ac_cv_lib_dnet_dnet_ntoa" = xyes; then :
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
-fi
-
-    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet_stub" >&5
-$as_echo_n "checking for dnet_ntoa in -ldnet_stub... " >&6; }
-if ${ac_cv_lib_dnet_stub_dnet_ntoa+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldnet_stub  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dnet_ntoa ();
-int
-main ()
-{
-return dnet_ntoa ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_dnet_stub_dnet_ntoa=yes
-else
-  ac_cv_lib_dnet_stub_dnet_ntoa=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
-$as_echo "$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; }
-if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = xyes; then :
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
-fi
-
-    fi
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-    LIBS="$ac_xsave_LIBS"
-
-    # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
-    # to get the SysV transport functions.
-    # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4)
-    # needs -lnsl.
-    # The nsl library prevents programs from opening the X display
-    # on Irix 5.2, according to T.E. Dickey.
-    # The functions gethostbyname, getservbyname, and inet_addr are
-    # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
-    ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname"
-if test "x$ac_cv_func_gethostbyname" = xyes; then :
-
-fi
-
-    if test $ac_cv_func_gethostbyname = no; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5
-$as_echo_n "checking for gethostbyname in -lnsl... " >&6; }
-if ${ac_cv_lib_nsl_gethostbyname+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lnsl  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char gethostbyname ();
-int
-main ()
-{
-return gethostbyname ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_nsl_gethostbyname=yes
-else
-  ac_cv_lib_nsl_gethostbyname=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5
-$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; }
-if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then :
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
-fi
-
-      if test $ac_cv_lib_nsl_gethostbyname = no; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lbsd" >&5
-$as_echo_n "checking for gethostbyname in -lbsd... " >&6; }
-if ${ac_cv_lib_bsd_gethostbyname+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lbsd  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char gethostbyname ();
-int
-main ()
-{
-return gethostbyname ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_bsd_gethostbyname=yes
-else
-  ac_cv_lib_bsd_gethostbyname=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_gethostbyname" >&5
-$as_echo "$ac_cv_lib_bsd_gethostbyname" >&6; }
-if test "x$ac_cv_lib_bsd_gethostbyname" = xyes; then :
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
-fi
-
-      fi
-    fi
-
-    # lieder@skyler.mavd.honeywell.com says without -lsocket,
-    # socket/setsockopt and other routines are undefined under SCO ODT
-    # 2.0.  But -lsocket is broken on IRIX 5.2 (and is not necessary
-    # on later versions), says Simon Leinen: it contains gethostby*
-    # variants that don't use the name server (or something).  -lsocket
-    # must be given before -lnsl if both are needed.  We assume that
-    # if connect needs -lnsl, so does gethostbyname.
-    ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect"
-if test "x$ac_cv_func_connect" = xyes; then :
-
-fi
-
-    if test $ac_cv_func_connect = no; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5
-$as_echo_n "checking for connect in -lsocket... " >&6; }
-if ${ac_cv_lib_socket_connect+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char connect ();
-int
-main ()
-{
-return connect ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_socket_connect=yes
-else
-  ac_cv_lib_socket_connect=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5
-$as_echo "$ac_cv_lib_socket_connect" >&6; }
-if test "x$ac_cv_lib_socket_connect" = xyes; then :
-  X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
-fi
-
-    fi
-
-    # Guillermo Gomez says -lposix is necessary on A/UX.
-    ac_fn_c_check_func "$LINENO" "remove" "ac_cv_func_remove"
-if test "x$ac_cv_func_remove" = xyes; then :
-
-fi
-
-    if test $ac_cv_func_remove = no; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for remove in -lposix" >&5
-$as_echo_n "checking for remove in -lposix... " >&6; }
-if ${ac_cv_lib_posix_remove+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lposix  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char remove ();
-int
-main ()
-{
-return remove ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_posix_remove=yes
-else
-  ac_cv_lib_posix_remove=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix_remove" >&5
-$as_echo "$ac_cv_lib_posix_remove" >&6; }
-if test "x$ac_cv_lib_posix_remove" = xyes; then :
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
-fi
-
-    fi
-
-    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
-    ac_fn_c_check_func "$LINENO" "shmat" "ac_cv_func_shmat"
-if test "x$ac_cv_func_shmat" = xyes; then :
-
-fi
-
-    if test $ac_cv_func_shmat = no; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shmat in -lipc" >&5
-$as_echo_n "checking for shmat in -lipc... " >&6; }
-if ${ac_cv_lib_ipc_shmat+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lipc  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char shmat ();
-int
-main ()
-{
-return shmat ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_ipc_shmat=yes
-else
-  ac_cv_lib_ipc_shmat=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ipc_shmat" >&5
-$as_echo "$ac_cv_lib_ipc_shmat" >&6; }
-if test "x$ac_cv_lib_ipc_shmat" = xyes; then :
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
-fi
-
-    fi
-  fi
-
-  # Check for libraries that X11R6 Xt/Xaw programs need.
-  ac_save_LDFLAGS=$LDFLAGS
-  test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
-  # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
-  # check for ICE first), but we must link in the order -lSM -lICE or
-  # we get undefined symbols.  So assume we have SM if we have ICE.
-  # These have to be linked with before -lX11, unlike the other
-  # libraries we check for below, so use a different variable.
-  # John Interrante, Karl Berry
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IceConnectionNumber in -lICE" >&5
-$as_echo_n "checking for IceConnectionNumber in -lICE... " >&6; }
-if ${ac_cv_lib_ICE_IceConnectionNumber+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lICE $X_EXTRA_LIBS $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char IceConnectionNumber ();
-int
-main ()
-{
-return IceConnectionNumber ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_ICE_IceConnectionNumber=yes
-else
-  ac_cv_lib_ICE_IceConnectionNumber=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
-$as_echo "$ac_cv_lib_ICE_IceConnectionNumber" >&6; }
-if test "x$ac_cv_lib_ICE_IceConnectionNumber" = xyes; then :
-  X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
-fi
-
-  LDFLAGS=$ac_save_LDFLAGS
-
-fi
-
-fi
-
-ac_aux_dir=
-for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
-  if test -f "$ac_dir/install-sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install-sh -c"
-    break
-  elif test -f "$ac_dir/install.sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install.sh -c"
-    break
-  elif test -f "$ac_dir/shtool"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/shtool install -c"
-    break
-  fi
-done
-if test -z "$ac_aux_dir"; then
-  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
-fi
-
-# These three variables are undocumented and unsupported,
-# and are intended to be withdrawn in a future Autoconf release.
-# They can cause serious problems if a builder's source tree is in a directory
-# whose full name contains unusual characters.
-ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
-ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
-ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
-
-
-# Make sure we can run config.sub.
-$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
-$as_echo_n "checking build system type... " >&6; }
-if ${ac_cv_build+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_build_alias=$build_alias
-test "x$ac_build_alias" = x &&
-  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
-test "x$ac_build_alias" = x &&
-  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
-ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
-$as_echo "$ac_cv_build" >&6; }
-case $ac_cv_build in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
-esac
-build=$ac_cv_build
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_build
-shift
-build_cpu=$1
-build_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-build_os=$*
-IFS=$ac_save_IFS
-case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
-$as_echo_n "checking host system type... " >&6; }
-if ${ac_cv_host+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "x$host_alias" = x; then
-  ac_cv_host=$ac_cv_build
-else
-  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
-$as_echo "$ac_cv_host" >&6; }
-case $ac_cv_host in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
-esac
-host=$ac_cv_host
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_host
-shift
-host_cpu=$1
-host_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-host_os=$*
-IFS=$ac_save_IFS
-case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
-$as_echo_n "checking target system type... " >&6; }
-if ${ac_cv_target+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "x$target_alias" = x; then
-  ac_cv_target=$ac_cv_host
-else
-  ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
-    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5
-$as_echo "$ac_cv_target" >&6; }
-case $ac_cv_target in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;;
-esac
-target=$ac_cv_target
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_target
-shift
-target_cpu=$1
-target_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-target_os=$*
-IFS=$ac_save_IFS
-case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac
-
-
-# The aliases save the names the user supplied, while $host etc.
-# will get canonicalized.
-test -n "$target_alias" &&
-  test "$program_prefix$program_suffix$program_transform_name" = \
-    NONENONEs,x,x, &&
-  program_prefix=${target_alias}-
-
-
-
-use_quartz_opengl=no
-if test x"$enable_opengl" = xyes; then
-  case $target_os in
-  darwin*)
-
-$as_echo "#define USE_QUARTZ_OPENGL 1" >>confdefs.h
-
-    use_quartz_opengl=yes
-    ;;
-  esac
-fi
-
-GLU_FRAMEWORKS=
-GLUT_FRAMEWORKS=
-if test x"$use_quartz_opengl" = xyes; then
-  GLU_FRAMEWORKS=OpenGL
-  GLUT_FRAMEWORKS=GLUT
-fi
-
-
-
-
-
-
-
-if test x"$use_quartz_opengl" = xno; then
-  ac_fn_c_check_func "$LINENO" "atan" "ac_cv_func_atan"
-if test "x$ac_cv_func_atan" = xyes; then :
-  fp_libm_not_needed=yes
-else
-  fp_libm_not_needed=dunno
-fi
-
-  if test x"$fp_libm_not_needed" = xdunno; then
-     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atan in -lm" >&5
-$as_echo_n "checking for atan in -lm... " >&6; }
-if ${ac_cv_lib_m_atan+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char atan ();
-int
-main ()
-{
-return atan ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_m_atan=yes
-else
-  ac_cv_lib_m_atan=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_atan" >&5
-$as_echo "$ac_cv_lib_m_atan" >&6; }
-if test "x$ac_cv_lib_m_atan" = xyes; then :
-  GL_LIBS="-lm $GL_LIBS"
-fi
-
-  fi
-
-  if test x"$no_x" != xyes; then
-    test -n "$x_includes" && GL_CFLAGS="-I$x_includes $GL_CFLAGS"
-    test -n "$x_libraries" && GL_LIBS="-L$x_libraries -lX11 $GL_LIBS"
-  fi
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GL library" >&5
-$as_echo_n "checking for GL library... " >&6; }
-if ${fp_cv_check_GL_lib+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fp_cv_check_GL_lib="no"
-  fp_save_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS ${GL_CFLAGS}"
-  fp_save_LIBS="$LIBS"
-  for fp_try_lib in -lGL -lopengl32; do
-    # transform "-lfoo" to "foo.lib" when using cl
-    if test x"$CC" = xcl; then
-      fp_try_lib=`echo $fp_try_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
-    fi
-    LIBS="$fp_try_lib ${GL_LIBS} $fp_save_LIBS"
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <GL/gl.h>
-int
-main ()
-{
-glEnd()
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  fp_cv_check_GL_lib="$fp_try_lib ${GL_LIBS}"; break
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  done
-  LIBS="$fp_save_LIBS"
-  CPPFLAGS="$fp_save_CPPFLAGS"
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $fp_cv_check_GL_lib" >&5
-$as_echo "$fp_cv_check_GL_lib" >&6; }
-
-  if test x"$fp_cv_check_GL_lib" = xno; then
-    no_GL=yes
-    GL_CFLAGS=
-    GL_LIBS=
-  else
-    GL_CFLAGS0="${GL_CFLAGS}"
-    GL_CFLAGS="$CPPFLAGS ${GL_CFLAGS0}"
-    GL_LIBS0="$fp_cv_check_GL_lib"
-    GL_LIBS="$LDFLAGS ${GL_LIBS0}"
-  fi
-
-
-  if test x"$fp_is_win32" = xyes; then
-    # Ugly: To get wglGetProcAddress on Windows, we have to link with
-    # opengl32.dll, too, even when we are using Cygwin with X11.
-    case "$GL_LIBS" in
-      *-lopengl32*|*opengl32.lib*) ;;
-      *) fp_save_LIBS="$LIBS"
-         LIBS="$LIBS -lopengl32"
-         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <GL/gl.h>
-int
-main ()
-{
-glEnd()
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  GL_LIBS="$GL_LIBS -lopengl32"; GL_LIBS0="$GL_LIBS0 -lopengl32"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-         LIBS="$fp_save_LIBS"
-         ;;
-    esac
-  fi
-fi
-
-
-
-GLU_CFLAGS="$GL_CFLAGS0"
-GLU_LIBS="$GL_LIBS0"
-
-if test x"$use_quartz_opengl" = xno; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLU library" >&5
-$as_echo_n "checking for GLU library... " >&6; }
-if ${fp_cv_check_GLU_lib+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fp_cv_check_GLU_lib="no"
-  fp_save_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS ${GLU_CFLAGS}"
-  fp_save_LIBS="$LIBS"
-  for fp_try_lib in -lglu32 -lGLU; do
-    # transform "-lfoo" to "foo.lib" when using cl
-    if test x"$CC" = xcl; then
-      fp_try_lib=`echo $fp_try_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
-    fi
-    LIBS="$fp_try_lib ${GLU_LIBS} $fp_save_LIBS"
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <GL/glu.h>
-int
-main ()
-{
-gluNewQuadric()
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  fp_cv_check_GLU_lib="$fp_try_lib ${GLU_LIBS}"; break
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  done
-  LIBS="$fp_save_LIBS"
-  CPPFLAGS="$fp_save_CPPFLAGS"
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $fp_cv_check_GLU_lib" >&5
-$as_echo "$fp_cv_check_GLU_lib" >&6; }
-
-  if test x"$fp_cv_check_GLU_lib" = xno; then
-    no_GLU=yes
-    GLU_CFLAGS=
-    GLU_LIBS=
-  else
-    GLU_CFLAGS0="${GLU_CFLAGS}"
-    GLU_CFLAGS="$CPPFLAGS ${GLU_CFLAGS0}"
-    GLU_LIBS0="$fp_cv_check_GLU_lib"
-    GLU_LIBS="$LDFLAGS ${GLU_LIBS0}"
-  fi
-
-fi
-
-
-
-
-
-if test x"$GLU_LIBS" = xno; then
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "no OpenGL library found, so this package cannot be built
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-
-# check for OpenGL include files
-gl_found_header=no
-glu_found_header=no
-fp_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
-$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if ${ac_cv_path_GREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$GREP"; then
-  ac_path_GREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in grep ggrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
-# Check for GNU ac_path_GREP and select it if it is found.
-  # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'GREP' >> "conftest.nl"
-    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_GREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_GREP="$ac_path_GREP"
-      ac_path_GREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_GREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_GREP"; then
-    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_GREP=$GREP
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
-$as_echo "$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-$as_echo_n "checking for egrep... " >&6; }
-if ${ac_cv_path_EGREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
-   then ac_cv_path_EGREP="$GREP -E"
-   else
-     if test -z "$EGREP"; then
-  ac_path_EGREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in egrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
-  # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'EGREP' >> "conftest.nl"
-    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_EGREP="$ac_path_EGREP"
-      ac_path_EGREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_EGREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_EGREP=$EGREP
-fi
-
-   fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-$as_echo "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if ${ac_cv_header_stdc+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_header_stdc=yes
-else
-  ac_cv_header_stdc=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then :
-  :
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
-		   (('a' <= (c) && (c) <= 'i') \
-		     || ('j' <= (c) && (c) <= 'r') \
-		     || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-	|| toupper (i) != TOUPPER (i))
-      return 2;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
-$as_echo "$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-$as_echo "#define STDC_HEADERS 1" >>confdefs.h
-
-fi
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-		  inttypes.h stdint.h unistd.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-for ac_header in GL/gl.h OpenGL/gl.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
- gl_found_header=yes
-fi
-
-done
-
-for ac_header in GL/glu.h OpenGL/glu.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
- glu_found_header=yes
-fi
-
-done
-
-CPPFLAGS="$fp_save_cppflags"
-
-if test x"$gl_found_header" = xno || test x"$glu_found_header" = xno; then
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "no OpenGL headers found, so this package cannot be built
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-
-GL_BUILD_PACKAGE=yes
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLboolean" >&5
-$as_echo_n "checking Haskell type for GLboolean... " >&6; }
-if ${fptools_cv_htype_GLboolean+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLboolean=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLboolean=NotReallyATypeCross; fptools_cv_htype_sup_GLboolean=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLboolean testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLboolean=`cat conftestval`
-else
-  fptools_cv_htype_GLboolean=NotReallyAType; fptools_cv_htype_sup_GLboolean=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLboolean" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLboolean" >&5
-$as_echo "$fptools_cv_htype_GLboolean" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLBOOLEAN $fptools_cv_htype_GLboolean
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLbyte" >&5
-$as_echo_n "checking Haskell type for GLbyte... " >&6; }
-if ${fptools_cv_htype_GLbyte+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLbyte=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLbyte=NotReallyATypeCross; fptools_cv_htype_sup_GLbyte=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLbyte testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLbyte=`cat conftestval`
-else
-  fptools_cv_htype_GLbyte=NotReallyAType; fptools_cv_htype_sup_GLbyte=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLbyte" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLbyte" >&5
-$as_echo "$fptools_cv_htype_GLbyte" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLBYTE $fptools_cv_htype_GLbyte
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLubyte" >&5
-$as_echo_n "checking Haskell type for GLubyte... " >&6; }
-if ${fptools_cv_htype_GLubyte+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLubyte=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLubyte=NotReallyATypeCross; fptools_cv_htype_sup_GLubyte=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLubyte testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLubyte=`cat conftestval`
-else
-  fptools_cv_htype_GLubyte=NotReallyAType; fptools_cv_htype_sup_GLubyte=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLubyte" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLubyte" >&5
-$as_echo "$fptools_cv_htype_GLubyte" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLUBYTE $fptools_cv_htype_GLubyte
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLshort" >&5
-$as_echo_n "checking Haskell type for GLshort... " >&6; }
-if ${fptools_cv_htype_GLshort+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLshort=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLshort=NotReallyATypeCross; fptools_cv_htype_sup_GLshort=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLshort testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLshort=`cat conftestval`
-else
-  fptools_cv_htype_GLshort=NotReallyAType; fptools_cv_htype_sup_GLshort=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLshort" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLshort" >&5
-$as_echo "$fptools_cv_htype_GLshort" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLSHORT $fptools_cv_htype_GLshort
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLushort" >&5
-$as_echo_n "checking Haskell type for GLushort... " >&6; }
-if ${fptools_cv_htype_GLushort+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLushort=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLushort=NotReallyATypeCross; fptools_cv_htype_sup_GLushort=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLushort testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLushort=`cat conftestval`
-else
-  fptools_cv_htype_GLushort=NotReallyAType; fptools_cv_htype_sup_GLushort=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLushort" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLushort" >&5
-$as_echo "$fptools_cv_htype_GLushort" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLUSHORT $fptools_cv_htype_GLushort
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLint" >&5
-$as_echo_n "checking Haskell type for GLint... " >&6; }
-if ${fptools_cv_htype_GLint+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLint=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLint=NotReallyATypeCross; fptools_cv_htype_sup_GLint=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLint testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLint=`cat conftestval`
-else
-  fptools_cv_htype_GLint=NotReallyAType; fptools_cv_htype_sup_GLint=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLint" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLint" >&5
-$as_echo "$fptools_cv_htype_GLint" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLINT $fptools_cv_htype_GLint
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLuint" >&5
-$as_echo_n "checking Haskell type for GLuint... " >&6; }
-if ${fptools_cv_htype_GLuint+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLuint=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLuint=NotReallyATypeCross; fptools_cv_htype_sup_GLuint=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLuint testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLuint=`cat conftestval`
-else
-  fptools_cv_htype_GLuint=NotReallyAType; fptools_cv_htype_sup_GLuint=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLuint" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLuint" >&5
-$as_echo "$fptools_cv_htype_GLuint" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLUINT $fptools_cv_htype_GLuint
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLsizei" >&5
-$as_echo_n "checking Haskell type for GLsizei... " >&6; }
-if ${fptools_cv_htype_GLsizei+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLsizei=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLsizei=NotReallyATypeCross; fptools_cv_htype_sup_GLsizei=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLsizei testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLsizei=`cat conftestval`
-else
-  fptools_cv_htype_GLsizei=NotReallyAType; fptools_cv_htype_sup_GLsizei=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLsizei" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLsizei" >&5
-$as_echo "$fptools_cv_htype_GLsizei" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLSIZEI $fptools_cv_htype_GLsizei
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLenum" >&5
-$as_echo_n "checking Haskell type for GLenum... " >&6; }
-if ${fptools_cv_htype_GLenum+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLenum=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLenum=NotReallyATypeCross; fptools_cv_htype_sup_GLenum=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLenum testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLenum=`cat conftestval`
-else
-  fptools_cv_htype_GLenum=NotReallyAType; fptools_cv_htype_sup_GLenum=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLenum" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLenum" >&5
-$as_echo "$fptools_cv_htype_GLenum" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLENUM $fptools_cv_htype_GLenum
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLbitfield" >&5
-$as_echo_n "checking Haskell type for GLbitfield... " >&6; }
-if ${fptools_cv_htype_GLbitfield+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLbitfield=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLbitfield=NotReallyATypeCross; fptools_cv_htype_sup_GLbitfield=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLbitfield testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLbitfield=`cat conftestval`
-else
-  fptools_cv_htype_GLbitfield=NotReallyAType; fptools_cv_htype_sup_GLbitfield=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLbitfield" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLbitfield" >&5
-$as_echo "$fptools_cv_htype_GLbitfield" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLBITFIELD $fptools_cv_htype_GLbitfield
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLfloat" >&5
-$as_echo_n "checking Haskell type for GLfloat... " >&6; }
-if ${fptools_cv_htype_GLfloat+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLfloat=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLfloat=NotReallyATypeCross; fptools_cv_htype_sup_GLfloat=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLfloat testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLfloat=`cat conftestval`
-else
-  fptools_cv_htype_GLfloat=NotReallyAType; fptools_cv_htype_sup_GLfloat=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLfloat" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLfloat" >&5
-$as_echo "$fptools_cv_htype_GLfloat" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLFLOAT $fptools_cv_htype_GLfloat
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLclampf" >&5
-$as_echo_n "checking Haskell type for GLclampf... " >&6; }
-if ${fptools_cv_htype_GLclampf+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLclampf=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLclampf=NotReallyATypeCross; fptools_cv_htype_sup_GLclampf=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLclampf testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLclampf=`cat conftestval`
-else
-  fptools_cv_htype_GLclampf=NotReallyAType; fptools_cv_htype_sup_GLclampf=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLclampf" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLclampf" >&5
-$as_echo "$fptools_cv_htype_GLclampf" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLCLAMPF $fptools_cv_htype_GLclampf
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLdouble" >&5
-$as_echo_n "checking Haskell type for GLdouble... " >&6; }
-if ${fptools_cv_htype_GLdouble+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLdouble=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLdouble=NotReallyATypeCross; fptools_cv_htype_sup_GLdouble=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLdouble testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLdouble=`cat conftestval`
-else
-  fptools_cv_htype_GLdouble=NotReallyAType; fptools_cv_htype_sup_GLdouble=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLdouble" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLdouble" >&5
-$as_echo "$fptools_cv_htype_GLdouble" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLDOUBLE $fptools_cv_htype_GLdouble
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLclampd" >&5
-$as_echo_n "checking Haskell type for GLclampd... " >&6; }
-if ${fptools_cv_htype_GLclampd+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLclampd=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLclampd=NotReallyATypeCross; fptools_cv_htype_sup_GLclampd=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLclampd testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLclampd=`cat conftestval`
-else
-  fptools_cv_htype_GLclampd=NotReallyAType; fptools_cv_htype_sup_GLclampd=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLclampd" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLclampd" >&5
-$as_echo "$fptools_cv_htype_GLclampd" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLCLAMPD $fptools_cv_htype_GLclampd
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-
-# cruel hack for ancient Windows headers
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for char" >&5
-$as_echo_n "checking Haskell type for char... " >&6; }
-if ${fptools_cv_htype_char+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_char=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_char=NotReallyATypeCross; fptools_cv_htype_sup_char=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef char testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_char=`cat conftestval`
-else
-  fptools_cv_htype_char=NotReallyAType; fptools_cv_htype_sup_char=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_char" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_char" >&5
-$as_echo "$fptools_cv_htype_char" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_CHAR $fptools_cv_htype_char
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLchar" >&5
-$as_echo_n "checking Haskell type for GLchar... " >&6; }
-if ${fptools_cv_htype_GLchar+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLchar=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLchar=NotReallyATypeCross; fptools_cv_htype_sup_GLchar=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLchar testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLchar=`cat conftestval`
-else
-  fptools_cv_htype_GLchar=$fptools_cv_htype_char
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLchar" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLchar" >&5
-$as_echo "$fptools_cv_htype_GLchar" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLCHAR $fptools_cv_htype_GLchar
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-
-# ... and a similar hack
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for ptrdiff_t" >&5
-$as_echo_n "checking Haskell type for ptrdiff_t... " >&6; }
-if ${fptools_cv_htype_ptrdiff_t+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_ptrdiff_t=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_ptrdiff_t=NotReallyATypeCross; fptools_cv_htype_sup_ptrdiff_t=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef ptrdiff_t testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_ptrdiff_t=`cat conftestval`
-else
-  fptools_cv_htype_ptrdiff_t=NotReallyAType; fptools_cv_htype_sup_ptrdiff_t=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_ptrdiff_t" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_ptrdiff_t" >&5
-$as_echo "$fptools_cv_htype_ptrdiff_t" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_PTRDIFF_T $fptools_cv_htype_ptrdiff_t
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLintptr" >&5
-$as_echo_n "checking Haskell type for GLintptr... " >&6; }
-if ${fptools_cv_htype_GLintptr+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLintptr=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLintptr=NotReallyATypeCross; fptools_cv_htype_sup_GLintptr=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLintptr testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLintptr=`cat conftestval`
-else
-  fptools_cv_htype_GLintptr=$fptools_cv_htype_ptrdiff_t
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLintptr" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLintptr" >&5
-$as_echo "$fptools_cv_htype_GLintptr" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLINTPTR $fptools_cv_htype_GLintptr
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Haskell type for GLsizeiptr" >&5
-$as_echo_n "checking Haskell type for GLsizeiptr... " >&6; }
-if ${fptools_cv_htype_GLsizeiptr+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  fptools_cv_htype_sup_GLsizeiptr=yes
-fp_check_htype_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-if test "$cross_compiling" = yes; then :
-  fptools_cv_htype_GLsizeiptr=NotReallyATypeCross; fptools_cv_htype_sup_GLsizeiptr=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <stddef.h>
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#if HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-
-#if HAVE_TIME_H
-# include <time.h>
-#endif
-
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#if defined(HAVE_GL_GL_H)
-# include <GL/gl.h>
-#elif defined(HAVE_OPENGL_GL_H)
-# include <OpenGL/gl.h>
-#endif
-
-#if defined(HAVE_AL_AL_H)
-# include <AL/al.h>
-#elif defined(HAVE_OPENAL_AL_H)
-# include <OpenAL/al.h>
-#endif
-
-#if defined(HAVE_AL_ALC_H)
-# include <AL/alc.h>
-#elif defined(HAVE_OPENAL_ALC_H)
-# include <OpenAL/alc.h>
-#endif
-
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-typedef GLsizeiptr testing;
-
-main() {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
-    fprintf(f, "%s%d\n",
-           ((testing)(-1) < (testing)0) ? "Int" : "Word",
-           sizeof(testing)*8);
-  } else {
-    fprintf(f,"%s\n",
-           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
-           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
-  }
-  fclose(f);
-  exit(0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  fptools_cv_htype_GLsizeiptr=`cat conftestval`
-else
-  fptools_cv_htype_GLsizeiptr=$fptools_cv_htype_ptrdiff_t
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-CPPFLAGS="$fp_check_htype_save_cppflags"
-fi
- if test "$fptools_cv_htype_sup_GLsizeiptr" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fptools_cv_htype_GLsizeiptr" >&5
-$as_echo "$fptools_cv_htype_GLsizeiptr" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define HTYPE_GLSIZEIPTR $fptools_cv_htype_GLsizeiptr
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not supported" >&5
-$as_echo "not supported" >&6; }
-fi
-
-
-
-cat >>confdefs.h <<_ACEOF
-#define GLU_CFLAGS `echo '' $GLU_CFLAGS | sed -e 's/-[^ ]*/,"&"/g' -e 's/^ *,//'`
-_ACEOF
-
-
-
-cat >>confdefs.h <<_ACEOF
-#define GLU_LIBS `echo '' $GLU_LIBS | sed -e 's/-[^ ]*/,"&"/g' -e 's/^ *,//'`
-_ACEOF
-
-
-
-cat >>confdefs.h <<_ACEOF
-#define GLU_FRAMEWORKS `echo '' $GLU_FRAMEWORKS | sed -e 's/-[^ ]*/,"&"/g' -e 's/^ *,//'`
-_ACEOF
-
-
-fi
-
-if test x"$GL_BUILD_PACKAGE" = xyes; then
-  BUILD_PACKAGE_BOOL=True
-else
-  BUILD_PACKAGE_BOOL=False
-fi
-
-
-case "$host" in
-*-mingw32) CALLCONV=stdcall ;;
-*)	CALLCONV=ccall ;;
-esac
-
-
-ac_config_files="$ac_config_files OpenGL.buildinfo"
-
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems.  If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, we kill variables containing newlines.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(
-  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
-    eval ac_val=\$$ac_var
-    case $ac_val in #(
-    *${as_nl}*)
-      case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
-      esac
-      case $ac_var in #(
-      _ | IFS | as_nl) ;; #(
-      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-      *) { eval $ac_var=; unset $ac_var;} ;;
-      esac ;;
-    esac
-  done
-
-  (set) 2>&1 |
-    case $as_nl`(ac_space=' '; set) 2>&1` in #(
-    *${as_nl}ac_space=\ *)
-      # `set' does not quote correctly, so add quotes: double-quote
-      # substitution turns \\\\ into \\, and sed turns \\ into \.
-      sed -n \
-	"s/'/'\\\\''/g;
-	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
-      ;; #(
-    *)
-      # `set' quotes correctly as required by POSIX, so do not add quotes.
-      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
-      ;;
-    esac |
-    sort
-) |
-  sed '
-     /^ac_cv_env_/b end
-     t clear
-     :clear
-     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
-     t end
-     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
-     :end' >>confcache
-if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
-  if test -w "$cache_file"; then
-    if test "x$cache_file" != "x/dev/null"; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
-$as_echo "$as_me: updating cache $cache_file" >&6;}
-      if test ! -f "$cache_file" || test -h "$cache_file"; then
-	cat confcache >"$cache_file"
-      else
-        case $cache_file in #(
-        */* | ?:*)
-	  mv -f confcache "$cache_file"$$ &&
-	  mv -f "$cache_file"$$ "$cache_file" ;; #(
-        *)
-	  mv -f confcache "$cache_file" ;;
-	esac
-      fi
-    fi
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
-$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
-  fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-U=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
-  # 1. Remove the extension, and $U if already installed.
-  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
-  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
-  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
-  #    will be set to the directory where LIBOBJS objects are built.
-  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
-  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
-
-: "${CONFIG_STATUS=./config.status}"
-ac_write_fail=0
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
-$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
-as_write_fail=0
-cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-
-SHELL=\${CONFIG_SHELL-$SHELL}
-export SHELL
-_ASEOF
-cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
-
-# Be more Bourne compatible
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
-fi
-
-
-as_nl='
-'
-export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='printf %s\n'
-  as_echo_n='printf %s'
-else
-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
-    as_echo_n='/usr/ucb/echo -n'
-  else
-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-    as_echo_n_body='eval
-      arg=$1;
-      case $arg in #(
-      *"$as_nl"*)
-	expr "X$arg" : "X\\(.*\\)$as_nl";
-	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-      esac;
-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-    '
-    export as_echo_n_body
-    as_echo_n='sh -c $as_echo_n_body as_echo'
-  fi
-  export as_echo_body
-  as_echo='sh -c $as_echo_body as_echo'
-fi
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  PATH_SEPARATOR=:
-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
-    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
-      PATH_SEPARATOR=';'
-  }
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.  Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" ""	$as_nl"
-
-# Find who we are.  Look in the path if we contain no directory separator.
-as_myself=
-case $0 in #((
-  *[\\/]* ) as_myself=$0 ;;
-  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-  done
-IFS=$as_save_IFS
-
-     ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
-  as_myself=$0
-fi
-if test ! -f "$as_myself"; then
-  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-  exit 1
-fi
-
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
-as_fn_error ()
-{
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-  fi
-  $as_echo "$as_me: error: $2" >&2
-  as_fn_exit $as_status
-} # as_fn_error
-
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
-  return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
-  set +e
-  as_fn_set_status $1
-  exit $1
-} # as_fn_exit
-
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
-  { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
-  eval 'as_fn_append ()
-  {
-    eval $1+=\$2
-  }'
-else
-  as_fn_append ()
-  {
-    eval $1=\$$1\$2
-  }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
-  eval 'as_fn_arith ()
-  {
-    as_val=$(( $* ))
-  }'
-else
-  as_fn_arith ()
-  {
-    as_val=`expr "$@" || test $? -eq 1`
-  }
-fi # as_fn_arith
-
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
-   test "X`expr 00001 : '.*\(...\)'`" = X001; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
-  as_basename=basename
-else
-  as_basename=false
-fi
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-  as_dirname=dirname
-else
-  as_dirname=false
-fi
-
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
--n*)
-  case `echo 'xy\c'` in
-  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
-  xy)  ECHO_C='\c';;
-  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
-       ECHO_T='	';;
-  esac;;
-*)
-  ECHO_N='-n';;
-esac
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
-  rm -f conf$$.dir/conf$$.file
-else
-  rm -f conf$$.dir
-  mkdir conf$$.dir 2>/dev/null
-fi
-if (echo >conf$$.file) 2>/dev/null; then
-  if ln -s conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s='ln -s'
-    # ... but there are two gotchas:
-    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
-    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
-    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
-  elif ln conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s=ln
-  else
-    as_ln_s='cp -p'
-  fi
-else
-  as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
-  case $as_dir in #(
-  -*) as_dir=./$as_dir;;
-  esac
-  test -d "$as_dir" || eval $as_mkdir_p || {
-    as_dirs=
-    while :; do
-      case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-      *) as_qdir=$as_dir;;
-      esac
-      as_dirs="'$as_qdir' $as_dirs"
-      as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-      test -d "$as_dir" && break
-    done
-    test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
-if mkdir -p . 2>/dev/null; then
-  as_mkdir_p='mkdir -p "$as_dir"'
-else
-  test -d ./-p && rmdir ./-p
-  as_mkdir_p=false
-fi
-
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-exec 6>&1
-## ----------------------------------- ##
-## Main body of $CONFIG_STATUS script. ##
-## ----------------------------------- ##
-_ASEOF
-test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# Save the log message, to keep $0 and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling.
-ac_log="
-This file was extended by Haskell OpenGL package $as_me 2.2.3.0, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
-
-  CONFIG_FILES    = $CONFIG_FILES
-  CONFIG_HEADERS  = $CONFIG_HEADERS
-  CONFIG_LINKS    = $CONFIG_LINKS
-  CONFIG_COMMANDS = $CONFIG_COMMANDS
-  $ $0 $@
-
-on `(hostname || uname -n) 2>/dev/null | sed 1q`
-"
-
-_ACEOF
-
-case $ac_config_files in *"
-"*) set x $ac_config_files; shift; ac_config_files=$*;;
-esac
-
-case $ac_config_headers in *"
-"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
-esac
-
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-# Files that config.status was made for.
-config_files="$ac_config_files"
-config_headers="$ac_config_headers"
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-ac_cs_usage="\
-\`$as_me' instantiates files and other configuration actions
-from templates according to the current configuration.  Unless the files
-and actions are specified as TAGs, all are instantiated by default.
-
-Usage: $0 [OPTION]... [TAG]...
-
-  -h, --help       print this help, then exit
-  -V, --version    print version number and configuration settings, then exit
-      --config     print configuration, then exit
-  -q, --quiet, --silent
-                   do not print progress messages
-  -d, --debug      don't remove temporary files
-      --recheck    update $as_me by reconfiguring in the same conditions
-      --file=FILE[:TEMPLATE]
-                   instantiate the configuration file FILE
-      --header=FILE[:TEMPLATE]
-                   instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Report bugs to <sven.panne@aedion.de>."
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
-ac_cs_version="\\
-Haskell OpenGL package config.status 2.2.3.0
-configured by $0, generated by GNU Autoconf 2.68,
-  with options \\"\$ac_cs_config\\"
-
-Copyright (C) 2010 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-
-ac_pwd='$ac_pwd'
-srcdir='$srcdir'
-test -n "\$AWK" || AWK=awk
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# The default lists apply if the user does not specify any file.
-ac_need_defaults=:
-while test $# != 0
-do
-  case $1 in
-  --*=?*)
-    ac_option=`expr "X$1" : 'X\([^=]*\)='`
-    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
-    ac_shift=:
-    ;;
-  --*=)
-    ac_option=`expr "X$1" : 'X\([^=]*\)='`
-    ac_optarg=
-    ac_shift=:
-    ;;
-  *)
-    ac_option=$1
-    ac_optarg=$2
-    ac_shift=shift
-    ;;
-  esac
-
-  case $ac_option in
-  # Handling of the options.
-  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    ac_cs_recheck=: ;;
-  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
-    $as_echo "$ac_cs_version"; exit ;;
-  --config | --confi | --conf | --con | --co | --c )
-    $as_echo "$ac_cs_config"; exit ;;
-  --debug | --debu | --deb | --de | --d | -d )
-    debug=: ;;
-  --file | --fil | --fi | --f )
-    $ac_shift
-    case $ac_optarg in
-    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    '') as_fn_error $? "missing file argument" ;;
-    esac
-    as_fn_append CONFIG_FILES " '$ac_optarg'"
-    ac_need_defaults=false;;
-  --header | --heade | --head | --hea )
-    $ac_shift
-    case $ac_optarg in
-    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    esac
-    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
-    ac_need_defaults=false;;
-  --he | --h)
-    # Conflict between --help and --header
-    as_fn_error $? "ambiguous option: \`$1'
-Try \`$0 --help' for more information.";;
-  --help | --hel | -h )
-    $as_echo "$ac_cs_usage"; exit ;;
-  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-  | -silent | --silent | --silen | --sile | --sil | --si | --s)
-    ac_cs_silent=: ;;
-
-  # This is an error.
-  -*) as_fn_error $? "unrecognized option: \`$1'
-Try \`$0 --help' for more information." ;;
-
-  *) as_fn_append ac_config_targets " $1"
-     ac_need_defaults=false ;;
-
-  esac
-  shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
-  exec 6>/dev/null
-  ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-if \$ac_cs_recheck; then
-  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-  shift
-  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
-  CONFIG_SHELL='$SHELL'
-  export CONFIG_SHELL
-  exec "\$@"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-exec 5>>config.log
-{
-  echo
-  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-  $as_echo "$ac_log"
-} >&5
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-
-# Handling of arguments.
-for ac_config_target in $ac_config_targets
-do
-  case $ac_config_target in
-    "include/HsOpenGLConfig.h") CONFIG_HEADERS="$CONFIG_HEADERS include/HsOpenGLConfig.h" ;;
-    "include/HsOpenGL.h") CONFIG_HEADERS="$CONFIG_HEADERS include/HsOpenGL.h" ;;
-    "OpenGL.buildinfo") CONFIG_FILES="$CONFIG_FILES OpenGL.buildinfo" ;;
-
-  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
-  esac
-done
-
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used.  Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
-  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
-  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-fi
-
-# Have a temporary directory for convenience.  Make it in the build tree
-# simply because there is no reason against having it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Hook for its removal unless debugging.
-# Note that there is a small window in which the directory will not be cleaned:
-# after its creation but before its name has been assigned to `$tmp'.
-$debug ||
-{
-  tmp= ac_tmp=
-  trap 'exit_status=$?
-  : "${ac_tmp:=$tmp}"
-  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
-' 0
-  trap 'as_fn_exit 1' 1 2 13 15
-}
-# Create a (secure) tmp directory for tmp files.
-
-{
-  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
-  test -d "$tmp"
-}  ||
-{
-  tmp=./conf$$-$RANDOM
-  (umask 077 && mkdir "$tmp")
-} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
-ac_tmp=$tmp
-
-# Set up the scripts for CONFIG_FILES section.
-# No need to generate them if there are no CONFIG_FILES.
-# This happens for instance with `./config.status config.h'.
-if test -n "$CONFIG_FILES"; then
-
-
-ac_cr=`echo X | tr X '\015'`
-# On cygwin, bash can eat \r inside `` if the user requested igncr.
-# But we know of no other shell where ac_cr would be empty at this
-# point, so we can use a bashism as a fallback.
-if test "x$ac_cr" = x; then
-  eval ac_cr=\$\'\\r\'
-fi
-ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
-if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
-  ac_cs_awk_cr='\\r'
-else
-  ac_cs_awk_cr=$ac_cr
-fi
-
-echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
-_ACEOF
-
-
-{
-  echo "cat >conf$$subs.awk <<_ACEOF" &&
-  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
-  echo "_ACEOF"
-} >conf$$subs.sh ||
-  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
-ac_delim='%!_!# '
-for ac_last_try in false false false false false :; do
-  . ./conf$$subs.sh ||
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-
-  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
-  if test $ac_delim_n = $ac_delim_num; then
-    break
-  elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-  else
-    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
-  fi
-done
-rm -f conf$$subs.sh
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
-_ACEOF
-sed -n '
-h
-s/^/S["/; s/!.*/"]=/
-p
-g
-s/^[^!]*!//
-:repl
-t repl
-s/'"$ac_delim"'$//
-t delim
-:nl
-h
-s/\(.\{148\}\)..*/\1/
-t more1
-s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
-p
-n
-b repl
-:more1
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t nl
-:delim
-h
-s/\(.\{148\}\)..*/\1/
-t more2
-s/["\\]/\\&/g; s/^/"/; s/$/"/
-p
-b
-:more2
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t delim
-' <conf$$subs.awk | sed '
-/^[^""]/{
-  N
-  s/\n//
-}
-' >>$CONFIG_STATUS || ac_write_fail=1
-rm -f conf$$subs.awk
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-_ACAWK
-cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
-  for (key in S) S_is_set[key] = 1
-  FS = ""
-
-}
-{
-  line = $ 0
-  nfields = split(line, field, "@")
-  substed = 0
-  len = length(field[1])
-  for (i = 2; i < nfields; i++) {
-    key = field[i]
-    keylen = length(key)
-    if (S_is_set[key]) {
-      value = S[key]
-      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
-      len += length(value) + length(field[++i])
-      substed = 1
-    } else
-      len += 1 + keylen
-  }
-
-  print line
-}
-
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
-  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
-else
-  cat
-fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
-  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
-_ACEOF
-
-# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
-# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
-h
-s///
-s/^/:/
-s/[	 ]*$/:/
-s/:\$(srcdir):/:/g
-s/:\${srcdir}:/:/g
-s/:@srcdir@:/:/g
-s/^:*//
-s/:*$//
-x
-s/\(=[	 ]*\).*/\1/
-G
-s/\n//
-s/^[^=]*=[	 ]*$//
-}'
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-fi # test -n "$CONFIG_FILES"
-
-# Set up the scripts for CONFIG_HEADERS section.
-# No need to generate them if there are no CONFIG_HEADERS.
-# This happens for instance with `./config.status Makefile'.
-if test -n "$CONFIG_HEADERS"; then
-cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
-BEGIN {
-_ACEOF
-
-# Transform confdefs.h into an awk script `defines.awk', embedded as
-# here-document in config.status, that substitutes the proper values into
-# config.h.in to produce config.h.
-
-# Create a delimiter string that does not exist in confdefs.h, to ease
-# handling of long lines.
-ac_delim='%!_!# '
-for ac_last_try in false false :; do
-  ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
-  if test -z "$ac_tt"; then
-    break
-  elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
-  else
-    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
-  fi
-done
-
-# For the awk script, D is an array of macro values keyed by name,
-# likewise P contains macro parameters if any.  Preserve backslash
-# newline sequences.
-
-ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
-sed -n '
-s/.\{148\}/&'"$ac_delim"'/g
-t rset
-:rset
-s/^[	 ]*#[	 ]*define[	 ][	 ]*/ /
-t def
-d
-:def
-s/\\$//
-t bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3"/p
-s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2"/p
-d
-:bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3\\\\\\n"\\/p
-t cont
-s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
-t cont
-d
-:cont
-n
-s/.\{148\}/&'"$ac_delim"'/g
-t clear
-:clear
-s/\\$//
-t bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/"/p
-d
-:bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
-b cont
-' <confdefs.h | sed '
-s/'"$ac_delim"'/"\\\
-"/g' >>$CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-  for (key in D) D_is_set[key] = 1
-  FS = ""
-}
-/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
-  line = \$ 0
-  split(line, arg, " ")
-  if (arg[1] == "#") {
-    defundef = arg[2]
-    mac1 = arg[3]
-  } else {
-    defundef = substr(arg[1], 2)
-    mac1 = arg[2]
-  }
-  split(mac1, mac2, "(") #)
-  macro = mac2[1]
-  prefix = substr(line, 1, index(line, defundef) - 1)
-  if (D_is_set[macro]) {
-    # Preserve the white space surrounding the "#".
-    print prefix "define", macro P[macro] D[macro]
-    next
-  } else {
-    # Replace #undef with comments.  This is necessary, for example,
-    # in the case of _POSIX_SOURCE, which is predefined and required
-    # on some systems where configure will not decide to define it.
-    if (defundef == "undef") {
-      print "/*", prefix defundef, macro, "*/"
-      next
-    }
-  }
-}
-{ print }
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
-fi # test -n "$CONFIG_HEADERS"
-
-
-eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    "
-shift
-for ac_tag
-do
-  case $ac_tag in
-  :[FHLC]) ac_mode=$ac_tag; continue;;
-  esac
-  case $ac_mode$ac_tag in
-  :[FHL]*:*);;
-  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
-  :[FH]-) ac_tag=-:-;;
-  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
-  esac
-  ac_save_IFS=$IFS
-  IFS=:
-  set x $ac_tag
-  IFS=$ac_save_IFS
-  shift
-  ac_file=$1
-  shift
-
-  case $ac_mode in
-  :L) ac_source=$1;;
-  :[FH])
-    ac_file_inputs=
-    for ac_f
-    do
-      case $ac_f in
-      -) ac_f="$ac_tmp/stdin";;
-      *) # Look for the file first in the build tree, then in the source tree
-	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
-	 # because $ac_f cannot contain `:'.
-	 test -f "$ac_f" ||
-	   case $ac_f in
-	   [\\/$]*) false;;
-	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
-	   esac ||
-	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
-      esac
-      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
-      as_fn_append ac_file_inputs " '$ac_f'"
-    done
-
-    # Let's still pretend it is `configure' which instantiates (i.e., don't
-    # use $as_me), people would be surprised to read:
-    #    /* config.h.  Generated by config.status.  */
-    configure_input='Generated from '`
-	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
-	`' by configure.'
-    if test x"$ac_file" != x-; then
-      configure_input="$ac_file.  $configure_input"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
-$as_echo "$as_me: creating $ac_file" >&6;}
-    fi
-    # Neutralize special characters interpreted by sed in replacement strings.
-    case $configure_input in #(
-    *\&* | *\|* | *\\* )
-       ac_sed_conf_input=`$as_echo "$configure_input" |
-       sed 's/[\\\\&|]/\\\\&/g'`;; #(
-    *) ac_sed_conf_input=$configure_input;;
-    esac
-
-    case $ac_tag in
-    *:-:* | *:-) cat >"$ac_tmp/stdin" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
-    esac
-    ;;
-  esac
-
-  ac_dir=`$as_dirname -- "$ac_file" ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$ac_file" : 'X\(//\)[^/]' \| \
-	 X"$ac_file" : 'X\(//\)$' \| \
-	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$ac_file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-  as_dir="$ac_dir"; as_fn_mkdir_p
-  ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
-  # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
-  case $ac_top_builddir_sub in
-  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
-  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
-  esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
-  .)  # We are building in place.
-    ac_srcdir=.
-    ac_top_srcdir=$ac_top_builddir_sub
-    ac_abs_top_srcdir=$ac_pwd ;;
-  [\\/]* | ?:[\\/]* )  # Absolute name.
-    ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir
-    ac_abs_top_srcdir=$srcdir ;;
-  *) # Relative name.
-    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_build_prefix$srcdir
-    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
-
-  case $ac_mode in
-  :F)
-  #
-  # CONFIG_FILE
-  #
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# If the template does not know about datarootdir, expand it.
-# FIXME: This hack should be removed a few years after 2.60.
-ac_datarootdir_hack=; ac_datarootdir_seen=
-ac_sed_dataroot='
-/datarootdir/ {
-  p
-  q
-}
-/@datadir@/p
-/@docdir@/p
-/@infodir@/p
-/@localedir@/p
-/@mandir@/p'
-case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
-*datarootdir*) ac_datarootdir_seen=yes;;
-*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
-$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-  ac_datarootdir_hack='
-  s&@datadir@&$datadir&g
-  s&@docdir@&$docdir&g
-  s&@infodir@&$infodir&g
-  s&@localedir@&$localedir&g
-  s&@mandir@&$mandir&g
-  s&\\\${datarootdir}&$datarootdir&g' ;;
-esac
-_ACEOF
-
-# Neutralize VPATH when `$srcdir' = `.'.
-# Shell code in configure.ac might set extrasub.
-# FIXME: do we really want to maintain this feature?
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_sed_extra="$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s|@configure_input@|$ac_sed_conf_input|;t t
-s&@top_builddir@&$ac_top_builddir_sub&;t t
-s&@top_build_prefix@&$ac_top_build_prefix&;t t
-s&@srcdir@&$ac_srcdir&;t t
-s&@abs_srcdir@&$ac_abs_srcdir&;t t
-s&@top_srcdir@&$ac_top_srcdir&;t t
-s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
-s&@builddir@&$ac_builddir&;t t
-s&@abs_builddir@&$ac_abs_builddir&;t t
-s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
-$ac_datarootdir_hack
-"
-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
-  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-
-test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
-  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
-  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
-      "$ac_tmp/out"`; test -z "$ac_out"; } &&
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&5
-$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&2;}
-
-  rm -f "$ac_tmp/stdin"
-  case $ac_file in
-  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
-  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
-  esac \
-  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
- ;;
-  :H)
-  #
-  # CONFIG_HEADER
-  #
-  if test x"$ac_file" != x-; then
-    {
-      $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
-    } >"$ac_tmp/config.h" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
-$as_echo "$as_me: $ac_file is unchanged" >&6;}
-    else
-      rm -f "$ac_file"
-      mv "$ac_tmp/config.h" "$ac_file" \
-	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
-    fi
-  else
-    $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
-      || as_fn_error $? "could not create -" "$LINENO" 5
-  fi
- ;;
-
-
-  esac
-
-done # for ac_tag
-
-
-as_fn_exit 0
-_ACEOF
-ac_clean_files=$ac_clean_files_save
-
-test $ac_write_fail = 0 ||
-  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded.  So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status.  When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
-  ac_cs_success=:
-  ac_config_status_args=
-  test "$silent" = yes &&
-    ac_config_status_args="$ac_config_status_args --quiet"
-  exec 5>/dev/null
-  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
-  exec 5>>config.log
-  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
-  # would make configure fail if this is the last instruction.
-  $ac_cs_success || as_fn_exit 1
-fi
-if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
-$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
-fi
-
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
--- a/configure.ac
+++ /dev/null
@@ -1,97 +0,0 @@
-AC_INIT([Haskell OpenGL package], [2.2.3.0], [sven.panne@aedion.de], [OpenGL])
-
-# Safety check: Ensure that we are in the correct source directory.
-AC_CONFIG_SRCDIR([include/HsOpenGL.h.in])
-
-# The first file mentioned below will be generated by autoheader and contains
-# defines which are needed during package build time only. The second header
-# contains all kinds of stuff which is needed for using this package.
-AC_CONFIG_HEADERS([include/HsOpenGLConfig.h include/HsOpenGL.h])
-
-# we do not really care about this here, but this avoids a warning about an
-# unknown option
-FP_ARG_COMPILER
-
-# We set this to "yes" later when we have found OpenGL libs and headers.
-GL_BUILD_PACKAGE=no
-
-# Shall we build this package at all?
-FP_ARG_OPENGL
-
-if test x"$enable_opengl" != xno; then
-
-# Check for OpenGL include paths and libraries
-FP_CHECK_GLU
-
-if test x"$GLU_LIBS" = xno; then
-  AC_MSG_FAILURE([no OpenGL library found, so this package cannot be built])
-fi
-
-# check for OpenGL include files
-gl_found_header=no
-glu_found_header=no
-fp_save_cppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-AC_CHECK_HEADERS([GL/gl.h OpenGL/gl.h], [gl_found_header=yes])
-AC_CHECK_HEADERS([GL/glu.h OpenGL/glu.h], [glu_found_header=yes])
-CPPFLAGS="$fp_save_cppflags"
-
-if test x"$gl_found_header" = xno || test x"$glu_found_header" = xno; then
-  AC_MSG_FAILURE([no OpenGL headers found, so this package cannot be built])
-fi
-
-GL_BUILD_PACKAGE=yes
-
-FPTOOLS_CHECK_HTYPE([GLboolean])
-FPTOOLS_CHECK_HTYPE([GLbyte])
-FPTOOLS_CHECK_HTYPE([GLubyte])
-FPTOOLS_CHECK_HTYPE([GLshort])
-FPTOOLS_CHECK_HTYPE([GLushort])
-FPTOOLS_CHECK_HTYPE([GLint])
-FPTOOLS_CHECK_HTYPE([GLuint])
-FPTOOLS_CHECK_HTYPE([GLsizei])
-FPTOOLS_CHECK_HTYPE([GLenum])
-FPTOOLS_CHECK_HTYPE([GLbitfield])
-FPTOOLS_CHECK_HTYPE([GLfloat])
-FPTOOLS_CHECK_HTYPE([GLclampf])
-FPTOOLS_CHECK_HTYPE([GLdouble])
-FPTOOLS_CHECK_HTYPE([GLclampd])
-
-# cruel hack for ancient Windows headers
-FPTOOLS_CHECK_HTYPE([char])
-FPTOOLS_CHECK_HTYPE([GLchar], [$fptools_cv_htype_char])
-
-# ... and a similar hack
-FPTOOLS_CHECK_HTYPE([ptrdiff_t])
-FPTOOLS_CHECK_HTYPE([GLintptr], [$fptools_cv_htype_ptrdiff_t])
-FPTOOLS_CHECK_HTYPE([GLsizeiptr], [$fptools_cv_htype_ptrdiff_t])
-
-AC_DEFINE_UNQUOTED([GLU_CFLAGS],
-  [`echo '' $GLU_CFLAGS | sed -e 's/-[[^ ]]*/,"&"/g' -e 's/^ *,//'`],
-  [C flags for GLU, as a list of string literals.])
-
-AC_DEFINE_UNQUOTED([GLU_LIBS],
-  [`echo '' $GLU_LIBS | sed -e 's/-[[^ ]]*/,"&"/g' -e 's/^ *,//'`],
-  [Library flags for GLU, as a list of string literals.])
-
-AC_DEFINE_UNQUOTED([GLU_FRAMEWORKS],
-  [`echo '' $GLU_FRAMEWORKS | sed -e 's/-[[^ ]]*/,"&"/g' -e 's/^ *,//'`],
-  [Framework flags for GLU, as a list of string literals.])
-
-fi
-
-if test x"$GL_BUILD_PACKAGE" = xyes; then
-  BUILD_PACKAGE_BOOL=True
-else
-  BUILD_PACKAGE_BOOL=False
-fi
-AC_SUBST([BUILD_PACKAGE_BOOL])
-
-case "$host" in
-*-mingw32) CALLCONV=stdcall ;;
-*)	CALLCONV=ccall ;;
-esac
-AC_SUBST([CALLCONV])
-
-AC_CONFIG_FILES([OpenGL.buildinfo])
-AC_OUTPUT
diff --git a/include/HsOpenGL.h b/include/HsOpenGL.h
deleted file mode 100644
--- a/include/HsOpenGL.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* include/HsOpenGL.h.  Generated from HsOpenGL.h.in by configure.  */
-/* -----------------------------------------------------------------------------
- *
- * Module      :  C support for Graphics.Rendering.OpenGL
- * Copyright   :  (c) Sven Panne 2002-2005
- * License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
- * 
- * Maintainer  :  sven.panne@aedion.de
- * Stability   :  provisional
- * Portability :  portable
- *
- * -------------------------------------------------------------------------- */
-
-#ifndef HSOPENGL_H
-#define HSOPENGL_H
-
-/* Define to 1 if native OpenGL should be used on Mac OS X */
-#define USE_QUARTZ_OPENGL 1
-
-#if defined(_WIN32) || defined(__CYGWIN__)
-
-/* for the prototype of wglGetProcAddress */
-#include <windows.h>
-#include <GL/glu.h>
-
-#elif defined(USE_QUARTZ_OPENGL)
-
-#include <OpenGL/glu.h>
-
-#else
-
-/* Hmmm, this seems to be necessary to get a prototype for glXGetProcAddressARB
-   when Mesa is used. Strange... */
-#ifndef GLX_GLXEXT_PROTOTYPES
-#define GLX_GLXEXT_PROTOTYPES
-#endif
-
-#include <GL/glu.h>
-#include <GL/glx.h>
-
-#endif
-
-extern void* hs_OpenGL_getProcAddress(char* procName);
-
-#endif
diff --git a/include/HsOpenGL.h.in b/include/HsOpenGL.h.in
deleted file mode 100644
--- a/include/HsOpenGL.h.in
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -----------------------------------------------------------------------------
- *
- * Module      :  C support for Graphics.Rendering.OpenGL
- * Copyright   :  (c) Sven Panne 2002-2005
- * License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
- * 
- * Maintainer  :  sven.panne@aedion.de
- * Stability   :  provisional
- * Portability :  portable
- *
- * -------------------------------------------------------------------------- */
-
-#ifndef HSOPENGL_H
-#define HSOPENGL_H
-
-/* Define to 1 if native OpenGL should be used on Mac OS X */
-#undef USE_QUARTZ_OPENGL
-
-#if defined(_WIN32) || defined(__CYGWIN__)
-
-/* for the prototype of wglGetProcAddress */
-#include <windows.h>
-#include <GL/glu.h>
-
-#elif defined(USE_QUARTZ_OPENGL)
-
-#include <OpenGL/glu.h>
-
-#else
-
-/* Hmmm, this seems to be necessary to get a prototype for glXGetProcAddressARB
-   when Mesa is used. Strange... */
-#ifndef GLX_GLXEXT_PROTOTYPES
-#define GLX_GLXEXT_PROTOTYPES
-#endif
-
-#include <GL/glu.h>
-#include <GL/glx.h>
-
-#endif
-
-extern void* hs_OpenGL_getProcAddress(char* procName);
-
-#endif
diff --git a/include/HsOpenGLConfig.h.in b/include/HsOpenGLConfig.h.in
deleted file mode 100644
--- a/include/HsOpenGLConfig.h.in
+++ /dev/null
@@ -1,133 +0,0 @@
-/* include/HsOpenGLConfig.h.in.  Generated from configure.ac by autoheader.  */
-
-/* C flags for GLU, as a list of string literals. */
-#undef GLU_CFLAGS
-
-/* Framework flags for GLU, as a list of string literals. */
-#undef GLU_FRAMEWORKS
-
-/* Library flags for GLU, as a list of string literals. */
-#undef GLU_LIBS
-
-/* Define to 1 if you have the <GL/glu.h> header file. */
-#undef HAVE_GL_GLU_H
-
-/* Define to 1 if you have the <GL/gl.h> header file. */
-#undef HAVE_GL_GL_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <OpenGL/glu.h> header file. */
-#undef HAVE_OPENGL_GLU_H
-
-/* Define to 1 if you have the <OpenGL/gl.h> header file. */
-#undef HAVE_OPENGL_GL_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to Haskell type for char */
-#undef HTYPE_CHAR
-
-/* Define to Haskell type for GLbitfield */
-#undef HTYPE_GLBITFIELD
-
-/* Define to Haskell type for GLboolean */
-#undef HTYPE_GLBOOLEAN
-
-/* Define to Haskell type for GLbyte */
-#undef HTYPE_GLBYTE
-
-/* Define to Haskell type for GLchar */
-#undef HTYPE_GLCHAR
-
-/* Define to Haskell type for GLclampd */
-#undef HTYPE_GLCLAMPD
-
-/* Define to Haskell type for GLclampf */
-#undef HTYPE_GLCLAMPF
-
-/* Define to Haskell type for GLdouble */
-#undef HTYPE_GLDOUBLE
-
-/* Define to Haskell type for GLenum */
-#undef HTYPE_GLENUM
-
-/* Define to Haskell type for GLfloat */
-#undef HTYPE_GLFLOAT
-
-/* Define to Haskell type for GLint */
-#undef HTYPE_GLINT
-
-/* Define to Haskell type for GLintptr */
-#undef HTYPE_GLINTPTR
-
-/* Define to Haskell type for GLshort */
-#undef HTYPE_GLSHORT
-
-/* Define to Haskell type for GLsizei */
-#undef HTYPE_GLSIZEI
-
-/* Define to Haskell type for GLsizeiptr */
-#undef HTYPE_GLSIZEIPTR
-
-/* Define to Haskell type for GLubyte */
-#undef HTYPE_GLUBYTE
-
-/* Define to Haskell type for GLuint */
-#undef HTYPE_GLUINT
-
-/* Define to Haskell type for GLushort */
-#undef HTYPE_GLUSHORT
-
-/* Define to Haskell type for ptrdiff_t */
-#undef HTYPE_PTRDIFF_T
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Define to 1 if native OpenGL should be used on Mac OS X */
-#undef USE_QUARTZ_OPENGL
-
-/* Define to 1 if the X Window System is missing or not being used. */
-#undef X_DISPLAY_MISSING
diff --git a/include/HsOpenGLExt.h b/include/HsOpenGLExt.h
deleted file mode 100644
--- a/include/HsOpenGLExt.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -----------------------------------------------------------------------------
- *
- * Module      :  GL extension support for Graphics.Rendering.OpenGL
- * Copyright   :  (c) Sven Panne 2002-2005
- * License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
- * 
- * Maintainer  :  sven.panne@aedion.de
- * Stability   :  provisional
- * Portability :  portable
- *
- * This header should only define preprocessor macros!
- *
- * -------------------------------------------------------------------------- */
-
-#ifndef HSOPENGLEXT_H
-#define HSOPENGLEXT_H
-
-/* NOTE: The macro must immediately start with the foreign declaration,
-   otherwise the magic mangler (hack_foreign) in the Hugs build system
-   doesn't recognize it. */
-#define EXTENSION_ENTRY(_msg,_entry,_ty) \
-foreign import CALLCONV unsafe "dynamic" dyn_/**/_entry :: Graphics.Rendering.OpenGL.GL.Extensions.Invoker (_ty) ; \
-_entry :: (_ty) ; \
-_entry = dyn_/**/_entry ptr_/**/_entry ; \
-ptr_/**/_entry :: FunPtr a ; \
-ptr_/**/_entry = unsafePerformIO (Graphics.Rendering.OpenGL.GL.Extensions.getProcAddress (_msg) ("_entry")) ; \
-{-# NOINLINE ptr_/**/_entry #-}
-
-#endif
diff --git a/include/HsOpenGLTypes.h b/include/HsOpenGLTypes.h
deleted file mode 100644
--- a/include/HsOpenGLTypes.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -----------------------------------------------------------------------------
- *
- * Module      :  Macros for basic GL types to get better Haddock documentation
- * Copyright   :  (c) Sven Panne 2002-2005
- * License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
- * 
- * Maintainer  :  sven.panne@aedion.de
- * Stability   :  provisional
- * Portability :  portable
- *
- * This header should only define preprocessor macros!
- *
- * -------------------------------------------------------------------------- */
-
-#ifndef HSOPENGLTYPES_H
-#define HSOPENGLTYPES_H
-
-#include "HsOpenGLConfig.h"
-
-/* Using a type synonym in an instance head is not Haskell98, but it is much
-   better for a useful documentation. */
-#ifdef __HADDOCK__
-#define GLbyte_   GLbyte
-#define GLdouble_ GLdouble
-#define GLfloat_  GLfloat
-#define GLint_    GLint
-#define GLshort_  GLshort
-#define GLubyte_  GLubyte
-#define GLuint_   GLuint
-#define GLushort_ GLushort
-#else
-#define GLbyte_   HTYPE_GLBYTE
-#define GLdouble_ HTYPE_GLDOUBLE
-#define GLfloat_  HTYPE_GLFLOAT
-#define GLint_    HTYPE_GLINT
-#define GLshort_  HTYPE_GLSHORT
-#define GLubyte_  HTYPE_GLUBYTE
-#define GLuint_   HTYPE_GLUINT
-#define GLushort_ HTYPE_GLUSHORT
-#endif
-
-#endif
diff --git a/install-sh b/install-sh
deleted file mode 100644
--- a/install-sh
+++ /dev/null
@@ -1,295 +0,0 @@
-#!/bin/sh
-# install - install a program, script, or datafile
-
-scriptversion=2003-09-24.23
-
-# This originates from X11R5 (mit/util/scripts/install.sh), which was
-# later released in X11R6 (xc/config/util/install.sh) with the
-# following copyright and license.
-#
-# Copyright (C) 1994 X Consortium
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
-# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# Except as contained in this notice, the name of the X Consortium shall not
-# be used in advertising or otherwise to promote the sale, use or other deal-
-# ings in this Software without prior written authorization from the X Consor-
-# tium.
-#
-#
-# FSF changes to this file are in the public domain.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.  It can only install one file at a time, a restriction
-# shared with many OS's install programs.
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-transformbasename=
-transform_arg=
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=
-chgrpcmd=
-stripcmd=
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=
-dst=
-dir_arg=
-
-usage="Usage: $0 [OPTION]... SRCFILE DSTFILE
-   or: $0 -d DIR1 DIR2...
-
-In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default.
-In the second, create the directory path DIR.
-
-Options:
--b=TRANSFORMBASENAME
--c         copy source (using $cpprog) instead of moving (using $mvprog).
--d         create directories instead of installing files.
--g GROUP   $chgrp installed files to GROUP.
--m MODE    $chmod installed files to MODE.
--o USER    $chown installed files to USER.
--s         strip installed files (using $stripprog).
--t=TRANSFORM
---help     display this help and exit.
---version  display version info and exit.
-
-Environment variables override the default commands:
-  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
-"
-
-while test -n "$1"; do
-  case $1 in
-    -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
-        shift
-        continue;;
-
-    -c) instcmd=$cpprog
-        shift
-        continue;;
-
-    -d) dir_arg=true
-        shift
-        continue;;
-
-    -g) chgrpcmd="$chgrpprog $2"
-        shift
-        shift
-        continue;;
-
-    --help) echo "$usage"; exit 0;;
-
-    -m) chmodcmd="$chmodprog $2"
-        shift
-        shift
-        continue;;
-
-    -o) chowncmd="$chownprog $2"
-        shift
-        shift
-        continue;;
-
-    -s) stripcmd=$stripprog
-        shift
-        continue;;
-
-    -t=*) transformarg=`echo $1 | sed 's/-t=//'`
-        shift
-        continue;;
-
-    --version) echo "$0 $scriptversion"; exit 0;;
-
-    *)  if test -z "$src"; then
-          src=$1
-        else
-          # this colon is to work around a 386BSD /bin/sh bug
-          :
-          dst=$1
-        fi
-        shift
-        continue;;
-  esac
-done
-
-if test -z "$src"; then
-  echo "$0: no input file specified." >&2
-  exit 1
-fi
-
-# Protect names starting with `-'.
-case $src in
-  -*) src=./$src ;;
-esac
-
-if test -n "$dir_arg"; then
-  dst=$src
-  src=
-
-  if test -d "$dst"; then
-    instcmd=:
-    chmodcmd=
-  else
-    instcmd=$mkdirprog
-  fi
-else
-  # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-  # might cause directories to be created, which would be especially bad
-  # if $src (and thus $dsttmp) contains '*'.
-  if test ! -f "$src" && test ! -d "$src"; then
-    echo "$0: $src does not exist." >&2
-    exit 1
-  fi
-
-  if test -z "$dst"; then
-    echo "$0: no destination specified." >&2
-    exit 1
-  fi
-
-  # Protect names starting with `-'.
-  case $dst in
-    -*) dst=./$dst ;;
-  esac
-
-  # If destination is a directory, append the input filename; won't work
-  # if double slashes aren't ignored.
-  if test -d "$dst"; then
-    dst=$dst/`basename "$src"`
-  fi
-fi
-
-# This sed command emulates the dirname command.
-dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-
-# Skip lots of stat calls in the usual case.
-if test ! -d "$dstdir"; then
-  defaultIFS='
-	'
-  IFS="${IFS-$defaultIFS}"
-
-  oIFS=$IFS
-  # Some sh's can't handle IFS=/ for some reason.
-  IFS='%'
-  set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
-  IFS=$oIFS
-
-  pathcomp=
-
-  while test $# -ne 0 ; do
-    pathcomp=$pathcomp$1
-    shift
-    test -d "$pathcomp" || $mkdirprog "$pathcomp"
-    pathcomp=$pathcomp/
-  done
-fi
-
-if test -n "$dir_arg"; then
-  $doit $instcmd "$dst" \
-    && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
-    && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
-    && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
-    && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
-
-else
-  # If we're going to rename the final executable, determine the name now.
-  if test -z "$transformarg"; then
-    dstfile=`basename "$dst"`
-  else
-    dstfile=`basename "$dst" $transformbasename \
-             | sed $transformarg`$transformbasename
-  fi
-
-  # don't allow the sed command to completely eliminate the filename.
-  test -z "$dstfile" && dstfile=`basename "$dst"`
-
-  # Make a couple of temp file names in the proper directory.
-  dsttmp=$dstdir/_inst.$$_
-  rmtmp=$dstdir/_rm.$$_
-
-  # Trap to clean up those temp files at exit.
-  trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
-  trap '(exit $?); exit' 1 2 13 15
-
-  # Move or copy the file name to the temp name
-  $doit $instcmd "$src" "$dsttmp" &&
-
-  # and set any options; do chmod last to preserve setuid bits.
-  #
-  # If any of these fail, we abort the whole thing.  If we want to
-  # ignore errors from any of these, just make sure not to ignore
-  # errors from the above "$doit $instcmd $src $dsttmp" command.
-  #
-  { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
-    && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
-    && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
-    && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
-
-  # Now remove or move aside any old file at destination location.  We
-  # try this two ways since rm can't unlink itself on some systems and
-  # the destination file might be busy for other reasons.  In this case,
-  # the final cleanup might fail but the new file should still install
-  # successfully.
-  {
-    if test -f "$dstdir/$dstfile"; then
-      $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
-      || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
-      || {
-	  echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
-	  (exit 1); exit
-      }
-    else
-      :
-    fi
-  } &&
-
-  # Now rename the file to the real destination.
-  $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
-fi &&
-
-# The final little trick to "correctly" pass the exit status to the exit trap.
-{
-  (exit 0); exit
-}
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
