Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In order to run make file, I am supposed to go to the make file's directory and from there only I can run the make file. How can I do the same even if i am in any directory?

share|improve this question
Which make? Borland's make? GNU make? Microsoft's nmake? One of the umpteen shareware implementations of make that have floated around over the years? And on what platform? The answer is different depending from the specifics. RedGrittyBrick is presuming that you have a POSIX-conformant shell and filesystem, for example. – JdeBP Dec 23 '11 at 13:43
up vote 3 down vote accepted
(cd /other/dir && make)

will not change your shell's current directory, but will run make with the indicated working directory.

The && will ensure that make doesn't run if there's an error in the cd part of the command (e.g., the directory doesn't exist, or you don't have access to it).

share|improve this answer
Looks like there's a -C option to make for most Unixes these days. Details and some more complete answers here: – Noyo Oct 24 '13 at 13:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .