1-- | Provides an abstraction expansion of $Makefile$ macros.2module Mach.Types where34-- | Supported command line flags.5data Flag6 = EnvOverwrite7 | IgnoreAll8 | DryRun9 | SilentAll10 | ExecCont11 | TermOnErr12 | NoBuiltin13 | Makefile String14 | Jobs String15 deriving (Show)1617-- | A macro assignment, can either be evaluated when the macro18-- is assigned (immediate) or when the macro is used (delayed).19data MacroAssign20 = -- | Immediate assignment21 AssignI String22 | -- | Delayed assignment23 AssignD Token24 deriving (Show)2526-- | Tokens of text which are potentially subject to macro expansion.27data Token28 = -- | Literal, not subject to macro expansion29 Lit String30 | -- | Macro expansion31 Exp Token32 | -- | Macro expansion with suffix replacement33 ExpSub Token String String34 | -- | Sequence text35 Seq [Token]36 deriving (Show, Eq)3738-- | A macro definition, i.e. an assignment.39data Assign40 = Assign41 -- | Unique identifier for the macro42 Token43 -- | Assignment type44 Flavor45 -- | Right value of the assignment46 Token47 deriving (Show, Eq)4849-- | POSIX make supports different macro assignment operators (macro flavors).50data Flavor51 = -- | Assign and expand macro on use52 Delayed53 | -- | Assign and expand macro in definition line54 Immediate55 | -- | Immediately expand rvalue, but expand defined macro on use56 StrictDelay57 | -- | Shell command assignment, expanded on use58 System59 | -- | Conditional assignment, expanded on use60 Cond61 | -- | Appends text to a macro62 Append63 deriving (Eq)6465instance Show Flavor where66 show Delayed = "="67 show Immediate = "::="68 show StrictDelay = ":::="69 show System = "!="70 show Cond = "?="71 show Append = "+="7273------------------------------------------------------------------------7475-- | Makefile specification, a sequence of statements.76type MkFile = [MkStat]7778-- | Inference rule.79data InfRule80 = InfRule81 -- | Target, always begins with a period82 String83 -- | Commands (might be empty)84 [Token]85 deriving86 (Show, Eq)8788-- | Target rule which relates targets to commands for their creation.89data TgtRule90 = TgtRule91 -- | Targets (non-empty)92 [Token]93 -- | Prerequisites94 [Token]95 -- | Commands96 [Token]97 deriving98 (Show, Eq)99100-- | A statement within a @Makefile@. Three types of statements are101-- supported: assignments, includes, and rules.102data MkStat103 = MkAssign Assign104 | MkInclude [Token]105 | MkTgtRule TgtRule106 | MkInfRule InfRule107 deriving (Show, Eq)