I have a makefile in the project root directory. If I am editing a file in a subdirectory, how do I invoke make from EMACS? M-x compile make will not work as it looks for the makefile in the current directory. But I have the makefile in the project root directory.
Any thoughts?
Edit
As suggested, make -f fullpath_to_makefile did the trick. But I have some includes in the makefile like include “tests/module.mk” which failed. It is looking for “tests” directory in the subdirectory. This can be solved by specifying fully qualified path in the makefile. But I don’t think that is a good solution. Any better approaches?
The
M-x compilefunction looks up thecompile-command-variablewhich you can override on the promt — so just replace it with something likeand let that run.
I also often use a file header (in line 1) such as
which you can generalize at will with different options. After reloading the file,
M-x compilewill execute your custom compile command which I find quite useful.