Building Software Packages for Linux: Using Make

prev-6071049 next-2649386 toc-1446496

The Makefile is the key to the build process. In its simplest form, a Makefile is a script for compiling or building the « binaries », the executable portions of a program. The Makefile can also provide a means of updating a software package without having to recompile every single source file in it, but that is a different story (or a different article).

At some point, the Makefile launches cc or gcc. This is actually a preprocessor, a C (or C++) compiler, and a linker, invoked in that order. This process converts the source into the binaries, the actual executables.

Only the simplest software uses a generic Makefile. More complex installations require tailoring the Makefile according to the location of libraries, include files, and resources on your particular machine. This is especially the case when the build needs the X11 libraries to install. Imake and xmkmf accomplish this task.

An Imakefile is, to quote the man page, a « template » Makefile. The imake utility constructs a Makefile appropriate for your system from the Imakefile. In almost all cases, however, you would run xmkmf, a shell script that invokes imake, a front end for it. Check the README or INSTALL file included in the software archive for specific instructions. Read the imake and xmkmf man pages for a more detailed analysis of the procedure..

Be aware that xmkmf and make may need to be invoked as root, especially when doing a make install to move the binaries over to the /usr/bin or /usr/local/bin directories. Using make as an ordinary user without root privileges will likely result in write access denied error messages because you lack write permission to system directories. Check also that the binaries created have the proper execute permissions for you and any other appropriate users.


Invoking xmkmf uses the imake file to build a new Makefile appropriate for your system. It sets the variables and defines the library locations for the compiler and linker. Sometimes, there will be no imake file, instead there will be an INSTALL script that will accomplish this purpose. The README file included with the distribution will usually explain the install procedure.

Your general installation procedure will therefore be:

  • Read the README file.
  • Run xmkmf or the INSTALL script.
  • If necessary, run make clean or make depend
  • Run make.
  • If necessary, run make install

prev-6071049 next-2649386 toc-1446496