compile-command

compile-command is a variable defined in `compile.el'.
Its value is
"make -k "

  • This variable may be risky if used as a file-local variable.
  • This variable is safe as a file local variable if its value
    satisfies the predicate `(lambda (a) (and (stringp a) (or (not (boundp (quote compilation-read-command))) compilation-read-command)))'.

Documentation:
Last shell command used to do a compilation; default for next compilation.

Sometimes it is useful for files to supply local values for this variable.
You might also use mode hooks to specify it in certain modes, like this:

(add-hook 'c-mode-hook
(lambda ()
(unless (or (file-exists-p "makefile")
(file-exists-p "Makefile"))
(set (make-local-variable 'compile-command)
(concat "make -k "
(if buffer-file-name
(shell-quote-argument
(file-name-sans-extension buffer-file-name))))))))

You can customize this variable.