Install 3rd-party programs or libraries
A lot of great software has been written by people not in our group, and it's to our advantage to be able to make use of it. This HOWTO explains how to install a 3rd-party project (that is, a program or library) into $G so that everyone in the group can use it. This is easiest if you can get a simple source tree for the project, but we can even deal with complicated source trees and binary-only projects.
Remember to never copy files directly into $G! Everything in $G should get there by being checked into CVS.
Install a simple source tree
In this case, installing a 3rd-party project is identical to checking in and installing one you wrote yourself.
- Copy the source tree into any directory of your choice (not in
$Gbut somewhere in your homedir). Remember to make sure the tree is clean; no object files or other binaries. - Import the project into CVS as normal.
- Modify the Makefile that came with the project so that
make allbuilds the project locally andmake installputs executables into$G/bin, headers into$G/include, libraries into$G/lib, and documentation into$G/man. - Check in and commit your changes to the Makefile, and you're done!
Here's an example Makefile for the NIFTI medical image format library:
all: cd src; make all install: all cd src; make doc cp src/bin/* $(G)/bin cp -rf src/lib $(G)/lib/nifti cp -rf src/include $(G)/include/nifti cp -rf src/docs/html $G/shared/man/nifti
Install a complicated source tree
In some rare situations, you can't put all the project's source into our CVS tree. In this case, the goal is to package everything you've got up into a .zip file and make the build and install scripts temporarily unpack the source tree.
- If you already have a
.zipfile for the source tree, continue on. If not, use thezipcommand to create an archive. - Move the
.zipfile into its own directory and create a Makefile there.- The
alltarget should unzip the archive and build it. - The
installtarget should copy the resulting executables, headers, libraries, and documentation into$G/bin,$G/include,$G/lib, and$G/manrespectively.
- The
- Move the
.zipfile somewhere else temporarily and import the project into CVS as normal with just the Makefile in the directory. - Move the
.zipfile into the appropriate$G/src/<projname>directory, check it in withcvs add -kb <archivename>, and then commit.
Here's another Makefile for the NIFTI library, but this time extracting the source code on the fly:
all: unzip -ou nifti.zip # nifti.zip has a root directory called "src" cd src; make all install: all cd src; make doc cp src/bin/* $(G)/bin cp -rf src/lib $(G)/lib/nifti cp -rf src/include $(G)/include/nifti cp -rf src/docs/html $G/shared/man/nifti
Advanced: use wget
Sometimes it makes sense to have the build and install scripts just download the project directly, rather than checking an archive into our CVS. Be careful about doing this, as versions and URLs change over time.
Rather than download the project's .zip file yourself and then check that in, you can add a wget command to the Makefile to download it, and then unzip, build, and install it as above.
Here's an optional download target that could be appended to the Makefile above and added to the all step:
download: rm -rf src nifti.zip wget -rq --reject "*.html*" --nH --cut-dirs=2 http://nifti.nimh.nih.gov/pub/dist/src/ zip -r nifti.zip src rm -rf src
Install binary files directly
If you don't even have a .zip file of the source tree for a project, then you have no other choice but to put the actual binary library file into CVS.
- Put all the binaries you want to install into their own directory.
- Create a Makefile in that directory that will respond to
make allandmake install.- For
make allyou can just print out "Nothing to do for this project." - For
make install, usegfxinstall3to install the files in the proper places in$G.
- For
- Now move the binaries out of the directory and import the directory into CVS.
- Copy the binaries into the new
$G/src/<projectname>directory, add each one withcvs add -kb <filename>, and then commit.