Commit 580183e0 authored by ijones's avatar ijones
Browse files

lots of cvs changes from Ross

  tweak SHGetFolderPath
  preprocess: Hugs+MinGW: remove special case
  test *_HOST_OS (as well as *_TARGET_OS, which is there for old GHC's)
  take care of string literals while stripping comments
  rearrange so that we print "Compiling FFI stubs" at most once
  only run ffihugs on Main module if required
  add comment about older Windows versions
  Hugs only: avoid SHGetFolderPath for now
  convert input file paths to platform form (from Brian Smith)
  convert paths to native form at entry
  rename --builddir as --scratchdir to avoid clash with autoconf --build flag.

  doc: consolidate descriptions of preprocessors
parent b2166cc3
......@@ -24,7 +24,7 @@ import Foreign
import System.Directory
import Distribution.Compat.Exception (bracket)
import Control.Monad (when, unless)
#ifndef mingw32_TARGET_OS
#if !(mingw32_HOST_OS || mingw32_TARGET_OS)
import System.Posix (getFileStatus,setFileMode,fileMode,accessTime,
setFileMode,modificationTime,setFileTimes)
#endif
......@@ -43,14 +43,14 @@ findExecutable binary = do
else search ds
exeSuffix :: String
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
exeSuffix = "exe"
#else
exeSuffix = ""
#endif
copyPermissions :: FilePath -> FilePath -> IO ()
#ifndef mingw32_TARGET_OS
#if !(mingw32_HOST_OS || mingw32_TARGET_OS)
copyPermissions src dest
= do srcStatus <- getFileStatus src
setFileMode dest (fileMode srcStatus)
......@@ -61,7 +61,7 @@ copyPermissions src dest
copyFileTimes :: FilePath -> FilePath -> IO ()
#ifndef mingw32_TARGET_OS
#if !(mingw32_HOST_OS || mingw32_TARGET_OS)
copyFileTimes src dest
= do st <- getFileStatus src
let atime = accessTime st
......
......@@ -25,6 +25,7 @@ module Distribution.Compat.FilePath
, isPathSeparator
, pathSeparator
, searchPathSeparator
, platformPath
-- * Filename extensions
, exeExtension
......@@ -70,7 +71,7 @@ import Data.List(intersperse)
-- This is a special case because the \"\\\\\" path doesn\'t refer to
-- an object (file or directory) which resides within a directory.
splitFileName :: FilePath -> (String, String)
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
splitFileName p = (reverse (path2++drive), reverse fname)
where
(path,drive) = case p of
......@@ -171,7 +172,7 @@ joinPaths :: FilePath -> FilePath -> FilePath
joinPaths path1 path2
| isRootedPath path2 = path2
| otherwise =
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
case path2 of
d:':':path2' | take 2 path1 == [d,':'] -> path1 `joinFileName` path2'
| otherwise -> path2
......@@ -196,7 +197,7 @@ changeFileExt path ext = joinFileExt name ext
-- the drive letter and the full file path.
isRootedPath :: FilePath -> Bool
isRootedPath (c:_) | isPathSeparator c = True
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
isRootedPath (_:':':c:_) | isPathSeparator c = True -- path with drive letter
#endif
isRootedPath _ = False
......@@ -204,7 +205,7 @@ isRootedPath _ = False
-- | Returns 'True' if this path\'s meaning is independent of any OS
-- \"working directory\", or 'False' if it isn\'t.
isAbsolutePath :: FilePath -> Bool
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
isAbsolutePath (_:':':c:_) | isPathSeparator c = True
#else
isAbsolutePath (c:_) | isPathSeparator c = True
......@@ -216,7 +217,7 @@ isAbsolutePath _ = False
-- Unix the prefix is always \"\/\".
dropAbsolutePrefix :: FilePath -> FilePath
dropAbsolutePrefix (c:cs) | isPathSeparator c = cs
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
dropAbsolutePrefix (_:':':c:cs) | isPathSeparator c = cs -- path with drive letter
dropAbsolutePrefix (_:':':cs) = cs
#endif
......@@ -272,7 +273,7 @@ pathParents :: FilePath -> [FilePath]
pathParents p =
root'' : map ((++) root') (dropEmptyPath $ inits path')
where
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
(root,path) = case break (== ':') p of
(path, "") -> ("",path)
(root,_:path) -> (root++":",path)
......@@ -303,7 +304,7 @@ commonParent :: [FilePath] -> Maybe FilePath
commonParent [] = Nothing
commonParent paths@(p:ps) =
case common Nothing "" p ps of
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
Nothing | all (not . isAbsolutePath) paths ->
let
getDrive (d:':':_) ds
......@@ -376,7 +377,7 @@ mkSearchPath paths = concat (intersperse [searchPathSeparator] paths)
-- checks for it on this platform, too.
isPathSeparator :: Char -> Bool
isPathSeparator ch =
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
ch == '/' || ch == '\\'
#else
ch == '/'
......@@ -387,7 +388,7 @@ isPathSeparator ch =
-- separator is a slash (@\"\/\"@) on Unix and Macintosh, and a backslash
-- (@\"\\\"@) on the Windows operating system.
pathSeparator :: Char
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
pathSeparator = '\\'
#else
pathSeparator = '/'
......@@ -397,17 +398,27 @@ pathSeparator = '/'
-- environment variables. The separator is a colon (\":\") on Unix and Macintosh,
-- and a semicolon (\";\") on the Windows operating system.
searchPathSeparator :: Char
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
searchPathSeparator = ';'
#else
searchPathSeparator = ':'
#endif
-- |Convert Unix-style path separators to the path separators for this platform.
platformPath :: FilePath -> FilePath
#if mingw32_HOST_OS || mingw32_TARGET_OS
platformPath = map slash
where slash '/' = '\\'
slash c = c
#else
platformPath = id
#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_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
exeExtension = "exe"
#else
exeExtension = ""
......@@ -422,7 +433,7 @@ objExtension = "o"
-- | Extension for dynamically linked (or shared) libraries
-- (typically @\"so\"@ on Unix and @\"dll\"@ on Windows)
dllExtension :: String
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
dllExtension = "dll"
#else
dllExtension = "so"
......
......@@ -62,7 +62,9 @@ import Distribution.License
import Distribution.Version
import Distribution.Package ( parsePackageName )
import Distribution.Compat.ReadP as ReadP hiding (get)
import Distribution.Compat.FilePath (platformPath)
import Debug.Trace
import Control.Monad (liftM)
import Data.Char
import Language.Haskell.Extension (Extension)
......@@ -215,7 +217,7 @@ parseModuleNameQ = parseQuoted modu <++ modu
return (c:cs)
parseFilePathQ :: ReadP r FilePath
parseFilePathQ = parseTokenQ
parseFilePathQ = liftM platformPath parseTokenQ
parseReadS :: Read a => ReadP r a
parseReadS = readS_to_P reads
......
......@@ -214,11 +214,7 @@ ppCpp' inputArgs bi lbi =
hc = compiler lbi
use_cpphs cpphs inFile outFile verbose
#if __HUGS__ && mingw32_TARGET_OS
= rawSystemVerbose verbose "sh" (cpphs : cpphsArgs)
#else
= rawSystemVerbose verbose cpphs cpphsArgs
#endif
where cpphsArgs = ("-O"++outFile) : inFile : "--noline" : "--strip"
: extraArgs
......@@ -236,11 +232,7 @@ ppCpp' inputArgs bi lbi =
ppHsc2hs :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppHsc2hs bi lbi
= maybe (ppNone "hsc2hs") pp (withHsc2hs lbi)
#if __HUGS__ && mingw32_TARGET_OS
where pp n = standardPP "sh" (n : cppOptions bi lbi)
#else
where pp n = standardPP n (cppOptions bi lbi)
#endif
ppC2hs :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppC2hs bi lbi
......
......@@ -52,7 +52,8 @@ module Distribution.Setup (--parseArgs,
parseConfigureArgs, parseBuildArgs, parseCleanArgs,
parseHaddockArgs, parseProgramaticaArgs, parseTestArgs,
parseInstallArgs, parseSDistArgs, parseRegisterArgs,
parseUnregisterArgs, parseCopyArgs
parseUnregisterArgs, parseCopyArgs,
reqPathArg, reqDirArg
) where
......@@ -65,6 +66,7 @@ import Distribution.Compiler (CompilerFlavor(..), Compiler(..))
import Distribution.Simple.Utils (die)
import Data.List(find)
import Distribution.GetOpt
import Distribution.Compat.FilePath (platformPath)
import System.Exit
import System.Environment
......@@ -239,25 +241,25 @@ configureCmd = Cmd {
Option "g" ["ghc"] (NoArg GhcFlag) "compile with GHC",
Option "n" ["nhc"] (NoArg NhcFlag) "compile with NHC",
Option "" ["hugs"] (NoArg HugsFlag) "compile with hugs",
Option "w" ["with-compiler"] (ReqArg WithCompiler "PATH")
Option "w" ["with-compiler"] (reqPathArg WithCompiler)
"give the path to a particular compiler",
Option "" ["with-hc-pkg"] (ReqArg WithHcPkg "PATH")
Option "" ["with-hc-pkg"] (reqPathArg WithHcPkg)
"give the path to the package tool",
Option "" ["prefix"] (ReqArg Prefix "DIR")
Option "" ["prefix"] (reqDirArg Prefix)
"bake this prefix in preparation of installation",
Option "" ["with-haddock"] (ReqArg WithHaddock "PATH")
Option "" ["with-haddock"] (reqPathArg WithHaddock)
"give the path to haddock",
Option "" ["with-happy"] (ReqArg WithHappy "PATH")
Option "" ["with-happy"] (reqPathArg WithHappy)
"give the path to happy",
Option "" ["with-alex"] (ReqArg WithAlex "PATH")
Option "" ["with-alex"] (reqPathArg WithAlex)
"give the path to alex",
Option "" ["with-hsc2hs"] (ReqArg WithHsc2hs "PATH")
Option "" ["with-hsc2hs"] (reqPathArg WithHsc2hs)
"give the path to hsc2hs",
Option "" ["with-c2hs"] (ReqArg WithC2hs "PATH")
Option "" ["with-c2hs"] (reqPathArg WithC2hs)
"give the path to c2hs",
Option "" ["with-cpphs"] (ReqArg WithCpphs "PATH")
Option "" ["with-cpphs"] (reqPathArg WithCpphs)
"give the path to cpphs",
Option "" ["with-greencard"] (ReqArg WithGreencard "PATH")
Option "" ["with-greencard"] (reqPathArg WithGreencard)
"give the path to greencard",
Option "p" ["enable-library-profiling"] (NoArg WithProfLib)
"Enable library profiling",
......@@ -275,6 +277,12 @@ configureCmd = Cmd {
cmdAction = ConfigCmd emptyConfigFlags
}
reqPathArg :: (FilePath -> a) -> ArgDescr a
reqPathArg constr = ReqArg (constr . platformPath) "PATH"
reqDirArg :: (FilePath -> a) -> ArgDescr a
reqDirArg constr = ReqArg (constr . platformPath) "DIR"
parseConfigureArgs :: ConfigFlags -> [String] -> [OptDescr a] ->
IO (ConfigFlags, [a], [String])
parseConfigureArgs = parseArgs configureCmd updateCfg
......@@ -355,7 +363,7 @@ installCmd = Cmd {
cmdHelp = "Copy the files into the install locations. Run register.",
cmdDescription = "Unlike the copy command, install calls the register command.\nIf you want to install into a location that is not what was\nspecified in the configure step, use the copy command.\n",
cmdOptions = [cmd_help, cmd_verbose,
Option "" ["install-prefix"] (ReqArg InstPrefix "DIR")
Option "" ["install-prefix"] (reqDirArg InstPrefix)
"[DEPRECATED, use copy]",
Option "" ["user"] (NoArg UserFlag)
"upon registration, register this package in the user's local package database",
......@@ -371,7 +379,7 @@ copyCmd = Cmd {
cmdHelp = "Copy the files into the install locations.",
cmdDescription = "Does not call register, and allows a prefix at install time\nWithout the copy-prefix flag, configure determines location.\n",
cmdOptions = [cmd_help, cmd_verbose,
Option "" ["copy-prefix"] (ReqArg InstPrefix "DIR")
Option "" ["copy-prefix"] (reqDirArg InstPrefix)
"specify the directory in which to place installed files"
],
cmdAction = CopyCmd Nothing
......
......@@ -435,7 +435,7 @@ no_extra_flags extra_flags =
die ("Unrecognised flags: " ++ concat (intersperse "," (extra_flags)))
buildDirOpt :: OptDescr (LocalBuildInfo -> LocalBuildInfo)
buildDirOpt = Option "b" ["builddir"] (ReqArg setBuildDir "DIR")
buildDirOpt = Option "b" ["scratchdir"] (reqDirArg setBuildDir)
"directory to receive the built package [dist/build]"
where setBuildDir dir lbi = lbi { buildDir = dir }
......
......@@ -68,7 +68,7 @@ import Language.Haskell.Extension (Extension(..))
import Data.Char(isSpace)
import Data.Maybe(mapMaybe, maybeToList)
import Control.Monad (unless, when)
import Control.Monad (unless, when, filterM)
#ifndef __NHC__
import Control.Exception (try)
#else
......@@ -78,8 +78,9 @@ import Data.List(nub, sort, isSuffixOf)
import System.Directory (removeFile)
import Distribution.Compat.Directory (copyFile,createDirectoryIfMissing)
import Distribution.Compat.FilePath (splitFilePath, joinFileName,
splitFileExt, joinFileExt,
searchPathSeparator, objExtension, joinPaths, splitFileName)
splitFileExt, joinFileExt, objExtension,
searchPathSeparator, joinPaths,
splitFileName, platformPath)
import qualified Distribution.Simple.GHCPackageConfig
as GHC (localPackageConfig, canReadLocalPackageConfig)
......@@ -284,7 +285,7 @@ buildHugs pkg_descr lbi verbose = do
let destMainFile = exeDir `joinFileName` hugsMainFilename exe
copyModule (CPP `elem` extensions bi) bi srcMainFile destMainFile
compileBuildInfo exeDir (maybe [] (hsSourceDirs . libBuildInfo) (library pkg_descr)) exeMods bi
compileFFI bi destMainFile
compileFiles bi [destMainFile]
compileBuildInfo :: FilePath
-> [FilePath] -- ^library source dirs, if building exes
......@@ -307,7 +308,7 @@ buildHugs pkg_descr lbi verbose = do
-- Pass 2: compile foreign stubs in build directory
stubsFileLists <- sequence [moduleToFilePath [destDir] modu suffixes |
modu <- mods]
mapM_ (compileFFI bi) (concat stubsFileLists)
compileFiles bi (concat stubsFileLists)
suffixes = ["hs", "lhs"]
......@@ -323,28 +324,37 @@ buildHugs pkg_descr lbi verbose = do
else
copyFile srcFile destFile
compileFFI :: BuildInfo -> FilePath -> IO ()
compileFFI bi file = do
-- Only compile FFI stubs for a file if it contains some FFI stuff
inp <- readHaskellFile file
when ("foreign" `elem` symbols (stripComments False inp)) $ do
compileFiles :: BuildInfo -> [FilePath] -> IO ()
compileFiles bi fileList = do
ffiFileList <- filterM testFFI fileList
unless (null ffiFileList) $ do
when (verbose > 2) (putStrLn "Compiling FFI stubs")
(_, opts, file_incs) <- getOptionsFromSource file
let ghcOpts = hcOptions GHC opts
let pkg_incs = ["\"" ++ inc ++ "\"" | inc <- includes bi]
let incs = uniq (sort (file_incs ++ includeOpts ghcOpts ++ pkg_incs))
let pathFlag = "-P" ++ buildDir lbi ++ [searchPathSeparator]
let hugsArgs = "-98" : pathFlag : map ("-i" ++) incs
cfiles <- getCFiles file
let cArgs =
["-I" ++ dir | dir <- includeDirs bi] ++
ccOptions bi ++
cfiles ++
["-L" ++ dir | dir <- extraLibDirs bi] ++
ldOptions bi ++
["-l" ++ lib | lib <- extraLibs bi] ++
concat [["-framework", f] | f <- frameworks bi]
rawSystemExit verbose ffihugs (hugsArgs ++ file : cArgs)
mapM_ (compileFFI bi) ffiFileList
-- Only compile FFI stubs for a file if it contains some FFI stuff
testFFI :: FilePath -> IO Bool
testFFI file = do
inp <- readHaskellFile file
return ("foreign" `elem` symbols (stripComments False inp))
compileFFI :: BuildInfo -> FilePath -> IO ()
compileFFI bi file = do
(_, opts, file_incs) <- getOptionsFromSource file
let ghcOpts = hcOptions GHC opts
let pkg_incs = ["\"" ++ inc ++ "\"" | inc <- includes bi]
let incs = uniq (sort (file_incs ++ includeOpts ghcOpts ++ pkg_incs))
let pathFlag = "-P" ++ buildDir lbi ++ [searchPathSeparator]
let hugsArgs = "-98" : pathFlag : map ("-i" ++) incs
cfiles <- getCFiles file
let cArgs =
["-I" ++ dir | dir <- includeDirs bi] ++
ccOptions bi ++
cfiles ++
["-L" ++ dir | dir <- extraLibDirs bi] ++
ldOptions bi ++
["-l" ++ lib | lib <- extraLibs bi] ++
concat [["-framework", f] | f <- frameworks bi]
rawSystemExit verbose ffihugs (hugsArgs ++ file : cArgs)
ffihugs = compilerPath (compiler lbi)
......@@ -357,7 +367,7 @@ buildHugs pkg_descr lbi verbose = do
getCFiles :: FilePath -> IO [String]
getCFiles file = do
inp <- readHaskellFile file
return [cfile |
return [platformPath cfile |
"{-#" : "CFILES" : rest <-
map words $ lines $ stripComments True inp,
last rest == "#-}",
......@@ -435,6 +445,7 @@ stripComments
-> String
stripComments keepPragmas = stripCommentsLevel 0
where stripCommentsLevel :: Int -> String -> String
stripCommentsLevel 0 ('"':cs) = '"':copyString cs
stripCommentsLevel 0 ('-':'-':cs) = -- FIX: symbols like -->
stripCommentsLevel 0 (dropWhile (/= '\n') cs)
stripCommentsLevel 0 ('{':'-':'#':cs)
......@@ -445,6 +456,11 @@ stripComments keepPragmas = stripCommentsLevel 0
stripCommentsLevel n (c:cs) = stripCommentsLevel n cs
stripCommentsLevel _ [] = []
copyString ('\\':c:cs) = '\\' : c : copyString cs
copyString ('"':cs) = '"' : stripCommentsLevel 0 cs
copyString (c:cs) = c : copyString cs
copyString [] = []
copyPragma ('#':'-':'}':cs) = '#' : '-' : '}' : stripCommentsLevel 0 cs
copyPragma (c:cs) = c : copyPragma cs
copyPragma [] = []
......
......@@ -92,7 +92,7 @@ import Distribution.Compat.ReadP
import Distribution.Compat.Directory (findExecutable)
import Data.Char (isDigit)
import Prelude hiding (catch)
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
import Foreign
import Foreign.C
#endif
......@@ -245,7 +245,11 @@ getInstalledPackages comp user verbose = do
_ -> die "cannot parse package list"
system_default_prefix :: IO String
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
# if __HUGS__
system_default_prefix =
return "C:\\Program Files"
# else
system_default_prefix =
allocaBytes long_path_size $ \pPath -> do
r <- c_SHGetFolderPath nullPtr csidl_PROGRAM_FILES nullPtr 0 pPath
......@@ -254,13 +258,14 @@ system_default_prefix =
csidl_PROGRAM_FILES = 0x0026
long_path_size = 1024
foreign import stdcall unsafe "SHGetFolderPathW"
foreign import stdcall unsafe "shlobj.h SHGetFolderPathA"
c_SHGetFolderPath :: Ptr ()
-> CInt
-> Ptr ()
-> CInt
-> CString
-> IO CInt
# endif
#else
system_default_prefix =
return "/usr/local"
......
......@@ -181,7 +181,7 @@ installHugs verbose libPref binPref targetLibPref buildPref pkg_descr = do
try $ removeDirectoryRecursive installDir
smartCopySources verbose [buildDir] installDir
("Main" : otherModules (buildInfo exe)) hugsInstallSuffixes True
#ifndef mingw32_TARGET_OS
#if !(mingw32_HOST_OS || mingw32_TARGET_OS)
-- FIX (HUGS): works for Unix only
let targetName = targetDir `joinFileName` hugsMainFilename exe
let exeFile = binPref `joinFileName` exeName exe
......@@ -230,7 +230,7 @@ mkLibDir pkg_descr lbi install_prefixM =
where
hc = compiler lbi
libDir = (fromMaybe (prefix lbi) install_prefixM)
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
`joinFileName` "Haskell"
#else
`joinFileName` "lib"
......@@ -239,7 +239,7 @@ mkLibDir pkg_descr lbi install_prefixM =
mkBinDir :: PackageDescription -> LocalBuildInfo -> Maybe FilePath -> FilePath
mkBinDir pkg_descr lbi install_prefixM =
(fromMaybe (prefix lbi) install_prefixM)
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
`joinFileName` showPackageId (package pkg_descr)
#endif
`joinFileName` "bin"
......
......@@ -96,14 +96,14 @@ import HUnit (Test)
#endif
regScriptLocation :: FilePath
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
regScriptLocation = "register.bat"
#else
regScriptLocation = "register.sh"
#endif
unregScriptLocation :: FilePath
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
unregScriptLocation = "unregister.bat"
#else
unregScriptLocation = "unregister.sh"
......@@ -153,14 +153,14 @@ register pkg_descr lbi (userInst, genScript, verbose)
let register_flags
| ghc_63_plus = "update":
#ifndef mingw32_TARGET_OS
#if !(mingw32_HOST_OS || mingw32_TARGET_OS)
if genScript
then []
else
#endif
[installedPkgConfigFile]
| otherwise = "--update-package":
#ifndef mingw32_TARGET_OS
#if !(mingw32_HOST_OS || mingw32_TARGET_OS)
if genScript
then []
else
......@@ -296,7 +296,7 @@ rawSystemEmit :: FilePath -- ^Script name
rawSystemEmit _ False verbosity path args
= rawSystemExit verbosity path args
rawSystemEmit scriptName True verbosity path args = do
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
writeFile scriptName ("@" ++ path ++ concatMap (' ':) args)
#else
writeFile scriptName ("#!/bin/sh\n\n"
......@@ -314,7 +314,7 @@ rawSystemPipe :: FilePath -- ^Script location
-> [String] -- ^Args
-> IO ()
rawSystemPipe scriptName verbose pipeFrom path args = do
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
writeFile scriptName ("@" ++ path ++ concatMap (' ':) args)
#else
writeFile scriptName ("#!/bin/sh\n\n"
......
......@@ -86,7 +86,7 @@ import System.Environment (getProgName)
import System.IO (hPutStrLn, stderr, hFlush, stdout)
import System.IO.Error
import System.Exit
#if (__GLASGOW_HASKELL__ || __HUGS__) && !defined(mingw32_TARGET_OS)
#if (__GLASGOW_HASKELL__ || __HUGS__) && !(mingw32_HOST_OS || mingw32_TARGET_OS)
import System.Posix.Internals (c_getpid)
#endif
......@@ -291,7 +291,7 @@ withTempFile tmp_dir extn action
if b then findTempName (x+1)
else action path `finally` try (removeFile path)
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
foreign import ccall unsafe "_getpid" getProcessID :: IO Int
-- relies on Int == Int32 on Windows
#elif __GLASGOW_HASKELL__ || __HUGS__
......@@ -386,7 +386,7 @@ hunitTests :: [Test]
hunitTests
= let suffixes = ["hs", "lhs"]
in [TestCase $
#ifdef mingw32_TARGET_OS
#if mingw32_HOST_OS || mingw32_TARGET_OS
do mp1 <- moduleToFilePath [""] "Distribution.Simple.Build" suffixes --exists
mp2 <- moduleToFilePath [""] "Foo.Bar" suffixes -- doesn't exist
assertEqual "existing not found failed"
......
......@@ -288,11 +288,15 @@ Other-Modules: A, C, Utils</programlisting>
</variablelist>
<note>
<para>Module names may correspond to Haskell source files, i.e.
with names ending in <quote><literal>.hs</literal></quote>
or <quote><literal>.lhs</literal></quote>, or to inputs for
various Haskell preprocessors. The simple build infrastructure
understands
<title>Modules and preprocessors</title>
<para>Haskell module names listed in the
<literal>exposed-modules</literal> and
<literal>other-modules</literal> fields may
correspond to Haskell source files, i.e. with names
ending in <quote><literal>.hs</literal></quote> or
<quote><literal>.lhs</literal></quote>, or to inputs for
various Haskell preprocessors.
The simple build infrastructure understands the extensions
<quote><literal>.gc</literal></quote> (GreenCard),
<quote><literal>.chs</literal></quote> (<command>c2hs</command>),
<quote><literal>.hsc</literal></quote> (<command>hsc2hs</command>),
......@@ -301,8 +305,8 @@ Other-Modules: A, C, Utils</programlisting>
<quote><literal>.x</literal></quote> (<command>alex</command>)
and
<quote><literal>.cpphs</literal></quote> (<command>cpphs</command>).
In such cases the appropriate preprocessor will be run
automatically as required.</para>
When building, Cabal will automatically run the appropriate
preprocessor and compile the Haskell module it produces.</para>
</note>
<para>Some fields take lists of values, which
......@@ -934,20 +938,6 @@ ld-options: -L/usr/X11R6/lib</programlisting>
</note>
</sect2>
<sect2 id="Preprocessors">
<title>Preprocessors</title>
<para>Cabal will automatically handle certain preprocessors
including GreenCard, hsc2hs, happy, and alex. To use these
preprocessors, just specify the module name (without any
extension) in the <literal>exposed-modules</literal> or
<literal>extra-modules</literal> fields. No further steps are
required. Cabal will look for modules with extensions
corresponding to the preprocessors it knows about (".y" for
Happy files, ".gc" for GreenCard files, etc.), run the
appropriate preprocessor on those files, then compile the
output.</para>
</sect2>
<sect2 id="complex-packages">