So after running configure
file on source codes for different applications one enters make
and make install
to install the application. My question is what is the difference between make
and make install
?
2 Answers
make
looks for the first target in the Makefile. (GNU Make allows configuring this.)
make install
looks for a target named exactly "install
".
-
-
And then during "make" command process, no files then being copied anywhere, right?– NajiOct 24, 2013 at 15:38
-
1@Naji Because some software developers just prefer it that way - one target to compile, and one to move the files to the destination on the file system ("install"). There's nothing saying you have to run both, or that everything that uses
make
must have aninstall
target. There's absolutely no rules except what's defined in each specificMakefile
, though there are general guidelines many developers follow. Normally guidelines are specific to smallish groups - there's an infinite number of ways to do things, many equally valid.– BobOct 24, 2013 at 15:38 -
@Bob The guideline that "building and installing should be separate" is followed by a huge majority, though. Oct 24, 2013 at 15:41
-
Make install is one of various possible targets in a Makefile. As a simple example, the other very common one is clean: make clean, in general, cleans temporary files which are necessary/useful by-products of the compilation process, but which are no longer needed once the final executable has been produced.
Make install contains the instructions to insert the compiled product into the system, for instance by running the necessary depmod command which takes care of a module installation.
then why ones have to run both?!
Because the first one can be executed as a normal user, the second often requires system privileges.
If your next question is: then why not run both as sudo, then the answer is that not all installations are going to be used system-wide. For instance, if you do not have root privileges on a system you have access to, you may wish to compile and install a given package for your own exclusive use. In this case, you want to be able to compile it and pass it to the linker, but you cannot install it for use by all system users. In this case, the reason for the difference is obvious.
In other words, each stage of the installation process is organized so that it can be executed with the lowest possible privileges, which allows both system-wide and local installations, whenever this makes sense.