" Vim syntax file
" Language:	Makefile
" Maintainer:	Claudio Fleiner <fleiner@acm.org>
" Last change:	1997 May 27

" Remove any old syntax stuff hanging around
syntax clear

" This file makes use of the highlighting "Function", which is not defined
" in the normal syntax.vim file yet.

" Note: there seem to be some bugs in the highlighting:
" - strings enclosed in '  ' should be colored as Function which works fine.
"   However, when adding "contains makeNextLine", only the first and last
"   line of such a string is colored correctly.
" - Adding a \$ in front of (subst does not work, i.e.:
"      syntax match makeStatement contained "\$(subst"s+2
"   no longer matches
"		$(subst somestring)


" some directives
syntax match makePreCondit	"^[	 ]*\(ifeq\>\|else\>\|endif\>\|define\>\|ifneq\>\|ifdef\>\|ifndef\)"
syntax match makeInclude	"^[	 ]*include"
syntax match makeStatement	"^[	 ]*vpath"
syntax match makeOverride	"^[	 ]*override"
highlight link makeOverride makeStatement


" make targets
syntax match makeTarget		"^[A-Za-z0-9_][A-Za-z0-9_./	 ]*:[^=]"e-2
syntax match makeTarget		"^[A-Za-z0-9_][A-Za-z0-9_./	 ]*:$"e-1
syntax match makeSpecTarget	"^\.SUFFIXES"
syntax match makeSpecTarget	"^\.PHONY"
syntax match makeSpecTarget	"^\.DEFAULT"
syntax match makeSpecTarget	"^\.PRECIOUS"
syntax match makeSpecTarget	"^\.IGNORE"
syntax match makeSpecTarget	"^\.SILENT"
syntax match makeSpecTarget	"^\.EXPORT_ALL_VARIABLES"
syntax match makeImplicit	"^\.[A-Za-z0-9_]*\.[A-Za-z0-9_]*[	 ]*:[^=]"e-2
syntax match makeImplicit	"^\.[A-Za-z0-9_]*\.[A-Za-z0-9_]*[	 ]*:$"e-1

" Statements / Functions (GNU make)
syntax match makeStatement contained "(subst"s+1
syntax match makeStatement contained "(addprefix"s+1
syntax match makeStatement contained "(addsuffix"s+1
syntax match makeStatement contained "(basename"s+1
syntax match makeStatement contained "(dir"s+1
syntax match makeStatement contained "(filter"s+1
syntax match makeStatement contained "(filter-out"s+1
syntax match makeStatement contained "(findstring"s+1
syntax match makeStatement contained "(firstword"s+1
syntax match makeStatement contained "(foreach"s+1
syntax match makeStatement contained "(join"s+1
syntax match makeStatement contained "(notdir"s+1
syntax match makeStatement contained "(origin"s+1
syntax match makeStatement contained "(patsubst"s+1
syntax match makeStatement contained "(shell"s+1
syntax match makeStatement contained "(sort"s+1
syntax match makeStatement contained "(strip"s+1
syntax match makeStatement contained "(suffix"s+1
syntax match makeStatement contained "(wildcard"s+1
syntax match makeStatement contained "(word"s+1
syntax match makeStatement contained "(words"s+1

" some special characters
syntax match makeSpecial	"^[	 ]*[@-][@-]*"
syntax match makeNextLine	"\\$"

" identifiers
syntax match makeIdent		"\$([^)]*)" contains makeStatement
syntax match makeIdent		"\$\$[A-Za-z0-9_]*"
syntax match makeIdent		"\$[^({]" 
syntax match makeIdent		"\${[^}]*}"
syntax match makeIdent		"[A-Za-z0-9_]*[	\t]*[:+]="e-2
syntax match makeIdent		"[A-Za-z0-9_]*[	\t]*="e-1
syntax match makeIdent		"%"

" Comment
syntax match  makeComment	"#.*$" 

syntax region  makeDString      start=+^"+  skip=+\\"+  end=+"+  contains makeIdent 
syntax region  makeDString      start=+[^\\]"+S+1  skip=+\\"+  end=+"+  contains makeIdent 
syntax region  makeSString      start=+'+  skip=+\\'+  end=+'+  contains makeIdent 
syntax region  makeBString      start=+`+  skip=+\\`+  end=+`+  contains makeIdent  makeSString makeDString makeNextLine

if !exists("did_makefile_syntax_inits")
  let did_makefile_syntax_inits = 1
  highlight link makeNextLine	makeSpecial
  highlight link makeSpecTarget	Statement
  highlight link makeImplicit	Function
  highlight link makeTarget	Function
  highlight link makeInclude	Include
  highlight link makePreCondit	PreCondit
  highlight link makeStatement	Statement
  highlight link makeIdent	Identifier
  highlight link makeSpecial	Special
  highlight link makeComment	Comment
  highlight link makeDString	String
  highlight link makeSString	String
  highlight link makeBString	Function
endif

