Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 512
aggressionexp Avatar asked May 19 '13 18:05

aggressionexp


People also ask

Why run make before make install?

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.

Do I need to run make install?

The Makefile will normally be correct for your system, but you may occasionally be required to "tweak" it or correct errors manually. Installing the freshly built binaries into the appropriate system directories is usually a matter of running make install as root.

What does configure make and make install do?

What does all of this do. The configure script is responsible for getting ready to build the software on your specific system. It makes sure all of the dependencies for the rest of the build and install process are available, and finds out whatever it needs to know to use those dependencies.

How make install works?

When you do "make install", the make program takes the binaries from the previous step and copies them into some appropriate locations so that they can be accessed. Unlike on Windows, installation just requires copying some libraries and executables and there is no registry requirement as such.


2 Answers

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.

like image 149
Matt Patenaude Avatar answered Oct 06 '22 03:10

Matt Patenaude


make without parameters takes the ./Makefile (or ./makefile) and builds the first target. By convention, this may be the all target, but not necessarily. make install builds the special target, install. By convention, this takes the results of make all, and installs them on the current computer.

Not everybody needs make install. For example, if you build some a web app to be deployed on a different server, or if you use a cross-compiler (e.g. you build an Android application on a Linux machine), it makes no sense to run make install.

In most cases, the single line ./configure && make all install will be equivalent to the three-step process you describe, but this depends on the product, on your specific needs, and again, this is only by a convention.

like image 26
Alex Cohn Avatar answered Oct 06 '22 05:10

Alex Cohn