By default, makeprg is set to just make. However, I’ve got a lot of projects where different build configurations and targets reside in the same directory.
This of course necessitates that I specify a target when invoking make.
For example, I’ve got a project that’s set up to build a source file <foo>.cpp by invoking make foo, and the project contains a number of such source files.
How can I achieve that when I’m editing said <foo>.cpp in Vim, makeprg is set to make <foo>? I thought of modelines in each file, but setting makeprg via the modeline is forbidden (due to security concerns?).
Notice that this setting is only appropriate for some projects so I don’t want to modify the general value of make – otherwise I’d just
set makeprg=make\ expand("%:t:r")
(or something like that) in my .gvimrc.