4

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?

2 Answers 2

3

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.

1

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.

2
  • Isn't there at least one platform where make gets called by make install though? Commented Nov 20, 2009 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.
    – user1931
    Commented Nov 20, 2009 at 2:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .