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.

Answer from Matt Patenaude on Stack Overflow
๐ŸŒ
Reddit
reddit.com โ€บ r/linuxquestions โ€บ whats the differnce between make and make install when compiling software
r/linuxquestions on Reddit: whats the differnce between make and make install when compiling software
October 21, 2018 - Since install depends on the files being built, running make install without first running make will essentially run the default state first as part of the installation (though generally in a different order since make works depth-first).
Discussions

software installation - Difference between "make install" and "sudo make install" - Unix & Linux Stack Exchange
Sometimes I encounter problems with using make install which gives me a permission denied error when writing to some folders. So instinctively I use sudo make install. Will this introduce additional More on unix.stackexchange.com
๐ŸŒ unix.stackexchange.com
September 18, 2011
software installation - What ./configure make and make install does - Unix & Linux Stack Exchange
I would like to know the exact background tasks that happen when you install an application from source. What happens when you run ./configure, make, and make install? I tried googling a bit about ... More on unix.stackexchange.com
๐ŸŒ unix.stackexchange.com
February 27, 2015
unix - Why always ./configure; make; make install; as 3 separate steps? - Stack Overflow
Every time you compile something from source, you go through the same 3 steps: $ ./configure $ make $ make install I understand, that it makes sense to divide the installing process into different... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Difference between configure/make/make install.
Hi, While installation of apache on linux, we perform the below tasks. 1) Untar 2) configure 3) make 4) make install. I wanted to understand the difference and working of configure/make/make install. Can any one help me understanding this? Thanks in advance. More on unix.com
๐ŸŒ unix.com
1
0
April 8, 2010
Top answer
1 of 5
78

Make is a general purpose workflow program, usually used for compilation. But it can be used for anything.

When you do something like "make all", the make program executes a rule named "all" from a file in current directory named "Makefile". This rule usually calls the compiler to compile some source code into binaries.

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. In short, "make install" just copies compiled files into appropriate locations.

2 of 5
54

make install does whatever the Makefile author wants it to do. Typically, by this point, it is too late to change the install directory, as it is often known earlier, during the build, so help files and configuration files can be referenced with the correct pathnames.

Many projects use the GNU Autotools to try to improve their portability among hardware and operating system differences. (Different Unix variants use slightly different headers for declarations of functions that are slightly off the usual path -- except most programs need one or another of the ones declared in different locations.)

When a project does use the Autotools, the normal mantra to install it is:

./configure
make
make install

The ./configure typically allows you to use a command line option like --prefix /opt/apache or something similar to specify a different pathname. /usr/local/ is a common default prefix. It is far easier for locally built software to live in one place and distribution-provided software to live in the "main directories": /usr/ /bin/, and so on. (Packagers are very careful to never touch files in /usr/local/ -- they know it is exclusively for system administrators.)

Anyway, the ./configure --prefix /path/to/new/prefix will set a variable in the Makefile that is available when compiling the program, modifying the manual pages so they point to the correct locations for files, modifying configuration files, etc. So make will build the software specifically for the install location you want and make install will install it into that location.

Most programs can run even without the final make install step -- just ./program_name will often start them up. This is definitely a per-project thing -- some, like postfix, qmail, etc., are made up of many different moving pieces and rely on them all working together. Others, like ls or su might be self-contained enough to execute fine from the directory they were built in. (This is not often useful -- but sometimes very useful.)

However, not all projects use the Autotools -- they are huge, complicated, and miserable to maintain. Hand-written Makefiles are much simpler to write, and I personally think just distributing a simple Makefile with configuration variables available is a lot easier on developers and users both. (Though the ./configure ; make ; make install mantra is really easy on users when it works.)

๐ŸŒ
Thoughtbot
thoughtbot.com โ€บ blog โ€บ the-magic-behind-configure-make-make-install
The magic behind configure, make, and make install
August 5, 2024 - Since the install step is also defined in the Makefile, where the software is installed can change based on options passed to the configure script, or things the configure script discovered about your system.
Top answer
1 of 3
21

Avoid making local installs into system directories. The system directories eg /usr, are reserved for the package management system to use. By definition, if you are doing make install that means you are making a local install, and if you need to do sudo make install that means you don't have permission to wherever you are writing.

