diff -Naur ghc/libraries/ALUT/aclocal.m4 ghc/libraries/ALUT/aclocal.m4
--- ghc/libraries/ALUT/aclocal.m4	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/aclocal.m4	2006-05-08 21:52:51.000000000 +0200
@@ -81,9 +81,13 @@
   ALUT_FRAMEWORKS=ALUT
   ;;
 *)
+  AL_LIBS=no
+  AC_SEARCH_LIBS([alGenSources], [openal openal32], [AL_LIBS="$ac_cv_search_alGenSources"])
+  test x"$AL_LIBS" = x"none required" && AL_LIBS=
+
   fp_save_libs="$LIBS"
-  LIBS="$LIBS -lopenal"
-  AC_SEARCH_LIBS([alutGetMajorVersion], [alut alut32], [ALUT_LIBS="$ac_cv_search_alutGetMajorVersion"])
+  LIBS="$AL_LIBS $LIBS"
+  AC_SEARCH_LIBS([alutExit], [alut alut32], [ALUT_LIBS="$ac_cv_search_alutExit"])
   test x"$ALUT_LIBS" = x"none required" && ALUT_LIBS=
   LIBS="$fp_save_libs"
   ALUT_FRAMEWORKS=
@@ -105,3 +109,71 @@
   AC_CHECK_HEADERS([AL/alut.h OpenAL/alut.h], [fp_found_alut_header=yes; break])
 fi
 ]) # FP_HEADER_AL
