1 -----------------------------------------------------------------------------
2 -- $Id: DriverPhases.hs,v 1.24 2003/05/21 12:46:19 simonmar Exp $
6 -- (c) The University of Glasgow 2002
8 -----------------------------------------------------------------------------
10 #include "../includes/config.h"
14 startPhase, -- :: String -> Phase
15 phaseInputExt, -- :: Phase -> String
17 haskellish_file, haskellish_suffix,
18 haskellish_src_file, haskellish_src_suffix,
19 objish_file, objish_suffix,
20 cish_file, cish_suffix,
21 isExtCore_file, extcoreish_suffix,
22 isSourceFile -- :: FilePath -> Bool
27 -----------------------------------------------------------------------------
31 Phase of the | Suffix saying | Flag saying | (suffix of)
32 compilation system | ``start here''| ``stop after''| output file
34 literate pre-processor | .lhs | - | -
35 C pre-processor (opt.) | - | -E | -
36 Haskell compiler | .hs | -C, -S | .hc, .s
37 C compiler (opt.) | .hc or .c | -S | .s
38 assembler | .s or .S | -c | .o
39 linker | other | - | a.out
43 = MkDependHS -- haskell dependency generation
49 | HCc -- Haskellised C (as opposed to vanilla C) compilation
50 | Mangle -- assembly mangling, now done by a separate script.
51 | SplitMangle -- after mangler if splitting
61 -- the first compilation phase for a given file is determined
63 startPhase "lhs" = Unlit
65 startPhase "hscpp" = HsPp
66 startPhase "hspp" = Hsc
67 startPhase "hcr" = Hsc
74 startPhase "raw_s" = Mangle
78 startPhase _ = Ln -- all unknown file types
80 -- the output suffix for a given phase is uniquely determined by
81 -- the input requirements of the next phase.
82 phaseInputExt Unlit = "lhs"
83 phaseInputExt Cpp = "lpp" -- intermediate only
84 phaseInputExt HsPp = "hscpp"
85 phaseInputExt Hsc = "hspp"
86 phaseInputExt HCc = "hc"
87 phaseInputExt Cc = "c"
88 phaseInputExt Mangle = "raw_s"
89 phaseInputExt SplitMangle = "split_s" -- not really generated
90 phaseInputExt As = "s"
91 phaseInputExt SplitAs = "split_s" -- not really generated
92 phaseInputExt Ln = "o"
93 phaseInputExt MkDependHS = "dep"
95 phaseInputExt Ilx2Il = "ilx"
96 phaseInputExt Ilasm = "il"
99 haskellish_suffix = (`elem` [ "hs", "lhs", "hspp", "hscpp", "hcr", "hc", "raw_s" ])
100 haskellish_src_suffix = (`elem` [ "hs", "lhs", "hspp", "hscpp", "hcr"])
101 cish_suffix = (`elem` [ "c", "cpp", "C", "cc", "cxx", "s", "S" ])
102 extcoreish_suffix = (`elem` [ "hcr" ])
104 -- Use the appropriate suffix for the system on which
105 -- the GHC-compiled code will run
106 #if mingw32_TARGET_OS || cygwin32_TARGET_OS
107 objish_suffix = (`elem` [ "o", "O", "obj", "OBJ" ])
109 objish_suffix = (`elem` [ "o" ])
112 haskellish_file = haskellish_suffix . getFileSuffix
113 haskellish_src_file = haskellish_src_suffix . getFileSuffix
114 cish_file = cish_suffix . getFileSuffix
115 isExtCore_file = extcoreish_suffix . getFileSuffix
116 objish_file = objish_suffix . getFileSuffix
118 isSourceFile :: FilePath -> Bool