So, if you are getting permission errors with make install, check and see whether you are trying to install into system directories, and install into /usr/local or similar instead. /usr/local is reserved for local installations. You may need to give yourself permission to write to /usr/local, but this is usually easily done. On Debian this can be done by adding yourself to the staff group. Better still, find or create a binary package, and install that instead. That way you can easily keep track of installed packages and obtain the other benefits of package management.

Note that the package management system conversely does not install into /usr/local, per the FHS. See Section 9.1 of the Debian Policy Manual- File system hierarchy for an overview.

2 of 3
5

As has been answered above, sudo make install lets you install the files in directories which are otherwise read-only to you as a user.

The problem I can foresee is that at a later date you may want to uninstall or upgrade the program. If you still have the source code directory tree then a make uninstall will uninstall the program for you but if, as many other typical users, you had deleted the source code directory tree then you are out of luck. And since you have not installed the program using a package management system, you may also be unable to uninstall the program that way.

The best way to install such programs may be to install them in your home directory. Pass the option --prefix=/home/<user>/<some>/<directory> to ./configure. This will allow you to use make install instead of sudo make install since /home/<user>/<some>/<directory> is writable by you. Also uninstallation is a snap -- rm -rf /home/<user>/<some>/<directory>

Top answer
1 of 4
130

Because each step does different things

Prepare(setup) environment for building

./configure

This script has lots of options that you should change. Like --prefix or --with-dir=/foo. That means every system has a different configuration. Also ./configure checks for missing libraries that should be installed. Anything wrong here causes not to build your application. That's why distros have packages that are installed on different places, because every distro thinks it's better to install certain libraries and files to certain directories. It is said to run ./configure, but in fact you should change it always.

For example have a look at the Arch Linux packages site. Here you'll see that any package uses a different configure parameter (assume they are using autotools for the build system).

Building the system

make

This is actually make all by default. And every make has different actions to do. Some do building, some do tests after building, some do checkout from external SCM repositories. Usually you don't have to give any parameters, but again some packages execute them differently.

Install to the system

make install

This installs the package in the place specified with configure. If you want you can specify ./configure to point to your home directory. However, lots of configure options are pointing to /usr or /usr/local. That means then you have to use actually sudo make install because only root can copy files to /usr and /usr/local.


Now you see that each step is a pre-requirement for next step. Each step is a preparation to make things work in a problemless flow. Distros use this metaphor to build packages (like RPM, deb, etc.).

Here you'll see that each step is actually a different state. That's why package managers have different wrappers. Below is an example of a wrapper that lets you build the whole package in one step. But remember that each application has a different wrapper (actually these wrappers have a name like spec, PKGBUILD, etc.):

def setup:
... #use ./configure if autotools is used

def build:
... #use make if autotools is used

def install:
... #use make all if autotools is used

Here one can use autotools, that means ./configure, make and make install. But another one can use SCons, Python related setup or something different.

As you see splitting each state makes things much easier for maintaining and deployment, especially for package maintainers and distros.

2 of 4
33

First, it should be ./configure && make && make install since each depends on the success of the former. Part of the reason is evolution and part of the reason is convenience for the development workflow.

Originally, most Makefiles would only contain the commands to compile a program and installation was left to the user. An extra rule allows make install to place the compiled output in a place that might be correct; there are still plenty of good reasons that you might not want to do this, including not being the system administrator, not want to install it at all. Moreover, if I am developing the software, I probably don't want to install it. I want to make some changes and test the version sitting in my directory. This becomes even more salient if I'm going to have multiple versions lying around.

./configure goes and detects what is available in the environment and/or is desired by the user to determine how to build the software. This is not something that needs to change very often and can often take some time. Again, if I am a developer, it's not worth the time to reconfigure constantly. More importantly, since make uses timestamps to rebuild modules, if I rerun configure there is a possibility that flags will change and now some of the components in my build will be compile with one set of flags and others with a different set of flags that might lead to different, incompatible behaviour. So long as I don't rerun configure, I know that my compilation environment remains the same even if I change my sources. If I rerun configure, I should make clean first, to remove any built sources to ensure things are built uniformly.

