The Trivial Build System
The simplest build system is the one not requiring any software. There are several approaches.
Write a note in your source on how to build. Or don't, if it is obvious.
// compile: g++ -oprogram -lm program.cpp
// <URL:vimscript:set mp=g++\ -oprogram\ -lm\ program.cpp>
A Vim user can just place the cursor on the URL and press
<Leader>gu and then type
:make to build.
makeprg cannot be specified using modelines, but you could use Vim Directory Environment Configuration.
Self-Contained Build Script
The source file could serve as a build script itself. Here is an example using bash as interpreter:
#/* Compile: sh program.cpp g++ program.cpp -oprogram exit */ ... // C++ program follows here
Thus, the source file is bilingual :).
This could also be combined with the Vim UTL URL:
#/* Compile: sh program.cpp <URL:vimscript:set mp=.\ %> g++ program.cpp -oprogram exit */ ... // C++ program follows here
or specified using Vim Directory Environment Configuration.