Here is a start. Add to your .emacs file:
(global-set-key [f4] 'compile)
You can also enter the "f4" and "compile" interactively. Starting out with
Compile is a generic for running any command in a separate buffer. The default command runs "make", which may or not be what you want. You have an opportunity to change that and compile will remember what you last typed and keep a history of invocations you've given.
If what you always wanted to run "foo" with no questions asked, you could define a command and bind that instead of "compile" above to f4. The function definition would look like this:
(defun compile-run-remake ()
"Run `remake -x` in a compilation buffer."
(compile "remake -x"))
Going further you instead of hard-coding a command like "remake -x" you can pick that out from a constant or a customizable variable.