<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!-- Makefile syntaxfile v0.9 by Per Wigren <wigren@home.se> -->
<!-- Modified by Joseph Wenninger <jowenn@kde.org> -->
<!-- Modified by Rui Santana <santana.rui@gmail.com> -->
<!-- v2.0 by Andreas Nordal <andreas.nordal@gmail.com> -->
<!-- small priority to allow for example Makefile.cpp to be detected as cpp file -->
<!-- v2.1 by Alex Turbov <i.zaufi@gmail.com>
     improve comments handling -->
<language name="Makefile" section="Other"
          version="2.1" kateversion="2.4"
          extensions="GNUmakefile;Makefile;makefile;GNUmakefile.*;Makefile.*;makefile.*;*.mk"
          mimetype="text/x-makefile"
          author="Per Wigren (wigren@home.se)" license="">
  <highlighting>
    <list name = "keywords">
      <item> include </item>
      <item> define </item>
      <item> else </item>
      <item> endef </item>
      <item> endif </item>
      <item> ifdef </item>
      <item> ifeq </item>
      <item> ifndef </item>
      <item> ifneq </item>
      <item> override </item>
    </list>
    <list name = "functions">
      <item> call </item>
      <item> subst </item>
      <item> patsubst </item>
      <item> strip </item>
      <item> findstring </item>
      <item> filter </item>
      <item> filter-out </item>
      <item> sort </item>
      <item> word </item>
      <item> wordlist </item>
      <item> words </item>
      <item> firstword </item>
      <item> lastword </item>
      <item> dir </item>
      <item> notdir </item>
      <item> suffix </item>
      <item> basename </item>
      <item> addsuffix </item>
      <item> addprefix </item>
      <item> join </item>
      <item> wildcard </item>
      <item> realpath </item>
      <item> abspath </item>
      <item> if </item>
      <item> or </item>
      <item> and </item>
      <item> foreach </item>
      <item> value </item>
      <item> eval </item>
      <item> origin </item>
      <item> flavor </item>
      <item> shell </item>
      <item> error </item>
      <item> warning </item>
      <item> info </item>
    </list>

    <contexts>
      <context name="normal" attribute="Normal" lineEndContext="#stay">
        <DetectSpaces/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
        <keyword attribute="Keyword"  context="#stay" String="keywords"/>
        <RegExpr attribute="Variable" context="assign" String="[^\s:+?]*\s*(?=:=|=|\+=|\?=)"/>
        <RegExpr attribute="Section"  context="prereq" String="^\.[^.][^:]*:"/>
        <RegExpr attribute="Target"   context="prereq" String="^[^:]*:"/>
        <DetectIdentifier/>
        <DetectChar attribute="String" context="string&quot;" char="&quot;"/>
        <DetectChar attribute="String" context="string'" char="'"/>
        <DetectChar attribute="Operator" context="dollar" char="$"/>
        <Detect2Chars attribute="Special" context="#stay" char="\" char1="#"/>
        <Detect2Chars attribute="Special" context="#stay" char="\" char1="\"/>
        <AnyChar attribute="Operator" context="silent" String="@-" firstNonSpace="1"/>
      </context>

      <context name="prereq" attribute="Prereq" lineEndContext="rule">
        <DetectSpaces/>
        <DetectIdentifier/>
        <LineContinue attribute="Operator" context="#stay"/>
        <DetectChar attribute="Operator" context="dollar" char="$"/>
        <Detect2Chars attribute="Special" context="#stay" char="\" char1="#"/>
        <Detect2Chars attribute="Special" context="#stay" char="\" char1="\"/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
      </context>

      <context name="rule" attribute="Normal" lineEndContext="#stay">
        <LineContinue attribute="Operator" context="#stay"/>
        <!-- pop if there is a leading non-tab,
        and in particular, mark leading spaces as errors -->
        <RegExpr attribute="Error" context="#pop#pop#pop" String="^ +" firstNonSpace="1"/>
        <RegExpr context="#pop#pop#pop" String="^[^\t]" lookAhead="1" firstNonSpace="1"/>
        <DetectSpaces/>
        <DetectIdentifier/>
        <DetectChar attribute="String" context="string&quot;" char="&quot;"/>
        <DetectChar attribute="String" context="string'" char="'"/>
        <DetectChar attribute="Operator" context="dollar" char="$"/>
        <Detect2Chars attribute="Special" context="#stay" char="\" char1="#"/>
        <Detect2Chars attribute="Special" context="#stay" char="\" char1="\"/>
        <AnyChar attribute="Operator" context="silent" String="@-" firstNonSpace="1"/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
      </context>

      <context name="silent" attribute="Silent" lineEndContext="#pop">
        <LineContinue attribute="Operator" context="#stay"/>
        <DetectSpaces/>
        <DetectIdentifier/>
        <DetectChar attribute="String" context="string&quot;" char="&quot;"/>
        <DetectChar attribute="String" context="string'" char="'"/>
        <DetectChar attribute="Operator" context="dollar" char="$"/>
        <Detect2Chars attribute="Special" context="#stay" char="\" char1="#"/>
        <Detect2Chars attribute="Special" context="#stay" char="\" char1="\"/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
      </context>

      <context name="string&quot;" attribute="String" lineEndContext="#pop">
        <LineContinue attribute="Operator" context="#stay"/>
        <DetectChar attribute="String" context="#pop" char="&quot;"/>
        <DetectChar attribute="Operator" context="dollar" char="$"/>
      </context>

      <context name="string'" attribute="String" lineEndContext="#pop">
        <LineContinue attribute="String" context="#stay"/>
        <DetectChar attribute="String" context="#pop" char="'"/>
        <DetectChar attribute="Operator" context="dollar" char="$"/>
      </context>

      <context name="assign" attribute="Operator" lineEndContext="#pop">
        <DetectChar attribute="Operator" context="value" char="="/>
      </context>

      <context name="value" attribute="String" lineEndContext="#pop#pop">
        <LineContinue attribute="Operator"/>
        <DetectChar attribute="Operator" context="dollar" char="$"/>
        <RegExpr attribute="Special" context="#pop#pop" String="@[-_\d\w]*@"/>
        <DetectChar attribute="Operator" char=";" context="#pop#pop"/>
      </context>

      <context name="dollar" attribute="Operator" lineEndContext="#pop">
        <DetectChar attribute="Operator" context="call(" char="("/>
        <DetectChar attribute="Operator" context="call{" char="{"/>
        <RegExpr attribute="Operator" context="#pop" String="."/>
      </context>

      <context name="call(" attribute="Variable" lineEndContext="#stay" fallthroughContext="callVar(" fallthrough="1">
        <keyword attribute="Keyword" context="callFunc(" String="functions"/>
      </context>

      <context name="call{" attribute="Variable" lineEndContext="#stay" fallthroughContext="callVar{" fallthrough="1">
        <keyword attribute="Keyword" context="callFunc{" String="functions"/>
      </context>

      <context name="callVar(" attribute="Variable" lineEndContext="#stay">
        <DetectChar attribute="Operator" char=")" context="#pop#pop#pop"/>
        <DetectChar attribute="Operator" context="dollar" char="$"/>
        <DetectSpaces attribute="Error" context="#stay"/>
        <AnyChar attribute="Error" context="#stay" String="=#:"/>
      </context>

      <context name="callVar{" attribute="Variable" lineEndContext="#stay">
        <DetectChar attribute="Operator" char="}" context="#pop#pop#pop"/>
        <DetectChar attribute="Operator" context="dollar" char="$"/>
        <DetectSpaces attribute="Error" context="#stay"/>
        <AnyChar attribute="Error" context="#stay" String="=#:"/>
      </context>

      <context name="callFunc(" attribute="FuncParam" lineEndContext="#stay">
        <DetectChar attribute="Operator" char=")" context="#pop#pop#pop"/>
        <DetectChar attribute="Operator" context="dollar" char="$"/>
        <DetectChar attribute="Keyword" context="#stay" char=","/>
        <DetectChar attribute="String" context="string'" char="'"/>
      </context>

      <context name="callFunc{" attribute="FuncParam" lineEndContext="#stay">
        <DetectChar attribute="Operator" char="}" context="#pop#pop#pop"/>
        <DetectChar attribute="Operator" context="dollar" char="$"/>
        <DetectChar attribute="Keyword" context="#stay" char=","/>
        <DetectChar attribute="String" context="string'" char="'"/>
      </context>

      <context attribute="Comment" lineEndContext="#pop" name="Comment">
        <LineContinue attribute="Comment" context="#stay" />
        <IncludeRules context="##Alerts" />
        <IncludeRules context="##Modelines" />
      </context>

    </contexts>
    <itemDatas>
      <itemData name="Normal"    defStyleNum="dsNormal" spellChecking="0"/>
      <itemData name="Keyword"   defStyleNum="dsKeyword" spellChecking="0"/>
      <itemData name="Comment"   defStyleNum="dsComment"/>
      <itemData name="String"    defStyleNum="dsString" spellChecking="0"/>
      <itemData name="Variable"  defStyleNum="dsDataType" spellChecking="0"/>
      <itemData name="Target"    defStyleNum="dsDecVal" spellChecking="0"/>
      <itemData name="Section"   defStyleNum="dsOthers" spellChecking="0"/>
      <itemData name="Prereq"    defStyleNum="dsDataType" spellChecking="0"/>
      <itemData name="FuncParam" defStyleNum="dsString" spellChecking="0"/>
      <itemData name="Operator"  defStyleNum="dsChar" spellChecking="0"/>
      <itemData name="Silent"    defStyleNum="dsFunction" spellChecking="0"/>
      <itemData name="Special"   defStyleNum="dsFloat" spellChecking="0"/>
      <itemData name="Error"     defStyleNum="dsError" spellChecking="0"/>
    </itemDatas>
  </highlighting>
  <general>
    <comments>
      <comment name = "singleLine" start = "#"/>
    </comments>
    <!-- '-' is not a deliminator in function filter-out -->
    <keywords casesensitive="1" weakDeliminator = "-"/>
  </general>
</language>