diff --git a/GLUT.buildinfo.in b/GLUT.buildinfo.in
new file mode 100644
--- /dev/null
+++ b/GLUT.buildinfo.in
@@ -0,0 +1,8 @@
+-- @configure_input@
+-- System-dependent values used by Distribution.Simple.defaultUserHooks
+--
+buildable: @BUILD_PACKAGE_BOOL@
+ghc-options: -DCALLCONV=@CALLCONV@
+cc-options: -DCALLCONV=@CALLCONV@ @GLUT_CFLAGS@
+ld-options: @GLUT_LIBS@
+frameworks: @GLUT_FRAMEWORKS@
diff --git a/GLUT.cabal b/GLUT.cabal
new file mode 100644
--- /dev/null
+++ b/GLUT.cabal
@@ -0,0 +1,49 @@
+name:		GLUT
+version:	2.0
+license:	BSD3
+license-file:	LICENSE
+maintainer:	Sven Panne <sven.panne@aedion.de>
+homepage:	http://www.haskell.org/HOpenGL/
+category:	Graphics
+synopsis:	A binding for the OpenGL Utility Toolkit
+description:
+	A Haskell binding for the OpenGL Utility Toolkit, a window
+	system independent toolkit for writing OpenGL programs. For more
+	information about the C library on which this binding is based,
+	please see: <http://www.opengl.org/resources/libraries/glut/>.
+extra-source-files:
+	config.guess config.sub install-sh
+	configure.ac configure config.mk.in GLUT.buildinfo.in
+	include/HsGLUTConfig.h.in include/HsGLUT.h.in
+	include/HsGLUTExt.h
+extra-tmp-files:
+	config.log config.status autom4te.cache
+	config.mk GLUT.buildinfo include/HsGLUTConfig.h include/HsGLUT.h
+exposed-modules:
+	Graphics.UI.GLUT,
+	Graphics.UI.GLUT.Begin,
+	Graphics.UI.GLUT.Callbacks,
+	Graphics.UI.GLUT.Callbacks.Global,
+	Graphics.UI.GLUT.Callbacks.Window,
+	Graphics.UI.GLUT.Colormap,
+	Graphics.UI.GLUT.Debugging,
+	Graphics.UI.GLUT.DeviceControl,
+	Graphics.UI.GLUT.Fonts,
+	Graphics.UI.GLUT.GameMode,
+	Graphics.UI.GLUT.Initialization,
+	Graphics.UI.GLUT.Menu,
+	Graphics.UI.GLUT.Objects,
+	Graphics.UI.GLUT.Overlay,
+	Graphics.UI.GLUT.State,
+	Graphics.UI.GLUT.Window
+other-modules:
+	Graphics.UI.GLUT.Callbacks.Registration,
+	Graphics.UI.GLUT.Constants,
+	Graphics.UI.GLUT.Extensions,
+	Graphics.UI.GLUT.QueryUtils,
+	Graphics.UI.GLUT.Types
+include-dirs:	include
+install-includes: HsGLUT.h
+c-sources:	cbits/HsGLUT.c
+build-depends:	base, OpenGL
+extensions:	CPP, ForeignFunctionInterface
diff --git a/Graphics/UI/GLUT.hs b/Graphics/UI/GLUT.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT.hs
@@ -0,0 +1,386 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- A Haskell binding for GLUT, the OpenGL Utility Toolkit, a window system
+-- independent toolkit for writing OpenGL programs. It includes support for
+-- the extended functionality available in freeglut (see
+-- <http://freeglut.sourceforge.net/>) and OpenGLUT (see
+-- <http://openglut.sourceforge.net/>), too.
+--
+-----------------------------------------------------------------------------
+
+module Graphics.UI.GLUT (
+   -- * Legal stuff
+
+   -- $LegalStuff
+
+   -- * Introduction
+
+   -- $Introduction
+
+   -- ** Background
+
+   -- $Background
+
+   -- ** Design Philosophy
+
+   -- $DesignPhilosophy
+
+   -- ** API Versions
+
+   -- $APIVersions
+
+   -- ** Conventions
+
+   -- $Conventions
+
+   -- ** Terminology
+
+   -- $Terminology
+
+   module Graphics.Rendering.OpenGL,
+
+   module Graphics.UI.GLUT.Initialization,
+   module Graphics.UI.GLUT.Begin,
+   module Graphics.UI.GLUT.Window,
+   module Graphics.UI.GLUT.Overlay,
+   module Graphics.UI.GLUT.Menu,
+   module Graphics.UI.GLUT.Callbacks,
+   module Graphics.UI.GLUT.Colormap,
+   module Graphics.UI.GLUT.State,
+   module Graphics.UI.GLUT.Fonts,
+   module Graphics.UI.GLUT.Objects,
+   module Graphics.UI.GLUT.Debugging,
+   module Graphics.UI.GLUT.DeviceControl,
+   module Graphics.UI.GLUT.GameMode
+)  where
+
+import Graphics.Rendering.OpenGL
+
+import Graphics.UI.GLUT.Initialization
+import Graphics.UI.GLUT.Begin
+import Graphics.UI.GLUT.Window
+import Graphics.UI.GLUT.Overlay
+import Graphics.UI.GLUT.Menu
+import Graphics.UI.GLUT.Callbacks
+import Graphics.UI.GLUT.Colormap
+import Graphics.UI.GLUT.State
+import Graphics.UI.GLUT.Fonts
+import Graphics.UI.GLUT.Objects
+import Graphics.UI.GLUT.Debugging
+import Graphics.UI.GLUT.DeviceControl
+import Graphics.UI.GLUT.GameMode
+
+-----------------------------------------------------------------------------
+-- $LegalStuff
+-- This documentation is heavily based on the man pages of Mark J. Kilgard\'s
+-- GLUT library.
+--
+-- OpenGL is a trademark of Silicon Graphics, Inc.
+-- X Window System is a trademark of X Consortium, Inc.
+-- Spaceball is a registered trademark of Spatial Systems, Inc.
+--
+-- The author has taken care in preparation of this documentation but makes
+-- no expressed or implied warranty of any kind and assumes no responsibility
+-- for errors or omissions. No liability is assumed for incidental or
+-- consequential damages in connection with or arising from the use of
+-- information or programs contained herein.
+
+-----------------------------------------------------------------------------
+-- $Introduction
+-- The OpenGL Utility Toolkit (GLUT) is a programming interface for writing
+-- window system independent OpenGL programs. Currently there are
+-- implementations for the X Window System, the Windows family, OS\/2, and Mac.
+-- The toolkit supports the following functionality:
+--
+-- * Multiple windows for OpenGL rendering.
+--
+-- * Callback driven event processing.
+--
+-- * Sophisticated input devices.
+--
+-- * An /idle/ routine and timers.
+--
+-- * A simple, cascading pop-up menu facility.
+--
+-- * Utility routines to generate various solid and wire frame objects.
+--
+-- * Support for bitmap and stroke fonts.
+--
+-- * Miscellaneous window management functions, including managing overlays.
+--
+-- This documentation serves as both a specification and a programming guide.
+-- If you are interested in a brief introduction to programming with GLUT,
+-- have a look at the relevant parts of <http://www.opengl.org/> and the vast
+-- amount of books on OpenGL, most of them use GLUT.
+--
+-- The remainder of this section describes GLUT\'s design philosophy and
+-- usage model. The following sections specify the GLUT routines, grouped by
+-- functionality. The final sections discuss usage advice and the logical
+-- programmer visible state maintained by GLUT.
+
+-----------------------------------------------------------------------------
+-- $Background
+-- One of the major accomplishments in the specification of OpenGL was
+-- the isolation of window system dependencies from OpenGL\'s rendering
+-- model. The result is that OpenGL is window system independent.
+--
+-- Window system operations such as the creation of a rendering window and the
+-- handling of window system events are left to the native window system to
+-- define. Necessary interactions between OpenGL and the window system such as
+-- creating and binding an OpenGL context to a window are described separately
+-- from the OpenGL specification in a window system dependent specification. For
+-- example, the GLX specification describes the standard by which OpenGL
+-- interacts with the X Window System.
+--
+-- The predecessor to OpenGL is IRIS GL. Unlike OpenGL, IRIS GL /does/
+-- specify how rendering windows are created and manipulated. IRIS GL\'s
+-- windowing interface is reasonably popular largely because it is simple to
+-- use. IRIS GL programmers can worry about graphics programming without needing
+-- to be an expert in programming the native window system. Experience also
+-- demonstrated that IRIS GL\'s windowing interface was high-level enough that
+-- it could be retargeted to different window systems. Silicon Graphics migrated
+-- from NeWS to the X Window System without any major changes to IRIS GL\'s
+-- basic windowing interface.
+--
+-- Removing window system operations from OpenGL is a sound decision because it
+-- allows the OpenGL graphics system to be retargeted to various systems
+-- including powerful but expensive graphics workstations as well as
+-- mass-production graphics systems like video games, set-top boxes for
+-- interactive television, and PCs.
+--
+-- Unfortunately, the lack of a window system interface for OpenGL is a gap in
+-- OpenGL\'s utility. Learning native window system APIs such as the X Window
+-- System\'s Xlib or Motif can be daunting. Even those familiar with
+-- native window system APIs need to understand the interface that binds OpenGL
+-- to the native window system. And when an OpenGL program is written using the
+-- native window system interface, despite the portability of the program\'s
+-- OpenGL rendering code, the program itself will be window system dependent.
+--
+-- Testing and documenting OpenGL\'s functionality lead to the development of
+-- the @tk@ and @aux@ toolkits. The @aux@ toolkit is used in the examples found
+-- in the /OpenGL Programming Guide/. Unfortunately, @aux@ has numerous
+-- limitations and its utility is largely limited to toy programs. The @tk@
+-- library has more functionality than @aux@ but was developed in an /ad hoc/
+-- fashion and still lacks much important functionality that IRIS GL programmers
+-- expect, like pop-up menus and overlays.
+--
+-- GLUT is designed to fill the need for a window system independent programming
+-- interface for OpenGL programs. The interface is designed to be simple yet
+-- still meet the needs of useful OpenGL programs. Features from the IRIS GL,
+-- @aux@, and @tk@ interfaces are included to make it easy for programmers used
+-- to these interfaces to develop programs for GLUT.
+
+-----------------------------------------------------------------------------
+-- $DesignPhilosophy
+-- GLUT simplifies the implementation of programs using OpenGL rendering. The
+-- GLUT application programming interface (API) requires very few routines to
+-- display a graphics scene rendered using OpenGL. The GLUT API (like the OpenGL
+-- API) is stateful. Most initial GLUT state is defined and the initial state is
+-- reasonable for simple programs. The GLUT routines also take relatively few
+-- parameters.
+--
+-- The GLUT API is (as much as reasonable) window system independent. For this
+-- reason, GLUT does not return /any/ native window system handles, pointers, or
+-- other data structures. More subtle window system dependencies such as
+-- reliance on window system dependent fonts are avoided by GLUT; instead, GLUT
+-- supplies its own (limited) set of fonts.
+--
+-- For programming ease, GLUT provides a simple menu sub-API. While the menuing
+-- support is designed to be implemented as pop-up menus, GLUT gives window
+-- system leeway to support the menu functionality in another manner (pull-down
+-- menus for example).
+--
+-- Two of the most important pieces of GLUT state are the /current window/ and
+-- /current menu/. Most window and menu routines affect the /current window/ or
+-- /menu/ respectively. Most callbacks implicitly set the /current window/ and
+-- /menu/ to the appropriate window or menu responsible for the callback. GLUT
+-- is designed so that a program with only a single window and\/or menu will not
+-- need to keep track of any window or menu identifiers. This greatly simplifies
+-- very simple GLUT programs.
+--
+-- GLUT is designed for simple to moderately complex programs focused on OpenGL
+-- rendering. GLUT implements its own event loop. For this reason, mixing GLUT
+-- with other APIs that demand their own event handling structure may be
+-- difficult. The advantage of a builtin event dispatch loop is simplicity.
+--
+-- GLUT contains routines for rendering fonts and geometric objects, however
+-- GLUT makes no claims on the OpenGL display list name space. For this reason,
+-- none of the GLUT rendering routines use OpenGL display lists. It is up to the
+-- GLUT programmer to compile the output from GLUT rendering routines into
+-- display lists if this is desired.
+--
+-- GLUT routines are logically organized into several sub-APIs according to
+-- their functionality. The sub-APIs are:
+--
+-- * /Initialization:/ Command line processing, window system initialization,
+--   and initial window creation state are controlled by these routines.
+--
+-- * /Beginning Event Processing:/ This routine enters GLUT\'s event processing
+--   loop. This routine never returns, and it continuously calls GLUT callbacks
+--   as necessary.
+--
+-- * /Window Management:/ These routines create and control windows.
+--
+-- * /Overlay Management:/ These routines establish and manage overlays for
+--   windows.
+--
+-- * /Menu Management:/ These routines create and control pop-up menus.
+--
+-- * /Callback Registration:/ These routines register callbacks to be called by
+--   the GLUT event processing loop.
+--
+-- * /Color Index Colormap Management:/ These routines allow the manipulation
+--   of color index colormaps for windows.
+--
+-- * /State Retrieval:/ These routines allows programs to retrieve state from
+--   GLUT.
+--
+-- * /Font Rendering:/ These routines allow rendering of stroke and bitmap
+--   fonts.
+--
+-- * /Geometric Shape Rendering:/ These routines allow the rendering of 3D
+--   geometric objects including spheres, cones, icosahedrons, and teapots.
+--
+-- * /Debugging:/ This routine reports any pending GL errors.
+--
+-- * /Device Control:/ These routines allow setting the key repeat and polling
+--   the joystick.
+--
+-- * /Game Mode:/ These routines allow programs to enter\/leave a full-screen
+--   mode with specified properties.
+
+-- Note that the following item has been left out intentionally, its
+-- implementation is too SGI-specific:
+-- * /Video Resizing:/ These routines provide a means for doing swap or frame
+--   synchronous resizing\/panning of the area that is to be magnified (or
+--   passed through) to the output video resolution.
+
+-----------------------------------------------------------------------------
+-- $APIVersions
+-- The GLUT API has undergone several revisions with increasing functionality.
+-- This Haskell binding provides access to everything in API version 4,
+-- although it is not yet officially finalized. Nevertheless, it provides very
+-- useful things like handling full-screen modes and special keys.
+
+-----------------------------------------------------------------------------
+-- $Conventions
+-- GLUT window and screen coordinates are expressed in pixels. The upper
+-- left hand corner of the screen or a window is (0,0). X coordinates
+-- increase in a rightward direction; Y coordinates increase in a
+-- downward direction. Note: This is inconsistent with OpenGL\'s
+-- coordinate scheme that generally considers the lower left hand
+-- coordinate of a window to be at (0,0) but is consistent with most
+-- popular window systems.
+
+-----------------------------------------------------------------------------
+-- $Terminology
+-- A number of terms are used in a GLUT-specific manner throughout this
+-- document. The GLUT meaning of these terms is independent of the window
+-- system GLUT is used with. Here are GLUT-specific meanings for the
+-- following GLUT-specific terms:
+--
+-- * /Callback:/ A programmer specified routine that can be registered with
+--   GLUT to be called in response to a specific type of event. Also used to
+-- refer to a specific callback routine being called.
+--
+-- * /Colormap:/ A mapping of pixel values to RGB color values. Used by color
+--   index windows.
+--
+-- * /Dials and button box:/ A sophisticated input device consisting of a pad
+--   of buttons and an array of rotating dials, often used by computer-aided
+--   design programs.
+--
+-- * /Display mode:/ A set of OpenGL frame buffer capabilities that can be
+--   attributed to a window.
+--
+-- * /Idle:/ A state when no window system events are received for processing
+--   as callbacks and the idle callback, if one is registered, is called.
+--
+-- * /Layer in use:/ Either the normal plane or overlay. This per-window state
+--   determines what frame buffer layer OpenGL commands affect.
+--
+-- * /Menu entry:/ A menu item that the user can select to trigger the menu
+--   callback for the menu entry\'s value.
+--
+-- * /Menu item:/ Either a menu entry or a sub-menu trigger.
+--
+-- * /Modifiers:/ The Shift, Ctrl, and Alt keys that can be held down
+--   simultaneously with a key or mouse button being pressed or released.
+--
+-- * /Multisampling:/ A technique for hardware antialiasing generally available
+--   only on expensive 3D graphics hardware. Each pixel is composed of a number
+--   of samples (each containing color and depth information). The samples are
+--   averaged to determine the displayed pixel color value. Multisampling is
+--   supported as an extension to OpenGL.
+--
+-- * /Normal plane:/ The default frame buffer layer where GLUT window state
+--   resides; as opposed to the /overlay/.
+--
+-- * /Overlay:/ A frame buffer layer that can be displayed preferentially to
+--   the /normal plane/ and supports transparency to display through to the
+--   /normal plane/. Overlays are useful for rubber-banding effects, text
+--   annotation, and other operations, to avoid damaging the normal plane frame
+--   buffer state. Overlays require hardware support not present on all systems.
+--
+-- * /Pop:/ The act of forcing a window to the top of the stacking order for
+--   sibling windows.
+--
+-- * /Pop-up menu:/ A menu that can be set to appear when a specified mouse
+--   button is pressed in a window. A pop-menu consists of multiple menu items.
+--
+-- * /Push:/ The act of forcing a window to the bottom of the stacking order
+--   for sibling windows.
+--
+-- * /Reshape:/ The act of changing the size or shape of the window.
+--
+-- * /Spaceball:/ A sophisticated 3D input device that provides six degrees of
+--   freedom, three axes of rotation and three axes of translation. It also
+--   supports a number of buttons. The device is a hand-sized ball attached to
+--   a base. By cupping the ball with one\'s hand and applying torsional or
+--   directional force on the ball, rotations and translationsare generated.
+--
+-- * /Stereo:/ A frame buffer capability providing left and right color buffers
+--   for creating stereoscopic renderings. Typically, the user wears LCD
+--   shuttered goggles synchronized with the alternating display on the screen
+--   of the left and right color buffers.
+--
+-- * /Sub-menu:/ A menu cascaded from some sub-menu trigger.
+--
+-- * /Sub-menu trigger:/ A menu item that the user can enter to cascade another
+--   pop-up menu.
+--
+-- * /Subwindow:/ A type of window that is the child window of a top-level
+--   window or other subwindow. The drawing and visible region of a subwindow
+--   is limited by its parent window.
+--
+-- * /Tablet:/ A precise 2D input device. Like a mouse, 2D coordinates are
+--   returned. The absolute position of the tablet \"puck\" on the tablet is
+--   returned. Tablets also support a number of buttons.
+--
+-- * /Timer:/ A callback that can be scheduled to be called in a specified
+--   interval of time.
+--
+-- * /Top-level window:/ A window that can be placed, moved, resized, etc.
+--   independently from other top-level windows by the user. Subwindows may
+--   reside within a top-level window.
+--
+-- * /Window:/ A rectangular area for OpenGL rendering.
+--
+-- * /Window display state:/ One of shown, hidden, or iconified. A shown window
+--   is potentially visible on the screen (it may be obscured by other windows
+--   and not actually visible). A hidden window will never be visible. An
+--   iconified window is not visible but could be made visible in response to
+--   some user action like clicking on the window\'s corresponding icon.
+--
+-- * /Window system:/ A broad notion that refers to both the mechanism and
+--   policy of the window system. For example, in the X Window System both the
+--   window manager and the X server are integral to what GLUT considers the
+--   window system.
diff --git a/Graphics/UI/GLUT/Begin.hs b/Graphics/UI/GLUT/Begin.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Begin.hs
@@ -0,0 +1,108 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Begin
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- After a GLUT program has done initial setup such as creating windows and
+-- menus, GLUT programs enter the GLUT event processing loop by calling
+-- 'mainLoop' or handle events iteratively with 'mainLoopEvent'.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Begin (
+   -- * Handling events
+   mainLoop, mainLoopEvent, leaveMainLoop,
+
+   -- * Controlling the behaviour when windows are closed
+   ActionOnWindowClose(..), actionOnWindowClose
+) where
+
+import Foreign.C.Types ( CInt )
+import Graphics.Rendering.OpenGL.GL.StateVar ( StateVar, makeStateVar )
+import Graphics.UI.GLUT.Constants (
+   glut_ACTION_ON_WINDOW_CLOSE, glut_ACTION_EXIT,
+   glut_ACTION_GLUTMAINLOOP_RETURNS, glut_ACTION_CONTINUE_EXECUTION )
+import Graphics.UI.GLUT.QueryUtils ( simpleGet, glutSetOption )
+import Graphics.UI.GLUT.Extensions
+
+--------------------------------------------------------------------------------
+
+#include "HsGLUTExt.h"
+
+--------------------------------------------------------------------------------
+
+-- | Enter the GLUT event processing loop; it will call as necessary any
+-- callbacks that have been registered. This routine should be called at most
+-- once in a GLUT program.
+
+foreign import CALLCONV safe "glutMainLoop" mainLoop :: IO ()
+
+--------------------------------------------------------------------------------
+
+-- | (/freeglut only/) Process one iteration's worth of events in its event loop.
+-- This allows the application to control its own event loop and still use the
+-- GLUT package.
+
+mainLoopEvent :: IO ()
+mainLoopEvent = glutMainLoopEvent
+
+EXTENSION_ENTRY(safe,"freeglut",glutMainLoopEvent,IO ())
+
+--------------------------------------------------------------------------------
+
+-- | (/freeglut only/) Stop the event loop. If 'actionOnWindowClose' contains
+-- 'Exit', the application will exit; otherwise control will return to the
+-- function which called 'mainLoop'.
+--
+-- If the application has two nested calls to 'mainLoop' and calls
+-- 'leaveMainLoop', the behaviour is undefined. It may leave only the inner
+-- nested loop or it may leave both loops. If the reader has a strong preference
+-- for one behaviour over the other he should contact the freeglut Programming
+-- Consortium and ask for the code to be fixed. 
+
+leaveMainLoop :: IO ()
+leaveMainLoop = glutLeaveMainLoop
+
+EXTENSION_ENTRY(safe,"freeglut",glutLeaveMainLoop,IO ())
+
+--------------------------------------------------------------------------------
+
+-- | The behaviour when the user closes a window.
+
+data ActionOnWindowClose
+   = -- | Exit the whole program when any window is closed or 'leaveMainLoop'
+     -- is called (default).
+     Exit
+   | -- | Return from mainLoop when any window is closed.
+     MainLoopReturns
+   | -- | Return from mainLoop after the last window is closed.
+     ContinueExectuion
+   deriving ( Eq, Ord, Show )
+
+marshalActionOnWindowClose :: ActionOnWindowClose -> CInt
+marshalActionOnWindowClose x = case x of
+   Exit ->  glut_ACTION_EXIT
+   MainLoopReturns -> glut_ACTION_GLUTMAINLOOP_RETURNS
+   ContinueExectuion -> glut_ACTION_CONTINUE_EXECUTION
+
+unmarshalActionOnWindowClose :: CInt -> ActionOnWindowClose
+unmarshalActionOnWindowClose x
+   | x == glut_ACTION_EXIT = Exit
+   | x == glut_ACTION_GLUTMAINLOOP_RETURNS = MainLoopReturns
+   | x == glut_ACTION_CONTINUE_EXECUTION = ContinueExectuion
+   | otherwise = error ("unmarshalActionOnWindowClose: illegal value " ++ show x)
+
+-----------------------------------------------------------------------------
+
+-- | (/freeglut only/) Controls the behaviour when the user closes a window.
+
+actionOnWindowClose :: StateVar ActionOnWindowClose
+actionOnWindowClose =
+   makeStateVar
+      (simpleGet unmarshalActionOnWindowClose glut_ACTION_ON_WINDOW_CLOSE)
+      (glutSetOption glut_ACTION_ON_WINDOW_CLOSE . marshalActionOnWindowClose)
diff --git a/Graphics/UI/GLUT/Callbacks.hs b/Graphics/UI/GLUT/Callbacks.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Callbacks.hs
@@ -0,0 +1,47 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Callbacks
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+--
+-- GLUT supports a number of callbacks to respond to events. There are three
+-- types of callbacks: window, menu, and global. Window callbacks indicate when
+-- to redisplay or reshape a window, when the visibility of the window changes,
+-- and when input is available for the window. Menu callbacks are described in
+-- "Graphics.UI.GLUT.Menu". The global callbacks manage the passing of time and
+-- menu usage. The calling order of callbacks between different windows is
+-- undefined.
+--
+-- Callbacks for input events should be delivered to the window the event occurs
+-- in. Events should not propagate to parent windows.
+--
+-- A callback of type @Foo@ can registered by setting @fooCallback@ to 'Just'
+-- the callback. Almost all callbacks can be de-registered by setting
+-- the corresponding @fooCallback@ to 'Nothing', the only exceptions being
+-- 'Graphics.UI.GLUT.Callbacks.Window.DisplayCallback' (can only be
+-- re-registered) and 'Graphics.UI.GLUT.Callbacks.Global.TimerCallback' (can\'t
+-- be unregistered).
+--
+-- /X Implementation Notes:/ The X GLUT implementation uses the X Input
+-- extension to support sophisticated input devices: Spaceball, dial & button
+-- box, and digitizing tablet. Because the X Input extension  does not mandate
+-- how particular types of devices are advertised through the extension, it is
+-- possible GLUT for X may not correctly support input devices that would
+-- otherwise be of the correct type. The X GLUT implementation will support the
+-- Silicon Graphics Spaceball, dial & button box, and digitizing tablet as
+-- advertised through the X Input extension.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Callbacks (
+   module Graphics.UI.GLUT.Callbacks.Window,
+   module Graphics.UI.GLUT.Callbacks.Global
+) where
+
+import Graphics.UI.GLUT.Callbacks.Window
+import Graphics.UI.GLUT.Callbacks.Global
diff --git a/Graphics/UI/GLUT/Callbacks/Global.hs b/Graphics/UI/GLUT/Callbacks/Global.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Callbacks/Global.hs
@@ -0,0 +1,138 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Callbacks.Global
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Callbacks.Global (
+   -- * Menu status callback
+   MenuUsage(..), MenuStatusCallback, menuStatusCallback,
+
+   -- * Idle callback
+   IdleCallback, idleCallback,
+
+   -- * Timer callbacks
+   Timeout, TimerCallback, addTimerCallback
+) where
+
+import Control.Monad.Fix ( MonadFix(..) )
+import Foreign.C.Types ( CInt, CUInt )
+import Foreign.Ptr ( FunPtr )
+import Graphics.Rendering.OpenGL.GL.CoordTrans ( Position(..) )
+import Graphics.Rendering.OpenGL.GL.StateVar (
+   SettableStateVar, makeSettableStateVar )
+import Graphics.UI.GLUT.Constants ( glut_MENU_NOT_IN_USE, glut_MENU_IN_USE )
+import Graphics.UI.GLUT.Callbacks.Registration (
+   CallbackType(..), setCallback, registerForCleanup )
+
+--------------------------------------------------------------------------------
+
+data MenuUsage
+   = NotInUse
+   | InUse
+   deriving ( Eq, Ord, Show )
+
+unmarshalMenuUsage :: CInt -> MenuUsage
+unmarshalMenuUsage x
+   | x == glut_MENU_NOT_IN_USE = NotInUse
+   | x == glut_MENU_IN_USE = InUse
+   | otherwise = error ("unmarshalMenuUsage: illegal value " ++ show x)
+
+type MenuStatusCallback  = MenuUsage -> Position -> IO ()
+
+type MenuStatusCallback' = CInt -> CInt -> CInt -> IO ()
+
+-- | Controls the global menu status callback so a GLUT program can determine
+-- when a menu is in use or not. When a menu status callback is registered, it
+-- will be called with the value 'InUse' when pop-up menus are in use by the
+-- user; and the callback will be called with the value 'NotInUse' when pop-up
+-- menus are no longer in use. Additionally, the location in window coordinates
+-- of the button press that caused the menu to go into use, or the location where
+-- the menu was released (maybe outside the window). Other callbacks continue to
+-- operate (except mouse motion callbacks) when pop-up menus are in use so the
+-- menu status callback allows a program to suspend animation or other tasks
+-- when menus are in use. The cascading and unmapping of sub-menus from an
+-- initial pop-up menu does not generate menu status callbacks. There is a
+-- single menu status callback for GLUT.
+--
+-- When the menu status callback is called, the /current menu/ will be set to
+-- the initial pop-up menu in both the 'InUse' and 'NotInUse' cases. The
+-- /current window/ will be set to the window from which the initial menu was
+-- popped up from, also in both cases.
+
+menuStatusCallback :: SettableStateVar (Maybe MenuStatusCallback)
+menuStatusCallback =
+   makeSettableStateVar $
+      setCallback MenuStatusCB glutMenuStatusFunc
+                  (makeMenuStatusCallback . unmarshal)
+   where unmarshal cb s x y =
+            cb (unmarshalMenuUsage s)
+               (Position (fromIntegral x) (fromIntegral y))
+
+foreign import ccall "wrapper" makeMenuStatusCallback ::
+   MenuStatusCallback' -> IO (FunPtr MenuStatusCallback')
+
+foreign import CALLCONV unsafe "glutMenuStatusFunc" glutMenuStatusFunc ::
+   FunPtr MenuStatusCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+type IdleCallback = IO ()
+
+-- | Controls the global idle callback so a GLUT program can perform background
+-- processing tasks or continuous animation when window system events are not
+-- being received. If enabled, the idle callback is continuously called when
+-- events are not being received. The /current window/ and /current menu/ will
+-- not be changed before the idle callback. Programs with multiple windows
+-- and\/or menus should explicitly set the /current window/ and\/or /current
+-- menu/ and not rely on its current setting.
+--
+-- The amount of computation and rendering done in an idle callback should be
+-- minimized to avoid affecting the program\'s interactive response. In general,
+-- not more than a single frame of rendering should be done in an idle callback.
+
+idleCallback :: SettableStateVar (Maybe IdleCallback)
+idleCallback =
+   makeSettableStateVar $ setCallback IdleCB glutIdleFunc makeIdleCallback
+
+foreign import ccall "wrapper" makeIdleCallback ::
+   IdleCallback -> IO (FunPtr IdleCallback)
+
+foreign import CALLCONV unsafe "glutIdleFunc" glutIdleFunc ::
+   FunPtr IdleCallback -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Timeout for the timer callback in milliseconds
+type Timeout = Int
+
+type TimerCallback  = IO ()
+
+type TimerCallback' = CInt -> IO ()
+
+-- | Register a one-shot timer callback to be triggered after at least the given
+-- amount of time. Multiple timer callbacks at same or differing times may be
+-- registered simultaneously. There is no support for canceling a registered
+-- callback.
+--
+-- The number of milliseconds is a lower bound on the time before the callback
+-- is generated. GLUT attempts to deliver the timer callback as soon as possible
+-- after the expiration of the callback\'s time interval.
+
+addTimerCallback :: Timeout -> TimerCallback -> IO ()
+addTimerCallback msecs timerCallback = do
+   funPtr <- mfix (\self -> makeTimerCallback (\_ -> do registerForCleanup self
+                                                        timerCallback))
+   glutTimerFunc (fromIntegral msecs) funPtr 0
+
+foreign import ccall "wrapper" makeTimerCallback ::
+   TimerCallback' -> IO (FunPtr TimerCallback')
+
+foreign import CALLCONV unsafe "glutTimerFunc" glutTimerFunc ::
+   CUInt -> FunPtr TimerCallback' -> CInt -> IO ()
diff --git a/Graphics/UI/GLUT/Callbacks/Registration.hs b/Graphics/UI/GLUT/Callbacks/Registration.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Callbacks/Registration.hs
@@ -0,0 +1,170 @@
+{-# OPTIONS_GHC -fno-cse #-}
+
+-- #hide
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Callbacks.Registration
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Callbacks.Registration (
+   CallbackType(..), registerForCleanup, setCallback, getCurrentWindow
+) where
+
+--------------------------------------------------------------------------------
+
+import Control.Monad ( when )
+import Data.IORef ( IORef, newIORef, readIORef, writeIORef, modifyIORef )
+import qualified Data.Map as Map ( empty, lookup, insert, delete )
+import Data.Map ( Map )
+import Foreign.C.Types ( CInt, CUInt )
+import Foreign.Ptr ( FunPtr, nullFunPtr, freeHaskellFunPtr )
+import System.IO.Unsafe ( unsafePerformIO )
+import Graphics.Rendering.OpenGL.GL.StateVar ( HasGetter(get) )
+import Graphics.UI.GLUT.Window ( Window, currentWindow )
+
+--------------------------------------------------------------------------------
+-- No timer callback here, because they are one-shot and "self destroy"
+
+data CallbackType
+   = DisplayCB         | OverlayDisplayCB  | ReshapeCB
+   | KeyboardCB        | KeyboardUpCB      | MouseCB
+   | MotionCB          | PassiveMotionCB   | CrossingCB
+   | VisibilityCB      | WindowStatusCB    | SpecialCB
+   | SpecialUpCB       | SpaceballMotionCB | SpaceballRotateCB
+   | SpaceballButtonCB | ButtonBoxCB       | DialsCB
+   | TabletMotionCB    | TabletButtonCB    | JoystickCB
+   | MenuStatusCB      | IdleCB
+   | CloseCB   -- freeglut only
+   deriving ( Eq, Ord )
+
+isGlobal :: CallbackType -> Bool
+isGlobal MenuStatusCB = True
+isGlobal IdleCB       = True
+isGlobal _            = False
+
+--------------------------------------------------------------------------------
+-- To uniquely identify a particular callback, the associated window is needed
+-- for window callbacks.
+
+data CallbackID = CallbackID (Maybe Window) CallbackType
+   deriving ( Eq, Ord )
+
+getCallbackID :: CallbackType -> IO CallbackID
+getCallbackID callbackType = do
+   maybeWindow <- if isGlobal callbackType
+                     then return Nothing
+                     else fmap Just $ getCurrentWindow "getCallbackID"
+   return $ CallbackID maybeWindow callbackType
+
+getCurrentWindow :: String -> IO Window
+getCurrentWindow func = do
+   win <- get currentWindow
+   maybe (error (func ++ ": no current window")) return win
+
+--------------------------------------------------------------------------------
+-- This seems to be a common Haskell hack nowadays: A plain old global variable
+-- with an associated mutator. Perhaps some language/library support is needed?
+
+{-# NOINLINE theCallbackTable #-}
+theCallbackTable :: IORef (CallbackTable a)
+theCallbackTable = unsafePerformIO (newIORef emptyCallbackTable)
+
+getCallbackTable :: IO (CallbackTable a)
+getCallbackTable = readIORef theCallbackTable
+
+modifyCallbackTable :: (CallbackTable a -> CallbackTable a) -> IO ()
+modifyCallbackTable = modifyIORef theCallbackTable
+
+--------------------------------------------------------------------------------
+
+type CallbackTable a = Map CallbackID (FunPtr a)
+
+emptyCallbackTable :: CallbackTable a
+emptyCallbackTable = Map.empty
+
+lookupInCallbackTable :: CallbackID -> IO (Maybe (FunPtr a))
+lookupInCallbackTable callbackID =
+   fmap (Map.lookup callbackID) getCallbackTable
+
+deleteFromCallbackTable :: CallbackID -> IO ()
+deleteFromCallbackTable callbackID =
+   modifyCallbackTable (Map.delete callbackID)
+
+addToCallbackTable :: CallbackID -> FunPtr a -> IO ()
+addToCallbackTable callbackID funPtr =
+   modifyCallbackTable (Map.insert callbackID funPtr)
+
+--------------------------------------------------------------------------------
+-- Another global mutable variable: The list of function pointers ready to be
+-- freed by freeHaskellFunPtr
+
+{-# NOINLINE theCleanupList #-}
+theCleanupList :: IORef [FunPtr a]
+theCleanupList = unsafePerformIO (newIORef [])
+
+getCleanupList :: IO [FunPtr a]
+getCleanupList = readIORef theCleanupList
+
+setCleanupList :: [FunPtr a] -> IO ()
+setCleanupList = writeIORef theCleanupList
+
+--------------------------------------------------------------------------------
+-- And yet another mutable (write-once) variable: A function pointer to a
+-- callback which frees all function pointers on the cleanup list.
+
+{-# NOINLINE theScavenger #-}
+theScavenger :: IORef (FunPtr TimerCallback)
+theScavenger = unsafePerformIO (newIORef =<< makeTimerCallback (\_ -> do
+   cleanupList <- getCleanupList
+   mapM_ freeHaskellFunPtr cleanupList
+   setCleanupList []))
+
+getScavenger :: IO (FunPtr TimerCallback)
+getScavenger = readIORef theScavenger
+
+-- More or less copied from Global.hs to avoid mutual dependencies
+
+type TimerCallback = CInt -> IO ()
+
+foreign import ccall "wrapper" makeTimerCallback ::
+   TimerCallback -> IO (FunPtr TimerCallback)
+
+foreign import CALLCONV unsafe "glutTimerFunc" glutTimerFunc ::
+   CUInt -> FunPtr TimerCallback -> CInt -> IO ()
+
+--------------------------------------------------------------------------------
+-- Here is the really cunning stuff: If an element is added to the cleanup list
+-- when it is empty, register an immediate callback at GLUT to free the list as
+-- soon as possible.
+
+registerForCleanup :: FunPtr a -> IO ()
+registerForCleanup funPtr = do
+   oldCleanupList <- getCleanupList
+   setCleanupList (funPtr : oldCleanupList)
+   when (null oldCleanupList) $ do
+        scavenger <- getScavenger
+        glutTimerFunc 0 scavenger 0
+
+--------------------------------------------------------------------------------
+
+setCallback :: CallbackType -> (FunPtr a -> IO ()) -> (b -> IO (FunPtr a))
+            -> Maybe b -> IO ()
+setCallback callbackType registerAtGLUT makeCallback maybeCallback = do
+   callbackID <- getCallbackID callbackType
+   maybeOldFunPtr <- lookupInCallbackTable callbackID
+   case maybeOldFunPtr of
+      Nothing -> return ()
+      Just oldFunPtr -> do registerForCleanup oldFunPtr
+                           deleteFromCallbackTable callbackID
+   case maybeCallback of
+      Nothing -> registerAtGLUT nullFunPtr
+      Just callback -> do newFunPtr <- makeCallback callback
+                          addToCallbackTable callbackID newFunPtr
+                          registerAtGLUT newFunPtr
diff --git a/Graphics/UI/GLUT/Callbacks/Window.hs b/Graphics/UI/GLUT/Callbacks/Window.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Callbacks/Window.hs
@@ -0,0 +1,883 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Callbacks.Window
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Callbacks.Window (
+   -- * Redisplay callbacks
+   DisplayCallback, displayCallback, overlayDisplayCallback,
+
+   -- * Reshape callback
+   ReshapeCallback, reshapeCallback,
+
+   -- * Callback for visibility changes
+   Visibility(..), VisibilityCallback, visibilityCallback,
+
+   -- * Window close callback
+   CloseCallback, closeCallback,
+
+   -- * Keyboard and mouse input callback
+   Key(..), SpecialKey(..), MouseButton(..), KeyState(..), Modifiers(..),
+   KeyboardMouseCallback, keyboardMouseCallback,
+
+   -- * Mouse movement callbacks
+   MotionCallback, motionCallback, passiveMotionCallback,
+   Crossing(..), CrossingCallback, crossingCallback,
+
+   -- * Spaceball callback
+   SpaceballMotion, SpaceballRotation, ButtonIndex, SpaceballInput(..),
+   SpaceballCallback, spaceballCallback,
+
+   -- * Dial & button box callback
+   DialAndButtonBoxInput(..), DialIndex,
+   DialAndButtonBoxCallback, dialAndButtonBoxCallback,
+
+   -- * Tablet callback
+   TabletPosition(..), TabletInput(..), TabletCallback, tabletCallback,
+
+   -- * Joystick callback
+   JoystickButtons(..), JoystickPosition(..),
+   JoystickCallback, joystickCallback
+) where
+
+import Data.Bits ( Bits((.&.)) )
+import Data.Char ( chr )
+import Data.Maybe ( fromJust )
+import Foreign.C.Types ( CInt, CUInt, CUChar )
+import Graphics.Rendering.OpenGL.GL.CoordTrans ( Position(..), Size(..) )
+import Graphics.Rendering.OpenGL.GL.StateVar (
+   SettableStateVar, makeSettableStateVar )
+import Graphics.UI.GLUT.Callbacks.Registration ( CallbackType(..), setCallback )
+import Graphics.UI.GLUT.Constants (
+   glut_NOT_VISIBLE, glut_VISIBLE,
+   glut_KEY_F1, glut_KEY_F2, glut_KEY_F3, glut_KEY_F4, glut_KEY_F5, glut_KEY_F6,
+   glut_KEY_F7, glut_KEY_F8, glut_KEY_F9, glut_KEY_F10, glut_KEY_F11,
+   glut_KEY_F12, glut_KEY_LEFT, glut_KEY_UP, glut_KEY_RIGHT, glut_KEY_DOWN,
+   glut_KEY_PAGE_UP, glut_KEY_PAGE_DOWN, glut_KEY_HOME, glut_KEY_END,
+   glut_KEY_INSERT,
+   glut_DOWN, glut_UP,
+   glut_ACTIVE_SHIFT, glut_ACTIVE_CTRL, glut_ACTIVE_ALT,
+   glut_LEFT, glut_ENTERED,
+   glut_JOYSTICK_BUTTON_A, glut_JOYSTICK_BUTTON_B,
+   glut_JOYSTICK_BUTTON_C, glut_JOYSTICK_BUTTON_D )
+import Graphics.UI.GLUT.State ( PollRate )
+import Graphics.UI.GLUT.Types ( MouseButton(..), unmarshalMouseButton )
+import Graphics.UI.GLUT.Extensions
+
+--------------------------------------------------------------------------------
+
+#include "HsGLUTExt.h"
+
+--------------------------------------------------------------------------------
+
+-- | A display callback
+
+type DisplayCallback = IO ()
+
+-- | Controls the display callback for the /current window./ When GLUT determines
+-- that the normal plane for the window needs to be redisplayed, the display
+-- callback for the window is called. Before the callback, the /current window/
+-- is set to the window needing to be redisplayed and (if no overlay display
+-- callback is registered) the /layer in use/ is set to the normal plane. The
+-- entire normal plane region should be redisplayed in response to the callback
+-- (this includes ancillary buffers if your program depends on their state).
+--
+-- GLUT determines when the display callback should be triggered based on the
+-- window\'s redisplay state. The redisplay state for a window can be either set
+-- explicitly by calling 'Graphics.UI.GLUT.Window.postRedisplay' or implicitly
+-- as the result of window damage reported by the window system. Multiple posted
+-- redisplays for a window are coalesced by GLUT to minimize the number of
+-- display callbacks called.
+--
+-- When an overlay is established for a window, but there is no overlay display
+-- callback registered, the display callback is used for redisplaying both the
+-- overlay and normal plane (that is, it will be called if either the redisplay
+-- state or overlay redisplay state is set). In this case, the /layer in use/ is
+-- not implicitly changed on entry to the display callback.
+--
+-- See 'overlayDisplayCallback' to understand how distinct callbacks for the
+-- overlay and normal plane of a window may be established.
+--
+-- When a window is created, no display callback exists for the window. It is
+-- the responsibility of the programmer to install a display callback for the
+-- window before the window is shown. A display callback must be registered for
+-- any window that is shown. If a window becomes displayed without a display
+-- callback being registered, a fatal error occurs. There is no way to
+-- \"deregister\" a display callback (though another callback routine can always
+-- be registered).
+--
+-- Upon return from the display callback, the normal damaged state of the window
+-- (see 'Graphics.UI.GLUT.State.damaged') is cleared. If there is no overlay
+-- display callback registered the overlay damaged state of the window (see
+-- 'Graphics.UI.GLUT.State.damaged') is also cleared.
+
+displayCallback :: SettableStateVar DisplayCallback
+displayCallback = makeSettableStateVar $
+   setCallback DisplayCB glutDisplayFunc makeDisplayCallback . Just
+
+foreign import ccall "wrapper" makeDisplayCallback ::
+   DisplayCallback -> IO (FunPtr DisplayCallback)
+
+foreign import CALLCONV unsafe "glutDisplayFunc" glutDisplayFunc ::
+   FunPtr DisplayCallback -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Controls the overlay display callback for the /current window./ The overlay
+-- display callback is functionally the same as the window\'s display callback
+-- except that the overlay display callback is used to redisplay the window\'s
+-- overlay.
+--
+-- When GLUT determines that the overlay plane for the window needs to be
+-- redisplayed, the overlay display callback for the window is called. Before
+-- the callback, the /current window/ is set to the window needing to be
+-- redisplayed and the /layer in use/ is set to the overlay. The entire overlay
+-- region should be redisplayed in response to the callback (this includes
+-- ancillary buffers if your program depends on their state).
+--
+-- GLUT determines when the overlay display callback should be triggered based
+-- on the window\'s overlay redisplay state. The overlay redisplay state for a
+-- window can be either set explicitly by calling
+-- 'Graphics.UI.GLUT.Overlay.postOverlayRedisplay' or implicitly as the result
+-- of window damage reported by the window system. Multiple posted overlay
+-- redisplays for a window are coalesced by GLUT to minimize the number of
+-- overlay display callbacks called.
+--
+-- Upon return from the overlay display callback, the overlay damaged state of
+-- the window (see 'Graphics.UI.GLUT.State.damaged') is cleared.
+--
+-- Initially there is no overlay display callback registered when an overlay is
+-- established. See 'displayCallback' to understand how the display callback
+-- alone is used if an overlay display callback is not registered.
+
+overlayDisplayCallback :: SettableStateVar (Maybe DisplayCallback)
+overlayDisplayCallback = makeSettableStateVar $
+   setCallback OverlayDisplayCB glutOverlayDisplayFunc makeDisplayCallback
+
+foreign import CALLCONV unsafe "glutOverlayDisplayFunc" glutOverlayDisplayFunc
+   :: FunPtr DisplayCallback -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | A reshape callback
+
+type ReshapeCallback = Size -> IO ()
+
+type ReshapeCallback' = CInt -> CInt -> IO ()
+
+-- | Controls the reshape callback for the /current window./ The reshape callback
+-- is triggered when a window is reshaped. A reshape callback is also triggered
+-- immediately before a window\'s first display callback after a window is
+-- created or whenever an overlay for the window is established. The parameter
+-- of the callback specifies the new window size in pixels. Before the callback,
+-- the /current window/ is set to the window that has been reshaped.
+--
+-- If a reshape callback is not registered for a window or 'reshapeCallback' is
+-- set to 'Nothing' (to deregister a previously registered callback), the
+-- default reshape callback is used. This default callback will simply call
+--
+-- @
+-- 'Graphics.Rendering.OpenGL.GL.CoordTrans.viewport' ('Graphics.Rendering.OpenGL.GL.CoordTrans.Position' 0 0) ('Graphics.Rendering.OpenGL.GL.CoordTrans.Size' /width/ /height/)
+-- @
+--
+-- on the normal plane (and on the overlay if one exists).
+--
+-- If an overlay is established for the window, a single reshape callback is
+-- generated. It is the callback\'s responsibility to update both the normal
+-- plane and overlay for the window (changing the layer in use as necessary).
+--
+-- When a top-level window is reshaped, subwindows are not reshaped. It is up to
+-- the GLUT program to manage the size and positions of subwindows within a
+-- top-level window. Still, reshape callbacks will be triggered for subwindows
+-- when their size is changed using 'Graphics.UI.GLUT.Window.windowSize'.
+
+reshapeCallback :: SettableStateVar (Maybe ReshapeCallback)
+reshapeCallback = makeSettableStateVar $
+   setCallback ReshapeCB glutReshapeFunc (makeReshapeCallback . unmarshal)
+   where unmarshal cb w h = cb (Size (fromIntegral w) (fromIntegral h))
+
+foreign import ccall "wrapper" makeReshapeCallback ::
+   ReshapeCallback' -> IO (FunPtr ReshapeCallback')
+
+foreign import CALLCONV unsafe "glutReshapeFunc" glutReshapeFunc ::
+   FunPtr ReshapeCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | The visibility state of the /current window/
+
+data Visibility
+   = NotVisible -- ^ No part of the /current window/ is visible, i.e., until the
+                --   window\'s visibility changes, all further rendering to the
+                --   window is discarded.
+   | Visible    -- ^ The /current window/ is totally or partially visible. GLUT
+                --   considers a window visible if any pixel of the window is
+                --   visible or any pixel of any descendant window is visible on
+                --   the screen.
+   deriving ( Eq, Ord, Show )
+
+unmarshalVisibility :: CInt -> Visibility
+unmarshalVisibility x
+   | x == glut_NOT_VISIBLE = NotVisible
+   | x == glut_VISIBLE = Visible
+   | otherwise = error ("unmarshalVisibility: illegal value " ++ show x)
+
+--------------------------------------------------------------------------------
+
+-- | A visibilty callback
+
+type VisibilityCallback = Visibility -> IO ()
+
+type VisibilityCallback' = CInt -> IO ()
+
+-- | Controls the visibility callback for the /current window./ The visibility
+-- callback for a window is called when the visibility of a window changes.
+-- 
+-- If the visibility callback for a window is disabled and later re-enabled, the
+-- visibility status of the window is undefined; any change in window visibility
+-- will be reported, that is if you disable a visibility callback and re-enable
+-- the callback, you are guaranteed the next visibility change will be reported.
+
+visibilityCallback :: SettableStateVar (Maybe VisibilityCallback)
+visibilityCallback = makeSettableStateVar $
+   setCallback VisibilityCB glutVisibilityFunc
+               (makeVisibilityCallback . unmarshal)
+   where unmarshal cb  = cb . unmarshalVisibility
+
+foreign import ccall "wrapper" makeVisibilityCallback ::
+   VisibilityCallback' -> IO (FunPtr VisibilityCallback')
+
+foreign import CALLCONV unsafe "glutVisibilityFunc" glutVisibilityFunc ::
+   FunPtr VisibilityCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+type CloseCallback = IO ()
+
+closeCallback :: SettableStateVar (Maybe CloseCallback)
+closeCallback = makeSettableStateVar $
+   setCallback CloseCB glutCloseFunc makeCloseCallback
+
+foreign import ccall "wrapper"
+   makeCloseCallback :: CloseCallback -> IO (FunPtr CloseCallback)
+
+EXTENSION_ENTRY(unsafe,"freeglut",glutCloseFunc,FunPtr CloseCallback -> IO ())
+
+--------------------------------------------------------------------------------
+
+type KeyboardCallback = Char -> Position -> IO ()
+
+type KeyboardCallback' = CUChar -> CInt -> CInt -> IO ()
+
+setKeyboardCallback :: Maybe KeyboardCallback -> IO ()
+setKeyboardCallback =
+   setCallback KeyboardCB glutKeyboardFunc (makeKeyboardCallback . unmarshal)
+   where unmarshal cb c x y = cb (chr (fromIntegral c))
+                                 (Position (fromIntegral x) (fromIntegral y))
+
+foreign import ccall "wrapper" makeKeyboardCallback ::
+   KeyboardCallback' -> IO (FunPtr KeyboardCallback')
+
+foreign import CALLCONV unsafe "glutKeyboardFunc" glutKeyboardFunc ::
+   FunPtr KeyboardCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+setKeyboardUpCallback :: Maybe KeyboardCallback -> IO ()
+setKeyboardUpCallback =
+   setCallback KeyboardUpCB glutKeyboardUpFunc
+               (makeKeyboardCallback . unmarshal)
+   where unmarshal cb c x y = cb (chr (fromIntegral c))
+                                 (Position (fromIntegral x) (fromIntegral y))
+
+foreign import CALLCONV unsafe "glutKeyboardUpFunc" glutKeyboardUpFunc ::
+   FunPtr KeyboardCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Special keys
+
+data SpecialKey
+   = KeyF1
+   | KeyF2
+   | KeyF3
+   | KeyF4
+   | KeyF5
+   | KeyF6
+   | KeyF7
+   | KeyF8
+   | KeyF9
+   | KeyF10
+   | KeyF11
+   | KeyF12
+   | KeyLeft
+   | KeyUp
+   | KeyRight
+   | KeyDown
+   | KeyPageUp
+   | KeyPageDown
+   | KeyHome
+   | KeyEnd
+   | KeyInsert
+   deriving ( Eq, Ord, Show )
+
+unmarshalSpecialKey :: CInt -> SpecialKey
+unmarshalSpecialKey x
+   | x == glut_KEY_F1 = KeyF1
+   | x == glut_KEY_F2 = KeyF2
+   | x == glut_KEY_F3 = KeyF3
+   | x == glut_KEY_F4 = KeyF4
+   | x == glut_KEY_F5 = KeyF5
+   | x == glut_KEY_F6 = KeyF6
+   | x == glut_KEY_F7 = KeyF7
+   | x == glut_KEY_F8 = KeyF8
+   | x == glut_KEY_F9 = KeyF9
+   | x == glut_KEY_F10 = KeyF10
+   | x == glut_KEY_F11 = KeyF11
+   | x == glut_KEY_F12 = KeyF12
+   | x == glut_KEY_LEFT = KeyLeft
+   | x == glut_KEY_UP = KeyUp
+   | x == glut_KEY_RIGHT = KeyRight
+   | x == glut_KEY_DOWN = KeyDown
+   | x == glut_KEY_PAGE_UP = KeyPageUp
+   | x == glut_KEY_PAGE_DOWN = KeyPageDown
+   | x == glut_KEY_HOME = KeyHome
+   | x == glut_KEY_END = KeyEnd
+   | x == glut_KEY_INSERT = KeyInsert
+   | otherwise = error ("unmarshalSpecialKey: illegal value " ++ show x)
+
+--------------------------------------------------------------------------------
+
+type SpecialCallback = SpecialKey -> Position -> IO ()
+
+type SpecialCallback' = CInt -> CInt -> CInt -> IO ()
+
+setSpecialCallback :: Maybe SpecialCallback -> IO ()
+setSpecialCallback =
+   setCallback SpecialCB glutSpecialFunc (makeSpecialCallback . unmarshal)
+   where unmarshal cb k x y = cb (unmarshalSpecialKey k)
+                                 (Position (fromIntegral x) (fromIntegral y))
+
+foreign import ccall "wrapper" makeSpecialCallback ::
+   SpecialCallback' -> IO (FunPtr SpecialCallback')
+
+foreign import CALLCONV unsafe "glutSpecialFunc" glutSpecialFunc ::
+   FunPtr SpecialCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+setSpecialUpCallback :: Maybe SpecialCallback -> IO ()
+setSpecialUpCallback =
+   setCallback SpecialUpCB glutSpecialUpFunc (makeSpecialCallback . unmarshal)
+   where unmarshal cb k x y = cb (unmarshalSpecialKey k)
+                                 (Position (fromIntegral x) (fromIntegral y))
+
+foreign import CALLCONV unsafe "glutSpecialUpFunc" glutSpecialUpFunc ::
+   FunPtr SpecialCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | The current state of a key or button
+
+data KeyState
+   = Down
+   | Up
+   deriving ( Eq, Ord, Show )
+
+unmarshalKeyState :: CInt -> KeyState
+unmarshalKeyState x
+   | x == glut_DOWN = Down
+   | x == glut_UP = Up
+   | otherwise = error ("unmarshalKeyState: illegal value " ++ show x)
+
+--------------------------------------------------------------------------------
+
+type MouseCallback = MouseButton -> KeyState -> Position -> IO ()
+
+type MouseCallback' = CInt -> CInt -> CInt -> CInt -> IO ()
+
+setMouseCallback :: Maybe MouseCallback -> IO ()
+setMouseCallback =
+   setCallback MouseCB glutMouseFunc (makeMouseCallback . unmarshal)
+   where unmarshal cb b s x y = cb (unmarshalMouseButton b)
+                                   (unmarshalKeyState s)
+                                   (Position (fromIntegral x) (fromIntegral y))
+
+foreign import ccall "wrapper" makeMouseCallback ::
+   MouseCallback' -> IO (FunPtr MouseCallback')
+
+foreign import CALLCONV unsafe "glutMouseFunc" glutMouseFunc ::
+   FunPtr MouseCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | The state of the keyboard modifiers
+
+data Modifiers = Modifiers { shift, ctrl, alt :: KeyState }
+   deriving ( Eq, Ord, Show )
+
+-- Could use fromBitfield + Enum/Bounded instances + marshalModifier instead...
+unmarshalModifiers :: CInt -> Modifiers
+unmarshalModifiers m = Modifiers {
+   shift = if (m .&. glut_ACTIVE_SHIFT) /= 0 then Down else Up,
+   ctrl  = if (m .&. glut_ACTIVE_CTRL ) /= 0 then Down else Up,
+   alt   = if (m .&. glut_ACTIVE_ALT  ) /= 0 then Down else Up }
+
+getModifiers :: IO Modifiers
+getModifiers = fmap unmarshalModifiers glutGetModifiers
+
+foreign import CALLCONV unsafe "glutGetModifiers" glutGetModifiers :: IO CInt
+
+--------------------------------------------------------------------------------
+
+-- | A generalized view of keys
+
+data Key
+   = Char Char
+   | SpecialKey SpecialKey
+   | MouseButton MouseButton
+   deriving ( Eq, Ord, Show )
+
+-- | A keyboard\/mouse callback
+
+type KeyboardMouseCallback =
+   Key -> KeyState -> Modifiers -> Position -> IO ()
+
+-- | Controls the keyboard\/mouse callback for the /current window./ The
+-- keyboard\/mouse callback for a window is called when the state of a key or
+-- mouse button changes. The callback parameters indicate the new state of the
+-- key\/button, the state of the keyboard modifiers, and the mouse location in
+-- window relative coordinates.
+
+keyboardMouseCallback :: SettableStateVar (Maybe KeyboardMouseCallback)
+keyboardMouseCallback = makeSettableStateVar setKeyboardMouseCallback
+
+setKeyboardMouseCallback :: Maybe KeyboardMouseCallback -> IO ()
+setKeyboardMouseCallback Nothing = do
+   setKeyboardCallback   Nothing
+   setKeyboardUpCallback Nothing
+   setSpecialCallback    Nothing
+   setSpecialUpCallback  Nothing
+   setMouseCallback      Nothing
+setKeyboardMouseCallback (Just cb) = do
+   setKeyboardCallback   (Just (\c   p -> do m <- getModifiers
+                                             cb (Char        c) Down m p))
+   setKeyboardUpCallback (Just (\c   p -> do m <- getModifiers
+                                             cb (Char        c) Up   m p))
+   setSpecialCallback    (Just (\s   p -> do m <- getModifiers
+                                             cb (SpecialKey  s) Down m p))
+   setSpecialUpCallback  (Just (\s   p -> do m <- getModifiers
+                                             cb (SpecialKey  s) Up   m p))
+   setMouseCallback      (Just (\b s p -> do m <- getModifiers
+                                             cb (MouseButton b) s    m p))
+
+--------------------------------------------------------------------------------
+
+-- | A motion callback
+
+type MotionCallback = Position -> IO ()
+
+type MotionCallback' = CInt -> CInt -> IO ()
+
+-- | Controls the motion callback for the /current window./ The motion callback
+-- for a window is called when the mouse moves within the window while one or
+-- more mouse buttons are pressed. The callback parameter indicates the mouse
+-- location in window relative coordinates.
+
+motionCallback :: SettableStateVar (Maybe MotionCallback)
+motionCallback = makeSettableStateVar $
+   setCallback MotionCB glutMotionFunc (makeMotionCallback . unmarshal)
+   where unmarshal cb x y = cb (Position (fromIntegral x) (fromIntegral y))
+
+foreign import ccall "wrapper" makeMotionCallback ::
+   MotionCallback' -> IO (FunPtr MotionCallback')
+
+foreign import CALLCONV unsafe "glutMotionFunc" glutMotionFunc ::
+   FunPtr MotionCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Controls the passive motion callback for the /current window./ The passive
+-- motion callback for a window is called when the mouse moves within the window
+-- while /no/ mouse buttons are pressed. The callback parameter indicates the
+-- mouse location in window relative coordinates.
+
+passiveMotionCallback :: SettableStateVar (Maybe MotionCallback)
+passiveMotionCallback = makeSettableStateVar $
+   setCallback PassiveMotionCB glutPassiveMotionFunc
+               (makeMotionCallback . unmarshal)
+   where unmarshal cb x y = cb (Position (fromIntegral x) (fromIntegral y))
+
+foreign import CALLCONV unsafe "glutPassiveMotionFunc" glutPassiveMotionFunc ::
+   FunPtr MotionCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | The relation between the mouse pointer and the /current window/ has
+-- changed.
+
+data Crossing
+   = WindowLeft    -- ^ The mouse pointer has left the /current window./
+   | WindowEntered -- ^ The mouse pointer has entered the /current window./
+   deriving ( Eq, Ord, Show )
+
+unmarshalCrossing :: CInt -> Crossing
+unmarshalCrossing x
+   | x == glut_LEFT = WindowLeft
+   | x == glut_ENTERED = WindowEntered
+   | otherwise = error ("unmarshalCrossing: illegal value " ++ show x)
+
+--------------------------------------------------------------------------------
+
+-- | An enter\/leave callback
+
+type CrossingCallback = Crossing -> IO ()
+
+type CrossingCallback' = CInt -> IO ()
+
+-- | Controls the mouse enter\/leave callback for the /current window./ Note
+-- that some window systems may not generate accurate enter\/leave callbacks.
+--
+-- /X Implementation Notes:/ An X implementation of GLUT should generate
+-- accurate enter\/leave callbacks.
+
+crossingCallback :: SettableStateVar (Maybe CrossingCallback)
+crossingCallback = makeSettableStateVar $
+   setCallback CrossingCB glutEntryFunc (makeCrossingCallback . unmarshal)
+   where unmarshal cb = cb . unmarshalCrossing
+
+foreign import ccall "wrapper" makeCrossingCallback ::
+   CrossingCallback' -> IO (FunPtr CrossingCallback')
+
+foreign import CALLCONV unsafe "glutEntryFunc" glutEntryFunc ::
+   FunPtr CrossingCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Translation of the Spaceball along one axis, normalized to be in the range
+-- of -1000 to +1000 inclusive
+
+type SpaceballMotion = Int
+
+-- | Rotation of the Spaceball along one axis, normalized to be in the range
+-- of -1800 .. +1800 inclusive
+
+type SpaceballRotation = Int
+
+-- | The index of a specific buttons of an input device.
+
+type ButtonIndex = Int
+
+-- | The state of the Spaceball has changed.
+
+data SpaceballInput
+   = SpaceballMotion   SpaceballMotion SpaceballMotion SpaceballMotion
+   | SpaceballRotation SpaceballRotation SpaceballRotation SpaceballRotation
+   | SpaceballButton   ButtonIndex KeyState
+   deriving ( Eq, Ord, Show )
+
+-- | A SpaceballButton callback
+
+type SpaceballCallback = SpaceballInput -> IO ()
+
+-- | Controls the Spaceball callback for the /current window./ The Spaceball
+-- callback for a window is called when the window has Spaceball input focus
+-- (normally, when the mouse is in the window) and the user generates Spaceball
+-- translations, rotations, or button presses. The number of available Spaceball
+-- buttons can be determined with 'Graphics.UI.GLUT.State.numSpaceballButtons'.
+--
+-- Registering a Spaceball callback when a Spaceball device is not available has
+-- no effect and is not an error. In this case, no Spaceball callbacks will be
+-- generated.
+
+spaceballCallback :: SettableStateVar (Maybe SpaceballCallback)
+spaceballCallback = makeSettableStateVar setSpaceballCallback
+
+setSpaceballCallback :: Maybe SpaceballCallback -> IO ()
+setSpaceballCallback Nothing = do
+   setSpaceballMotionCallback   Nothing
+   setSpaceballRotationCallback Nothing
+   setSpaceballButtonCallback   Nothing
+setSpaceballCallback (Just cb) = do
+   setSpaceballMotionCallback   (Just (\x y z -> cb (SpaceballMotion   x y z)))
+   setSpaceballRotationCallback (Just (\x y z -> cb (SpaceballRotation x y z)))
+   setSpaceballButtonCallback   (Just (\b s   -> cb (SpaceballButton   b s)))
+
+--------------------------------------------------------------------------------
+
+type SpaceballMotionCallback =
+   SpaceballMotion -> SpaceballMotion -> SpaceballMotion -> IO ()
+
+setSpaceballMotionCallback :: Maybe SpaceballMotionCallback -> IO ()
+setSpaceballMotionCallback =
+   setCallback SpaceballMotionCB glutSpaceballMotionFunc
+               (makeSpaceballMotionCallback . unmarshal)
+   where unmarshal cb x y z =
+            cb (fromIntegral x) (fromIntegral y) (fromIntegral z)
+
+foreign import ccall "wrapper" makeSpaceballMotionCallback ::
+   SpaceballMotionCallback -> IO (FunPtr SpaceballMotionCallback)
+
+foreign import CALLCONV unsafe "glutSpaceballMotionFunc" glutSpaceballMotionFunc
+   :: FunPtr SpaceballMotionCallback -> IO ()
+
+--------------------------------------------------------------------------------
+
+type SpaceballRotationCallback =
+   SpaceballRotation -> SpaceballRotation -> SpaceballRotation -> IO ()
+
+setSpaceballRotationCallback :: Maybe SpaceballRotationCallback -> IO ()
+setSpaceballRotationCallback =
+   setCallback SpaceballRotateCB glutSpaceballRotateFunc
+               (makeSpaceballRotationCallback . unmarshal)
+   where unmarshal cb x y z =
+            cb (fromIntegral x) (fromIntegral y) (fromIntegral z)
+
+foreign import ccall "wrapper" makeSpaceballRotationCallback ::
+   SpaceballRotationCallback -> IO (FunPtr SpaceballRotationCallback)
+
+foreign import CALLCONV unsafe "glutSpaceballRotateFunc" glutSpaceballRotateFunc
+   :: FunPtr SpaceballRotationCallback -> IO ()
+
+--------------------------------------------------------------------------------
+
+type SpaceballButtonCallback = ButtonIndex -> KeyState -> IO ()
+
+type SpaceballButtonCallback' = CInt -> CInt -> IO ()
+
+setSpaceballButtonCallback :: Maybe SpaceballButtonCallback -> IO ()
+setSpaceballButtonCallback =
+   setCallback SpaceballButtonCB glutSpaceballButtonFunc
+               (makeSpaceballButtonCallback . unmarshal)
+   where unmarshal cb b s = cb (fromIntegral b) (unmarshalKeyState s)
+
+foreign import ccall "wrapper" makeSpaceballButtonCallback ::
+   SpaceballButtonCallback' -> IO (FunPtr SpaceballButtonCallback')
+
+foreign import CALLCONV unsafe "glutSpaceballButtonFunc"
+   glutSpaceballButtonFunc :: FunPtr SpaceballButtonCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | The index of a specific dial of a dial and button box.
+
+type DialIndex = Int
+
+-- | The dial & button box state has changed.
+
+data DialAndButtonBoxInput
+   = DialAndButtonBoxButton ButtonIndex KeyState
+   | DialAndButtonBoxDial   DialIndex Int
+   deriving ( Eq, Ord, Show )
+
+-- | A dial & button box callback
+
+type DialAndButtonBoxCallback = DialAndButtonBoxInput -> IO ()
+
+-- | Controls the dial & button box callback for the /current window./ The dial
+-- & button box button callback for a window is called when the window has dial
+-- & button box input focus (normally, when the mouse is in the window) and the
+-- user generates dial & button box button presses or dial changes. The number
+-- of available dial & button box buttons and dials can be determined with
+-- 'Graphics.UI.GLUT.State.numDialsAndButtons'.
+--
+-- Registering a dial & button box callback when a dial & button box device is
+-- not available is ineffectual and not an error. In this case, no dial & button
+-- box button will be generated.
+
+dialAndButtonBoxCallback :: SettableStateVar (Maybe DialAndButtonBoxCallback)
+dialAndButtonBoxCallback = makeSettableStateVar setDialAndButtonBoxCallback
+
+setDialAndButtonBoxCallback :: Maybe DialAndButtonBoxCallback -> IO ()
+setDialAndButtonBoxCallback Nothing = do
+   setButtonBoxCallback Nothing
+   setDialsCallback     Nothing
+setDialAndButtonBoxCallback (Just cb) = do
+   setButtonBoxCallback (Just (\b s -> cb (DialAndButtonBoxButton b s)))
+   setDialsCallback     (Just (\d x -> cb (DialAndButtonBoxDial   d x)))
+
+--------------------------------------------------------------------------------
+
+type ButtonBoxCallback = ButtonIndex -> KeyState -> IO ()
+
+type ButtonBoxCallback' = CInt -> CInt -> IO ()
+
+setButtonBoxCallback :: Maybe ButtonBoxCallback -> IO ()
+setButtonBoxCallback =
+   setCallback ButtonBoxCB glutButtonBoxFunc (makeButtonBoxFunc . unmarshal)
+   where unmarshal cb b s = cb (fromIntegral b) (unmarshalKeyState s)
+
+foreign import ccall "wrapper" makeButtonBoxFunc ::
+   ButtonBoxCallback' -> IO (FunPtr ButtonBoxCallback')
+
+foreign import CALLCONV unsafe "glutButtonBoxFunc" glutButtonBoxFunc ::
+   FunPtr ButtonBoxCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+type DialsCallback = DialIndex -> Int -> IO ()
+
+type DialsCallback' = CInt -> CInt -> IO ()
+
+setDialsCallback :: Maybe DialsCallback -> IO ()
+setDialsCallback =
+    setCallback DialsCB glutDialsFunc (makeDialsFunc . unmarshal)
+    where unmarshal cb d x = cb (fromIntegral d) (fromIntegral x)
+
+foreign import ccall "wrapper" makeDialsFunc ::
+   DialsCallback -> IO (FunPtr DialsCallback')
+
+foreign import CALLCONV unsafe "glutDialsFunc" glutDialsFunc ::
+   FunPtr DialsCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Absolute tablet position, with coordinates normalized to be in the range of
+-- 0 to 2000 inclusive
+
+data TabletPosition = TabletPosition Int Int
+   deriving ( Eq, Ord, Show )
+
+-- | The table state has changed.
+
+data TabletInput
+   = TabletMotion
+   | TabletButton ButtonIndex KeyState
+   deriving ( Eq, Ord, Show )
+
+-- | A tablet callback
+
+type TabletCallback = TabletInput -> TabletPosition -> IO ()
+
+-- | Controls the tablet callback for the /current window./ The tablet callback
+-- for a window is called when the window has tablet input focus (normally, when
+-- the mouse is in the window) and the user generates tablet motion or button
+-- presses. The number of available tablet buttons can be determined with
+-- 'Graphics.UI.GLUT.State.numTabletButtons'.
+--
+-- Registering a tablet callback when a tablet device is not available is
+-- ineffectual and not an error. In this case, no tablet callbacks will be
+-- generated.
+
+tabletCallback :: SettableStateVar (Maybe TabletCallback)
+tabletCallback = makeSettableStateVar setTabletCallback
+
+setTabletCallback :: Maybe TabletCallback -> IO ()
+setTabletCallback Nothing = do
+   setTabletMotionCallback Nothing
+   setTabletButtonCallback Nothing
+setTabletCallback (Just cb) = do 
+   setTabletMotionCallback (Just (\p     -> cb TabletMotion       p))
+   setTabletButtonCallback (Just (\b s p -> cb (TabletButton b s) p))
+
+--------------------------------------------------------------------------------
+
+type TabletMotionCallback = TabletPosition -> IO ()
+
+type TabletMotionCallback' = CInt -> CInt -> IO ()
+
+setTabletMotionCallback :: Maybe TabletMotionCallback -> IO ()
+setTabletMotionCallback =
+    setCallback TabletMotionCB glutTabletMotionFunc
+                (makeTabletMotionFunc . unmarshal)
+    where unmarshal cb x y =
+             cb (TabletPosition (fromIntegral x) (fromIntegral y))
+
+foreign import ccall "wrapper" makeTabletMotionFunc ::
+   TabletMotionCallback' -> IO (FunPtr TabletMotionCallback')
+
+foreign import CALLCONV unsafe "glutTabletMotionFunc" glutTabletMotionFunc ::
+   FunPtr TabletMotionCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+type TabletButtonCallback = ButtonIndex -> KeyState -> TabletPosition -> IO ()
+
+type TabletButtonCallback' = CInt -> CInt -> CInt -> CInt -> IO ()
+
+setTabletButtonCallback :: Maybe TabletButtonCallback -> IO ()
+setTabletButtonCallback =
+    setCallback TabletButtonCB glutTabletButtonFunc
+                (makeTabletButtonFunc . unmarshal)
+    where unmarshal cb b s x y =
+             cb (fromIntegral b) (unmarshalKeyState s)
+                (TabletPosition (fromIntegral x) (fromIntegral y))
+
+foreign import ccall "wrapper" makeTabletButtonFunc ::
+   TabletButtonCallback' -> IO (FunPtr TabletButtonCallback')
+
+foreign import CALLCONV unsafe "glutTabletButtonFunc" glutTabletButtonFunc ::
+   FunPtr TabletButtonCallback' -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | The state of the joystick buttons
+
+data JoystickButtons = JoystickButtons {
+   joystickButtonA, joystickButtonB,
+   joystickButtonC, joystickButtonD :: KeyState }
+   deriving ( Eq, Ord, Show )
+
+-- Could use fromBitfield + Enum/Bounded instances + unmarshalJoystickButton
+-- instead...
+unmarshalJoystickButtons :: CUInt -> JoystickButtons
+unmarshalJoystickButtons m = JoystickButtons {
+   joystickButtonA = if (m .&. glut_JOYSTICK_BUTTON_A) /= 0 then Down else Up,
+   joystickButtonB = if (m .&. glut_JOYSTICK_BUTTON_B) /= 0 then Down else Up,
+   joystickButtonC = if (m .&. glut_JOYSTICK_BUTTON_C) /= 0 then Down else Up,
+   joystickButtonD = if (m .&. glut_JOYSTICK_BUTTON_D) /= 0 then Down else Up }
+
+--------------------------------------------------------------------------------
+
+-- | Absolute joystick position, with coordinates normalized to be in the range
+-- of -1000 to 1000 inclusive. The signs of the three axes mean the following:
+--
+-- * negative = left, positive = right
+--
+-- * negative = towards player, positive = away
+--
+-- * if available (e.g. rudder): negative = down, positive = up
+
+data JoystickPosition = JoystickPosition Int Int Int
+   deriving ( Eq, Ord, Show )
+
+--------------------------------------------------------------------------------
+
+-- | A joystick callback
+
+type JoystickCallback = JoystickButtons -> JoystickPosition -> IO ()
+
+type JoystickCallback' = CUInt -> CInt -> CInt -> CInt -> IO ()
+
+-- | Controls the joystick callback for the /current window./ The joystick
+-- callback is called either due to polling of the joystick at the uniform timer
+-- interval specified (if > 0) or in response to an explicit call of
+-- 'Graphics.UI.GLUT.DeviceControl.forceJoystickCallback'.
+--
+-- /X Implementation Notes:/ Currently GLUT has no joystick support for X11.
+
+-- joystickCallback :: SettableStateVar (Maybe JoystickCallback, PollRate)
+joystickCallback :: SettableStateVar (Maybe (JoystickCallback, PollRate))
+joystickCallback =
+   makeSettableStateVar $ \maybeCBAndRate ->
+      setCallback JoystickCB
+                  (\f -> glutJoystickFunc f (fromIntegral (snd (fromJust maybeCBAndRate))))
+                  (makeJoystickFunc . unmarshal)
+                  (fmap fst maybeCBAndRate)
+    where unmarshal cb b x y z = cb (unmarshalJoystickButtons b)
+                                    (JoystickPosition (fromIntegral x)
+                                                      (fromIntegral y)
+                                                      (fromIntegral z))
+
+foreign import ccall "wrapper" makeJoystickFunc ::
+   JoystickCallback' -> IO (FunPtr JoystickCallback')
+
+foreign import CALLCONV unsafe "glutJoystickFunc" glutJoystickFunc ::
+   FunPtr JoystickCallback' -> CInt -> IO ()
diff --git a/Graphics/UI/GLUT/Colormap.hs b/Graphics/UI/GLUT/Colormap.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Colormap.hs
@@ -0,0 +1,119 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Colormap
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- OpenGL supports both RGBA and color index rendering. The RGBA mode is
+-- generally preferable to color index because more OpenGL rendering
+-- capabilities are available and color index mode requires the loading of
+-- colormap entries.
+--
+-- The GLUT color index state variables are used to read and write entries in a
+-- window\'s color index colormap. Every GLUT color index window has its own
+-- logical color index colormap. The size of a window\'s colormap can be
+-- determined by reading 'numColorMapEntries'.
+--
+-- GLUT color index windows within a program can attempt to share colormap
+-- resources by copying a single color index colormap to multiple windows using
+-- 'copyColormap'. If possible GLUT will attempt to share the actual colormap.
+-- While copying colormaps using 'copyColormap' can potentially allow sharing of
+-- physical colormap resources, logically each window has its own colormap. So
+-- changing a copied colormap of a window will force the duplication of the
+-- colormap. For this reason, color index programs should generally load a
+-- single color index colormap, copy it to all color index windows within the
+-- program, and then not modify any colormap cells.
+--
+-- Use of multiple colormaps is likely to result in colormap installation
+-- problems where some windows are displayed with an incorrect colormap due to
+-- limitations on colormap resources.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Colormap (
+   colorMapEntry,
+   copyColormap,
+   numColorMapEntries,
+   transparentIndex
+) where
+
+import Foreign.C.Types ( CInt )
+import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLint, GLfloat )
+import Graphics.Rendering.OpenGL.GL.StateVar (
+   GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
+import Graphics.Rendering.OpenGL.GL.VertexSpec ( Color3(..), Index1(..) )
+import Graphics.UI.GLUT.Constants (
+   glut_RED, glut_GREEN, glut_BLUE,
+   glut_WINDOW_COLORMAP_SIZE, glut_TRANSPARENT_INDEX )
+import Graphics.UI.GLUT.QueryUtils ( simpleGet, layerGet )
+import Graphics.UI.GLUT.Window ( Window )
+
+--------------------------------------------------------------------------------
+
+-- | Controls the color index colormap entry of the /current window/\'s logical
+-- colormap for the /layer in use/. The /layer in use/ of the /current window/
+-- should be a color index window. The color index should be zero or greater and
+-- less than the total number of colormap entries for the window (see
+-- 'numColorMapEntries') and different from an overlay\'s transparent index (see
+-- 'transparentIndex').
+--
+-- If the /layer in use/\'s colormap was copied by reference, setting a colormap
+-- entry will force the duplication of the colormap.
+
+colorMapEntry :: Index1 GLint -> StateVar (Color3 GLfloat)
+colorMapEntry (Index1 cell) =
+   makeStateVar (getColorMapEntry (fromIntegral cell))
+                (setColorMapEntry (fromIntegral cell))
+
+setColorMapEntry :: CInt -> Color3 GLfloat -> IO ()
+setColorMapEntry cell (Color3 r g b) = glutSetColor cell r g b
+
+foreign import CALLCONV unsafe "glutSetColor" glutSetColor ::
+   CInt -> GLfloat -> GLfloat -> GLfloat -> IO ()
+
+getColorMapEntry :: CInt -> IO (Color3 GLfloat)
+getColorMapEntry cell = do
+   r <- glutGetColor cell glut_RED
+   g <- glutGetColor cell glut_GREEN
+   b <- glutGetColor cell glut_BLUE
+   return $ Color3 r g b
+
+foreign import CALLCONV unsafe "glutGetColor" glutGetColor ::
+   CInt -> CInt -> IO GLfloat
+
+--------------------------------------------------------------------------------
+
+-- | Copy (lazily if possible to promote sharing) the logical colormap from a
+-- specified window to the /current window/\'s /layer in use/. The copy will be
+-- from the normal plane to the normal plane; or from the overlay to the overlay
+-- (never across different layers). Once a colormap has been copied, avoid
+-- setting cells in the colormap via 'colorMapEntry' since that will force an
+-- actual copy of the colormap if it was previously copied by reference.
+-- 'copyColormap' should only be called when both the /current window/ and the
+-- specified window are color index windows.
+
+foreign import CALLCONV unsafe "glutCopyColormap" copyColormap ::
+      Window -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Contains the number of entries in the colormap of the /current window/\'s
+-- current layer (0 in RGBA mode).
+
+numColorMapEntries :: GettableStateVar GLint
+numColorMapEntries =
+   makeGettableStateVar $ simpleGet fromIntegral glut_WINDOW_COLORMAP_SIZE
+
+--------------------------------------------------------------------------------
+
+-- | Contains the transparent color index of the overlay of the /current window/
+-- or -1 if no overlay is in use.
+
+transparentIndex :: GettableStateVar (Index1 GLint)
+transparentIndex =
+   makeGettableStateVar $
+      layerGet (Index1 . fromIntegral) glut_TRANSPARENT_INDEX
diff --git a/Graphics/UI/GLUT/Constants.hs b/Graphics/UI/GLUT/Constants.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Constants.hs
@@ -0,0 +1,343 @@
+-- #hide
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Constants
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- This purely internal module defines all numeric GLUT constants.
+--
+-----------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Constants where
+
+import Foreign.C.Types ( CInt, CUInt )
+import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
+
+-----------------------------------------------------------------------------
+-- * Display mode bit masks
+glut_RGB, glut_RGBA, glut_INDEX, glut_SINGLE, glut_DOUBLE, glut_ACCUM,
+   glut_ALPHA, glut_DEPTH, glut_STENCIL, glut_MULTISAMPLE, glut_STEREO,
+   glut_LUMINANCE, glut_AUX1, glut_AUX2, glut_AUX3, glut_AUX4 :: CUInt
+glut_RGB                               = 0x0000
+glut_RGBA                              = glut_RGB
+glut_INDEX                             = 0x0001
+glut_SINGLE                            = 0x0000
+glut_DOUBLE                            = 0x0002
+glut_ACCUM                             = 0x0004
+glut_ALPHA                             = 0x0008
+glut_DEPTH                             = 0x0010
+glut_STENCIL                           = 0x0020
+glut_MULTISAMPLE                       = 0x0080
+glut_STEREO                            = 0x0100
+glut_LUMINANCE                         = 0x0200
+glut_AUX1                              = 0x1000
+glut_AUX2                              = 0x2000
+glut_AUX3                              = 0x4000
+glut_AUX4                              = 0x8000
+
+-----------------------------------------------------------------------------
+-- * Mouse buttons
+glut_LEFT_BUTTON, glut_MIDDLE_BUTTON, glut_RIGHT_BUTTON, glut_WHEEL_UP,
+   glut_WHEEL_DOWN :: CInt
+glut_LEFT_BUTTON                       = 0
+glut_MIDDLE_BUTTON                     = 1
+glut_RIGHT_BUTTON                      = 2
+glut_WHEEL_UP                          = 3
+glut_WHEEL_DOWN                        = 4
+
+-----------------------------------------------------------------------------
+-- * Mouse button  state
+glut_DOWN, glut_UP :: CInt
+glut_DOWN                              = 0
+glut_UP                                = 1
+
+-----------------------------------------------------------------------------
+-- * Function keys
+glut_KEY_F1, glut_KEY_F2, glut_KEY_F3, glut_KEY_F4, glut_KEY_F5, glut_KEY_F6,
+   glut_KEY_F7, glut_KEY_F8, glut_KEY_F9, glut_KEY_F10, glut_KEY_F11,
+   glut_KEY_F12 :: CInt
+glut_KEY_F1                            = 1
+glut_KEY_F2                            = 2
+glut_KEY_F3                            = 3
+glut_KEY_F4                            = 4
+glut_KEY_F5                            = 5
+glut_KEY_F6                            = 6
+glut_KEY_F7                            = 7
+glut_KEY_F8                            = 8
+glut_KEY_F9                            = 9
+glut_KEY_F10                           = 10
+glut_KEY_F11                           = 11
+glut_KEY_F12                           = 12
+
+-----------------------------------------------------------------------------
+-- * Directional Keys
+glut_KEY_LEFT, glut_KEY_UP, glut_KEY_RIGHT, glut_KEY_DOWN, glut_KEY_PAGE_UP,
+   glut_KEY_PAGE_DOWN, glut_KEY_HOME, glut_KEY_END, glut_KEY_INSERT :: CInt
+glut_KEY_LEFT                          = 100
+glut_KEY_UP                            = 101
+glut_KEY_RIGHT                         = 102
+glut_KEY_DOWN                          = 103
+glut_KEY_PAGE_UP                       = 104
+glut_KEY_PAGE_DOWN                     = 105
+glut_KEY_HOME                          = 106
+glut_KEY_END                           = 107
+glut_KEY_INSERT                        = 108
+
+-----------------------------------------------------------------------------
+-- * Entry\/exit state
+glut_LEFT, glut_ENTERED :: CInt
+glut_LEFT                              = 0
+glut_ENTERED                           = 1
+
+-----------------------------------------------------------------------------
+-- * Menu usage state
+glut_MENU_NOT_IN_USE, glut_MENU_IN_USE :: CInt
+glut_MENU_NOT_IN_USE                   = 0
+glut_MENU_IN_USE                       = 1
+
+-----------------------------------------------------------------------------
+-- * Visibility state
+glut_NOT_VISIBLE, glut_VISIBLE :: CInt
+glut_NOT_VISIBLE                       = 0
+glut_VISIBLE                           = 1
+
+-----------------------------------------------------------------------------
+-- * Window status state
+glut_HIDDEN, glut_FULLY_RETAINED, glut_PARTIALLY_RETAINED,
+   glut_FULLY_COVERED :: CInt
+glut_HIDDEN                            = 0
+glut_FULLY_RETAINED                    = 1
+glut_PARTIALLY_RETAINED                = 2
+glut_FULLY_COVERED                     = 3
+
+-----------------------------------------------------------------------------
+-- * Color index component selection values
+glut_RED, glut_GREEN, glut_BLUE :: CInt
+glut_RED                               = 0
+glut_GREEN                             = 1
+glut_BLUE                              = 2
+
+-----------------------------------------------------------------------------
+-- * Layers in use
+glut_NORMAL, glut_OVERLAY :: GLenum
+glut_NORMAL                            = 0
+glut_OVERLAY                           = 1
+
+-----------------------------------------------------------------------------
+-- * @glutGet@ parameters
+
+glut_WINDOW_X, glut_WINDOW_Y, glut_WINDOW_WIDTH, glut_WINDOW_HEIGHT,
+   glut_WINDOW_BUFFER_SIZE, glut_WINDOW_STENCIL_SIZE, glut_WINDOW_DEPTH_SIZE,
+   glut_WINDOW_RED_SIZE, glut_WINDOW_GREEN_SIZE, glut_WINDOW_BLUE_SIZE,
+   glut_WINDOW_ALPHA_SIZE, glut_WINDOW_ACCUM_RED_SIZE,
+   glut_WINDOW_ACCUM_GREEN_SIZE, glut_WINDOW_ACCUM_BLUE_SIZE,
+   glut_WINDOW_ACCUM_ALPHA_SIZE, glut_WINDOW_DOUBLEBUFFER, glut_WINDOW_RGBA,
+   glut_WINDOW_PARENT, glut_WINDOW_NUM_CHILDREN, glut_WINDOW_COLORMAP_SIZE,
+   glut_WINDOW_NUM_SAMPLES, glut_WINDOW_STEREO, glut_WINDOW_CURSOR,
+   glut_SCREEN_WIDTH, glut_SCREEN_HEIGHT, glut_SCREEN_WIDTH_MM,
+   glut_SCREEN_HEIGHT_MM, glut_MENU_NUM_ITEMS, glut_DISPLAY_MODE_POSSIBLE,
+   glut_INIT_WINDOW_X, glut_INIT_WINDOW_Y, glut_INIT_WINDOW_WIDTH,
+   glut_INIT_WINDOW_HEIGHT, glut_INIT_DISPLAY_MODE, glut_ELAPSED_TIME,
+   glut_WINDOW_FORMAT_ID, glut_ACTION_ON_WINDOW_CLOSE, glut_WINDOW_BORDER_WIDTH,
+   glut_WINDOW_HEADER_HEIGHT, glut_VERSION, glut_RENDERING_CONTEXT,
+   glut_DIRECT_RENDERING :: GLenum
+glut_WINDOW_X                          = 100
+glut_WINDOW_Y                          = 101
+glut_WINDOW_WIDTH                      = 102
+glut_WINDOW_HEIGHT                     = 103
+glut_WINDOW_BUFFER_SIZE                = 104
+glut_WINDOW_STENCIL_SIZE               = 105
+glut_WINDOW_DEPTH_SIZE                 = 106
+glut_WINDOW_RED_SIZE                   = 107
+glut_WINDOW_GREEN_SIZE                 = 108
+glut_WINDOW_BLUE_SIZE                  = 109
+glut_WINDOW_ALPHA_SIZE                 = 110
+glut_WINDOW_ACCUM_RED_SIZE             = 111
+glut_WINDOW_ACCUM_GREEN_SIZE           = 112
+glut_WINDOW_ACCUM_BLUE_SIZE            = 113
+glut_WINDOW_ACCUM_ALPHA_SIZE           = 114
+glut_WINDOW_DOUBLEBUFFER               = 115
+glut_WINDOW_RGBA                       = 116
+glut_WINDOW_PARENT                     = 117
+glut_WINDOW_NUM_CHILDREN               = 118
+glut_WINDOW_COLORMAP_SIZE              = 119
+glut_WINDOW_NUM_SAMPLES                = 120
+glut_WINDOW_STEREO                     = 121
+glut_WINDOW_CURSOR                     = 122
+glut_SCREEN_WIDTH                      = 200
+glut_SCREEN_HEIGHT                     = 201
+glut_SCREEN_WIDTH_MM                   = 202
+glut_SCREEN_HEIGHT_MM                  = 203
+glut_MENU_NUM_ITEMS                    = 300
+glut_DISPLAY_MODE_POSSIBLE             = 400
+glut_INIT_WINDOW_X                     = 500
+glut_INIT_WINDOW_Y                     = 501
+glut_INIT_WINDOW_WIDTH                 = 502
+glut_INIT_WINDOW_HEIGHT                = 503
+glut_INIT_DISPLAY_MODE                 = 504
+glut_ELAPSED_TIME                      = 700
+glut_WINDOW_FORMAT_ID                  = 123
+glut_ACTION_ON_WINDOW_CLOSE            = 505
+glut_WINDOW_BORDER_WIDTH               = 506
+glut_WINDOW_HEADER_HEIGHT              = 507
+glut_VERSION                           = 508
+glut_RENDERING_CONTEXT                 = 509
+glut_DIRECT_RENDERING                  = 510
+
+-----------------------------------------------------------------------------
+-- * @glutDeviceGet@ parameters
+glut_HAS_KEYBOARD, glut_HAS_MOUSE, glut_HAS_SPACEBALL,
+   glut_HAS_DIAL_AND_BUTTON_BOX, glut_HAS_TABLET, glut_NUM_MOUSE_BUTTONS,
+   glut_NUM_SPACEBALL_BUTTONS, glut_NUM_BUTTON_BOX_BUTTONS, glut_NUM_DIALS,
+   glut_NUM_TABLET_BUTTONS, glut_DEVICE_IGNORE_KEY_REPEAT,
+   glut_DEVICE_KEY_REPEAT, glut_HAS_JOYSTICK, glut_OWNS_JOYSTICK,
+   glut_JOYSTICK_BUTTONS, glut_JOYSTICK_AXES, glut_JOYSTICK_POLL_RATE :: GLenum
+glut_HAS_KEYBOARD                      = 600
+glut_HAS_MOUSE                         = 601
+glut_HAS_SPACEBALL                     = 602
+glut_HAS_DIAL_AND_BUTTON_BOX           = 603
+glut_HAS_TABLET                        = 604
+glut_NUM_MOUSE_BUTTONS                 = 605
+glut_NUM_SPACEBALL_BUTTONS             = 606
+glut_NUM_BUTTON_BOX_BUTTONS            = 607
+glut_NUM_DIALS                         = 608
+glut_NUM_TABLET_BUTTONS                = 609
+glut_DEVICE_IGNORE_KEY_REPEAT          = 610
+glut_DEVICE_KEY_REPEAT                 = 611
+glut_HAS_JOYSTICK                      = 612
+glut_OWNS_JOYSTICK                     = 613
+glut_JOYSTICK_BUTTONS                  = 614
+glut_JOYSTICK_AXES                     = 615
+glut_JOYSTICK_POLL_RATE                = 616
+
+-----------------------------------------------------------------------------
+-- * @glutLayerGet@ parameters
+glut_OVERLAY_POSSIBLE, glut_LAYER_IN_USE, glut_HAS_OVERLAY,
+   glut_TRANSPARENT_INDEX, glut_NORMAL_DAMAGED, glut_OVERLAY_DAMAGED :: GLenum
+
+glut_OVERLAY_POSSIBLE                  = 800
+glut_LAYER_IN_USE                      = 801
+glut_HAS_OVERLAY                       = 802
+glut_TRANSPARENT_INDEX                 = 803
+glut_NORMAL_DAMAGED                    = 804
+glut_OVERLAY_DAMAGED                   = 805
+
+-----------------------------------------------------------------------------
+-- * @glutVideoResizeGet@ parameters
+glut_VIDEO_RESIZE_POSSIBLE, glut_VIDEO_RESIZE_IN_USE,
+   glut_VIDEO_RESIZE_X_DELTA, glut_VIDEO_RESIZE_Y_DELTA,
+   glut_VIDEO_RESIZE_WIDTH_DELTA, glut_VIDEO_RESIZE_HEIGHT_DELTA,
+   glut_VIDEO_RESIZE_X, glut_VIDEO_RESIZE_Y, glut_VIDEO_RESIZE_WIDTH,
+   glut_VIDEO_RESIZE_HEIGHT :: CInt
+glut_VIDEO_RESIZE_POSSIBLE             = 900
+glut_VIDEO_RESIZE_IN_USE               = 901
+glut_VIDEO_RESIZE_X_DELTA              = 902
+glut_VIDEO_RESIZE_Y_DELTA              = 903
+glut_VIDEO_RESIZE_WIDTH_DELTA          = 904
+glut_VIDEO_RESIZE_HEIGHT_DELTA         = 905
+glut_VIDEO_RESIZE_X                    = 906
+glut_VIDEO_RESIZE_Y                    = 907
+glut_VIDEO_RESIZE_WIDTH                = 908
+glut_VIDEO_RESIZE_HEIGHT               = 909
+
+-----------------------------------------------------------------------------
+-- * @glutGetModifiers@ return mask
+glut_ACTIVE_SHIFT, glut_ACTIVE_CTRL, glut_ACTIVE_ALT :: CInt
+glut_ACTIVE_SHIFT                      = 0x01
+glut_ACTIVE_CTRL                       = 0x02
+glut_ACTIVE_ALT                        = 0x04
+
+-----------------------------------------------------------------------------
+-- * @glutSetCursor@ parameters
+glut_CURSOR_RIGHT_ARROW, glut_CURSOR_LEFT_ARROW, glut_CURSOR_INFO,
+   glut_CURSOR_DESTROY, glut_CURSOR_HELP, glut_CURSOR_CYCLE,
+   glut_CURSOR_SPRAY, glut_CURSOR_WAIT, glut_CURSOR_TEXT,
+   glut_CURSOR_CROSSHAIR, glut_CURSOR_UP_DOWN, glut_CURSOR_LEFT_RIGHT,
+   glut_CURSOR_TOP_SIDE, glut_CURSOR_BOTTOM_SIDE, glut_CURSOR_LEFT_SIDE,
+   glut_CURSOR_RIGHT_SIDE, glut_CURSOR_TOP_LEFT_CORNER,
+   glut_CURSOR_TOP_RIGHT_CORNER, glut_CURSOR_BOTTOM_RIGHT_CORNER,
+   glut_CURSOR_BOTTOM_LEFT_CORNER, glut_CURSOR_INHERIT, glut_CURSOR_NONE,
+   glut_CURSOR_FULL_CROSSHAIR :: CInt
+glut_CURSOR_RIGHT_ARROW                = 0
+glut_CURSOR_LEFT_ARROW                 = 1
+glut_CURSOR_INFO                       = 2
+glut_CURSOR_DESTROY                    = 3
+glut_CURSOR_HELP                       = 4
+glut_CURSOR_CYCLE                      = 5
+glut_CURSOR_SPRAY                      = 6
+glut_CURSOR_WAIT                       = 7
+glut_CURSOR_TEXT                       = 8
+glut_CURSOR_CROSSHAIR                  = 9
+glut_CURSOR_UP_DOWN                    = 10
+glut_CURSOR_LEFT_RIGHT                 = 11
+glut_CURSOR_TOP_SIDE                   = 12
+glut_CURSOR_BOTTOM_SIDE                = 13
+glut_CURSOR_LEFT_SIDE                  = 14
+glut_CURSOR_RIGHT_SIDE                 = 15
+glut_CURSOR_TOP_LEFT_CORNER            = 16
+glut_CURSOR_TOP_RIGHT_CORNER           = 17
+glut_CURSOR_BOTTOM_RIGHT_CORNER        = 18
+glut_CURSOR_BOTTOM_LEFT_CORNER         = 19
+glut_CURSOR_INHERIT                    = 100
+glut_CURSOR_NONE                       = 101
+glut_CURSOR_FULL_CROSSHAIR             = 102
+
+-----------------------------------------------------------------------------
+-- * @glutSetKeyRepeat@ modes
+glut_KEY_REPEAT_OFF, glut_KEY_REPEAT_ON, glut_KEY_REPEAT_DEFAULT :: CInt
+glut_KEY_REPEAT_OFF                    = 0
+glut_KEY_REPEAT_ON                     = 1
+glut_KEY_REPEAT_DEFAULT                = 2
+
+-----------------------------------------------------------------------------
+-- * Joystick button masks
+glut_JOYSTICK_BUTTON_A, glut_JOYSTICK_BUTTON_B, glut_JOYSTICK_BUTTON_C,
+   glut_JOYSTICK_BUTTON_D :: CUInt
+glut_JOYSTICK_BUTTON_A                 = 0x01
+glut_JOYSTICK_BUTTON_B                 = 0x02
+glut_JOYSTICK_BUTTON_C                 = 0x04
+glut_JOYSTICK_BUTTON_D                 = 0x08
+
+-----------------------------------------------------------------------------
+-- @glutGameModeGet@ parameters
+glut_GAME_MODE_ACTIVE, glut_GAME_MODE_POSSIBLE, glut_GAME_MODE_WIDTH,
+   glut_GAME_MODE_HEIGHT, glut_GAME_MODE_PIXEL_DEPTH,
+   glut_GAME_MODE_REFRESH_RATE, glut_GAME_MODE_DISPLAY_CHANGED :: GLenum
+glut_GAME_MODE_ACTIVE                  = 0
+glut_GAME_MODE_POSSIBLE                = 1
+glut_GAME_MODE_WIDTH                   = 2
+glut_GAME_MODE_HEIGHT                  = 3
+glut_GAME_MODE_PIXEL_DEPTH             = 4
+glut_GAME_MODE_REFRESH_RATE            = 5
+glut_GAME_MODE_DISPLAY_CHANGED         = 6
+
+-----------------------------------------------------------------------------
+-- Direct/indirect rendering context options (has meaning only in unix/x11),
+-- see glut_DIRECT_RENDERING (freeglut extension)
+glut_FORCE_INDIRECT_CONTEXT, glut_ALLOW_DIRECT_CONTEXT,
+   glut_TRY_DIRECT_CONTEXT, glut_FORCE_DIRECT_CONTEXT :: CInt
+glut_FORCE_INDIRECT_CONTEXT            = 0
+glut_ALLOW_DIRECT_CONTEXT              = 1
+glut_TRY_DIRECT_CONTEXT                = 2
+glut_FORCE_DIRECT_CONTEXT              = 3
+
+-----------------------------------------------------------------------------
+-- Behaviour when the user clicks on an "x" to close a window, see
+-- glut_ACTION_ON_WINDOW_CLOSE (freeglut extension)
+glut_ACTION_EXIT, glut_ACTION_GLUTMAINLOOP_RETURNS,
+   glut_ACTION_CONTINUE_EXECUTION :: CInt
+glut_ACTION_EXIT                       = 0
+glut_ACTION_GLUTMAINLOOP_RETURNS       = 1
+glut_ACTION_CONTINUE_EXECUTION         = 2
+
+-----------------------------------------------------------------------------
+-- Create a new rendering context when the user opens a new window? See
+-- glut_RENDERING_CONTEXT (freeglut extension)
+glut_CREATE_NEW_CONTEXT, glut_USE_CURRENT_CONTEXT :: CInt
+glut_CREATE_NEW_CONTEXT                = 0
+glut_USE_CURRENT_CONTEXT               = 1
diff --git a/Graphics/UI/GLUT/Debugging.hs b/Graphics/UI/GLUT/Debugging.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Debugging.hs
@@ -0,0 +1,38 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Debugging
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- This module contains a simple utility routine to report any pending GL
+-- errors.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Debugging (
+   reportErrors
+) where
+
+import System.Environment ( getProgName )
+import System.IO ( hPutStrLn, stderr )
+import Graphics.Rendering.OpenGL.GL.StateVar ( HasGetter(get) )
+import Graphics.Rendering.OpenGL.GLU.Errors ( Error(..), errors )
+
+--------------------------------------------------------------------------------
+
+-- | Report any pending GL errors to stderr (which is typically the console).
+-- If there are no pending errors, this routine does nothing. Note that the
+-- error flags are reset after this action, i.e. there are no pending errors
+-- left afterwards.
+
+reportErrors :: IO ()
+reportErrors = get errors >>= mapM_ reportError
+
+reportError :: Error -> IO ()
+reportError (Error _ msg) = do
+   pn <- getProgName
+   hPutStrLn stderr ("GLUT: Warning in " ++ pn ++ ": GL error: " ++ msg)
diff --git a/Graphics/UI/GLUT/DeviceControl.hs b/Graphics/UI/GLUT/DeviceControl.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/DeviceControl.hs
@@ -0,0 +1,130 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.DeviceControl
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- GLUT offers some routines for controlling the key repeat and polling the
+-- joystick.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.DeviceControl (
+   GlobalKeyRepeat(..), globalKeyRepeat,
+   PerWindowKeyRepeat(..), perWindowKeyRepeat,
+   forceJoystickCallback
+) where
+
+import Foreign.C.Types ( CInt )
+import Graphics.Rendering.OpenGL.GL.StateVar ( StateVar, makeStateVar )
+import Graphics.UI.GLUT.Constants (
+   glut_KEY_REPEAT_OFF, glut_KEY_REPEAT_ON, glut_KEY_REPEAT_DEFAULT,
+   glut_DEVICE_KEY_REPEAT, glut_DEVICE_IGNORE_KEY_REPEAT )
+import Graphics.UI.GLUT.QueryUtils ( deviceGet )
+
+--------------------------------------------------------------------------------
+
+-- | The state of the global key repeat
+
+data GlobalKeyRepeat
+   = GlobalKeyRepeatOff
+   | GlobalKeyRepeatOn
+   | GlobalKeyRepeatDefault
+   deriving ( Eq, Ord, Show )
+
+marshalGlobalKeyRepeat :: GlobalKeyRepeat -> CInt
+marshalGlobalKeyRepeat x = case x of
+   GlobalKeyRepeatOff -> glut_KEY_REPEAT_OFF
+   GlobalKeyRepeatOn -> glut_KEY_REPEAT_ON
+   GlobalKeyRepeatDefault -> glut_KEY_REPEAT_DEFAULT
+
+unmarshalGlobalKeyRepeat :: CInt -> GlobalKeyRepeat
+unmarshalGlobalKeyRepeat x
+   | x == glut_KEY_REPEAT_OFF     = GlobalKeyRepeatOff
+   | x == glut_KEY_REPEAT_ON      = GlobalKeyRepeatOn
+   | x == glut_KEY_REPEAT_DEFAULT = GlobalKeyRepeatDefault
+   | otherwise = error ("unmarshalGlobalKeyRepeat: illegal value " ++ show x)
+
+--------------------------------------------------------------------------------
+
+-- | Controls the key repeat mode for the window system on a global basis if
+-- possible. If supported by the window system, the key repeat can either be
+-- disabled, enabled, or set to the window system\'s default key repeat state.
+--
+-- /X Implementation Notes:/ X11 sends @KeyPress@ events repeatedly when the
+-- window system\'s global auto repeat is enabled. 'perWindowKeyRepeat' can
+-- prevent these auto repeated keystrokes from being reported as keyboard or
+-- special callbacks, but there is still some minimal overhead by the X server
+-- to continually stream @KeyPress@ events to the GLUT application. The
+-- 'globalKeyRepeat' state variable can be used to actually disable the global
+-- sending of auto repeated @KeyPress@ events. Note that 'globalKeyRepeat'
+-- affects the global window system auto repeat state so other applications
+-- will not auto repeat if you disable auto repeat globally through
+-- 'globalKeyRepeat'. GLUT applications using the X11 GLUT implementation
+-- should disable key repeat with 'globalKeyRepeat' to disable key repeats most
+-- efficiently, but are responsible for explicitly restoring the default key
+-- repeat state on exit.
+--
+-- /Win32 Implementation Notes:/ The Win32 implementation of 'globalKeyRepeat'
+-- does nothing. The 'perWindowKeyRepeat' can be used in the Win32 GLUT
+-- implementation to ignore repeated keys on a per-window basis without changing
+-- the global window system key repeat.
+
+globalKeyRepeat :: StateVar GlobalKeyRepeat
+globalKeyRepeat =
+   makeStateVar (deviceGet unmarshalGlobalKeyRepeat glut_DEVICE_KEY_REPEAT)
+                (glutSetKeyRepeat . marshalGlobalKeyRepeat)
+
+foreign import CALLCONV unsafe "glutSetKeyRepeat" glutSetKeyRepeat ::
+   CInt -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | The state of the per-window key repeat
+
+data PerWindowKeyRepeat
+   = PerWindowKeyRepeatOff
+   | PerWindowKeyRepeatOn
+   deriving ( Eq, Ord, Show )
+
+marshalPerWindowKeyRepeat :: PerWindowKeyRepeat -> CInt
+marshalPerWindowKeyRepeat x = case x of
+   PerWindowKeyRepeatOn -> 0
+   PerWindowKeyRepeatOff -> 1
+
+unmarshalPerWindowKeyRepeat :: CInt -> PerWindowKeyRepeat
+unmarshalPerWindowKeyRepeat x
+   | x == 0 = PerWindowKeyRepeatOn
+   | otherwise = PerWindowKeyRepeatOff
+
+--------------------------------------------------------------------------------
+
+-- | Controls if auto repeat keystrokes are reported to the /current window./
+-- Ignoring auto repeated keystrokes is generally done in conjunction with using
+-- the 'Graphics.UI.GLUT.Callbacks.Window.keyboardMouseCallback'. If you do
+-- not ignore auto repeated keystrokes, your GLUT application will experience
+-- repeated release\/press callbacks. Games using the keyboard will typically
+-- want to ignore key repeat.
+
+perWindowKeyRepeat :: StateVar PerWindowKeyRepeat
+perWindowKeyRepeat =
+   makeStateVar
+      (deviceGet unmarshalPerWindowKeyRepeat glut_DEVICE_IGNORE_KEY_REPEAT)
+      (glutIgnoreKeyRepeat . marshalPerWindowKeyRepeat)
+
+foreign import CALLCONV unsafe "glutIgnoreKeyRepeat" glutIgnoreKeyRepeat ::
+   CInt -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Execute the joystick callback set by
+-- 'Graphics.UI.GLUT.Callbacks.Window.joystickCallback' once (if one exists).
+-- This is done in a synchronous fashion within the current context, i.e. when
+-- 'forceJoystickCallback' returns, the callback will have already happened.
+		
+foreign import CALLCONV unsafe "glutForceJoystickFunc" forceJoystickCallback ::
+   IO ()
diff --git a/Graphics/UI/GLUT/Extensions.hs b/Graphics/UI/GLUT/Extensions.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Extensions.hs
@@ -0,0 +1,46 @@
+-- #hide
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Extensions
+-- 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 is a purely internal module for handling an OpenGL-like extension
+-- mechanism for GLUT.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Extensions (
+   FunPtr, unsafePerformIO,
+   Invoker, getProcAddress, getProcAddressInternal   -- used only internally
+) where
+
+import Foreign.C.String ( CString, withCString )
+import Foreign.Ptr ( FunPtr, nullFunPtr )
+import System.IO.Unsafe ( unsafePerformIO )
+
+--------------------------------------------------------------------------------
+
+type Invoker a = FunPtr a -> a
+
+getProcAddress :: String -> String -> IO (FunPtr a)
+getProcAddress ext call =
+   throwIfNull ("unknown GLUT call " ++ call ++ ", check for " ++ ext) $
+      getProcAddressInternal call
+
+throwIfNull :: String -> IO (FunPtr a) -> IO (FunPtr a)
+throwIfNull msg act = do
+   res <- act
+   if res == nullFunPtr
+      then ioError (userError msg)
+      else return res
+
+getProcAddressInternal :: String -> IO (FunPtr a)
+getProcAddressInternal call = withCString call hs_GLUT_getProcAddress
+
+foreign import CALLCONV unsafe "hs_GLUT_getProcAddress" hs_GLUT_getProcAddress
+   :: CString -> IO (FunPtr a)
diff --git a/Graphics/UI/GLUT/Fonts.hs b/Graphics/UI/GLUT/Fonts.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Fonts.hs
@@ -0,0 +1,213 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Fonts
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- GLUT supports two types of font rendering: stroke fonts, meaning each
+-- character is rendered as a set of line segments; and bitmap fonts, where each
+-- character is a bitmap generated with
+-- 'Graphics.Rendering.OpenGL.GL.Bitmaps.bitmap'. Stroke fonts have the
+-- advantage that because they are geometry, they can be arbitrarily scale and
+-- rendered. Bitmap fonts are less flexible since they are rendered as bitmaps
+-- but are usually faster than stroke fonts.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Fonts (
+   Font(..), BitmapFont(..), StrokeFont(..),
+) where
+
+import Data.Char ( ord )
+import Foreign.C.String ( CString, withCString )
+import Foreign.C.Types ( CInt )
+import Foreign.Ptr ( Ptr )
+import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLint, GLfloat )
+import Graphics.UI.GLUT.Extensions
+
+#ifdef __HUGS__
+{-# CFILES cbits/HsGLUT.c #-}
+#endif
+
+--------------------------------------------------------------------------------
+
+#include "HsGLUTExt.h"
+
+--------------------------------------------------------------------------------
+
+class Font a where
+   -- | Render the string in the named font, without using any display lists.
+   -- Rendering a nonexistent character has no effect.
+   --
+   -- If the font is a bitmap font, 'renderString' automatically sets the OpenGL
+   -- unpack pixel storage modes it needs appropriately and saves and restores
+   -- the previous modes before returning. The generated call to
+   -- 'Graphics.Rendering.OpenGL.GL.bitmap' will adjust the current raster
+   -- position based on the width of the string.
+   -- If the font is a stroke font,
+   -- 'Graphics.Rendering.OpenGL.GL.CoordTrans.translate' is used to translate
+   -- the current model view matrix to advance the width of the string.
+
+   renderString :: a -> String -> IO ()
+
+   -- | For a bitmap font, return the width in pixels of a string. For a stroke
+   -- font, return the width in units. While the width of characters in a font
+   -- may vary (though fixed width fonts do not vary), the maximum height
+   -- characteristics of a particular font are fixed.
+
+   stringWidth :: a -> String -> IO GLint
+
+   -- | (/freeglut only/) For a bitmap font, return the maximum height of the
+   -- characters in the given font measured in pixels. For a stroke font,
+   -- return the width in units.
+
+   fontHeight :: a -> IO GLfloat
+
+instance Font BitmapFont where
+   renderString = bitmapString
+   stringWidth  = bitmapLength
+   fontHeight   = bitmapHeight
+
+
+instance Font StrokeFont where
+   renderString = strokeString
+   stringWidth  = strokeLength
+   fontHeight   = strokeHeight
+
+--------------------------------------------------------------------------------
+
+-- | The bitmap fonts available in GLUT. The exact bitmap to be used is
+-- defined by the standard X glyph bitmaps for the X font with the given name.
+
+data BitmapFont
+   = Fixed8By13   -- ^ A fixed width font with every character fitting in an 8
+                  --   by 13 pixel rectangle.
+                  --   (@-misc-fixed-medium-r-normal--13-120-75-75-C-80-iso8859-1@)
+   | Fixed9By15   -- ^ A fixed width font with every character fitting in an 9
+                  --   by 15 pixel rectangle.
+                  --   (@-misc-fixed-medium-r-normal--15-140-75-75-C-90-iso8859-1@)
+   | TimesRoman10 -- ^ A 10-point proportional spaced Times Roman font.
+                  --   (@-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1@)
+   | TimesRoman24 -- ^ A 24-point proportional spaced Times Roman font.
+                  --   (@-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1@)
+   | Helvetica10  -- ^ A 10-point proportional spaced Helvetica font.
+                  --   (@-adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1@)
+   | Helvetica12  -- ^ A 12-point proportional spaced Helvetica font.
+                  --   (@-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1@)
+   | Helvetica18  -- ^ A 18-point proportional spaced Helvetica font.
+                  --   (@-adobe-helvetica-medium-r-normal--18-180-75-75-p-98-iso8859-1@)
+   deriving ( Eq, Ord, Show )
+
+-- Alas, fonts in GLUT are not denoted by some integral value, but by opaque
+-- pointers on the C side. Even worse: For WinDoze, they are simply small ints,
+-- casted to void*, for other platforms addresses of global variables are used.
+-- And all is done via ugly #ifdef-ed #defines... Aaaaargl! So the only portable
+-- way is using integers on the Haskell side and doing the marshaling via some
+-- small C wrappers around those macros. *sigh*
+type GLUTbitmapFont = Ptr ()
+
+foreign import ccall unsafe "hs_GLUT_marshalBitmapFont"
+   hs_GLUT_marshalBitmapFont :: CInt -> IO GLUTbitmapFont
+
+marhshalBitmapFont :: BitmapFont -> IO GLUTbitmapFont
+marhshalBitmapFont x = case x of
+   Fixed8By13 -> hs_GLUT_marshalBitmapFont 0
+   Fixed9By15 -> hs_GLUT_marshalBitmapFont 1
+   TimesRoman10 -> hs_GLUT_marshalBitmapFont 2
+   TimesRoman24 -> hs_GLUT_marshalBitmapFont 3
+   Helvetica10 -> hs_GLUT_marshalBitmapFont 4
+   Helvetica12 -> hs_GLUT_marshalBitmapFont 5
+   Helvetica18 -> hs_GLUT_marshalBitmapFont 6
+
+--------------------------------------------------------------------------------
+
+-- | The stroke fonts available in GLUT.
+data StrokeFont
+   = Roman     -- ^ A proportionally spaced Roman Simplex font for ASCII
+               --   characters 32 through 127. The maximum top character in the
+               --   font is 119.05 units; the bottom descends 33.33 units.
+   | MonoRoman -- ^ A mono-spaced spaced Roman Simplex font (same characters as
+               --   'Roman') for ASCII characters 32 through 127. The maximum
+               --   top character in the font is 119.05 units; the bottom
+               --   descends 33.33 units. Each character is 104.76 units wide.
+   deriving ( Eq, Ord, Show )
+
+-- Same remarks as for GLUTbitmapFont
+type GLUTstrokeFont = Ptr ()
+
+foreign import ccall unsafe "hs_GLUT_marshalStrokeFont"
+   hs_GLUT_marshalStrokeFont :: CInt -> IO GLUTstrokeFont
+
+marhshalStrokeFont :: StrokeFont -> IO GLUTstrokeFont
+marhshalStrokeFont x = case x of
+   Roman -> hs_GLUT_marshalStrokeFont 0
+   MonoRoman -> hs_GLUT_marshalStrokeFont 1
+
+--------------------------------------------------------------------------------
+
+bitmapString :: BitmapFont -> String -> IO ()
+bitmapString f s = do
+   i <- marhshalBitmapFont f
+   mapM_ (\c -> withChar c (glutBitmapCharacter i)) s
+
+withChar :: Char -> (CInt -> IO a) -> IO a
+withChar c f = f . fromIntegral . ord $ c
+
+foreign import CALLCONV "glutBitmapCharacter" glutBitmapCharacter ::
+   GLUTbitmapFont -> CInt -> IO ()
+
+--------------------------------------------------------------------------------
+
+strokeString :: StrokeFont -> String -> IO ()
+strokeString f s = do
+   i <- marhshalStrokeFont f
+   mapM_ (\c -> withChar c (glutStrokeCharacter i)) s
+
+foreign import CALLCONV unsafe "glutStrokeCharacter"
+   glutStrokeCharacter :: GLUTstrokeFont -> CInt -> IO ()
+
+--------------------------------------------------------------------------------
+
+bitmapLength :: BitmapFont -- ^ Bitmap font to use.
+             -> String     -- ^ String to return width of (not confined to 8
+                           --   bits).
+             -> IO GLint   -- ^ Width in pixels.
+bitmapLength f s = do
+   i <- marhshalBitmapFont f
+   fmap fromIntegral $ withCString s (glutBitmapLength i)
+
+foreign import CALLCONV unsafe "glutBitmapLength"
+   glutBitmapLength :: GLUTbitmapFont -> CString -> IO CInt
+
+--------------------------------------------------------------------------------
+
+strokeLength :: StrokeFont -- ^ Stroke font to use.
+             -> String     -- ^ String to return width of (not confined to 8
+                           --   bits).
+             -> IO GLint   -- ^ Width in units.
+strokeLength f s = do
+   i <- marhshalStrokeFont f
+   fmap fromIntegral $ withCString s (glutStrokeLength i)
+
+foreign import CALLCONV unsafe "glutStrokeLength"
+   glutStrokeLength :: GLUTstrokeFont -> CString -> IO CInt
+
+--------------------------------------------------------------------------------
+
+bitmapHeight :: BitmapFont -- ^ Bitmap font to use.
+             -> IO GLfloat -- ^ Height in pixels.
+bitmapHeight f = fmap fromIntegral $ glutBitmapHeight =<< marhshalBitmapFont f
+
+EXTENSION_ENTRY(unsafe,"freeglut",glutBitmapHeight,GLUTbitmapFont -> IO CInt)
+
+--------------------------------------------------------------------------------
+
+strokeHeight :: StrokeFont -- ^ Stroke font to use.
+             -> IO GLfloat -- ^ Height in units.
+strokeHeight f = glutStrokeHeight =<< marhshalStrokeFont f
+
+EXTENSION_ENTRY(unsafe,"freeglut",glutStrokeHeight,GLUTstrokeFont -> IO GLfloat)
diff --git a/Graphics/UI/GLUT/GameMode.hs b/Graphics/UI/GLUT/GameMode.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/GameMode.hs
@@ -0,0 +1,205 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.GameMode
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- In addition to the functionality offered by
+-- 'Graphics.UI.GLUT.Window.fullScreen', GLUT offers an sub-API to change the
+-- screen resolution, color depth, and refresh rate of the display for a single
+-- full screen window. This mode of operation is called /game mode/, and is
+-- restricted in various ways: No pop-up menus are allowed for this full screen
+-- window, no other (sub-)windows can be created, and all other applications are
+-- hidden.
+--
+-- /X Implementation Notes:/ Note that game mode is not fully supported in the
+-- original GLUT for X, it is essentially the same as using
+-- 'Graphics.UI.GLUT.Window.fullScreen'. The GLUT clone freeglut
+-- (see <http://freeglut.sourceforge.net/>) does not have this restriction.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.GameMode (
+   GameModeCapability(..), GameModeCapabilityDescription(..),
+   gameModeCapabilities, enterGameMode, leaveGameMode,
+   BitsPerPlane, RefreshRate, GameModeInfo(..), gameModeInfo,
+   gameModeActive
+) where
+
+import Data.List ( intersperse )
+import Foreign.C.String ( CString, withCString )
+import Foreign.C.Types ( CInt )
+import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
+import Graphics.Rendering.OpenGL.GL.CoordTrans ( Size(..) )
+import Graphics.Rendering.OpenGL.GL.StateVar (
+   GettableStateVar, makeGettableStateVar,
+   SettableStateVar, makeSettableStateVar )
+import Graphics.UI.GLUT.Constants (
+   glut_GAME_MODE_DISPLAY_CHANGED, glut_GAME_MODE_POSSIBLE,
+   glut_GAME_MODE_WIDTH, glut_GAME_MODE_HEIGHT,
+   glut_GAME_MODE_PIXEL_DEPTH, glut_GAME_MODE_REFRESH_RATE,
+   glut_GAME_MODE_ACTIVE )
+import Graphics.UI.GLUT.Types ( makeWindow, relationToString )
+import Graphics.UI.GLUT.Window ( Window )
+import Graphics.UI.GLUT.Initialization ( Relation(..) )
+
+--------------------------------------------------------------------------------
+
+-- | Capabilities for 'gameModeCapabilities'
+
+data GameModeCapability
+   = GameModeWidth         -- ^ Width of the screen resolution in pixels
+   | GameModeHeight        -- ^ Height of the screen resolution in pixels
+   | GameModeBitsPerPlane  -- ^ Color depth of the screen in bits
+   | GameModeRefreshRate   -- ^ Refresh rate in Hertz
+   | GameModeNum           -- ^ Match the Nth frame buffer configuration
+                           --   compatible with the given capabilities
+                           --   (numbering starts at 1)
+   deriving ( Eq, Ord, Show )
+
+gameModeCapabilityToString :: GameModeCapability -> String
+gameModeCapabilityToString x = case x of
+   GameModeWidth        -> "width"
+   GameModeHeight       -> "height"
+   GameModeBitsPerPlane -> "bpp"
+   GameModeRefreshRate  -> "hertz"
+   GameModeNum          -> "num"
+
+-- | A single capability description for 'gameModeCapabilities'.
+
+data GameModeCapabilityDescription = Where' GameModeCapability Relation Int
+   deriving ( Eq, Ord, Show )
+
+gameModeCapabilityDescriptionToString :: GameModeCapabilityDescription -> String
+gameModeCapabilityDescriptionToString (Where' c r i) =
+      gameModeCapabilityToString c ++ relationToString r ++ show i
+
+--------------------------------------------------------------------------------
+
+-- | Controls the /game mode/ to be used when 'enterGameMode' is called. It is
+-- described by a list of zero or more capability descriptions, which are
+-- translated into a set of criteria used to select the appropriate screen
+-- configuration. The criteria are matched in strict left to right order of
+-- precdence. That is, the first specified criterion (leftmost) takes precedence
+-- over the later criteria for non-exact criteria
+-- ('Graphics.UI.GLUT.Initialization.IsGreaterThan',
+-- 'Graphics.UI.GLUT.Initialization.IsLessThan', etc.). Exact criteria
+-- ('Graphics.UI.GLUT.Initialization.IsEqualTo',
+-- 'Graphics.UI.GLUT.Initialization.IsNotEqualTo') must match exactly so
+-- precedence is not relevant.
+--
+-- To determine which configuration will actually be tried by 'enterGameMode'
+-- (if any), use 'gameModeInfo'.
+--
+-- Note that even for game mode the current values of
+-- 'Graphics.UI.GLUT.Initialization.initialDisplayMode'or
+-- 'Graphics.UI.GLUT.Initialization.initialDisplayCapabilities' will
+-- determine which buffers are available, if double buffering is used or not,
+-- etc.
+
+gameModeCapabilities :: SettableStateVar [GameModeCapabilityDescription]
+gameModeCapabilities = makeSettableStateVar $ \ds ->
+   withCString (descriptionsToString ds) glutGameModeString
+
+foreign import CALLCONV unsafe "glutGameModeString" glutGameModeString ::
+   CString -> IO ()
+
+-- freeglut currently handles only simple game mode descriptions like "WxH:B@R",
+-- so we try hard to use this format instead of the more general format allowed
+-- by the "real" GLUT.
+descriptionsToString :: [GameModeCapabilityDescription] -> String
+descriptionsToString ds =
+   let ws = [ x | Where' GameModeWidth        IsEqualTo x <- ds ]
+       hs = [ x | Where' GameModeHeight       IsEqualTo x <- ds ]
+       bs = [ x | Where' GameModeBitsPerPlane IsEqualTo x <- ds ]
+       rs = [ x | Where' GameModeRefreshRate  IsEqualTo x <- ds ]
+       allSimple = (length ws + length hs + length bs + length rs) == (length ds)
+       dimensionsOK = (null ws) == (null hs)
+   in if allSimple && dimensionsOK
+         then simpleCapStr ws hs bs rs
+         else generalCapStr ds
+
+simpleCapStr :: [Int] -> [Int] -> [Int] -> [Int] -> String
+simpleCapStr ws hs bs rs =
+   showCap "" ws ++ showCap "x" hs ++ showCap ":" bs ++ showCap "@" rs
+   where showCap _      []    = ""
+         showCap prefix (x:_) = prefix ++ show x
+
+generalCapStr :: [GameModeCapabilityDescription] -> String
+generalCapStr =
+   concat . intersperse " " . map gameModeCapabilityDescriptionToString
+
+--------------------------------------------------------------------------------
+
+-- | Enter /game mode/, trying to change resolution, refresh rate, etc., as
+-- specified by the current value of 'gameModeCapabilities'. An identifier for
+-- the game mode window and a flag, indicating if the display mode actually
+-- changed, are returned. The game mode window is made the /current window/.
+--
+-- Re-entering /game mode/ is allowed, the previous game mode window gets
+-- destroyed by this, and a new one is created.
+
+enterGameMode :: IO (Window, Bool)
+enterGameMode = do
+   w <- glutEnterGameMode
+   c <- getBool glut_GAME_MODE_DISPLAY_CHANGED
+   return (makeWindow w, c)
+
+foreign import CALLCONV unsafe "glutEnterGameMode" glutEnterGameMode :: IO CInt
+
+--------------------------------------------------------------------------------
+
+-- | Leave /game mode/, restoring the old display mode and destroying the game
+-- mode window.
+
+foreign import CALLCONV unsafe "glutLeaveGameMode" leaveGameMode :: IO ()
+
+--------------------------------------------------------------------------------
+
+-- | The color depth of the screen, measured in bits (e.g. 8, 16, 24, 32, ...)
+
+type BitsPerPlane = Int
+
+-- | The refresh rate of the screen, measured in Hertz (e.g. 60, 75, 100, ...)
+
+type RefreshRate = Int
+
+data GameModeInfo = GameModeInfo Size BitsPerPlane RefreshRate
+   deriving ( Eq, Ord, Show )
+
+--------------------------------------------------------------------------------
+
+-- | Return 'Just' the mode which would be tried by the next call to
+-- 'enterGameMode'. Returns 'Nothing' if the mode requested by the current value
+-- of 'gameModeCapabilities' is not possible, in which case 'enterGameMode'
+-- would simply create a full screen window using the current mode.
+
+gameModeInfo :: GettableStateVar (Maybe GameModeInfo)
+gameModeInfo = makeGettableStateVar $ do
+   possible <- getBool glut_GAME_MODE_POSSIBLE
+   if possible
+      then do
+         w <- glutGameModeGet glut_GAME_MODE_WIDTH
+         h <- glutGameModeGet glut_GAME_MODE_HEIGHT
+         let size = Size (fromIntegral w) (fromIntegral h)
+         b <- glutGameModeGet glut_GAME_MODE_PIXEL_DEPTH
+         r <- glutGameModeGet glut_GAME_MODE_REFRESH_RATE
+         return $ Just $ GameModeInfo size (fromIntegral b) (fromIntegral r)
+      else return Nothing
+
+getBool :: GLenum -> IO Bool
+getBool = fmap (/= 0) . glutGameModeGet
+
+foreign import CALLCONV unsafe "glutGameModeGet" glutGameModeGet ::
+   GLenum -> IO CInt
+
+--------------------------------------------------------------------------------
+
+-- | Contains 'True' when the /game mode/ is active, 'False' otherwise.
+
+gameModeActive :: GettableStateVar Bool
+gameModeActive = makeGettableStateVar $ getBool glut_GAME_MODE_ACTIVE
diff --git a/Graphics/UI/GLUT/Initialization.hs b/Graphics/UI/GLUT/Initialization.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Initialization.hs
@@ -0,0 +1,595 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Initialization
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- Actions and state variables in this module are used to initialize GLUT state.
+-- The primary initialization routine is 'initialize', which should only be
+-- called exactly once in a GLUT program. No other GLUT or OpenGL actions should
+-- be called before 'initialize', apart from getting or setting the state
+-- variables in this module.
+--
+-- The reason is that these state variables can be used to set default window
+-- initialization state that might be modified by the command processing done in
+-- 'initialize'. For example, 'initialWindowSize' can be set to @('Size'
+-- 400 400)@ before 'initialize' is called to indicate 400 by 400 is the
+-- program\'s default window size. Setting the initial window size or position
+-- before 'initialize' allows the GLUT program user to specify the initial size
+-- or position using command line arguments.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Initialization (
+   -- * Primary initialization
+   initialize, getArgsAndInitialize,
+
+   -- * Initial window geometry
+   initialWindowPosition, initialWindowSize,
+
+   -- * Setting the initial display mode (I)
+   DisplayMode(..), initialDisplayMode, displayModePossible,
+
+   -- * Setting the initial display mode (II)
+   DisplayCapability(..), Relation(..), DisplayCapabilityDescription(..),
+   initialDisplayCapabilities,
+
+   -- * Controlling the creation of rendering contexts
+   RenderingContext(..), renderingContext,
+
+   -- * Direct\/indirect rendering
+   DirectRendering(..), directRendering
+) where
+
+import Data.Bits ( Bits((.|.),(.&.)) )
+import Data.List ( genericLength, intersperse )
+import Foreign.C.String ( CString, withCString, peekCString )
+import Foreign.C.Types ( CInt, CUInt )
+import Foreign.Marshal.Array ( withArray0, peekArray )
+import Foreign.Marshal.Utils ( with, withMany )
+import Foreign.Ptr ( Ptr, nullPtr )
+import Foreign.Storable ( Storable(..) )
+import System.Environment ( getProgName, getArgs )
+import Graphics.Rendering.OpenGL.GL.CoordTrans ( Position(..), Size(..) )
+import Graphics.Rendering.OpenGL.GL.StateVar (
+   GettableStateVar, makeGettableStateVar,
+   SettableStateVar, makeSettableStateVar,
+   StateVar, makeStateVar )
+import Graphics.UI.GLUT.Constants (
+   glut_INIT_WINDOW_X, glut_INIT_WINDOW_Y,
+   glut_INIT_WINDOW_WIDTH, glut_INIT_WINDOW_HEIGHT,
+   glut_RGBA, glut_RGB, glut_INDEX, glut_SINGLE, glut_DOUBLE, glut_ACCUM,
+   glut_ALPHA, glut_DEPTH, glut_STENCIL, glut_MULTISAMPLE, glut_STEREO,
+   glut_LUMINANCE, glut_AUX1, glut_AUX2, glut_AUX3, glut_AUX4,
+   glut_INIT_DISPLAY_MODE,
+   glut_DISPLAY_MODE_POSSIBLE,
+   glut_RENDERING_CONTEXT, glut_CREATE_NEW_CONTEXT, glut_USE_CURRENT_CONTEXT,
+   glut_DIRECT_RENDERING,
+   glut_FORCE_INDIRECT_CONTEXT, glut_ALLOW_DIRECT_CONTEXT,
+   glut_TRY_DIRECT_CONTEXT, glut_FORCE_DIRECT_CONTEXT )
+import Graphics.UI.GLUT.QueryUtils ( simpleGet, glutSetOption )
+import Graphics.UI.GLUT.Types ( Relation(..), relationToString )
+
+--------------------------------------------------------------------------------
+
+-- | Given the program name and command line arguments, initialize the GLUT
+-- library and negotiate a session with the window system. During this
+-- process, 'initialize' may cause the termination of the GLUT program with an
+-- error message to the user if GLUT cannot be properly initialized.
+-- Examples of this situation include the failure to connect to the window
+-- system, the lack of window system support for OpenGL, and invalid command
+-- line options.
+--
+-- 'initialize' also processes command line options, but the specific options
+-- parsed are window system dependent. Any command line arguments which are
+-- not GLUT-specific are returned.
+--
+-- /X Implementation Notes:/ The X Window System specific options parsed by
+-- 'initialize' are as follows:
+--
+-- * @-display /DISPLAY/@: Specify the X server to connect to. If not specified,
+--   the value of the @DISPLAY@ environment variable is used.
+--
+-- * @-geometry /WxH+X+Y/@: Determines where windows should be created on the
+--   screen. The parameter following @-geometry@ should be formatted as a
+--   standard X geometry specification. The effect of using this option is to
+--   change the GLUT initial size and initial position the same as if
+--   'initialWindowSize' or 'initialWindowPosition' were modified directly.
+--
+-- * @-iconic@: Requests all top-level windows be created in an iconic state.
+--
+-- * @-indirect@: Force the use of indirect OpenGL rendering contexts.
+--
+-- * @-direct@: Force the use of direct OpenGL rendering contexts (not all GLX
+--   implementations support direct rendering contexts). A fatal error is
+--   generated if direct rendering is not supported by the OpenGL
+--   implementation. If neither @-indirect@ or @-direct@ are used to force a
+--   particular behavior, GLUT will attempt to use direct rendering if
+--   possible and otherwise fallback to indirect rendering.
+--
+-- * @-gldebug@: After processing callbacks and\/or events, call
+--   'Graphics.UI.GLUT.Debugging.reportErrors' to check if there are any pending
+--   OpenGL errors. Using this option is helpful in detecting OpenGL run-time
+--   errors.
+--
+-- * @-sync@: Enable synchronous X protocol transactions. This option makes
+--   it easier to track down potential X protocol errors.
+
+initialize :: String      -- ^ The program name.
+           -> [String]    -- ^ The command line arguments
+           -> IO [String] -- ^ Non-GLUT command line arguments
+initialize prog args =
+   with (1 + genericLength args) $ \argcBuf ->
+   withMany withCString (prog : args) $ \argvPtrs ->
+   withArray0 nullPtr argvPtrs $ \argvBuf -> do
+   glutInit argcBuf argvBuf
+   newArgc <- peek argcBuf
+   newArgvPtrs <- peekArray (fromIntegral newArgc) argvBuf
+   newArgv <- mapM peekCString newArgvPtrs
+   return $ tail newArgv
+
+foreign import CALLCONV unsafe "glutInit" glutInit ::
+   Ptr CInt -> Ptr CString -> IO ()
+
+-- | Convenience action: Initialize GLUT, returning the program name and any
+-- non-GLUT command line arguments.
+
+getArgsAndInitialize :: IO (String, [String])
+getArgsAndInitialize = do
+   prog <- getProgName
+   args <- getArgs
+   nonGLUTArgs <- initialize prog args
+   return (prog, nonGLUTArgs)
+
+--------------------------------------------------------------------------------
+
+-- | Controls the /initial window position/.  Windows created by
+-- 'Graphics.UI.GLUT.Window.createWindow' will be requested to be created with
+-- the current /initial window position/. The initial value of the /initial
+-- window position/ GLUT state is @'Size' (-1) (-1)@. If either the X or Y
+-- component of the /initial window position/ is negative, the actual window
+-- position is left to the window system to determine.
+--
+-- The intent of the /initial window position/ is to provide a suggestion to
+-- the window system for a window\'s initial position. The window system is
+-- not obligated to use this information. Therefore, GLUT programs should not
+-- assume the window was created at the specified position.
+
+initialWindowPosition :: StateVar Position
+initialWindowPosition =
+   makeStateVar getInitialWindowPosition setInitialWindowPosition
+
+getInitialWindowPosition :: IO Position
+getInitialWindowPosition = do
+   x <- simpleGet fromIntegral glut_INIT_WINDOW_X
+   y <- simpleGet fromIntegral glut_INIT_WINDOW_Y
+   return $ Position x y
+
+setInitialWindowPosition :: Position -> IO ()
+setInitialWindowPosition (Position x y) =
+    glutInitWindowPosition (fromIntegral x) (fromIntegral y)
+
+foreign import CALLCONV unsafe "glutInitWindowPosition" glutInitWindowPosition
+   :: CInt -> CInt -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Controls the /initial window size/.  Windows created by
+-- 'Graphics.UI.GLUT.Window.createWindow' will be requested to be created with
+-- the current /initial window size/. The initial value of the /initial window
+-- size/ GLUT state is @'Size' 300 300@. If either the width or the height
+-- component of the /initial window size/ is non-positive, the actual window
+-- size is left to the window system to determine.
+--
+-- The intent of the /initial window size/ is to provide a suggestion to the
+-- window system for a window\'s initial size. The window system is not
+-- obligated to use this information. Therefore, GLUT programs should not
+-- assume the window was created at the specified size. A GLUT program should
+-- use the window\'s reshape callback to determine the true size of the
+-- window.
+
+initialWindowSize :: StateVar Size
+initialWindowSize = makeStateVar getInitialWindowSize setInitialWindowSize
+
+getInitialWindowSize :: IO Size
+getInitialWindowSize = do
+   w <- simpleGet fromIntegral glut_INIT_WINDOW_WIDTH
+   h <- simpleGet fromIntegral glut_INIT_WINDOW_HEIGHT
+   return $ Size w h
+
+setInitialWindowSize :: Size -> IO ()
+setInitialWindowSize (Size w h) =
+   glutInitWindowSize (fromIntegral w) (fromIntegral h)
+
+foreign import CALLCONV unsafe "glutInitWindowSize" glutInitWindowSize ::
+   CInt -> CInt -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | A single aspect of a window which is to be created, used in conjunction
+-- with 'initialDisplayMode'.
+
+data DisplayMode
+   = RGBAMode           -- ^ Select an RGBA mode window. This is the default if neither 'RGBAMode' nor 'IndexMode' are specified.
+   | RGBMode            -- ^ An alias for 'RGBAMode'.
+   | IndexMode          -- ^ Select a color index mode window. This overrides 'RGBAMode' if it is also specified.
+   | LuminanceMode      -- ^ Select a window with a \"luminance\" color model. This model provides the functionality of OpenGL\'s
+                        --   RGBA color model, but the green and blue components are not maintained in the frame buffer. Instead
+                        --   each pixel\'s red component is converted to an index between zero and  'Graphics.UI.GLUT.Colormap.numColorMapEntries'
+                        --   and looked up in a per-window color map to determine the color of pixels within the window. The initial
+                        --   colormap of 'LuminanceMode' windows is initialized to be a linear gray ramp, but can be modified with GLUT\'s
+                        --   colormap actions. /Implementation Notes:/ 'LuminanceMode' is not supported on most OpenGL platforms.
+   | WithAlphaComponent -- ^ Select a window with an alpha component to the color buffer(s).
+   | WithAccumBuffer    -- ^ Select a window with an accumulation buffer.
+   | WithDepthBuffer    -- ^ Select a window with a depth buffer.
+   | WithStencilBuffer  -- ^ Select a window with a stencil buffer.
+   | WithAuxBuffers Int -- ^ (/freeglut only/) Select a window with /n/ (1 .. 4) auxiliary buffers. Any /n/ outside the range 1 .. 4 is a fatal error.
+   | SingleBuffered     -- ^ Select a single buffered window. This is the default if neither 'DoubleBuffered' nor 'SingleBuffered' are specified.
+   | DoubleBuffered     -- ^ Select a double buffered window. This overrides 'SingleBuffered' if it is also specified.
+   | Multisampling      -- ^ Select a window with multisampling support. If multisampling is not available, a non-multisampling
+                        --   window will automatically be chosen. Note: both the OpenGL client-side and server-side implementations
+                        --   must support the @GLX_SAMPLE_SGIS@ extension for multisampling to be available.
+   | Stereoscopic       -- ^ Select A Stereo Window.
+   deriving ( Eq, Ord, Show )
+
+marshalDisplayMode :: DisplayMode -> CUInt
+marshalDisplayMode m = case m of
+   RGBAMode -> glut_RGBA
+   RGBMode -> glut_RGB
+   IndexMode -> glut_INDEX
+   SingleBuffered -> glut_SINGLE
+   DoubleBuffered -> glut_DOUBLE
+   WithAccumBuffer -> glut_ACCUM
+   WithAlphaComponent -> glut_ALPHA
+   WithDepthBuffer -> glut_DEPTH
+   WithStencilBuffer -> glut_STENCIL
+   WithAuxBuffers 1 -> glut_AUX1
+   WithAuxBuffers 2 -> glut_AUX2
+   WithAuxBuffers 3 -> glut_AUX3
+   WithAuxBuffers 4 -> glut_AUX4
+   WithAuxBuffers n ->
+      error ("marshalDisplayMode: illegal number of auxiliary buffers: " ++ show n)
+   Multisampling -> glut_MULTISAMPLE
+   Stereoscopic -> glut_STEREO
+   LuminanceMode -> glut_LUMINANCE
+
+--------------------------------------------------------------------------------
+
+-- | Controls the /initial display mode/ used when creating top-level windows,
+-- subwindows, and overlays to determine the OpenGL display mode for the
+-- to-be-created window or overlay.
+--
+-- Note that 'RGBAMode' selects the RGBA color model, but it does not request any
+-- bits of alpha (sometimes called an /alpha buffer/ or /destination alpha/)
+-- be allocated. To request alpha, specify 'WithAlphaComponent'. The same
+-- applies to 'LuminanceMode'.
+
+initialDisplayMode :: StateVar [DisplayMode]
+initialDisplayMode = makeStateVar getInitialDisplayMode setInitialDisplayMode
+
+getInitialDisplayMode :: IO [DisplayMode]
+getInitialDisplayMode = simpleGet i2dms glut_INIT_DISPLAY_MODE
+
+i2dms :: CInt -> [DisplayMode]
+i2dms bitfield =
+   [ c | c <- [ RGBAMode, RGBMode, IndexMode, SingleBuffered, DoubleBuffered,
+                WithAccumBuffer, WithAlphaComponent, WithDepthBuffer,
+                WithStencilBuffer, WithAuxBuffers 1, WithAuxBuffers 2,
+                WithAuxBuffers 3, WithAuxBuffers 4, Multisampling, Stereoscopic,
+                LuminanceMode ]
+       , (fromIntegral bitfield .&. marshalDisplayMode c) /= 0 ]
+
+setInitialDisplayMode :: [DisplayMode] -> IO ()
+setInitialDisplayMode = glutInitDisplayMode . toBitfield marshalDisplayMode
+
+toBitfield :: (Bits b) => (a -> b) -> [a] -> b
+toBitfield marshal = foldl (.|.) 0 . map marshal
+
+foreign import CALLCONV unsafe "glutInitDisplayMode" glutInitDisplayMode ::
+   CUInt -> IO ()
+
+-- | Contains 'True' if the /current display mode/ is supported, 'False'
+-- otherwise.
+
+displayModePossible :: GettableStateVar Bool
+displayModePossible =
+   makeGettableStateVar $ simpleGet (/= 0) glut_DISPLAY_MODE_POSSIBLE
+
+--------------------------------------------------------------------------------
+
+-- | Capabilities for 'initialDisplayCapabilities', most of them are extensions
+-- of the constructors of 'DisplayMode'.
+
+data DisplayCapability
+   = DisplayRGBA  -- ^ Number of bits of red, green, blue, and alpha in the RGBA
+                  --   color buffer. Default is \"'IsAtLeast' @1@\" for red,
+                  --   green, blue, and alpha capabilities, and \"'IsEqualTo'
+                  --   @1@\" for the RGBA color model capability.
+   | DisplayRGB   -- ^ Number of bits of red, green, and blue in the RGBA color
+                  --   buffer and zero bits of alpha color buffer precision.
+                  --   Default is \"'IsAtLeast' @1@\" for the red, green, and
+                  --   blue capabilities, and \"'IsNotLessThan' @0@\" for alpha
+                  --   capability, and \"'IsEqualTo' @1@\" for the RGBA color
+                  --   model capability.
+   | DisplayRed   -- ^ Red color buffer precision in bits. Default is
+                  --   \"'IsAtLeast' @1@\".
+   | DisplayGreen -- ^ Green color buffer precision in bits. Default is
+                  --   \"'IsAtLeast' @1@\".
+   | DisplayBlue  -- ^ Blue color buffer precision in bits. Default is
+                  --   \"'IsAtLeast' @1@\".
+   | DisplayIndex -- ^ Boolean if the color model is color index or not. True is
+                  --   color index. Default is \"'IsAtLeast' @1@\".
+   | DisplayBuffer -- ^ Number of bits in the color index color buffer. Default
+                  --   is \"'IsAtLeast' @1@\".
+   | DisplaySingle -- ^ Boolean indicate the color buffer is single buffered.
+                  --   Default is \"'IsEqualTo' @1@\".
+   | DisplayDouble -- ^ Boolean indicating if the color buffer is double
+                  --   buffered. Default is \"'IsEqualTo' @1@\".
+   | DisplayAccA  -- ^ Red, green, blue, and alpha accumulation buffer precision
+                  --   in  bits. Default is \"'IsAtLeast' @1@\" for red, green,
+                  --   blue, and alpha capabilities.
+   | DisplayAcc   -- ^ Red, green, and green accumulation buffer precision in
+                  --   bits and zero bits of alpha accumulation buffer precision.
+                  --   Default is \"'IsAtLeast' @1@\" for red, green, and blue
+                  --   capabilities, and \"'IsNotLessThan' @0@\" for the alpha
+                  --   capability.
+   | DisplayAlpha -- ^ Alpha color buffer precision in bits. Default is
+                  --   \"'IsAtLeast' @1@\".
+   | DisplayDepth -- ^ Number of bits of precsion in the depth buffer. Default
+                  --   is \"'IsAtLeast' @12@\".
+   | DisplayStencil -- ^ Number of bits in the stencil buffer. Default is
+                  --   \"'IsNotLessThan' @1@\".
+   | DisplaySamples -- ^ Indicates the number of multisamples to use based on
+                  --   GLX\'s @SGIS_multisample@ extension (for antialiasing).
+                  --   Default is \"'IsNotGreaterThan' @4@\". This default means
+                  --   that a GLUT application can request multisampling if
+                  --   available by simply specifying \"'With' 'DisplaySamples'\".
+   | DisplayStereo -- ^ Boolean indicating the color buffer is supports
+                  --   OpenGL-style stereo. Default is \"'IsEqualTo' @1@\".
+   | DisplayLuminance -- ^ Number of bits of red in the RGBA and zero bits of green,
+                  --   blue (alpha not specified) of color buffer precision.
+                  --   Default is \"'IsAtLeast' @1@\" for the red capabilitis,
+                  --   and \"'IsEqualTo' @0@\" for the green and blue
+                  --   capabilities, and \"'IsEqualTo' @1@\" for the RGBA color
+                  --   model capability, and, for X11, \"'IsEqualTo' @1@\" for
+                  --   the 'DisplayXStaticGray' capability. SGI InfiniteReality (and
+                  --   other future machines) support a 16-bit luminance (single
+                  --   channel) display mode (an additional 16-bit alpha channel
+                  --   can also be requested). The red channel maps to gray
+                  --   scale and green and blue channels are not available. A
+                  --   16-bit precision luminance display mode is often
+                  --   appropriate for medical imaging applications. Do not
+                  --   expect many machines to support extended precision
+                  --   luminance display modes.
+   | DisplayAux   -- ^ (/freeglut only/) Number of auxiliary buffers. Default is
+                  --   \"'IsEqualTo' @1@\".
+   | DisplayNum   -- ^ A special capability name indicating where the value
+                  --   represents the Nth frame buffer configuration matching
+                  --   the description string. When not specified,
+                  --   'initialDisplayCapabilities' also uses the first
+                  --   (best matching) configuration. 'Num' requires a relation
+                  --   and numeric value.
+   | DisplayConformant -- ^ Boolean indicating if the frame buffer configuration is
+                  --   conformant or not. Conformance information is based on
+                  --   GLX\'s @EXT_visual_rating@ extension if supported. If the
+                  --   extension is not supported, all visuals are assumed
+                  --   conformant. Default is \"'IsEqualTo' @1@\".
+   | DisplaySlow  -- ^ Boolean indicating if the frame buffer configuration is
+                  --   slow or not. Slowness information is based on GLX\'s
+                  --   @EXT_visual_rating@ extension if supported. If the
+                  --   extension is not supported, all visuals are assumed fast.
+                  --   Note that slowness is a relative designation relative to
+                  --   other frame buffer configurations available. The intent
+                  --   of the slow capability is to help programs avoid frame
+                  --   buffer configurations that are slower (but perhaps higher
+                  --   precision) for the current machine. Default is
+                  --   \"'IsAtLeast' @0@\". This default means that slow visuals
+                  --   are used in preference to fast visuals, but fast visuals
+                  --   will still be allowed.
+   | DisplayWin32PFD -- ^ Only recognized on GLUT implementations for Win32, this
+                  --   capability name matches the Win32 Pixel Format Descriptor
+                  --   by number. 'DisplayWin32PFD' can only be used with 'Where'.
+   | DisplayXVisual -- ^ Only recongized on GLUT implementations for the X Window
+                  --   System, this capability name matches the X visual ID by
+                  --   number. 'DisplayXVisual' requires a relation and numeric value.
+   | DisplayXStaticGray -- ^ Only recongized on GLUT implementations for the X Window
+                  --   System, boolean indicating if the frame buffer
+                  --   configuration\'s X visual is of type @StaticGray@.
+                  --   Default is \"'IsEqualTo' @1@\".
+   | DisplayXGrayScale -- ^ Only recongized on GLUT implementations for the X Window
+                  --   System, boolean indicating if the frame buffer
+                  --   configuration\'s X visual is of type @GrayScale@. Default
+                  --   is \"'IsEqualTo' @1@\".
+   | DisplayXStaticColor -- ^ Only recongized on GLUT implementations for the X Window
+                  --   System, boolean indicating if the frame buffer
+                  --   configuration\'s X visual is of type @StaticColor@.
+                  --   Default is \"'IsEqualTo' @1@\".
+   | DisplayXPseudoColor -- ^ Only recongized on GLUT implementations for the X Window
+                  --   System, boolean indicating if the frame buffer
+                  --   configuration\'s X visual is of type @PsuedoColor@.
+                  --   Default is \"'IsEqualTo' @1@\".
+   | DisplayXTrueColor -- ^ Only recongized on GLUT implementations for the X Window
+                  --   System, boolean indicating if the frame buffer
+                  --   configuration\'s X visual is of type @TrueColor@. Default
+                  --   is \"'IsEqualTo' @1@\".
+   | DisplayXDirectColor -- ^ Only recongized on GLUT implementations for the X Window
+                  --   System, boolean indicating if the frame buffer
+                  --   configuration\'s X visual is of type @DirectColor@.
+                  --   Default is \"'IsEqualTo' @1@\".
+   deriving ( Eq, Ord, Show )
+
+displayCapabilityToString :: DisplayCapability -> String
+displayCapabilityToString x = case x of
+   DisplayRGBA         -> "rgba"
+   DisplayRGB          -> "rgb"
+   DisplayRed          -> "red"
+   DisplayGreen        -> "green"
+   DisplayBlue         -> "blue"
+   DisplayIndex        -> "index"
+   DisplayBuffer       -> "buffer"
+   DisplaySingle       -> "single"
+   DisplayDouble       -> "double"
+   DisplayAccA         -> "acca"
+   DisplayAcc          -> "acc"
+   DisplayAlpha        -> "alpha"
+   DisplayDepth        -> "depth"
+   DisplayStencil      -> "stencil"
+   DisplaySamples      -> "samples"
+   DisplayStereo       -> "stereo"
+   DisplayLuminance    -> "luminance"
+   DisplayAux          -> "aux"
+   DisplayNum          -> "num"
+   DisplayConformant   -> "conformant"
+   DisplaySlow         -> "slow"
+   DisplayWin32PFD     -> "win32pfd"
+   DisplayXVisual      -> "xvisual"
+   DisplayXStaticGray  -> "xstaticgray"
+   DisplayXGrayScale   -> "xgrayscale"
+   DisplayXStaticColor -> "xstaticcolor"
+   DisplayXPseudoColor -> "xpseudocolor"
+   DisplayXTrueColor   -> "xtruecolor"
+   DisplayXDirectColor -> "xdirectcolor"
+
+-- | A single capability description for 'initialDisplayCapabilities'.
+
+data DisplayCapabilityDescription
+   = Where DisplayCapability Relation Int
+     -- ^ A description of a capability with a specific relation to a numeric
+     --   value.
+   | With  DisplayCapability
+     -- ^ When the relation and numeric value are not specified, each capability
+     --   has a different default, see the different constructors of
+     --   'DisplayCapability'.
+   deriving ( Eq, Ord, Show )
+
+displayCapabilityDescriptionToString ::  DisplayCapabilityDescription -> String
+displayCapabilityDescriptionToString (Where c r i) =
+   displayCapabilityToString c ++ relationToString r ++ show i
+displayCapabilityDescriptionToString (With c) = displayCapabilityToString c
+
+-- | Controls the /initial display mode/ used when creating top-level windows,
+-- subwindows, and overlays to determine the OpenGL display mode for the
+-- to-be-created window or overlay. It is described by a list of zero or more
+-- capability descriptions, which are translated into a set of criteria used to
+-- select the appropriate frame buffer configuration. The criteria are matched
+-- in strict left to right order of precdence. That is, the first specified
+-- criterion (leftmost) takes precedence over the later criteria for non-exact
+-- criteria ('IsGreaterThan', 'IsLessThan', etc.). Exact criteria ('IsEqualTo',
+-- 'IsNotEqualTo') must match exactly so precedence is not relevant.
+--
+-- Unspecified capability descriptions will result in unspecified criteria being
+-- generated. These unspecified criteria help 'initialDisplayCapabilities'
+-- behave sensibly with terse display mode descriptions.
+--
+-- Here is an example using 'initialDisplayCapabilities':
+--
+-- @
+--    initialDisplayCapabilities $= [ With  DisplayRGB,
+--                                    Where DisplayDepth IsAtLeast 16,
+--                                    With  DisplaySamples,
+--                                    Where DisplayStencil IsNotLessThan 2,
+--                                    With  DisplayDouble ]
+-- @
+--
+-- The above call requests a window with an RGBA color model (but requesting
+-- no bits of alpha), a depth buffer with at least 16 bits of precision but
+-- preferring more, multisampling if available, at least 2 bits of stencil
+-- (favoring less stencil to more as long as 2 bits are available), and double
+-- buffering.
+
+initialDisplayCapabilities :: SettableStateVar [DisplayCapabilityDescription]
+initialDisplayCapabilities =
+   makeSettableStateVar $ \caps ->
+      withCString
+         (concat . intersperse " " . map displayCapabilityDescriptionToString $
+          caps)
+         glutInitDisplayString
+
+foreign import CALLCONV unsafe "glutInitDisplayString" glutInitDisplayString ::
+  CString -> IO ()
+
+-----------------------------------------------------------------------------
+
+-- | How rendering context for new windows are created.
+
+data RenderingContext
+   = -- | Create a new context via @glXCreateContext@ or @wglCreateContext@
+     --   (default).
+     CreateNewContext
+   | -- | Re-use the current rendering context.
+     UseCurrentContext
+   deriving ( Eq, Ord, Show )
+
+marshalRenderingContext :: RenderingContext -> CInt
+marshalRenderingContext CreateNewContext  = glut_CREATE_NEW_CONTEXT
+marshalRenderingContext UseCurrentContext = glut_USE_CURRENT_CONTEXT
+
+unmarshalRenderingContext :: CInt -> RenderingContext
+unmarshalRenderingContext r
+   | r == glut_CREATE_NEW_CONTEXT  = CreateNewContext
+   | r == glut_USE_CURRENT_CONTEXT = UseCurrentContext
+   | otherwise = error "unmarshalRenderingContext"
+
+-----------------------------------------------------------------------------
+
+-- | (/freeglut only/) Controls the creation of rendering contexts for new
+-- windows.
+
+renderingContext :: StateVar RenderingContext
+renderingContext =
+   makeStateVar
+      (simpleGet unmarshalRenderingContext glut_RENDERING_CONTEXT)
+      (glutSetOption glut_RENDERING_CONTEXT . marshalRenderingContext)
+
+-----------------------------------------------------------------------------
+
+-- | The kind of GLX rendering context used. Direct rendering provides a
+-- performance advantage in some implementations. However, direct rendering
+-- contexts cannot be shared outside a single process, and they may be unable
+-- to render to GLX pixmaps.
+
+data DirectRendering
+   = -- | Rendering is always done through the X server. This corresponds to
+     -- the command line argument @-indirect@, see 'initialize'.
+     ForceIndirectContext
+   | -- | Try to use direct rendering, silently using indirect rendering if this
+     -- is not possible.
+     AllowDirectContext
+   | -- | Try to use direct rendering, issue a warning and use indirect
+     -- rendering if this is not possible.
+     TryDirectContext
+   | -- | Try to use direct rendering, issue an error and terminate the program
+     -- if this is not possible.This corresponds to the command line argument
+     -- @-direct@, see 'initialize'.
+     ForceDirectContext
+   deriving ( Eq, Ord, Show )
+
+marshalDirectRendering :: DirectRendering -> CInt
+marshalDirectRendering x = case x of
+   ForceIndirectContext -> glut_FORCE_INDIRECT_CONTEXT
+   AllowDirectContext -> glut_ALLOW_DIRECT_CONTEXT
+   TryDirectContext -> glut_TRY_DIRECT_CONTEXT
+   ForceDirectContext -> glut_FORCE_DIRECT_CONTEXT
+
+unmarshalDirectRendering :: CInt -> DirectRendering
+unmarshalDirectRendering x
+   | x == glut_FORCE_INDIRECT_CONTEXT = ForceIndirectContext
+   | x == glut_ALLOW_DIRECT_CONTEXT = AllowDirectContext
+   | x == glut_TRY_DIRECT_CONTEXT = TryDirectContext
+   | x == glut_FORCE_DIRECT_CONTEXT = ForceDirectContext
+   | otherwise = error ("unmarshalDirectRendering: illegal value " ++ show x)
+
+-----------------------------------------------------------------------------
+
+-- | (/freeglut on X11 only/) Controls which kind of rendering context is
+-- created when a new one is required.
+
+directRendering :: StateVar DirectRendering
+directRendering =
+   makeStateVar
+      (simpleGet unmarshalDirectRendering glut_DIRECT_RENDERING)
+      (glutSetOption glut_DIRECT_RENDERING . marshalDirectRendering)
diff --git a/Graphics/UI/GLUT/Menu.hs b/Graphics/UI/GLUT/Menu.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Menu.hs
@@ -0,0 +1,310 @@
+{-# OPTIONS_GHC -fno-cse #-}
+
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Menu
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- GLUT supports simple cascading pop-up menus. They are designed to let a user
+-- select various modes within a program. The functionality is simple and
+-- minimalistic and is meant to be that way. Do not mistake GLUT\'s pop-up menu
+-- facility with an attempt to create a full-featured user interface.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Menu (
+   Menu(..), MenuItem(..), MenuCallback, attachMenu,
+   numMenuItems
+) where
+
+import Data.Array ( listArray, (!) )
+import Data.IORef ( IORef, newIORef, readIORef, modifyIORef )
+import qualified Data.Map as Map ( empty, lookup, insert, delete )
+import Data.Map ( Map )
+import Foreign.C.String ( CString, withCString )
+import Foreign.C.Types ( CInt )
+import Foreign.Ptr ( FunPtr, freeHaskellFunPtr )
+import Control.Monad ( unless, zipWithM, when )
+import System.IO.Unsafe ( unsafePerformIO )
+import Graphics.Rendering.OpenGL.GL.StateVar (
+   HasGetter(get), HasSetter(($=)),
+   GettableStateVar, makeGettableStateVar,
+   StateVar, makeStateVar )
+import Graphics.UI.GLUT.Constants ( glut_MENU_NUM_ITEMS )
+import Graphics.UI.GLUT.QueryUtils ( simpleGet )
+import Graphics.UI.GLUT.Types ( marshalMouseButton )
+import Graphics.UI.GLUT.Window ( Window )
+import Graphics.UI.GLUT.Callbacks.Registration ( getCurrentWindow )
+import Graphics.UI.GLUT.Callbacks.Window ( MouseButton )
+
+--------------------------------------------------------------------------------
+
+-- | A menu is simply a list of menu items.
+newtype Menu = Menu [MenuItem]
+
+-- | A single item within a menu can either be a plain menu entry or a sub-menu
+-- entry, allowing for arbitrarily deep nested menus.
+data MenuItem
+   = MenuEntry String MenuCallback -- ^ A plain menu entry with an associated
+                                   --   callback, which is triggered when the
+                                   --   user selects the entry
+   | SubMenu   String Menu         -- ^ A sub-menu, which is cascaded when the
+                                   --   user selects the entry, allowing
+                                   --   sub-menu entries to be selected
+
+type MenuCallback = IO ()
+
+-- | Create a new pop-up menu for the /current window,/ attaching it to the
+-- given mouse button. A previously attached menu (if any), is detached before
+-- and won\'t receive callbacks anymore.
+--
+-- It is illegal to call 'attachMenu' while any (sub-)menu is in use, i.e.
+-- popped up.
+--
+-- /X Implementation Notes:/ If available, GLUT for X will take advantage of
+-- overlay planes for implementing pop-up menus. The use of overlay planes can
+-- eliminate display callbacks when pop-up menus are deactivated. The
+-- @SERVER_OVERLAY_VISUALS@ convention is used to determine if overlay visuals
+-- are available.
+
+attachMenu :: MouseButton -> Menu -> IO ()
+attachMenu mouseButton menu@(Menu items) = do
+   win <- getCurrentWindow "attachMenu"
+   let hook = MenuHook win mouseButton
+   detachMenu hook
+   unless (null items) $ do
+      (_, destructor) <- traverseMenu menu
+      addToMenuTable hook destructor
+      attachMenu_ mouseButton
+
+detachMenu :: MenuHook -> IO ()
+detachMenu hook@(MenuHook _ mouseButton) = do
+   maybeDestructor <- lookupInMenuTable hook
+   case maybeDestructor of
+      Nothing         -> return ()
+      Just destructor -> do detachMenu_ mouseButton
+                            destructor
+   deleteFromMenuTable hook
+
+traverseMenu :: Menu -> IO (MenuID, Destructor)
+traverseMenu (Menu items) = do
+   let callbackArray = listArray (1, length items) (map makeCallback items)
+   cb <- makeMenuFunc (\i -> callbackArray ! (fromIntegral i))
+   menuID <- glutCreateMenu cb
+   destructors <- zipWithM addMenuItem items [1..]
+   let destructor = do sequence_ destructors
+                       glutDestroyMenu menuID
+                       freeHaskellFunPtr cb
+   return (menuID, destructor)
+
+makeCallback :: MenuItem -> MenuCallback
+makeCallback (MenuEntry _ cb) = cb
+makeCallback _ = error "shouldn't receive a callback for submenus"
+
+addMenuItem :: MenuItem -> Value -> IO Destructor
+addMenuItem (MenuEntry s _) v = do
+   addMenuEntry s v
+   return $ glutRemoveMenuItem 1
+addMenuItem (SubMenu s m) _ = do
+   (menuID, destructor) <- saveExcursion (traverseMenu m)
+   addSubMenu s menuID
+   return $ do glutRemoveMenuItem 1
+               destructor
+
+-- Perform an action, saving/restoring the current menu around it
+saveExcursion :: IO a -> IO a
+saveExcursion act = do
+   menuID <- get currentMenu
+   returnValue <- act
+   when (isRealMenu menuID) $
+      currentMenu $= menuID
+   return returnValue
+
+--------------------------------------------------------------------------------
+-- This seems to be a common Haskell hack nowadays: A plain old global variable
+-- with an associated mutator. Perhaps some language/library support is needed?
+
+{-# NOINLINE theMenuTable #-}
+theMenuTable :: IORef MenuTable
+theMenuTable = unsafePerformIO (newIORef emptyMenuTable)
+
+getMenuTable :: IO MenuTable
+getMenuTable = readIORef theMenuTable
+
+modifyMenuTable :: (MenuTable -> MenuTable) -> IO ()
+modifyMenuTable = modifyIORef theMenuTable
+
+--------------------------------------------------------------------------------
+-- To facilitate cleanup, we have to keep track how to destroy menus which are
+-- currently attached in a window to a mouse button.
+
+data MenuHook = MenuHook Window MouseButton
+   deriving ( Eq, Ord )
+
+type Destructor = IO ()
+
+type MenuTable = Map MenuHook Destructor
+
+emptyMenuTable :: MenuTable
+emptyMenuTable = Map.empty
+
+lookupInMenuTable :: MenuHook -> IO (Maybe Destructor)
+lookupInMenuTable callbackID =
+   fmap (Map.lookup callbackID) getMenuTable
+
+deleteFromMenuTable :: MenuHook -> IO ()
+deleteFromMenuTable callbackID =
+   modifyMenuTable (Map.delete callbackID)
+
+addToMenuTable :: MenuHook -> Destructor -> IO ()
+addToMenuTable callbackID funPtr =
+   modifyMenuTable (Map.insert callbackID funPtr)
+
+--------------------------------------------------------------------------------
+
+type MenuID = CInt
+type Value  = CInt
+type Item   = CInt
+
+--------------------------------------------------------------------------------
+
+-- | The type of a menu callback action that is called when a menu entry from a
+-- menu is selected. The value passed to the callback is determined by the value
+-- for the selected menu entry.
+
+type MenuCB = CInt -> IO ()
+
+-- | Create a new pop-up menu and return a unique identifier for it, which can
+-- be used when setting 'currentMenu'. Implicitly, the /current menu/ is set to
+-- the newly created menu.
+--
+-- When the menu callback is called because a menu entry is selected for the
+-- menu, the /current menu/ will be implicitly set to the menu with the selected
+-- entry before the callback is made.
+--
+-- /X Implementation Notes:/ If available, GLUT for X will take advantage of
+-- overlay planes for implementing pop-up menus. The use of overlay planes can
+-- eliminate display callbacks when pop-up menus are deactivated. The
+-- @SERVER_OVERLAY_VISUALS@ convention is used to determine if overlay visuals
+-- are available.
+
+foreign import CALLCONV unsafe "glutCreateMenu" glutCreateMenu ::
+   FunPtr MenuCB -> IO MenuID
+
+foreign import ccall "wrapper" makeMenuFunc :: MenuCB -> IO (FunPtr MenuCB)
+
+-- | Destroy the specified menu. If it was the /current menu/, the /current
+-- menu/ becomes invalid and 'currentMenu' will contain 'Nothing'.
+
+foreign import CALLCONV unsafe "glutDestroyMenu" glutDestroyMenu ::
+   MenuID -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Controls the /current menu./ If no menus exist or the previous /current
+-- menu/ was destroyed, a pseudo menu is returned, see 'isRealMenu'.
+
+currentMenu :: StateVar MenuID
+currentMenu = makeStateVar glutGetMenu glutSetMenu
+
+foreign import CALLCONV unsafe "glutSetMenu" glutSetMenu :: MenuID -> IO ()
+
+foreign import CALLCONV unsafe "glutGetMenu" glutGetMenu :: IO MenuID
+
+-- | Returns 'True' if the given menu identifier refers to a real menu, not
+-- a pseudo one.
+
+isRealMenu :: MenuID -> Bool
+isRealMenu = (/= 0)
+
+--------------------------------------------------------------------------------
+
+-- | Add a menu entry to the bottom of the /current menu./ The given string will
+-- be displayed for the newly added menu entry. If the menu entry is selected by
+-- the user, the menu\'s callback will be called passing the given value as the
+-- callback\'s parameter.
+
+addMenuEntry :: String -> Value -> IO ()
+addMenuEntry name value = withCString name $ \n -> glutAddMenuEntry n value
+
+foreign import CALLCONV unsafe "glutAddMenuEntry" glutAddMenuEntry ::
+   CString -> Value -> IO ()
+
+-- | Add a sub-menu trigger to the bottom of the /current menu./ The given
+-- string will be displayed for the newly added sub-menu trigger. If the
+-- sub-menu trigger is entered, the sub-menu specified by the given menu
+-- identifier will be cascaded, allowing sub-menu menu items to be selected.
+
+addSubMenu :: String -> MenuID -> IO ()
+addSubMenu name menuID = withCString name $ \n -> glutAddSubMenu n menuID
+
+foreign import CALLCONV unsafe "glutAddSubMenu" glutAddSubMenu ::
+   CString -> MenuID -> IO ()
+
+--------------------------------------------------------------------------------
+
+{- UNUSED
+-- | Change the specified menu entry in the /current menu/ into a menu entry.
+-- The given position determines which menu item should be changed and must be
+-- between 1 (the topmost menu item) and
+-- 'Graphics.UI.GLUT.State.getNumMenuItems' inclusive. The menu item to change
+-- does not have to be a menu entry already. The given string will be displayed
+-- for the newly changed menu entry. The given value will be returned to the
+-- menu\'s callback if this menu entry is selected.
+
+foreign import CALLCONV unsafe "glutChangeToMenuEntry" glutChangeToMenuEntry ::
+   Item -> CString -> Value -> IO ()
+
+-- | Change the specified menu item in the /current menu/ into a sub-menu
+-- trigger. The  given position determines which menu item should be changed and
+-- must be between 1 and 'Graphics.UI.GLUT.State.getNumMenuItems' inclusive. The
+-- menu item to change does not have to be a sub-menu trigger already. The
+-- given name will be displayed for the newly changed sub-menu trigger. The
+-- given menu identifier names the sub-menu to cascade from the newly added
+-- sub-menu trigger.
+
+foreign import CALLCONV unsafe "glutChangeToSubMenu" glutChangeToSubMenu ::
+   Item -> CString -> MenuID -> IO ()
+-}
+
+--------------------------------------------------------------------------------
+
+-- | Remove the menu item at the given position, regardless of whether it is a
+-- menu entry or sub-menu trigger. The position must be between 1 (the topmost
+-- menu item) and 'Graphics.UI.GLUT.State.getNumMenuItems' inclusive. Menu items
+-- below the removed menu item are renumbered.
+
+foreign import CALLCONV unsafe "glutRemoveMenuItem" glutRemoveMenuItem ::
+   Item -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Attach a mouse button for the /current window/ to the identifier of the
+-- /current menu./ By attaching a menu identifier to a button, the named menu
+-- will be popped up when the user presses the specified button. Note that the
+-- menu is attached to the button by identifier, not by reference.
+
+
+attachMenu_ :: MouseButton -> IO ()
+attachMenu_ = glutAttachMenu . marshalMouseButton
+
+foreign import CALLCONV unsafe "glutAttachMenu" glutAttachMenu :: CInt -> IO ()
+
+-- | Detach an attached mouse button from the /current window./
+
+detachMenu_ :: MouseButton -> IO ()
+detachMenu_ = glutDetachMenu . marshalMouseButton
+
+foreign import CALLCONV unsafe "glutDetachMenu" glutDetachMenu :: CInt -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Contains the number of menu items in the /current menu./
+
+numMenuItems :: GettableStateVar Int
+numMenuItems = makeGettableStateVar $ simpleGet fromIntegral glut_MENU_NUM_ITEMS
diff --git a/Graphics/UI/GLUT/Objects.hs b/Graphics/UI/GLUT/Objects.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Objects.hs
@@ -0,0 +1,342 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Objects
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- GLUT includes a number of routines for generating easily recognizable 3D
+-- geometric objects. These routines reflect functionality available in the
+-- @aux@ toolkit described in the /OpenGL Programmer\'s Guide/ and are included
+-- in GLUT to allow the construction of simple GLUT programs that render
+-- recognizable objects. These routines can be implemented as pure OpenGL
+-- rendering routines. The routines do not generate display lists for the
+-- objects they create. The routines generate normals appropriate for lighting
+-- but do not generate texture coordinates (except for the teapot).
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Objects (
+   -- * Rendering flavour
+   Flavour(..),
+
+   -- * Object description
+   Object(..),
+
+   -- * Type synonyms
+   Sides, Rings, NumLevels,
+
+   -- * Rendering
+   renderObject
+) where
+
+import Foreign.C.Types ( CInt )
+import Foreign.Marshal.Utils ( with )
+import Foreign.Ptr ( Ptr )
+import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLint, GLdouble )
+import Graphics.Rendering.OpenGL.GL.VertexSpec ( Vertex3(..) )
+import Graphics.Rendering.OpenGL.GLU.Quadrics ( Radius, Height, Slices, Stacks )
+import Graphics.UI.GLUT.Extensions
+
+--------------------------------------------------------------------------------
+
+#include "HsGLUTExt.h"
+
+--------------------------------------------------------------------------------
+
+-- | Flavour of object rendering
+
+data Flavour
+   = -- | Object is rendered as a solid with shading and surface normals.
+     Solid
+   | -- | Object is rendered as a wireframe without surface normals.
+     Wireframe
+   deriving ( Eq, Ord, Show )
+
+--------------------------------------------------------------------------------
+
+-- | GLUT offers five types of objects:
+--
+-- *  The five Platonic solids, see
+--    <http://mathworld.wolfram.com/PlatonicSolid.html>.
+--
+-- * A rhombic dodecahedron, see
+--   <http://mathworld.wolfram.com/RhombicDodecahedron.html>.
+--
+-- * Approximations to rounded objects.
+--
+-- * The classic teapot modeled by Martin Newell in 1975. Both surface normals
+--   and texture coordinates for the teapot are generated. The teapot is
+--   generated with OpenGL evaluators.
+--
+-- * A Sierpinski sponge, see
+--   <http://mathworld.wolfram.com/Tetrix.html>.
+
+data Object
+   = -- | A cube centered at the modeling coordinates origin with sides of the
+     --   given length.
+     Cube Height
+   | -- | A dodecahedron (12-sided regular solid) centered at the modeling
+     --   coordinates origin with a radius of @sqrt 3@.
+     Dodecahedron
+   | -- | A icosahedron (20-sided regular solid) centered at the modeling
+     --   coordinates origin with a radius of 1.0.
+     Icosahedron
+   | -- | Render a solid octahedron (8-sided regular solid) centered at the
+     --   modeling coordinates origin with a radius of 1.0.
+     Octahedron
+   | -- | Render a solid tetrahedron (4-sided regular solid) centered at the
+     --   modeling coordinates origin with a radius of @sqrt 3@.
+     Tetrahedron
+   | -- | (/freeglut only/) A rhombic dodecahedron whose corners are at most a
+     -- distance of one from the origin. The rhombic dodecahedron has faces
+     -- which are identical rhombi, but which have some vertices at which three
+     -- faces meet and some vertices at which four faces meet. The length of
+     -- each side is @(sqrt 3)\/2@. Vertices at which four faces meet are found
+     -- at @(0, 0, +\/-1)@ and @(+\/-(sqrt 2)\/2, +\/-(sqrt 2)\/2, 0)@. 
+     RhombicDodecahedron
+   | -- | A sphere centered at the modeling coordinates origin of the specified
+     --   radius. The sphere is subdivided around the Z axis into slices
+     --   (similar to lines of longitude) and along the Z axis into stacks
+     --   (similar to lines of latitude).
+     Sphere' Radius Slices Stacks
+   | -- | A cone oriented along the Z axis. The base of the cone is placed at Z
+     --   = 0, and the top at Z = the given height. The cone is subdivided
+     --   around the Z axis into slices, and along the Z axis into stacks.
+     Cone Radius Height Slices Stacks
+   | -- |(/freeglut only/) A cylinder oriented along the Z axis. The base of the
+     --  cylinder is placed at Z = 0, and the top at Z = the given height. The
+     --  cylinder is subdivided around the Z axis into slices, and along the Z
+     -- axis into stacks.
+     Cylinder' Radius Height Slices Stacks
+   | -- | A torus (doughnut) centered at the modeling coordinates origin
+     -- whose axis is aligned with the Z axis. The torus is described by its
+     -- inner and outer radius, the number of sides for each radial section,
+     -- and the number of radial divisions (rings).
+     Torus Radius Radius Sides Rings
+   | -- | A teapot with a given relative size.
+     Teapot Height
+   | -- |(/freeglut only/) A Sierpinski sponge of a given level, where a level
+     -- 0 sponge is the same as a 'Tetrahedron'. 
+     SierpinskiSponge NumLevels
+   deriving ( Eq, Ord, Show )
+
+--------------------------------------------------------------------------------
+
+type Sides     = GLint
+type Rings     = GLint
+type NumLevels = GLint
+
+--------------------------------------------------------------------------------
+
+-- | Render an object in the given flavour.
+
+renderObject :: Flavour -> Object -> IO ()
+renderObject Solid     (Cube h)             = solidCube h
+renderObject Wireframe (Cube h)             = wireCube  h
+renderObject Solid     Dodecahedron         = solidDodecahedron
+renderObject Wireframe Dodecahedron         = wireDodecahedron
+renderObject Solid     Icosahedron          = solidIcosahedron
+renderObject Wireframe Icosahedron          = wireIcosahedron
+renderObject Solid     Octahedron           = solidOctahedron
+renderObject Wireframe Octahedron           = wireOctahedron
+renderObject Solid     Tetrahedron          = solidTetrahedron
+renderObject Wireframe Tetrahedron          = wireTetrahedron
+renderObject Solid     RhombicDodecahedron  = glutSolidRhombicDodecahedron
+renderObject Wireframe RhombicDodecahedron  = glutWireRhombicDodecahedron
+renderObject Solid     (Sphere' r s t)      = solidSphere r s t
+renderObject Wireframe (Sphere' r s t)      = wireSphere  r s t 
+renderObject Solid     (Cone r h s t)       = solidCone r h s t
+renderObject Wireframe (Cone r h s t)       = wireCone  r h s t
+renderObject Solid     (Cylinder' r h s t)  = glutSolidCylinder r h s t
+renderObject Wireframe (Cylinder' r h s t)  = glutWireCylinder r h s t
+renderObject Solid     (Torus i o s r)      = solidTorus i o s r
+renderObject Wireframe (Torus i o s r)      = wireTorus  i o s r 
+renderObject Solid     (Teapot h)           = solidTeapot h
+renderObject Wireframe (Teapot h)           = wireTeapot  h
+renderObject Solid     (SierpinskiSponge n) = solidSierpinskiSponge n
+renderObject Wireframe (SierpinskiSponge n) = wireSierpinskiSponge n
+
+--------------------------------------------------------------------------------
+
+-- | Render a solid cube centered at the modeling coordinates origin with sides
+-- of the given length.
+
+foreign import CALLCONV unsafe "glutSolidCube" solidCube
+   :: Height -- ^ Length of the cube sides
+   -> IO ()
+
+-- | Render a wireframe cube centered at the modeling coordinates origin with
+-- sides of the given length.
+
+foreign import CALLCONV unsafe "glutWireCube" wireCube
+   :: Height -- ^ Length of the cube sides
+   -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Render a solid dodecahedron (12-sided regular solid) centered at the
+-- modeling coordinates origin with a radius of @sqrt 3@.
+
+foreign import CALLCONV unsafe "glutSolidDodecahedron" solidDodecahedron ::
+   IO ()
+
+-- | Render a wireframe dodecahedron (12-sided regular solid) centered at the
+-- modeling coordinates origin with a radius of @sqrt 3@.
+
+foreign import CALLCONV unsafe "glutWireDodecahedron" wireDodecahedron :: IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Render a solid icosahedron (20-sided regular solid) centered at the
+-- modeling coordinates origin with a radius of 1.0.
+
+foreign import CALLCONV unsafe "glutWireIcosahedron" wireIcosahedron :: IO ()
+
+-- | Render a wireframe icosahedron (20-sided regular solid) centered at the
+-- modeling coordinates origin with a radius of 1.0.
+
+foreign import CALLCONV unsafe "glutSolidIcosahedron" solidIcosahedron :: IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Render a solid octahedron (8-sided regular solid) centered at the modeling
+-- coordinates origin with a radius of 1.0.
+
+foreign import CALLCONV unsafe "glutSolidOctahedron" solidOctahedron :: IO ()
+
+-- | Render a wireframe octahedron (8-sided regular solid) centered at the
+-- modeling coordinates origin with a radius of 1.0.
+
+foreign import CALLCONV unsafe "glutWireOctahedron" wireOctahedron :: IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Render a solid tetrahedron (4-sided regular solid) centered at the modeling
+-- coordinates origin with a radius of @sqrt 3@.
+
+foreign import CALLCONV unsafe "glutWireTetrahedron" wireTetrahedron :: IO ()
+
+-- | Render a wireframe tetrahedron (4-sided regular solid) centered at the
+-- modeling coordinates origin with a radius of @sqrt 3@.
+
+foreign import CALLCONV unsafe "glutSolidTetrahedron" solidTetrahedron  :: IO ()
+
+--------------------------------------------------------------------------------
+
+EXTENSION_ENTRY(unsafe,"freeglut",glutSolidRhombicDodecahedron,IO ())
+
+EXTENSION_ENTRY(unsafe,"freeglut",glutWireRhombicDodecahedron,IO ())
+
+--------------------------------------------------------------------------------
+
+-- | Render a solid sphere centered at the modeling coordinates origin of the
+-- specified radius. The sphere is subdivided around the Z axis into slices
+-- and along the Z axis into stacks.
+
+foreign import CALLCONV unsafe "glutSolidSphere" solidSphere
+   :: Radius   -- ^ Radius of the sphere.
+   -> Slices   -- ^ Number of subdivisions (slices) around the Z axis, similar
+               --   to lines of longitude.
+   -> Stacks   -- ^ The number of subdivisions (stacks) along the Z axis,
+               --   similar to lines of latitude.
+   -> IO ()
+
+-- | Render a wireframe sphere centered at the modeling coordinates origin of
+-- the specified radius. The sphere is subdivided around the Z axis into slices
+-- and along the Z axis into stacks.
+
+foreign import CALLCONV unsafe "glutWireSphere" wireSphere
+   :: Radius   -- ^ Radius of the sphere.
+   -> Slices   -- ^ Number of subdivisions (slices) around the Z axis, similar
+               --   to lines of longitude.
+   -> Stacks   -- ^ The number of subdivisions (stacks) along the Z axis,
+               --   similar to lines of latitude.
+   -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Render a solid cone oriented along the Z axis. The base of the cone is
+-- placed at Z = 0, and the top at Z = height. The cone is subdivided around the
+-- Z axis into slices, and along the Z axis into stacks.
+
+foreign import CALLCONV unsafe "glutSolidCone" solidCone
+   :: Radius   -- ^ Radius of the base of the cone.
+   -> Height   -- ^ Height of the cone.
+   -> Slices   -- ^ Number of subdivisions around the Z axis.
+   -> Stacks   -- ^ The number of subdivisions along the Z axis.
+   -> IO ()
+
+-- | Render a wireframe cone oriented along the Z axis. The base of the cone is
+-- placed at Z = 0, and the top at Z = height. The cone is subdivided around the
+-- Z axis into slices, and along the Z axis into stacks.
+
+foreign import CALLCONV unsafe "glutWireCone" wireCone
+   :: Radius   -- ^ Radius of the base of the cone.
+   -> Height   -- ^ Height of the cone.
+   -> Slices   -- ^ Number of subdivisions around the Z axis.
+   -> Stacks   -- ^ The number of subdivisions along the Z axis.
+   -> IO ()
+
+--------------------------------------------------------------------------------
+
+EXTENSION_ENTRY(unsafe,"freeglut",glutSolidCylinder,Radius -> Height -> Slices -> Stacks -> IO ())
+
+EXTENSION_ENTRY(unsafe,"freeglut",glutWireCylinder,Radius -> Height -> Slices -> Stacks -> IO ())
+
+--------------------------------------------------------------------------------
+
+-- | Render a solid torus (doughnut) centered at the modeling coordinates origin
+-- whose axis is aligned with the Z axis.
+
+foreign import CALLCONV unsafe "glutSolidTorus" solidTorus
+   :: Radius   -- ^ Inner radius of the torus.
+   -> Radius   -- ^ Outer radius of the torus.
+   -> Slices   -- ^ Number of sides for each radial section.
+   -> Stacks   -- ^ Number of radial divisions for the torus.
+   -> IO ()
+
+-- | Render a wireframe torus (doughnut) centered at the modeling coordinates
+-- origin whose axis is aligned with the Z axis.
+
+foreign import CALLCONV unsafe "glutWireTorus" wireTorus
+   :: Radius   -- ^ Inner radius of the torus.
+   -> Radius   -- ^ Outer radius of the torus.
+   -> Slices   -- ^ Number of sides for each radial section.
+   -> Stacks   -- ^ Number of radial divisions for the torus.
+   -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Render a solid teapot.
+
+foreign import CALLCONV unsafe "glutSolidTeapot" solidTeapot  
+   :: Height -- ^ Relative size of the teapot
+   -> IO ()
+
+-- | Render a wireframe teapot.
+
+foreign import CALLCONV unsafe "glutWireTeapot" wireTeapot
+   :: Height -- ^ Relative size of the teapot
+   -> IO ()
+
+--------------------------------------------------------------------------------
+
+solidSierpinskiSponge :: NumLevels -> IO ()
+solidSierpinskiSponge = sierpinskiSponge glutSolidSierpinskiSponge
+
+EXTENSION_ENTRY(unsafe,"freeglut",glutSolidSierpinskiSponge,CInt -> Ptr (Vertex3 GLdouble) -> Height -> IO ())
+
+wireSierpinskiSponge :: NumLevels -> IO ()
+wireSierpinskiSponge = sierpinskiSponge glutWireSierpinskiSponge
+
+EXTENSION_ENTRY(unsafe,"freeglut",glutWireSierpinskiSponge,CInt -> Ptr (Vertex3 GLdouble) -> Height -> IO ())
+
+-- for consistency, we hide the offset and scale on the Haskell side
+sierpinskiSponge :: (CInt -> Ptr (Vertex3 GLdouble) -> Height -> IO ()) -> NumLevels -> IO ()
+sierpinskiSponge f n =
+   with (Vertex3 0 0 0) $ \offsetBuf ->
+      f (fromIntegral n) offsetBuf 1
diff --git a/Graphics/UI/GLUT/Overlay.hs b/Graphics/UI/GLUT/Overlay.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Overlay.hs
@@ -0,0 +1,191 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Overlay
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- When  overlay hardware is available, GLUT provides a set of routines for
+-- establishing, using, and removing an overlay for GLUT windows. When an
+-- overlay is established, a separate OpenGL context is also established. A
+-- window\'s overlay OpenGL state is kept distinct from the normal planes\'
+-- OpenGL state.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Overlay (
+   -- * Overlay creation and destruction
+   hasOverlay, overlayPossible,
+
+   -- * Showing and hiding an overlay
+   overlayVisible,
+
+   -- * Changing the /layer in use/
+   Layer(..), layerInUse,
+
+   -- * Re-displaying
+   postOverlayRedisplay
+) where
+
+import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
+import Graphics.Rendering.OpenGL.GL.StateVar (
+   GettableStateVar, makeGettableStateVar,
+   SettableStateVar, makeSettableStateVar,
+   StateVar, makeStateVar )
+import Graphics.UI.GLUT.Constants (
+   glut_OVERLAY_POSSIBLE, glut_HAS_OVERLAY, glut_NORMAL, glut_OVERLAY,
+   glut_LAYER_IN_USE )
+import Graphics.UI.GLUT.QueryUtils ( layerGet )
+#ifdef __NHC__
+import NHC.FFI ( CInt )
+#endif
+import Graphics.UI.GLUT.Window ( Window )
+
+--------------------------------------------------------------------------------
+
+-- | Controls the overlay for the /current window/. The requested display mode
+-- for the overlay is determined by the /initial display mode/.
+-- 'overlayPossible' can be used to determine if an overlay is possible for the
+-- /current window/ with the current /initial display mode/. Do not attempt to
+-- establish an overlay when one is not possible; GLUT will terminate the
+-- program.
+--
+-- When 'hasOverlay' is set to 'True' when an overlay already exists, the
+-- existing overlay is first removed, and then a new overlay is established. The
+-- state of the old overlay\'s OpenGL context is discarded. Implicitly, the
+-- window\'s /layer in use/ changes to the overlay immediately after the overlay
+-- is established.
+--
+-- The initial display state of an overlay is shown, however the overlay is only
+-- actually shown if the overlay\'s window is shown.
+--
+-- Setting 'hasOverlay' to 'False' is safe even if no overlay is currently
+-- established, nothing happens in this case. Implicitly, the window\'s /layer
+-- in use/ changes to the normal plane immediately once the overlay is removed.
+-- 
+-- If the program intends to re-establish the overlay later, it is typically
+-- faster and less resource intensive to use 'overlayVisible' to simply change
+-- the display status of the overlay.
+--
+-- /X Implementation Notes:/ GLUT for X uses the @SERVER_OVERLAY_VISUALS@
+-- convention to determine if overlay visuals are available. While the
+-- convention allows for opaque overlays (no transparency) and overlays with the
+-- transparency specified as a bitmask, GLUT overlay management only provides
+-- access to transparent pixel overlays.
+-- 
+-- Until RGBA overlays are better understood, GLUT only supports color index
+-- overlays.
+
+hasOverlay :: StateVar Bool
+hasOverlay = makeStateVar getHasOverlay setHasOverlay
+
+setHasOverlay :: Bool -> IO ()
+setHasOverlay False = glutRemoveOverlay
+setHasOverlay True  = glutEstablishOverlay
+
+foreign import CALLCONV safe "glutRemoveOverlay" glutRemoveOverlay :: IO ()
+
+foreign import CALLCONV safe "glutEstablishOverlay" glutEstablishOverlay :: IO ()
+
+getHasOverlay :: IO Bool
+getHasOverlay = layerGet (/= 0) glut_HAS_OVERLAY
+
+--------------------------------------------------------------------------------
+
+-- | Contains 'True' if an overlay could be established for the /current window/
+-- given the current /initial display mode/. If it contains 'False',
+-- 'setHasOverlay' will fail with a fatal error if called.
+
+overlayPossible :: GettableStateVar Bool
+overlayPossible = makeGettableStateVar $ layerGet (/= 0) glut_OVERLAY_POSSIBLE
+
+--------------------------------------------------------------------------------
+
+-- | Controls the visibility of the overlay of the /current window/.
+--
+-- The effect of showing or hiding an overlay takes place immediately. Note that
+-- setting 'overlayVisible' to 'True' will not actually display the overlay
+-- unless the window is also shown (and even a shown window may be obscured by
+-- other windows, thereby obscuring the overlay). It is typically faster and
+-- less resource intensive to use the routines below to control the display
+-- status of an overlay as opposed to removing and re-establishing the overlay.
+
+overlayVisible :: SettableStateVar Bool
+overlayVisible =
+   makeSettableStateVar $ \flag ->
+      if flag then glutShowOverlay else glutHideOverlay
+
+foreign import CALLCONV safe "glutShowOverlay" glutShowOverlay :: IO ()
+
+foreign import CALLCONV safe "glutHideOverlay" glutHideOverlay :: IO ()
+
+--------------------------------------------------------------------------------
+
+-- | The /layer in use/.
+data Layer
+   = Normal   -- ^ The normal plane.
+   | Overlay  -- ^ The overlay.
+   deriving ( Eq, Ord, Show )
+
+marshalLayer :: Layer -> GLenum
+marshalLayer x = case x of
+   Normal -> glut_NORMAL
+   Overlay -> glut_OVERLAY
+
+unmarshalLayer :: GLenum -> Layer
+unmarshalLayer x
+   | x == glut_NORMAL  = Normal
+   | x == glut_OVERLAY = Overlay
+   | otherwise = error ("unmarshalLayer: illegal value " ++ show x)
+
+--------------------------------------------------------------------------------
+
+-- | Controls the per-window /layer in use/ for the /current window/, which can
+-- either be the normal plane or the overlay. Selecting the overlay should only
+-- be done if an overlay exists, however windows without an overlay may still
+-- set the /layer in use/ to 'Normal'. OpenGL commands for the window are
+-- directed to the current /layer in use/.
+
+layerInUse :: StateVar Layer
+layerInUse =
+   makeStateVar getLayerInUse setLayerInUse
+
+setLayerInUse :: Layer -> IO ()
+setLayerInUse = glutUseLayer . marshalLayer
+
+foreign import CALLCONV safe "glutUseLayer" glutUseLayer :: GLenum -> IO ()
+
+getLayerInUse :: IO Layer
+getLayerInUse = layerGet (unmarshalLayer . fromIntegral) glut_LAYER_IN_USE
+
+--------------------------------------------------------------------------------
+
+-- | Mark the overlay of the given window (or the /current window/, if none is
+-- supplied) as needing to be redisplayed. The next iteration through
+-- 'Graphics.UI.GLUT.Begin.mainLoop', the window\'s overlay display callback
+-- (or simply the display callback if no overlay display callback is registered)
+-- will be called to redisplay the window\'s overlay plane. Multiple calls to
+-- 'postOverlayRedisplay' before the next display callback opportunity (or
+-- overlay display callback opportunity if one is registered) generate only a
+-- single redisplay. 'postOverlayRedisplay' may be called within a window\'s
+-- display or overlay display callback to re-mark that window for redisplay.
+--
+-- Logically, overlay damage notification for a window is treated as a
+-- 'postOverlayRedisplay' on the damaged window. Unlike damage reported by the
+-- window system, 'postOverlayRedisplay' will not set to true the overlay\'s
+-- damaged status (see 'Graphics.UI.GLUT.State.damaged').
+--
+-- Also, see 'Graphics.UI.GLUT.Window.postRedisplay'.
+
+postOverlayRedisplay :: Maybe Window -> IO ()
+postOverlayRedisplay =
+   maybe glutPostOverlayRedisplay glutPostWindowOverlayRedisplay
+
+foreign import CALLCONV safe "glutPostOverlayRedisplay"
+   glutPostOverlayRedisplay :: IO ()
+
+foreign import CALLCONV safe "glutPostWindowOverlayRedisplay"
+   glutPostWindowOverlayRedisplay :: Window -> IO ()
diff --git a/Graphics/UI/GLUT/QueryUtils.hs b/Graphics/UI/GLUT/QueryUtils.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/QueryUtils.hs
@@ -0,0 +1,46 @@
+-- #hide
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.QueryUtils
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- This is a purely internal module with utilities to query GLUT state.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.QueryUtils (
+  Getter, simpleGet, layerGet, deviceGet, glutSetOption
+) where
+
+import Foreign.C.Types ( CInt )
+import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
+import Graphics.UI.GLUT.Extensions
+
+--------------------------------------------------------------------------------
+
+#include "HsGLUTExt.h"
+
+--------------------------------------------------------------------------------
+
+type PrimGetter =                GLenum -> IO CInt
+type Getter a   = (CInt -> a) -> GLenum -> IO a
+
+makeGetter :: PrimGetter -> Getter a
+makeGetter g f = fmap f . g
+
+simpleGet, layerGet, deviceGet :: Getter a
+simpleGet = makeGetter glutGet
+layerGet  = makeGetter glutLayerGet
+deviceGet = makeGetter glutDeviceGet
+
+foreign import CALLCONV unsafe "glutGet"       glutGet       :: PrimGetter
+foreign import CALLCONV unsafe "glutLayerGet"  glutLayerGet  :: PrimGetter
+foreign import CALLCONV unsafe "glutDeviceGet" glutDeviceGet :: PrimGetter
+
+-- Not really a query function, but it's quite handy to have it here
+EXTENSION_ENTRY(unsafe,"freeglut",glutSetOption,GLenum -> CInt -> IO ())
diff --git a/Graphics/UI/GLUT/State.hs b/Graphics/UI/GLUT/State.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/State.hs
@@ -0,0 +1,350 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.State
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- GLUT maintains a considerable amount of programmer visible state. Some (but
+-- not all) of this state may be directly retrieved.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.State (
+  -- * State of all windows
+  windowBorderWidth, windowHeaderHeight,
+
+  -- * State of the /current window/
+  rgba,
+  BufferDepth, rgbaBufferDepths, colorBufferDepth,
+  doubleBuffered, stereo,
+  accumBufferDepths, depthBufferDepth, stencilBufferDepth,
+  SampleCount, sampleCount, formatID,
+
+  -- * GLUT state pertaining to the layers of the /current window/
+  damaged,
+
+  -- * Timing
+  elapsedTime,
+
+  -- * Device information
+
+  -- $DeviceInformation
+  screenSize, screenSizeMM,
+  hasKeyboard,
+  ButtonCount, numMouseButtons,
+  numSpaceballButtons,
+  DialCount, numDialsAndButtons,
+  numTabletButtons,
+  AxisCount, PollRate, joystickInfo,
+
+  -- * GLUT information
+ glutVersion
+) where
+
+import Foreign.C.Types ( CInt )
+import Foreign.Ptr ( nullFunPtr )
+import Graphics.Rendering.OpenGL.GL.BasicTypes ( GLenum )
+import Graphics.Rendering.OpenGL.GL.CoordTrans ( Size(..) )
+import Graphics.Rendering.OpenGL.GL.StateVar (
+   GettableStateVar, makeGettableStateVar )
+import Graphics.UI.GLUT.Constants (
+   glut_WINDOW_RGBA,
+   glut_WINDOW_RED_SIZE, glut_WINDOW_GREEN_SIZE, glut_WINDOW_BLUE_SIZE,
+   glut_WINDOW_ALPHA_SIZE, glut_WINDOW_BUFFER_SIZE,
+   glut_WINDOW_DOUBLEBUFFER, glut_WINDOW_STEREO,
+   glut_WINDOW_ACCUM_RED_SIZE, glut_WINDOW_ACCUM_GREEN_SIZE,
+   glut_WINDOW_ACCUM_BLUE_SIZE, glut_WINDOW_ACCUM_ALPHA_SIZE,
+   glut_WINDOW_DEPTH_SIZE, glut_WINDOW_STENCIL_SIZE, glut_WINDOW_NUM_SAMPLES,
+   glut_WINDOW_FORMAT_ID, glut_ELAPSED_TIME,
+   glut_NORMAL_DAMAGED, glut_OVERLAY_DAMAGED,
+   glut_SCREEN_WIDTH, glut_SCREEN_HEIGHT,
+   glut_SCREEN_WIDTH_MM, glut_SCREEN_HEIGHT_MM,
+   glut_HAS_KEYBOARD,
+   glut_HAS_MOUSE, glut_NUM_MOUSE_BUTTONS,
+   glut_HAS_SPACEBALL, glut_NUM_SPACEBALL_BUTTONS,
+   glut_HAS_DIAL_AND_BUTTON_BOX, glut_NUM_DIALS, glut_NUM_BUTTON_BOX_BUTTONS,
+   glut_HAS_TABLET, glut_NUM_TABLET_BUTTONS,
+   glut_HAS_JOYSTICK, glut_JOYSTICK_BUTTONS, glut_JOYSTICK_POLL_RATE,
+   glut_JOYSTICK_AXES,
+   glut_VERSION, glut_WINDOW_BORDER_WIDTH, glut_WINDOW_HEADER_HEIGHT )
+
+import Graphics.UI.GLUT.Overlay ( Layer(..) )
+import Graphics.UI.GLUT.QueryUtils ( simpleGet, layerGet, deviceGet )
+import Graphics.UI.GLUT.Extensions ( getProcAddressInternal )
+
+--------------------------------------------------------------------------------
+
+-- | Contains 'True' when the current layer of the /current window/ is in RGBA
+-- mode, 'False' means color index mode.
+
+rgba :: GettableStateVar Bool
+rgba = makeGettableStateVar$ simpleGet i2b glut_WINDOW_RGBA
+
+-- | Bit depth of a buffer
+
+type BufferDepth = Int
+
+-- | Contains the number of red, green, blue, and alpha bits in the color buffer
+-- of the /current window\'s/ current layer (0 in color index mode).
+
+rgbaBufferDepths ::
+   GettableStateVar (BufferDepth, BufferDepth, BufferDepth, BufferDepth)
+rgbaBufferDepths = makeGettableStateVar $ do
+   r <- simpleGet fromIntegral glut_WINDOW_RED_SIZE
+   g <- simpleGet fromIntegral glut_WINDOW_GREEN_SIZE
+   b <- simpleGet fromIntegral glut_WINDOW_BLUE_SIZE
+   a <- simpleGet fromIntegral glut_WINDOW_ALPHA_SIZE
+   return (r, g, b, a)
+
+-- | Contains the total number of bits in the color buffer of the /current
+-- window\'s/ current layer. For an RGBA layer, this is the sum of the red,
+-- green, blue, and alpha bits. For an color index layer, this is the number
+-- of bits of the color indexes.
+
+colorBufferDepth :: GettableStateVar BufferDepth
+colorBufferDepth =
+   makeGettableStateVar $ simpleGet fromIntegral glut_WINDOW_BUFFER_SIZE
+
+-- | Contains 'True' when the current layer of the /current window/ is double
+-- buffered, 'False' otherwise.
+
+doubleBuffered :: GettableStateVar Bool
+doubleBuffered = makeGettableStateVar $ simpleGet i2b glut_WINDOW_DOUBLEBUFFER
+
+-- | Contains 'True' when the current layer of the /current window/ is stereo,
+-- 'False' otherwise.
+
+stereo :: GettableStateVar Bool
+stereo = makeGettableStateVar $ simpleGet i2b glut_WINDOW_STEREO
+
+-- | Contains the number of red, green, blue, and alpha bits in the accumulation
+-- buffer of the /current window\'s/ current layer (0 in color index mode).
+
+accumBufferDepths ::
+   GettableStateVar (BufferDepth, BufferDepth, BufferDepth, BufferDepth)
+accumBufferDepths = makeGettableStateVar $ do
+   r <- simpleGet fromIntegral glut_WINDOW_ACCUM_RED_SIZE
+   g <- simpleGet fromIntegral glut_WINDOW_ACCUM_GREEN_SIZE
+   b <- simpleGet fromIntegral glut_WINDOW_ACCUM_BLUE_SIZE
+   a <- simpleGet fromIntegral glut_WINDOW_ACCUM_ALPHA_SIZE
+   return (r, g, b, a)
+
+-- | Contains the number of bits in the depth buffer of the /current window\'s/
+-- current layer.
+
+depthBufferDepth :: GettableStateVar BufferDepth
+depthBufferDepth =
+   makeGettableStateVar $ simpleGet fromIntegral glut_WINDOW_DEPTH_SIZE
+
+-- | Contains the number of bits in the stencil buffer of the /current
+-- window\'s/ current layer.
+
+stencilBufferDepth :: GettableStateVar BufferDepth
+stencilBufferDepth =
+   makeGettableStateVar $ simpleGet fromIntegral glut_WINDOW_STENCIL_SIZE
+
+-- | Number of samples for multisampling
+
+type SampleCount = Int
+
+-- | Contains the number of samples for multisampling for the /current window./
+
+sampleCount :: GettableStateVar SampleCount
+sampleCount =
+   makeGettableStateVar $ simpleGet fromIntegral glut_WINDOW_NUM_SAMPLES
+
+-- | Contains the window system dependent format ID for the current layer of the
+-- /current window/. On X11 GLUT implementations, this is the X visual ID. On
+-- Win32 GLUT implementations, this is the Win32 Pixel Format Descriptor number.
+-- This value is returned for debugging, benchmarking, and testing ease.
+
+formatID :: GettableStateVar Int
+formatID = makeGettableStateVar $ simpleGet fromIntegral glut_WINDOW_FORMAT_ID
+
+--------------------------------------------------------------------------------
+
+-- | Contains the number of milliseconds since
+-- 'Graphics.UI.GLUT.Initialization.initialize' was called.
+
+elapsedTime :: GettableStateVar Int
+elapsedTime = makeGettableStateVar $ simpleGet fromIntegral glut_ELAPSED_TIME
+
+--------------------------------------------------------------------------------
+
+-- | Contains 'True' if the given plane of the /current window/ has been
+-- damaged (by window system activity) since the last display callback was
+-- triggered. Calling 'Graphics.UI.GLUT.Window.postRedisplay' or
+-- 'Graphics.UI.GLUT.Overlay.postOverlayRedisplay' will not set this 'True'.
+
+damaged :: Layer -> GettableStateVar Bool
+damaged l = makeGettableStateVar $ layerGet isDamaged (marshalDamagedLayer l)
+   where isDamaged d = d /= 0 && d /= -1
+         marshalDamagedLayer x = case x of
+            Normal -> glut_NORMAL_DAMAGED
+            Overlay -> glut_OVERLAY_DAMAGED
+
+--------------------------------------------------------------------------------
+
+-- $DeviceInformation
+-- If a device is not available, the following state variables contain
+-- 'Nothing', otherwise they return 'Just' the specific device information.
+-- Only a screen is always assumed.
+
+--------------------------------------------------------------------------------
+
+-- | The size of the screen in pixels.
+
+screenSize :: GettableStateVar Size
+screenSize =
+   makeGettableStateVar $ do
+      wpx <- simpleGet fromIntegral glut_SCREEN_WIDTH
+      hpx <- simpleGet fromIntegral glut_SCREEN_HEIGHT
+      return $ Size wpx hpx
+
+-- | The size of the screen in millimeters.
+
+screenSizeMM :: GettableStateVar Size
+screenSizeMM =
+   makeGettableStateVar $ do
+      wmm <- simpleGet fromIntegral glut_SCREEN_WIDTH_MM
+      hmm <- simpleGet fromIntegral glut_SCREEN_HEIGHT_MM
+      return $ Size wmm hmm
+
+--------------------------------------------------------------------------------
+
+-- | Contains 'True' if a keyboard is present, 'False' otherwise.
+
+hasKeyboard :: GettableStateVar Bool
+hasKeyboard = makeGettableStateVar $ deviceGet i2b glut_HAS_KEYBOARD
+
+--------------------------------------------------------------------------------
+
+-- | Number of buttons of an input device
+
+type ButtonCount = Int
+
+-- | Contains 'Just' the number of buttons of an attached mouse or 'Nothing' if
+-- there is none.
+
+numMouseButtons :: GettableStateVar (Maybe ButtonCount)
+numMouseButtons =
+   getDeviceInfo glut_HAS_MOUSE $
+      deviceGet fromIntegral glut_NUM_MOUSE_BUTTONS
+
+--------------------------------------------------------------------------------
+
+-- | Contains 'Just' the number of buttons of the attached Spaceball or 'Nothing'
+-- if there is none.
+
+numSpaceballButtons :: GettableStateVar (Maybe ButtonCount)
+numSpaceballButtons =
+   getDeviceInfo glut_HAS_SPACEBALL $
+      deviceGet fromIntegral glut_NUM_SPACEBALL_BUTTONS
+
+--------------------------------------------------------------------------------
+
+-- | Number of dials of a dial and button box
+
+type DialCount = Int
+
+-- | Contains 'Just' the number of dials and buttons of an attached dial &
+-- button box or 'Nothing' if there is none.
+
+numDialsAndButtons :: GettableStateVar (Maybe (DialCount, ButtonCount))
+numDialsAndButtons =
+   getDeviceInfo glut_HAS_DIAL_AND_BUTTON_BOX $ do
+      d <- deviceGet fromIntegral glut_NUM_DIALS
+      b <- deviceGet fromIntegral glut_NUM_BUTTON_BOX_BUTTONS
+      return (d, b)
+
+--------------------------------------------------------------------------------
+
+-- | Contains 'Just' the number of buttons of an attached tablet or 'Nothing' if
+-- there is none.
+
+numTabletButtons :: GettableStateVar (Maybe ButtonCount)
+numTabletButtons =
+   getDeviceInfo glut_HAS_TABLET $
+      deviceGet fromIntegral glut_NUM_TABLET_BUTTONS
+
+--------------------------------------------------------------------------------
+
+-- | Number of axes of a joystick
+
+type AxisCount = Int
+
+-- | The a rate at which a joystick is polled (in milliseconds)
+
+type PollRate = Int
+
+-- | Contains 'Just' the number of buttons of an attached joystick, the number
+-- of joystick axes, and the rate at which the joystick is polled. Contains
+-- 'Nothing' if there is no joystick attached.
+
+joystickInfo :: GettableStateVar (Maybe (ButtonCount, PollRate, AxisCount))
+joystickInfo =
+   getDeviceInfo glut_HAS_JOYSTICK $ do
+      b <- deviceGet fromIntegral glut_JOYSTICK_BUTTONS
+      a <- deviceGet fromIntegral glut_JOYSTICK_AXES
+      r <- deviceGet fromIntegral glut_JOYSTICK_POLL_RATE
+      return (b, a, r)
+
+--------------------------------------------------------------------------------
+-- Convenience unmarshalers
+
+i2b :: CInt -> Bool
+i2b = (/= 0)
+
+--------------------------------------------------------------------------------
+
+getDeviceInfo :: GLenum -> IO a -> GettableStateVar (Maybe a)
+getDeviceInfo dev act =
+   makeGettableStateVar $ do
+      hasDevice <- deviceGet i2b dev
+      if hasDevice then fmap Just act else return Nothing
+
+-----------------------------------------------------------------------------
+
+-- | Contains version of GLUT in the form of
+-- @/flavour/ /major/./minor/./patchlevel/@, where @/flavour/@ is one of
+-- @GLUT@, @freeglut@ or @OpenGLUT@.
+
+glutVersion :: GettableStateVar String
+glutVersion = makeGettableStateVar $ do
+   let isGLUT = isUnknown "glutSetOption"
+       isFreeglut = isUnknown "glutSetWindowStayOnTop"
+       isUnknown = fmap (== nullFunPtr) . getProcAddressInternal
+       showVersionPart x = shows (x `mod` 100)
+       showVersion v = showVersionPart (v `div` 10000) . showChar '.' .
+                       showVersionPart (v `div`   100) . showChar '.' .
+                       showVersionPart  v
+   g <- isGLUT
+   if g
+      then return "GLUT 3.7"   -- ToDo: just guessing
+      else do f <- isFreeglut
+              v <- simpleGet id glut_VERSION
+              let prefix = if f then "freeglut" else "OpenGLUT"
+              return $ showString prefix . showChar ' ' . showVersion v $ ""
+
+-----------------------------------------------------------------------------
+
+-- | (/freeglut only/) Contains the thickness of the sizing border around the
+-- perimeter of a window that can be resized, in pixels.
+
+windowBorderWidth :: GettableStateVar Int
+windowBorderWidth =
+   makeGettableStateVar (simpleGet fromIntegral glut_WINDOW_BORDER_WIDTH)
+
+-----------------------------------------------------------------------------
+
+-- | (/freeglut only/) Contains the height of the header\/caption area of a
+-- window in pixels.
+
+windowHeaderHeight :: GettableStateVar Int
+windowHeaderHeight =
+   makeGettableStateVar (simpleGet fromIntegral glut_WINDOW_HEADER_HEIGHT)
+
diff --git a/Graphics/UI/GLUT/Types.hs b/Graphics/UI/GLUT/Types.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Types.hs
@@ -0,0 +1,102 @@
+-- #hide
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Types
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- This is a purely internal module with miscellaneous types which don\'t really
+-- have a good place elsewhere.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Types (
+   Window,                                   -- constructor used only internally
+   makeWindow,                               -- used only internally
+   Relation(..),
+   relationToString,                         -- used only internally
+   MouseButton(..),
+   marshalMouseButton, unmarshalMouseButton  -- used only internally
+) where
+
+import Foreign.C.Types ( CInt )
+import Graphics.UI.GLUT.Constants (
+   glut_LEFT_BUTTON, glut_MIDDLE_BUTTON, glut_RIGHT_BUTTON,
+   glut_WHEEL_UP, glut_WHEEL_DOWN )
+
+--------------------------------------------------------------------------------
+
+-- | An opaque identifier for a top-level window or a subwindow.
+
+newtype Window = Window CInt
+   deriving ( Eq, Ord, Show )
+
+makeWindow :: CInt -> Window
+makeWindow = Window
+
+--------------------------------------------------------------------------------
+
+-- | A relation between a 'Graphics.UI.GLUT.Initialization.DisplayCapability'
+-- and a numeric value.
+
+data Relation
+   = IsEqualTo        -- ^ Equal.
+   | IsNotEqualTo     -- ^ Not equal.
+   | IsLessThan       -- ^ Less than and preferring larger difference (the least
+                      --   is best).
+   | IsNotGreaterThan -- ^ Less than or equal and preferring larger difference
+                      --   (the least is best).
+   | IsGreaterThan    -- ^ Greater than and preferring larger differences (the
+                      --   most is best).
+   | IsAtLeast        -- ^ Greater than or equal and preferring more instead of
+                      --   less. This relation is useful for allocating
+                      --   resources like color precision or depth buffer
+                      --   precision where the maximum precision is generally
+                      --   preferred. Contrast with 'IsNotLessThan' relation.
+   | IsNotLessThan    -- ^ Greater than or equal but preferring less instead of
+                      --   more. This relation is useful for allocating
+                      --   resources such as stencil bits or auxillary color
+                      --   buffers where you would rather not over-allocate.
+   deriving ( Eq, Ord, Show )
+
+relationToString :: Relation -> String
+relationToString IsEqualTo        = "="
+relationToString IsNotEqualTo     = "!="
+relationToString IsLessThan       = "<"
+relationToString IsNotGreaterThan = "<="
+relationToString IsGreaterThan    = ">"
+relationToString IsAtLeast        = ">="
+relationToString IsNotLessThan    = "~"
+
+--------------------------------------------------------------------------------
+
+-- | Mouse buttons, including a wheel
+
+data MouseButton
+   = LeftButton
+   | MiddleButton
+   | RightButton
+   | WheelUp
+   | WheelDown
+   deriving ( Eq, Ord, Show )
+
+marshalMouseButton :: MouseButton -> CInt
+marshalMouseButton x = case x of
+   LeftButton -> glut_LEFT_BUTTON
+   MiddleButton -> glut_MIDDLE_BUTTON
+   RightButton -> glut_RIGHT_BUTTON
+   WheelUp ->glut_WHEEL_UP
+   WheelDown -> glut_WHEEL_DOWN
+
+unmarshalMouseButton :: CInt -> MouseButton
+unmarshalMouseButton x
+   | x == glut_LEFT_BUTTON = LeftButton
+   | x == glut_MIDDLE_BUTTON = MiddleButton
+   | x == glut_RIGHT_BUTTON = RightButton
+   | x == glut_WHEEL_UP = WheelUp
+   | x == glut_WHEEL_DOWN = WheelDown
+   | otherwise = error ("unmarshalMouseButton: illegal value " ++ show x)
diff --git a/Graphics/UI/GLUT/Window.hs b/Graphics/UI/GLUT/Window.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/UI/GLUT/Window.hs
@@ -0,0 +1,530 @@
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.UI.GLUT.Window
+-- Copyright   :  (c) Sven Panne 2002-2005
+-- License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- GLUT supports two types of windows: top-level windows and subwindows. Both
+-- types support OpenGL rendering and GLUT callbacks. There is a single
+-- identifier space for both types of windows.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.UI.GLUT.Window (
+   -- * Window identifiers
+   Window,
+
+   -- * Creating and destroying (sub-)windows
+
+   -- $CreatingAndDestroyingSubWindows
+   createWindow, createSubWindow, destroyWindow,
+   parentWindow, numSubWindows,
+
+   -- * Manipulating the /current window/
+   currentWindow,
+
+   -- * Re-displaying and double buffer management
+   postRedisplay, swapBuffers,
+
+   -- * Changing the window geometry
+
+   -- $ChangingTheWindowGeometry
+   windowPosition, windowSize, fullScreen,
+
+   -- * Manipulating the stacking order
+
+   -- $ManipulatingTheStackingOrder
+   pushWindow, popWindow,
+
+   -- * Managing a window\'s display status
+   WindowStatus(..), windowStatus,
+
+   -- * Changing the window\/icon title
+
+   -- $ChangingTheWindowIconTitle
+   windowTitle, iconTitle,
+
+   -- * Cursor management
+   Cursor(..), cursor, pointerPosition
+) where
+
+import Foreign.C.String ( CString, withCString )
+import Foreign.C.Types ( CInt )
+import Graphics.Rendering.OpenGL.GL.CoordTrans ( Position(..), Size(..) )
+import Graphics.Rendering.OpenGL.GL.StateVar (
+   GettableStateVar, makeGettableStateVar,
+   SettableStateVar, makeSettableStateVar,
+   StateVar, makeStateVar )
+import Graphics.UI.GLUT.Constants (
+   glut_WINDOW_PARENT, glut_WINDOW_NUM_CHILDREN,
+   glut_WINDOW_X, glut_WINDOW_Y, glut_WINDOW_WIDTH, glut_WINDOW_HEIGHT,
+   glut_CURSOR_RIGHT_ARROW, glut_CURSOR_LEFT_ARROW, glut_CURSOR_INFO,
+   glut_CURSOR_DESTROY, glut_CURSOR_HELP, glut_CURSOR_CYCLE, glut_CURSOR_SPRAY,
+   glut_CURSOR_WAIT, glut_CURSOR_TEXT, glut_CURSOR_CROSSHAIR,
+   glut_CURSOR_UP_DOWN, glut_CURSOR_LEFT_RIGHT, glut_CURSOR_TOP_SIDE,
+   glut_CURSOR_BOTTOM_SIDE, glut_CURSOR_LEFT_SIDE, glut_CURSOR_RIGHT_SIDE,
+   glut_CURSOR_TOP_LEFT_CORNER, glut_CURSOR_TOP_RIGHT_CORNER,
+   glut_CURSOR_BOTTOM_RIGHT_CORNER, glut_CURSOR_BOTTOM_LEFT_CORNER,
+   glut_CURSOR_INHERIT, glut_CURSOR_NONE, glut_CURSOR_FULL_CROSSHAIR,
+   glut_WINDOW_CURSOR )
+import Graphics.UI.GLUT.QueryUtils ( simpleGet )
+import Graphics.UI.GLUT.Types ( Window, makeWindow )
+
+--------------------------------------------------------------------------------
+
+-- $CreatingAndDestroyingSubWindows
+-- Each created window has a unique associated OpenGL context. State changes to
+-- a window\'s associated OpenGL context can be done immediately after the
+-- window is created.
+--
+-- The /display state/ of a window is initially for the window to be shown. But
+-- the window\'s /display state/ is not actually acted upon until
+-- 'Graphics.UI.GLUT.Begin.mainLoop' is entered. This means until
+-- 'Graphics.UI.GLUT.Begin.mainLoop' is called, rendering to a created window is
+-- ineffective because the window can not yet be displayed.
+--
+-- The value returned by 'createWindow' and 'createSubWindow' is a unique
+-- identifier for the window, which can be used with 'currentWindow'.
+
+-- | Create a top-level window. The given name will be provided to the window
+-- system as the window\'s name. The intent is that the window system will label
+-- the window with the name.Implicitly, the /current window/ is set to the newly
+-- created window.
+--
+-- /X Implementation Notes:/ The proper X Inter-Client Communication Conventions
+-- Manual (ICCCM) top-level properties are established. The @WM_COMMAND@
+-- property that lists the command line used to invoke the GLUT program is only
+-- established for the first window created.
+
+createWindow
+   :: String    -- ^ The window name
+   -> IO Window -- ^ The identifier for the newly created window
+createWindow name = withCString name glutCreateWindow
+
+foreign import CALLCONV unsafe "glutCreateWindow" glutCreateWindow ::
+      CString -> IO Window
+
+--------------------------------------------------------------------------------
+
+-- | Create a subwindow of the identified window with the given relative
+-- position and size. Implicitly, the /current window/ is set to the
+-- newly created subwindow. Subwindows can be nested arbitrarily deep.
+
+createSubWindow
+   :: Window    -- ^ Identifier of the subwindow\'s parent window.
+   -> Position  -- ^ Window position in pixels relative to parent window\'s
+                --   origin.
+   -> Size      -- ^ Window size in pixels
+   -> IO Window -- ^ The identifier for the newly created subwindow
+createSubWindow win (Position x y) (Size w h) =
+   glutCreateSubWindow win
+                       (fromIntegral x) (fromIntegral y)
+                       (fromIntegral w) (fromIntegral h)
+
+foreign import CALLCONV unsafe "glutCreateSubWindow" glutCreateSubWindow ::
+      Window -> CInt -> CInt -> CInt -> CInt -> IO Window
+
+--------------------------------------------------------------------------------
+
+-- | Contains the /current window\'s/ parent. If the /current window/ is a
+-- top-level window, 'Nothing' is returned.
+
+parentWindow :: GettableStateVar (Maybe Window)
+parentWindow =
+   makeGettableStateVar $
+      getWindow (simpleGet makeWindow glut_WINDOW_PARENT)
+
+--------------------------------------------------------------------------------
+
+-- | Contains the number of subwindows the /current window/ has, not counting
+-- children of children.
+
+numSubWindows :: GettableStateVar Int
+numSubWindows =
+   makeGettableStateVar $
+      simpleGet fromIntegral glut_WINDOW_NUM_CHILDREN
+
+--------------------------------------------------------------------------------
+
+-- | Destroy the specified window and the window\'s associated OpenGL context,
+-- logical colormap (if the window is color index), and overlay and related
+-- state (if an overlay has been established). Any subwindows of the destroyed
+-- window are also destroyed by 'destroyWindow'. If the specified window was the
+-- /current window/, the /current window/ becomes invalid ('currentWindow' will
+-- contain 'Nothing').
+
+foreign import CALLCONV unsafe "glutDestroyWindow" destroyWindow ::
+   Window -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Controls the /current window/. It does /not/ affect the /layer in use/ for
+-- the window; this is done using 'Graphics.UI.GLUT.Overlay.layerInUse'.
+-- Contains 'Nothing' if no windows exist or the previously /current window/ was
+-- destroyed. Setting the /current window/ to 'Nothing' is a no-op.
+
+currentWindow :: StateVar (Maybe Window)
+currentWindow =
+   makeStateVar (getWindow glutGetWindow) (maybe (return ()) glutSetWindow)
+
+getWindow :: IO Window -> IO (Maybe Window)
+getWindow act = do
+   win <- act
+   return $ if win == makeWindow 0 then Nothing else Just win
+
+foreign import CALLCONV unsafe "glutSetWindow" glutSetWindow :: Window -> IO ()
+
+foreign import CALLCONV unsafe "glutGetWindow" glutGetWindow :: IO Window
+
+--------------------------------------------------------------------------------
+
+-- | Mark the normal plane of given window (or the /current window/, if none
+-- is supplied) as needing to be redisplayed. The next iteration through
+-- 'Graphics.UI.GLUT.Begin.mainLoop', the window\'s display callback will be
+-- called to redisplay the window\'s normal plane. Multiple calls to
+-- 'postRedisplay' before the next display callback opportunity generates only a
+-- single redisplay callback. 'postRedisplay' may be called within a window\'s
+-- display or overlay display callback to re-mark that window for redisplay.
+--
+-- Logically, normal plane damage notification for a window is treated as a
+-- 'postRedisplay' on the damaged window. Unlike damage reported by the window
+-- system, 'postRedisplay' will /not/ set to true the normal plane\'s damaged
+-- status (see 'Graphics.UI.GLUT.State.damaged').
+--
+-- Also, see 'Graphics.UI.GLUT.Overlay.postOverlayRedisplay'.
+
+postRedisplay :: Maybe Window -> IO ()
+postRedisplay = maybe glutPostRedisplay glutPostWindowRedisplay
+
+foreign import CALLCONV unsafe "glutPostRedisplay" glutPostRedisplay :: IO ()
+
+-- | Mark the normal plane of the given window as needing to be redisplayed,
+-- otherwise the same as 'postRedisplay'.
+--
+-- The advantage of this routine is that it saves the cost of using
+-- 'currentWindow' (entailing an expensive OpenGL context switch), which is
+-- particularly useful when multiple windows need redisplays posted at the same
+-- time. 
+
+foreign import CALLCONV unsafe "glutPostWindowRedisplay"
+   glutPostWindowRedisplay :: Window -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | Perform a buffer swap on the /layer in use/ for the /current window/.
+-- Specifically, 'swapBuffers' promotes the contents of the back buffer of the
+-- /layer in use/ of the /current window/ to become the contents of the front
+-- buffer. The contents of the back buffer then become undefined. The update
+-- typically takes place during the vertical retrace of the monitor, rather than
+-- immediately after 'swapBuffers' is called.
+--
+-- An implicit 'Graphics.Rendering.OpenGL.GL.FlushFinish.flush' is done by
+-- 'swapBuffers' before it returns. Subsequent OpenGL commands can be issued
+-- immediately after calling 'swapBuffers', but are not executed until the
+-- buffer exchange is completed.
+--
+-- If the /layer in use/ is not double buffered, 'swapBuffers' has no effect.
+
+foreign import CALLCONV unsafe "glutSwapBuffers" swapBuffers :: IO ()
+
+--------------------------------------------------------------------------------
+
+-- $ChangingTheWindowGeometry
+-- Note that the requests by 'windowPosition', 'windowSize', and 'fullScreen'
+-- are not processed immediately. A request is executed after returning to the
+-- main event loop. This allows multiple requests to the same window to be
+-- coalesced.
+--
+-- 'windowPosition' and 'windowSize' requests on a window will disable the full
+-- screen status of the window.
+
+--------------------------------------------------------------------------------
+
+-- | Controls the position of the /current window/. For top-level windows,
+-- parameters of 'Position' are pixel offsets from the screen origin. For
+-- subwindows, the parameters are pixel offsets from the window\'s parent window
+-- origin.
+--
+-- In the case of top-level windows, setting 'windowPosition' is considered only
+-- a request for positioning the window. The window system is free to apply its
+-- own policies to top-level window placement. The intent is that top-level
+-- windows should be repositioned according to the value of 'windowPosition'.
+
+windowPosition :: StateVar Position
+windowPosition = makeStateVar getWindowPosition setWindowPosition
+
+setWindowPosition :: Position -> IO ()
+setWindowPosition (Position x y) =
+   glutPositionWindow (fromIntegral x) (fromIntegral y)
+
+foreign import CALLCONV unsafe "glutPositionWindow" glutPositionWindow ::
+   CInt -> CInt -> IO ()
+
+getWindowPosition :: IO Position
+getWindowPosition = do
+   x <- simpleGet fromIntegral glut_WINDOW_X
+   y <- simpleGet fromIntegral glut_WINDOW_Y
+   return $ Position x y
+
+--------------------------------------------------------------------------------
+
+-- | Controls the size of the /current window/. The parameters of 'Size' are
+-- size extents in pixels. The width and height must be positive values.
+--
+-- In the case of top-level windows, setting 'windowSize' is considered only a
+-- request for sizing the window. The window system is free to apply its own
+-- policies to top-level window sizing. The intent is that top-level windows
+-- should be reshaped according to the value of 'windowSize'. Whether a reshape
+-- actually takes effect and, if so, the reshaped dimensions are reported to the
+-- program by a reshape callback.
+
+windowSize :: StateVar Size
+windowSize = makeStateVar getWindowSize setWindowSize
+
+setWindowSize :: Size -> IO ()
+setWindowSize (Size w h) =
+   glutReshapeWindow (fromIntegral w) (fromIntegral h)
+
+foreign import CALLCONV unsafe "glutReshapeWindow" glutReshapeWindow ::
+   CInt -> CInt -> IO ()
+
+getWindowSize :: IO Size
+getWindowSize = do
+   w <- simpleGet fromIntegral glut_WINDOW_WIDTH
+   h <- simpleGet fromIntegral glut_WINDOW_HEIGHT
+   return $ Size w h
+
+--------------------------------------------------------------------------------
+
+-- | Request that the /current window/ be made full screen. The exact semantics
+-- of what full screen means may vary by window system. The intent is to make
+-- the window as large as possible and disable any window decorations or borders
+-- added the window system. The window width and height are not guaranteed to be
+-- the same as the screen width and height, but that is the intent of making a
+-- window full screen.
+--
+-- 'fullScreen' is defined to work only on top-level windows.
+--
+-- /X Implementation Notes:/ In the X implementation of GLUT, full screen is
+-- implemented by sizing and positioning the window to cover the entire screen
+-- and posting the @_MOTIF_WM_HINTS@ property on the window requesting
+-- absolutely no decorations. Non-Motif window managers may not respond to
+-- @_MOTIF_WM_HINTS@.
+
+foreign import CALLCONV unsafe "glutFullScreen" fullScreen :: IO ()
+
+--------------------------------------------------------------------------------
+
+-- $ManipulatingTheStackingOrder
+-- 'pushWindow' and 'popWindow' work on both top-level windows and subwindows.
+-- The effect of pushing and popping windows does not take place immediately.
+-- Instead the push or pop is saved for execution upon return to the GLUT event
+-- loop. Subsequent pop or push requests on a window replace the previously
+-- saved request for that window. The effect of pushing and popping top-level
+-- windows is subject to the window system\'s policy for restacking windows.
+
+-- | Change the stacking order of the /current window/ relative to its siblings
+-- (lowering it).
+
+foreign import CALLCONV unsafe "glutPushWindow" pushWindow :: IO ()
+
+-- | Change the stacking order of the /current window/ relative to its siblings,
+-- bringing the /current window/ closer to the top.
+
+foreign import CALLCONV unsafe "glutPopWindow" popWindow :: IO ()
+
+--------------------------------------------------------------------------------
+
+-- | The display status of a window.
+
+data WindowStatus
+   = Shown
+   | Hidden
+   | Iconified
+   deriving ( Eq, Ord, Show )
+
+-- | Controls the display status of the /current window/.
+--
+-- Note that the effect of showing, hiding, and iconifying windows does not take
+-- place immediately. Instead the requests are saved for execution upon return
+-- to the GLUT event loop. Subsequent show, hide, or iconification requests on a
+-- window replace the previously saved request for that window. The effect of
+-- hiding, showing, or iconifying top-level windows is subject to the window
+-- system\'s policy for displaying windows. Subwindows can\'t be iconified.
+
+windowStatus :: SettableStateVar WindowStatus
+windowStatus = makeSettableStateVar setStatus
+   where setStatus Shown     = glutShowWindow
+         setStatus Hidden    = glutHideWindow
+         setStatus Iconified = glutIconifyWindow
+
+foreign import CALLCONV unsafe "glutShowWindow" glutShowWindow :: IO ()
+
+foreign import CALLCONV unsafe "glutHideWindow" glutHideWindow :: IO ()
+
+foreign import CALLCONV unsafe "glutIconifyWindow" glutIconifyWindow :: IO ()
+
+--------------------------------------------------------------------------------
+
+-- $ChangingTheWindowIconTitle
+-- 'windowTitle' and 'iconTitle' should be set only when the /current
+-- window/ is a top-level window. Upon creation of a top-level window, the
+-- window and icon names are determined by the name given to 'createWindow'.
+-- Once created, setting 'windowTitle' and 'iconTitle' can change the window and
+-- icon names respectively of top-level windows. Each call requests the window
+-- system change the title appropriately. Requests are not buffered or
+-- coalesced. The policy by which the window and icon name are displayed is
+-- window system dependent.
+
+-- | Controls the window title of the /current top-level window/.
+
+windowTitle :: SettableStateVar String
+windowTitle =
+   makeSettableStateVar $ \name ->
+      withCString name glutSetWindowTitle
+
+foreign import CALLCONV unsafe "glutSetWindowTitle" glutSetWindowTitle ::
+      CString -> IO ()
+
+-- | Controls the icon title of the /current top-level window/.
+
+iconTitle :: SettableStateVar String
+iconTitle =
+   makeSettableStateVar $ \name ->
+      withCString name glutSetIconTitle
+
+foreign import CALLCONV unsafe "glutSetIconTitle" glutSetIconTitle ::
+      CString -> IO ()
+
+--------------------------------------------------------------------------------
+
+-- | The different cursor images GLUT supports.
+
+data Cursor
+   = RightArrow        -- ^ Arrow pointing up and to the right.
+   | LeftArrow         -- ^ Arrow pointing up and to the left.
+   | Info              -- ^ Pointing hand.
+   | Destroy           -- ^ Skull & cross bones.
+   | Help              -- ^ Question mark.
+   | Cycle             -- ^ Arrows rotating in a circle.
+   | Spray             -- ^ Spray can.
+   | Wait              -- ^ Wrist watch.
+   | Text              -- ^ Insertion point cursor for text.
+   | Crosshair         -- ^ Simple cross-hair.
+   | UpDown            -- ^ Bi-directional pointing up & down.
+   | LeftRight         -- ^ Bi-directional pointing left & right.
+   | TopSide           -- ^ Arrow pointing to top side.
+   | BottomSide        -- ^ Arrow pointing to bottom side.
+   | LeftSide          -- ^ Arrow pointing to left side.
+   | RightSide         -- ^ Arrow pointing to right side.
+   | TopLeftCorner     -- ^ Arrow pointing to top-left corner.
+   | TopRightCorner    -- ^ Arrow pointing to top-right corner.
+   | BottomRightCorner -- ^ Arrow pointing to bottom-left corner.
+   | BottomLeftCorner  -- ^ Arrow pointing to bottom-right corner.
+   | Inherit           -- ^ Use parent\'s cursor.
+   | None              -- ^ Invisible cursor.
+   | FullCrosshair     -- ^ Full-screen cross-hair cursor (if possible, otherwise 'Crosshair').
+   deriving ( Eq, Ord, Show )
+
+marshalCursor :: Cursor -> CInt
+marshalCursor x = case x of
+   RightArrow -> glut_CURSOR_RIGHT_ARROW
+   LeftArrow -> glut_CURSOR_LEFT_ARROW
+   Info -> glut_CURSOR_INFO
+   Destroy -> glut_CURSOR_DESTROY
+   Help -> glut_CURSOR_HELP
+   Cycle -> glut_CURSOR_CYCLE
+   Spray -> glut_CURSOR_SPRAY
+   Wait -> glut_CURSOR_WAIT
+   Text -> glut_CURSOR_TEXT
+   Crosshair -> glut_CURSOR_CROSSHAIR
+   UpDown -> glut_CURSOR_UP_DOWN
+   LeftRight -> glut_CURSOR_LEFT_RIGHT
+   TopSide -> glut_CURSOR_TOP_SIDE
+   BottomSide -> glut_CURSOR_BOTTOM_SIDE
+   LeftSide -> glut_CURSOR_LEFT_SIDE
+   RightSide -> glut_CURSOR_RIGHT_SIDE
+   TopLeftCorner -> glut_CURSOR_TOP_LEFT_CORNER
+   TopRightCorner -> glut_CURSOR_TOP_RIGHT_CORNER
+   BottomRightCorner -> glut_CURSOR_BOTTOM_RIGHT_CORNER
+   BottomLeftCorner -> glut_CURSOR_BOTTOM_LEFT_CORNER
+   Inherit -> glut_CURSOR_INHERIT
+   None -> glut_CURSOR_NONE
+   FullCrosshair -> glut_CURSOR_FULL_CROSSHAIR
+
+unmarshalCursor :: CInt -> Cursor
+unmarshalCursor x
+   | x == glut_CURSOR_RIGHT_ARROW = RightArrow
+   | x == glut_CURSOR_LEFT_ARROW = LeftArrow
+   | x == glut_CURSOR_INFO = Info
+   | x == glut_CURSOR_DESTROY = Destroy
+   | x == glut_CURSOR_HELP = Help
+   | x == glut_CURSOR_CYCLE = Cycle
+   | x == glut_CURSOR_SPRAY = Spray
+   | x == glut_CURSOR_WAIT = Wait
+   | x == glut_CURSOR_TEXT = Text
+   | x == glut_CURSOR_CROSSHAIR = Crosshair
+   | x == glut_CURSOR_UP_DOWN = UpDown
+   | x == glut_CURSOR_LEFT_RIGHT = LeftRight
+   | x == glut_CURSOR_TOP_SIDE = TopSide
+   | x == glut_CURSOR_BOTTOM_SIDE = BottomSide
+   | x == glut_CURSOR_LEFT_SIDE = LeftSide
+   | x == glut_CURSOR_RIGHT_SIDE = RightSide
+   | x == glut_CURSOR_TOP_LEFT_CORNER = TopLeftCorner
+   | x == glut_CURSOR_TOP_RIGHT_CORNER = TopRightCorner
+   | x == glut_CURSOR_BOTTOM_RIGHT_CORNER = BottomRightCorner
+   | x == glut_CURSOR_BOTTOM_LEFT_CORNER = BottomLeftCorner
+   | x == glut_CURSOR_INHERIT = Inherit
+   | x == glut_CURSOR_NONE = None
+   | x == glut_CURSOR_FULL_CROSSHAIR = FullCrosshair
+   | otherwise = error ("unmarshalCursor: illegal value " ++ show x)
+
+--------------------------------------------------------------------------------
+
+-- | Change the cursor image of the /current window/. Each call requests the
+-- window system change the cursor appropriately. The cursor image when a window
+-- is created is 'Inherit'. The exact cursor images used are implementation
+-- dependent. The intent is for the image to convey the meaning of the cursor
+-- name. For a top-level window, 'Inherit' uses the default window system
+-- cursor.
+--
+-- /X Implementation Notes:/ GLUT for X uses SGI\'s @_SGI_CROSSHAIR_CURSOR@
+-- convention to access a full-screen cross-hair cursor if possible.
+
+cursor :: StateVar Cursor
+cursor = makeStateVar getCursor setCursor
+
+setCursor :: Cursor -> IO ()
+setCursor = glutSetCursor . marshalCursor
+
+foreign import CALLCONV unsafe "glutSetCursor" glutSetCursor :: CInt -> IO ()
+
+getCursor :: IO Cursor
+getCursor = simpleGet unmarshalCursor glut_WINDOW_CURSOR
+
+--------------------------------------------------------------------------------
+
+-- | Setting 'pointerPosition' warps the window system\'s pointer to a new
+-- location relative to the origin of the /current window/ by the specified
+-- pixel offset, which may be negative. The warp is done immediately.
+--
+-- If the pointer would be warped outside the screen\'s frame buffer region, the
+-- location will be clamped to the nearest screen edge. The window system is
+-- allowed to further constrain the pointer\'s location in window system
+-- dependent ways.
+--
+-- Good advice from Xlib\'s @XWarpPointer@ man page: \"There is seldom any
+-- reason for calling this function. The pointer should normally be left to the
+-- user.\"
+
+pointerPosition :: SettableStateVar Position
+pointerPosition =
+   makeSettableStateVar $ \(Position x y) ->
+      glutWarpPointer (fromIntegral x) (fromIntegral y)
+
+foreign import CALLCONV unsafe "glutWarpPointer" glutWarpPointer ::
+   CInt -> CInt -> IO ()
diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,28 @@
+Copyright (c) 2002-2005, Sven Panne
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+   this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the author nor the names of its contributors may be
+   used to endorse or promote products derived from this software without
+   specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,6 @@
+module Main (main) where
+
+import Distribution.Simple (defaultMainWithHooks, defaultUserHooks)
+
+main :: IO ()
+main = defaultMainWithHooks defaultUserHooks
diff --git a/cbits/HsGLUT.c b/cbits/HsGLUT.c
new file mode 100644
--- /dev/null
+++ b/cbits/HsGLUT.c
@@ -0,0 +1,64 @@
+/* -----------------------------------------------------------------------------
+ *
+ * Module      :  C support for Graphics.UI.GLUT.Fonts
+ * Copyright   :  (c) Sven Panne 2002-2005
+ * License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+ * 
+ * Maintainer  :  sven.panne@aedion.de
+ * Stability   :  provisional
+ * Portability :  portable
+ *
+ * -------------------------------------------------------------------------- */
+
+#include "HsGLUT.h"
+
+/* needed only for GLUT_GET_PROC_ADDRESS_IS_BROKEN */
+#include "HsGLUTConfig.h"
+
+#if (FREEGLUT || GLUT_API_VERSION >= 5) && GLUT_GET_PROC_ADDRESS_IS_BROKEN
+#include <string.h>
+#endif
+
+void*
+hs_GLUT_marshalBitmapFont(int fontID)
+{
+  switch (fontID) {
+  case 0 : return GLUT_BITMAP_8_BY_13;
+  case 1 : return GLUT_BITMAP_9_BY_15;
+  case 2 : return GLUT_BITMAP_TIMES_ROMAN_10;
+  case 3 : return GLUT_BITMAP_TIMES_ROMAN_24;
+  case 4 : return GLUT_BITMAP_HELVETICA_10;
+  case 5 : return GLUT_BITMAP_HELVETICA_12;
+  case 6 : return GLUT_BITMAP_HELVETICA_18;
+  }
+  return (void*)0;
+}
+
+void*
+hs_GLUT_marshalStrokeFont(int fontID)
+{
+  switch (fontID) {
+  case 0 : return GLUT_STROKE_ROMAN;
+  case 1 : return GLUT_STROKE_MONO_ROMAN;
+  }
+  return (void*)0;
+}
+
+/* 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_GLUT_getProcAddress(char *procName)
+{
+#if (FREEGLUT || GLUT_API_VERSION >= 5)
+#if GLUT_GET_PROC_ADDRESS_IS_BROKEN
+  /* There are a few typos/omissions in freeglut 2.20 */
+  if (strcmp(procName, "glutWireCylinder"         ) == 0) return (void*)glutWireCylinder;
+  if (strcmp(procName, "glutSolidCylinder"        ) == 0) return (void*)glutSolidCylinder;
+  if (strcmp(procName, "glutWireSierpinskiSponge" ) == 0) return (void*)glutWireSierpinskiSponge;
+  if (strcmp(procName, "glutSolidSierpinskiSponge") == 0) return (void*)glutSolidSierpinskiSponge;
+#endif
+  return glutGetProcAddress(procName);
+#else
+  return (void*)0;
+#endif
+}
diff --git a/config.guess b/config.guess
new file mode 100644
--- /dev/null
+++ b/config.guess
@@ -0,0 +1,1497 @@
+#! /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.mk.in b/config.mk.in
new file mode 100644
--- /dev/null
+++ b/config.mk.in
@@ -0,0 +1,10 @@
+GLUT_BUILD_PACKAGE=@GLUT_BUILD_PACKAGE@
+ifneq "$(GLUT_BUILD_PACKAGE)" "no"
+GLUT_LIBS=@GLUT_LIBS@
+GLUT_CFLAGS=@GLUT_CFLAGS@
+GLUT_EXTRA_LIBS=@GLUT_EXTRA_LIBS@
+GLUT_FRAMEWORKS=@GLUT_FRAMEWORKS@
+PACKAGE=@PACKAGE_TARNAME@
+VERSION=@PACKAGE_VERSION@
+MAINTAINER=@PACKAGE_BUGREPORT@
+endif
diff --git a/config.sub b/config.sub
new file mode 100644
--- /dev/null
+++ b/config.sub
@@ -0,0 +1,1608 @@
+#! /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
new file mode 100644
--- /dev/null
+++ b/configure
@@ -0,0 +1,6238 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.57 for Haskell GLUT package 2.0.
+#
+# Report bugs to <sven.panne@aedion.de>.
+#
+# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
+# 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 Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+  set -o posix
+fi
+
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+  LC_TELEPHONE LC_TIME
+do
+  if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    $as_unset $as_var
+  fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; 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
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)$' \| \
+	 .     : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+  	  /^X\/\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\/\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# 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
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
+  # Find who we are.  Look in the path if we contain no path at all
+  # relative or not.
+  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
+
+       ;;
+  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
+    { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
+   { (exit 1); exit 1; }; }
+  fi
+  case $CONFIG_SHELL in
+  '')
+    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for as_base in sh bash ksh sh5; do
+	 case $as_dir in
+	 /*)
+	   if ("$as_dir/$as_base" -c '
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
+	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+	     CONFIG_SHELL=$as_dir/$as_base
+	     export CONFIG_SHELL
+	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+	   fi;;
+	 esac
+       done
+done
+;;
+  esac
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line before each line; the second 'sed' does the real
+  # work.  The second script uses 'N' to pair each line-number line
+  # with the numbered line, and appends trailing '-' during
+  # substitution so that $LINENO is not a special case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
+  sed '=' <$as_myself |
+    sed '
+      N
+      s,$,-,
+      : loop
+      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+      t loop
+      s,-$,,
+      s,^['$as_cr_digits']*\n,,
+    ' >$as_me.lineno &&
+  chmod +x $as_me.lineno ||
+    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+   { (exit 1); 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 sensible to this).
+  . ./$as_me.lineno
+  # Exit status is that of the last command.
+  exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+  *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T='	' ;;
+  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  # We could just check for DJGPP; but this test a) works b) is more generic
+  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+  if test -f conf$$.exe; then
+    # Don't use ln at all; we don't have any links
+    as_ln_s='cp -p'
+  else
+    as_ln_s='ln -s'
+  fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="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="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" 	$as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+exec 6>&1
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Maximum number of lines to put in a shell here document.
+# This variable seems obsolete.  It should probably be removed, and
+# only ac_max_sed_lines should be used.
+: ${ac_max_here_lines=38}
+
+# Identity of this package.
+PACKAGE_NAME='Haskell GLUT package'
+PACKAGE_TARNAME='GLUT'
+PACKAGE_VERSION='2.0'
+PACKAGE_STRING='Haskell GLUT package 2.0'
+PACKAGE_BUGREPORT='sven.panne@aedion.de'
+
+ac_unique_file="include/HsGLUT.h.in"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+#  include <stdint.h>
+# endif
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS GLUT_BUILD_PACKAGE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os GLU_FRAMEWORKS GLUT_FRAMEWORKS GLUT_EXTRA_LIBS GL_CFLAGS GL_LIBS GLU_CFLAGS GLU_LIBS EGREP GLUT_CFLAGS GLUT_LIBS BUILD_PACKAGE_BOOL CALLCONV LIBOBJS LTLIBOBJS'
+ac_subst_files=''
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# 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.
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+ac_prev=
+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
+
+  ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_option in
+
+  -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 | --data | --dat | --da)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+  | --da=*)
+    datadir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+    eval "enable_$ac_feature=no" ;;
+
+  -enable-* | --enable-*)
+    ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+    case $ac_option in
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "enable_$ac_feature='$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 ;;
+
+  -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 ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst \
+  | --locals | --local | --loca | --loc | --lo)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+    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 ;;
+
+  -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_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
+    ac_package=`echo $ac_package| sed 's/-/_/g'`
+    case $ac_option in
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "with_$ac_package='$ac_optarg'" ;;
+
+  -without-* | --without-*)
+    ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
+    ac_package=`echo $ac_package | sed 's/-/_/g'`
+    eval "with_$ac_package=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 ;;
+
+  -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; }
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+   { (exit 1); exit 1; }; }
+    ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+    eval "$ac_envvar='$ac_optarg'"
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      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'`
+  { echo "$as_me: error: missing argument to $ac_option" >&2
+   { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+  eval ac_val=$`echo $ac_var`
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; };;
+  esac
+done
+
+# Be sure to have absolute paths.
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+              localstatedir libdir includedir oldincludedir infodir mandir
+do
+  eval ac_val=$`echo $ac_var`
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* ) ;;
+    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; };;
+  esac
+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
+    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
+
+
+# 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 its parent.
+  ac_confdir=`(dirname "$0") 2>/dev/null ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$0" : 'X\(//\)[^/]' \| \
+         X"$0" : 'X\(//\)$' \| \
+         X"$0" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$0" |
+    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
+  if test "$ac_srcdir_defaulted" = yes; then
+    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
+   { (exit 1); exit 1; }; }
+  else
+    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+   { (exit 1); exit 1; }; }
+  fi
+fi
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
+  { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
+   { (exit 1); exit 1; }; }
+srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
+ac_env_build_alias_set=${build_alias+set}
+ac_env_build_alias_value=$build_alias
+ac_cv_env_build_alias_set=${build_alias+set}
+ac_cv_env_build_alias_value=$build_alias
+ac_env_host_alias_set=${host_alias+set}
+ac_env_host_alias_value=$host_alias
+ac_cv_env_host_alias_set=${host_alias+set}
+ac_cv_env_host_alias_value=$host_alias
+ac_env_target_alias_set=${target_alias+set}
+ac_env_target_alias_value=$target_alias
+ac_cv_env_target_alias_set=${target_alias+set}
+ac_cv_env_target_alias_value=$target_alias
+ac_env_CC_set=${CC+set}
+ac_env_CC_value=$CC
+ac_cv_env_CC_set=${CC+set}
+ac_cv_env_CC_value=$CC
+ac_env_CFLAGS_set=${CFLAGS+set}
+ac_env_CFLAGS_value=$CFLAGS
+ac_cv_env_CFLAGS_set=${CFLAGS+set}
+ac_cv_env_CFLAGS_value=$CFLAGS
+ac_env_LDFLAGS_set=${LDFLAGS+set}
+ac_env_LDFLAGS_value=$LDFLAGS
+ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
+ac_cv_env_LDFLAGS_value=$LDFLAGS
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
+
+#
+# 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 GLUT package 2.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 \`..']
+
+_ACEOF
+
+  cat <<_ACEOF
+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]
+  --datadir=DIR          read-only architecture-independent data [PREFIX/share]
+  --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]
+  --infodir=DIR          info documentation [PREFIX/info]
+  --mandir=DIR           man documentation [PREFIX/man]
+_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 GLUT package 2.0:";;
+   esac
+  cat <<\_ACEOF
+
+Optional Features:
+  --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)
+  --enable-glut           build a Haskell binding for GLUT
+                          (default=autodetect)
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --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>
+  CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have
+              headers in a nonstandard directory <include dir>
+  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
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  ac_popdir=`pwd`
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d $ac_dir || continue
+    ac_builddir=.
+
+if test "$ac_dir" != .; then
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A "../" for each directory in $ac_dir_suffix.
+  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+  ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+  .)  # No --srcdir option.  We are building in place.
+    ac_srcdir=.
+    if test -z "$ac_top_builddir"; then
+       ac_top_srcdir=.
+    else
+       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+    fi ;;
+  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir ;;
+  *) # Relative path.
+    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
+# absolute.
+ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
+ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
+ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
+ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
+
+    cd $ac_dir
+    # Check for guested configure; otherwise get Cygnus style 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
+    elif test -f $ac_srcdir/configure.ac ||
+           test -f $ac_srcdir/configure.in; then
+      echo
+      $ac_configure --help
+    else
+      echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi
+    cd $ac_popdir
+  done
+fi
+
+test -n "$ac_init_help" && exit 0
+if $ac_init_version; then
+  cat <<\_ACEOF
+Haskell GLUT package configure 2.0
+generated by GNU Autoconf 2.57
+
+Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
+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 0
+fi
+exec 5>config.log
+cat >&5 <<_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 GLUT package $as_me 2.0, which was
+generated by GNU Autoconf 2.57.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+{
+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`
+hostinfo               = `(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=.
+  echo "PATH: $as_dir"
+done
+
+} >&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_sep=
+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=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+    2)
+      ac_configure_args1="$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
+      ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+      # Get rid of the leading space.
+      ac_sep=" "
+      ;;
+    esac
+  done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export 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: Be sure not to use single quotes in there, as some shells,
+# such as our DU 5.0 friend, will then `close' the trap.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+{
+  (set) 2>&1 |
+    case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
+    *ac_space=\ *)
+      sed -n \
+        "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
+    	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+      ;;
+    *)
+      sed -n \
+        "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      ;;
+    esac;
+}
+    echo
+
+    cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=$`echo $ac_var`
+      echo "$ac_var='"'"'$ac_val'"'"'"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      cat <<\_ASBOX
+## ------------- ##
+## Output files. ##
+## ------------- ##
+_ASBOX
+      echo
+      for ac_var in $ac_subst_files
+      do
+	eval ac_val=$`echo $ac_var`
+        echo "$ac_var='"'"'$ac_val'"'"'"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+      echo
+      sed "/^$/d" confdefs.h | sort
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      echo "$as_me: caught signal $ac_signal"
+    echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core core.* *.core &&
+  rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+     ' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo >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
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+  if test "x$prefix" != xNONE; then
+    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+  else
+    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+  fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+  if test -r "$ac_site_file"; then
+    { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file"
+  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.
+  if test -f "$cache_file"; then
+    { echo "$as_me:$LINENO: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . $cache_file;;
+      *)                      . ./$cache_file;;
+    esac
+  fi
+else
+  { echo "$as_me:$LINENO: creating cache $cache_file" >&5
+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 `(set) 2>&1 |
+               sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; 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,)
+      { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+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
+        { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+        { echo "$as_me:$LINENO:   former value:  $ac_old_val" >&5
+echo "$as_me:   former value:  $ac_old_val" >&2;}
+        { echo "$as_me:$LINENO:   current value: $ac_new_val" >&5
+echo "$as_me:   current value: $ac_new_val" >&2;}
+        ac_cache_corrupted=:
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+      ac_arg=$ac_var=`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.
+      *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+   { (exit 1); exit 1; }; }
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# 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/HsGLUTConfig.h include/HsGLUT.h"
+
+
+# We set this to "yes" later when we have found GLUT libs and headers.
+GLUT_BUILD_PACKAGE=no
+
+
+# Shall we build this package at all?
+# Check whether --enable-opengl or --disable-opengl was given.
+if test "${enable_opengl+set}" = set; then
+  enableval="$enable_opengl"
+  enable_opengl=$enableval
+else
+  enable_opengl=yes
+fi;
+
+
+# Check whether --enable-glut or --disable-glut was given.
+if test "${enable_glut+set}" = set; then
+  enableval="$enable_glut"
+  enable_glut=$enableval
+else
+  enable_glut=yes
+fi;
+
+
+if test x"$enable_glut" = xyes; then
+
+# Check for GLUT 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
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}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
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  CC=$ac_ct_CC
+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
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  CC=$ac_ct_CC
+else
+  CC="$ac_cv_prog_CC"
+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
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$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"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+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
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl
+  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
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$ac_ct_CC" && break
+done
+
+  CC=$ac_ct_CC
+fi
+
+fi
+
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+     "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+  (eval $ac_compiler --version </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+  (eval $ac_compiler -v </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+  (eval $ac_compiler -V </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out 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.
+echo "$as_me:$LINENO: checking for C compiler default output" >&5
+echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
+  (eval $ac_link_default) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # Find the output, starting from the most likely.  This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+
+# Be careful to initialize this variable, since it used to be cached.
+# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
+ac_cv_exeext=
+# b.out is created by i960 compilers.
+for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
+        ;;
+    conftest.$ac_ext )
+        # This is the source file.
+        ;;
+    [ab].out )
+        # We found the default executable, but exeext='' is most
+        # certainly right.
+        break;;
+    *.* )
+        ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+        # FIXME: I believe we export ac_cv_exeext for Libtool,
+        # but it would be cool to find out if it's true.  Does anybody
+        # maintain Libtool? --akim.
+        export ac_cv_exeext
+        break;;
+    * )
+        break;;
+  esac
+done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6
+
+# Check the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+  if { ac_try='./$ac_file'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+    fi
+  fi
+fi
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6
+
+echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; 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 | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+          export ac_cv_exeext
+          break;;
+    * ) break;;
+  esac
+done
+else
+  { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
+if test "${ac_cv_objext+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_compiler_gnu=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_compiler_gnu=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$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
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* 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;
+}
+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
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX			-qlanglvl=ansi
+# Ultrix and OSF/1	-std1
+# HP-UX 10.20 and later	-Ae
+# HP-UX older versions	-Aa -D_HPUX_SOURCE
+# SVR4			-Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+  x|xno)
+    echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+  *)
+    echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+    CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
+# Some people use a C++ compiler to compile C.  Since we use `exit',
+# in C++ we need to declare it.  In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+  choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  for ac_declaration in \
+   ''\
+   '#include <stdlib.h>' \
+   'extern "C" void std::exit (int) throw (); using std::exit;' \
+   'extern "C" void std::exit (int); using std::exit;' \
+   'extern "C" void exit (int) throw ();' \
+   'extern "C" void exit (int);' \
+   'void exit (int);'
+do
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+$ac_declaration
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+continue
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_declaration
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+  echo '#ifdef __cplusplus' >>confdefs.h
+  echo $ac_declaration      >>confdefs.h
+  echo '#endif'             >>confdefs.h
+fi
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+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
+
+
+echo "$as_me:$LINENO: checking for Windows environment" >&5
+echo $ECHO_N "checking for Windows environment... $ECHO_C" >&6
+if test "${fp_cv_is_win32+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+#if !_WIN32
+   syntax error;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  fp_cv_is_win32=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fp_cv_is_win32=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $fp_cv_is_win32" >&5
+echo "${ECHO_T}$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
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                     Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f 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
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$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 >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                     Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  :
+else
+  { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+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
+
+
+echo "$as_me:$LINENO: checking for X" >&5
+echo $ECHO_N "checking for X... $ECHO_C" >&6
+
+
+# Check whether --with-x or --without-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
+  if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
+    # Both variables are already set.
+    have_x=yes
+  else
+    if test "${ac_cv_have_x+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 -fr conftest.dir
+if mkdir conftest.dir; then
+  cd conftest.dir
+  # Make sure to not put "make" in the Imakefile rules, since we grep it out.
+  cat >Imakefile <<'_ACEOF'
+acfindx:
+	@echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
+_ACEOF
+  if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
+    # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+    eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
+    # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
+    for ac_extension in a so sl; 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) ;;
+	*) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
+    esac
+    case $ac_im_usrlibdir in
+	/usr/lib | /lib) ;;
+	*) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
+    esac
+  fi
+  cd ..
+  rm -fr 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/X11R6/include
+/usr/X11R5/include
+/usr/X11R4/include
+
+/usr/include/X11
+/usr/include/X11R6
+/usr/include/X11R5
+/usr/include/X11R4
+
+/usr/local/X11/include
+/usr/local/X11R6/include
+/usr/local/X11R5/include
+/usr/local/X11R4/include
+
+/usr/local/include/X11
+/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 Intrinsic.h.
+  # First, try using that file with no special directory specified.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <X11/Intrinsic.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # We can compile using X headers with no special include directory.
+ac_x_includes=
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  for ac_dir in $ac_x_header_dirs; do
+  if test -r "$ac_dir/X11/Intrinsic.h"; then
+    ac_x_includes=$ac_dir
+    break
+  fi
+done
+fi
+rm -f conftest.err 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="-lXt $LIBS"
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <X11/Intrinsic.h>
+int
+main ()
+{
+XtMalloc (0)
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  LIBS=$ac_save_LIBS
+# We can link X programs with no special library path.
+ac_x_libraries=
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+LIBS=$ac_save_LIBS
+for ac_dir in `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; do
+    if test -r $ac_dir/libXt.$ac_extension; then
+      ac_x_libraries=$ac_dir
+      break 2
+    fi
+  done
+done
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi # $ac_x_libraries = no
+
+if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then
+  # Didn't find X anywhere.  Cache the known absence of X.
+  ac_cv_have_x="have_x=no"
+else
+  # 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"
+fi
+fi
+
+  fi
+  eval "$ac_cv_have_x"
+fi # $with_x != no
+
+if test "$have_x" != yes; then
+  echo "$as_me:$LINENO: result: $have_x" >&5
+echo "${ECHO_T}$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"
+  echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5
+echo "${ECHO_T}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.
+
+cat >>confdefs.h <<\_ACEOF
+#define X_DISPLAY_MISSING 1
+_ACEOF
+
+  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 . . . .
+    case `(uname -sr) 2>/dev/null` in
+    "SunOS 5"*)
+      echo "$as_me:$LINENO: checking whether -R must be followed by a space" >&5
+echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6
+      ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
+      cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_R_nospace=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_R_nospace=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+      if test $ac_R_nospace = yes; then
+	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+	X_LIBS="$X_LIBS -R$x_libraries"
+      else
+	LIBS="$ac_xsave_LIBS -R $x_libraries"
+	cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_R_space=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_R_space=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+	if test $ac_R_space = yes; then
+	  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+	  X_LIBS="$X_LIBS -R $x_libraries"
+	else
+	  echo "$as_me:$LINENO: result: neither works" >&5
+echo "${ECHO_T}neither works" >&6
+	fi
+      fi
+      LIBS=$ac_xsave_LIBS
+    esac
+  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 >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XOpenDisplay ();
+int
+main ()
+{
+XOpenDisplay ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet" >&5
+echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6
+if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldnet  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dnet_ntoa ();
+int
+main ()
+{
+dnet_ntoa ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dnet_dnet_ntoa=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dnet_dnet_ntoa=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
+echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6
+if test $ac_cv_lib_dnet_dnet_ntoa = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
+fi
+
+    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
+      echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet_stub" >&5
+echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6
+if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldnet_stub  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dnet_ntoa ();
+int
+main ()
+{
+dnet_ntoa ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dnet_stub_dnet_ntoa=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dnet_stub_dnet_ntoa=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
+echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6
+if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
+fi
+
+    fi
+fi
+rm -f 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.
+    echo "$as_me:$LINENO: checking for gethostbyname" >&5
+echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6
+if test "${ac_cv_func_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char gethostbyname (); 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
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname ();
+/* 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_gethostbyname) || defined (__stub___gethostbyname)
+choke me
+#else
+char (*f) () = gethostbyname;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != gethostbyname;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_gethostbyname=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_gethostbyname=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6
+
+    if test $ac_cv_func_gethostbyname = no; then
+      echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5
+echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
+if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lnsl  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname ();
+int
+main ()
+{
+gethostbyname ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_nsl_gethostbyname=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_nsl_gethostbyname=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
+if test $ac_cv_lib_nsl_gethostbyname = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
+fi
+
+      if test $ac_cv_lib_nsl_gethostbyname = no; then
+        echo "$as_me:$LINENO: checking for gethostbyname in -lbsd" >&5
+echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6
+if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lbsd  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname ();
+int
+main ()
+{
+gethostbyname ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_bsd_gethostbyname=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_bsd_gethostbyname=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_bsd_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6
+if test $ac_cv_lib_bsd_gethostbyname = yes; 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.
+    echo "$as_me:$LINENO: checking for connect" >&5
+echo $ECHO_N "checking for connect... $ECHO_C" >&6
+if test "${ac_cv_func_connect+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char connect (); 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
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char connect ();
+/* 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_connect) || defined (__stub___connect)
+choke me
+#else
+char (*f) () = connect;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != connect;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_connect=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_connect=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_connect" >&5
+echo "${ECHO_T}$ac_cv_func_connect" >&6
+
+    if test $ac_cv_func_connect = no; then
+      echo "$as_me:$LINENO: checking for connect in -lsocket" >&5
+echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6
+if test "${ac_cv_lib_socket_connect+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char connect ();
+int
+main ()
+{
+connect ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_socket_connect=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_socket_connect=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_socket_connect" >&5
+echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6
+if test $ac_cv_lib_socket_connect = yes; then
+  X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
+fi
+
+    fi
+
+    # Guillermo Gomez says -lposix is necessary on A/UX.
+    echo "$as_me:$LINENO: checking for remove" >&5
+echo $ECHO_N "checking for remove... $ECHO_C" >&6
+if test "${ac_cv_func_remove+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char remove (); 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
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char remove ();
+/* 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_remove) || defined (__stub___remove)
+choke me
+#else
+char (*f) () = remove;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != remove;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_remove=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_remove=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_remove" >&5
+echo "${ECHO_T}$ac_cv_func_remove" >&6
+
+    if test $ac_cv_func_remove = no; then
+      echo "$as_me:$LINENO: checking for remove in -lposix" >&5
+echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6
+if test "${ac_cv_lib_posix_remove+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lposix  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char remove ();
+int
+main ()
+{
+remove ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_posix_remove=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_posix_remove=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_posix_remove" >&5
+echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6
+if test $ac_cv_lib_posix_remove = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
+fi
+
+    fi
+
+    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
+    echo "$as_me:$LINENO: checking for shmat" >&5
+echo $ECHO_N "checking for shmat... $ECHO_C" >&6
+if test "${ac_cv_func_shmat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char shmat (); 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
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shmat ();
+/* 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_shmat) || defined (__stub___shmat)
+choke me
+#else
+char (*f) () = shmat;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != shmat;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_shmat=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_shmat=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_shmat" >&5
+echo "${ECHO_T}$ac_cv_func_shmat" >&6
+
+    if test $ac_cv_func_shmat = no; then
+      echo "$as_me:$LINENO: checking for shmat in -lipc" >&5
+echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6
+if test "${ac_cv_lib_ipc_shmat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lipc  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shmat ();
+int
+main ()
+{
+shmat ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_ipc_shmat=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_ipc_shmat=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_ipc_shmat" >&5
+echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6
+if test $ac_cv_lib_ipc_shmat = yes; 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
+  echo "$as_me:$LINENO: checking for IceConnectionNumber in -lICE" >&5
+echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6
+if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lICE $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char IceConnectionNumber ();
+int
+main ()
+{
+IceConnectionNumber ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_ICE_IceConnectionNumber=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_ICE_IceConnectionNumber=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
+echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6
+if test $ac_cv_lib_ICE_IceConnectionNumber = yes; 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
+  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"
+ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
+
+# Make sure we can run config.sub.
+$ac_config_sub sun4 >/dev/null 2>&1 ||
+  { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
+echo "$as_me: error: cannot run $ac_config_sub" >&2;}
+   { (exit 1); exit 1; }; }
+
+echo "$as_me:$LINENO: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6
+if test "${ac_cv_build+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_build_alias=$build_alias
+test -z "$ac_cv_build_alias" &&
+  ac_cv_build_alias=`$ac_config_guess`
+test -z "$ac_cv_build_alias" &&
+  { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+   { (exit 1); exit 1; }; }
+ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
+  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6
+build=$ac_cv_build
+build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+echo "$as_me:$LINENO: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6
+if test "${ac_cv_host+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_host_alias=$host_alias
+test -z "$ac_cv_host_alias" &&
+  ac_cv_host_alias=$ac_cv_build_alias
+ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
+  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6
+host=$ac_cv_host
+host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+echo "$as_me:$LINENO: checking target system type" >&5
+echo $ECHO_N "checking target system type... $ECHO_C" >&6
+if test "${ac_cv_target+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_target_alias=$target_alias
+test "x$ac_cv_target_alias" = "x" &&
+  ac_cv_target_alias=$ac_cv_host_alias
+ac_cv_target=`$ac_config_sub $ac_cv_target_alias` ||
+  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_target" >&5
+echo "${ECHO_T}$ac_cv_target" >&6
+target=$ac_cv_target
+target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+# 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*)
+
+cat >>confdefs.h <<\_ACEOF
+#define USE_QUARTZ_OPENGL 1
+_ACEOF
+
+    use_quartz_opengl=yes
+    ;;
+  esac
+fi
+
+GLU_FRAMEWORKS=
+GLUT_FRAMEWORKS=
+GLUT_EXTRA_LIBS=
+if test x"$use_quartz_opengl" = xyes; then
+  GLU_FRAMEWORKS=OpenGL
+  GLUT_FRAMEWORKS=GLUT
+  GLUT_EXTRA_LIBS=objc
+fi
+
+
+
+
+
+
+
+
+if test x"$use_quartz_opengl" = xno; then
+  echo "$as_me:$LINENO: checking for atan" >&5
+echo $ECHO_N "checking for atan... $ECHO_C" >&6
+if test "${ac_cv_func_atan+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char atan (); 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
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char atan ();
+/* 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_atan) || defined (__stub___atan)
+choke me
+#else
+char (*f) () = atan;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != atan;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_atan=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_atan=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_atan" >&5
+echo "${ECHO_T}$ac_cv_func_atan" >&6
+if test $ac_cv_func_atan = yes; then
+  fp_libm_not_needed=yes
+else
+  fp_libm_not_needed=dunno
+fi
+
+  if test x"$fp_libm_not_needed" = xdunno; then
+     echo "$as_me:$LINENO: checking for atan in -lm" >&5
+echo $ECHO_N "checking for atan in -lm... $ECHO_C" >&6
+if test "${ac_cv_lib_m_atan+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lm  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char atan ();
+int
+main ()
+{
+atan ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_m_atan=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_m_atan=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_m_atan" >&5
+echo "${ECHO_T}$ac_cv_lib_m_atan" >&6
+if test $ac_cv_lib_m_atan = yes; 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
+
+  echo "$as_me:$LINENO: checking for GL library" >&5
+echo $ECHO_N "checking for GL library... $ECHO_C" >&6
+if test "${fp_cv_check_GL_lib+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <GL/gl.h>
+int
+main ()
+{
+glEnd()
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  fp_cv_check_GL_lib="$fp_try_lib ${GL_LIBS}"; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+  done
+  LIBS="$fp_save_LIBS"
+  CPPFLAGS="$fp_save_CPPFLAGS"
+fi
+echo "$as_me:$LINENO: result: $fp_cv_check_GL_lib" >&5
+echo "${ECHO_T}$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 >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <GL/gl.h>
+int
+main ()
+{
+glEnd()
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  GL_LIBS="$GL_LIBS -lopengl32"; GL_LIBS0="$GL_LIBS0 -lopengl32"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f 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
+  echo "$as_me:$LINENO: checking for GLU library" >&5
+echo $ECHO_N "checking for GLU library... $ECHO_C" >&6
+if test "${fp_cv_check_GLU_lib+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <GL/glu.h>
+int
+main ()
+{
+gluNewQuadric()
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  fp_cv_check_GLU_lib="$fp_try_lib ${GLU_LIBS}"; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+  done
+  LIBS="$fp_save_LIBS"
+  CPPFLAGS="$fp_save_CPPFLAGS"
+fi
+echo "$as_me:$LINENO: result: $fp_cv_check_GLU_lib" >&5
+echo "${ECHO_T}$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
+
+
+
+
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+    then ac_cv_prog_egrep='grep -E'
+    else ac_cv_prog_egrep='egrep'
+    fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_header_stdc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
+fi
+rm -f 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 >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* 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 >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* 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 >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ctype.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))
+      exit(2);
+  exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+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=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+if test x"$use_quartz_opengl" = xno; then
+  GLUT_CFLAGS="$GLU_CFLAGS0"
+  GLUT_LIBS="$GLU_LIBS0"
+
+  if test x"$no_x" != xyes; then
+    GLUT_LIBS="$X_PRE_LIBS -lXmu -lXi $X_EXTRA_LIBS $GLUT_LIBS"
+  fi
+
+
+for ac_header in windows.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+  fp_save_cppflags="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+for ac_header in GL/glut.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+  CPPFLAGS="$fp_save_cppflags"
+
+  # Note 1: On Cygwin with X11, GL/GLU functions use the "normal" calling
+  # convention, but GLUT functions use stdcall. To get this right, it is
+  # necessary to include <windows.h> first.
+  # Note 2: MinGW/MSYS comes without a GLUT header, so we use Cygwin's one in
+  # that case.
+  echo "$as_me:$LINENO: checking for GLUT library" >&5
+echo $ECHO_N "checking for GLUT library... $ECHO_C" >&6
+if test "${fp_cv_check_GLUT_lib+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  fp_cv_check_GLUT_lib="no"
+  fp_save_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS ${GLUT_CFLAGS}"
+  fp_save_LIBS="$LIBS"
+  for fp_try_lib in -lglut32 -lglut; 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 ${GLUT_LIBS} $fp_save_LIBS"
+    cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#if HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+#if HAVE_GL_GLUT_H
+#include <GL/glut.h>
+#else
+#include "glut_local.h"
+#endif
+
+int
+main ()
+{
+glutMainLoop()
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  fp_cv_check_GLUT_lib="$fp_try_lib ${GLUT_LIBS}"; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+  done
+  LIBS="$fp_save_LIBS"
+  CPPFLAGS="$fp_save_CPPFLAGS"
+fi
+echo "$as_me:$LINENO: result: $fp_cv_check_GLUT_lib" >&5
+echo "${ECHO_T}$fp_cv_check_GLUT_lib" >&6
+
+  if test x"$fp_cv_check_GLUT_lib" = xno; then
+    no_GLUT=yes
+    GLUT_CFLAGS=
+    GLUT_LIBS=
+  else
+    GLUT_CFLAGS0="${GLUT_CFLAGS}"
+    GLUT_CFLAGS="$CPPFLAGS ${GLUT_CFLAGS0}"
+    GLUT_LIBS0="$fp_cv_check_GLUT_lib"
+    GLUT_LIBS="$LDFLAGS ${GLUT_LIBS0}"
+  fi
+
+fi
+
+
+
+
+
+if test "$GLUT_LIBS" = no; then
+  { echo "$as_me:$LINENO: WARNING: no GLUT library found, so this package will not be built" >&5
+echo "$as_me: WARNING: no GLUT library found, so this package will not be built" >&2;}
+else
+
+# check for GLUT include files
+glut_found_header=no
+fp_save_cppflags="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+
+for ac_header in GL/glut.h GLUT/glut.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ glut_found_header=yes
+fi
+
+done
+
+CPPFLAGS="$fp_save_cppflags"
+
+if test "$glut_found_header" = no; then
+  { echo "$as_me:$LINENO: WARNING: no GLUT header found, so this package will not be built" >&5
+echo "$as_me: WARNING: no GLUT header found, so this package will not be built" >&2;}
+else
+
+GLUT_BUILD_PACKAGE=yes
+
+
+for ac_header in windows.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define GLUT_EXTRA_LIBS `echo HSGLUT_cbits $GLUT_EXTRA_LIBS | sed -e 's/[^ ]*/,"&"/g' -e 's/^ *,//'`
+_ACEOF
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define GLUT_CFLAGS `echo '' $GLUT_CFLAGS | sed -e 's/-[^ ]*/,"&"/g' -e 's/^ *,//'`
+_ACEOF
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define GLUT_LIBS `echo '' $GLUT_LIBS | sed -e 's/-[^ ]*/,"&"/g' -e 's/^ *,//'`
+_ACEOF
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define GLUT_FRAMEWORKS `echo '' $GLUT_FRAMEWORKS | sed -e 's/-[^ ]*/,"&"/g' -e 's/^ *,//'`
+_ACEOF
+
+
+fi
+fi
+fi
+
+if test "$GLUT_BUILD_PACKAGE" = yes; 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 config.mk GLUT.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, don't put newlines in cache variables' values.
+# 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.
+{
+  (set) 2>&1 |
+    case `(ac_space=' '; set | grep ac_space) 2>&1` in
+    *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 \
+        "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      ;;
+    esac;
+} |
+  sed '
+     t clear
+     : clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     : end' >>confcache
+if diff $cache_file confcache >/dev/null 2>&1; then :; else
+  if test -w $cache_file; then
+    test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+    cat confcache >$cache_file
+  else
+    echo "not updating unwritable cache $cache_file"
+  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}'
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ 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[ 	]*=/{
+s/:*\$(srcdir):*/:/;
+s/:*\${srcdir}:*/:/;
+s/:*@srcdir@:*/:/;
+s/^\([^=]*=[ 	]*\):*/\1/;
+s/:*$//;
+s/^[^=]*=[ 	]*$//;
+}'
+fi
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_i=`echo "$ac_i" |
+         sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
+  # 2. Add them.
+  ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
+  ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $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}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+  set -o posix
+fi
+
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+  LC_TELEPHONE LC_TIME
+do
+  if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    $as_unset $as_var
+  fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; 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
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)$' \| \
+	 .     : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+  	  /^X\/\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\/\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# 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
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
+  # Find who we are.  Look in the path if we contain no path at all
+  # relative or not.
+  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
+
+       ;;
+  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
+    { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
+echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+  case $CONFIG_SHELL in
+  '')
+    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for as_base in sh bash ksh sh5; do
+	 case $as_dir in
+	 /*)
+	   if ("$as_dir/$as_base" -c '
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
+	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+	     CONFIG_SHELL=$as_dir/$as_base
+	     export CONFIG_SHELL
+	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+	   fi;;
+	 esac
+       done
+done
+;;
+  esac
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line before each line; the second 'sed' does the real
+  # work.  The second script uses 'N' to pair each line-number line
+  # with the numbered line, and appends trailing '-' during
+  # substitution so that $LINENO is not a special case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
+  sed '=' <$as_myself |
+    sed '
+      N
+      s,$,-,
+      : loop
+      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+      t loop
+      s,-$,,
+      s,^['$as_cr_digits']*\n,,
+    ' >$as_me.lineno &&
+  chmod +x $as_me.lineno ||
+    { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
+echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+   { (exit 1); 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 sensible to this).
+  . ./$as_me.lineno
+  # Exit status is that of the last command.
+  exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+  *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T='	' ;;
+  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  # We could just check for DJGPP; but this test a) works b) is more generic
+  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+  if test -f conf$$.exe; then
+    # Don't use ln at all; we don't have any links
+    as_ln_s='cp -p'
+  else
+    as_ln_s='ln -s'
+  fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="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="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" 	$as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+exec 6>&1
+
+# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.  Logging --version etc. is OK.
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+} >&5
+cat >&5 <<_CSEOF
+
+This file was extended by Haskell GLUT package $as_me 2.0, which was
+generated by GNU Autoconf 2.57.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+_CSEOF
+echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
+echo >&5
+_ACEOF
+
+# Files that config.status was made for.
+if test -n "$ac_config_files"; then
+  echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_headers"; then
+  echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_links"; then
+  echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_commands"; then
+  echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number, then exit
+  -q, --quiet      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 <bug-autoconf@gnu.org>."
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+Haskell GLUT package config.status 2.0
+configured by $0, generated by GNU Autoconf 2.57,
+  with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+srcdir=$srcdir
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If no file are specified by the user, then we need to provide default
+# value.  By we need to know if files were specified by the user.
+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=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  *) # This is not an option, so the user has probably given explicit
+     # arguments.
+     ac_option=$1
+     ac_need_defaults=false;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --vers* | -V )
+    echo "$ac_cs_version"; exit 0 ;;
+  --he | --h)
+    # Conflict between --help and --header
+    { { echo "$as_me:$LINENO: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2;}
+   { (exit 1); exit 1; }; };;
+  --help | --hel | -h )
+    echo "$ac_cs_usage"; exit 0 ;;
+  --debug | --d* | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+    ac_need_defaults=false;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2;}
+   { (exit 1); exit 1; }; } ;;
+
+  *) ac_config_targets="$ac_config_targets $1" ;;
+
+  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
+if \$ac_cs_recheck; then
+  echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+  exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
+
+_ACEOF
+
+
+
+
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_config_target in $ac_config_targets
+do
+  case "$ac_config_target" in
+  # Handling of arguments.
+  "config.mk" ) CONFIG_FILES="$CONFIG_FILES config.mk" ;;
+  "GLUT.buildinfo" ) CONFIG_FILES="$CONFIG_FILES GLUT.buildinfo" ;;
+  "include/HsGLUTConfig.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/HsGLUTConfig.h" ;;
+  "include/HsGLUT.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/HsGLUT.h" ;;
+  *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+   { (exit 1); exit 1; }; };;
+  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 to put it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+  trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./confstat$$-$RANDOM
+  (umask 077 && mkdir $tmp)
+} ||
+{
+   echo "$me: cannot create a temporary directory in ." >&2
+   { (exit 1); exit 1; }
+}
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+
+#
+# CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "\$CONFIG_FILES"; then
+  # Protect against being on the right side of a sed subst in config.status.
+  sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
+   s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+s,@SHELL@,$SHELL,;t t
+s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s,@exec_prefix@,$exec_prefix,;t t
+s,@prefix@,$prefix,;t t
+s,@program_transform_name@,$program_transform_name,;t t
+s,@bindir@,$bindir,;t t
+s,@sbindir@,$sbindir,;t t
+s,@libexecdir@,$libexecdir,;t t
+s,@datadir@,$datadir,;t t
+s,@sysconfdir@,$sysconfdir,;t t
+s,@sharedstatedir@,$sharedstatedir,;t t
+s,@localstatedir@,$localstatedir,;t t
+s,@libdir@,$libdir,;t t
+s,@includedir@,$includedir,;t t
+s,@oldincludedir@,$oldincludedir,;t t
+s,@infodir@,$infodir,;t t
+s,@mandir@,$mandir,;t t
+s,@build_alias@,$build_alias,;t t
+s,@host_alias@,$host_alias,;t t
+s,@target_alias@,$target_alias,;t t
+s,@DEFS@,$DEFS,;t t
+s,@ECHO_C@,$ECHO_C,;t t
+s,@ECHO_N@,$ECHO_N,;t t
+s,@ECHO_T@,$ECHO_T,;t t
+s,@LIBS@,$LIBS,;t t
+s,@GLUT_BUILD_PACKAGE@,$GLUT_BUILD_PACKAGE,;t t
+s,@CC@,$CC,;t t
+s,@CFLAGS@,$CFLAGS,;t t
+s,@LDFLAGS@,$LDFLAGS,;t t
+s,@CPPFLAGS@,$CPPFLAGS,;t t
+s,@ac_ct_CC@,$ac_ct_CC,;t t
+s,@EXEEXT@,$EXEEXT,;t t
+s,@OBJEXT@,$OBJEXT,;t t
+s,@CPP@,$CPP,;t t
+s,@X_CFLAGS@,$X_CFLAGS,;t t
+s,@X_PRE_LIBS@,$X_PRE_LIBS,;t t
+s,@X_LIBS@,$X_LIBS,;t t
+s,@X_EXTRA_LIBS@,$X_EXTRA_LIBS,;t t
+s,@build@,$build,;t t
+s,@build_cpu@,$build_cpu,;t t
+s,@build_vendor@,$build_vendor,;t t
+s,@build_os@,$build_os,;t t
+s,@host@,$host,;t t
+s,@host_cpu@,$host_cpu,;t t
+s,@host_vendor@,$host_vendor,;t t
+s,@host_os@,$host_os,;t t
+s,@target@,$target,;t t
+s,@target_cpu@,$target_cpu,;t t
+s,@target_vendor@,$target_vendor,;t t
+s,@target_os@,$target_os,;t t
+s,@GLU_FRAMEWORKS@,$GLU_FRAMEWORKS,;t t
+s,@GLUT_FRAMEWORKS@,$GLUT_FRAMEWORKS,;t t
+s,@GLUT_EXTRA_LIBS@,$GLUT_EXTRA_LIBS,;t t
+s,@GL_CFLAGS@,$GL_CFLAGS,;t t
+s,@GL_LIBS@,$GL_LIBS,;t t
+s,@GLU_CFLAGS@,$GLU_CFLAGS,;t t
+s,@GLU_LIBS@,$GLU_LIBS,;t t
+s,@EGREP@,$EGREP,;t t
+s,@GLUT_CFLAGS@,$GLUT_CFLAGS,;t t
+s,@GLUT_LIBS@,$GLUT_LIBS,;t t
+s,@BUILD_PACKAGE_BOOL@,$BUILD_PACKAGE_BOOL,;t t
+s,@CALLCONV@,$CALLCONV,;t t
+s,@LIBOBJS@,$LIBOBJS,;t t
+s,@LTLIBOBJS@,$LTLIBOBJS,;t t
+CEOF
+
+_ACEOF
+
+  cat >>$CONFIG_STATUS <<\_ACEOF
+  # Split the substitutions into bite-sized pieces for seds with
+  # small command number limits, like on Digital OSF/1 and HP-UX.
+  ac_max_sed_lines=48
+  ac_sed_frag=1 # Number of current file.
+  ac_beg=1 # First line for current file.
+  ac_end=$ac_max_sed_lines # Line after last line for current file.
+  ac_more_lines=:
+  ac_sed_cmds=
+  while $ac_more_lines; do
+    if test $ac_beg -gt 1; then
+      sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+    else
+      sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+    fi
+    if test ! -s $tmp/subs.frag; then
+      ac_more_lines=false
+    else
+      # The purpose of the label and of the branching condition is to
+      # speed up the sed processing (if there are no `@' at all, there
+      # is no need to browse any of the substitutions).
+      # These are the two extra sed commands mentioned above.
+      (echo ':t
+  /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+      if test -z "$ac_sed_cmds"; then
+  	ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+      else
+  	ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+      fi
+      ac_sed_frag=`expr $ac_sed_frag + 1`
+      ac_beg=$ac_end
+      ac_end=`expr $ac_end + $ac_max_sed_lines`
+    fi
+  done
+  if test -z "$ac_sed_cmds"; then
+    ac_sed_cmds=cat
+  fi
+fi # test -n "$CONFIG_FILES"
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case $ac_file in
+  - | *:- | *:-:* ) # input from stdin
+        cat >$tmp/stdin
+        ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  * )   ac_file_in=$ac_file.in ;;
+  esac
+
+  # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
+  ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$ac_file" : 'X\(//\)[^/]' \| \
+         X"$ac_file" : 'X\(//\)$' \| \
+         X"$ac_file" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+  { if $as_mkdir_p; then
+    mkdir -p "$ac_dir"
+  else
+    as_dir="$ac_dir"
+    as_dirs=
+    while test ! -d "$as_dir"; do
+      as_dirs="$as_dir $as_dirs"
+      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$as_dir" : 'X\(//\)[^/]' \| \
+         X"$as_dir" : 'X\(//\)$' \| \
+         X"$as_dir" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+    done
+    test ! -n "$as_dirs" || mkdir $as_dirs
+  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+   { (exit 1); exit 1; }; }; }
+
+  ac_builddir=.
+
+if test "$ac_dir" != .; then
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A "../" for each directory in $ac_dir_suffix.
+  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+  ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+  .)  # No --srcdir option.  We are building in place.
+    ac_srcdir=.
+    if test -z "$ac_top_builddir"; then
+       ac_top_srcdir=.
+    else
+       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+    fi ;;
+  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir ;;
+  *) # Relative path.
+    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
+# absolute.
+ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
+ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
+ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
+ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
+
+
+
+  if test x"$ac_file" != x-; then
+    { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+    rm -f "$ac_file"
+  fi
+  # 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.  */
+  if test x"$ac_file" = x-; then
+    configure_input=
+  else
+    configure_input="$ac_file.  "
+  fi
+  configure_input=$configure_input"Generated from `echo $ac_file_in |
+                                     sed 's,.*/,,'` by configure."
+
+  # First look for the input files in the build tree, otherwise in the
+  # src tree.
+  ac_file_inputs=`IFS=:
+    for f in $ac_file_in; do
+      case $f in
+      -) echo $tmp/stdin ;;
+      [\\/$]*)
+         # Absolute (can't be DOS-style, as IFS=:)
+         test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         echo $f;;
+      *) # Relative
+         if test -f "$f"; then
+           # Build tree
+           echo $f
+         elif test -f "$srcdir/$f"; then
+           # Source tree
+           echo $srcdir/$f
+         else
+           # /dev/null tree
+           { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         fi;;
+      esac
+    done` || { (exit 1); exit 1; }
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+  sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s,@configure_input@,$configure_input,;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,@top_builddir@,$ac_top_builddir,;t t
+s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
+" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
+  rm -f $tmp/stdin
+  if test x"$ac_file" != x-; then
+    mv $tmp/out $ac_file
+  else
+    cat $tmp/out
+    rm -f $tmp/out
+  fi
+
+done
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+#
+# CONFIG_HEADER section.
+#
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s,^\([ 	]*\)#\([ 	]*define[ 	][ 	]*\)'
+ac_dB='[ 	].*$,\1#\2'
+ac_dC=' '
+ac_dD=',;t'
+# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_uA='s,^\([ 	]*\)#\([ 	]*\)undef\([ 	][ 	]*\)'
+ac_uB='$,\1#\2define\3'
+ac_uC=' '
+ac_uD=',;t'
+
+for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case $ac_file in
+  - | *:- | *:-:* ) # input from stdin
+        cat >$tmp/stdin
+        ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  * )   ac_file_in=$ac_file.in ;;
+  esac
+
+  test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+
+  # First look for the input files in the build tree, otherwise in the
+  # src tree.
+  ac_file_inputs=`IFS=:
+    for f in $ac_file_in; do
+      case $f in
+      -) echo $tmp/stdin ;;
+      [\\/$]*)
+         # Absolute (can't be DOS-style, as IFS=:)
+         test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         echo $f;;
+      *) # Relative
+         if test -f "$f"; then
+           # Build tree
+           echo $f
+         elif test -f "$srcdir/$f"; then
+           # Source tree
+           echo $srcdir/$f
+         else
+           # /dev/null tree
+           { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         fi;;
+      esac
+    done` || { (exit 1); exit 1; }
+  # Remove the trailing spaces.
+  sed 's/[ 	]*$//' $ac_file_inputs >$tmp/in
+
+_ACEOF
+
+# Transform confdefs.h into two sed scripts, `conftest.defines' and
+# `conftest.undefs', that substitutes the proper values into
+# config.h.in to produce config.h.  The first handles `#define'
+# templates, and the second `#undef' templates.
+# And first: Protect against being on the right side of a sed subst in
+# config.status.  Protect against being in an unquoted here document
+# in config.status.
+rm -f conftest.defines conftest.undefs
+# Using a here document instead of a string reduces the quoting nightmare.
+# Putting comments in sed scripts is not portable.
+#
+# `end' is used to avoid that the second main sed command (meant for
+# 0-ary CPP macros) applies to n-ary macro definitions.
+# See the Autoconf documentation for `clear'.
+cat >confdef2sed.sed <<\_ACEOF
+s/[\\&,]/\\&/g
+s,[\\$`],\\&,g
+t clear
+: clear
+s,^[ 	]*#[ 	]*define[ 	][ 	]*\([^ 	(][^ 	(]*\)\(([^)]*)\)[ 	]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
+t end
+s,^[ 	]*#[ 	]*define[ 	][ 	]*\([^ 	][^ 	]*\)[ 	]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
+: end
+_ACEOF
+# If some macros were called several times there might be several times
+# the same #defines, which is useless.  Nevertheless, we may not want to
+# sort them, since we want the *last* AC-DEFINE to be honored.
+uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
+sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
+rm -f confdef2sed.sed
+
+# This sed command replaces #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.
+cat >>conftest.undefs <<\_ACEOF
+s,^[ 	]*#[ 	]*undef[ 	][ 	]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
+_ACEOF
+
+# Break up conftest.defines because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo '  # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
+echo '  if grep "^[ 	]*#[ 	]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
+echo '  # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
+echo '  :' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.defines >/dev/null
+do
+  # Write a limited-size here document to $tmp/defines.sed.
+  echo '  cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
+  # Speed up: don't consider the non `#define' lines.
+  echo '/^[ 	]*#[ 	]*define/!b' >>$CONFIG_STATUS
+  # Work around the forget-to-reset-the-flag bug.
+  echo 't clr' >>$CONFIG_STATUS
+  echo ': clr' >>$CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
+  echo 'CEOF
+  sed -f $tmp/defines.sed $tmp/in >$tmp/out
+  rm -f $tmp/in
+  mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
+  rm -f conftest.defines
+  mv conftest.tail conftest.defines
+done
+rm -f conftest.defines
+echo '  fi # grep' >>$CONFIG_STATUS
+echo >>$CONFIG_STATUS
+
+# Break up conftest.undefs because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo '  # Handle all the #undef templates' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.undefs >/dev/null
+do
+  # Write a limited-size here document to $tmp/undefs.sed.
+  echo '  cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
+  # Speed up: don't consider the non `#undef'
+  echo '/^[ 	]*#[ 	]*undef/!b' >>$CONFIG_STATUS
+  # Work around the forget-to-reset-the-flag bug.
+  echo 't clr' >>$CONFIG_STATUS
+  echo ': clr' >>$CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
+  echo 'CEOF
+  sed -f $tmp/undefs.sed $tmp/in >$tmp/out
+  rm -f $tmp/in
+  mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
+  rm -f conftest.undefs
+  mv conftest.tail conftest.undefs
+done
+rm -f conftest.undefs
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+  # 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.  */
+  if test x"$ac_file" = x-; then
+    echo "/* Generated by configure.  */" >$tmp/config.h
+  else
+    echo "/* $ac_file.  Generated by configure.  */" >$tmp/config.h
+  fi
+  cat $tmp/in >>$tmp/config.h
+  rm -f $tmp/in
+  if test x"$ac_file" != x-; then
+    if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
+      { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$ac_file" : 'X\(//\)[^/]' \| \
+         X"$ac_file" : 'X\(//\)$' \| \
+         X"$ac_file" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+      { if $as_mkdir_p; then
+    mkdir -p "$ac_dir"
+  else
+    as_dir="$ac_dir"
+    as_dirs=
+    while test ! -d "$as_dir"; do
+      as_dirs="$as_dir $as_dirs"
+      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$as_dir" : 'X\(//\)[^/]' \| \
+         X"$as_dir" : 'X\(//\)$' \| \
+         X"$as_dir" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+    done
+    test ! -n "$as_dirs" || mkdir $as_dirs
+  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+   { (exit 1); exit 1; }; }; }
+
+      rm -f $ac_file
+      mv $tmp/config.h $ac_file
+    fi
+  else
+    cat $tmp/config.h
+    rm -f $tmp/config.h
+  fi
+done
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+
+# 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 || { (exit 1); exit 1; }
+fi
+
diff --git a/configure.ac b/configure.ac
new file mode 100644
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,76 @@
+AC_INIT([Haskell GLUT package], [2.0], [sven.panne@aedion.de], [GLUT])
+
+# Safety check: Ensure that we are in the correct source directory.
+AC_CONFIG_SRCDIR([include/HsGLUT.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/HsGLUTConfig.h include/HsGLUT.h])
+
+# We set this to "yes" later when we have found GLUT libs and headers.
+GLUT_BUILD_PACKAGE=no
+AC_SUBST([GLUT_BUILD_PACKAGE])
+
+# Shall we build this package at all?
+FP_ARG_GLUT
+
+if test x"$enable_glut" = xyes; then
+
+# Check for GLUT include paths and libraries
+FP_CHECK_GLUT
+
+if test "$GLUT_LIBS" = no; then
+  AC_MSG_WARN([no GLUT library found, so this package will not be built])
+else
+
+# check for GLUT include files
+glut_found_header=no
+fp_save_cppflags="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h], [glut_found_header=yes])
+CPPFLAGS="$fp_save_cppflags"
+
+if test "$glut_found_header" = no; then
+  AC_MSG_WARN([no GLUT header found, so this package will not be built])
+else
+
+GLUT_BUILD_PACKAGE=yes
+
+AC_CHECK_HEADERS([windows.h])
+
+AC_DEFINE_UNQUOTED([GLUT_EXTRA_LIBS],
+  [`echo HSGLUT_cbits $GLUT_EXTRA_LIBS | sed -e 's/[[^ ]]*/,"&"/g' -e 's/^ *,//'`],
+  [Extra libraries for GLUT, as a list of string literals.])
+
+AC_DEFINE_UNQUOTED([GLUT_CFLAGS],
+  [`echo '' $GLUT_CFLAGS | sed -e 's/-[[^ ]]*/,"&"/g' -e 's/^ *,//'`],
+  [C flags for GLUT, as a list of string literals.])
+
+AC_DEFINE_UNQUOTED([GLUT_LIBS],
+  [`echo '' $GLUT_LIBS | sed -e 's/-[[^ ]]*/,"&"/g' -e 's/^ *,//'`],
+  [Library flags for GLUT, as a list of string literals.])
+
+AC_DEFINE_UNQUOTED([GLUT_FRAMEWORKS],
+  [`echo '' $GLUT_FRAMEWORKS | sed -e 's/-[[^ ]]*/,"&"/g' -e 's/^ *,//'`],
+  [Framework flags for GLUT, as a list of string literals.])
+
+fi
+fi
+fi
+
+if test "$GLUT_BUILD_PACKAGE" = yes; 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([config.mk GLUT.buildinfo])
+AC_OUTPUT
diff --git a/include/HsGLUT.h.in b/include/HsGLUT.h.in
new file mode 100644
--- /dev/null
+++ b/include/HsGLUT.h.in
@@ -0,0 +1,46 @@
+/* -----------------------------------------------------------------------------
+ *
+ * Module      :  C support for Graphics.UI.GLUT.Fonts
+ * Copyright   :  (c) Sven Panne 2002-2005
+ * License     :  BSD-style (see the file libraries/GLUT/LICENSE)
+ * 
+ * Maintainer  :  sven.panne@aedion.de
+ * Stability   :  provisional
+ * Portability :  portable
+ *
+ * -------------------------------------------------------------------------- */
+
+#ifndef HSGLUT_H
+#define HSGLUT_H
+
+/* Define to 1 if you have the <GL/glut.h> header file. */
+#undef HAVE_GL_GLUT_H
+
+/* Define to 1 if you have the <windows.h> header file. */
+#undef HAVE_WINDOWS_H
+
+/* Define to 1 if native OpenGL should be used on Mac OS X */
+#undef USE_QUARTZ_OPENGL
+
+#ifdef USE_QUARTZ_OPENGL /* Mac OS X only */
+#include <GLUT/glut.h>
+#else
+#if HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+#if HAVE_GL_GLUT_H
+#include <GL/glut.h>
+#else
+#include "glut_local.h"
+#endif
+#endif
+
+#if FREEGLUT
+#include <GL/freeglut_ext.h>
+#endif
+
+extern void* hs_GLUT_marshalBitmapFont(int fontID);
+extern void* hs_GLUT_marshalStrokeFont(int fontID);
+extern void* hs_GLUT_getProcAddress(char *procName);
+
+#endif
diff --git a/include/HsGLUTConfig.h.in b/include/HsGLUTConfig.h.in
new file mode 100644
--- /dev/null
+++ b/include/HsGLUTConfig.h.in
@@ -0,0 +1,73 @@
+/* include/HsGLUTConfig.h.in.  Generated from configure.ac by autoheader.  */
+
+/* C flags for GLUT, as a list of string literals. */
+#undef GLUT_CFLAGS
+
+/* Extra libraries for GLUT, as a list of string literals. */
+#undef GLUT_EXTRA_LIBS
+
+/* Framework flags for GLUT, as a list of string literals. */
+#undef GLUT_FRAMEWORKS
+
+/* Library flags for GLUT, as a list of string literals. */
+#undef GLUT_LIBS
+
+/* Define to 1 if you have the <GLUT/glut.h> header file. */
+#undef HAVE_GLUT_GLUT_H
+
+/* Define to 1 if you have the <GL/glut.h> header file. */
+#undef HAVE_GL_GLUT_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 <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 1 if you have the <windows.h> header file. */
+#undef HAVE_WINDOWS_H
+
+/* 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 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/HsGLUTExt.h b/include/HsGLUTExt.h
new file mode 100644
--- /dev/null
+++ b/include/HsGLUTExt.h
@@ -0,0 +1,29 @@
+/* -----------------------------------------------------------------------------
+ *
+ * Module      :  GLUT extension support for Graphics.UI.GLUT
+ * 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 HSGLUTEXT_H
+#define HSGLUTEXT_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(_saftey,_msg,_entry,_ty)			\
+foreign import CALLCONV _saftey "dynamic" dyn_/**/_entry :: Graphics.UI.GLUT.Extensions.Invoker (_ty) ; \
+_entry :: (_ty) ; \
+_entry = dyn_/**/_entry ptr_/**/_entry ; \
+ptr_/**/_entry :: FunPtr a ; \
+ptr_/**/_entry = unsafePerformIO (Graphics.UI.GLUT.Extensions.getProcAddress (_msg) ("_entry")) ; \
+{-# NOINLINE ptr_/**/_entry #-}
+
+#endif
diff --git a/install-sh b/install-sh
new file mode 100644
--- /dev/null
+++ b/install-sh
@@ -0,0 +1,295 @@
+#!/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:
