Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying path to "makefile" using "make" command

Tags:

makefile

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.

like image 293
rablentain Avatar asked Jan 20 '15 20:01

rablentain


People also ask

How do I make a specific makefile?

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.

What is make command and makefile?

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.

How do you use make command?

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.

Where is the makefile located?

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 .


1 Answers

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)?

like image 108
Etan Reisner Avatar answered Sep 20 '22 20:09

Etan Reisner