+
+
+# FP_CHECK_FUNC_ALUT(FUNCTION, ARGUMENTS)
+# ---------------------------------------
+AC_DEFUN([FP_CHECK_FUNC_ALUT],
+[AS_VAR_PUSHDEF([alut_var], [alut_cv_func_$1])dnl
+AC_CACHE_CHECK([for $1],
+  alut_var,
+  [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_AL_ALUT_H
+#include <AL/alut.h>
+#elif HAVE_OPENAL_ALUT_H
+#include <OpenAL/alut.h>
+#endif]],
+                    [$1 $2;])],
+                  [AS_VAR_SET(alut_var, yes)],
+                  [AS_VAR_SET(alut_var, no)])])
+if test AS_VAR_GET(alut_var) = yes; then
+  AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), [1],
+                    [Define to 1 if you have the `$1' function.])
+fi
+AS_VAR_POPDEF([alut_var])dnl
+])# FP_CHECK_FUNC_ALUT
+
+
+# FP_FUNC_ALUTINIT_VOID
+# ---------------------
+# Defines ALUTINIT_VOID to 1 if `alutInit' returns void.
+AC_DEFUN([FP_FUNC_ALUTINIT_VOID],
+[AC_REQUIRE([FP_HEADER_ALUT])
+AC_CACHE_CHECK([whether alutInit returns void],
+  [fp_cv_func_alutInit_void],
+  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
+#if HAVE_AL_ALUT_H
+#include <AL/alut.h>
+#elif HAVE_OPENAL_ALUT_H
+#include <OpenAL/alut.h>
+#endif
+],
+ [[int x = (int)alutInit((int *)0, (char **)0);]])],
+ [fp_cv_func_alutInit_void=no],
+ [fp_cv_func_alutInit_void=yes])])
+if test x"$fp_cv_func_alutInit_void" = xyes; then
+  AC_DEFINE([ALUTINIT_VOID], [1], [Define to 1 if `alutInit' returns void.])
+fi
+]) # FP_FUNC_ALUTINIT_VOID
+
+
+# FP_FUNC_ALUTEXIT_VOID
+# ---------------------
+# Defines ALUTEXIT_VOID to 1 if `alutExit' returns void.
+AC_DEFUN([FP_FUNC_ALUTEXIT_VOID],
+[AC_REQUIRE([FP_HEADER_ALUT])
+AC_CACHE_CHECK([whether alutExit returns void],
+  [fp_cv_func_alutExit_void],
+  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
+#if HAVE_AL_ALUT_H
+#include <AL/alut.h>
+#elif HAVE_OPENAL_ALUT_H
+#include <OpenAL/alut.h>
+#endif
+],
+ [[int x = (int)alutExit();]])],
+ [fp_cv_func_alutExit_void=no],
+ [fp_cv_func_alutExit_void=yes])])
+if test x"$fp_cv_func_alutExit_void" = xyes; then
+  AC_DEFINE([ALUTEXIT_VOID], [1], [Define to 1 if `alutExit' returns void.])
+fi
+]) # FP_FUNC_ALUTEXIT_VOID
diff -Naur ghc/libraries/ALUT/ALUT.cabal ghc/libraries/ALUT/ALUT.cabal
--- ghc/libraries/ALUT/ALUT.cabal	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/ALUT.cabal	2006-05-08 21:52:51.000000000 +0200
@@ -1,5 +1,5 @@
 name:		ALUT
-version:	1.0
+version:	2.0
 license:	BSD3
 license-file:	LICENSE
 maintainer:	Sven Panne <sven.panne@aedion.de>
@@ -23,12 +23,12 @@
 	config.mk ALUT.buildinfo include/HsALUTConfig.h include/HsALUT.h
 exposed-modules:
 	Sound.ALUT,
-	Sound.ALUT.BuiltInSounds,
 	Sound.ALUT.Initialization,
 	Sound.ALUT.Loaders,
 	Sound.ALUT.Sleep,
 	Sound.ALUT.Version
 other-modules:
+	Sound.ALUT.Config,
 	Sound.ALUT.Constants,
 	Sound.ALUT.Errors
 include-dirs:	include
diff -Naur ghc/libraries/ALUT/configure.ac ghc/libraries/ALUT/configure.ac
--- ghc/libraries/ALUT/configure.ac	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/configure.ac	2006-05-08 21:52:51.000000000 +0200
@@ -1,4 +1,4 @@
-AC_INIT([Haskell ALUT package], [1.0], [sven.panne@aedion.de], [ALUT])
+AC_INIT([Haskell ALUT package], [2.0], [sven.panne@aedion.de], [ALUT])
 
 # Safety check: Ensure that we are in the correct source directory.
 AC_CONFIG_SRCDIR([include/HsALUT.h.in])
@@ -33,12 +33,83 @@
 
 ALUT_BUILD_PACKAGE=yes
 
+# checks for library functions.
+
+fp_save_libs="$LIBS"
+LIBS="$ALUT_LIBS $AL_LIBS $LIBS"
+
+FP_FUNC_ALUTINIT_VOID
+FP_CHECK_FUNC_ALUT([alutInitWithoutContext], [((int *)0, (char **)0)])
+FP_FUNC_ALUTEXIT_VOID
+
+FP_CHECK_FUNC_ALUT([alutGetError], [()])
+FP_CHECK_FUNC_ALUT([alutGetErrorString], [(0)])
+
+FP_CHECK_FUNC_ALUT([alutCreateBufferFromFile], [((const char *)0)])
+FP_CHECK_FUNC_ALUT([alutCreateBufferFromFileImage], [((const ALvoid *)0, 0)])
+FP_CHECK_FUNC_ALUT([alutCreateBufferHelloWorld], [()])
+FP_CHECK_FUNC_ALUT([alutCreateBufferWaveform], [(0, 0.0f, 0.0f, 0.0f)])
+
+FP_CHECK_FUNC_ALUT([alutLoadMemoryFromFile], [((const char *)0, (ALenum *)0, (ALsizei *)0, (ALfloat *)0)])
+FP_CHECK_FUNC_ALUT([alutLoadMemoryFromFileImage], [((const ALvoid *)0, 0, (ALenum *)0, (ALsizei *)0, (ALfloat *)0)])
+FP_CHECK_FUNC_ALUT([alutLoadMemoryHelloWorld], [((ALenum *)0, (ALsizei *)0, (ALfloat *)0)])
+FP_CHECK_FUNC_ALUT([alutLoadMemoryWaveform], [(0, 0.0f, 0.0f, 0.0f, (ALenum *)0, (ALsizei *)0, (ALfloat *)0)])
+
+FP_CHECK_FUNC_ALUT([alutGetMIMETypes], [(0)])
+
+FP_CHECK_FUNC_ALUT([alutGetMajorVersion], [()])
+FP_CHECK_FUNC_ALUT([alutGetMinorVersion], [()])
+
+FP_CHECK_FUNC_ALUT([alutSleep], [(0.0f)])
+
+LIBS="$fp_save_libs"
+
+# checks for constant values
+
 FP_CHECK_CONSTS([ALUT_API_MAJOR_VERSION ALUT_API_MINOR_VERSION ALUT_WAVEFORM_SINE ALUT_WAVEFORM_SQUARE ALUT_WAVEFORM_SAWTOOTH ALUT_WAVEFORM_WHITENOISE ALUT_WAVEFORM_IMPULSE ALUT_LOADER_BUFFER ALUT_LOADER_MEMORY], [#if HAVE_AL_ALUT_H
 #include <AL/alut.h>
 #elif HAVE_OPENAL_ALUT_H
 #include <OpenAL/alut.h>
+#endif
+
+#ifndef ALUT_API_MAJOR_VERSION
+#define ALUT_API_MAJOR_VERSION   0
+#endif
+
+#ifndef ALUT_API_MINOR_VERSION
+#define ALUT_API_MINOR_VERSION   0
+#endif
+
+#ifndef ALUT_WAVEFORM_SINE
+#define ALUT_WAVEFORM_SINE       0x100
+#endif
+
+#ifndef ALUT_WAVEFORM_SQUARE
+#define ALUT_WAVEFORM_SQUARE     0x101
+#endif
+
+#ifndef ALUT_WAVEFORM_SAWTOOTH
+#define ALUT_WAVEFORM_SAWTOOTH   0x102
+#endif
+
+#ifndef ALUT_WAVEFORM_WHITENOISE
+#define ALUT_WAVEFORM_WHITENOISE 0x103
+#endif
+
+#ifndef ALUT_WAVEFORM_IMPULSE
+#define ALUT_WAVEFORM_IMPULSE    0x104
+#endif
+
+#ifndef ALUT_LOADER_BUFFER
+#define ALUT_LOADER_BUFFER       0x300
+#endif
+
+#ifndef ALUT_LOADER_MEMORY
+#define ALUT_LOADER_MEMORY       0x301
 #endif])
 
+# tell our build system about the results
+
 AC_DEFINE_UNQUOTED([ALUT_CFLAGS],
   [`echo '' $ALUT_CFLAGS | sed -e 's/-[[^ ]]*/,"&"/g' -e 's/^ *,//'`],
   [C flags for ALUT, as a list of string literals.])
diff -Naur ghc/libraries/ALUT/examples/Basic/HelloWorld.hs ghc/libraries/ALUT/examples/Basic/HelloWorld.hs
--- ghc/libraries/ALUT/examples/Basic/HelloWorld.hs	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/examples/Basic/HelloWorld.hs	2006-05-08 21:52:51.000000000 +0200
@@ -13,7 +13,7 @@
 main :: IO ()
 main =
    withProgNameAndArgs runALUT $ \_progName _args -> do
-      helloBuffer <- helloWorld
+      helloBuffer <- createBuffer HelloWorld
       [helloSource] <- genObjectNames 1
       buffer helloSource $= Just helloBuffer
       play [helloSource]
diff -Naur ghc/libraries/ALUT/examples/TestSuite/TestWaveforms.hs ghc/libraries/ALUT/examples/TestSuite/TestWaveforms.hs
--- ghc/libraries/ALUT/examples/TestSuite/TestWaveforms.hs	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/examples/TestSuite/TestWaveforms.hs	2006-05-08 21:52:51.000000000 +0200
@@ -9,9 +9,9 @@
 
 -- This program plays a 440Hz tone using a variety of waveforms.
 
-playTone :: (Frequency -> Phase -> Duration -> IO Buffer) -> IO ()
-playTone makeBuffer = do
-   buf <- makeBuffer 440 0 1
+playTone :: (Frequency -> Phase -> Duration -> SoundDataSource a) -> IO ()
+playTone soundDataSource = do
+   buf <- createBuffer (soundDataSource 440 0 1)
    [source] <- genObjectNames 1
    buffer source $= Just buf
    play [source]
@@ -20,4 +20,4 @@
 main :: IO ()
 main =
    withProgNameAndArgs runALUT $ \_progName _args ->
-      mapM_ playTone [ sine, square, sawtooth, (const (const whiteNoise)), impulse ]
+      mapM_ playTone [ Sine, Square, Sawtooth, (const (const WhiteNoise)), Impulse ]
diff -Naur ghc/libraries/ALUT/package.conf.in ghc/libraries/ALUT/package.conf.in
--- ghc/libraries/ALUT/package.conf.in	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/package.conf.in	2006-05-08 21:52:51.000000000 +0200
@@ -8,13 +8,13 @@
 
 exposed-modules:
 	Sound.ALUT,
-	Sound.ALUT.BuiltInSounds,
 	Sound.ALUT.Initialization,
 	Sound.ALUT.Loaders,
 	Sound.ALUT.Sleep,
 	Sound.ALUT.Version
 
 hidden-modules:
+	Sound.ALUT.Config,
 	Sound.ALUT.Constants,
 	Sound.ALUT.Errors
 
diff -Naur ghc/libraries/ALUT/Sound/ALUT/BuiltInSounds.hs ghc/libraries/ALUT/Sound/ALUT/BuiltInSounds.hs
--- ghc/libraries/ALUT/Sound/ALUT/BuiltInSounds.hs	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/Sound/ALUT/BuiltInSounds.hs	1970-01-01 01:00:00.000000000 +0100
@@ -1,60 +0,0 @@
---------------------------------------------------------------------------------
--- |
--- Module      :  Sound.ALUT.BuiltInSounds
--- Copyright   :  (c) Sven Panne 2005
--- License     :  BSD-style (see the file libraries/ALUT/LICENSE)
--- 
--- Maintainer  :  sven.panne@aedion.de
--- Stability   :  provisional
--- Portability :  portable
---
---------------------------------------------------------------------------------
-
-module Sound.ALUT.BuiltInSounds (
-   helloWorld, Phase, Duration, sine, square, sawtooth, impulse, whiteNoise
-)  where
-
-import Sound.ALUT.Constants (
-   alut_WAVEFORM_SINE, alut_WAVEFORM_SQUARE, alut_WAVEFORM_SAWTOOTH,
-   alut_WAVEFORM_WHITENOISE, alut_WAVEFORM_IMPULSE )
-import Sound.ALUT.Errors ( makeBuffer )
-import Sound.OpenAL.AL.BasicTypes ( ALuint, ALenum, ALfloat )
-import Sound.OpenAL.AL.Buffer ( Buffer )
-import Sound.OpenAL.ALC.Context ( Frequency )
-
---------------------------------------------------------------------------------
-
-helloWorld :: IO Buffer
-helloWorld = makeBuffer "helloWorld" alutCreateBufferHelloWorld
-
-foreign import CALLCONV unsafe "alutCreateBufferHelloWorld"
-   alutCreateBufferHelloWorld :: IO ALuint
-
---------------------------------------------------------------------------------
-
-type Phase = Float
-
-type Duration = Float
-
-sine :: Frequency -> Phase -> Duration -> IO Buffer
-sine = createBufferWaveform "sine" alut_WAVEFORM_SINE
-
-square :: Frequency -> Phase -> Duration -> IO Buffer
-square = createBufferWaveform "square" alut_WAVEFORM_SQUARE
-
-sawtooth :: Frequency -> Phase -> Duration -> IO Buffer
-sawtooth = createBufferWaveform "sawtooth" alut_WAVEFORM_SAWTOOTH
-
-impulse :: Frequency -> Phase -> Duration -> IO Buffer
-impulse = createBufferWaveform "impulse" alut_WAVEFORM_IMPULSE
-
-whiteNoise :: Duration -> IO Buffer
-whiteNoise = createBufferWaveform "whiteNoise" alut_WAVEFORM_WHITENOISE 1 0
-
-createBufferWaveform :: String -> ALenum -> Frequency -> Phase -> Duration -> IO Buffer
-createBufferWaveform name shape frequency phase duration =
-   makeBuffer name $
-      alutCreateBufferWaveform shape frequency phase duration
-
-foreign import CALLCONV unsafe "alutCreateBufferWaveform"
-   alutCreateBufferWaveform :: ALenum -> ALfloat -> ALfloat -> ALfloat -> IO ALuint
diff -Naur ghc/libraries/ALUT/Sound/ALUT/Config.hs ghc/libraries/ALUT/Sound/ALUT/Config.hs
--- ghc/libraries/ALUT/Sound/ALUT/Config.hs	1970-01-01 01:00:00.000000000 +0100
+++ ghc/libraries/ALUT/Sound/ALUT/Config.hs	2006-05-08 21:52:51.000000000 +0200
@@ -0,0 +1,323 @@
+-- #hide
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Sound.ALUT.Config
+-- Copyright   :  (c) Sven Panne 2006
+-- License     :  BSD-style (see the file libraries/ALUT/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  provisional
+-- Portability :  portable
+--
+-- This purely internal module defines the platform-specific stuff which has
+-- been figured out by configure.
+--
+--------------------------------------------------------------------------------
+
+module Sound.ALUT.Config (
+   alut_Init,
+   alut_InitWithoutContext,
+   alut_Exit,
+
+   alut_GetError,
+   alut_GetErrorString,
+
+   alut_CreateBufferFromFile,
+   alut_CreateBufferFromFileImage,
+   alut_CreateBufferHelloWorld,
+   alut_CreateBufferWaveform,
+
+   alut_LoadMemoryFromFile,
+   alut_LoadMemoryFromFileImage,
+   alut_LoadMemoryHelloWorld,
+   alut_LoadMemoryWaveform,
+
+   alut_GetMIMETypes,
+
+   alut_GetMajorVersion,
+   alut_GetMinorVersion,
+
+   alut_Sleep
+) where
+
+--------------------------------------------------------------------------------
+
+#include "HsALUTConfig.h"
+
+--------------------------------------------------------------------------------
+
+import Foreign.C
+import Foreign.Ptr
+import Sound.OpenAL.AL.BasicTypes
+
+#if ALUTINIT_VOID || !HAVE_ALUTINITWITHOUTCONTEXT || ALUTEXIT_VOID || !HAVE_ALUTSLEEP
+import Sound.OpenAL.AL.ALboolean
+#endif
+
+#if !HAVE_ALUTCREATEBUFFERFROMFILE || !HAVE_ALUTCREATEBUFFERFROMFILEIMAGE || !HAVE_ALUTCREATEBUFFERHELLOWORLD || !HAVE_ALUTCREATEBUFFERWAVEFORM
+import Sound.OpenAL.AL.BufferInternal
+#endif
+
+#if !HAVE_ALUTSLEEP && defined(__GLASGOW_HASKELL__)
+import Control.Concurrent
+#endif
+
+
+--------------------------------------------------------------------------------
+
+#if ALUTINIT_VOID
+
+alut_Init :: Ptr CInt -> Ptr CString -> IO ALboolean
+alut_Init argc argv = alutInit argc argv >> return (marshalALboolean True)
+
+foreign import CALLCONV unsafe "alutInit"
+   alutInit :: Ptr CInt -> Ptr CString -> IO ()
+
+#else
+
+foreign import CALLCONV unsafe "alutInit"
+   alut_Init :: Ptr CInt -> Ptr CString -> IO ALboolean
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTINITWITHOUTCONTEXT
+
+foreign import CALLCONV unsafe "alutInitWithoutContext"
+   alut_InitWithoutContext :: Ptr CInt -> Ptr CString -> IO ALboolean
+
+#else
+
+alut_InitWithoutContext :: Ptr CInt -> Ptr CString -> IO ALboolean
+alut_InitWithoutContext _ _ = return (marshalALboolean True)
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if ALUTEXIT_VOID
+
+alut_Exit :: IO ALboolean
+alut_Exit = alutExit >> return (marshalALboolean True)
+
+foreign import CALLCONV unsafe "alutExit"
+   alutExit :: IO ()
+
+#else
+
+foreign import CALLCONV unsafe "alutExit"
+   alut_Exit :: IO ALboolean
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTGETERROR
+
+foreign import CALLCONV unsafe "alutGetError"
+   alut_GetError :: IO ALenum
+
+#else
+
+alut_GetError :: IO ALenum
+alut_GetError = return 0
+
+#endif
+
+--------------------------------------------------------------------------------
+
+alut_GetErrorString :: ALenum -> IO String
+
+#if HAVE_ALUTGETERRORSTRING
+
+alut_GetErrorString e = peekCString =<< alutGetErrorString e
+
+foreign import CALLCONV unsafe "alutGetErrorString"
+   alutGetErrorString :: ALenum -> IO CString
+
+#else
+
+alut_GetErrorString _ = return "<unknown ALUT error>"
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTCREATEBUFFERFROMFILE
+
+foreign import CALLCONV unsafe "alutCreateBufferFromFile"
+   alut_CreateBufferFromFile :: CString -> IO ALuint
+
+#else
+
+alut_CreateBufferFromFile :: CString -> IO ALuint
+alut_CreateBufferFromFile _ = return (marshalBuffer Nothing)
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTCREATEBUFFERFROMFILEIMAGE
+
+foreign import CALLCONV unsafe "alutCreateBufferFromFileImage"
+   alut_CreateBufferFromFileImage :: Ptr a -> ALsizei -> IO ALuint
+
+#else
+
+alut_CreateBufferFromFileImage :: Ptr a -> ALsizei -> IO ALuint
+alut_CreateBufferFromFileImage _ _ =  return (marshalBuffer Nothing)
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTCREATEBUFFERHELLOWORLD
+
+foreign import CALLCONV unsafe "alutCreateBufferHelloWorld"
+   alut_CreateBufferHelloWorld :: IO ALuint
+
+#else
+
+alut_CreateBufferHelloWorld :: IO ALuint
+alut_CreateBufferHelloWorld =  return (marshalBuffer Nothing)
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTCREATEBUFFERWAVEFORM
+
+foreign import CALLCONV unsafe "alutCreateBufferWaveform"
+   alut_CreateBufferWaveform :: ALenum -> ALfloat -> ALfloat -> ALfloat -> IO ALuint
+
+#else
+
+alut_CreateBufferWaveform :: ALenum -> ALfloat -> ALfloat -> ALfloat -> IO ALuint
+alut_CreateBufferWaveform _ _ _ _ =  return (marshalBuffer Nothing)
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTLOADMEMORYFROMFILE
+
+foreign import CALLCONV unsafe "alutLoadMemoryFromFile"
+   alut_LoadMemoryFromFile :: CString -> Ptr ALenum -> Ptr ALsizei -> Ptr ALfloat -> IO (Ptr b)
+
+#else
+
+alut_LoadMemoryFromFile :: CString -> Ptr ALenum -> Ptr ALsizei -> Ptr ALfloat -> IO (Ptr b)
+alut_LoadMemoryFromFile _ _ _ _ = return nullPtr
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTLOADMEMORYFROMFILEIMAGE
+
+foreign import CALLCONV unsafe "alutLoadMemoryFromFileImage"
+   alut_LoadMemoryFromFileImage :: Ptr a -> ALsizei -> Ptr ALenum -> Ptr ALsizei -> Ptr ALfloat -> IO (Ptr b)
+
+#else
+
+alut_LoadMemoryFromFileImage :: Ptr a -> ALsizei -> Ptr ALenum -> Ptr ALsizei -> Ptr ALfloat -> IO (Ptr b)
+alut_LoadMemoryFromFileImage _ _ _ _ _ = return nullPtr
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTLOADMEMORYHELLOWORLD
+
+foreign import CALLCONV unsafe "alutLoadMemoryHelloWorld"
+   alut_LoadMemoryHelloWorld :: Ptr ALenum -> Ptr ALsizei -> Ptr ALfloat -> IO (Ptr b)
+
+#else
+
+alut_LoadMemoryHelloWorld :: Ptr ALenum -> Ptr ALsizei -> Ptr ALfloat -> IO (Ptr b)
+alut_LoadMemoryHelloWorld _ _ _ = return nullPtr
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTLOADMEMORYWAVEFORM
+
+foreign import CALLCONV unsafe "alutLoadMemoryWaveform"
+   alut_LoadMemoryWaveform :: ALenum -> ALfloat -> ALfloat -> ALfloat -> Ptr ALenum -> Ptr ALsizei -> Ptr ALfloat -> IO (Ptr b)
+
+#else
+
+alut_LoadMemoryWaveform :: ALenum -> ALfloat -> ALfloat -> ALfloat -> Ptr ALenum -> Ptr ALsizei -> Ptr ALfloat -> IO (Ptr b)
+alut_LoadMemoryWaveform _ _ _ _ _ _ _ = return nullPtr
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTGETMIMETYPES
+
+foreign import CALLCONV unsafe "alutGetMIMETypes"
+   alut_GetMIMETypes :: ALenum -> IO CString
+
+#else
+
+alut_GetMIMETypes :: ALenum -> IO CString
+alut_GetMIMETypes _ = return nullPtr
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTGETMAJORVERSION
+
+foreign import CALLCONV unsafe "alutGetMajorVersion"
+   alut_GetMajorVersion :: IO ALint
+
+#else
+
+alut_GetMajorVersion :: IO ALint
+alut_GetMajorVersion = return 0
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTGETMINORVERSION
+
+foreign import CALLCONV unsafe "alutGetMinorVersion"
+   alut_GetMinorVersion :: IO ALint
+
+#else
+
+alut_GetMinorVersion :: IO ALint
+alut_GetMinorVersion = return 0
+
+#endif
+
+--------------------------------------------------------------------------------
+
+#if HAVE_ALUTSLEEP
+
+foreign import CALLCONV unsafe "alutSleep"
+   alut_Sleep :: ALfloat -> IO ALboolean
+
+#else
+
+alut_Sleep :: ALfloat -> IO ALboolean
+alut_Sleep d = mySleep d  >> return (marshalALboolean True)
+
+mySleep :: ALfloat -> IO ()
+
+#if defined(__GLASGOW_HASKELL__)
+
+mySleep = threadDelay . round .  (* 1.0E6)
+
+#else
+
+mySleep = return ()
+
+#endif
+
+#endif
diff -Naur ghc/libraries/ALUT/Sound/ALUT/Constants.hs ghc/libraries/ALUT/Sound/ALUT/Constants.hs
--- ghc/libraries/ALUT/Sound/ALUT/Constants.hs	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/Sound/ALUT/Constants.hs	2006-05-08 21:52:51.000000000 +0200
@@ -28,12 +28,12 @@
 --------------------------------------------------------------------------------
 
 alut_WAVEFORM_SINE, alut_WAVEFORM_SQUARE, alut_WAVEFORM_SAWTOOTH,
-   alut_WAVEFORM_WHITENOISE, alut_WAVEFORM_IMPULSE :: ALenum
+   alut_WAVEFORM_IMPULSE, alut_WAVEFORM_WHITENOISE :: ALenum
 alut_WAVEFORM_SINE                   = CONST_ALUT_WAVEFORM_SINE
 alut_WAVEFORM_SQUARE                 = CONST_ALUT_WAVEFORM_SQUARE
 alut_WAVEFORM_SAWTOOTH               = CONST_ALUT_WAVEFORM_SAWTOOTH
-alut_WAVEFORM_WHITENOISE             = CONST_ALUT_WAVEFORM_WHITENOISE
 alut_WAVEFORM_IMPULSE                = CONST_ALUT_WAVEFORM_IMPULSE
+alut_WAVEFORM_WHITENOISE             = CONST_ALUT_WAVEFORM_WHITENOISE
 
 --------------------------------------------------------------------------------
 
diff -Naur ghc/libraries/ALUT/Sound/ALUT/Errors.hs ghc/libraries/ALUT/Sound/ALUT/Errors.hs
--- ghc/libraries/ALUT/Sound/ALUT/Errors.hs	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/Sound/ALUT/Errors.hs	2006-05-08 21:52:51.000000000 +0200
@@ -17,12 +17,12 @@
 
 import Control.Monad ( when )
 import Data.Maybe ( fromJust, isNothing )
-import Foreign.C.String ( CString, peekCString )
 import Foreign.Ptr ( Ptr, nullPtr )
 import Sound.OpenAL.AL.ALboolean ( unmarshalALboolean )
-import Sound.OpenAL.AL.BasicTypes ( ALboolean, ALenum, ALuint )
+import Sound.OpenAL.AL.BasicTypes ( ALboolean, ALuint )
 import Sound.OpenAL.AL.Buffer ( Buffer )
 import Sound.OpenAL.AL.BufferInternal ( unmarshalBuffer )
+import Sound.ALUT.Config ( alut_GetError, alut_GetErrorString )
 
 --------------------------------------------------------------------------------
 
@@ -30,16 +30,10 @@
 throwIf failurePredicate name action = do
    returnValue <- action
    when (failurePredicate returnValue) $ do
-      description <- peekCString =<< alutGetErrorString =<< alutGetError
+      description <- alut_GetErrorString =<< alut_GetError
       ioError (userError (name ++ ": " ++ description))
    return returnValue
 
-foreign import CALLCONV unsafe "alutGetError"
-   alutGetError :: IO ALenum
-
-foreign import CALLCONV unsafe "alutGetErrorString"
-   alutGetErrorString :: ALenum -> IO CString
-
 --------------------------------------------------------------------------------
 
 throwIfALfalse :: String -> IO ALboolean -> IO ()
diff -Naur ghc/libraries/ALUT/Sound/ALUT/Initialization.hs ghc/libraries/ALUT/Sound/ALUT/Initialization.hs
--- ghc/libraries/ALUT/Sound/ALUT/Initialization.hs	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/Sound/ALUT/Initialization.hs	2006-05-08 21:52:51.000000000 +0200
@@ -23,6 +23,7 @@
 import Foreign.Ptr ( Ptr, nullPtr )
 import Foreign.Storable ( Storable(peek) )
 import Sound.ALUT.Errors ( throwIfALfalse )
+import Sound.ALUT.Config ( alut_Init, alut_InitWithoutContext, alut_Exit )
 import Sound.OpenAL.AL.BasicTypes ( ALboolean )
 import System.Environment ( getProgName, getArgs )
 
@@ -46,25 +47,18 @@
 --------------------------------------------------------------------------------
 
 runALUT :: ArgumentConsumer (Runner a)
-runALUT = runner "runALUT" alutInit
-
-type InitAction = Ptr CInt -> Ptr CString -> IO ALboolean
-
-foreign import CALLCONV unsafe "alutInit"
-   alutInit :: InitAction
+runALUT = runner "runALUT" alut_Init
 
 --------------------------------------------------------------------------------
 
 runALUTUsingCurrentContext :: ArgumentConsumer (Runner a)
 runALUTUsingCurrentContext =
-   runner "runALUTUsingCurrentContext" alutInitWithoutContext
-
-foreign import CALLCONV unsafe "alutInitWithoutContext"
-   alutInitWithoutContext :: InitAction
+   runner "runALUTUsingCurrentContext" alut_InitWithoutContext
 
 --------------------------------------------------------------------------------
 
-runner :: String -> InitAction -> String -> [String] -> Runner a
+runner :: String -> (Ptr CInt -> Ptr CString -> IO ALboolean) -> String
+       -> [String] -> Runner a
 runner name initAction progName args action =
    with (1 + genericLength args) $ \argcBuf ->
       withMany withCString (progName : args) $ \argvPtrs ->
@@ -74,10 +68,7 @@
             newArgvPtrs <- peekArray (fromIntegral newArgc) argvBuf
             newArgv <- mapM peekCString newArgvPtrs
             action (head newArgv) (tail newArgv)
-               `finally` throwIfALfalse name alutExit
-
-foreign import CALLCONV unsafe "alutExit"
-   alutExit :: IO ALboolean
+               `finally` throwIfALfalse name alut_Exit
 
 --------------------------------------------------------------------------------
 
diff -Naur ghc/libraries/ALUT/Sound/ALUT/Loaders.hs ghc/libraries/ALUT/Sound/ALUT/Loaders.hs
--- ghc/libraries/ALUT/Sound/ALUT/Loaders.hs	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/Sound/ALUT/Loaders.hs	2006-05-08 21:52:51.000000000 +0200
@@ -11,28 +11,49 @@
 --------------------------------------------------------------------------------
 
 module Sound.ALUT.Loaders (
-   SoundDataSource(..), createBuffer, createBufferData,
+   Phase, Duration, SoundDataSource(..),
+   createBuffer, createBufferData,
    bufferMIMETypes, bufferDataMIMETypes
 )  where
 
-import Foreign.C.String ( CString, peekCString, withCString )
+import Foreign.C.String ( peekCString, withCString )
 import Foreign.Marshal.Alloc ( alloca )
 import Foreign.Storable ( Storable(peek) )
 import Foreign.Ptr ( Ptr )
 import Graphics.Rendering.OpenGL.GL.StateVar (
    GettableStateVar, makeGettableStateVar )
-import Sound.ALUT.Constants ( alut_LOADER_BUFFER, alut_LOADER_MEMORY )
+import Sound.ALUT.Config (
+   alut_CreateBufferFromFile, alut_CreateBufferFromFileImage,
+   alut_CreateBufferHelloWorld, alut_CreateBufferWaveform,
+   alut_LoadMemoryFromFile, alut_LoadMemoryFromFileImage,
+   alut_LoadMemoryHelloWorld, alut_LoadMemoryWaveform,
+   alut_GetMIMETypes )
+import Sound.ALUT.Constants (
+   alut_WAVEFORM_SINE, alut_WAVEFORM_SQUARE, alut_WAVEFORM_SAWTOOTH,
+   alut_WAVEFORM_IMPULSE, alut_WAVEFORM_WHITENOISE,
+   alut_LOADER_BUFFER, alut_LOADER_MEMORY )
 import Sound.ALUT.Errors ( makeBuffer, throwIfNullPtr )
-import Sound.OpenAL.AL.BasicTypes ( ALuint, ALsizei, ALenum, ALfloat )
+import Sound.OpenAL.AL.BasicTypes ( ALsizei, ALenum, ALfloat )
 import Sound.OpenAL.AL.Buffer ( Buffer, MemoryRegion(..), BufferData(..) )
 import Sound.OpenAL.AL.Format ( unmarshalFormat )
+import Sound.OpenAL.ALC.Context ( Frequency )
 import System.IO ( FilePath )
 
 --------------------------------------------------------------------------------
 
+type Phase = Float
+
+type Duration = Float
+
 data SoundDataSource a =
      File FilePath
    | FileImage (MemoryRegion a)
+   | HelloWorld
+   | Sine Frequency Phase Duration
+   | Square Frequency Phase Duration
+   | Sawtooth Frequency Phase Duration
+   | Impulse Frequency Phase Duration
+   | WhiteNoise Duration
 #ifdef __HADDOCK__
 -- Help Haddock a bit, because it doesn't do any instance inference.
 instance Eq (SoundDataSource a)
@@ -45,26 +66,28 @@
 --------------------------------------------------------------------------------
 
 createBuffer :: SoundDataSource a -> IO Buffer
-createBuffer src =
-   makeBuffer "createBuffer" $
-      case src of
-         File filePath -> withCString filePath alutCreateBufferFromFile
-         FileImage (MemoryRegion buf size) -> alutCreateBufferFromFileImage buf size
-
-foreign import CALLCONV unsafe "alutCreateBufferFromFile"
-   alutCreateBufferFromFile :: CString -> IO ALuint
-
-foreign import CALLCONV unsafe "alutCreateBufferFromFileImage"
-   alutCreateBufferFromFileImage :: Ptr a -> ALsizei -> IO ALuint
+createBuffer src = makeBuffer "createBuffer" $ case src of
+   File filePath -> withCString filePath alut_CreateBufferFromFile
+   FileImage (MemoryRegion buf size) -> alut_CreateBufferFromFileImage buf size
+   HelloWorld -> alut_CreateBufferHelloWorld
+   Sine f p d -> alut_CreateBufferWaveform alut_WAVEFORM_SINE f p d 
+   Square f p d -> alut_CreateBufferWaveform alut_WAVEFORM_SQUARE f p d
+   Sawtooth f p d -> alut_CreateBufferWaveform alut_WAVEFORM_SAWTOOTH f p d
+   Impulse f p d -> alut_CreateBufferWaveform alut_WAVEFORM_IMPULSE f p d
+   WhiteNoise d -> alut_CreateBufferWaveform alut_WAVEFORM_WHITENOISE 1 0 d
 
 --------------------------------------------------------------------------------
 
 createBufferData :: SoundDataSource a -> IO (BufferData b)
 createBufferData src = case src of
-   File filePath ->
-      withCString filePath $ \fp -> loadWith (alutLoadMemoryFromFile fp)
-   FileImage (MemoryRegion buf size) ->
-      loadWith (alutLoadMemoryFromFileImage buf size)
+   File filePath -> withCString filePath $ \fp -> loadWith (alut_LoadMemoryFromFile fp)
+   FileImage (MemoryRegion buf size) -> loadWith (alut_LoadMemoryFromFileImage buf size)
+   HelloWorld -> loadWith alut_LoadMemoryHelloWorld
+   Sine f p d -> loadWith (alut_LoadMemoryWaveform alut_WAVEFORM_SINE f p d)
+   Square f p d -> loadWith (alut_LoadMemoryWaveform alut_WAVEFORM_SQUARE f p d)
+   Sawtooth f p d -> loadWith (alut_LoadMemoryWaveform alut_WAVEFORM_SAWTOOTH f p d)
+   Impulse f p d -> loadWith (alut_LoadMemoryWaveform alut_WAVEFORM_IMPULSE f p d)
+   WhiteNoise d -> loadWith (alut_LoadMemoryWaveform alut_WAVEFORM_WHITENOISE 1 0 d)
 
 loadWith :: (Ptr ALenum -> Ptr ALsizei -> Ptr ALfloat -> IO (Ptr b)) -> IO (BufferData b)
 loadWith loader =
@@ -78,12 +101,6 @@
             frequency <- peek frequencyBuf
             return $ BufferData (MemoryRegion buf size) (unmarshalFormat format) frequency
 
-foreign import CALLCONV unsafe "alutLoadMemoryFromFile"
-   alutLoadMemoryFromFile :: CString -> Ptr ALenum -> Ptr ALsizei -> Ptr ALfloat -> IO (Ptr b)
-
-foreign import CALLCONV unsafe "alutLoadMemoryFromFileImage"
-   alutLoadMemoryFromFileImage :: Ptr a -> ALsizei -> Ptr ALenum -> Ptr ALsizei -> Ptr ALfloat -> IO (Ptr b)
-
 --------------------------------------------------------------------------------
 
 bufferMIMETypes :: GettableStateVar [String]
@@ -95,7 +112,7 @@
 mimeTypes :: String -> ALenum -> GettableStateVar [String]
 mimeTypes name loaderType =
    makeGettableStateVar $ do
-      ts <- throwIfNullPtr name $ alutGetMIMETypes loaderType
+      ts <- throwIfNullPtr name $ alut_GetMIMETypes loaderType
       fmap (splitBy (== ',')) $ peekCString ts
 
 splitBy :: (a -> Bool) -> [a] -> [[a]]
@@ -103,6 +120,3 @@
 splitBy p xs = case break p xs of
                 (ys, []  ) -> [ys]
                 (ys, _:zs) -> ys : splitBy p zs
-
-foreign import CALLCONV unsafe "alutGetMIMETypes"
-   alutGetMIMETypes :: ALenum -> IO CString
diff -Naur ghc/libraries/ALUT/Sound/ALUT/Sleep.hs ghc/libraries/ALUT/Sound/ALUT/Sleep.hs
--- ghc/libraries/ALUT/Sound/ALUT/Sleep.hs	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/Sound/ALUT/Sleep.hs	2006-05-08 21:52:51.000000000 +0200
@@ -14,13 +14,11 @@
    sleep
 )  where
 
+import Sound.ALUT.Config ( alut_Sleep )
 import Sound.ALUT.Errors ( throwIfALfalse )
-import Sound.OpenAL.AL.BasicTypes ( ALboolean, ALfloat )
+import Sound.ALUT.Loaders ( Duration )
 
 --------------------------------------------------------------------------------
 
-sleep :: Float -> IO ()
-sleep = throwIfALfalse "sleep" . alutSleep
-
-foreign import CALLCONV unsafe "alutSleep"
-   alutSleep :: ALfloat -> IO ALboolean
+sleep :: Duration -> IO ()
+sleep = throwIfALfalse "sleep" . alut_Sleep
diff -Naur ghc/libraries/ALUT/Sound/ALUT/Version.hs ghc/libraries/ALUT/Sound/ALUT/Version.hs
--- ghc/libraries/ALUT/Sound/ALUT/Version.hs	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/Sound/ALUT/Version.hs	2006-05-08 21:52:51.000000000 +0200
@@ -18,6 +18,7 @@
 import Graphics.Rendering.OpenGL.GL.StateVar (
    GettableStateVar, makeGettableStateVar )
 import Sound.OpenAL.AL.BasicTypes ( ALint )
+import Sound.ALUT.Config ( alut_GetMajorVersion, alut_GetMinorVersion )
 import Sound.ALUT.Constants ( alut_API_MAJOR_VERSION, alut_API_MINOR_VERSION )
 
 --------------------------------------------------------------------------------
@@ -33,10 +34,4 @@
 alutVersion :: GettableStateVar String
 alutVersion =
    makeGettableStateVar $
-      liftM2 makeVersionString alutGetMajorVersion alutGetMinorVersion
-
-foreign import CALLCONV unsafe "alutGetMajorVersion"
-   alutGetMajorVersion :: IO ALint
-
-foreign import CALLCONV unsafe "alutGetMinorVersion"
-   alutGetMinorVersion :: IO ALint
+      liftM2 makeVersionString alut_GetMajorVersion alut_GetMinorVersion
diff -Naur ghc/libraries/ALUT/Sound/ALUT.hs ghc/libraries/ALUT/Sound/ALUT.hs
--- ghc/libraries/ALUT/Sound/ALUT.hs	2006-03-21 16:58:03.000000000 +0100
+++ ghc/libraries/ALUT/Sound/ALUT.hs	2006-05-08 21:52:51.000000000 +0200
@@ -20,7 +20,6 @@
 
    module Sound.ALUT.Initialization,
    module Sound.ALUT.Loaders,
-   module Sound.ALUT.BuiltInSounds,
    module Sound.ALUT.Version,
    module Sound.ALUT.Sleep
 )  where
@@ -29,6 +28,5 @@
 
 import Sound.ALUT.Initialization
 import Sound.ALUT.Loaders
-import Sound.ALUT.BuiltInSounds
 import Sound.ALUT.Version
 import Sound.ALUT.Sleep
--- ghc/libraries/OpenAL/Sound/OpenAL/ALC/Capture.hs	2006-03-21 15:58:03.000000000 +0000
+++ ghc/libraries/OpenAL/Sound/OpenAL/ALC/Capture.hs	2006-05-09 11:46:50.000000000 +0100
@@ -81,16 +81,18 @@
 --------------------------------------------------------------------------------
 
 captureNumSamples :: Device -> GettableStateVar NumSamples
-captureNumSamples device =
-   makeGettableStateVar $ getInteger (Just device) CaptureSamples
+captureNumSamples device = makeGettableStateVar $
+   fmap fromIntegral (getInteger (Just device) CaptureSamples)
 
 --------------------------------------------------------------------------------
 
 captureSamples :: Device -> Ptr a -> NumSamples -> IO ()
-captureSamples = alcCaptureSamples . marshalDevice
+captureSamples device buf n = do
+   funPtr <- getCaptureFunc "alcCaptureSamples"
+   invokeCaptureSamples funPtr (marshalDevice device) buf n
 
-foreign import CALLCONV unsafe "alcCaptureSamples"
-   alcCaptureSamples :: ALCdevice -> Ptr a -> NumSamples -> IO ()
+foreign import CALLCONV unsafe "dynamic"
+   invokeCaptureSamples :: Invoker (ALCdevice -> Ptr a -> NumSamples -> IO ())
 
 --------------------------------------------------------------------------------
 
