If you are in a buffer for a remote file, then M-x compile should run make on the remote machine.
Docs are here: https://www.gnu.org/software/tramp/#index-compile
Docs are here: https://www.gnu.org/software/tramp/#index-compile
- If you're walking the filesystem, make sure you start from the "default-directory" variable.
- If you call other programs, make sure you use "process-file" (for synchronous processes) or "start-file-process" (for async). Using "call-process" or "start-process" unfortunately won't do the right thing, but the two functions I mentioned are mostly drop-in replacements.
Unfortunately, my current job doesn't use Linux as much, and so it has been too long since I've spent time improving my .emacs file, as it is only home projects at this point.