Search code examples
bashmakefile

How to run Makefile from any directory?


I have created a makefile which is fully automatic. This means, I do not need to change makefile to run different programs.

Now what I want to do is put that makefile somewhere and call that makefile from directory where my program is. But condition is that makefile should run as if I have putted that makefile in directory where my program is created and NOT at place where makefile actually is.


Solution

  • You can run a Makefile from another location as if it was in the current directory with:

    make -f /path/to/your/makefile
    

    You can make an alias or function for it if you want.