About

Unix programmers have a long lasting tradition of sharing and exchanging source codes. An important number of tools and application are commonly published under Free Software and/or Open Source licenses, making the necessity to develop some conventions and standards in publishing source code.

Tarballs

Source code is generally distributed as a compressed archive. The most common compression method are and bzip2 (a slower but more effective compression algorithm). The packaged archives are referred to as tarballs. Commonly, here are the filename extension used in naming conventions:

  • .tar.gz and.tgz signaling gzip compression
  • .tar.bz2, .tbz, .tbz2 and .tb2 signaling bzip2 compression.

Here's how to extract the source code from the tarball:

On

tar xvzf foo.tar.gz

tar xvjf foo.tar.bz2

On

gzcat foo.tar.gz | tar xv

bzcat foo.tbz2 | tar xv

A common case: Autotools

The GNU build system (sometimes referred to as autotools, because it includes tools like autoconf or automake) is by far the most common format of Unix-source packages. Here's the most basic use-case to install an autotools package from source:

  • ./configure --prefix=/path

The configure script will detect the tools installed in the user's environment and will generate the Makefile (and other scripts) accordingly. The option --prefix=/path will define the target install directory (if nothing is specified it will use /usr/local by default). More options may be available and can generally be consulted with ./configure --help.

  • make

    This command will compile the code into binaries by calling the tool. It can optionally take specific targets as arguments and/or options.

  • make install

    This command will install the compiled code into the target directory (/usr/local by default). Depending on the user's permission on the directory, it may need to be executed with permissions.

Publicly available Source Control systems

Another form of source code distribution is setting up a publicly available source repository. Some projects make the latest developments of the code available this way. For instance:

Git

git clone http://url-to-git-repo

SVN

svn co http://url-to-svn-repo proj-trunk
history | show excerpt | excerpt history