[commit: packages/directory] master: Use autoconf to figure out exeExtension (b6b625f)
git at git.haskell.org
git at git.haskell.org
Fri Dec 18 09:50:59 UTC 2015
Repository : ssh://git@git.haskell.org/directory
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/b6b625f42190ab489c0c6b071cb6188d15dd7c63/directory
>---------------------------------------------------------------
commit b6b625f42190ab489c0c6b071cb6188d15dd7c63
Author: Phil Ruffwind <rf at rufflewind.com>
Date: Fri May 29 20:43:32 2015 -0400
Use autoconf to figure out exeExtension
>---------------------------------------------------------------
b6b625f42190ab489c0c6b071cb6188d15dd7c63
System/Directory.hs | 15 +++------------
System/Directory/Internal.hsc | 7 +++++++
configure.ac | 5 +++++
3 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/System/Directory.hs b/System/Directory.hs
index faddfe3..8bd06c2 100644
--- a/System/Directory.hs
+++ b/System/Directory.hs
@@ -145,12 +145,13 @@ import qualified System.Posix as Posix
#endif
#ifdef HAVE_UTIMENSAT
-import System.Directory.Internal
import System.Posix.Internals ( withFilePath )
#endif
#endif /* __GLASGOW_HASKELL__ */
+import System.Directory.Internal
+
#ifdef mingw32_HOST_OS
win32_cSIDL_LOCAL_APPDATA :: Win32.CSIDL
win32_fILE_SHARE_DELETE :: Win32.ShareMode
@@ -876,7 +877,7 @@ findExecutable fileName = do
findExecutables :: String -> IO [FilePath]
findExecutables binary = do
#if defined(mingw32_HOST_OS)
- file <- Win32.searchPath Nothing binary ('.':exeExtension)
+ file <- Win32.searchPath Nothing binary exeExtension
return $ maybeToList file
#else
path <- getEnv "PATH"
@@ -1513,13 +1514,3 @@ getTemporaryDirectory =
getEnv "TMPDIR" `catchIOError` \ err ->
if isDoesNotExistError err then return "/tmp" else ioError err
#endif
-
--- ToDo: This should be determined via autoconf (AC_EXEEXT)
--- | Extension for executable files
--- (typically @\"\"@ on Unix and @\"exe\"@ on Windows or OS\/2)
-exeExtension :: String
-#ifdef mingw32_HOST_OS
-exeExtension = "exe"
-#else
-exeExtension = ""
-#endif
diff --git a/System/Directory/Internal.hsc b/System/Directory/Internal.hsc
index 17c06f0..e20187b 100644
--- a/System/Directory/Internal.hsc
+++ b/System/Directory/Internal.hsc
@@ -1,5 +1,7 @@
module System.Directory.Internal where
+#include <HsDirectory.h>
+
#ifndef mingw32_HOST_OS
# include <HsUnixConfig.h>
#endif
@@ -13,6 +15,11 @@ import Foreign.C
import System.Posix.Types
#endif
+-- | Filename extension for executable files (including the dot if any)
+-- (usually @\"\"@ on POSIX systems and @\".exe\"@ on Windows or OS\/2).
+exeExtension :: String
+exeExtension = (#const_str EXE_EXTENSION)
+
#ifdef HAVE_UTIMENSAT
data CTimeSpec = CTimeSpec EpochTime CLong
diff --git a/configure.ac b/configure.ac
index c75262c..6bd44ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,4 +13,9 @@ AC_PROG_CC()
# check for specific header (.h) files that we are interested in
AC_CHECK_HEADERS([sys/types.h unistd.h sys/stat.h])
+# EXTEXT is defined automatically by AC_PROG_CC;
+# we just need to capture it in the header file
+AC_DEFINE_UNQUOTED([EXE_EXTENSION], ["$EXEEXT"],
+ [Filename extension of executable files])
+
AC_OUTPUT
More information about the ghc-commits
mailing list