Reputation: 9157
Let's say I'm in a subdirectory sub
:
admin@pc ~/folder/subfolder $
I would like to run make
on a Makefile
from the folder
directory.
How can I achieve it when I'm in the subfolder
directory?
I had some ideas like:
admin@pc ~/folder/subfolder $ ../make
admin@pc ~/folder/subfolder $ /../make
but none of these works.
Upvotes: 1
Views: 340
Reputation: 81032
An alternative, built-in answer, that avoids the extra sub-shell from khachik's answer is the answer given by helpYou in their comment:
To run make from a different directory automatically you want the -C
option to make.
‘-C dir’
‘--directory=dir’
Change to directory dir before reading the makefiles. If multiple ‘-C’ options are specified, each is interpreted relative to the previous one: ‘-C / -C etc’ is equivalent to ‘-C /etc’. This is typically used with recursive invocations of make (see Recursive Use of make).
The -f
argument simply specifies an alternate makefile to use but runs in the current directory.
The sub-shell solution is a good one and would be the correct one if make did not have a built-in solution for this.
Upvotes: 2
Reputation: 28703
And if for some reason you really need to run make
in ..
, you can run
(cd .. && make)
Upvotes: 3