Tags

, , , , , , , , , , , , , , , , , ,

Installing a package (AKA software) from source code is often considered to be the secret cult of the worshipers of the Geek God. But, you know, it’s not that difficult. Let’s see how we can do it.

First, some preliminaries. Why should I build it form the source code? Well, source codes are more or less platform independent. If you have a suitable compiler and necessary libraries, you may install it on any platform of your choice. Source code files are available  in ASCII plain text  format (not binaries) — so you can study it and understand what it does and whether/ how it may affect your system. Reading  the description of a software distributed as a binary does not even come close to that — you really don’t know what that piece of  software does until you actually run it. Needless to add, you may include your changes to the open-source code to suit your needs as well in accordance with the relevant license.

Secondly, where can I find the source code? The source code for a open-source package is often distributed in compressed format (i.e., with an extension “tar.gz”, “tgz” or “tar.bz2” — that’s why it’s also called tarball). You may download the tarball from a reliable source, e.g. homepage of the package developer, Free Software Directory, Open Source Software directory, linux.org, Ubuntu archive, Darwin ports, Fink and Open Source Apple website. Last three are specifically intended for OSX running Darwin. Wikipedia also has a nice list of Free and Open Source softwares.

Now, let’s do the installation step-by step. Create a directory (say, ~/packages) where you want to save the packages, navigate to that directory, save the tarball (say, newpack.tar.gz) there and uncompress it:

$ tar zxvf newpack.tar.gz

Replace “zxvf” by “jxvf” if it has a “tar.bz2” extension instead of “tar.gz” or “tgz”.

Then navigate to the uncompressed directory (usually newpack, but be sure of  that first using the ls command) using

$ cd newpack

and read the instruction files (e.g., INSTRUCTIONS, INSTALL, README), if any, for special instructions using your favorite text editor. Otherwise, the normal procedure for installation is the following series of commands: (wait for each one to finish before you issue the next command!)

$ ./configure
$ make
$ sudo make install

You need to enter the superuser password in the last step as it copies the executable in the system’s executable directory (e.g., /bin, /sbin/). That’s it!

However, you may want to clean up the mess (especially the object files) created by the installation process using:

$ make clean

In a spree of cleaning up, however, don’t delete the file named Makefile: you need this if you want to uninstall the package (the above command won’t delete it).

In order to uninstall the package, navigate to the same directory (~/packages/newpack/), and issue the following command:

$ sudo make uninstall

You need to enter the superuser password for this.

Reference: here.

Advertisements