I always prefer to use the package manager instead of compiling from sources, mmh maybe compiling is more creates more efficient programs, than using binaries, but in that case, we better use Gentoo or Sabayon, but if we are using Debian/Ubuntu, or Centos/Fedora, I still think is better to use binaries.

Well this said, I have to add that sometimes there is no binary available for our favorite distro, in that case we are forced to compile from sources, but wait, we can still use a binary, we can make our own .deb or .rpm package and install it using dpkg or rpm, checkinstall is the program that will do the magic here.

First install it, as it does not come by default installed.

Debian / Ubuntu

sudo aptitude install checkinstall

Fedora / CentOS

sudo yum install checkinstall

Now as an example I will compile and install aterm which is a terminal emulator, I will write about it later.

Ok, get the code

wget ftp://ftp.afterstep.org/apps/aterm/aterm-1.0.1.tar.gz

Untar it

tar xvzf aterm-1.0.1.tar.gz

Change to its directory:

cd aterm-1.0.1

Now, usually at this point you have to enter three commands

./configure
make
make install

This time we will enter only the first two:

./configure

make

Now, here comes the magic, staying at the same directory change to root or use sudo

sudo checkinstall

You will see something like this, the first time:

checkinstall 1.6.1, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.


           The package documentation directory ./doc-pak does not exist.
           Should I create a default set of package docs?  [y]:


Preparing package documentation...OK

Please write a description for the package.
End your description with an empty line or EOF.
>> aterm 1.0.1

*****************************************
**** Debian package creation selected ***
*****************************************

This package will be built according to these values:

0 -  Maintainer: [ root@ggarron ]
1 -  Summary: [ aterm 1.0.1 ]
2 -  Name:    [ aterm ]
3 -  Version: [ 1.0.1 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ i386 ]
8 -  Source location: [ aterm-1.0.1 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]

Enter a number to change any of them or press ENTER to continue:

Copying files to the temporary directory...OK

Stripping ELF binaries and libraries...OK

Compressing man pages...OK

Building file list...OK

Building Debian package...OK

Installing Debian package...OK

Erasing temporary files...OK

Writing backup package...OK

Deleting temp dir...OK


**********************************************************************

 Done. The new package has been installed and saved to

 /home/ggarron/Desktop/borrar/aterm-1.0.1/aterm_1.0.1-1_i386.deb

 You can remove it from your system anytime using:

 dpkg -r aterm

**********************************************************************

You need to answer one time Y, and enter the description of the package, and you are done, after that, the program will create a .deb or .rpm package and install it, if you do not like the result, just uninstall it.