The only case where the three command are run in a row are when users install the program or a package is built (e.g., Debian's debuild or RedHat's rpmbuild). And that assumes that the package can be given a plain configure, which is not usually the case for packaging, where, at least, --prefix=/usr is desired. And pacakgers are like to have to deal with fake-roots when doing the make install part. Since there are lots of exceptions, making ./configure && make && make install the rule would be inconvenient for a lot of people who do it on a far more frequent basis!

Find elsewhere
๐ŸŒ
Unix.com
unix.com โ€บ unix for beginners q & a โ€บ unix for dummies questions & answers
Difference between configure/make/make install. - UNIX for Dummies Questions & Answers - Unix Linux Community
April 8, 2010 - Hi, While installation of apache on linux, we perform the below tasks. Untar configure make make install. I wanted to understand the difference and working of configure/make/make install. Can any one help me understโ€ฆ
๐ŸŒ
The Linux Documentation Project
tldp.org โ€บ HOWTO โ€บ Software-Building-HOWTO-3.html
Building and Installing Software Packages for Linux: Using Make
Invoking make usually involves just typing make. This generally builds all the necessary executable files for the package in question. However, make can also do other tasks, such as installing the files in their proper directories (make install) and removing stale object files (make clean).
๐ŸŒ
Reddit
reddit.com โ€บ r/explainlikeimfive โ€บ eli5: linux's 'configure', 'make', 'make install'
r/explainlikeimfive on Reddit: ELI5: Linux's 'configure', 'make', 'make install'
September 24, 2012 -

I just finished up installing ruby on a CentOS system and I can't for the life of me understand why I had to do these three steps. I googled around and it seems that this is the build system that all linux applications use. How does it work? And why execute three steps, why not just do 'make install'?

(I'm a java developer so I have very limited linux knowledge)

๐ŸŒ
Quora
quora.com โ€บ What-does-configure-make-make-install-do
What does './configure && make && make install' do? - Quora
Answer (1 of 2): the command [code]./configure && make && make install [/code]is combo of 3 distinct commands joined by the โ€˜&&โ€™ i.e. logical โ€˜andโ€™ operator the way โ€˜&&โ€™ operation work is this way : When multiple expressions joined using โ€˜&&โ€™, the evaluation can be true only if all the express...
๐ŸŒ
Reddit
reddit.com โ€บ r/debian โ€บ apt-get vs. make install
r/debian on Reddit: Apt-get vs. Make install
January 14, 2014 -

Very new to Linux. Been using Raspbian on my pi for a couple months. I've been successful in installing software from source. I've been noticing that whenever I use apt-get install it is so much easier and usually works without some fussing.

I usually try to save questions for Reddit until I'm out of Googling ideas, but where can I find a great place to find apt-get software and understand it?

Most of my programming experience has been through web languages so I'm clueless when it comes to compiling. When I tried to install Apache through make, make install it was unsuccessful. I'm not sure why, but when I attempted the same feat with apt-get it worked perfectly. Why is that?

Thanks :)

Top answer
1 of 5
23
make install is not an installer in the modern sense. It typically just copies compiled files to the desired location. It might put the pieces in the right place (if you got all the arguments to the configure script correct) but it typically will not take any further steps (e.g. it will not create an init script for apache so that the service gets started automatically.) Debian packages (the things apt-get installs) are the output of make install (the compiled files and their expected location) combined with tweaks, configuration files, post-install scripts and other things done by a Debian developer to properly integrate the software with Debian. Further, packages installed with apt-get are tracked. You cannot install two packages where one overwrites a file of another. Packages can be cleanly uninstalled, cleanly upgraded (old files not in the new version of the package get removed), etc. make install provides no such guarantees. And apt-get can automatically install newer versions of packages as they become available. Anything installed from source (i.e. configure and make install) is your responsibility to keep up to date. EDIT: With respect to 'make install' I qualified everything with "typically". The is because technically make install can do anything that the developers of the software you are building want it to do. So one certainly could include a Debian init script with Apache that gets installed with make install. But most software packages do not because either a) they are not interested in maintaining such integration pieces for a large number of different operating systems (where in that sense Linux distros are different operating systems that share a kernel) or b) they include them in a different way (e.g. a special make target to build a proper Debian package).
2 of 5
4
aptitude (and apt-get) are downloading precompiled binaries off of whichever repository you have in your /etc/apt/sources.list file. make install compiles the binary from the source based off the instructions in the makefile in whatever directory you're in. I can't say for sure why make install isn't working on the apache source without seeing the output but it is most likely a dependeicy issue. Apache should be in just about any repository though. Try apt-get install apache2
Top answer
1 of 2
1

