Pritalgo
Pritalgo

Reputation: 301

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.

Upvotes: 1

Views: 1285

Answers (2)

Swamp Fox
Swamp Fox

Reputation: 11

You can also run it this way and supply any arguments:

make -C path/to/your/directory argument

Upvotes: 0

that other guy
that other guy

Reputation: 123400

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.

Upvotes: 2

Related Questions