Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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
    
Thanks RedGrittyBrick :). –  Dinesh Dec 22 '11 at 9:52
2  
Looks like there's a -C option to make for most Unixes these days. Details and some more complete answers here: stackoverflow.com/q/453447/357774 –  Noyo Oct 24 '13 at 13:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.