flymake: Example---Configuring a tool called via make
4.2.2 Example—Configuring a tool called via make
------------------------------------------------
In this example we will add support for C files syntax checked by ‘gcc’
called via ‘make’.
We’re not required to write any new functions, as Flymake already has
functions for ‘make’. We just add a new entry to the
‘flymake-allowed-file-name-masks’:
(setq flymake-allowed-file-name-masks
(cons '(".+\\.c$"
flymake-simple-make-init
flymake-simple-cleanup
flymake-get-real-file-name)
flymake-allowed-file-name-masks))
‘flymake-simple-make-init’ builds the following ‘make’ command line:
(list "make"
(list "-s" "-C"
base-dir
(concat "CHK_SOURCES=" source)
"SYNTAX_CHECK_MODE=1"
"check-syntax"))
‘base-dir’ is a directory containing ‘Makefile’, see Locating
the buildfile.
Thus, ‘Makefile’ must contain the ‘check-syntax’ target. In our case
this target might look like this:
check-syntax:
gcc -o /dev/null -S ${CHK_SOURCES}
The format of error messages reported by ‘gcc’ is already supported by
Flymake, so we don’t have to add a new entry to
‘flymake-err-line-patterns’. Note that if you are using Automake, you
may want to replace ‘gcc’ with the standard Automake variable ‘COMPILE’:
check-syntax:
$(COMPILE) -o /dev/null -S ${CHK_SOURCES}