patch 9.1.1307: make syntax does not reliably detect different flavors
Problem: GNU extensions, such as `ifeq` and `wildcard` function, are
highlighted in BSDmakefile
Solution: detect BSD, GNU, or Microsoft implementation according to
filename, user-defined global variables, or file contents
closes: #17089
Co-authored-by: Roland Hieber <rohieb@users.noreply.github.com>
Signed-off-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt
index 20bf395..761d667 100644
--- a/runtime/doc/filetype.txt
+++ b/runtime/doc/filetype.txt
@@ -1,4 +1,4 @@
-*filetype.txt* For Vim version 9.1. Last change: 2025 Mar 15
+*filetype.txt* For Vim version 9.1. Last change: 2025 Apr 15
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -158,6 +158,8 @@
*.inc g:filetype_inc
*.lsl g:filetype_lsl
*.m g:filetype_m |ft-mathematica-syntax|
+ *[mM]makefile,*.mk,*.mak,[mM]akefile*
+ g:make_flavor |ft-make-syntax|
*.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md
g:filetype_md |ft-pandoc-syntax|
*.mod g:filetype_mod
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 3c3bde2..ae89bd9 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -1,4 +1,4 @@
-*syntax.txt* For Vim version 9.1. Last change: 2025 Apr 13
+*syntax.txt* For Vim version 9.1. Last change: 2025 Apr 15
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -2393,11 +2393,16 @@
:let make_no_comments = 1
-Microsoft Makefile handles variable expansion and comments differently
-(backslashes are not used for escape). If you see any wrong highlights
-because of this, you can try this: >
+There are various Make implementations, which add extensions other than the
+POSIX specification and thus are mutually incompatible. If the filename is
+BSDmakefile or GNUmakefile, the corresponding implementation is automatically
+determined; otherwise vim tries to detect it by the file contents. If you see
+any wrong highlights because of this, you can enforce a flavor by setting one
+of the following: >
- :let make_microsoft = 1
+ :let g:make_flavor = 'bsd' " or
+ :let g:make_flavor = 'gnu' " or
+ :let g:make_flavor = 'microsoft'
MAPLE *maple.vim* *ft-maple-syntax*