vote up 4 vote down star

This is something that has always bugged me. It seems like I always see build instructions for building and then installing something saying to do this:

make
sudo make install

Is there really any reason to call make? Doesn't sudo make install implicitly call make?

flag

65% accept rate

2 Answers

vote up 3 vote down check

Technically, there is no reason why not - this really is based on how the makefile was set up. It is all designed around dependencies. If the 'install' target is made dependent on the rest of the product, then it would implicitly build the product as you are thinking.

The reason they are separated out is that you are usually going to do a 'make' as the unprivileged developer, and do the 'make install' with elevated privs. Usually you don't want to mix those actions.

link|flag
vote up 1 vote down

The 2 commands do different things.

make - this reads the makefile for instructions on how to compile the sources. It builds the program and the end result is your binaries.

make install - this reads the makefile for the target install directory, and places the files created by make into their appropriate directories.

link|flag
Isn't there at least one platform where make gets called by make install though? – Jason Baker Nov 20 at 2:07
You can call make with make install, make install looks for a label in the makefile called install and follows the directions below it. If you put make directives below it, you could do it all in one go. It's traditionally done the other way though, probably to prevent confusion so all software is installed the same. I don't know of any software I've built that allowed me to skip the make process. You'll also notice make install is prefixed with sudo because the make process can be done anywhere, make install moves files to directories that are usually write restricted from regular users. – John T Nov 20 at 2:30

Your Answer

Get an OpenID
or
never shown

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