+-- GHC and Hugs get the appropriate include file from the OPTIONS
+-- pragma generated by hsc2hs from the above #include.
+-- Implementations following the FFI spec have to specify it in the
+-- foreign import, which is awkward because some systems provide
+-- regex.h and the rest of the regex library, but otherwise we
+-- need to use our own copy, regex/regex.h.
+
+#if __GLASGOW_HASKELL__ || __HUGS__
+foreign import ccall unsafe "regcomp"
+ c_regcomp :: Ptr CRegex -> CString -> CInt -> IO CInt
+
+foreign import ccall unsafe "®free"
+ ptr_regfree :: FunPtr (Ptr CRegex -> IO ())
+
+foreign import ccall unsafe "regexec"
+ c_regexec :: Ptr CRegex -> CString -> CSize
+ -> Ptr CRegMatch -> CInt -> IO CInt
+#elif HAVE_REGEX_H && HAVE_REGCOMP
+foreign import ccall unsafe "regex.h regcomp"
+ c_regcomp :: Ptr CRegex -> CString -> CInt -> IO CInt
+
+foreign import ccall unsafe "regex.h ®free"
+ ptr_regfree :: FunPtr (Ptr CRegex -> IO ())
+
+foreign import ccall unsafe "regex.h regexec"
+ c_regexec :: Ptr CRegex -> CString -> CSize
+ -> Ptr CRegMatch -> CInt -> IO CInt
+#else
+foreign import ccall unsafe "regex/regex.h regcomp"