Specifying a makefile path using the make command

I would like to run makefile from another place in the file system. How to transfer the location of the makefile?

if I get into "/" and I would like to run a make file that resists "/ dir / dir2 / dir3 / makefile", how do I add this to the make command?

I tried:

make --file=dir/dir2/dir3/makefile 

but it didn’t work.

+8
source share
2 answers

All relative paths to the makefile will refer to your current directory, and not to the makefile directory.

Assuming that you understand what and what you want to do, it will work anyway, then you want the -f flag to indicate the makefile to use. (What is on the manual page, the manual and the output of --help .)

If instead you want to say that you want cd to another place and run make, maybe you are looking for (cd /some/path && make) ?

+9
source

You can use the -C flag to specify the path to your makefile. This way you can execute it from another directory. The -f flag has a different purpose. With this flag, you can execute a makefile with a name other than makefile .

+4
source

Source: https://habr.com/ru/post/981310/


All Articles