$_ CLI In Depth
Learning progress 0%
lesson packages services cron

Installing from Source: configure, make & install

5 min read Module 11: Packages, Services & Scheduled Jobs Updated Dec 5, 2026
Cheat Sheet
0:00 / 3:10

Why build from source

A package manager is the preferred way to install software, because it tracks files, versions, and dependencies. Building from source is what you do when no package exists, when you need a patched version, or when you want a build with particular options. You take on the work the package maintainer normally does: finding the dependencies, choosing the options, and placing the files. The trade-off is that the package manager no longer knows about the files you install, so you must keep track of them yourself.

The three steps

Most projects that use the GNU build system follow the same three steps. The first is ./configure, a script generated by autoconf. It inspects the compiler, the libraries, and the headers on the machine, and it writes a file called Makefile that records what it found. The second is make, which reads the Makefile and runs the compiler on each source file in the right order. The third is make install, which copies the built programs, libraries, and documentation to the install location.

A common shape for the whole process is shown below. It is a sketch for a real project, not a command to run on this machine, which has no compiler and no source tree to build.

BASH3 lines
./configure --prefix="$HOME/.local"
make
make install

The --prefix option sets the top of the install tree. With a prefix inside your home directory, the files go into $HOME/.local/bin and the other standard subdirectories, and you need no administrative rights. Without a prefix, the default is usually /usr/local, which requires root.

Reading configure output

Configure prints a long list of checks, such as whether a C compiler works, whether a header exists, and which version of a library it found. The last lines are the most useful. A failed check that the project requires ends the run with an error message that names the missing item. The fix is almost always to install the named development package and run configure again.

To see the options a project accepts, read its help text rather than its documentation. The option list is generated from the same script that performs the checks, so it is the authoritative list for that version.

BASH1 lines
./configure --help | head -n 20

Make and parallel builds

The make program decides what to rebuild by comparing the time stamps of the source files with the time stamps of the outputs. A file is rebuilt only when its source is newer than the object file that came from it. This is why a second run of make after a small change is fast. The -j option runs several compile steps at once, which speeds up large builds on machines with several cores. The number after -j is the count of jobs, and -j alone asks for as many as the make program allows.

A dry run prints the commands that make would run without running them. The -n option is the safe way to inspect a build you did not write.

BASH1 lines
make -n | head -n 5

Install, uninstall, and tracking

The install step copies files, and it does not record them anywhere that the package manager can read. If you want to remove the software later, you must either run an uninstall target that the project provides, or keep a list of the files it installed. A simple habit is to install into a dedicated prefix directory, so that removing the software means removing that one directory. Another useful habit is to keep the build directory around until the install is verified.

The DESTDIR variable makes make install copy into a staging directory instead of the real prefix. Package builders use it so that they can capture the exact files before they move them into place.

Warning

Do not run make install as root for software you have not read. The install step writes to system directories, and a bad install script can overwrite files that the package manager owns.

Source builds also depend on the environment in ways that a package hides from you. The configure script records the compiler flags, the library paths, and the optional features it found, and it stores them in the generated files. If you change the machine, such as by installing a new library, run configure again so the recipe matches the machine. A stale Makefile is a common cause of a build that succeeds but produces a program that fails at run time.

Before a build, it is worth reading the README and the install notes that ship with the source. Many projects list the required libraries and the minimum versions, and those notes are usually more accurate than the error messages from a failed configure run. Keep the source tarball and its checksum next to the build, so that you can prove later which source produced which program.

This lab machine

The lab does not have make, a C compiler, or a source tree, so you cannot run the build in it. The lab does have the tools that the build steps rely on, such as the shell, the file utilities, and the library inspection tools that the next unit covers. The hands-on part of this unit asks you to write the build plan as a file and to check whether make is installed, so you can see the answer for yourself.

Hands-on: write a build plan

Write the three build commands into a plan file, in the order they must run. Then test whether make exists on this machine and save the answer.

BASH2 lines
printf "%s\n" "./configure --prefix=$HOME/.local" make "make install" > plan.txt
if command -v make >/dev/null 2>&1; then echo yes; else echo no; fi > make.txt

The file plan.txt lists the three steps in order, and make.txt holds yes or no. The answer for this lab is no, which is the reason you cannot run the build here.

Terminal lab · 2 steps · real Linux in your browser

Write a build plan and check for make

Record the three build commands in order, then check whether make exists on this machine.

01
Write the three build steps in order
Write the configure, make, and install commands into plan.txt, one per line, in the order they must run. Keep the prefix in your home directory. ``bash printf "%s\n" "./configure --prefix=$HOME/.local" make "make install" > plan.txt `` Read the file with cat plan.txt. The first line must start with ./configure.
Show hint for step 1
Use printf with one argument per line. The second line is make and the third is make install.
02
Check whether make is installed
The command -v builtin prints a path when a program exists and nothing when it does not. Turn that into a yes or no answer and save it in make.txt. ``bash if command -v make >/dev/null 2>&1; then echo yes; else echo no; fi > make.txt `` The file holds yes or no. On this lab machine the answer is no.
Show hint for step 2
Use if with command -v make, and send the echo output to make.txt.
Check yourself Question 1 of 4
Concept Check Script that writes the Makefile recall

Which script in a GNU-style source tree checks the system and writes the Makefile?

Recap & Key Takeaways

The classic build is ./configure to write a Makefile, make to compile, and make install to copy the results.
Use --prefix inside your home directory to install without root, and read configure --help for the real option list.
make rebuilds only files whose sources are newer than their outputs, and make -n prints the commands without running them.
Software installed by make install is not tracked by the package manager, so keep a separate prefix to make removal easy.
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue