Installing programs from source codes

  • Best Practice: Open README file, and follow its instructions.
  • If README file has no useful information, you should give it up to install the program, or simply try:
    > ./configure
    > make
    # make install
    

Configure Script

The following command (when a configure script is in the folder) shows available options to customize your source code build.

> ./configure --help 

Frequently Used Options

  • --prefix
      --prefix=PREFIX         install architecture-independent files in PREFIX  [default=/usr/local]
    
    • Even if you do not have enough authority to install programs into /usr/local, with prefix option, you can install them into another location, e.g., your home directory, etc.
> ./configure --prefix=/home/leo/local 
> make
> make install	# generated binary programs will be installed to /home/leo/local/bin
  • --program-prefix, --program-suffix
    • These parameters can be used to add prefix/suffix to the executable file. For example, when a program named "hello" is already installed in the system, but you want to install your own compiled version of the program as "hello2":
       > ./configure --program-suffix=2 && make && sudo make install
      

The resulting executable file will be "hello2".

  • --enable-something, --disable-something
    • Sometimes, a configure script generates a Makefile that contains unnecessary functionalities. Find these options from the help message.

GNU Autotools

  • A good tutorial I found on the web pdf

Programs required special users

Some programs, e.g., Postfix, Apache, Squid, etc. require special users to install and run these programs.

  • related commands: useradd, adduser, usermod, groupadd, groupdel, adduser --system, chmod, etc.
  • Read the chapter 8 of the Linux Cook Book

Setting Environment Variables Shared by Users

  • Some programs need special settings. For example, Ant uses ANT_HOME variable, and this is mandatory for running Ant.
  • In general, these variables should be set in your shell configuration files, such as .bash_profile, .bashrc, etc.

.bash_profile

export ANT_HOME=$HOME/local/apache-ant-1.7
export PATH=$ANT_HOME/bin:$PATH
  • When you have to share these settings with other users, edit the /etc/profile
    • This script is automatically loaded when users open a shell.
      • Thus, care should be taken to modify /etc/profile

Configuration Templates

  • /etc/skel directory contains templates for various programs, e.g., .emacs, .bash_profile, .bashrc, etc.
  • When creating a new user, these files will be copied into the new user's home directory.

Practice

  • A Story: You want to use the new features in the latest Ruby language (version 1.8.6), but you have only an older version of ruby program (1.8.4) in your system, and its RPM package for the latest version is not available yet:

  • A Solution: Install the latest ruby program from source codes.
  • Tips
    • Your system usually have an ruby program. First, test the version of the installed ruby program:
      leo@xerial:~/local/src> ruby --version
      ruby 1.8.4 (2005-12-24) [i386-linux]
      

The latest version is 1.8.6 (2007 Jul 19th).

  1. Download the source tar ball from the ruby site.
  2. Extract files from the archive. tar xvfz ..., unzip ..
  3. Run the configure script. You have several options:
    1. Remove the already installed ruby program with "yum remove ruby" or "rpm -e ruby", or
    2. Configure with --program-suffix="-1.8.6" option, which gives ruby program named "ruby-1.8.6", or
    3. Install the latest ruby program locally, by using --prefix=$HOME/local, then configure your PATH environment variable in .bashrc, .bash_profile, etc.
  4. make
  5. make install. (Whether to use the root privilege or not depends on your previous choice)
  6. (Optional) make clean.

Attachments