FSL Developers Guide

Table of contents

  • Introduction
  • Accessing the sources with CVS
  • Environment variables
  • Starting a new project
  • Getting a local copy of the files
  • Tracking changes to a project
  • Freshening your copy
  • Adding files to a project
  • Removing files from a project
  • Deleting the local copy
  • Building your program/library
  • Installing
  • Using libraries
  • Troubleshooting

  • Introduction

    This guide is for students/staff wishing to contribute to the FMRIB Software Library (FSL). It outlines: how to use CVS (Concurrent Version System); how to prepare conformant Makefiles; how and when to install your software.

    The section on CVS assumes no prior knowledge. If you don't know about Makefiles, function libraries and multi-object compilation/linking then you're likely to find the section on Makefiles heavy going.

    Any suggestions as to how to improve this document would be greatly appreciated.


    Accessing the sources with CVS

    There is a web based interface providing an overview of our repository. It is quite useful for checking change history, examining diffs, etc. For day to day access to the sources you will need to use the commands outlined in the rest of this section.

    Environment variables

    To access the repository you will need to set up your environment variables as follows:

    VariableSuggested valueDescription
    CVSROOT :ext:cocoa.fmrib.ox.ac.uk:/usr/local/share/sources How our repository can be accessed.
    CVS_RSH ssh The CVS access method.
    FSLDIR /usr/local/fsl Path to the main installed versions of the binaries/headers/scripts/libraries etc.
    FSLDEVDIR ${HOME}/fsldev Path to your own development versions of the software.
    FSLCONFDIR /usr/local/fsl/config Path to the make configuration files. Change this if you want to experiment with compiler settings etc.
    FSLMACHTYPE `gcc -dumpmachine`-gcc`gcc -dumpversion` The GNU style target machine descriptor used to select the correct platform configuration settings (e.g. mips-sgi-irix6.5-gcc2.95.2, i386-redhat-linux-gcc2.96, i386-redhat-linux-gcc3.2, sparc-sun-solaris2.8-gcc2.95.3, alphaev6-dec-osf5.0-gcc2.95.2). Use export FSLMACHTYPE=`gcc -dumpmachine`-gcc`gcc -dumpversion` to get the right value automatically each time you log in to a machine.

    Starting a new project

    To import an existing directory/project simply skip the mkdir step. However one should note an import will include all the files in the directory and this probably isn't what you want.

    First create the new project directory and import it into CVS:

    mkdir <projectname>

    cd <projectname>

    cvs import -m "Initial import into CVS" <projectname> <username> 'pre1_0'

    The current directory should then be discarded and a copy checked out from the cvs repository, which is necessary to get a local CVS directory that is needed by other cvs commands (like adding files - see below)

    cd .. ; rmdir <projectname>

    cvs co <projectname>

    Getting a local copy of the files

    It is recommended that you check copies out to a directory other than FSLDEVDIR. This will help avoid mistakes when updating sources back into the repository.

    CVS allows you to create and maintain local copies of the sources. Each developer works on his/her own copy and, periodically, commits their changes to the source repository. If a developer wants to get changes that other developers have committed then they need to perform an update of the local copy.

    Although the sources can be put anywhere, it is better to keep them out of the ${FSLDEVDIR} tree, as it avoids problems with accidental check-ins and check-outs.

    Create a local copy of the project you want to edit:

    cvs co <projectname>

    This will create a directory called <projectname> in the current directory. Each subdirectory of <projectname> will also contain a directory called CVS. These are CVSs control files and you should leave them alone unless you know precisely what you're doing.

    Edit these sources and when you're happy with the changes commit them back into the repository.

    (Before committing changes you may want to update your local sources. CVS will stop you from committing changes which clash with other developers changes.)

    If you don't tell CVS which files to work on then it will automatically process the whole directory.

    cvs update

    Now commit your changes:

    cvs commit -m 'These changes implement some whim of mine!'

    Tracking changes to a project

    If you have checked out a project, e.g., utils, so that you can use the latest version of it, then you'll probably want to know when someone changes it. CVS helps by letting you sign up for notification when events occur on files within a project. To get notifications via e-mail when someone commits changes to a project you must add yourself to the watch list of the files as follows:

    You won't be notified if someone adds a file to the project since you won't automatically be a watcher of the new file. This is an unavoidable weakness in this scheme.

    cd <projectname>

    cvs watch add -a commit

    And to remove yourself from the watch list:

    cvs watch remove

    Freshening your copy

    From time to time you will need to incorporate other peoples changes to a local copy you are maintaining. Use cvs status to see if any source file "Needs patch". The cvs update command will patch the files unless there is a conflict, i.e., your local changes would be lost.

    You will not be able to commit your changes to a file until you have resolved all conflicts.

    If two versions do conflict then CVS will place a version of the file in your directory with both possible changes highlighted in it. It will then be up to you to resolve the differences and commit the corrected file.

    Adding files to a project

    The repository should not contain any files which are being generated, e.g., via the compilation process. The depend.mk file would be an example of a file which should not be in the repository.

    Before adding a file to the repository first make sure you really need it in there. The repository should only contain those files needed to build the project, i.e., Makefile, scripts, sources, headers, documentation and, possibly, required data.

    To add new files to the project:

    Binary files need to be added with a special option to stop CVS from doing keyword substitutions, i.e., cvs add -kb ashes.jpg

    cvs add <filename>

    cvs commit

    Removing files from a project

    Files never really get removed from the repository. If you tell CVS to remove a file it puts in that directories Attic so that it can still recreate old versions of the source tree. To remove a file first delete it from the local copy then commit your changes as follows:

    rm <oldfile>

    cvs remove <oldfile>

    cvs commit -m "Deleted dead file" <oldfile>

    Deleting the local copy

    Simply remove the directory. Any uncommitted changes will be lost. You will still be watching the project if you had a watch on it. So cvs watch remove if appropriate.


    Building your program/library

    make is used to control how an FSL project gets compiled and installed. To contribute properly you will need to maintain FSL conformant Makefiles for all your projects.

    An explanation of FSL Makefiles complete with examples can be found in the FSL Makefile Reference Guide.


    Using libraries

    So you want to use functionallity in an FSL library, e.g. libutils. First you must include the headers in your source code:

    #include "utils/options.h"

    Next you need to add the library to your link line. To do this you need to add -lutils to your list of libraries. Edit the Makefile so it has a line like this:

    LIBS = -lfilm -lutils

    Development libraries

    Note that this differs from the scheme we were using pre-CVS. You do not need to modify USRINCFLAGS any more. Also you no longer need to specify <projectname>_dev to get development libraries.

    To use debug/experimental versions of libraries simply check them out, compile and install them locally. You will automatically pick up the locally installed libraries and headers before the released versions. Please try to avoid writing programs which rely on experimental versions of some library as these will not be in the main installation and may break the release process.


    Installing

  • How do I install for local testing/development?
  • How do I install into FMRIBs version?
  • How do I release this to the world?
  • How do I install for local testing/development?

    This process does not update the repository.

    Simply run make install in the source directory. This will put binaries, libraries, headers, scripts, and documents in ${FSLDEVDIR} where they can be used for local testing and development.

    How do I install into FMRIBs version ?

    This process does update the files in the repository as well as placing a tag on the project.

    First use cvs commit to put your changes into the repository. Next run tagstable in the top level directory of the project to indicate that this is a version you want included in the FMRIB installation. The changes will get incorporated into the nightly automated rebuild. If the build succeeds then the changes will be installed into /usr/local/fsl and users will be running your updates in the morning.

    How do I release this to the world?

    The world release will automatically be made up of our latest stable tagged sources. You don't need to do anything.


    Troubleshooting

    Don't panic!


    David Flitney
    Last modified: Mon Mar 3 16:01:30 GMT 2003