Install 3rd-party programs or libraries: Difference between revisions

From VrlWiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
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.
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 <tt>$G</tt>!'''  Everything in <tt>$G</tt> should get there by being checked into CVS.
'''Remember to never copy files directly into <code>$G</code>!'''  Everything in <code>$G</code> should get there by being checked into CVS.


==Install a simple source tree==
==Install a simple source tree==
In this case, installing a 3rd-party project is identical to checking in and installing one you wrote yourself.
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 <tt>$G</tt> but somewhere in your homedir).  Remember to make sure the tree is clean; no object files or other binaries.
# Copy the source tree into any directory of your choice (''not'' in <code>$G</code> but somewhere in your homedir).  Remember to make sure the tree is clean; no object files or other binaries.
# [[Put your code into CVS in $G|Import the project into CVS as normal]].
# [[Put your code into CVS in $G|Import the project into CVS as normal]].
# Modify the Makefile that came with the project so that <tt>make all</tt> builds the project locally and <tt>make install</tt> puts executables into <tt>$G/bin</tt>, headers into <tt>$G/include</tt>, libraries into <tt>$G/lib</tt>, and documentation into <tt>$G/man</tt>.
# Modify the Makefile that came with the project so that <code>make all</code> builds the project locally and <code>make install</code> puts executables into <code>$G/bin</code>, headers into <code>$G/include</code>, libraries into <code>$G/lib</code>, and documentation into <code>$G/man</code>.
# Check in and commit your changes to the Makefile, and you're done!
# Check in and commit your changes to the Makefile, and you're done!


==Install a complicated source tree==
==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 <tt>.zip</tt> file and make the build and install scripts temporarily unpack the 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 <code>.zip</code> file and make the build and install scripts temporarily unpack the source tree.
# If you already have a <tt>.zip</tt> file for the source tree, continue on.  If not, use the <tt>zip</tt> command to create an archive.
# If you already have a <code>.zip</code> file for the source tree, continue on.  If not, use the <code>zip</code> command to create an archive.
# Move the <tt>.zip</tt> file into its own directory and create a Makefile there.
# Move the <code>.zip</code> file into its own directory and create a Makefile there.
#* The <tt>all</tt> target should unzip the archive and build it.
#* The <code>all</code> target should unzip the archive and build it.
#* The <tt>install</tt> target should copy the resulting executables, headers, libraries, and documentation into <tt>$G/bin</tt>, <tt>$G/include</tt>, <tt>$G/lib</tt>, and <tt>$G/man</tt> respectively.
#* The <code>install</code> target should copy the resulting executables, headers, libraries, and documentation into <code>$G/bin</code>, <code>$G/include</code>, <code>$G/lib</code>, and <code>$G/man</code> respectively.
# Move the <tt>.zip</tt> file somewhere else temporarily and [[Put your code into CVS in $G|import the project into CVS as normal]] with just the Makefile in the directory.
# Move the <code>.zip</code> file somewhere else temporarily and [[Put your code into CVS in $G|import the project into CVS as normal]] with just the Makefile in the directory.
# Move the <tt>.zip</tt> file into the appropriate <tt>$G/src/&lt;projname&gt;</tt> directory, check it in with <tt>cvs add -kb &lt;archivename&gt;</tt>, and then commit.
# Move the <code>.zip</code> file into the appropriate <code>$G/src/&lt;projname&gt;</code> directory, check it in with <code>cvs add -kb &lt;archivename&gt;</code>, and then commit.


Here's an example Makefile for the NIFTI medical image format library:
Here's an example Makefile for the NIFTI medical image format library:
Line 32: Line 32:
  cp -rf src/docs/html $G/shared/man/nifti
  cp -rf src/docs/html $G/shared/man/nifti


===Advanced: use <tt>wget</tt>===
===Advanced: use <code>wget</code>===
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.
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 <tt>.zip</tt> file yourself and then check that in, you can add a <tt>wget</tt> command to the Makefile to download it, and then unzip, build, and install it as above.
Rather than download the project's <code>.zip</code> file yourself and then check that in, you can add a <code>wget</code> command to the Makefile to download it, and then unzip, build, and install it as above.


Here's an optional <tt>download</tt> target that could be appended to the Makefile above and added to the <tt>all</tt> step:
Here's an optional <code>download</code> target that could be appended to the Makefile above and added to the <code>all</code> step:
  download:
  download:
  rm -rf src nifti.zip
  rm -rf src nifti.zip
Line 45: Line 45:


==Install binary files directly==
==Install binary files directly==
If you don't even have a <tt>.zip</tt> file of the source tree for a project, then you have no other choice but to put the actual binary library file into CVS.
If you don't even have a <code>.zip</code> 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.
# Put all the binaries you want to install into their own directory.
# Create a Makefile in that directory that will respond to <tt>make all</tt> and <tt>make install</tt>.
# Create a Makefile in that directory that will respond to <code>make all</code> and <code>make install</code>.
#* For <tt>make all</tt> you can just print out "Nothing to do for this project."
#* For <code>make all</code> you can just print out "Nothing to do for this project."
#* For <tt>make install</tt>, use <tt>gfxinstall3</tt> to install the files in the proper places in <tt>$G</tt>.
#* For <code>make install</code>, use <code>gfxinstall3</code> to install the files in the proper places in <code>$G</code>.
# Now move the binaries out of the directory and import the directory into CVS.
# Now move the binaries out of the directory and import the directory into CVS.
# Copy the binaries into the new <tt>$G/src/&lt;projectname&gt;</tt> directory, add each one with <tt>cvs add -kb &lt;filename&gt;</tt>, and then commit.
# Copy the binaries into the new <code>$G/src/&lt;projectname&gt;</code> directory, add each one with <code>cvs add -kb &lt;filename&gt;</code>, and then commit.


[[Category:HOWTO]]
[[Category:HOWTO]]

Revision as of 00:01, 23 July 2008

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.

  1. Copy the source tree into any directory of your choice (not in $G but somewhere in your homedir). Remember to make sure the tree is clean; no object files or other binaries.
  2. Import the project into CVS as normal.
  3. Modify the Makefile that came with the project so that make all builds the project locally and make install puts executables into $G/bin, headers into $G/include, libraries into $G/lib, and documentation into $G/man.
  4. Check in and commit your changes to the Makefile, and you're done!

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.

  1. If you already have a .zip file for the source tree, continue on. If not, use the zip command to create an archive.
  2. Move the .zip file into its own directory and create a Makefile there.
    • The all target should unzip the archive and build it.
    • The install target should copy the resulting executables, headers, libraries, and documentation into $G/bin, $G/include, $G/lib, and $G/man respectively.
  3. Move the .zip file somewhere else temporarily and import the project into CVS as normal with just the Makefile in the directory.
  4. Move the .zip file into the appropriate $G/src/<projname> directory, check it in with cvs add -kb <archivename>, and then commit.

Here's an example Makefile for the NIFTI medical image format library:

all:
	unzip -ou nifti.zip
	# nifti.zip has a 
	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.

  1. Put all the binaries you want to install into their own directory.
  2. Create a Makefile in that directory that will respond to make all and make install.
    • For make all you can just print out "Nothing to do for this project."
    • For make install, use gfxinstall3 to install the files in the proper places in $G.
  3. Now move the binaries out of the directory and import the directory into CVS.
  4. Copy the binaries into the new $G/src/<projectname> directory, add each one with cvs add -kb <filename>, and then commit.