I would like to run a makefile from another place in the file system. How do I pass the location of the makefile to make?
if I stand in "/" and I would like to run a makefile that resists in "/dir/dir2/dir3/makefile", how do I add that to the make command?
I tried:
make --file=dir/dir2/dir3/makefile
but it did not worked.
If you want to use a nonstandard name for your makefile, you can specify the makefile name with the ' -f ' or ' --file ' option. The arguments ' -f name ' or ' --file= name ' tell make to read the file name as the makefile. If you use more than one ' -f ' or ' --file ' option, you can specify several makefiles.
The makefile is read by the make command, which determines the target file or files that are to be made and then compares the dates and times of the source files to decide which rules need to be invoked to construct the target. Often, other intermediate targets have to be created before the final target can be made.
To prepare to use make, you must write a file called the makefile that describes the relationships among files in your program, and the states the commands for updating each file. In a program, typically the executable file is updated from object files, which are in turn made by compiling source files.
The makefile is a text file that contains the recipe for building your program. It usually resides in the same directory as the sources, and it is usually called Makefile .
All relative paths in the makefile will be relative to your current directory and not the directory of the makefile.
Assuming that you understand that and what you want to do is still going to work then you want the -f
flag to specify the makefile to use. (Which is in the man page, the manual and the --help
output.)
If, instead, what you mean is you want to cd
to somewhere else and run make then perhaps you are looking for (cd /some/path && make)
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With