diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,31 @@
+The Glasgow Haskell Compiler License
+
+Copyright 2002, The University Court of the University of Glasgow. 
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+- Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+ 
+- 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.
+ 
+- Neither name of the University 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 UNIVERSITY COURT OF THE UNIVERSITY OF
+GLASGOW AND THE 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
+UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE 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/Network.hs b/Network.hs
new file mode 100644
--- /dev/null
+++ b/Network.hs
@@ -0,0 +1,303 @@
+{-# OPTIONS_GHC -cpp #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Network
+-- Copyright   :  (c) The University of Glasgow 2001
+-- License     :  BSD-style (see the file libraries/network/LICENSE)
+-- 
+-- Maintainer  :  libraries@haskell.org
+-- Stability   :  provisional
+-- Portability :  portable
+--
+-- The "Network" interface is a \"higher-level\" interface to
+-- networking facilities, and it is recommended unless you need the
+-- lower-level interface in "Network.Socket".
+--
+-----------------------------------------------------------------------------
+
+module Network (
+
+	-- * Basic data types
+	Socket,
+        PortID(..),
+	HostName,
+	PortNumber,	-- instance (Eq, Enum, Num, Real, Integral)
+
+	-- * Initialisation
+	withSocketsDo,  -- :: IO a   -> IO a
+	
+	-- * Server-side connections
+	listenOn,	-- :: PortID -> IO Socket
+	accept,		-- :: Socket -> IO (Handle, HostName, PortNumber)
+        sClose,		-- :: Socket -> IO ()
+
+	-- * Client-side connections
+	connectTo,	-- :: HostName -> PortID -> IO Handle
+
+	-- * Simple sending and receiving
+	{-$sendrecv-}
+	sendTo,		-- :: HostName -> PortID -> String -> IO ()
+	recvFrom,	-- :: HostName -> PortID -> IO String
+
+	-- * Miscellaneous
+	socketPort,	-- :: Socket -> IO PortID
+
+	-- * Networking Issues
+	-- ** Buffering
+	{-$buffering-}
+
+	-- ** Improving I\/O Performance over sockets
+	{-$performance-}
+
+	-- ** @SIGPIPE@
+	{-$sigpipe-}
+
+       ) where
+
+import Network.BSD
+import Network.Socket hiding ( accept, socketPort, recvFrom, sendTo, PortNumber )
+import qualified Network.Socket as Socket ( accept )
+import System.IO
+import Prelude
+import Control.Exception as Exception
+
+-- ---------------------------------------------------------------------------
+-- High Level ``Setup'' functions
+
+-- If the @PortID@ specifies a unix family socket and the @Hostname@
+-- differs from that returned by @getHostname@ then an error is
+-- raised. Alternatively an empty string may be given to @connectTo@
+-- signalling that the current hostname applies.
+
+data PortID = 
+	  Service String		-- Service Name eg "ftp"
+	| PortNumber PortNumber		-- User defined Port Number
+#if !defined(mingw32_HOST_OS) && !defined(cygwin32_HOST_OS) && !defined(_WIN32)
+	| UnixSocket String		-- Unix family socket in file system
+#endif
+
+-- | Calling 'connectTo' creates a client side socket which is
+-- connected to the given host and port.  The Protocol and socket type is
+-- derived from the given port identifier.  If a port number is given
+-- then the result is always an internet family 'Stream' socket. 
+
+connectTo :: HostName		-- Hostname
+	  -> PortID 		-- Port Identifier
+	  -> IO Handle		-- Connected Socket
+
+connectTo hostname (Service serv) = do
+    proto <- getProtocolNumber "tcp"
+    Exception.bracketOnError
+	(socket AF_INET Stream proto)
+	(sClose)  -- only done if there's an error
+	(\sock -> do
+          port	<- getServicePortNumber serv
+          he	<- getHostByName hostname
+          connect sock (SockAddrInet port (hostAddress he))
+          socketToHandle sock ReadWriteMode
+ 	)
+
+connectTo hostname (PortNumber port) = do
+    proto <- getProtocolNumber "tcp"
+    Exception.bracketOnError
+	(socket AF_INET Stream proto)
+	(sClose)  -- only done if there's an error
+        (\sock -> do
+      	  he <- getHostByName hostname
+      	  connect sock (SockAddrInet port (hostAddress he))
+      	  socketToHandle sock ReadWriteMode
+	)
+
+#if !defined(mingw32_HOST_OS) && !defined(cygwin32_HOST_OS) && !defined(_WIN32)
+connectTo _ (UnixSocket path) = do
+    Exception.bracketOnError
+	(socket AF_UNIX Stream 0)
+	(sClose)
+	(\sock -> do
+          connect sock (SockAddrUnix path)
+          socketToHandle sock ReadWriteMode
+	)
+#endif
+
+-- | Creates the server side socket which has been bound to the
+-- specified port.  
+--
+-- NOTE: To avoid the \"Address already in use\"
+-- problems popped up several times on the GHC-Users mailing list we
+-- set the 'ReuseAddr' socket option on the listening socket.  If you
+-- don't want this behaviour, please use the lower level
+-- 'Network.Socket.listen' instead.
+
+listenOn :: PortID 	-- ^ Port Identifier
+	 -> IO Socket	-- ^ Connected Socket
+
+listenOn (Service serv) = do
+    proto <- getProtocolNumber "tcp"
+    Exception.bracketOnError
+        (socket AF_INET Stream proto)
+	(sClose)
+	(\sock -> do
+	    port    <- getServicePortNumber serv
+	    setSocketOption sock ReuseAddr 1
+	    bindSocket sock (SockAddrInet port iNADDR_ANY)
+	    listen sock maxListenQueue
+	    return sock
+	)
+
+listenOn (PortNumber port) = do
+    proto <- getProtocolNumber "tcp"
+    Exception.bracketOnError
+    	(socket AF_INET Stream proto)
+	(sClose)
+	(\sock -> do
+	    setSocketOption sock ReuseAddr 1
+	    bindSocket sock (SockAddrInet port iNADDR_ANY)
+	    listen sock maxListenQueue
+	    return sock
+	)
+
+#if !defined(mingw32_HOST_OS) && !defined(cygwin32_HOST_OS) && !defined(_WIN32)
+listenOn (UnixSocket path) =
+    Exception.bracketOnError
+    	(socket AF_UNIX Stream 0)
+	(sClose)
+	(\sock -> do
+	    setSocketOption sock ReuseAddr 1
+	    bindSocket sock (SockAddrUnix path)
+	    listen sock maxListenQueue
+	    return sock
+	)
+#endif
+
+-- -----------------------------------------------------------------------------
+-- accept
+
+-- | Accept a connection on a socket created by 'listenOn'.  Normal
+-- I\/O opertaions (see "System.IO") can be used on the 'Handle'
+-- returned to communicate with the client.
+-- Notice that although you can pass any Socket to Network.accept, only
+-- sockets of either AF_UNIX or AF_INET will work (this shouldn't be a problem,
+-- though). When using AF_UNIX, HostName will be set to the path of the socket
+-- and PortNumber to -1.
+--
+accept :: Socket 		-- ^ Listening Socket
+       -> IO (Handle,
+	      HostName,
+	      PortNumber)	-- ^ Triple of: read\/write 'Handle' for 
+				-- communicating with the client,
+			 	-- the 'HostName' of the peer socket, and
+				-- the 'PortNumber' of the remote connection.
+accept sock@(MkSocket _ AF_INET _ _ _) = do
+ ~(sock', (SockAddrInet port haddr)) <- Socket.accept sock
+ peer <- Exception.catchJust ioErrors
+	  (do 	
+	     (HostEntry peer _ _ _) <- getHostByAddr AF_INET haddr
+	     return peer
+	  )
+	  (\e -> inet_ntoa haddr)
+		-- if getHostByName fails, we fall back to the IP address
+ handle <- socketToHandle sock' ReadWriteMode
+ return (handle, peer, port)
+#if !defined(mingw32_HOST_OS) && !defined(cygwin32_HOST_OS) && !defined(_WIN32)
+accept sock@(MkSocket _ AF_UNIX _ _ _) = do
+ ~(sock', (SockAddrUnix path)) <- Socket.accept sock
+ handle <- socketToHandle sock' ReadWriteMode
+ return (handle, path, -1)
+#endif
+accept sock@(MkSocket _ family _ _ _) =
+  error $ "Sorry, address family " ++ (show family) ++ " is not supported!"
+
+-- -----------------------------------------------------------------------------
+-- sendTo/recvFrom
+
+{-$sendrecv
+Send and receive data from\/to the given host and port number.  These
+should normally only be used where the socket will not be required for
+further calls. Also, note that due to the use of 'hGetContents' in 'recvFrom'
+the socket will remain open (i.e. not available) even if the function already
+returned. Their use is strongly discouraged except for small test-applications
+or invocations from the command line.
+-}
+
+sendTo :: HostName 	-- Hostname
+       -> PortID	-- Port Number
+       -> String	-- Message to send
+       -> IO ()
+sendTo h p msg = do
+  s <- connectTo h p
+  hPutStr s msg
+  hClose s
+
+recvFrom :: HostName 	-- Hostname
+	 -> PortID	-- Port Number
+	 -> IO String	-- Received Data
+recvFrom host port = do
+ ip  <- getHostByName host
+ let ipHs = hostAddresses ip
+ s   <- listenOn port
+ let 
+  waiting = do
+     ~(s', SockAddrInet _ haddr)  <-  Socket.accept s
+     he <- getHostByAddr AF_INET haddr
+     if not (any (`elem` ipHs) (hostAddresses he))
+      then do
+         sClose s'
+         waiting
+      else do
+	h <- socketToHandle s' ReadMode
+        msg <- hGetContents h
+        return msg
+
+ message <- waiting
+ return message
+
+-- ---------------------------------------------------------------------------
+-- Access function returning the port type/id of socket.
+
+-- | Returns the 'PortID' associated with a given socket.
+socketPort :: Socket -> IO PortID
+socketPort s = do
+    sockaddr <- getSocketName s
+    return (portID sockaddr)
+  where
+   portID sa =
+    case sa of
+     SockAddrInet port _    -> PortNumber port
+#if !defined(mingw32_HOST_OS) && !defined(cygwin32_HOST_OS) && !defined(_WIN32)
+     SockAddrUnix path	    -> UnixSocket path
+#endif
+
+-----------------------------------------------------------------------------
+-- Extra documentation
+
+{-$buffering
+
+The 'Handle' returned by 'connectTo' and 'accept' is block-buffered by
+default.  For an interactive application you may want to set the
+buffering mode on the 'Handle' to
+'LineBuffering' or 'NoBuffering', like so:
+
+> h <- connectTo host port
+> hSetBuffering h LineBuffering
+-}
+
+{-$performance
+
+For really fast I\/O, it might be worth looking at the 'hGetBuf' and
+'hPutBuf' family of functions in "System.IO".
+-}
+
+{-$sigpipe
+
+On Unix, when writing to a socket and the reading end is
+closed by the remote client, the program is normally sent a
+@SIGPIPE@ signal by the operating system.  The
+default behaviour when a @SIGPIPE@ is received is
+to terminate the program silently, which can be somewhat confusing
+if you haven't encountered this before.  The solution is to
+specify that @SIGPIPE@ is to be ignored, using
+the POSIX library:
+
+>  import Posix
+>  main = do installHandler sigPIPE Ignore Nothing; ...
+-}
diff --git a/Network/BSD.hsc b/Network/BSD.hsc
new file mode 100644
--- /dev/null
+++ b/Network/BSD.hsc
@@ -0,0 +1,579 @@
+{-# OPTIONS -fglasgow-exts -cpp #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Network.BSD
+-- Copyright   :  (c) The University of Glasgow 2001
+-- License     :  BSD-style (see the file libraries/network/LICENSE)
+-- 
+-- Maintainer  :  libraries@haskell.org
+-- Stability   :  experimental
+-- Portability :  non-portable
+--
+-- The "Network.BSD" module defines Haskell bindings to network
+-- programming functionality provided by BSD Unix derivatives.
+--
+-----------------------------------------------------------------------------
+
+#include "HsNet.h"
+
+-- NOTE: ##, we want this interpreted when compiling the .hs, not by hsc2hs.
+##include "Typeable.h"
+
+module Network.BSD (
+       
+    -- * Host names
+    HostName,
+    getHostName,	    -- :: IO HostName
+
+    HostEntry(..),
+    getHostByName,	    -- :: HostName -> IO HostEntry
+    getHostByAddr,	    -- :: HostAddress -> Family -> IO HostEntry
+    hostAddress,	    -- :: HostEntry -> HostAddress
+
+#if defined(HAVE_GETHOSTENT) && !defined(cygwin32_HOST_OS) && !defined(mingw32_HOST_OS) && !defined(_WIN32)
+    getHostEntries,	    -- :: Bool -> IO [HostEntry]
+    -- ** Low level functionality
+    setHostEntry,	    -- :: Bool -> IO ()
+    getHostEntry,	    -- :: IO HostEntry
+    endHostEntry,	    -- :: IO ()
+#endif
+
+    -- * Service names
+    ServiceEntry(..),
+    ServiceName,
+    getServiceByName,	    -- :: ServiceName -> ProtocolName -> IO ServiceEntry
+    getServiceByPort,       -- :: PortNumber  -> ProtocolName -> IO ServiceEntry
+    getServicePortNumber,   -- :: ServiceName -> IO PortNumber
+
+#if !defined(cygwin32_HOST_OS) && !defined(mingw32_HOST_OS) && !defined(_WIN32)
+    getServiceEntries,	    -- :: Bool -> IO [ServiceEntry]
+    -- ** Low level functionality
+    getServiceEntry,	    -- :: IO ServiceEntry
+    setServiceEntry,	    -- :: Bool -> IO ()
+    endServiceEntry,	    -- :: IO ()
+#endif
+
+    -- * Protocol names
+    ProtocolName,
+    ProtocolNumber,
+    ProtocolEntry(..),
+    getProtocolByName,	    -- :: ProtocolName   -> IO ProtocolEntry
+    getProtocolByNumber,    -- :: ProtocolNumber -> IO ProtcolEntry
+    getProtocolNumber,	    -- :: ProtocolName   -> ProtocolNumber
+    defaultProtocol,        -- :: ProtocolNumber
+
+#if !defined(cygwin32_HOST_OS) && !defined(mingw32_HOST_OS) && !defined(_WIN32)
+    getProtocolEntries,	    -- :: Bool -> IO [ProtocolEntry]
+    -- ** Low level functionality
+    setProtocolEntry,	    -- :: Bool -> IO ()
+    getProtocolEntry,	    -- :: IO ProtocolEntry
+    endProtocolEntry,	    -- :: IO ()
+#endif
+
+    -- * Port numbers
+    PortNumber,
+
+    -- * Network names
+    NetworkName,
+    NetworkAddr,
+    NetworkEntry(..)
+
+#if !defined(cygwin32_HOST_OS) && !defined(mingw32_HOST_OS) && !defined(_WIN32)
+    , getNetworkByName	    -- :: NetworkName -> IO NetworkEntry
+    , getNetworkByAddr      -- :: NetworkAddr -> Family -> IO NetworkEntry
+    , getNetworkEntries     -- :: Bool -> IO [NetworkEntry]
+    -- ** Low level functionality
+    , setNetworkEntry	    -- :: Bool -> IO ()
+    , getNetworkEntry	    -- :: IO NetworkEntry
+    , endNetworkEntry	    -- :: IO ()
+#endif
+    ) where
+
+#ifdef __HUGS__
+import Hugs.Prelude ( IOException(..), IOErrorType(..) )
+#endif
+import Network.Socket
+
+import Control.Concurrent 	( MVar, newMVar, withMVar )
+import Foreign.C.Error ( throwErrnoIfMinus1, throwErrnoIfMinus1_ )
+import Foreign.C.String ( CString, peekCString, peekCStringLen, withCString )
+import Foreign.C.Types ( CInt, CULong, CChar, CSize, CShort )
+import Foreign.Ptr ( Ptr, nullPtr )
+import Foreign.Storable ( Storable(..) )
+import Foreign.Marshal.Array ( allocaArray0, peekArray0 )
+import Foreign.Marshal.Utils ( with, fromBool )
+import Data.Typeable
+import System.IO.Unsafe ( unsafePerformIO )
+
+#ifdef __GLASGOW_HASKELL__
+import GHC.IOBase
+#endif
+
+import Control.Monad ( liftM )
+
+-- ---------------------------------------------------------------------------
+-- Basic Types
+
+type HostName     = String
+type ProtocolName = String
+type ServiceName  = String
+
+-- ---------------------------------------------------------------------------
+-- Service Database Access
+
+-- Calling getServiceByName for a given service and protocol returns
+-- the systems service entry.  This should be used to find the port
+-- numbers for standard protocols such as SMTP and FTP.  The remaining
+-- three functions should be used for browsing the service database
+-- sequentially.
+
+-- Calling setServiceEntry with True indicates that the service
+-- database should be left open between calls to getServiceEntry.  To
+-- close the database a call to endServiceEntry is required.  This
+-- database file is usually stored in the file /etc/services.
+
+data ServiceEntry  = 
+  ServiceEntry  {
+     serviceName     :: ServiceName,	-- Official Name
+     serviceAliases  :: [ServiceName],	-- aliases
+     servicePort     :: PortNumber,	-- Port Number  ( network byte order )
+     serviceProtocol :: ProtocolName	-- Protocol
+  } deriving (Show)
+
+INSTANCE_TYPEABLE0(ServiceEntry,serviceEntryTc,"ServiceEntry")
+
+instance Storable ServiceEntry where
+   sizeOf    _ = #const sizeof(struct servent)
+   alignment _ = alignment (undefined :: CInt) -- ???
+
+   peek p = do
+        s_name    <- (#peek struct servent, s_name) p >>= peekCString
+        s_aliases <- (#peek struct servent, s_aliases) p
+                           >>= peekArray0 nullPtr
+                           >>= mapM peekCString
+        s_port    <- (#peek struct servent, s_port) p
+        s_proto   <- (#peek struct servent, s_proto) p >>= peekCString
+        return (ServiceEntry {
+                        serviceName     = s_name,
+                        serviceAliases  = s_aliases,
+#if defined(HAVE_WINSOCK_H) && !defined(cygwin32_HOST_OS)
+                        servicePort     = PortNum (fromIntegral (s_port :: CShort)),
+#else
+                           -- s_port is already in network byte order, but it
+                           -- might be the wrong size.
+                        servicePort     = PortNum (fromIntegral (s_port :: CInt)),
+#endif
+                        serviceProtocol = s_proto
+                })
+
+   poke p = error "Storable.poke(BSD.ServiceEntry) not implemented"
+
+
+-- | Get service by name.
+getServiceByName :: ServiceName 	-- Service Name
+		 -> ProtocolName 	-- Protocol Name
+		 -> IO ServiceEntry	-- Service Entry
+getServiceByName name proto = withLock $ do
+ withCString name  $ \ cstr_name  -> do
+ withCString proto $ \ cstr_proto -> do
+ throwNoSuchThingIfNull "getServiceByName" "no such service entry"
+   $ (trySysCall (c_getservbyname cstr_name cstr_proto))
+ >>= peek
+
+foreign import ccall unsafe "getservbyname" 
+  c_getservbyname :: CString -> CString -> IO (Ptr ServiceEntry)
+
+-- | Get the service given a 'PortNumber' and 'ProtocolName'.
+getServiceByPort :: PortNumber -> ProtocolName -> IO ServiceEntry
+getServiceByPort (PortNum port) proto = withLock $ do
+ withCString proto $ \ cstr_proto -> do
+ throwNoSuchThingIfNull "getServiceByPort" "no such service entry"
+   $ (trySysCall (c_getservbyport (fromIntegral port) cstr_proto))
+ >>= peek
+
+foreign import ccall unsafe "getservbyport" 
+  c_getservbyport :: CInt -> CString -> IO (Ptr ServiceEntry)
+
+-- | Get the 'PortNumber' corresponding to the 'ServiceName'.
+getServicePortNumber :: ServiceName -> IO PortNumber
+getServicePortNumber name = do
+    (ServiceEntry _ _ port _) <- getServiceByName name "tcp"
+    return port
+
+#if !defined(cygwin32_HOST_OS) && !defined(mingw32_HOST_OS) && !defined(_WIN32)
+getServiceEntry	:: IO ServiceEntry
+getServiceEntry = withLock $ do
+ throwNoSuchThingIfNull "getServiceEntry" "no such service entry"
+   $ trySysCall c_getservent
+ >>= peek
+
+foreign import ccall unsafe "getservent" c_getservent :: IO (Ptr ServiceEntry)
+
+setServiceEntry	:: Bool -> IO ()
+setServiceEntry flg = withLock $ trySysCall $ c_setservent (fromBool flg)
+
+foreign import ccall unsafe  "setservent" c_setservent :: CInt -> IO ()
+
+endServiceEntry	:: IO ()
+endServiceEntry = withLock $ trySysCall $ c_endservent
+
+foreign import ccall unsafe  "endservent" c_endservent :: IO ()
+
+getServiceEntries :: Bool -> IO [ServiceEntry]
+getServiceEntries stayOpen = do
+  setServiceEntry stayOpen
+  getEntries (getServiceEntry) (endServiceEntry)
+#endif
+
+-- ---------------------------------------------------------------------------
+-- Protocol Entries
+
+-- The following relate directly to the corresponding UNIX C
+-- calls for returning the protocol entries. The protocol entry is
+-- represented by the Haskell type ProtocolEntry.
+
+-- As for setServiceEntry above, calling setProtocolEntry.
+-- determines whether or not the protocol database file, usually
+-- @/etc/protocols@, is to be kept open between calls of
+-- getProtocolEntry. Similarly, 
+
+data ProtocolEntry = 
+  ProtocolEntry  {
+     protoName    :: ProtocolName,	-- Official Name
+     protoAliases :: [ProtocolName],	-- aliases
+     protoNumber  :: ProtocolNumber	-- Protocol Number
+  } deriving (Read, Show)
+
+INSTANCE_TYPEABLE0(ProtocolEntry,protocolEntryTc,"ProtocolEntry")
+
+instance Storable ProtocolEntry where
+   sizeOf    _ = #const sizeof(struct protoent)
+   alignment _ = alignment (undefined :: CInt) -- ???
+
+   peek p = do
+        p_name    <- (#peek struct protoent, p_name) p >>= peekCString
+        p_aliases <- (#peek struct protoent, p_aliases) p
+                           >>= peekArray0 nullPtr
+                           >>= mapM peekCString
+#if defined(HAVE_WINSOCK_H) && !defined(cygwin32_HOST_OS)
+         -- With WinSock, the protocol number is only a short;
+         -- hoist it in as such, but represent it on the Haskell side
+         -- as a CInt.
+        p_proto_short  <- (#peek struct protoent, p_proto) p 
+        let p_proto = fromIntegral (p_proto_short :: CShort)
+#else
+        p_proto        <- (#peek struct protoent, p_proto) p 
+#endif
+        return (ProtocolEntry { 
+                        protoName    = p_name,
+                        protoAliases = p_aliases,
+                        protoNumber  = p_proto
+                })
+
+   poke p = error "Storable.poke(BSD.ProtocolEntry) not implemented"
+
+getProtocolByName :: ProtocolName -> IO ProtocolEntry
+getProtocolByName name = withLock $ do
+ withCString name $ \ name_cstr -> do
+ throwNoSuchThingIfNull "getProtocolByName" ("no such protocol name: " ++ name)
+   $ (trySysCall.c_getprotobyname) name_cstr
+ >>= peek
+
+foreign import  ccall unsafe  "getprotobyname" 
+   c_getprotobyname :: CString -> IO (Ptr ProtocolEntry)
+
+
+getProtocolByNumber :: ProtocolNumber -> IO ProtocolEntry
+getProtocolByNumber num = withLock $ do
+ throwNoSuchThingIfNull "getProtocolByNumber" ("no such protocol number: " ++ show num)
+   $ (trySysCall.c_getprotobynumber) (fromIntegral num)
+ >>= peek
+
+foreign import ccall unsafe  "getprotobynumber"
+   c_getprotobynumber :: CInt -> IO (Ptr ProtocolEntry)
+
+
+getProtocolNumber :: ProtocolName -> IO ProtocolNumber
+getProtocolNumber proto = do
+ (ProtocolEntry _ _ num) <- getProtocolByName proto
+ return num
+
+-- | This is the default protocol for the given service.
+defaultProtocol :: ProtocolNumber
+defaultProtocol = 0
+
+#if !defined(cygwin32_HOST_OS) && !defined(mingw32_HOST_OS) && !defined(_WIN32)
+getProtocolEntry :: IO ProtocolEntry	-- Next Protocol Entry from DB
+getProtocolEntry = withLock $ do
+ ent <- throwNoSuchThingIfNull "getProtocolEntry" "no such protocol entry"
+   		$ trySysCall c_getprotoent
+ peek ent
+
+foreign import ccall unsafe  "getprotoent" c_getprotoent :: IO (Ptr ProtocolEntry)
+
+setProtocolEntry :: Bool -> IO ()	-- Keep DB Open ?
+setProtocolEntry flg = withLock $ trySysCall $ c_setprotoent (fromBool flg)
+
+foreign import ccall unsafe "setprotoent" c_setprotoent :: CInt -> IO ()
+
+endProtocolEntry :: IO ()
+endProtocolEntry = withLock $ trySysCall $ c_endprotoent
+
+foreign import ccall unsafe "endprotoent" c_endprotoent :: IO ()
+
+getProtocolEntries :: Bool -> IO [ProtocolEntry]
+getProtocolEntries stayOpen = withLock $ do
+  setProtocolEntry stayOpen
+  getEntries (getProtocolEntry) (endProtocolEntry)
+#endif
+
+-- ---------------------------------------------------------------------------
+-- Host lookups
+
+data HostEntry = 
+  HostEntry  {
+     hostName      :: HostName,  	-- Official Name
+     hostAliases   :: [HostName],	-- aliases
+     hostFamily    :: Family,	        -- Host Type (currently AF_INET)
+     hostAddresses :: [HostAddress]	-- Set of Network Addresses  (in network byte order)
+  } deriving (Read, Show)
+
+INSTANCE_TYPEABLE0(HostEntry,hostEntryTc,"hostEntry")
+
+instance Storable HostEntry where
+   sizeOf    _ = #const sizeof(struct hostent)
+   alignment _ = alignment (undefined :: CInt) -- ???
+
+   peek p = do
+        h_name       <- (#peek struct hostent, h_name) p >>= peekCString
+        h_aliases    <- (#peek struct hostent, h_aliases) p
+                                >>= peekArray0 nullPtr
+                                >>= mapM peekCString
+        h_addrtype   <- (#peek struct hostent, h_addrtype) p
+        -- h_length       <- (#peek struct hostent, h_length) p
+        h_addr_list  <- (#peek struct hostent, h_addr_list) p
+                                >>= peekArray0 nullPtr
+                                >>= mapM peek
+        return (HostEntry {
+                        hostName       = h_name,
+                        hostAliases    = h_aliases,
+                        hostFamily     = unpackFamily h_addrtype,
+                        hostAddresses  = h_addr_list
+                })
+
+   poke p = error "Storable.poke(BSD.ServiceEntry) not implemented"
+
+
+-- convenience function:
+hostAddress :: HostEntry -> HostAddress
+hostAddress (HostEntry nm _ _ ls) =
+ case ls of
+   []    -> error ("BSD.hostAddress: empty network address list for " ++ nm)
+   (x:_) -> x
+
+-- getHostByName must use the same lock as the *hostent functions
+-- may cause problems if called concurrently.
+
+-- | Resolve a 'HostName' to IPv4 address.
+getHostByName :: HostName -> IO HostEntry
+getHostByName name = withLock $ do
+  withCString name $ \ name_cstr -> do
+   ent <- throwNoSuchThingIfNull "getHostByName" "no such host entry"
+    		$ trySysCall $ c_gethostbyname name_cstr
+   peek ent
+
+foreign import ccall safe "gethostbyname" 
+   c_gethostbyname :: CString -> IO (Ptr HostEntry)
+
+
+-- The locking of gethostbyaddr is similar to gethostbyname.
+-- | Get a 'HostEntry' corresponding to the given address and family.
+-- Note that only IPv4 is currently supported.
+getHostByAddr :: Family -> HostAddress -> IO HostEntry
+getHostByAddr family addr = do
+ with addr $ \ ptr_addr -> withLock $ do
+ throwNoSuchThingIfNull 	"getHostByAddr" "no such host entry"
+   $ trySysCall $ c_gethostbyaddr ptr_addr (fromIntegral (sizeOf addr)) (packFamily family)
+ >>= peek
+
+foreign import ccall safe "gethostbyaddr"
+   c_gethostbyaddr :: Ptr HostAddress -> CInt -> CInt -> IO (Ptr HostEntry)
+
+#if defined(HAVE_GETHOSTENT) && !defined(cygwin32_HOST_OS) && !defined(mingw32_HOST_OS) && !defined(_WIN32)
+getHostEntry :: IO HostEntry
+getHostEntry = withLock $ do
+ throwNoSuchThingIfNull 	"getHostEntry" "unable to retrieve host entry"
+   $ trySysCall $ c_gethostent
+ >>= peek
+
+foreign import ccall unsafe "gethostent" c_gethostent :: IO (Ptr HostEntry)
+
+setHostEntry :: Bool -> IO ()
+setHostEntry flg = withLock $ trySysCall $ c_sethostent (fromBool flg)
+
+foreign import ccall unsafe "sethostent" c_sethostent :: CInt -> IO ()
+
+endHostEntry :: IO ()
+endHostEntry = withLock $ c_endhostent
+
+foreign import ccall unsafe "endhostent" c_endhostent :: IO ()
+
+getHostEntries :: Bool -> IO [HostEntry]
+getHostEntries stayOpen = do
+  setHostEntry stayOpen
+  getEntries (getHostEntry) (endHostEntry)
+#endif
+
+-- ---------------------------------------------------------------------------
+-- Accessing network information
+
+-- Same set of access functions as for accessing host,protocol and
+-- service system info, this time for the types of networks supported.
+
+-- network addresses are represented in host byte order.
+type NetworkAddr = CULong
+
+type NetworkName = String
+
+data NetworkEntry =
+  NetworkEntry {
+     networkName	:: NetworkName,   -- official name
+     networkAliases	:: [NetworkName], -- aliases
+     networkFamily	:: Family,	   -- type
+     networkAddress	:: NetworkAddr
+   } deriving (Read, Show)
+
+INSTANCE_TYPEABLE0(NetworkEntry,networkEntryTc,"NetworkEntry")
+
+instance Storable NetworkEntry where
+   sizeOf    _ = #const sizeof(struct hostent)
+   alignment _ = alignment (undefined :: CInt) -- ???
+
+   peek p = do
+        n_name         <- (#peek struct netent, n_name) p >>= peekCString
+        n_aliases      <- (#peek struct netent, n_aliases) p
+                                >>= peekArray0 nullPtr
+                                >>= mapM peekCString
+        n_addrtype     <- (#peek struct netent, n_addrtype) p
+        n_net          <- (#peek struct netent, n_net) p
+        return (NetworkEntry {
+                        networkName      = n_name,
+                        networkAliases   = n_aliases,
+                        networkFamily    = unpackFamily (fromIntegral 
+                                                        (n_addrtype :: CInt)),
+                        networkAddress   = n_net
+                })
+
+   poke p = error "Storable.poke(BSD.NetEntry) not implemented"
+
+
+#if !defined(cygwin32_HOST_OS) && !defined(mingw32_HOST_OS) && !defined(_WIN32)
+getNetworkByName :: NetworkName -> IO NetworkEntry
+getNetworkByName name = withLock $ do
+ withCString name $ \ name_cstr -> do
+  throwNoSuchThingIfNull "getNetworkByName" "no such network entry"
+    $ trySysCall $ c_getnetbyname name_cstr
+  >>= peek
+
+foreign import ccall unsafe "getnetbyname" 
+   c_getnetbyname  :: CString -> IO (Ptr NetworkEntry)
+
+getNetworkByAddr :: NetworkAddr -> Family -> IO NetworkEntry
+getNetworkByAddr addr family = withLock $ do
+ throwNoSuchThingIfNull "getNetworkByAddr" "no such network entry"
+   $ trySysCall $ c_getnetbyaddr addr (packFamily family)
+ >>= peek
+
+foreign import ccall unsafe "getnetbyaddr" 
+   c_getnetbyaddr  :: NetworkAddr -> CInt -> IO (Ptr NetworkEntry)
+
+getNetworkEntry :: IO NetworkEntry
+getNetworkEntry = withLock $ do
+ throwNoSuchThingIfNull "getNetworkEntry" "no more network entries"
+          $ trySysCall $ c_getnetent
+ >>= peek
+
+foreign import ccall unsafe "getnetent" c_getnetent :: IO (Ptr NetworkEntry)
+
+-- | Open the network name database. The parameter specifies
+-- whether a connection is maintained open between various
+-- networkEntry calls
+setNetworkEntry :: Bool -> IO ()
+setNetworkEntry flg = withLock $ trySysCall $ c_setnetent (fromBool flg)
+
+foreign import ccall unsafe "setnetent" c_setnetent :: CInt -> IO ()
+
+-- | Close the connection to the network name database.
+endNetworkEntry :: IO ()
+endNetworkEntry = withLock $ trySysCall $ c_endnetent
+
+foreign import ccall unsafe "endnetent" c_endnetent :: IO ()
+
+-- | Get the list of network entries.
+getNetworkEntries :: Bool -> IO [NetworkEntry]
+getNetworkEntries stayOpen = do
+  setNetworkEntry stayOpen
+  getEntries (getNetworkEntry) (endNetworkEntry)
+#endif
+
+-- Mutex for name service lockdown
+
+{-# NOINLINE lock #-}
+lock :: MVar ()
+lock = unsafePerformIO $ newMVar ()
+
+withLock :: IO a -> IO a
+withLock act = withMVar lock (\_ -> act)
+
+-- ---------------------------------------------------------------------------
+-- Miscellaneous Functions
+
+-- | Calling getHostName returns the standard host name for the current
+-- processor, as set at boot time.
+
+getHostName :: IO HostName
+getHostName = do
+  let size = 256
+  allocaArray0 size $ \ cstr -> do
+    throwSocketErrorIfMinus1_ "getHostName" $ c_gethostname cstr (fromIntegral size)
+    peekCString cstr
+
+foreign import ccall unsafe "gethostname" 
+   c_gethostname :: CString -> CSize -> IO CInt
+
+-- Helper function used by the exported functions that provides a
+-- Haskellised view of the enumerator functions:
+
+getEntries :: IO a  -- read
+           -> IO () -- at end
+	   -> IO [a]
+getEntries getOne atEnd = loop
+  where
+    loop = do
+      vv <- catch (liftM Just getOne) ((const.return) Nothing)
+      case vv of
+        Nothing -> return []
+        Just v  -> loop >>= \ vs -> atEnd >> return (v:vs)
+
+
+-- ---------------------------------------------------------------------------
+-- Winsock only:
+--   The BSD API networking calls made locally return NULL upon failure.
+--   That failure may very well be due to WinSock not being initialised,
+--   so if NULL is seen try init'ing and repeat the call.
+#if !defined(mingw32_HOST_OS) && !defined(_WIN32)
+trySysCall act = act
+#else
+trySysCall act = do
+  ptr <- act
+  if (ptr == nullPtr)
+   then withSocketsDo act
+   else return ptr
+#endif
+
+throwNoSuchThingIfNull :: String -> String -> IO (Ptr a) -> IO (Ptr a)
+throwNoSuchThingIfNull loc desc act = do
+  ptr <- act
+  if (ptr == nullPtr)
+   then ioError (IOError Nothing NoSuchThing loc desc Nothing)
+   else return ptr
diff --git a/Network/Socket.hsc b/Network/Socket.hsc
new file mode 100644
--- /dev/null
+++ b/Network/Socket.hsc
@@ -0,0 +1,2087 @@
+{-# OPTIONS -fglasgow-exts -cpp #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Network.Socket
+-- Copyright   :  (c) The University of Glasgow 2001
+-- License     :  BSD-style (see the file libraries/network/LICENSE)
+-- 
+-- Maintainer  :  libraries@haskell.org
+-- Stability   :  provisional
+-- Portability :  portable
+--
+-- The "Network.Socket" module is for when you want full control over
+-- sockets.  Essentially the entire C socket API is exposed through
+-- this module; in general the operations follow the behaviour of the C
+-- functions of the same name (consult your favourite Unix networking book).
+--
+-- A higher level interface to networking operations is provided
+-- through the module "Network".
+--
+-----------------------------------------------------------------------------
+
+#include "HsNet.h"
+
+-- NOTE: ##, we want this interpreted when compiling the .hs, not by hsc2hs.
+##include "Typeable.h"
+
+#if defined(HAVE_WINSOCK_H) && !defined(cygwin32_HOST_OS)
+#define WITH_WINSOCK  1
+#endif
+
+#if !defined(mingw32_HOST_OS) && !defined(_WIN32)
+#define DOMAIN_SOCKET_SUPPORT 1
+#endif
+
+#if !defined(CALLCONV)
+#ifdef WITH_WINSOCK
+#define CALLCONV stdcall
+#else
+#define CALLCONV ccall
+#endif
+#endif
+
+-- In order to process this file, you need to have CALLCONV defined.
+
+module Network.Socket (
+
+    -- * Types
+    Socket(..),		-- instance Eq, Show
+    Family(..),		
+    SocketType(..),
+    SockAddr(..),
+    SocketStatus(..),
+    HostAddress,
+    ShutdownCmd(..),
+    ProtocolNumber,
+    PortNumber(..),
+	-- PortNumber is used non-abstractly in Network.BSD.  ToDo: remove
+	-- this use and make the type abstract.
+
+    -- * Socket Operations
+    socket,		-- :: Family -> SocketType -> ProtocolNumber -> IO Socket 
+#if defined(DOMAIN_SOCKET_SUPPORT)
+    socketPair,         -- :: Family -> SocketType -> ProtocolNumber -> IO (Socket, Socket)
+#endif
+    connect,		-- :: Socket -> SockAddr -> IO ()
+    bindSocket,		-- :: Socket -> SockAddr -> IO ()
+    listen,		-- :: Socket -> Int -> IO ()
+    accept,		-- :: Socket -> IO (Socket, SockAddr)
+    getPeerName,	-- :: Socket -> IO SockAddr
+    getSocketName,	-- :: Socket -> IO SockAddr
+
+#ifdef SO_PEERCRED
+	-- get the credentials of our domain socket peer.
+    getPeerCred,         -- :: Socket -> IO (CUInt{-pid-}, CUInt{-uid-}, CUInt{-gid-})
+#endif
+
+    socketPort,		-- :: Socket -> IO PortNumber
+
+    socketToHandle,	-- :: Socket -> IOMode -> IO Handle
+
+    sendTo,		-- :: Socket -> String -> SockAddr -> IO Int
+    sendBufTo,          -- :: Socket -> Ptr a -> Int -> SockAddr -> IO Int
+
+    recvFrom,		-- :: Socket -> Int -> IO (String, Int, SockAddr)
+    recvBufFrom,        -- :: Socket -> Ptr a -> Int -> IO (Int, SockAddr)
+    
+    send,		-- :: Socket -> String -> IO Int
+    recv,		-- :: Socket -> Int    -> IO String
+    recvLen,            -- :: Socket -> Int    -> IO (String, Int)
+
+    inet_addr,		-- :: String -> IO HostAddress
+    inet_ntoa,		-- :: HostAddress -> IO String
+
+    shutdown,		-- :: Socket -> ShutdownCmd -> IO ()
+    sClose,		-- :: Socket -> IO ()
+
+    -- ** Predicates on sockets
+    sIsConnected,	-- :: Socket -> IO Bool
+    sIsBound,		-- :: Socket -> IO Bool
+    sIsListening,	-- :: Socket -> IO Bool 
+    sIsReadable,	-- :: Socket -> IO Bool
+    sIsWritable,	-- :: Socket -> IO Bool
+
+    -- * Socket options
+    SocketOption(..),
+    getSocketOption,     -- :: Socket -> SocketOption -> IO Int
+    setSocketOption,     -- :: Socket -> SocketOption -> Int -> IO ()
+
+    -- * File descriptor transmission
+#ifdef DOMAIN_SOCKET_SUPPORT
+    sendFd,              -- :: Socket -> CInt -> IO ()
+    recvFd,              -- :: Socket -> IO CInt
+
+      -- Note: these two will disappear shortly
+    sendAncillary,       -- :: Socket -> Int -> Int -> Int -> Ptr a -> Int -> IO ()
+    recvAncillary,       -- :: Socket -> Int -> Int -> IO (Int,Int,Int,Ptr a)
+
+#endif
+
+    -- * Special Constants
+    aNY_PORT,		-- :: PortNumber
+    iNADDR_ANY,		-- :: HostAddress
+    sOMAXCONN,		-- :: Int
+    sOL_SOCKET,         -- :: Int
+#ifdef SCM_RIGHTS
+    sCM_RIGHTS,         -- :: Int
+#endif
+    maxListenQueue,	-- :: Int
+
+    -- * Initialisation
+    withSocketsDo,	-- :: IO a -> IO a
+    
+    -- * Very low level operations
+     -- in case you ever want to get at the underlying file descriptor..
+    fdSocket,           -- :: Socket -> CInt
+    mkSocket,           -- :: CInt   -> Family 
+    			-- -> SocketType
+			-- -> ProtocolNumber
+			-- -> SocketStatus
+			-- -> IO Socket
+
+    -- * Internal
+
+    -- | The following are exported ONLY for use in the BSD module and
+    -- should not be used anywhere else.
+
+    packFamily, unpackFamily,
+    packSocketType,
+    throwSocketErrorIfMinus1_
+
+) where
+
+#ifdef __HUGS__
+import Hugs.Prelude ( IOException(..), IOErrorType(..) )
+import Hugs.IO ( openFd )
+
+{-# CFILES cbits/HsNet.c #-}
+# if HAVE_STRUCT_MSGHDR_MSG_CONTROL || HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
+{-# CFILES cbits/ancilData.c #-}
+# endif
+# if defined(HAVE_WINSOCK_H) && !defined(__CYGWIN__)
+{-# CFILES cbits/initWinSock.c cbits/winSockErr.c #-}
+# endif
+#endif
+
+import Data.Word ( Word8, Word16, Word32 )
+import Foreign.Ptr ( Ptr, castPtr, plusPtr )
+import Foreign.Storable ( Storable(..) )
+import Foreign.C.Error
+import Foreign.C.String ( withCString, peekCString, peekCStringLen, castCharToCChar )
+import Foreign.C.Types ( CInt, CUInt, CChar, CSize )
+import Foreign.Marshal.Alloc ( alloca, allocaBytes )
+import Foreign.Marshal.Array ( peekArray, pokeArray0 )
+import Foreign.Marshal.Utils ( with )
+
+import System.IO
+import Control.Monad ( liftM, when )
+import Data.Ratio ( (%) )
+
+import qualified Control.Exception
+import Control.Concurrent.MVar
+import Data.Typeable
+
+#ifdef __GLASGOW_HASKELL__
+import GHC.Conc		(threadWaitRead, threadWaitWrite)
+# if defined(mingw32_HOST_OS)
+import GHC.Conc		( asyncDoProc )
+import Foreign( FunPtr )
+# endif
+import GHC.Handle
+import GHC.IOBase
+import qualified System.Posix.Internals
+#else
+import System.IO.Unsafe	(unsafePerformIO)
+#endif
+
+-----------------------------------------------------------------------------
+-- Socket types
+
+-- There are a few possible ways to do this.  The first is convert the
+-- structs used in the C library into an equivalent Haskell type. An
+-- other possible implementation is to keep all the internals in the C
+-- code and use an Int## and a status flag. The second method is used
+-- here since a lot of the C structures are not required to be
+-- manipulated.
+
+-- Originally the status was non-mutable so we had to return a new
+-- socket each time we changed the status.  This version now uses
+-- mutable variables to avoid the need to do this.  The result is a
+-- cleaner interface and better security since the application
+-- programmer now can't circumvent the status information to perform
+-- invalid operations on sockets.
+
+data SocketStatus
+  -- Returned Status	Function called
+  = NotConnected	-- socket
+  | Bound		-- bindSocket
+  | Listening		-- listen
+  | Connected		-- connect/accept
+  | ConvertedToHandle   -- is now a Handle, don't touch
+    deriving (Eq, Show)
+
+INSTANCE_TYPEABLE0(SocketStatus,socketStatusTc,"SocketStatus")
+
+data Socket
+  = MkSocket
+	    CInt	         -- File Descriptor
+	    Family				  
+	    SocketType				  
+	    ProtocolNumber	 -- Protocol Number
+	    (MVar SocketStatus)  -- Status Flag
+
+INSTANCE_TYPEABLE0(Socket,socketTc,"Socket")
+
+mkSocket :: CInt
+	 -> Family
+	 -> SocketType
+	 -> ProtocolNumber
+	 -> SocketStatus
+	 -> IO Socket
+mkSocket fd fam sType pNum stat = do
+   mStat <- newMVar stat
+   return (MkSocket fd fam sType pNum mStat)
+
+instance Eq Socket where
+  (MkSocket _ _ _ _ m1) == (MkSocket _ _ _ _ m2) = m1 == m2
+
+instance Show Socket where
+  showsPrec n (MkSocket fd _ _ _ _) = 
+	showString "<socket: " . shows fd . showString ">"
+
+
+fdSocket :: Socket -> CInt
+fdSocket (MkSocket fd _ _ _ _) = fd
+
+type ProtocolNumber = CInt
+
+-- NOTE: HostAddresses are represented in network byte order.
+--       Functions that expect the address in machine byte order
+--       will have to perform the necessary translation.
+type HostAddress = Word32
+
+----------------------------------------------------------------------------
+-- Port Numbers
+--
+-- newtyped to prevent accidental use of sane-looking
+-- port numbers that haven't actually been converted to
+-- network-byte-order first.
+--
+newtype PortNumber = PortNum Word16 deriving ( Eq, Ord )
+
+INSTANCE_TYPEABLE0(PortNumber,portNumberTc,"PortNumber")
+
+instance Show PortNumber where
+  showsPrec p pn = showsPrec p (portNumberToInt pn)
+
+intToPortNumber :: Int -> PortNumber
+intToPortNumber v = PortNum (htons (fromIntegral v))
+
+portNumberToInt :: PortNumber -> Int
+portNumberToInt (PortNum po) = fromIntegral (ntohs po)
+
+foreign import CALLCONV unsafe "ntohs" ntohs :: Word16 -> Word16
+foreign import CALLCONV unsafe "htons" htons :: Word16 -> Word16
+--foreign import CALLCONV unsafe "ntohl" ntohl :: Word32 -> Word32
+foreign import CALLCONV unsafe "htonl" htonl :: Word32 -> Word32
+
+instance Enum PortNumber where
+    toEnum   = intToPortNumber
+    fromEnum = portNumberToInt
+
+instance Num PortNumber where
+   fromInteger i = intToPortNumber (fromInteger i)
+    -- for completeness.
+   (+) x y   = intToPortNumber (portNumberToInt x + portNumberToInt y)
+   (-) x y   = intToPortNumber (portNumberToInt x - portNumberToInt y)
+   negate x  = intToPortNumber (-portNumberToInt x)
+   (*) x y   = intToPortNumber (portNumberToInt x * portNumberToInt y)
+   abs n     = intToPortNumber (abs (portNumberToInt n))
+   signum n  = intToPortNumber (signum (portNumberToInt n))
+
+instance Real PortNumber where
+    toRational x = toInteger x % 1
+
+instance Integral PortNumber where
+    quotRem a b = let (c,d) = quotRem (portNumberToInt a) (portNumberToInt b) in
+		  (intToPortNumber c, intToPortNumber d)
+    toInteger a = toInteger (portNumberToInt a)
+
+instance Storable PortNumber where
+   sizeOf    _ = sizeOf    (undefined :: Word16)
+   alignment _ = alignment (undefined :: Word16)
+   poke p (PortNum po) = poke (castPtr p) po
+   peek p = PortNum `liftM` peek (castPtr p)
+
+-----------------------------------------------------------------------------
+-- SockAddr
+
+-- The scheme used for addressing sockets is somewhat quirky. The
+-- calls in the BSD socket API that need to know the socket address
+-- all operate in terms of struct sockaddr, a `virtual' type of
+-- socket address.
+
+-- The Internet family of sockets are addressed as struct sockaddr_in,
+-- so when calling functions that operate on struct sockaddr, we have
+-- to type cast the Internet socket address into a struct sockaddr.
+-- Instances of the structure for different families might *not* be
+-- the same size. Same casting is required of other families of
+-- sockets such as Xerox NS. Similarly for Unix domain sockets.
+
+-- To represent these socket addresses in Haskell-land, we do what BSD
+-- didn't do, and use a union/algebraic type for the different
+-- families. Currently only Unix domain sockets and the Internet family
+-- are supported.
+
+data SockAddr		-- C Names				
+  = SockAddrInet
+	PortNumber	-- sin_port  (network byte order)
+	HostAddress	-- sin_addr  (ditto)
+#if defined(DOMAIN_SOCKET_SUPPORT)
+  | SockAddrUnix
+        String          -- sun_path
+#endif
+  deriving (Eq)
+
+INSTANCE_TYPEABLE0(SockAddr,sockAddrTc,"SockAddr")
+
+#if defined(WITH_WINSOCK) || defined(cygwin32_HOST_OS)
+type CSaFamily = (#type unsigned short)
+#elif defined(darwin_HOST_OS)
+type CSaFamily = (#type u_char)
+#else
+type CSaFamily = (#type sa_family_t)
+#endif
+
+instance Show SockAddr where
+#if defined(DOMAIN_SOCKET_SUPPORT)
+  showsPrec _ (SockAddrUnix str) = showString str
+#endif
+  showsPrec _ (SockAddrInet port ha)
+   = showString (unsafePerformIO (inet_ntoa ha)) 
+   . showString ":"
+   . shows port
+
+-- we can't write an instance of Storable for SockAddr, because the Storable
+-- class can't easily handle alternatives. Also note that on Darwin, the
+-- sockaddr structure must be zeroed before use.
+
+#if defined(DOMAIN_SOCKET_SUPPORT)
+pokeSockAddr p (SockAddrUnix path) = do
+#if defined(darwin_TARGET_OS)
+	zeroMemory p (#const sizeof(struct sockaddr_un))
+#endif
+	(#poke struct sockaddr_un, sun_family) p ((#const AF_UNIX) :: CSaFamily)
+	let pathC = map castCharToCChar path
+	pokeArray0 0 ((#ptr struct sockaddr_un, sun_path) p) pathC
+#endif
+pokeSockAddr p (SockAddrInet (PortNum port) addr) = do
+#if defined(darwin_TARGET_OS)
+	zeroMemory p (#const sizeof(struct sockaddr_in))
+#endif
+	(#poke struct sockaddr_in, sin_family) p ((#const AF_INET) :: CSaFamily)
+	(#poke struct sockaddr_in, sin_port) p port
+	(#poke struct sockaddr_in, sin_addr) p addr	
+
+peekSockAddr p = do
+  family <- (#peek struct sockaddr, sa_family) p
+  case family :: CSaFamily of
+#if defined(DOMAIN_SOCKET_SUPPORT)
+	(#const AF_UNIX) -> do
+		str <- peekCString ((#ptr struct sockaddr_un, sun_path) p)
+		return (SockAddrUnix str)
+#endif
+	(#const AF_INET) -> do
+		addr <- (#peek struct sockaddr_in, sin_addr) p
+		port <- (#peek struct sockaddr_in, sin_port) p
+		return (SockAddrInet (PortNum port) addr)
+
+-- helper function used to zero a structure
+zeroMemory :: Ptr a -> CSize -> IO ()
+zeroMemory dest nbytes = memset dest 0 (fromIntegral nbytes)
+foreign import ccall unsafe "string.h" memset :: Ptr a -> CInt -> CSize -> IO ()
+
+-- size of struct sockaddr by family
+#if defined(DOMAIN_SOCKET_SUPPORT)
+sizeOfSockAddr_Family AF_UNIX = #const sizeof(struct sockaddr_un)
+#endif
+sizeOfSockAddr_Family AF_INET = #const sizeof(struct sockaddr_in)
+
+-- size of struct sockaddr by SockAddr
+#if defined(DOMAIN_SOCKET_SUPPORT)
+sizeOfSockAddr (SockAddrUnix _)   = #const sizeof(struct sockaddr_un)
+#endif
+sizeOfSockAddr (SockAddrInet _ _) = #const sizeof(struct sockaddr_in)
+
+withSockAddr :: SockAddr -> (Ptr SockAddr -> Int -> IO a) -> IO a
+withSockAddr addr f = do
+ let sz = sizeOfSockAddr addr
+ allocaBytes sz $ \p -> pokeSockAddr p addr >> f (castPtr p) sz
+
+withNewSockAddr :: Family -> (Ptr SockAddr -> Int -> IO a) -> IO a
+withNewSockAddr family f = do
+ let sz = sizeOfSockAddr_Family family
+ allocaBytes sz $ \ptr -> f ptr sz
+
+-----------------------------------------------------------------------------
+-- Connection Functions
+
+-- In the following connection and binding primitives.  The names of
+-- the equivalent C functions have been preserved where possible. It
+-- should be noted that some of these names used in the C library,
+-- \tr{bind} in particular, have a different meaning to many Haskell
+-- programmers and have thus been renamed by appending the prefix
+-- Socket.
+
+-- Create an unconnected socket of the given family, type and
+-- protocol.  The most common invocation of $socket$ is the following:
+--    ...
+--    my_socket <- socket AF_INET Stream 6
+--    ...
+
+socket :: Family 	 -- Family Name (usually AF_INET)
+       -> SocketType 	 -- Socket Type (usually Stream)
+       -> ProtocolNumber -- Protocol Number (getProtocolByName to find value)
+       -> IO Socket	 -- Unconnected Socket
+
+socket family stype protocol = do
+    fd <- throwSocketErrorIfMinus1Retry "socket" $
+		c_socket (packFamily family) (packSocketType stype) protocol
+#if !defined(__HUGS__)
+    System.Posix.Internals.setNonBlockingFD fd
+#endif
+    socket_status <- newMVar NotConnected
+    return (MkSocket fd family stype protocol socket_status)
+
+-- Create an unnamed pair of connected sockets, given family, type and
+-- protocol. Differs from a normal pipe in being a bi-directional channel
+-- of communication.
+
+#if defined(DOMAIN_SOCKET_SUPPORT)
+socketPair :: Family 	          -- Family Name (usually AF_INET)
+           -> SocketType 	  -- Socket Type (usually Stream)
+           -> ProtocolNumber      -- Protocol Number
+           -> IO (Socket, Socket) -- unnamed and connected.
+socketPair family stype protocol = do
+    allocaBytes (2 * sizeOf (1 :: CInt)) $ \ fdArr -> do
+    rc <- throwSocketErrorIfMinus1Retry "socketpair" $
+		c_socketpair (packFamily family)
+			     (packSocketType stype)
+			     protocol fdArr
+    [fd1,fd2] <- peekArray 2 fdArr 
+    s1 <- mkSocket fd1
+    s2 <- mkSocket fd2
+    return (s1,s2)
+  where
+    mkSocket fd = do
+#if !defined(__HUGS__)
+       System.Posix.Internals.setNonBlockingFD fd
+#endif
+       stat <- newMVar Connected
+       return (MkSocket fd family stype protocol stat)
+
+foreign import ccall unsafe "socketpair"
+  c_socketpair :: CInt -> CInt -> CInt -> Ptr CInt -> IO CInt
+#endif
+
+-----------------------------------------------------------------------------
+-- Binding a socket
+--
+-- Given a port number this {\em binds} the socket to that port. This
+-- means that the programmer is only interested in data being sent to
+-- that port number. The $Family$ passed to $bindSocket$ must
+-- be the same as that passed to $socket$.	 If the special port
+-- number $aNY\_PORT$ is passed then the system assigns the next
+-- available use port.
+-- 
+-- Port numbers for standard unix services can be found by calling
+-- $getServiceEntry$.  These are traditionally port numbers below
+-- 1000; although there are afew, namely NFS and IRC, which used higher
+-- numbered ports.
+-- 
+-- The port number allocated to a socket bound by using $aNY\_PORT$ can be
+-- found by calling $port$
+
+bindSocket :: Socket	-- Unconnected Socket
+	   -> SockAddr	-- Address to Bind to
+	   -> IO ()
+
+bindSocket (MkSocket s _family _stype _protocol socketStatus) addr = do
+ modifyMVar_ socketStatus $ \ status -> do
+ if status /= NotConnected 
+  then
+   ioError (userError ("bindSocket: can't peform bind on socket in status " ++
+	 show status))
+  else do
+   withSockAddr addr $ \p_addr sz -> do
+   status <- throwSocketErrorIfMinus1Retry "bind" $ c_bind s p_addr (fromIntegral sz)
+   return Bound
+
+-----------------------------------------------------------------------------
+-- Connecting a socket
+--
+-- Make a connection to an already opened socket on a given machine
+-- and port.  assumes that we have already called createSocket,
+-- otherwise it will fail.
+--
+-- This is the dual to $bindSocket$.  The {\em server} process will
+-- usually bind to a port number, the {\em client} will then connect
+-- to the same port number.  Port numbers of user applications are
+-- normally agreed in advance, otherwise we must rely on some meta
+-- protocol for telling the other side what port number we have been
+-- allocated.
+
+connect :: Socket	-- Unconnected Socket
+	-> SockAddr 	-- Socket address stuff
+	-> IO ()
+
+connect sock@(MkSocket s _family _stype _protocol socketStatus) addr = do
+ modifyMVar_ socketStatus $ \currentStatus -> do
+ if currentStatus /= NotConnected 
+  then
+   ioError (userError ("connect: can't peform connect on socket in status " ++
+         show currentStatus))
+  else do
+   withSockAddr addr $ \p_addr sz -> do
+
+   let  connectLoop = do
+       	   r <- c_connect s p_addr (fromIntegral sz)
+       	   if r == -1
+       	       then do 
+#if !(defined(HAVE_WINSOCK_H) && !defined(cygwin32_HOST_OS))
+	       	       err <- getErrno
+		       case () of
+			 _ | err == eINTR       -> connectLoop
+			 _ | err == eINPROGRESS -> connectBlocked
+--			 _ | err == eAGAIN      -> connectBlocked
+			 otherwise              -> throwErrno "connect"
+#else
+		       rc <- c_getLastError
+		       case rc of
+		         10093 -> do -- WSANOTINITIALISED
+			   withSocketsDo (return ())
+	       	           r <- c_connect s p_addr (fromIntegral sz)
+	       	           if r == -1
+			    then (c_getLastError >>= throwSocketError "connect")
+			    else return r
+			 _ -> throwSocketError "connect" rc
+#endif
+       	       else return r
+
+	connectBlocked = do 
+#if !defined(__HUGS__)
+	   threadWaitWrite (fromIntegral s)
+#endif
+	   err <- getSocketOption sock SoError
+	   if (err == 0)
+	   	then return 0
+	   	else do ioError (errnoToIOError "connect" 
+	   			(Errno (fromIntegral err))
+	   			Nothing Nothing)
+
+   connectLoop
+   return Connected
+
+-----------------------------------------------------------------------------
+-- Listen
+--
+-- The programmer must call $listen$ to tell the system software that
+-- they are now interested in receiving data on this port.  This must
+-- be called on the bound socket before any calls to read or write
+-- data are made.
+
+-- The programmer also gives a number which indicates the length of
+-- the incoming queue of unread messages for this socket. On most
+-- systems the maximum queue length is around 5.  To remove a message
+-- from the queue for processing a call to $accept$ should be made.
+
+listen :: Socket  -- Connected & Bound Socket
+       -> Int 	  -- Queue Length
+       -> IO ()
+
+listen (MkSocket s _family _stype _protocol socketStatus) backlog = do
+ modifyMVar_ socketStatus $ \ status -> do
+ if status /= Bound 
+   then
+    ioError (userError ("listen: can't peform listen on socket in status " ++
+          show status))
+   else do
+    throwSocketErrorIfMinus1Retry "listen" (c_listen s (fromIntegral backlog))
+    return Listening
+
+-----------------------------------------------------------------------------
+-- Accept
+--
+-- A call to `accept' only returns when data is available on the given
+-- socket, unless the socket has been set to non-blocking.  It will
+-- return a new socket which should be used to read the incoming data and
+-- should then be closed. Using the socket returned by `accept' allows
+-- incoming requests to be queued on the original socket.
+
+accept :: Socket			-- Queue Socket
+       -> IO (Socket,			-- Readable Socket
+	      SockAddr)			-- Peer details
+
+accept sock@(MkSocket s family stype protocol status) = do
+ currentStatus <- readMVar status
+ okay <- sIsAcceptable sock
+ if not okay
+   then
+     ioError (userError ("accept: can't perform accept on socket (" ++ (show (family,stype,protocol)) ++") in status " ++
+	 show currentStatus))
+   else do
+     let sz = sizeOfSockAddr_Family family
+     allocaBytes sz $ \ sockaddr -> do
+#if defined(mingw32_HOST_OS) && defined(__GLASGOW_HASKELL__)
+     new_sock <-
+	if threaded 
+	   then with (fromIntegral sz) $ \ ptr_len ->
+		  throwErrnoIfMinus1Retry "Network.Socket.accept" $
+		    c_accept_safe s sockaddr ptr_len
+	   else do
+     		paramData <- c_newAcceptParams s (fromIntegral sz) sockaddr
+     		rc        <- asyncDoProc c_acceptDoProc paramData
+     		new_sock  <- c_acceptNewSock    paramData
+     		c_free paramData
+     		when (rc /= 0)
+     		     (ioError (errnoToIOError "Network.Socket.accept" (Errno (fromIntegral rc)) Nothing Nothing))
+		return new_sock
+#else 
+     with (fromIntegral sz) $ \ ptr_len -> do
+     new_sock <- 
+# if !defined(__HUGS__)
+                 throwErrnoIfMinus1Retry_repeatOnBlock "accept" 
+			(threadWaitRead (fromIntegral s))
+# endif
+			(c_accept s sockaddr ptr_len)
+# if !defined(__HUGS__)
+     System.Posix.Internals.setNonBlockingFD new_sock
+# endif
+#endif
+     addr <- peekSockAddr sockaddr
+     new_status <- newMVar Connected
+     return ((MkSocket new_sock family stype protocol new_status), addr)
+
+#if defined(mingw32_HOST_OS) && !defined(__HUGS__)
+foreign import ccall unsafe "HsNet.h acceptNewSock"
+  c_acceptNewSock :: Ptr () -> IO CInt
+foreign import ccall unsafe "HsNet.h newAcceptParams"
+  c_newAcceptParams :: CInt -> CInt -> Ptr a -> IO (Ptr ())
+foreign import ccall unsafe "HsNet.h &acceptDoProc"
+  c_acceptDoProc :: FunPtr (Ptr () -> IO Int)
+foreign import ccall unsafe "free"
+  c_free:: Ptr a -> IO ()
+#endif
+
+-----------------------------------------------------------------------------
+-- sendTo & recvFrom
+
+sendTo :: Socket	-- (possibly) bound/connected Socket
+       -> String	-- Data to send
+       -> SockAddr
+       -> IO Int	-- Number of Bytes sent
+
+sendTo sock xs addr = do
+ withCString xs $ \str -> do
+   sendBufTo sock str (length xs) addr
+
+sendBufTo :: Socket	      -- (possibly) bound/connected Socket
+          -> Ptr a -> Int     -- Data to send
+          -> SockAddr
+          -> IO Int	      -- Number of Bytes sent
+
+sendBufTo (MkSocket s _family _stype _protocol status) ptr nbytes addr = do
+ withSockAddr addr $ \p_addr sz -> do
+   liftM fromIntegral $
+#if !defined(__HUGS__)
+     throwErrnoIfMinus1Retry_repeatOnBlock "sendTo"
+	(threadWaitWrite (fromIntegral s)) $
+#endif
+	c_sendto s ptr (fromIntegral $ nbytes) 0{-flags-} 
+			p_addr (fromIntegral sz)
+
+recvFrom :: Socket -> Int -> IO (String, Int, SockAddr)
+recvFrom sock nbytes =
+  allocaBytes nbytes $ \ptr -> do
+    (len, sockaddr) <- recvBufFrom sock ptr nbytes
+    str <- peekCStringLen (ptr, len)
+    return (str, len, sockaddr)
+
+recvBufFrom :: Socket -> Ptr a -> Int -> IO (Int, SockAddr)
+recvBufFrom sock@(MkSocket s _family _stype _protocol status) ptr nbytes
+ | nbytes <= 0 = ioError (mkInvalidRecvArgError "Network.Socket.recvFrom")
+ | otherwise   = 
+    withNewSockAddr AF_INET $ \ptr_addr sz -> do
+      alloca $ \ptr_len -> do
+      	poke ptr_len (fromIntegral sz)
+        len <- 
+#if !defined(__HUGS__)
+	       throwErrnoIfMinus1Retry_repeatOnBlock "recvFrom" 
+        	   (threadWaitRead (fromIntegral s)) $
+#endif
+        	   c_recvfrom s ptr (fromIntegral nbytes) 0{-flags-} 
+				ptr_addr ptr_len
+        let len' = fromIntegral len
+	if len' == 0
+	 then ioError (mkEOFError "Network.Socket.recvFrom")
+	 else do
+   	   flg <- sIsConnected sock
+	     -- For at least one implementation (WinSock 2), recvfrom() ignores
+	     -- filling in the sockaddr for connected TCP sockets. Cope with 
+	     -- this by using getPeerName instead.
+	   sockaddr <- 
+		if flg then
+		   getPeerName sock
+		else
+		   peekSockAddr ptr_addr 
+           return (len', sockaddr)
+
+-----------------------------------------------------------------------------
+-- send & recv
+
+send :: Socket	-- Bound/Connected Socket
+     -> String	-- Data to send
+     -> IO Int	-- Number of Bytes sent
+send (MkSocket s _family _stype _protocol status) xs = do
+ let len = length xs
+ withCString xs $ \str -> do
+   liftM fromIntegral $
+#if defined(__GLASGOW_HASKELL__) && defined(mingw32_HOST_OS)
+      writeRawBufferPtr "Network.Socket.send" (fromIntegral s) True str 0
+		(fromIntegral len)
+#else
+# if !defined(__HUGS__)
+     throwErrnoIfMinus1Retry_repeatOnBlock "send"
+	(threadWaitWrite (fromIntegral s)) $
+# endif
+	c_send s str (fromIntegral len) 0{-flags-} 
+#endif
+
+recv :: Socket -> Int -> IO String
+recv sock l = recvLen sock l >>= \ (s,_) -> return s
+
+recvLen :: Socket -> Int -> IO (String, Int)
+recvLen sock@(MkSocket s _family _stype _protocol status) nbytes 
+ | nbytes <= 0 = ioError (mkInvalidRecvArgError "Network.Socket.recv")
+ | otherwise   = do
+     allocaBytes nbytes $ \ptr -> do
+        len <- 
+#if defined(__GLASGOW_HASKELL__) && defined(mingw32_HOST_OS)
+	  readRawBufferPtr "Network.Socket.recvLen" (fromIntegral s) True ptr 0
+		 (fromIntegral nbytes)
+#else
+# if !defined(__HUGS__)
+	       throwErrnoIfMinus1Retry_repeatOnBlock "recv" 
+        	   (threadWaitRead (fromIntegral s)) $
+# endif
+        	   c_recv s ptr (fromIntegral nbytes) 0{-flags-} 
+#endif
+        let len' = fromIntegral len
+	if len' == 0
+	 then ioError (mkEOFError "Network.Socket.recv")
+	 else do
+	   s <- peekCStringLen (ptr,len')
+	   return (s, len')
+
+-- ---------------------------------------------------------------------------
+-- socketPort
+--
+-- The port number the given socket is currently connected to can be
+-- determined by calling $port$, is generally only useful when bind
+-- was given $aNY\_PORT$.
+
+socketPort :: Socket		-- Connected & Bound Socket
+	   -> IO PortNumber	-- Port Number of Socket
+socketPort sock@(MkSocket _ AF_INET _ _ _) = do
+    (SockAddrInet port _) <- getSocketName sock
+    return port
+socketPort (MkSocket _ family _ _ _) =
+    ioError (userError ("socketPort: not supported for Family " ++ show family))
+
+
+-- ---------------------------------------------------------------------------
+-- getPeerName
+
+-- Calling $getPeerName$ returns the address details of the machine,
+-- other than the local one, which is connected to the socket. This is
+-- used in programs such as FTP to determine where to send the
+-- returning data.  The corresponding call to get the details of the
+-- local machine is $getSocketName$.
+
+getPeerName   :: Socket -> IO SockAddr
+getPeerName (MkSocket s family _ _ _) = do
+ withNewSockAddr family $ \ptr sz -> do
+   with (fromIntegral sz) $ \int_star -> do
+   throwSocketErrorIfMinus1Retry "getPeerName" $ c_getpeername s ptr int_star
+   sz <- peek int_star
+   peekSockAddr ptr
+    
+getSocketName :: Socket -> IO SockAddr
+getSocketName (MkSocket s family _ _ _) = do
+ withNewSockAddr family $ \ptr sz -> do
+   with (fromIntegral sz) $ \int_star -> do
+   throwSocketErrorIfMinus1Retry "getSocketName" $ c_getsockname s ptr int_star
+   peekSockAddr ptr
+
+-----------------------------------------------------------------------------
+-- Socket Properties
+
+data SocketOption
+    = DummySocketOption__
+#ifdef SO_DEBUG
+    | Debug         {- SO_DEBUG     -}
+#endif
+#ifdef SO_REUSEADDR
+    | ReuseAddr     {- SO_REUSEADDR -}
+#endif
+#ifdef SO_TYPE
+    | Type          {- SO_TYPE      -}
+#endif
+#ifdef SO_ERROR
+    | SoError       {- SO_ERROR     -}
+#endif
+#ifdef SO_DONTROUTE
+    | DontRoute     {- SO_DONTROUTE -}
+#endif
+#ifdef SO_BROADCAST
+    | Broadcast     {- SO_BROADCAST -}
+#endif
+#ifdef SO_SNDBUF
+    | SendBuffer    {- SO_SNDBUF    -}
+#endif
+#ifdef SO_RCVBUF
+    | RecvBuffer    {- SO_RCVBUF    -}
+#endif
+#ifdef SO_KEEPALIVE
+    | KeepAlive     {- SO_KEEPALIVE -}
+#endif
+#ifdef SO_OOBINLINE
+    | OOBInline     {- SO_OOBINLINE -}
+#endif
+#ifdef IP_TTL
+    | TimeToLive    {- IP_TTL       -}
+#endif
+#ifdef TCP_MAXSEG
+    | MaxSegment    {- TCP_MAXSEG   -}
+#endif
+#ifdef TCP_NODELAY
+    | NoDelay       {- TCP_NODELAY  -}
+#endif
+#ifdef SO_LINGER
+    | Linger        {- SO_LINGER    -}
+#endif
+#ifdef SO_REUSEPORT
+    | ReusePort     {- SO_REUSEPORT -}
+#endif
+#ifdef SO_RCVLOWAT
+    | RecvLowWater  {- SO_RCVLOWAT  -}
+#endif
+#ifdef SO_SNDLOWAT
+    | SendLowWater  {- SO_SNDLOWAT  -}
+#endif
+#ifdef SO_RCVTIMEO
+    | RecvTimeOut   {- SO_RCVTIMEO  -}
+#endif
+#ifdef SO_SNDTIMEO
+    | SendTimeOut   {- SO_SNDTIMEO  -}
+#endif
+#ifdef SO_USELOOPBACK
+    | UseLoopBack   {- SO_USELOOPBACK -}
+#endif
+
+INSTANCE_TYPEABLE0(SocketOption,socketOptionTc,"SocketOption")
+
+socketOptLevel :: SocketOption -> CInt
+socketOptLevel so = 
+  case so of
+#ifdef IP_TTL
+    TimeToLive   -> #const IPPROTO_IP
+#endif
+#ifdef TCP_MAXSEG
+    MaxSegment   -> #const IPPROTO_TCP
+#endif
+#ifdef TCP_NODELAY
+    NoDelay      -> #const IPPROTO_TCP
+#endif
+    _            -> #const SOL_SOCKET
+
+packSocketOption :: SocketOption -> CInt
+packSocketOption so =
+  case so of
+#ifdef SO_DEBUG
+    Debug         -> #const SO_DEBUG
+#endif
+#ifdef SO_REUSEADDR
+    ReuseAddr     -> #const SO_REUSEADDR
+#endif
+#ifdef SO_TYPE
+    Type          -> #const SO_TYPE
+#endif
+#ifdef SO_ERROR
+    SoError       -> #const SO_ERROR
+#endif
+#ifdef SO_DONTROUTE
+    DontRoute     -> #const SO_DONTROUTE
+#endif
+#ifdef SO_BROADCAST
+    Broadcast     -> #const SO_BROADCAST
+#endif
+#ifdef SO_SNDBUF
+    SendBuffer    -> #const SO_SNDBUF
+#endif
+#ifdef SO_RCVBUF
+    RecvBuffer    -> #const SO_RCVBUF
+#endif
+#ifdef SO_KEEPALIVE
+    KeepAlive     -> #const SO_KEEPALIVE
+#endif
+#ifdef SO_OOBINLINE
+    OOBInline     -> #const SO_OOBINLINE
+#endif
+#ifdef IP_TTL
+    TimeToLive    -> #const IP_TTL
+#endif
+#ifdef TCP_MAXSEG
+    MaxSegment    -> #const TCP_MAXSEG
+#endif
+#ifdef TCP_NODELAY
+    NoDelay       -> #const TCP_NODELAY
+#endif
+#ifdef SO_LINGER
+    Linger	  -> #const SO_LINGER
+#endif
+#ifdef SO_REUSEPORT
+    ReusePort     -> #const SO_REUSEPORT
+#endif
+#ifdef SO_RCVLOWAT
+    RecvLowWater  -> #const SO_RCVLOWAT
+#endif
+#ifdef SO_SNDLOWAT
+    SendLowWater  -> #const SO_SNDLOWAT
+#endif
+#ifdef SO_RCVTIMEO
+    RecvTimeOut   -> #const SO_RCVTIMEO
+#endif
+#ifdef SO_SNDTIMEO
+    SendTimeOut   -> #const SO_SNDTIMEO
+#endif
+#ifdef SO_USELOOPBACK
+    UseLoopBack   -> #const SO_USELOOPBACK
+#endif
+
+setSocketOption :: Socket 
+		-> SocketOption -- Option Name
+		-> Int		-- Option Value
+		-> IO ()
+setSocketOption (MkSocket s _ _ _ _) so v = do
+   with (fromIntegral v) $ \ptr_v -> do
+   throwErrnoIfMinus1_ "setSocketOption" $
+       c_setsockopt s (socketOptLevel so) (packSocketOption so) ptr_v 
+	  (fromIntegral (sizeOf v))
+   return ()
+
+
+getSocketOption :: Socket
+		-> SocketOption  -- Option Name
+		-> IO Int	 -- Option Value
+getSocketOption (MkSocket s _ _ _ _) so = do
+   alloca $ \ptr_v ->
+     with (fromIntegral (sizeOf (undefined :: CInt))) $ \ptr_sz -> do
+       throwErrnoIfMinus1 "getSocketOption" $
+	 c_getsockopt s (socketOptLevel so) (packSocketOption so) ptr_v ptr_sz
+       fromIntegral `liftM` peek ptr_v
+
+
+#ifdef SO_PEERCRED
+-- | Returns the processID, userID and groupID of the socket's peer.
+--
+-- Only available on platforms that support SO_PEERCRED on domain sockets.
+getPeerCred :: Socket -> IO (CUInt, CUInt, CUInt)
+getPeerCred sock = do
+  let fd = fdSocket sock
+  let sz = (fromIntegral (#const sizeof(struct ucred)))
+  with sz $ \ ptr_cr -> 
+   alloca       $ \ ptr_sz -> do
+     poke ptr_sz sz
+     throwErrnoIfMinus1 "getPeerCred" $
+       c_getsockopt fd (#const SOL_SOCKET) (#const SO_PEERCRED) ptr_cr ptr_sz
+     pid <- (#peek struct ucred, pid) ptr_cr
+     uid <- (#peek struct ucred, uid) ptr_cr
+     gid <- (#peek struct ucred, gid) ptr_cr
+     return (pid, uid, gid)
+#endif
+
+#if defined(DOMAIN_SOCKET_SUPPORT)
+-- sending/receiving ancillary socket data; low-level mechanism
+-- for transmitting file descriptors, mainly.
+sendFd :: Socket -> CInt -> IO ()
+sendFd sock outfd = do
+  let fd = fdSocket sock
+#if !defined(__HUGS__)
+  throwErrnoIfMinus1Retry_repeatOnBlock "sendFd"
+     (threadWaitWrite (fromIntegral fd)) $
+     c_sendFd fd outfd
+#else
+  c_sendFd fd outfd
+#endif
+   -- Note: If Winsock supported FD-passing, thi would have been 
+   -- incorrect (since socket FDs need to be closed via closesocket().)
+  c_close outfd
+  return ()
+  
+recvFd :: Socket -> IO CInt
+recvFd sock = do
+  let fd = fdSocket sock
+  theFd <- 
+#if !defined(__HUGS__)
+    throwErrnoIfMinus1Retry_repeatOnBlock "recvFd" 
+        (threadWaitRead (fromIntegral fd)) $
+#endif
+         c_recvFd fd
+  return theFd
+
+
+sendAncillary :: Socket
+	      -> Int
+	      -> Int
+	      -> Int
+	      -> Ptr a
+	      -> Int
+	      -> IO ()
+sendAncillary sock level ty flags datum len = do
+  let fd = fdSocket sock
+  _ <-
+#if !defined(__HUGS__)
+   throwErrnoIfMinus1Retry_repeatOnBlock "sendAncillary"
+     (threadWaitWrite (fromIntegral fd)) $
+#endif
+     c_sendAncillary fd (fromIntegral level) (fromIntegral ty)
+     			(fromIntegral flags) datum (fromIntegral len)
+  return ()
+
+recvAncillary :: Socket
+	      -> Int
+	      -> Int
+	      -> IO (Int,Int,Ptr a,Int)
+recvAncillary sock flags len = do
+  let fd = fdSocket sock
+  alloca      $ \ ptr_len   ->
+   alloca      $ \ ptr_lev   ->
+    alloca      $ \ ptr_ty    ->
+     alloca      $ \ ptr_pData -> do
+      poke ptr_len (fromIntegral len)
+      _ <- 
+#if !defined(__HUGS__)
+        throwErrnoIfMinus1Retry_repeatOnBlock "recvAncillary" 
+            (threadWaitRead (fromIntegral fd)) $
+#endif
+	    c_recvAncillary fd ptr_lev ptr_ty (fromIntegral flags) ptr_pData ptr_len
+      len <- fromIntegral `liftM` peek ptr_len
+      lev <- fromIntegral `liftM` peek ptr_lev
+      ty  <- fromIntegral `liftM` peek ptr_ty
+      pD  <- peek ptr_pData
+      return (lev,ty,pD, len)
+foreign import ccall unsafe "sendAncillary"
+  c_sendAncillary :: CInt -> CInt -> CInt -> CInt -> Ptr a -> CInt -> IO CInt
+
+foreign import ccall unsafe "recvAncillary"
+  c_recvAncillary :: CInt -> Ptr CInt -> Ptr CInt -> CInt -> Ptr (Ptr a) -> Ptr CInt -> IO CInt
+
+foreign import ccall unsafe "sendFd" c_sendFd :: CInt -> CInt -> IO CInt
+foreign import ccall unsafe "recvFd" c_recvFd :: CInt -> IO CInt
+
+#endif
+
+
+{-
+A calling sequence table for the main functions is shown in the table below.
+
+\begin{figure}[h]
+\begin{center}
+\begin{tabular}{|l|c|c|c|c|c|c|c|}d
+\hline
+{\bf A Call to} & socket & connect & bindSocket & listen & accept & read & write \\
+\hline
+{\bf Precedes} & & & & & & & \\
+\hline 
+socket &	&	  &	       &	&	 &	& \\
+\hline
+connect & +	&	  &	       &	&	 &	& \\
+\hline
+bindSocket & +	&	  &	       &	&	 &	& \\
+\hline
+listen &	&	  & +	       &	&	 &	& \\
+\hline
+accept &	&	  &	       &  +	&	 &	& \\
+\hline
+read   &	&   +	  &	       &  +	&  +	 &  +	& + \\
+\hline
+write  &	&   +	  &	       &  +	&  +	 &  +	& + \\
+\hline
+\end{tabular}
+\caption{Sequence Table for Major functions of Socket}
+\label{tab:api-seq}
+\end{center}
+\end{figure}
+-}
+
+-- ---------------------------------------------------------------------------
+-- OS Dependent Definitions
+    
+unpackFamily	:: CInt -> Family
+packFamily	:: Family -> CInt
+
+packSocketType	:: SocketType -> CInt
+
+-- | Address Families.
+--
+-- This data type might have different constructors depending on what is
+-- supported by the operating system.
+data Family
+	= AF_UNSPEC	-- unspecified
+#ifdef AF_UNIX
+	| AF_UNIX	-- local to host (pipes, portals
+#endif
+#ifdef AF_INET
+	| AF_INET	-- internetwork: UDP, TCP, etc
+#endif
+#ifdef AF_INET6
+        | AF_INET6	-- Internet Protocol version 6
+#endif
+#ifdef AF_IMPLINK
+	| AF_IMPLINK	-- arpanet imp addresses
+#endif
+#ifdef AF_PUP
+	| AF_PUP	-- pup protocols: e.g. BSP
+#endif
+#ifdef AF_CHAOS
+	| AF_CHAOS	-- mit CHAOS protocols
+#endif
+#ifdef AF_NS
+	| AF_NS		-- XEROX NS protocols 
+#endif
+#ifdef AF_NBS
+	| AF_NBS	-- nbs protocols
+#endif
+#ifdef AF_ECMA
+	| AF_ECMA	-- european computer manufacturers
+#endif
+#ifdef AF_DATAKIT
+	| AF_DATAKIT	-- datakit protocols
+#endif
+#ifdef AF_CCITT
+	| AF_CCITT	-- CCITT protocols, X.25 etc
+#endif
+#ifdef AF_SNA
+	| AF_SNA	-- IBM SNA
+#endif
+#ifdef AF_DECnet
+	| AF_DECnet	-- DECnet
+#endif
+#ifdef AF_DLI
+	| AF_DLI	-- Direct data link interface
+#endif
+#ifdef AF_LAT
+	| AF_LAT	-- LAT
+#endif
+#ifdef AF_HYLINK
+	| AF_HYLINK	-- NSC Hyperchannel
+#endif
+#ifdef AF_APPLETALK
+	| AF_APPLETALK	-- Apple Talk
+#endif
+#ifdef AF_ROUTE
+	| AF_ROUTE	-- Internal Routing Protocol 
+#endif
+#ifdef AF_NETBIOS
+	| AF_NETBIOS	-- NetBios-style addresses
+#endif
+#ifdef AF_NIT
+	| AF_NIT	-- Network Interface Tap
+#endif
+#ifdef AF_802
+	| AF_802	-- IEEE 802.2, also ISO 8802
+#endif
+#ifdef AF_ISO
+	| AF_ISO	-- ISO protocols
+#endif
+#ifdef AF_OSI
+	| AF_OSI	-- umbrella of all families used by OSI
+#endif
+#ifdef AF_NETMAN
+	| AF_NETMAN	-- DNA Network Management 
+#endif
+#ifdef AF_X25
+	| AF_X25	-- CCITT X.25
+#endif
+#ifdef AF_AX25
+	| AF_AX25
+#endif
+#ifdef AF_OSINET
+	| AF_OSINET	-- AFI
+#endif
+#ifdef AF_GOSSIP
+	| AF_GOSSIP	-- US Government OSI
+#endif
+#ifdef AF_IPX
+	| AF_IPX	-- Novell Internet Protocol
+#endif
+#ifdef Pseudo_AF_XTP
+	| Pseudo_AF_XTP	-- eXpress Transfer Protocol (no AF) 
+#endif
+#ifdef AF_CTF
+	| AF_CTF	-- Common Trace Facility 
+#endif
+#ifdef AF_WAN
+	| AF_WAN	-- Wide Area Network protocols 
+#endif
+#ifdef AF_SDL
+        | AF_SDL	-- SGI Data Link for DLPI
+#endif
+#ifdef AF_NETWARE
+        | AF_NETWARE	
+#endif
+#ifdef AF_NDD
+        | AF_NDD		
+#endif
+#ifdef AF_INTF
+        | AF_INTF	-- Debugging use only 
+#endif
+#ifdef AF_COIP
+        | AF_COIP         -- connection-oriented IP, aka ST II
+#endif
+#ifdef AF_CNT
+        | AF_CNT	-- Computer Network Technology
+#endif
+#ifdef Pseudo_AF_RTIP
+        | Pseudo_AF_RTIP  -- Help Identify RTIP packets
+#endif
+#ifdef Pseudo_AF_PIP
+        | Pseudo_AF_PIP   -- Help Identify PIP packets
+#endif
+#ifdef AF_SIP
+        | AF_SIP          -- Simple Internet Protocol
+#endif
+#ifdef AF_ISDN
+        | AF_ISDN         -- Integrated Services Digital Network
+#endif
+#ifdef Pseudo_AF_KEY
+        | Pseudo_AF_KEY   -- Internal key-management function
+#endif
+#ifdef AF_NATM
+        | AF_NATM         -- native ATM access
+#endif
+#ifdef AF_ARP
+        | AF_ARP          -- (rev.) addr. res. prot. (RFC 826)
+#endif
+#ifdef Pseudo_AF_HDRCMPLT
+        | Pseudo_AF_HDRCMPLT -- Used by BPF to not rewrite hdrs in iface output
+#endif
+#ifdef AF_ENCAP
+        | AF_ENCAP 
+#endif
+#ifdef AF_LINK
+	| AF_LINK	-- Link layer interface 
+#endif
+#ifdef AF_RAW
+        | AF_RAW	-- Link layer interface
+#endif
+#ifdef AF_RIF
+        | AF_RIF	-- raw interface 
+#endif
+#ifdef AF_NETROM
+	| AF_NETROM			-- Amateur radio NetROM
+#endif
+#ifdef AF_BRIDGE
+	| AF_BRIDGE			-- multiprotocol bridge
+#endif
+#ifdef AF_ATMPVC
+	| AF_ATMPVC			-- ATM PVCs
+#endif
+#ifdef AF_ROSE
+	| AF_ROSE			-- Amateur Radio X.25 PLP
+#endif
+#ifdef AF_NETBEUI
+	| AF_NETBEUI			-- 802.2LLC
+#endif
+#ifdef AF_SECURITY
+	| AF_SECURITY			-- Security callback pseudo AF
+#endif
+#ifdef AF_PACKET
+	| AF_PACKET			-- Packet family
+#endif
+#ifdef AF_ASH
+	| AF_ASH			-- Ash
+#endif
+#ifdef AF_ECONET
+	| AF_ECONET			-- Acorn Econet
+#endif
+#ifdef AF_ATMSVC
+	| AF_ATMSVC			-- ATM SVCs
+#endif
+#ifdef AF_IRDA
+	| AF_IRDA			-- IRDA sockets
+#endif
+#ifdef AF_PPPOX
+	| AF_PPPOX			-- PPPoX sockets
+#endif
+#ifdef AF_WANPIPE
+	| AF_WANPIPE			-- Wanpipe API sockets
+#endif
+#ifdef AF_BLUETOOTH
+	| AF_BLUETOOTH			-- bluetooth sockets
+#endif
+	deriving (Eq, Ord, Read, Show)
+
+------ ------
+			
+packFamily f = case f of
+	AF_UNSPEC -> #const AF_UNSPEC
+#ifdef AF_UNIX
+	AF_UNIX -> #const AF_UNIX
+#endif
+#ifdef AF_INET
+	AF_INET -> #const AF_INET
+#endif
+#ifdef AF_INET6
+        AF_INET6 -> #const AF_INET6
+#endif
+#ifdef AF_IMPLINK
+	AF_IMPLINK -> #const AF_IMPLINK
+#endif
+#ifdef AF_PUP
+	AF_PUP -> #const AF_PUP
+#endif
+#ifdef AF_CHAOS
+	AF_CHAOS -> #const AF_CHAOS
+#endif
+#ifdef AF_NS
+	AF_NS -> #const AF_NS
+#endif
+#ifdef AF_NBS
+	AF_NBS -> #const AF_NBS
+#endif
+#ifdef AF_ECMA
+	AF_ECMA -> #const AF_ECMA
+#endif
+#ifdef AF_DATAKIT
+	AF_DATAKIT -> #const AF_DATAKIT
+#endif
+#ifdef AF_CCITT
+	AF_CCITT -> #const AF_CCITT
+#endif
+#ifdef AF_SNA
+	AF_SNA -> #const AF_SNA
+#endif
+#ifdef AF_DECnet
+	AF_DECnet -> #const AF_DECnet
+#endif
+#ifdef AF_DLI
+	AF_DLI -> #const AF_DLI
+#endif
+#ifdef AF_LAT
+	AF_LAT -> #const AF_LAT
+#endif
+#ifdef AF_HYLINK
+	AF_HYLINK -> #const AF_HYLINK
+#endif
+#ifdef AF_APPLETALK
+	AF_APPLETALK -> #const AF_APPLETALK
+#endif
+#ifdef AF_ROUTE
+	AF_ROUTE -> #const AF_ROUTE
+#endif
+#ifdef AF_NETBIOS
+	AF_NETBIOS -> #const AF_NETBIOS
+#endif
+#ifdef AF_NIT
+	AF_NIT -> #const AF_NIT
+#endif
+#ifdef AF_802
+	AF_802 -> #const AF_802
+#endif
+#ifdef AF_ISO
+	AF_ISO -> #const AF_ISO
+#endif
+#ifdef AF_OSI
+	AF_OSI -> #const AF_OSI
+#endif
+#ifdef AF_NETMAN
+	AF_NETMAN -> #const AF_NETMAN
+#endif
+#ifdef AF_X25
+	AF_X25 -> #const AF_X25
+#endif
+#ifdef AF_AX25
+	AF_AX25 -> #const AF_AX25
+#endif
+#ifdef AF_OSINET
+	AF_OSINET -> #const AF_OSINET
+#endif
+#ifdef AF_GOSSIP
+	AF_GOSSIP -> #const AF_GOSSIP
+#endif
+#ifdef AF_IPX
+	AF_IPX -> #const AF_IPX
+#endif
+#ifdef Pseudo_AF_XTP
+	Pseudo_AF_XTP -> #const Pseudo_AF_XTP
+#endif
+#ifdef AF_CTF
+	AF_CTF -> #const AF_CTF
+#endif
+#ifdef AF_WAN
+	AF_WAN -> #const AF_WAN
+#endif
+#ifdef AF_SDL
+        AF_SDL -> #const AF_SDL
+#endif
+#ifdef AF_NETWARE
+        AF_NETWARE -> #const AF_NETWARE	
+#endif
+#ifdef AF_NDD
+        AF_NDD -> #const AF_NDD		
+#endif
+#ifdef AF_INTF
+        AF_INTF -> #const AF_INTF
+#endif
+#ifdef AF_COIP
+        AF_COIP -> #const AF_COIP
+#endif
+#ifdef AF_CNT
+        AF_CNT -> #const AF_CNT
+#endif
+#ifdef Pseudo_AF_RTIP
+        Pseudo_AF_RTIP -> #const Pseudo_AF_RTIP
+#endif
+#ifdef Pseudo_AF_PIP
+        Pseudo_AF_PIP -> #const Pseudo_AF_PIP
+#endif
+#ifdef AF_SIP
+        AF_SIP -> #const AF_SIP
+#endif
+#ifdef AF_ISDN
+        AF_ISDN -> #const AF_ISDN
+#endif
+#ifdef Pseudo_AF_KEY
+        Pseudo_AF_KEY -> #const Pseudo_AF_KEY
+#endif
+#ifdef AF_NATM
+        AF_NATM -> #const AF_NATM
+#endif
+#ifdef AF_ARP
+        AF_ARP -> #const AF_ARP
+#endif
+#ifdef Pseudo_AF_HDRCMPLT
+        Pseudo_AF_HDRCMPLT -> #const Pseudo_AF_HDRCMPLT
+#endif
+#ifdef AF_ENCAP
+        AF_ENCAP -> #const AF_ENCAP 
+#endif
+#ifdef AF_LINK
+	AF_LINK -> #const AF_LINK
+#endif
+#ifdef AF_RAW
+        AF_RAW -> #const AF_RAW
+#endif
+#ifdef AF_RIF
+        AF_RIF -> #const AF_RIF
+#endif
+#ifdef AF_NETROM
+	AF_NETROM -> #const AF_NETROM
+#endif
+#ifdef AF_BRIDGE
+	AF_BRIDGE -> #const AF_BRIDGE
+#endif
+#ifdef AF_ATMPVC
+	AF_ATMPVC -> #const AF_ATMPVC
+#endif
+#ifdef AF_ROSE
+	AF_ROSE -> #const AF_ROSE
+#endif
+#ifdef AF_NETBEUI
+	AF_NETBEUI -> #const AF_NETBEUI
+#endif
+#ifdef AF_SECURITY
+	AF_SECURITY -> #const AF_SECURITY
+#endif
+#ifdef AF_PACKET
+	AF_PACKET -> #const AF_PACKET
+#endif
+#ifdef AF_ASH
+	AF_ASH -> #const AF_ASH
+#endif
+#ifdef AF_ECONET
+	AF_ECONET -> #const AF_ECONET
+#endif
+#ifdef AF_ATMSVC
+	AF_ATMSVC -> #const AF_ATMSVC
+#endif
+#ifdef AF_IRDA
+	AF_IRDA -> #const AF_IRDA
+#endif
+#ifdef AF_PPPOX
+	AF_PPPOX -> #const AF_PPPOX
+#endif
+#ifdef AF_WANPIPE
+	AF_WANPIPE -> #const AF_WANPIPE
+#endif
+#ifdef AF_BLUETOOTH
+	AF_BLUETOOTH -> #const AF_BLUETOOTH
+#endif
+
+--------- ----------
+
+unpackFamily f = case f of
+	(#const AF_UNSPEC) -> AF_UNSPEC
+#ifdef AF_UNIX
+	(#const AF_UNIX) -> AF_UNIX
+#endif
+#ifdef AF_INET
+	(#const AF_INET) -> AF_INET
+#endif
+#ifdef AF_INET6
+        (#const AF_INET6) -> AF_INET6
+#endif
+#ifdef AF_IMPLINK
+	(#const AF_IMPLINK) -> AF_IMPLINK
+#endif
+#ifdef AF_PUP
+	(#const AF_PUP) -> AF_PUP
+#endif
+#ifdef AF_CHAOS
+	(#const AF_CHAOS) -> AF_CHAOS
+#endif
+#ifdef AF_NS
+	(#const AF_NS) -> AF_NS
+#endif
+#ifdef AF_NBS
+	(#const AF_NBS) -> AF_NBS
+#endif
+#ifdef AF_ECMA
+	(#const AF_ECMA) -> AF_ECMA
+#endif
+#ifdef AF_DATAKIT
+	(#const AF_DATAKIT) -> AF_DATAKIT
+#endif
+#ifdef AF_CCITT
+	(#const AF_CCITT) -> AF_CCITT
+#endif
+#ifdef AF_SNA
+	(#const AF_SNA) -> AF_SNA
+#endif
+#ifdef AF_DECnet
+	(#const AF_DECnet) -> AF_DECnet
+#endif
+#ifdef AF_DLI
+	(#const AF_DLI) -> AF_DLI
+#endif
+#ifdef AF_LAT
+	(#const AF_LAT) -> AF_LAT
+#endif
+#ifdef AF_HYLINK
+	(#const AF_HYLINK) -> AF_HYLINK
+#endif
+#ifdef AF_APPLETALK
+	(#const AF_APPLETALK) -> AF_APPLETALK
+#endif
+#ifdef AF_ROUTE
+	(#const AF_ROUTE) -> AF_ROUTE
+#endif
+#ifdef AF_NETBIOS
+	(#const AF_NETBIOS) -> AF_NETBIOS
+#endif
+#ifdef AF_NIT
+	(#const AF_NIT) -> AF_NIT
+#endif
+#ifdef AF_802
+	(#const AF_802) -> AF_802
+#endif
+#ifdef AF_ISO
+	(#const AF_ISO) -> AF_ISO
+#endif
+#ifdef AF_OSI
+# if (!defined(AF_ISO)) || (defined(AF_ISO) && (AF_ISO != AF_OSI))
+	(#const AF_OSI) -> AF_OSI
+# endif
+#endif
+#ifdef AF_NETMAN
+	(#const AF_NETMAN) -> AF_NETMAN
+#endif
+#ifdef AF_X25
+	(#const AF_X25) -> AF_X25
+#endif
+#ifdef AF_AX25
+	(#const AF_AX25) -> AF_AX25
+#endif
+#ifdef AF_OSINET
+	(#const AF_OSINET) -> AF_OSINET
+#endif
+#ifdef AF_GOSSIP
+	(#const AF_GOSSIP) -> AF_GOSSIP
+#endif
+#ifdef AF_IPX
+	(#const AF_IPX) -> AF_IPX
+#endif
+#ifdef Pseudo_AF_XTP
+	(#const Pseudo_AF_XTP) -> Pseudo_AF_XTP
+#endif
+#ifdef AF_CTF
+	(#const AF_CTF) -> AF_CTF
+#endif
+#ifdef AF_WAN
+	(#const AF_WAN) -> AF_WAN
+#endif
+#ifdef AF_SDL
+        (#const AF_SDL) -> AF_SDL
+#endif
+#ifdef AF_NETWARE
+        (#const AF_NETWARE) -> AF_NETWARE	
+#endif
+#ifdef AF_NDD
+        (#const AF_NDD) -> AF_NDD		
+#endif
+#ifdef AF_INTF
+        (#const AF_INTF) -> AF_INTF
+#endif
+#ifdef AF_COIP
+        (#const AF_COIP) -> AF_COIP
+#endif
+#ifdef AF_CNT
+        (#const AF_CNT) -> AF_CNT
+#endif
+#ifdef Pseudo_AF_RTIP
+        (#const Pseudo_AF_RTIP) -> Pseudo_AF_RTIP
+#endif
+#ifdef Pseudo_AF_PIP
+        (#const Pseudo_AF_PIP) -> Pseudo_AF_PIP
+#endif
+#ifdef AF_SIP
+        (#const AF_SIP) -> AF_SIP
+#endif
+#ifdef AF_ISDN
+        (#const AF_ISDN) -> AF_ISDN
+#endif
+#ifdef Pseudo_AF_KEY
+        (#const Pseudo_AF_KEY) -> Pseudo_AF_KEY
+#endif
+#ifdef AF_NATM
+        (#const AF_NATM) -> AF_NATM
+#endif
+#ifdef AF_ARP
+        (#const AF_ARP) -> AF_ARP
+#endif
+#ifdef Pseudo_AF_HDRCMPLT
+        (#const Pseudo_AF_HDRCMPLT) -> Pseudo_AF_HDRCMPLT
+#endif
+#ifdef AF_ENCAP
+        (#const AF_ENCAP) -> AF_ENCAP 
+#endif
+#ifdef AF_LINK
+	(#const AF_LINK) -> AF_LINK
+#endif
+#ifdef AF_RAW
+        (#const AF_RAW) -> AF_RAW
+#endif
+#ifdef AF_RIF
+        (#const AF_RIF) -> AF_RIF
+#endif
+#ifdef AF_NETROM
+	(#const AF_NETROM) -> AF_NETROM
+#endif
+#ifdef AF_BRIDGE
+	(#const AF_BRIDGE) -> AF_BRIDGE
+#endif
+#ifdef AF_ATMPVC
+	(#const AF_ATMPVC) -> AF_ATMPVC
+#endif
+#ifdef AF_ROSE
+	(#const AF_ROSE) -> AF_ROSE
+#endif
+#ifdef AF_NETBEUI
+	(#const AF_NETBEUI) -> AF_NETBEUI
+#endif
+#ifdef AF_SECURITY
+	(#const AF_SECURITY) -> AF_SECURITY
+#endif
+#ifdef AF_PACKET
+	(#const AF_PACKET) -> AF_PACKET
+#endif
+#ifdef AF_ASH
+	(#const AF_ASH) -> AF_ASH
+#endif
+#ifdef AF_ECONET
+	(#const AF_ECONET) -> AF_ECONET
+#endif
+#ifdef AF_ATMSVC
+	(#const AF_ATMSVC) -> AF_ATMSVC
+#endif
+#ifdef AF_IRDA
+	(#const AF_IRDA) -> AF_IRDA
+#endif
+#ifdef AF_PPPOX
+	(#const AF_PPPOX) -> AF_PPPOX
+#endif
+#ifdef AF_WANPIPE
+	(#const AF_WANPIPE) -> AF_WANPIPE
+#endif
+#ifdef AF_BLUETOOTH
+	(#const AF_BLUETOOTH) -> AF_BLUETOOTH
+#endif
+
+-- Socket Types.
+
+-- | Socket Types.
+--
+-- This data type might have different constructors depending on what is
+-- supported by the operating system.
+data SocketType
+	= NoSocketType
+#ifdef SOCK_STREAM
+	| Stream 
+#endif
+#ifdef SOCK_DGRAM
+	| Datagram
+#endif
+#ifdef SOCK_RAW
+	| Raw 
+#endif
+#ifdef SOCK_RDM
+	| RDM 
+#endif
+#ifdef SOCK_SEQPACKET
+	| SeqPacket
+#endif
+	deriving (Eq, Ord, Read, Show)
+	
+INSTANCE_TYPEABLE0(SocketType,socketTypeTc,"SocketType")
+
+packSocketType stype = case stype of
+	NoSocketType -> 0
+#ifdef SOCK_STREAM
+	Stream -> #const SOCK_STREAM
+#endif
+#ifdef SOCK_DGRAM
+	Datagram -> #const SOCK_DGRAM
+#endif
+#ifdef SOCK_RAW
+	Raw -> #const SOCK_RAW
+#endif
+#ifdef SOCK_RDM
+	RDM -> #const SOCK_RDM
+#endif
+#ifdef SOCK_SEQPACKET
+	SeqPacket -> #const SOCK_SEQPACKET
+#endif
+
+-- ---------------------------------------------------------------------------
+-- Utility Functions
+
+aNY_PORT :: PortNumber 
+aNY_PORT = 0
+
+iNADDR_ANY :: HostAddress
+iNADDR_ANY = htonl (#const INADDR_ANY)
+
+sOMAXCONN :: Int
+sOMAXCONN = #const SOMAXCONN
+
+sOL_SOCKET :: Int
+sOL_SOCKET = #const SOL_SOCKET
+
+#ifdef SCM_RIGHTS
+sCM_RIGHTS :: Int
+sCM_RIGHTS = #const SCM_RIGHTS
+#endif
+
+maxListenQueue :: Int
+maxListenQueue = sOMAXCONN
+
+-- -----------------------------------------------------------------------------
+
+data ShutdownCmd 
+ = ShutdownReceive
+ | ShutdownSend
+ | ShutdownBoth
+
+INSTANCE_TYPEABLE0(ShutdownCmd,shutdownCmdTc,"ShutdownCmd")
+
+sdownCmdToInt :: ShutdownCmd -> CInt
+sdownCmdToInt ShutdownReceive = 0
+sdownCmdToInt ShutdownSend    = 1
+sdownCmdToInt ShutdownBoth    = 2
+
+shutdown :: Socket -> ShutdownCmd -> IO ()
+shutdown (MkSocket s _ _ _ _) stype = do
+  throwSocketErrorIfMinus1Retry "shutdown" (c_shutdown s (sdownCmdToInt stype))
+  return ()
+
+-- -----------------------------------------------------------------------------
+
+-- | Closes a socket
+sClose	 :: Socket -> IO ()
+sClose (MkSocket s _ _ _ socketStatus) = do 
+ withMVar socketStatus $ \ status ->
+   if status == ConvertedToHandle
+	then ioError (userError ("sClose: converted to a Handle, use hClose instead"))
+	else c_close s; return ()
+
+-- -----------------------------------------------------------------------------
+
+sIsConnected :: Socket -> IO Bool
+sIsConnected (MkSocket _ _ _ _ status) = do
+    value <- readMVar status
+    return (value == Connected)	
+
+-- -----------------------------------------------------------------------------
+-- Socket Predicates
+
+sIsBound :: Socket -> IO Bool
+sIsBound (MkSocket _ _ _ _ status) = do
+    value <- readMVar status
+    return (value == Bound)	
+
+sIsListening :: Socket -> IO Bool
+sIsListening (MkSocket _ _ _  _ status) = do
+    value <- readMVar status
+    return (value == Listening)	
+
+sIsReadable  :: Socket -> IO Bool
+sIsReadable (MkSocket _ _ _ _ status) = do
+    value <- readMVar status
+    return (value == Listening || value == Connected)
+
+sIsWritable  :: Socket -> IO Bool
+sIsWritable = sIsReadable -- sort of.
+
+sIsAcceptable :: Socket -> IO Bool
+#if defined(DOMAIN_SOCKET_SUPPORT)
+sIsAcceptable (MkSocket _ AF_UNIX Stream _ status) = do
+    value <- readMVar status
+    return (value == Connected || value == Bound || value == Listening)
+sIsAcceptable (MkSocket _ AF_UNIX _ _ _) = return False
+#endif
+sIsAcceptable (MkSocket _ _ _ _ status) = do
+    value <- readMVar status
+    return (value == Connected || value == Listening)
+    
+-- -----------------------------------------------------------------------------
+-- Internet address manipulation routines:
+
+inet_addr :: String -> IO HostAddress
+inet_addr ipstr = do
+   withCString ipstr $ \str -> do
+   had <- c_inet_addr str
+   if had == -1
+    then ioError (userError ("inet_addr: Malformed address: " ++ ipstr))
+    else return had  -- network byte order
+
+inet_ntoa :: HostAddress -> IO String
+inet_ntoa haddr = do
+  pstr <- c_inet_ntoa haddr
+  peekCString pstr
+
+-- | turns a Socket into an 'Handle'. By default, the new handle is
+-- unbuffered. Use 'System.IO.hSetBuffering' to change the buffering.
+--
+-- Note that since a 'Handle' is automatically closed by a finalizer
+-- when it is no longer referenced, you should avoid doing any more
+-- operations on the 'Socket' after calling 'socketToHandle'.  To
+-- close the 'Socket' after 'socketToHandle', call 'System.IO.hClose'
+-- on the 'Handle'.
+
+#ifndef __PARALLEL_HASKELL__
+socketToHandle :: Socket -> IOMode -> IO Handle
+socketToHandle s@(MkSocket fd _ _ _ socketStatus) mode = do
+ modifyMVar socketStatus $ \ status ->
+    if status == ConvertedToHandle
+	then ioError (userError ("socketToHandle: already a Handle"))
+	else do
+# ifdef __GLASGOW_HASKELL__
+    h <- openFd (fromIntegral fd) (Just System.Posix.Internals.Stream) True (show s) mode True{-bin-}
+# endif
+# ifdef __HUGS__
+    h <- openFd (fromIntegral fd) True{-is a socket-} mode True{-bin-}
+# endif
+    return (ConvertedToHandle, h)
+#else
+socketToHandle (MkSocket s family stype protocol status) m =
+  error "socketToHandle not implemented in a parallel setup"
+#endif
+
+mkInvalidRecvArgError :: String -> IOError
+mkInvalidRecvArgError loc = IOError Nothing 
+#ifdef __GLASGOW_HASKELL__
+				    InvalidArgument
+#else
+				    IllegalOperation
+#endif
+				    loc "non-positive length" Nothing
+
+mkEOFError :: String -> IOError
+mkEOFError loc = IOError Nothing EOF loc "end of file" Nothing
+
+-- ---------------------------------------------------------------------------
+-- WinSock support
+
+{-| On Windows operating systems, the networking subsystem has to be
+initialised using 'withSocketsDo' before any networking operations can
+be used.  eg.
+
+> main = withSocketsDo $ do {...}
+
+Although this is only strictly necessary on Windows platforms, it is
+harmless on other platforms, so for portability it is good practice to
+use it all the time.
+-}
+withSocketsDo :: IO a -> IO a
+#if !defined(WITH_WINSOCK)
+withSocketsDo x = x
+#else
+withSocketsDo act = do
+   x <- initWinSock
+   if ( x /= 0 ) then
+     ioError (userError "Failed to initialise WinSock")
+    else do
+      act `Control.Exception.finally` shutdownWinSock
+
+foreign import ccall unsafe "initWinSock" initWinSock :: IO Int
+foreign import ccall unsafe "shutdownWinSock" shutdownWinSock :: IO ()
+
+#endif
+
+-- ---------------------------------------------------------------------------
+-- foreign imports from the C library
+
+foreign import ccall unsafe "my_inet_ntoa"
+  c_inet_ntoa :: HostAddress -> IO (Ptr CChar)
+
+foreign import CALLCONV unsafe "inet_addr"
+  c_inet_addr :: Ptr CChar -> IO HostAddress
+
+foreign import CALLCONV unsafe "shutdown"
+  c_shutdown :: CInt -> CInt -> IO CInt 
+
+#if !defined(WITH_WINSOCK)
+foreign import ccall unsafe "close"
+  c_close :: CInt -> IO CInt
+#else
+foreign import stdcall unsafe "closesocket"
+  c_close :: CInt -> IO CInt
+#endif
+
+foreign import CALLCONV unsafe "socket"
+  c_socket :: CInt -> CInt -> CInt -> IO CInt
+foreign import CALLCONV unsafe "bind"
+  c_bind :: CInt -> Ptr SockAddr -> CInt{-CSockLen???-} -> IO CInt
+foreign import CALLCONV unsafe "connect"
+  c_connect :: CInt -> Ptr SockAddr -> CInt{-CSockLen???-} -> IO CInt
+foreign import CALLCONV unsafe "accept"
+  c_accept :: CInt -> Ptr SockAddr -> Ptr CInt{-CSockLen???-} -> IO CInt
+foreign import CALLCONV safe "accept"
+  c_accept_safe :: CInt -> Ptr SockAddr -> Ptr CInt{-CSockLen???-} -> IO CInt
+foreign import CALLCONV unsafe "listen"
+  c_listen :: CInt -> CInt -> IO CInt
+
+#ifdef __GLASGOW_HASKELL__
+foreign import ccall "rtsSupportsBoundThreads" threaded :: Bool
+#endif
+
+foreign import CALLCONV unsafe "send"
+  c_send :: CInt -> Ptr a -> CSize -> CInt -> IO CInt
+foreign import CALLCONV unsafe "sendto"
+  c_sendto :: CInt -> Ptr a -> CSize -> CInt -> Ptr SockAddr -> CInt -> IO CInt
+foreign import CALLCONV unsafe "recv"
+  c_recv :: CInt -> Ptr CChar -> CSize -> CInt -> IO CInt
+foreign import CALLCONV unsafe "recvfrom"
+  c_recvfrom :: CInt -> Ptr a -> CSize -> CInt -> Ptr SockAddr -> Ptr CInt -> IO CInt
+foreign import CALLCONV unsafe "getpeername"
+  c_getpeername :: CInt -> Ptr SockAddr -> Ptr CInt -> IO CInt
+foreign import CALLCONV unsafe "getsockname"
+  c_getsockname :: CInt -> Ptr SockAddr -> Ptr CInt -> IO CInt
+
+foreign import CALLCONV unsafe "getsockopt"
+  c_getsockopt :: CInt -> CInt -> CInt -> Ptr CInt -> Ptr CInt -> IO CInt
+foreign import CALLCONV unsafe "setsockopt"
+  c_setsockopt :: CInt -> CInt -> CInt -> Ptr CInt -> CInt -> IO CInt
+
+-----------------------------------------------------------------------------
+-- Support for thread-safe blocking operations in GHC.
+
+#if defined(__GLASGOW_HASKELL__) && !(defined(HAVE_WINSOCK_H) && !defined(cygwin32_HOST_OS))
+
+
+{-# SPECIALISE 
+    throwErrnoIfMinus1Retry_mayBlock
+	 :: String -> IO CInt -> IO CInt -> IO CInt #-}
+throwErrnoIfMinus1Retry_mayBlock :: Num a => String -> IO a -> IO a -> IO a
+throwErrnoIfMinus1Retry_mayBlock name on_block act = do
+    res <- act
+    if res == -1
+        then do
+            err <- getErrno
+            if err == eINTR
+                then throwErrnoIfMinus1Retry_mayBlock name on_block act
+	        else if err == eWOULDBLOCK || err == eAGAIN
+		        then on_block
+                        else throwErrno name
+        else return res
+
+throwErrnoIfMinus1Retry_repeatOnBlock :: Num a => String -> IO b -> IO a -> IO a
+throwErrnoIfMinus1Retry_repeatOnBlock name on_block act = do
+  throwErrnoIfMinus1Retry_mayBlock name (on_block >> repeat) act
+  where repeat = throwErrnoIfMinus1Retry_repeatOnBlock name on_block act
+
+throwSocketErrorIfMinus1Retry name act = throwErrnoIfMinus1Retry name act
+
+throwSocketErrorIfMinus1_ :: Num a => String -> IO a -> IO ()
+throwSocketErrorIfMinus1_ = throwErrnoIfMinus1_
+#else
+
+throwErrnoIfMinus1Retry_mayBlock name _ act
+  = throwSocketErrorIfMinus1Retry name act
+
+throwErrnoIfMinus1Retry_repeatOnBlock name _ act
+  = throwSocketErrorIfMinus1Retry name act
+
+throwSocketErrorIfMinus1_ :: Num a => String -> IO a -> IO ()
+throwSocketErrorIfMinus1_ name act = do
+  throwSocketErrorIfMinus1Retry name act
+  return ()
+
+# if defined(HAVE_WINSOCK_H) && !defined(cygwin32_HOST_OS)
+throwSocketErrorIfMinus1Retry name act = do
+  r <- act
+  if (r == -1) 
+   then do
+    rc   <- c_getLastError
+    case rc of
+      10093 -> do -- WSANOTINITIALISED
+        withSocketsDo (return ())
+	r <- act
+	if (r == -1)
+	 then (c_getLastError >>= throwSocketError name)
+	 else return r
+      _ -> throwSocketError name rc
+   else return r
+
+throwSocketError name rc = do
+    pstr <- c_getWSError rc
+    str  <- peekCString pstr
+#  if __GLASGOW_HASKELL__
+    ioError (IOError Nothing OtherError name str Nothing)
+#  else    
+    ioError (userError (name ++ ": socket error - " ++ str))
+#  endif
+foreign import CALLCONV unsafe "WSAGetLastError"
+  c_getLastError :: IO CInt
+
+foreign import ccall unsafe "getWSErrorDescr"
+  c_getWSError :: CInt -> IO (Ptr CChar)
+
+
+# else 
+throwSocketErrorIfMinus1Retry name act = throwErrnoIfMinus1Retry name act
+# endif
+#endif /* __GLASGOW_HASKELL */
+
diff --git a/Network/URI.hs b/Network/URI.hs
new file mode 100644
--- /dev/null
+++ b/Network/URI.hs
@@ -0,0 +1,1278 @@
+{-# OPTIONS_GHC -fglasgow-exts -cpp #-}
+--------------------------------------------------------------------------------
+-- |
+--  Module      :  Network.URI
+--  Copyright   :  (c) 2004, Graham Klyne
+--  License     :  BSD-style (see end of this file)
+--
+--  Maintainer  :  Graham Klyne <gk@ninebynine.org>
+--  Stability   :  provisional
+--  Portability :  portable
+--
+--  This module defines functions for handling URIs.  It presents substantially the
+--  same interface as the older GHC Network.URI module, but is implemented using
+--  Parsec rather than a Regex library that is not available with Hugs.  The internal
+--  representation of URI has been changed so that URI strings are more
+--  completely preserved when round-tripping to a URI value and back.
+--
+--  In addition, four methods are provided for parsing different
+--  kinds of URI string (as noted in RFC3986):
+--      'parseURI',
+--      'parseURIReference',
+--      'parseRelativeReference' and
+--      'parseAbsoluteURI'.
+--
+--  Further, four methods are provided for classifying different
+--  kinds of URI string (as noted in RFC3986):
+--      'isURI',
+--      'isURIReference',
+--      'isRelativeReference' and
+--      'isAbsoluteURI'.
+--
+--  The long-standing official reference for URI handling was RFC2396 [1],
+--  as updated by RFC 2732 [2], but this was replaced by a new specification,
+--  RFC3986 [3] in January 2005.  This latter specification has been used
+--  as the primary reference for constructing the URI parser implemented
+--  here, and it is intended that there is a direct relationship between
+--  the syntax definition in that document and this parser implementation.
+--
+--  RFC 1808 [4] contains a number of test cases for relative URI handling.
+--  Dan Connolly's Python module @uripath.py@ [5] also contains useful details
+--  and test cases.
+--
+--  Some of the code has been copied from the previous GHC implementation,
+--  but the parser is replaced with one that performs more complete
+--  syntax checking of the URI itself, according to RFC3986 [3].
+--
+--  References
+--
+--  (1) <http://www.ietf.org/rfc/rfc2396.txt>
+--
+--  (2) <http://www.ietf.org/rfc/rfc2732.txt>
+--
+--  (3) <http://www.ietf.org/rfc/rfc3986.txt>
+--
+--  (4) <http://www.ietf.org/rfc/rfc1808.txt>
+--
+--  (5) <http://www.w3.org/2000/10/swap/uripath.py>
+--
+--------------------------------------------------------------------------------
+
+module Network.URI
+    ( -- * The URI type
+      URI(..)
+    , URIAuth(..)
+    , nullURI
+      -- * Parsing
+    , parseURI                  -- :: String -> Maybe URI
+    , parseURIReference         -- :: String -> Maybe URI
+    , parseRelativeReference    -- :: String -> Maybe URI
+    , parseAbsoluteURI          -- :: String -> Maybe URI
+      -- * Test for strings containing various kinds of URI
+    , isURI
+    , isURIReference
+    , isRelativeReference
+    , isAbsoluteURI
+    , isIPv6address
+    , isIPv4address
+      -- * Relative URIs
+    , relativeTo                -- :: URI -> URI -> Maybe URI
+    , nonStrictRelativeTo       -- :: URI -> URI -> Maybe URI
+    , relativeFrom              -- :: URI -> URI -> URI
+      -- * Operations on URI strings
+      -- | Support for putting strings into URI-friendly
+      --   escaped format and getting them back again.
+      --   This can't be done transparently in all cases, because certain
+      --   characters have different meanings in different kinds of URI.
+      --   The URI spec [3], section 2.4, indicates that all URI components
+      --   should be escaped before they are assembled as a URI:
+      --   \"Once produced, a URI is always in its percent-encoded form\"
+    , uriToString               -- :: URI -> ShowS
+    , isReserved, isUnreserved  -- :: Char -> Bool
+    , isAllowedInURI, isUnescapedInURI  -- :: Char -> Bool
+    , escapeURIChar             -- :: (Char->Bool) -> Char -> String
+    , escapeURIString           -- :: (Char->Bool) -> String -> String
+    , unEscapeString            -- :: String -> String
+    -- * URI Normalization functions
+    , normalizeCase             -- :: String -> String
+    , normalizeEscape           -- :: String -> String
+    , normalizePathSegments     -- :: String -> String
+    -- * Deprecated functions
+    , parseabsoluteURI          -- :: String -> Maybe URI
+    , escapeString              -- :: String -> (Char->Bool) -> String
+    , reserved, unreserved      -- :: Char -> Bool
+    , scheme, authority, path, query, fragment
+    )
+where
+
+import Text.ParserCombinators.Parsec
+    ( GenParser(..), ParseError(..)
+    , parse, (<|>), (<?>), try
+    , option, many, many1, count, notFollowedBy, lookAhead
+    , char, satisfy, oneOf, string, letter, digit, hexDigit, eof
+    , unexpected
+    )
+
+import Data.Char( ord, chr, isHexDigit, isSpace, toLower, toUpper, digitToInt )
+
+import Debug.Trace( trace )
+
+import Numeric( showIntAtBase )
+
+import Data.Maybe( isJust )
+
+import Control.Monad( MonadPlus(..) )
+
+#ifdef __GLASGOW_HASKELL__
+import Data.Typeable  ( Typeable )
+import Data.Generics  ( Data )
+#else
+import Data.Typeable  ( Typeable(..), TyCon, mkTyCon, mkTyConApp )
+#endif
+
+------------------------------------------------------------
+--  The URI datatype
+------------------------------------------------------------
+
+-- |Represents a general universal resource identifier using
+--  its component parts.
+--
+--  For example, for the URI
+--
+--  >   foo://anonymous@www.haskell.org:42/ghc?query#frag
+--
+--  the components are:
+--
+data URI = URI
+    { uriScheme     :: String           -- ^ @foo:@
+    , uriAuthority  :: Maybe URIAuth    -- ^ @\/\/anonymous\@www.haskell.org:42@
+    , uriPath       :: String           -- ^ @\/ghc@
+    , uriQuery      :: String           -- ^ @?query@
+    , uriFragment   :: String           -- ^ @#frag@
+    } deriving (Eq
+#ifdef __GLASGOW_HASKELL__
+    , Typeable, Data
+#endif
+    )
+
+#ifndef __GLASGOW_HASKELL__
+uriTc :: TyCon
+uriTc = mkTyCon "URI"
+
+instance Typeable URI where
+  typeOf _ = mkTyConApp uriTc []
+#endif
+
+-- |Type for authority value within a URI
+data URIAuth = URIAuth
+    { uriUserInfo   :: String           -- ^ @anonymous\@@
+    , uriRegName    :: String           -- ^ @www.haskell.org@
+    , uriPort       :: String           -- ^ @:42@
+    } deriving (Eq
+#ifdef __GLASGOW_HASKELL__
+    , Typeable, Data
+#endif
+    )
+
+#ifndef __GLASGOW_HASKELL__
+uriAuthTc :: TyCon
+uriAuthTc = mkTyCon "URIAuth"
+
+instance Typeable URIAuth where
+  typeOf _ = mkTyConApp uriAuthTc []
+#endif
+
+-- |Blank URI
+nullURI :: URI
+nullURI = URI
+    { uriScheme     = ""
+    , uriAuthority  = Nothing
+    , uriPath       = ""
+    , uriQuery      = ""
+    , uriFragment   = ""
+    }
+
+--  URI as instance of Show.  Note that for security reasons, the default
+--  behaviour is to suppress any userinfo field (see RFC3986, section 7.5).
+--  This can be overridden by using uriToString directly with first
+--  argument @id@ (noting that this returns a ShowS value rather than a string).
+--
+--  [[[Another design would be to embed the userinfo mapping function in
+--  the URIAuth value, with the default value suppressing userinfo formatting,
+--  but providing a function to return a new URI value with userinfo
+--  data exposed by show.]]]
+--
+instance Show URI where
+    showsPrec _ uri = uriToString defaultUserInfoMap uri
+
+defaultUserInfoMap :: String -> String
+defaultUserInfoMap uinf = user++newpass
+    where
+        (user,pass) = break (==':') uinf
+        newpass     = if null pass || (pass == "@")
+                                   || (pass == ":@")
+                        then pass
+                        else ":...@"
+
+testDefaultUserInfoMap =
+     [ defaultUserInfoMap ""                == ""
+     , defaultUserInfoMap "@"               == "@"
+     , defaultUserInfoMap "user@"           == "user@"
+     , defaultUserInfoMap "user:@"          == "user:@"
+     , defaultUserInfoMap "user:anonymous@" == "user:...@"
+     , defaultUserInfoMap "user:pass@"      == "user:...@"
+     , defaultUserInfoMap "user:pass"       == "user:...@"
+     , defaultUserInfoMap "user:anonymous"  == "user:...@"
+     ]
+
+------------------------------------------------------------
+--  Parse a URI
+------------------------------------------------------------
+
+-- |Turn a string containing a URI into a 'URI'.
+--  Returns 'Nothing' if the string is not a valid URI;
+--  (an absolute URI with optional fragment identifier).
+--
+--  NOTE: this is different from the previous network.URI,
+--  whose @parseURI@ function works like 'parseURIReference'
+--  in this module.
+--
+parseURI :: String -> Maybe URI
+parseURI = parseURIAny uri
+
+-- |Parse a URI reference to a 'URI' value.
+--  Returns 'Nothing' if the string is not a valid URI reference.
+--  (an absolute or relative URI with optional fragment identifier).
+--
+parseURIReference :: String -> Maybe URI
+parseURIReference = parseURIAny uriReference
+
+-- |Parse a relative URI to a 'URI' value.
+--  Returns 'Nothing' if the string is not a valid relative URI.
+--  (a relative URI with optional fragment identifier).
+--
+parseRelativeReference :: String -> Maybe URI
+parseRelativeReference = parseURIAny relativeRef
+
+-- |Parse an absolute URI to a 'URI' value.
+--  Returns 'Nothing' if the string is not a valid absolute URI.
+--  (an absolute URI without a fragment identifier).
+--
+parseAbsoluteURI :: String -> Maybe URI
+parseAbsoluteURI = parseURIAny absoluteURI
+
+-- |Test if string contains a valid URI
+--  (an absolute URI with optional fragment identifier).
+--
+isURI :: String -> Bool
+isURI = isValidParse uri
+
+-- |Test if string contains a valid URI reference
+--  (an absolute or relative URI with optional fragment identifier).
+--
+isURIReference :: String -> Bool
+isURIReference = isValidParse uriReference
+
+-- |Test if string contains a valid relative URI
+--  (a relative URI with optional fragment identifier).
+--
+isRelativeReference :: String -> Bool
+isRelativeReference = isValidParse relativeRef
+
+-- |Test if string contains a valid absolute URI
+--  (an absolute URI without a fragment identifier).
+--
+isAbsoluteURI :: String -> Bool
+isAbsoluteURI = isValidParse absoluteURI
+
+-- |Test if string contains a valid IPv6 address
+--
+isIPv6address :: String -> Bool
+isIPv6address = isValidParse ipv6address
+
+-- |Test if string contains a valid IPv4 address
+--
+isIPv4address :: String -> Bool
+isIPv4address = isValidParse ipv4address
+
+-- |Test function: parse and reconstruct a URI reference
+--
+testURIReference :: String -> String
+testURIReference uristr = show (parseAll uriReference "" uristr)
+
+--  Helper function for turning a string into a URI
+--
+parseURIAny :: URIParser URI -> String -> Maybe URI
+parseURIAny parser uristr = case parseAll parser "" uristr of
+        Left  _ -> Nothing
+        Right u -> Just u
+
+--  Helper function to test a string match to a parser
+--
+isValidParse :: URIParser a -> String -> Bool
+isValidParse parser uristr = case parseAll parser "" uristr of
+        -- Left  e -> error (show e)
+        Left  _ -> False
+        Right u -> True
+
+parseAll :: URIParser a -> String -> String -> Either ParseError a
+parseAll parser filename uristr = parse newparser filename uristr
+    where
+        newparser =
+            do  { res <- parser
+                ; eof
+                ; return res
+                }
+
+------------------------------------------------------------
+--  URI parser body based on Parsec elements and combinators
+------------------------------------------------------------
+
+--  Parser parser type.
+--  Currently
+type URIParser a = GenParser Char () a
+
+--  RFC3986, section 2.1
+--
+--  Parse and return a 'pct-encoded' sequence
+--
+escaped :: URIParser String
+escaped =
+    do  { char '%'
+        ; h1 <- hexDigitChar
+        ; h2 <- hexDigitChar
+        ; return $ ['%',h1,h2]
+        }
+
+--  RFC3986, section 2.2
+--
+-- |Returns 'True' if the character is a \"reserved\" character in a
+--  URI.  To include a literal instance of one of these characters in a
+--  component of a URI, it must be escaped.
+--
+isReserved :: Char -> Bool
+isReserved c = isGenDelims c || isSubDelims c
+
+isGenDelims c = c `elem` ":/?#[]@"
+
+isSubDelims c = c `elem` "!$&'()*+,;="
+
+genDelims :: URIParser String
+genDelims = do { c <- satisfy isGenDelims ; return [c] }
+
+subDelims :: URIParser String
+subDelims = do { c <- satisfy isSubDelims ; return [c] }
+
+--  RFC3986, section 2.3
+--
+-- |Returns 'True' if the character is an \"unreserved\" character in
+--  a URI.  These characters do not need to be escaped in a URI.  The
+--  only characters allowed in a URI are either \"reserved\",
+--  \"unreserved\", or an escape sequence (@%@ followed by two hex digits).
+--
+isUnreserved :: Char -> Bool
+isUnreserved c = isAlphaNumChar c || (c `elem` "-_.~")
+
+unreservedChar :: URIParser String
+unreservedChar = do { c <- satisfy isUnreserved ; return [c] }
+
+--  RFC3986, section 3
+--
+--   URI         = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
+--
+--   hier-part   = "//" authority path-abempty
+--               / path-abs
+--               / path-rootless
+--               / path-empty
+
+uri :: URIParser URI
+uri =
+    do  { us <- try uscheme
+        -- ; ua <- option Nothing ( do { try (string "//") ; uauthority } )
+        -- ; up <- upath
+        ; (ua,up) <- hierPart
+        ; uq <- option "" ( do { char '?' ; uquery    } )
+        ; uf <- option "" ( do { char '#' ; ufragment } )
+        ; return $ URI
+            { uriScheme    = us
+            , uriAuthority = ua
+            , uriPath      = up
+            , uriQuery     = uq
+            , uriFragment  = uf
+            }
+        }
+
+hierPart :: URIParser ((Maybe URIAuth),String)
+hierPart =
+        do  { try (string "//")
+            ; ua <- uauthority
+            ; up <- pathAbEmpty
+            ; return (ua,up)
+            }
+    <|> do  { up <- pathAbs
+            ; return (Nothing,up)
+            }
+    <|> do  { up <- pathRootLess
+            ; return (Nothing,up)
+            }
+    <|> do  { return (Nothing,"")
+            }
+
+--  RFC3986, section 3.1
+
+uscheme :: URIParser String
+uscheme =
+    do  { s <- oneThenMany alphaChar (satisfy isSchemeChar)
+        ; char ':'
+        ; return $ s++":"
+        }
+
+--  RFC3986, section 3.2
+
+uauthority :: URIParser (Maybe URIAuth)
+uauthority =
+    do  { uu <- option "" (try userinfo)
+        ; uh <- host
+        ; up <- option "" port
+        ; return $ Just $ URIAuth
+            { uriUserInfo = uu
+            , uriRegName  = uh
+            , uriPort     = up
+            }
+        }
+
+--  RFC3986, section 3.2.1
+
+userinfo :: URIParser String
+userinfo =
+    do  { uu <- many (uchar ";:&=+$,")
+        ; char '@'
+        ; return (concat uu ++"@")
+        }
+
+--  RFC3986, section 3.2.2
+
+host :: URIParser String
+host = ipLiteral <|> try ipv4address <|> regName
+
+ipLiteral :: URIParser String
+ipLiteral =
+    do  { char '['
+        ; ua <- ( ipv6address <|> ipvFuture )
+        ; char ']'
+        ; return $ "[" ++ ua ++ "]"
+        }
+    <?> "IP address literal"
+
+ipvFuture :: URIParser String
+ipvFuture =
+    do  { char 'v'
+        ; h <- hexDigitChar
+        ; char '.'
+        ; a <- many1 (satisfy isIpvFutureChar)
+        ; return $ 'c':h:'.':a
+        }
+
+isIpvFutureChar c = isUnreserved c || isSubDelims c || (c==';')
+
+ipv6address :: URIParser String
+ipv6address =
+        try ( do
+                { a2 <- count 6 h4c
+                ; a3 <- ls32
+                ; return $ concat a2 ++ a3
+                } )
+    <|> try ( do
+                { string "::"
+                ; a2 <- count 5 h4c
+                ; a3 <- ls32
+                ; return $ "::" ++ concat a2 ++ a3
+                } )
+    <|> try ( do
+                { a1 <- opt_n_h4c_h4 0
+                ; string "::"
+                ; a2 <- count 4 h4c
+                ; a3 <- ls32
+                ; return $ a1 ++ "::" ++ concat a2 ++ a3
+                } )
+    <|> try ( do
+                { a1 <- opt_n_h4c_h4 1
+                ; string "::"
+                ; a2 <- count 3 h4c
+                ; a3 <- ls32
+                ; return $ a1 ++ "::" ++ concat a2 ++ a3
+                } )
+    <|> try ( do
+                { a1 <- opt_n_h4c_h4 2
+                ; string "::"
+                ; a2 <- count 2 h4c
+                ; a3 <- ls32
+                ; return $ a1 ++ "::" ++ concat a2 ++ a3
+                } )
+    <|> try ( do
+                { a1 <- opt_n_h4c_h4 3
+                ; string "::"
+                ; a2 <- h4c
+                ; a3 <- ls32
+                ; return $ a1 ++ "::" ++ a2 ++ a3
+                } )
+    <|> try ( do
+                { a1 <- opt_n_h4c_h4 4
+                ; string "::"
+                ; a3 <- ls32
+                ; return $ a1 ++ "::" ++ a3
+                } )
+    <|> try ( do
+                { a1 <- opt_n_h4c_h4 5
+                ; string "::"
+                ; a3 <- h4
+                ; return $ a1 ++ "::" ++ a3
+                } )
+    <|> try ( do
+                { a1 <- opt_n_h4c_h4 6
+                ; string "::"
+                ; return $ a1 ++ "::"
+                } )
+    <?> "IPv6 address"
+
+opt_n_h4c_h4 :: Int -> URIParser String
+opt_n_h4c_h4 n = option "" $
+    do  { a1 <- countMinMax 0 n h4c
+        ; a2 <- h4
+        ; return $ concat a1 ++ a2
+        }
+
+ls32 :: URIParser String
+ls32 =  try ( do
+                { a1 <- h4c
+                ; a2 <- h4
+                ; return (a1++a2)
+                } )
+    <|> ipv4address
+
+h4c :: URIParser String
+h4c = try $
+    do  { a1 <- h4
+        ; char ':'
+        ; notFollowedBy (char ':')
+        ; return $ a1 ++ ":"
+        }
+
+h4 :: URIParser String
+h4 = countMinMax 1 4 hexDigitChar
+
+ipv4address :: URIParser String
+ipv4address =
+    do  { a1 <- decOctet ; char '.'
+        ; a2 <- decOctet ; char '.'
+        ; a3 <- decOctet ; char '.'
+        ; a4 <- decOctet
+        ; return $ a1++"."++a2++"."++a3++"."++a4
+        }
+
+decOctet :: URIParser String
+decOctet =
+    do  { a1 <- countMinMax 1 3 digitChar
+        ; if read a1 > 255 then
+            fail "Decimal octet value too large"
+          else
+            return a1
+        }
+
+regName :: URIParser String
+regName =
+    do  { ss <- countMinMax 0 255 ( unreservedChar <|> escaped <|> subDelims )
+        ; return $ concat ss
+        }
+    <?> "Registered name"
+
+--  RFC3986, section 3.2.3
+
+port :: URIParser String
+port =
+    do  { char ':'
+        ; p <- many digitChar
+        ; return (':':p)
+        }
+
+--
+--  RFC3986, section 3.3
+--
+--   path          = path-abempty    ; begins with "/" or is empty
+--                 / path-abs        ; begins with "/" but not "//"
+--                 / path-noscheme   ; begins with a non-colon segment
+--                 / path-rootless   ; begins with a segment
+--                 / path-empty      ; zero characters
+--
+--   path-abempty  = *( "/" segment )
+--   path-abs      = "/" [ segment-nz *( "/" segment ) ]
+--   path-noscheme = segment-nzc *( "/" segment )
+--   path-rootless = segment-nz *( "/" segment )
+--   path-empty    = 0<pchar>
+--
+--   segment       = *pchar
+--   segment-nz    = 1*pchar
+--   segment-nzc   = 1*( unreserved / pct-encoded / sub-delims / "@" )
+--
+--   pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
+
+{-
+upath :: URIParser String
+upath = pathAbEmpty
+    <|> pathAbs
+    <|> pathNoScheme
+    <|> pathRootLess
+    <|> pathEmpty
+-}
+
+pathAbEmpty :: URIParser String
+pathAbEmpty =
+    do  { ss <- many slashSegment
+        ; return $ concat ss
+        }
+
+pathAbs :: URIParser String
+pathAbs =
+    do  { char '/'
+        ; ss <- option "" pathRootLess
+        ; return $ '/':ss
+        }
+
+pathNoScheme :: URIParser String
+pathNoScheme =
+    do  { s1 <- segmentNzc
+        ; ss <- many slashSegment
+        ; return $ concat (s1:ss)
+        }
+
+pathRootLess :: URIParser String
+pathRootLess =
+    do  { s1 <- segmentNz
+        ; ss <- many slashSegment
+        ; return $ concat (s1:ss)
+        }
+
+slashSegment :: URIParser String
+slashSegment =
+    do  { char '/'
+        ; s <- segment
+        ; return ('/':s)
+        }
+
+segment :: URIParser String
+segment =
+    do  { ps <- many pchar
+        ; return $ concat ps
+        }
+
+segmentNz :: URIParser String
+segmentNz =
+    do  { ps <- many1 pchar
+        ; return $ concat ps
+        }
+
+segmentNzc :: URIParser String
+segmentNzc =
+    do  { ps <- many1 (uchar "@")
+        ; return $ concat ps
+        }
+
+pchar :: URIParser String
+pchar = uchar ":@"
+
+-- helper function for pchar and friends
+uchar :: String -> URIParser String
+uchar extras =
+        unreservedChar
+    <|> escaped
+    <|> subDelims
+    <|> do { c <- oneOf extras ; return [c] }
+
+--  RFC3986, section 3.4
+
+uquery :: URIParser String
+uquery =
+    do  { ss <- many $ uchar (":@"++"/?")
+        ; return $ '?':concat ss
+        }
+
+--  RFC3986, section 3.5
+
+ufragment :: URIParser String
+ufragment =
+    do  { ss <- many $ uchar (":@"++"/?")
+        ; return $ '#':concat ss
+        }
+
+--  Reference, Relative and Absolute URI forms
+--
+--  RFC3986, section 4.1
+
+uriReference :: URIParser URI
+uriReference = uri <|> relativeRef
+
+--  RFC3986, section 4.2
+--
+--   relative-URI  = relative-part [ "?" query ] [ "#" fragment ]
+--
+--   relative-part = "//" authority path-abempty
+--                 / path-abs
+--                 / path-noscheme
+--                 / path-empty
+
+relativeRef :: URIParser URI
+relativeRef =
+    do  { notMatching uscheme
+        -- ; ua <- option Nothing ( do { try (string "//") ; uauthority } )
+        -- ; up <- upath
+        ; (ua,up) <- relativePart
+        ; uq <- option "" ( do { char '?' ; uquery    } )
+        ; uf <- option "" ( do { char '#' ; ufragment } )
+        ; return $ URI
+            { uriScheme    = ""
+            , uriAuthority = ua
+            , uriPath      = up
+            , uriQuery     = uq
+            , uriFragment  = uf
+            }
+        }
+
+relativePart :: URIParser ((Maybe URIAuth),String)
+relativePart =
+        do  { try (string "//")
+            ; ua <- uauthority
+            ; up <- pathAbEmpty
+            ; return (ua,up)
+            }
+    <|> do  { up <- pathAbs
+            ; return (Nothing,up)
+            }
+    <|> do  { up <- pathNoScheme
+            ; return (Nothing,up)
+            }
+    <|> do  { return (Nothing,"")
+            }
+
+--  RFC3986, section 4.3
+
+absoluteURI :: URIParser URI
+absoluteURI =
+    do  { us <- uscheme
+        -- ; ua <- option Nothing ( do { try (string "//") ; uauthority } )
+        -- ; up <- upath
+        ; (ua,up) <- hierPart
+        ; uq <- option "" ( do { char '?' ; uquery    } )
+        ; return $ URI
+            { uriScheme    = us
+            , uriAuthority = ua
+            , uriPath      = up
+            , uriQuery     = uq
+            , uriFragment  = ""
+            }
+        }
+
+--  Imports from RFC 2234
+
+    -- NOTE: can't use isAlphaNum etc. because these deal with ISO 8859
+    -- (and possibly Unicode!) chars.
+    -- [[[Above was a comment originally in GHC Network/URI.hs:
+    --    when IRIs are introduced then most codepoints above 128(?) should
+    --    be treated as unreserved, and higher codepoints for letters should
+    --    certainly be allowed.
+    -- ]]]
+
+isAlphaChar c    = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')
+
+isDigitChar c    = (c >= '0' && c <= '9')
+
+isAlphaNumChar c = isAlphaChar c || isDigitChar c
+
+isHexDigitChar c = isHexDigit c
+
+isSchemeChar c   = (isAlphaNumChar c) || (c `elem` "+-.")
+
+alphaChar :: URIParser Char
+alphaChar = satisfy isAlphaChar         -- or: Parsec.letter ?
+
+digitChar :: URIParser Char
+digitChar = satisfy isDigitChar         -- or: Parsec.digit ?
+
+alphaNumChar :: URIParser Char
+alphaNumChar = satisfy isAlphaNumChar
+
+hexDigitChar :: URIParser Char
+hexDigitChar = satisfy isHexDigitChar   -- or: Parsec.hexDigit ?
+
+--  Additional parser combinators for common patterns
+
+oneThenMany :: GenParser t s a -> GenParser t s a -> GenParser t s [a]
+oneThenMany p1 pr =
+    do  { a1 <- p1
+        ; ar <- many pr
+        ; return (a1:ar)
+        }
+
+countMinMax :: Int -> Int -> GenParser t s a -> GenParser t s [a]
+countMinMax m n p | m > 0 =
+    do  { a1 <- p
+        ; ar <- countMinMax (m-1) (n-1) p
+        ; return (a1:ar)
+        }
+countMinMax _ n _ | n <= 0 = return []
+countMinMax _ n p = option [] $
+    do  { a1 <- p
+        ; ar <- countMinMax 0 (n-1) p
+        ; return (a1:ar)
+        }
+
+notMatching :: Show a => GenParser tok st a -> GenParser tok st ()
+notMatching p = do { a <- try p ; unexpected (show a) } <|> return ()
+
+------------------------------------------------------------
+--  Reconstruct a URI string
+------------------------------------------------------------
+--
+-- |Turn a 'URI' into a string.
+--
+--  Uses a supplied function to map the userinfo part of the URI.
+--
+--  The Show instance for URI uses a mapping that hides any password
+--  that may be present in the URI.  Use this function with argument @id@
+--  to preserve the password in the formatted output.
+--
+uriToString :: (String->String) -> URI -> ShowS
+uriToString userinfomap URI { uriScheme=scheme
+                            , uriAuthority=authority
+                            , uriPath=path
+                            , uriQuery=query
+                            , uriFragment=fragment
+                            } =
+    (scheme++) . (uriAuthToString userinfomap authority)
+               . (path++) . (query++) . (fragment++)
+
+uriAuthToString :: (String->String) -> (Maybe URIAuth) -> ShowS
+uriAuthToString _           Nothing   = id          -- shows ""
+uriAuthToString userinfomap
+        (Just URIAuth { uriUserInfo = uinfo
+                      , uriRegName  = regname
+                      , uriPort     = port
+                      } ) =
+    ("//"++) . (if null uinfo then id else ((userinfomap uinfo)++))
+             . (regname++)
+             . (port++)
+
+------------------------------------------------------------
+--  Character classes
+------------------------------------------------------------
+
+-- | Returns 'True' if the character is allowed in a URI.
+--
+isAllowedInURI :: Char -> Bool
+isAllowedInURI c = isReserved c || isUnreserved c || c == '%' -- escape char
+
+-- | Returns 'True' if the character is allowed unescaped in a URI.
+--
+isUnescapedInURI :: Char -> Bool
+isUnescapedInURI c = isReserved c || isUnreserved c
+
+------------------------------------------------------------
+--  Escape sequence handling
+------------------------------------------------------------
+
+-- |Escape character if supplied predicate is not satisfied,
+--  otherwise return character as singleton string.
+--
+escapeURIChar :: (Char->Bool) -> Char -> String
+escapeURIChar p c
+    | p c       = [c]
+    | otherwise = '%' : myShowHex (ord c) ""
+    where
+        myShowHex :: Int -> ShowS
+        myShowHex n r =  case showIntAtBase 16 (toChrHex) n r of
+            []  -> "00"
+            [c] -> ['0',c]
+            cs  -> cs
+        toChrHex d
+            | d < 10    = chr (ord '0' + fromIntegral d)
+            | otherwise = chr (ord 'A' + fromIntegral (d - 10))
+
+-- |Can be used to make a string valid for use in a URI.
+--
+escapeURIString
+    :: (Char->Bool)     -- ^ a predicate which returns 'False'
+                        --   if the character should be escaped
+    -> String           -- ^ the string to process
+    -> String           -- ^ the resulting URI string
+escapeURIString p s = concatMap (escapeURIChar p) s
+
+-- |Turns all instances of escaped characters in the string back
+--  into literal characters.
+--
+unEscapeString :: String -> String
+unEscapeString [] = ""
+unEscapeString ('%':x1:x2:s) | isHexDigit x1 && isHexDigit x2 =
+    chr (digitToInt x1 * 16 + digitToInt x2) : unEscapeString s
+unEscapeString (c:s) = c : unEscapeString s
+
+------------------------------------------------------------
+-- Resolving a relative URI relative to a base URI
+------------------------------------------------------------
+
+-- |Returns a new 'URI' which represents the value of the
+--  first 'URI' interpreted as relative to the second 'URI'.
+--  For example:
+--
+--  > "foo" `relativeTo` "http://bar.org/" = "http://bar.org/foo"
+--  > "http:foo" `nonStrictRelativeTo` "http://bar.org/" = "http://bar.org/foo"
+--
+--  Algorithm from RFC3986 [3], section 5.2.2
+--
+
+nonStrictRelativeTo :: URI -> URI -> Maybe URI
+nonStrictRelativeTo ref base = relativeTo ref' base
+    where
+        ref' = if uriScheme ref == uriScheme base
+               then ref { uriScheme="" }
+               else ref
+
+isDefined :: ( MonadPlus m, Eq (m a) ) => m a -> Bool
+isDefined a = a /= mzero
+
+-- |Compute an absolute 'URI' for a supplied URI
+--  relative to a given base.
+relativeTo :: URI -> URI -> Maybe URI
+relativeTo ref base
+    | isDefined ( uriScheme ref ) =
+        just_segments ref
+    | isDefined ( uriAuthority ref ) =
+        just_segments ref { uriScheme = uriScheme base }
+    | isDefined ( uriPath ref ) =
+        if (head (uriPath ref) == '/') then
+            just_segments ref
+                { uriScheme    = uriScheme base
+                , uriAuthority = uriAuthority base
+                }
+        else
+            just_segments ref
+                { uriScheme    = uriScheme base
+                , uriAuthority = uriAuthority base
+                , uriPath      = mergePaths base ref
+                }
+    | isDefined ( uriQuery ref ) =
+        just_segments ref
+            { uriScheme    = uriScheme base
+            , uriAuthority = uriAuthority base
+            , uriPath      = uriPath base
+            }
+    | otherwise =
+        just_segments ref
+            { uriScheme    = uriScheme base
+            , uriAuthority = uriAuthority base
+            , uriPath      = uriPath base
+            , uriQuery     = uriQuery base
+            }
+    where
+        just_segments u =
+            Just $ u { uriPath = removeDotSegments (uriPath u) }
+        mergePaths b r
+            | isDefined (uriAuthority b) && null pb = '/':pr
+            | otherwise                             = dropLast pb ++ pr
+            where
+                pb = uriPath b
+                pr = uriPath r
+        dropLast = fst . splitLast -- reverse . dropWhile (/='/') . reverse
+
+--  Remove dot segments, but protect leading '/' character
+removeDotSegments :: String -> String
+removeDotSegments ('/':ps) = '/':elimDots ps []
+removeDotSegments ps       = elimDots ps []
+
+--  Second arg accumulates segments processed so far in reverse order
+elimDots :: String -> [String] -> String
+-- elimDots ps rs | traceVal "\nps " ps $ traceVal "rs " rs $ False = error ""
+elimDots [] [] = ""
+elimDots [] rs = concat (reverse rs)
+elimDots (    '.':'/':ps)     rs = elimDots ps rs
+elimDots (    '.':[]    )     rs = elimDots [] rs
+elimDots (    '.':'.':'/':ps) rs = elimDots ps (dropHead rs)
+elimDots (    '.':'.':[]    ) rs = elimDots [] (dropHead rs)
+elimDots ps rs = elimDots ps1 (r:rs)
+    where
+        (r,ps1) = nextSegment ps
+
+--  Return tail of non-null list, otherwise return null list
+dropHead :: [a] -> [a]
+dropHead []     = []
+dropHead (r:rs) = rs
+
+--  Returns the next segment and the rest of the path from a path string.
+--  Each segment ends with the next '/' or the end of string.
+--
+nextSegment :: String -> (String,String)
+nextSegment ps =
+    case break (=='/') ps of
+        (r,'/':ps1) -> (r++"/",ps1)
+        (r,_)       -> (r,[])
+
+--  Split last (name) segment from path, returning (path,name)
+splitLast :: String -> (String,String)
+splitLast path = (reverse revpath,reverse revname)
+    where
+        (revname,revpath) = break (=='/') $ reverse path
+
+------------------------------------------------------------
+-- Finding a URI relative to a base URI
+------------------------------------------------------------
+
+-- |Returns a new 'URI' which represents the relative location of
+--  the first 'URI' with respect to the second 'URI'.  Thus, the
+--  values supplied are expected to be absolute URIs, and the result
+--  returned may be a relative URI.
+--
+--  Example:
+--
+--  > "http://example.com/Root/sub1/name2#frag"
+--  >   `relativeFrom` "http://example.com/Root/sub2/name2#frag"
+--  >   == "../sub2/name2#frag"
+--
+--  There is no single correct implementation of this function,
+--  but any acceptable implementation must satisfy the following:
+--
+--  > (uabs `relativeFrom` ubase) `relativeTo` ubase == uabs
+--
+--  For any valid absolute URI.
+--  (cf. <http://lists.w3.org/Archives/Public/uri/2003Jan/0008.html>
+--       <http://lists.w3.org/Archives/Public/uri/2003Jan/0005.html>)
+--
+relativeFrom :: URI -> URI -> URI
+relativeFrom uabs base
+    | diff uriScheme    uabs base = uabs
+    | diff uriAuthority uabs base = uabs { uriScheme = "" }
+    | diff uriPath      uabs base = uabs
+        { uriScheme    = ""
+        , uriAuthority = Nothing
+        , uriPath      = relPathFrom (removeBodyDotSegments $ uriPath uabs)
+                                     (removeBodyDotSegments $ uriPath base)
+        }
+    | diff uriQuery     uabs base = uabs
+        { uriScheme    = ""
+        , uriAuthority = Nothing
+        , uriPath      = ""
+        }
+    | otherwise = uabs          -- Always carry fragment from uabs
+        { uriScheme    = ""
+        , uriAuthority = Nothing
+        , uriPath      = ""
+        , uriQuery     = ""
+        }
+    where
+        diff sel u1 u2 = sel u1 /= sel u2
+        -- Remove dot segments except the final segment
+        removeBodyDotSegments p = removeDotSegments p1 ++ p2
+            where
+                (p1,p2) = splitLast p
+
+relPathFrom :: String -> String -> String
+relPathFrom []   base = "/"
+relPathFrom pabs []   = pabs
+relPathFrom pabs base =                 -- Construct a relative path segments
+    if sa1 == sb1                       -- if the paths share a leading segment
+        then if (sa1 == "/")            -- other than a leading '/'
+            then if (sa2 == sb2)
+                then relPathFrom1 ra2 rb2
+                else pabs
+            else relPathFrom1 ra1 rb1
+        else pabs
+    where
+        (sa1,ra1) = nextSegment pabs
+        (sb1,rb1) = nextSegment base
+        (sa2,ra2) = nextSegment ra1
+        (sb2,rb2) = nextSegment rb1
+
+--  relPathFrom1 strips off trailing names from the supplied paths,
+--  and calls difPathFrom to find the relative path from base to
+--  target
+relPathFrom1 :: String -> String -> String
+relPathFrom1 pabs base = relName
+    where
+        (sa,na) = splitLast pabs
+        (sb,nb) = splitLast base
+        rp      = relSegsFrom sa sb
+        relName = if null rp then
+                      if (na == nb) then ""
+                      else if protect na then "./"++na
+                      else na
+                  else
+                      rp++na
+        -- Precede name with some path if it is null or contains a ':'
+        protect na = null na || ':' `elem` na
+
+--  relSegsFrom discards any common leading segments from both paths,
+--  then invokes difSegsFrom to calculate a relative path from the end
+--  of the base path to the end of the target path.
+--  The final name is handled separately, so this deals only with
+--  "directory" segtments.
+--
+relSegsFrom :: String -> String -> String
+{-
+relSegsFrom sabs base
+    | traceVal "\nrelSegsFrom\nsabs " sabs $ traceVal "base " base $
+      False = error ""
+-}
+relSegsFrom []   []   = ""      -- paths are identical
+relSegsFrom sabs base =
+    if sa1 == sb1
+        then relSegsFrom ra1 rb1
+        else difSegsFrom sabs base
+    where
+        (sa1,ra1) = nextSegment sabs
+        (sb1,rb1) = nextSegment base
+
+--  difSegsFrom calculates a path difference from base to target,
+--  not including the final name at the end of the path
+--  (i.e. results always ends with '/')
+--
+--  This function operates under the invariant that the supplied
+--  value of sabs is the desired path relative to the beginning of
+--  base.  Thus, when base is empty, the desired path has been found.
+--
+difSegsFrom :: String -> String -> String
+{-
+difSegsFrom sabs base
+    | traceVal "\ndifSegsFrom\nsabs " sabs $ traceVal "base " base $
+      False = error ""
+-}
+difSegsFrom sabs ""   = sabs
+difSegsFrom sabs base = difSegsFrom ("../"++sabs) (snd $ nextSegment base)
+
+------------------------------------------------------------
+--  Other normalization functions
+------------------------------------------------------------
+
+-- |Case normalization; cf. RFC3986 section 6.2.2.1
+--  NOTE:  authority case normalization is not performed
+--
+normalizeCase :: String -> String
+normalizeCase uristr = ncScheme uristr
+    where
+        ncScheme (':':cs)                = ':':ncEscape cs
+        ncScheme (c:cs) | isSchemeChar c = toLower c:ncScheme cs
+        ncScheme _                       = ncEscape uristr -- no scheme present
+        ncEscape ('%':h1:h2:cs) = '%':toUpper h1:toUpper h2:ncEscape cs
+        ncEscape (c:cs)         = c:ncEscape cs
+        ncEscape []             = []
+
+-- |Encoding normalization; cf. RFC3986 section 6.2.2.2
+--
+normalizeEscape :: String -> String
+normalizeEscape ('%':h1:h2:cs)
+    | isHexDigit h1 && isHexDigit h2 && isUnreserved escval =
+        escval:normalizeEscape cs
+    where
+        escval = chr (digitToInt h1*16+digitToInt h2)
+normalizeEscape (c:cs)         = c:normalizeEscape cs
+normalizeEscape []             = []
+
+-- |Path segment normalization; cf. RFC3986 section 6.2.2.4
+--
+normalizePathSegments :: String -> String
+normalizePathSegments uristr = normstr juri
+    where
+        juri = parseURI uristr
+        normstr Nothing  = uristr
+        normstr (Just u) = show (normuri u)
+        normuri u = u { uriPath = removeDotSegments (uriPath u) }
+
+------------------------------------------------------------
+--  Local trace helper functions
+------------------------------------------------------------
+
+traceShow :: Show a => String -> a -> a
+traceShow msg x = trace (msg ++ show x) x
+
+traceVal :: Show a => String -> a -> b -> b
+traceVal msg x y = trace (msg ++ show x) y
+
+------------------------------------------------------------
+--  Deprecated functions
+------------------------------------------------------------
+
+{-# DEPRECATED parseabsoluteURI "use parseAbsoluteURI" #-}
+parseabsoluteURI :: String -> Maybe URI
+parseabsoluteURI = parseAbsoluteURI
+
+{-# DEPRECATED escapeString "use escapeURIString, and note the flipped arguments" #-}
+escapeString :: String -> (Char->Bool) -> String
+escapeString = flip escapeURIString
+
+{-# DEPRECATED reserved "use isReserved" #-}
+reserved :: Char -> Bool
+reserved = isReserved
+
+{-# DEPRECATED unreserved "use isUnreserved" #-}
+unreserved :: Char -> Bool
+unreserved = isUnreserved
+
+--  Additional component access functions for backward compatibility
+
+{-# DEPRECATED scheme "use uriScheme" #-}
+scheme :: URI -> String
+scheme = orNull init . uriScheme
+
+{-# DEPRECATED authority "use uriAuthority, and note changed functionality" #-}
+authority :: URI -> String
+authority = dropss . ($"") . uriAuthToString id . uriAuthority
+    where
+        -- Old-style authority component does not include leading '//'
+        dropss ('/':'/':s) = s
+        dropss s           = s
+
+{-# DEPRECATED path "use uriPath" #-}
+path :: URI -> String
+path = uriPath
+
+{-# DEPRECATED query "use uriQuery, and note changed functionality" #-}
+query :: URI -> String
+query = orNull tail . uriQuery
+
+{-# DEPRECATED fragment "use uriFragment, and note changed functionality" #-}
+fragment :: URI -> String
+fragment = orNull tail . uriFragment
+
+orNull :: ([a]->[a]) -> [a] -> [a]
+orNull _ [] = []
+orNull f as = f as
+
+--------------------------------------------------------------------------------
+--
+--  Copyright (c) 2004, G. KLYNE.  All rights reserved.
+--  Distributed as free software under the following license.
+--
+--  Redistribution and use in source and binary forms, with or without
+--  modification, are permitted provided that the following conditions
+--  are met:
+--
+--  - Redistributions of source code must retain the above copyright notice,
+--  this list of conditions and the following disclaimer.
+--
+--  - 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.
+--
+--  - Neither name of the copyright holders 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 THE 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
+--  HOLDERS OR THE 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/HsNet.c b/cbits/HsNet.c
new file mode 100644
--- /dev/null
+++ b/cbits/HsNet.c
@@ -0,0 +1,8 @@
+/* -----------------------------------------------------------------------------
+ * (c) The University of Glasgow 2002
+ *
+ * static versions of the inline functions from HsNet.h
+ * -------------------------------------------------------------------------- */
+
+#define INLINE
+#include "HsNet.h"
diff --git a/cbits/ancilData.c b/cbits/ancilData.c
new file mode 100644
--- /dev/null
+++ b/cbits/ancilData.c
@@ -0,0 +1,236 @@
+/*
+ *  Copyright(c), 2002 The GHC Team.
+ */
+
+#ifdef aix_HOST_OS
+#define _LINUX_SOURCE_COMPAT 
+// Required to get CMSG_SPACE/CMSG_LEN macros.  See #265.
+// Alternative is to #define COMPAT_43 and use the 
+// HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS code instead, but that means
+// fiddling with the configure script too.
+#endif
+
+#include "HsNet.h"
+
+#if HAVE_STRUCT_MSGHDR_MSG_CONTROL || HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS /* until end */
+
+/* 
+ *  Support for transmitting file descriptors.
+ *
+ *  
+ */
+ 
+
+/*
+ * sendmsg() and recvmsg() wrappers for transmitting
+ * ancillary socket data.
+ *
+ * Doesn't provide the full generality of either, specifically:
+ *
+ *  - no support for scattered read/writes.
+ *  - only possible to send one ancillary chunk of data at a time.
+ *
+ *
+ * NOTE: recv/sendAncillary() is being phased out in preference
+ *       of the more specific send/recvFd(), as the latter is
+ *       really the only application of recv/sendAncillary() and
+ *       stand the chance of being supported on platforms that
+ *       don't have send/recvmsg() (but do have ioctl() support
+ *       for this kind of thing, for instance.)
+ *
+ */
+
+int
+sendFd(int sock,
+       int outfd)
+{
+  struct msghdr msg = {0};
+  struct iovec iov[1];
+  char  buf[2];
+#if HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
+  msg.msg_accrights = (void*)&outfd;
+  msg.msg_accrightslen = sizeof(int);
+#else
+  struct cmsghdr *cmsg;
+  char ancBuffer[CMSG_SPACE(sizeof(int))];
+  char* dPtr;
+  
+  msg.msg_control = ancBuffer;
+  msg.msg_controllen = sizeof(ancBuffer);
+
+  cmsg = CMSG_FIRSTHDR(&msg);
+  cmsg->cmsg_level = SOL_SOCKET;
+  cmsg->cmsg_type = SCM_RIGHTS;
+  cmsg->cmsg_len = CMSG_LEN(sizeof(int));
+  dPtr = (char*)CMSG_DATA(cmsg);
+  
+  *(int*)dPtr = outfd;
+  msg.msg_controllen = cmsg->cmsg_len;
+#endif
+
+  buf[0] = 0; buf[1] = '\0';
+  iov[0].iov_base = buf;
+  iov[0].iov_len  = 2;
+
+  msg.msg_iov = iov;
+  msg.msg_iovlen = 1;
+  
+  return sendmsg(sock,&msg,0);
+}
+
+int
+sendAncillary(int sock,
+	      int level,
+	      int type,
+	      int flags,
+	      void* data,
+	      int len)
+{
+  struct msghdr msg = {0};
+  struct iovec iov[1];
+  char  buf[2];
+#if HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
+  /* Contains the older BSD msghdr fields only, so no room
+     for 'type' or 'level' data.
+  */
+  msg.msg_accrights = data;
+  msg.msg_accrightslen=len;
+#else
+  struct cmsghdr *cmsg;
+  char ancBuffer[CMSG_SPACE(len)];
+  char* dPtr;
+  
+  msg.msg_control = ancBuffer;
+  msg.msg_controllen = sizeof(ancBuffer);
+
+  cmsg = CMSG_FIRSTHDR(&msg);
+  cmsg->cmsg_level = level;
+  cmsg->cmsg_type = type;
+  cmsg->cmsg_len = CMSG_LEN(len);
+  dPtr = (char*)CMSG_DATA(cmsg);
+  
+  memcpy(dPtr, data, len);
+  msg.msg_controllen = cmsg->cmsg_len;
+#endif
+  buf[0] = 0; buf[1] = '\0';
+  iov[0].iov_base = buf;
+  iov[0].iov_len  = 2;
+
+  msg.msg_iov = iov;
+  msg.msg_iovlen = 1;
+  
+  return sendmsg(sock,&msg,flags);
+}
+
+int
+recvFd(int sock)
+{
+  struct msghdr msg = {0};
+  char  duffBuf[10];
+  int rc;
+  int len = sizeof(int);
+  struct iovec iov[1];
+#if HAVE_STRUCT_MSGHDR_MSG_CONTROL
+  struct cmsghdr *cmsg = NULL;
+  struct cmsghdr *cptr;
+#else
+  int* fdBuffer;
+#endif
+
+  iov[0].iov_base = duffBuf;
+  iov[0].iov_len  = sizeof(duffBuf);
+  msg.msg_iov = iov;
+  msg.msg_iovlen = 1;
+
+#if HAVE_STRUCT_MSGHDR_MSG_CONTROL
+  cmsg = (struct cmsghdr*)malloc(CMSG_SPACE(len));
+  if (cmsg==NULL) {
+    return -1;
+  }
+  
+  msg.msg_control = (void *)cmsg;
+  msg.msg_controllen = CMSG_LEN(len);
+#else
+  fdBuffer = (int*)malloc(len);
+  if (fdBuffer) {
+    msg.msg_accrights    = (void *)fdBuffer;
+  } else {
+    return -1;
+  }
+  msg.msg_accrightslen = len;
+#endif
+
+  if ((rc = recvmsg(sock,&msg,0)) < 0) {
+    return rc;
+  }
+  
+#if HAVE_STRUCT_MSGHDR_MSG_CONTROL
+  cptr = (struct cmsghdr*)CMSG_FIRSTHDR(&msg);
+  return *(int*)CMSG_DATA(cptr);
+#else
+  return *(int*)fdBuffer;
+#endif
+}
+
+
+int
+recvAncillary(int  sock,
+	      int* pLevel,
+	      int* pType,
+	      int  flags,
+	      void** pData,
+	      int* pLen)
+{
+  struct msghdr msg = {0};
+  char  duffBuf[10];
+  int rc;
+  struct iovec iov[1];
+#if HAVE_STRUCT_MSGHDR_MSG_CONTROL
+  struct cmsghdr *cmsg = NULL;
+  struct cmsghdr *cptr;
+#endif
+  
+  iov[0].iov_base = duffBuf;
+  iov[0].iov_len  = sizeof(duffBuf);
+  msg.msg_iov = iov;
+  msg.msg_iovlen = 1;
+
+#if HAVE_STRUCT_MSGHDR_MSG_CONTROL
+  cmsg = (struct cmsghdr*)malloc(CMSG_SPACE(*pLen));
+  if (cmsg==NULL) {
+    return -1;
+  }
+  
+  msg.msg_control = (void *)cmsg;
+  msg.msg_controllen = CMSG_LEN(*pLen);
+#else
+  *pData = (void*)malloc(*pLen);
+  if (*pData) {
+      msg.msg_accrights    = *pData;
+  } else {
+      return -1;
+  }
+  msg.msg_accrightslen = *pLen;
+#endif
+
+  if ((rc = recvmsg(sock,&msg,flags)) < 0) {
+    return rc;
+  }
+  
+#if HAVE_STRUCT_MSGHDR_MSG_CONTROL
+  cptr = (struct cmsghdr*)CMSG_FIRSTHDR(&msg);
+
+  *pLevel = cptr->cmsg_level;
+  *pType  = cptr->cmsg_type;
+  /* The length of the data portion only */
+  *pLen   = cptr->cmsg_len - sizeof(struct cmsghdr);
+  *pData  = CMSG_DATA(cptr);
+#else
+  /* Sensible defaults, I hope.. */
+  *pLevel = 0;
+  *pType  = 0;
+#endif
+
+  return rc;
+}
+#endif
diff --git a/cbits/asyncAccept.c b/cbits/asyncAccept.c
new file mode 100644
--- /dev/null
+++ b/cbits/asyncAccept.c
@@ -0,0 +1,71 @@
+/*
+ * (c) sof, 2003.
+ */
+
+#include "HsNet.h"
+#include "HsFFI.h"
+
+#if defined(HAVE_WINSOCK_H) && !defined(__CYGWIN__) && !defined(__HUGS__)
+/* all the way to the end */
+
+/*
+ * To support non-blocking accept()s with WinSock, we use the asyncDoProc#
+ * primop, which lets a Haskell thread call an external routine without
+ * blocking the progress of other threads. 
+ *
+ * As can readily be seen, this is a low-level mechanism.
+ *
+ */
+
+typedef struct AcceptData {
+    int   fdSock;
+    int   newSock;
+    void* sockAddr;
+    int   size;
+} AcceptData;
+
+/*
+ * Fill in parameter block that's passed along when the RTS invokes the 
+ * accept()-calling proc below (acceptDoProc())
+ */
+void*
+newAcceptParams(int sock,
+		int sz,
+		void* sockaddr)
+{
+    AcceptData* data = (AcceptData*)malloc(sizeof(AcceptData));
+    if (!data) return NULL;
+    data->fdSock   = sock;
+    data->newSock  = 0;
+    data->sockAddr = sockaddr;
+    data->size     = sz;
+    
+    return data;
+}
+
+/* Accessors for return code and accept()'s socket result. */
+
+int
+acceptNewSock(void* d)
+{
+    return (((AcceptData*)d)->newSock);
+}
+
+/* Routine invoked by an RTS worker thread */
+int
+acceptDoProc(void* param)
+{
+    SOCKET s;
+
+    AcceptData* data = (AcceptData*)param;
+    s = accept( data->fdSock,
+		data->sockAddr,
+		&data->size);
+    data->newSock = s;
+    if ( s == INVALID_SOCKET ) {
+	return GetLastError();
+    } else {
+	return 0;
+    }
+}
+#endif
diff --git a/cbits/initWinSock.c b/cbits/initWinSock.c
new file mode 100644
--- /dev/null
+++ b/cbits/initWinSock.c
@@ -0,0 +1,63 @@
+#include "HsNet.h"
+#include "HsFFI.h"
+
+#if defined(HAVE_WINSOCK_H) && !defined(__CYGWIN__)
+
+static int winsock_inited = 0;
+static int winsock_uninited = 0;
+
+/* Initialising WinSock... */
+int
+initWinSock ()
+{
+  WORD wVersionRequested;
+  WSADATA wsaData;  
+  int err;
+#ifdef __HUGS__
+  int optval = SO_SYNCHRONOUS_NONALERT;
+#endif
+
+  if (!winsock_inited) {
+    wVersionRequested = MAKEWORD( 1, 1 );
+
+    err = WSAStartup ( wVersionRequested, &wsaData );
+    
+    if ( err != 0 ) {
+       return err;
+    }
+
+    if ( LOBYTE( wsaData.wVersion ) != 1 ||
+       HIBYTE( wsaData.wVersion ) != 1 ) {
+      WSACleanup();
+      return (-1);
+    }
+#ifdef __HUGS__
+    /* By default, socket() creates sockets in overlapped mode
+     * (so that async I/O is possible). The CRT can only handle
+     * non-overlapped sockets, so turn off overlap mode here.
+     */
+    setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
+	       &optval, sizeof(optval));
+#endif
+
+    winsock_inited = 1;
+  }
+  return 0;
+}
+
+static void
+shutdownHandler(void)
+{
+  WSACleanup();
+}
+
+void
+shutdownWinSock()
+{
+    if (!winsock_uninited) {
+	atexit(shutdownHandler);
+	winsock_uninited = 1;
+    }
+}
+
+#endif
diff --git a/cbits/winSockErr.c b/cbits/winSockErr.c
new file mode 100644
--- /dev/null
+++ b/cbits/winSockErr.c
@@ -0,0 +1,76 @@
+#include "HsNet.h"
+#include "HsFFI.h"
+
+#if defined(HAVE_WINSOCK_H) && !defined(__CYGWIN__)
+#include <stdio.h>
+
+/* to the end */
+
+const char*
+getWSErrorDescr(int err)
+{
+  static char  otherErrMsg[256];
+
+  switch (err) {
+  case WSAEINTR:  return "Interrupted function call (WSAEINTR)";
+  case WSAEBADF:  return "bad socket descriptor (WSAEBADF)";
+  case WSAEACCES: return "Permission denied (WSAEACCESS)";
+  case WSAEFAULT: return "Bad address (WSAEFAULT)";
+  case WSAEINVAL: return "Invalid argument (WSAEINVAL)";
+  case WSAEMFILE: return "Too many open files (WSAEMFILE)";
+  case WSAEWOULDBLOCK:  return "Resource temporarily unavailable (WSAEWOULDBLOCK)";
+  case WSAEINPROGRESS:  return "Operation now in progress (WSAEINPROGRESS)";
+  case WSAEALREADY:     return "Operation already in progress (WSAEALREADY)";
+  case WSAENOTSOCK:     return "Socket operation on non-socket (WSAENOTSOCK)";
+  case WSAEDESTADDRREQ: return "Destination address required (WSAEDESTADDRREQ)";
+  case WSAEMSGSIZE:    	return "Message too long (WSAEMSGSIZE)";
+  case WSAEPROTOTYPE:   return "Protocol wrong type for socket (WSAEPROTOTYPE)";
+  case WSAENOPROTOOPT:  return "Bad protocol option (WSAENOPROTOOPT)";
+  case WSAEPROTONOSUPPORT: return "Protocol not supported (WSAEPROTONOSUPPORT)";
+  case WSAESOCKTNOSUPPORT: return "Socket type not supported (WSAESOCKTNOSUPPORT)";
+  case WSAEOPNOTSUPP:      return "Operation not supported (WSAEOPNOTSUPP)";
+  case WSAEPFNOSUPPORT:    return "Protocol family not supported (WSAEPFNOSUPPORT)";
+  case WSAEAFNOSUPPORT:    return "Address family not supported by protocol family (WSAEAFNOSUPPORT)";
+  case WSAEADDRINUSE:      return "Address already in use (WSAEADDRINUSE)";
+  case WSAEADDRNOTAVAIL:   return "Cannot assign requested address (WSAEADDRNOTAVAIL)";
+  case WSAENETDOWN:        return "Network is down (WSAENETDOWN)";
+  case WSAENETUNREACH:     return "Network is unreachable (WSAENETUNREACH)";
+  case WSAENETRESET:       return "Network dropped connection on reset (WSAENETRESET)";
+  case WSAECONNABORTED:    return "Software caused connection abort (WSAECONNABORTED)";
+  case WSAECONNRESET:      return "Connection reset by peer (WSAECONNRESET)";
+  case WSAENOBUFS:         return "No buffer space available (WSAENOBUFS)";
+  case WSAEISCONN:         return "Socket is already connected (WSAEISCONN)";
+  case WSAENOTCONN:        return "Socket is not connected (WSAENOTCONN)";
+  case WSAESHUTDOWN:       return "Cannot send after socket shutdown (WSAESHUTDOWN)";
+  case WSAETOOMANYREFS:    return "Too many references (WSAETOOMANYREFS)";
+  case WSAETIMEDOUT:       return "Connection timed out (WSAETIMEDOUT)";
+  case WSAECONNREFUSED:    return "Connection refused (WSAECONNREFUSED)";
+  case WSAELOOP:           return "Too many levels of symbolic links (WSAELOOP)";
+  case WSAENAMETOOLONG:    return "Filename too long (WSAENAMETOOLONG)";
+  case WSAEHOSTDOWN:       return "Host is down (WSAEHOSTDOWN)";
+  case WSAEHOSTUNREACH:    return "Host is unreachable (WSAEHOSTUNREACH)";
+  case WSAENOTEMPTY:       return "Resource not empty (WSAENOTEMPTY)";
+  case WSAEPROCLIM:        return "Too many processes (WSAEPROCLIM)";
+  case WSAEUSERS:          return "Too many users (WSAEUSERS)";
+  case WSAEDQUOT:          return "Disk quota exceeded (WSAEDQUOT)";
+  case WSAESTALE:          return "Stale NFS file handle (WSAESTALE)";
+  case WSAEREMOTE:         return "Too many levels of remote in path (WSAEREMOTE)";
+  case WSAEDISCON:         return "Graceful shutdown in progress (WSAEDISCON)";
+  case WSASYSNOTREADY:     return "Network subsystem is unavailable (WSASYSNOTREADY)";
+  case WSAVERNOTSUPPORTED: return "Winsock.dll version out of range (WSAVERNOTSUPPORTED)";
+  case WSANOTINITIALISED:  return "Successful WSAStartup not yet performed (WSANOTINITIALISED)";
+#ifdef WSATYPE_NOT_FOUND
+  case WSATYPE_NOT_FOUND:  return "Class type not found (WSATYPE_NOT_FOUND)";
+#endif
+  case WSAHOST_NOT_FOUND:  return "Host not found (WSAHOST_NOT_FOUND)";
+  case WSATRY_AGAIN:       return "Nonauthoritative host not found (WSATRY_AGAIN)";
+  case WSANO_RECOVERY:     return "This is a nonrecoverable error (WSANO_RECOVERY)";
+  case WSANO_DATA:         return "Valid name, no data record of requested type (WSANO_DATA)";
+  default:
+    sprintf(otherErrMsg, "Unknown WinSock error: %u", err);
+    return otherErrMsg;
+  }
+}
+
+#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.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,4672 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.57 for Haskell network package 1.0.
+#
+# Report bugs to <libraries@haskell.org>.
+#
+# 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 network package'
+PACKAGE_TARNAME='network'
+PACKAGE_VERSION='1.0'
+PACKAGE_STRING='Haskell network package 1.0'
+PACKAGE_BUGREPORT='libraries@haskell.org'
+
+ac_unique_file="include/HsNet.h"
+# 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 build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP CALLCONV EXTRA_LIBS EXTRA_SRCS 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 network package 1.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
+
+System types:
+  --build=BUILD     configure for building on BUILD [guessed]
+  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of Haskell network package 1.0:";;
+   esac
+  cat <<\_ACEOF
+
+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 <libraries@haskell.org>.
+_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 network package configure 1.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 network package $as_me 1.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.
+
+
+          ac_config_headers="$ac_config_headers include/HsNetworkConfig.h"
+
+
+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/'`
+
+
+
+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 an ANSI C-conforming const" >&5
+echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
+if test "${ac_cv_c_const+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 ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+  /* Ultrix mips cc rejects this.  */
+  typedef int charset[2];
+  const charset x;
+  /* SunOS 4.1.1 cc rejects this.  */
+  char const *const *ccp;
+  char **p;
+  /* NEC SVR4.0.2 mips cc rejects this.  */
+  struct point {int x, y;};
+  static struct point const zero = {0,0};
+  /* AIX XL C 1.02.0.0 rejects this.
+     It does not let you subtract one const X* pointer from another in
+     an arm of an if-expression whose if-part is not a constant
+     expression */
+  const char *g = "string";
+  ccp = &g + (g ? g-g : 0);
+  /* HPUX 7.0 cc rejects these. */
+  ++ccp;
+  p = (char**) ccp;
+  ccp = (char const *const *) p;
+  { /* SCO 3.2v4 cc rejects this.  */
+    char *t;
+    char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+    *t++ = 0;
+  }
+  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+    int x[] = {25, 17};
+    const int *foo = &x[0];
+    ++foo;
+  }
+  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+    typedef const int *iptr;
+    iptr p = 0;
+    ++p;
+  }
+  { /* AIX XL C 1.02.0.0 rejects this saying
+       "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+    struct s { int j; const int *ap[3]; };
+    struct s *b; b->j = 5;
+  }
+  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+    const int foo = 10;
+  }
+#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_cv_c_const=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_const=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
+echo "${ECHO_T}$ac_cv_c_const" >&6
+if test $ac_cv_c_const = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define const
+_ACEOF
+
+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 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 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
+
+
+
+
+
+
+
+
+for ac_header in fcntl.h limits.h stdlib.h sys/types.h unistd.h winsock.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
+
+
+
+
+
+
+
+
+for ac_header in arpa/inet.h netdb.h netinet/in.h netinet/tcp.h sys/socket.h sys/uio.h sys/un.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
+
+
+
+
+for ac_func in readlink symlink
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+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 $ac_func (); 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 $ac_func ();
+/* 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_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+  ;
+  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
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+echo "$as_me:$LINENO: checking for struct msghdr.msg_control" >&5
+echo $ECHO_N "checking for struct msghdr.msg_control... $ECHO_C" >&6
+if test "${ac_cv_member_struct_msghdr_msg_control+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.  */
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_SYS_UIO_H
+# include <sys/uio.h>
+#endif
+
+int
+main ()
+{
+static struct msghdr ac_aggr;
+if (ac_aggr.msg_control)
+return 0;
+  ;
+  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_member_struct_msghdr_msg_control=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+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_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_SYS_UIO_H
+# include <sys/uio.h>
+#endif
+
+int
+main ()
+{
+static struct msghdr ac_aggr;
+if (sizeof ac_aggr.msg_control)
+return 0;
+  ;
+  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_member_struct_msghdr_msg_control=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_member_struct_msghdr_msg_control=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_member_struct_msghdr_msg_control" >&5
+echo "${ECHO_T}$ac_cv_member_struct_msghdr_msg_control" >&6
+if test $ac_cv_member_struct_msghdr_msg_control = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_MSGHDR_MSG_CONTROL 1
+_ACEOF
+
+
+fi
+echo "$as_me:$LINENO: checking for struct msghdr.msg_accrights" >&5
+echo $ECHO_N "checking for struct msghdr.msg_accrights... $ECHO_C" >&6
+if test "${ac_cv_member_struct_msghdr_msg_accrights+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.  */
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_SYS_UIO_H
+# include <sys/uio.h>
+#endif
+
+int
+main ()
+{
+static struct msghdr ac_aggr;
+if (ac_aggr.msg_accrights)
+return 0;
+  ;
+  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_member_struct_msghdr_msg_accrights=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+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_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_SYS_UIO_H
+# include <sys/uio.h>
+#endif
+
+int
+main ()
+{
+static struct msghdr ac_aggr;
+if (sizeof ac_aggr.msg_accrights)
+return 0;
+  ;
+  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_member_struct_msghdr_msg_accrights=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_member_struct_msghdr_msg_accrights=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_member_struct_msghdr_msg_accrights" >&5
+echo "${ECHO_T}$ac_cv_member_struct_msghdr_msg_accrights" >&6
+if test $ac_cv_member_struct_msghdr_msg_accrights = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS 1
+_ACEOF
+
+
+fi
+
+
+echo "$as_me:$LINENO: checking for in_addr_t in netinet/in.h" >&5
+echo $ECHO_N "checking for in_addr_t in netinet/in.h... $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 <netinet/in.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "in_addr_t" >/dev/null 2>&1; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_IN_ADDR_T 1
+_ACEOF
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+rm -f conftest*
+
+
+echo "$as_me:$LINENO: checking for sendfile in sys/sendfile.h" >&5
+echo $ECHO_N "checking for sendfile in sys/sendfile.h... $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 <sys/sendfile.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "sendfile" >/dev/null 2>&1; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LINUX_SENDFILE 1
+_ACEOF
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+rm -f conftest*
+
+
+echo "$as_me:$LINENO: checking for sendfile in sys/socket.h" >&5
+echo $ECHO_N "checking for sendfile in sys/socket.h... $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 <sys/socket.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "sendfile" >/dev/null 2>&1; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_BSD_SENDFILE 1
+_ACEOF
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+rm -f conftest*
+
+
+
+for ac_func in gethostent
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+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 $ac_func (); 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 $ac_func ();
+/* 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_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+  ;
+  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
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+case "$host" in
+*-mingw32)
+	EXTRA_SRCS="cbits/initWinSock.c, cbits/winSockErr.c, cbits/asyncAccept.c"
+	EXTRA_LIBS=wsock32
+	CALLCONV=stdcall ;;
+*-solaris2)
+	EXTRA_SRCS="cbits/ancilData.c"
+	EXTRA_LIBS="nsl, socket"
+	CALLCONV=ccall ;;
+*)
+	EXTRA_SRCS="cbits/ancilData.c"
+	EXTRA_LIBS=
+	CALLCONV=ccall ;;
+esac
+
+
+
+
+          ac_config_files="$ac_config_files network.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 network package $as_me 1.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 network package config.status 1.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.
+  "network.buildinfo" ) CONFIG_FILES="$CONFIG_FILES network.buildinfo" ;;
+  "include/HsNetworkConfig.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/HsNetworkConfig.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,@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,@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,@EGREP@,$EGREP,;t t
+s,@CALLCONV@,$CALLCONV,;t t
+s,@EXTRA_LIBS@,$EXTRA_LIBS,;t t
+s,@EXTRA_SRCS@,$EXTRA_SRCS,;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,75 @@
+AC_INIT([Haskell network package], [1.0], [libraries@haskell.org], [network])
+
+# Safety check: Ensure that we are in the correct source directory.
+AC_CONFIG_SRCDIR([include/HsNet.h])
+
+AC_CONFIG_HEADERS([include/HsNetworkConfig.h])
+
+AC_CANONICAL_HOST
+
+AC_C_CONST
+
+dnl ** check for specific header (.h) files that we are interested in
+AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h sys/types.h unistd.h winsock.h])
+AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h netinet/tcp.h sys/socket.h sys/uio.h sys/un.h])
+
+AC_CHECK_FUNCS([readlink symlink])
+
+dnl ** check what fields struct msghdr contains
+AC_CHECK_MEMBERS([struct msghdr.msg_control, struct msghdr.msg_accrights], [], [], [#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_SYS_UIO_H
+# include <sys/uio.h>
+#endif])
+
+dnl --------------------------------------------------
+dnl * test for in_addr_t
+dnl --------------------------------------------------
+AC_MSG_CHECKING(for in_addr_t in netinet/in.h)
+AC_EGREP_HEADER(in_addr_t, netinet/in.h,
+ [ AC_DEFINE([HAVE_IN_ADDR_T], [1], [Define to 1 if in_addr_t is available.]) AC_MSG_RESULT(yes) ],
+ AC_MSG_RESULT(no))
+
+dnl --------------------------------------------------
+dnl * test for Linux sendfile(2)
+dnl --------------------------------------------------
+AC_MSG_CHECKING(for sendfile in sys/sendfile.h)
+AC_EGREP_HEADER(sendfile, sys/sendfile.h,
+ [ AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have a Linux sendfile(2) implementation.]) AC_MSG_RESULT(yes) ],
+ AC_MSG_RESULT(no))
+
+dnl --------------------------------------------------
+dnl * test for BSD sendfile(2)
+dnl --------------------------------------------------
+AC_MSG_CHECKING(for sendfile in sys/socket.h)
+AC_EGREP_HEADER(sendfile, sys/socket.h,
+ [ AC_DEFINE([HAVE_BSD_SENDFILE], [1], [Define to 1 if you have a BSDish sendfile(2) implementation.]) AC_MSG_RESULT(yes) ],
+ AC_MSG_RESULT(no))
+
+AC_CHECK_FUNCS(gethostent)
+
+case "$host" in
+*-mingw32)
+	EXTRA_SRCS="cbits/initWinSock.c, cbits/winSockErr.c, cbits/asyncAccept.c"
+	EXTRA_LIBS=wsock32
+	CALLCONV=stdcall ;;
+*-solaris2)
+	EXTRA_SRCS="cbits/ancilData.c"
+	EXTRA_LIBS="nsl, socket"
+	CALLCONV=ccall ;;
+*)
+	EXTRA_SRCS="cbits/ancilData.c"
+	EXTRA_LIBS=
+	CALLCONV=ccall ;;
+esac
+AC_SUBST([CALLCONV])
+AC_SUBST([EXTRA_LIBS])
+AC_SUBST([EXTRA_SRCS])
+
+AC_CONFIG_FILES([network.buildinfo])
+
+AC_OUTPUT
diff --git a/include/HsNet.h b/include/HsNet.h
new file mode 100644
--- /dev/null
+++ b/include/HsNet.h
@@ -0,0 +1,135 @@
+/* -----------------------------------------------------------------------------
+ *
+ * Definitions for package `net' which are visible in Haskell land.
+ *
+ * ---------------------------------------------------------------------------*/
+
+#ifndef HSNET_H
+#define HSNET_H
+
+#include "HsNetworkConfig.h"
+
+/* ultra-evil... */
+#undef PACKAGE_BUGREPORT
+#undef PACKAGE_NAME
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+#undef PACKAGE_VERSION
+
+#ifndef INLINE
+# if defined(_MSC_VER)
+#  define INLINE extern __inline
+# elif defined(__GNUC__)
+#  define INLINE extern inline
+# else
+#  define INLINE inline
+# endif
+#endif
+
+#if defined(HAVE_WINSOCK_H) && !defined(__CYGWIN__)
+#include <winsock.h>
+
+extern void  shutdownWinSock();
+extern int   initWinSock ();
+extern const char* getWSErrorDescr(int err);
+
+# if !defined(__HUGS__)
+extern void* newAcceptParams(int sock,
+			     int sz,
+			     void* sockaddr);
+extern int   acceptNewSock(void* d);
+extern int   acceptDoProc(void* param);
+# endif
+
+#else
+
+#ifdef HAVE_LIMITS_H
+# include <limits.h>
+#endif
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+#ifdef HAVE_SYS_UIO_H
+# include <sys/uio.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_TCP_H
+# include <netinet/tcp.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#ifdef HAVE_SYS_UN_H
+# include <sys/un.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+#ifdef HAVE_BSD_SENDFILE
+#include <sys/uio.h>
+#endif
+#ifdef HAVE_LINUX_SENDFILE
+#if !defined(__USE_FILE_OFFSET64)
+#include <sys/sendfile.h>
+#endif
+#endif
+
+extern int
+sendFd(int sock, int outfd);
+
+extern int
+recvFd(int sock);
+
+/* The next two are scheduled for deletion */
+extern int
+sendAncillary(int sock,
+	      int level,
+	      int type,
+	      int flags,
+	      void* data,
+	      int len);
+
+extern int
+recvAncillary(int  sock,
+	      int* pLevel,
+	      int* pType,
+	      int  flags,
+	      void** pData,
+	      int* pLen);
+
+#endif /* HAVE_WINSOCK_H && !__CYGWIN */
+
+INLINE char *
+my_inet_ntoa(
+#if defined(HAVE_WINSOCK_H)
+             u_long addr
+#elif defined(HAVE_IN_ADDR_T)
+             in_addr_t addr
+#elif defined(HAVE_INTTYPES_H)
+             u_int32_t addr
+#else
+             unsigned long addr
+#endif
+	    )
+{ 
+    struct in_addr a;
+    a.s_addr = addr;
+    return inet_ntoa(a);
+}
+
+#endif
diff --git a/include/HsNetworkConfig.h.in b/include/HsNetworkConfig.h.in
new file mode 100644
--- /dev/null
+++ b/include/HsNetworkConfig.h.in
@@ -0,0 +1,103 @@
+/* include/HsNetworkConfig.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#undef HAVE_ARPA_INET_H
+
+/* Define to 1 if you have a BSDish sendfile(2) implementation. */
+#undef HAVE_BSD_SENDFILE
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the `gethostent' function. */
+#undef HAVE_GETHOSTENT
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if in_addr_t is available. */
+#undef HAVE_IN_ADDR_T
+
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define to 1 if you have a Linux sendfile(2) implementation. */
+#undef HAVE_LINUX_SENDFILE
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#undef HAVE_NETDB_H
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#undef HAVE_NETINET_IN_H
+
+/* Define to 1 if you have the <netinet/tcp.h> header file. */
+#undef HAVE_NETINET_TCP_H
+
+/* Define to 1 if you have the `readlink' function. */
+#undef HAVE_READLINK
+
+/* 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 `msg_accrights' is member of `struct msghdr'. */
+#undef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
+
+/* Define to 1 if `msg_control' is member of `struct msghdr'. */
+#undef HAVE_STRUCT_MSGHDR_MSG_CONTROL
+
+/* Define to 1 if you have the `symlink' function. */
+#undef HAVE_SYMLINK
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#undef HAVE_SYS_SOCKET_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 <sys/uio.h> header file. */
+#undef HAVE_SYS_UIO_H
+
+/* Define to 1 if you have the <sys/un.h> header file. */
+#undef HAVE_SYS_UN_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the <winsock.h> header file. */
+#undef HAVE_WINSOCK_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 empty if `const' does not conform to ANSI C. */
+#undef const
diff --git a/include/Typeable.h b/include/Typeable.h
new file mode 100644
--- /dev/null
+++ b/include/Typeable.h
@@ -0,0 +1,9 @@
+/* Cut down from base/include/Typeable.h */
+#ifndef TYPEABLE_H
+#define TYPEABLE_H
+
+#define INSTANCE_TYPEABLE0(tycon,tcname,str) \
+tcname = mkTyCon str; \
+instance Typeable tycon where { typeOf _ = mkTyConApp tcname [] }
+
+#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:
diff --git a/network.buildinfo.in b/network.buildinfo.in
new file mode 100644
--- /dev/null
+++ b/network.buildinfo.in
@@ -0,0 +1,4 @@
+ghc-options: -DCALLCONV=@CALLCONV@
+cc-options: -DCALLCONV=@CALLCONV@
+c-sources: @EXTRA_SRCS@
+extra-libraries: @EXTRA_LIBS@
diff --git a/network.cabal b/network.cabal
new file mode 100644
--- /dev/null
+++ b/network.cabal
@@ -0,0 +1,25 @@
+name:		network
+version:	2.0
+license:	BSD3
+license-file:	LICENSE
+maintainer:	libraries@haskell.org
+synopsis:	Networking-related facilities
+exposed-modules:
+		Network Network.BSD Network.Socket Network.URI
+extra-source-files:
+		config.guess config.sub install-sh
+		configure.ac configure
+		network.buildinfo.in include/HsNetworkConfig.h.in
+		include/HsNet.h include/Typeable.h
+		-- C sources only used on some systems
+		cbits/ancilData.c
+		cbits/asyncAccept.c cbits/initWinSock.c cbits/winSockErr.c
+extra-tmp-files:
+		config.log config.status autom4te.cache
+		network.buildinfo include/HsNetworkConfig.h
+build-depends:	base, parsec
+extensions:	CPP
+include-dirs: 	include
+install-includes:
+		HsNet.h HsNetworkConfig.h
+c-sources:	cbits/HsNet.c
