Search code examples
makefilecmakeopen-sourcegnu-makeconfigure

why "make" before "make install"


I know the process of installing from source are.

  1. ./configure
  2. make
  3. make install

But why "make" before /etc/cups/cupsd.conf, why not just do "make install"?

My understanding so far is "make" only compile the source into executable file, and "make install" actually place them into executable PATH folder, am I right?

If we want to install executable on the machine, can we just do

  1. ./configure
  2. make install

Instead of 3 steps shown above.


Solution

  • When you run make, you're instructing it to essentially follow a set of build steps for a particular target. When make is called with no parameters, it runs the first target, which usually simply compiles the project. make install maps to the install target, which usually does nothing more than copy binaries into their destinations.

    Frequently, the install target depends upon the compilation target, so you can get the same results by just running make install. However, I can see at least one good reason to do them in separate steps: privilege separation.

    Ordinarily, when you install your software, it goes into locations for which ordinary users do not have write access (like /usr/bin and /usr/local/bin). Often, then, you end up actually having to run make and then sudo make install, as the install step requires a privilege escalation. This is a "Good Thing™", because it allows your software to be compiled as a normal user (which actually makes a difference for some projects), limiting the scope of potential damage for a badly-behaving build procedure, and only obtains root privileges for the install step.