dpkg is a program on a Debian/Ubuntu or any derivative distribution for installing already packaged applications. The Difference is very simple, a .deb file is a compiled package of application binaries. It has inbuilt logic for placing the different files indifferent directories.

For example, the executable for the application goes into /usr/bin, However the point to note here is that .deb is a packaged binary file which contains compiled software. You do not get to see the source, Hence Many Companies tend to publish their proprietary software in .deb/.rpm format.One such example is Insync, another is Crossover for Linux. Both these are proprietary but distributed as a .deb or a .rpm file.

Here is the gist.

dpkg -i

Means you are installing a compiled and packaged application to run on any Linux distribution which uses .deb format for installing packages.

and

./configure make make install

Means that you have the source code for the application which you are installing. You are now compiling manually by using the compiler(configure and then followed by make.) on the system rather than the package manager. The make install command will then install the software on the system. this method works regardless of the distribution you are installing on.

2 of 2
0

Well, both methods don't have auto updating. They suggest adding an apt repository with the .deb which is updated by a package maintainer. Then when you do system updates, the program will be updated alongside your other .deb packages. dpkg is the Ubuntu default package manager because it's derived from Debian. The whole system is installed using it.

๐ŸŒ
DEV Community
dev.to โ€บ skypy โ€บ linux-make-install-command-2dd6
Linux make install command - DEV Community
September 1, 2021 - install is a command that was written for software installation, but it can do more than that. make install will do whatever instruction is defined in makefile.
๐ŸŒ
Pluralsight
pluralsight.com โ€บ blog โ€บ cloud
Troubleshooting ./configure, make and make install Tutorial | Pluralsight
If you want to install some software, please look for a precompiled package (like a .rpm or a .deb) first. If you really need to compile, do it with care.Note: This tutorial assumes that you have some linux command line knowledge and that you know how to work with your distro's package manager.We can divide the errors in three categories: ... make install errors It should be quite obvious how to recognize them: ./configure errors are outputted by the configure script, make errors by the make command and so on.
๐ŸŒ
Reddit
reddit.com โ€บ r/linux โ€บ why "sudo make install"?
r/linux on Reddit: Why "sudo make install"?
September 14, 2023 -

Why do that many projects recommend to push compiled binaries to the filesystem root?

edit Ok. I might have been wrong. My /usr/local ist empty. If stuff only gets installed there, my argument is invalid. I still feel pretty insecure about doing a make install, because it at least could conflict with the system installation.

Thanks for answering. /edit

I have a folder ~/usr where I push all compiled stuff. I then do cmake -DCMAKE_INSTALL_PREFIX=$HOME/usr/ or ./configure --prefix ... and then install that without sudo. Some big projects I compile even have their own prefix.

Sure you have to tell your users to have ~/usr/bin in your PATH. I also added that to my LD_LIBRARY_PATH and PKG_CONFIG_PATH. But IMO that should be a default thing to do for Linux users (who compile stuff).

Polluting your distro installation with random crap is a sure way to get issues later. Its far worse then anything you can do to install Software on Windows.

I mean compiling a bleeding edge kicad, inkscape or jpeg-xl is easy. But will probably trash your system if you already have an older version installed.

(Some projects tell you to build a distro package and sudo install that. Much better, but I still prefer having the binaries in my own prefix. Also a lot got better, since many big projects publish daily snapshots as Appimage or similar.)

edit2 I was of course talking about a single-user system for users who sometimes like to test bleeding edge software. Not Multi-user sytems. Not Grandma, who's not allowed to install stuff. edit