# Redland RDF Application Framework - Installation Instructions

## 1. Getting the sources

There are several ways to get the sources. The most stable and tested versions are the sources shipped with each release and these are recommended as the first place to start. If you want to get a newer set, then there are nightly snapshots made of the development sources, which may not yet be committed to the CVS. For the latest developent sources, anonymous CVS access is available but this may require some configuring of developer tools that are not needed for the snapshot releases.

The source bundle and package files contain all the HTML files and documentation provided on the web site.

### 1.1. Getting released sources

Every release comes with full sources and these are available from http://www.redland.opensource.ac.uk/dist/source/ master site as well as the SourceForge site.

### 1.2. Getting nightly source snapshots

Each night a snapshot distribution is attempted using the current development sources (that may not even be in the CVS), using the `make dist` target of the automake system. If this target completes, these snapshots are then made available from: http://www.redland.opensource.ac.uk/dist/snapshots/source/ (binary snapshot releases are also attempted each night from the same sources).

### 1.3. Getting the sources from CVS

      # sh, bash, ...
      CVSROOT=:pserver:anonymous@cvs.ilrt.org:/cvsroot
      export CVSROOT
      # csh, tcsh, ...
      setenv CVSROOT :pserver:anonymous@cvs.ilrt.org:/cvsroot

      cvs login
    Logging in to :pserver:anonymous@cvs.ilrt.org:2401/cvsroot
    CVS password:
      [return]

      cvs checkout redland

      cd redland

At this stage, or after a `cvs update` you will need to create the automake and autoconf derived files, as described below in Create the configure program by using the `autogen.sh` script.

Building Redland in this way requires some particular development tools not needed when building from snapshot releases - automake, autoconf and swig. The `autogen.sh` script checks for the appropriate versions.

(Aside: the current automake/conf system is using the "old" format configure.in with automake 1.4, autoconf 2.1x. These will be switched to the "new" format configure.ac with automake 1.6+, autoconf 2.5+ from the next release.)

## 2. Configuring and building

Redland uses the GNU automake and autoconf to handle system dependency checking. It is developed and built on x86 Linux (Redhat), but is also used extensively locally on various versions of sparc Sun Solaris 2.x. I also test it via SourceForges' compile farm and it builds on Debian Linux (x86, Alpha, PPC and Sparc), FreeBSD (x86) and Apple OSX.

### 2.1. Create `configure` program

If there is no `configure` program, you can create it by running the `autogen.sh` script, as long as you have the automake and autoconf tools. This is done by:

      ./autogen.sh

and you can also pass along arguments intended for configure (see below for what these are):

      ./autogen.sh --prefix=/usr/local/somewhere

Alternatively you can run the automake and autoconf programs by hand with:

      aclocal; autoheader; automake --add-missing; autoconf

(Ignore any warnings from autoconf about AC_TRY_RUN, it is caused by an autoconf macro and seems to be an autoconf bug.)

### 2.2. Options for `configure`

See also the generic GNU installation instructions in INSTALL for information about general options such as `--prefix` etc.

`--with-bdb=ROOT`

  Enable use of the Berkeley / Sleepycat DB library installed at ROOT. That means ROOT`/include` must contain the BDB header `db.h` and ROOT`/lib` must contain the library `libdb.a` (or whatever shared library version you have).

  Berkeley DB is now known as Sleepycat DB (after version 2) and distributed and supported by SleepyCat Software. Versions 4.1.24, 4.0.14, 3.3.11, 3.2.9, 3.1.17, 3.1.14, 2.7.7 and 2.4.14 have been tested and work. Some systems do not come installed with a working Berkeley/Sleepycat DB so on those systems, Redland will have no persistent storage unless BDB is built separately and enabled via this option.

  Note: If you change installed versions of BDB (from 3.x to 4.x) then you will need to re-configure Redland carefully to let it discover the features of the newer BDB as follows:

        rm -f config.cache
        make clean
        ./configure ... # any configure arguments here

  (plus you might need to use the `db`X`_upgrade` utility to update the BDB database files to the formats supported by the newer version X - see the BDB documentation to find out if this is required.)

  If the BerkeleyDB is installed in different places from ROOT`/lib` (library) and ROOT`/include` (header) or the library name is something that can't be worked out automatically, then you can use the following options to specify them.

`--with-bdb-lib=`LIBDIR
`--with-bdb-include=`INCDIR
`--with-bdb-name=`NAME

  Use Berkeley DB with the installed library in LIBDIR and the `db.h` header in INCDIR and the installed library called NAME like `-l`NAME. This is relative to LIBDIR. All of these options can be omitted and `configure` will try to find or guess the values from the system.

  For example, to compile redland on OSX with fink required a configure line something like this:

        ./configure  --with-bdb-lib=/sw/lib --with-bdb-include=/sw/include/db3

  The name of the BDB library was correctly discovered for this configuration, as `db-3.3`

`--with-libwww`

  Enable use of the W3C libwww, if available. configure will automatically enable this if the `libwww-config` program can be found in the path unless disabled by setting this option to no. libwww is not used at present.

`--enable-parsers=LIST`

  Select the list of RDF parsers to be included if the are availble. The valid list of RDF parsers are: `raptor repat` (the default). Even when selected these depend on the available XML parsers. Raptor uses either of libxml2 (prefered) or expat and repat requires expat. Redland requires the Raptor parser for other functionality, so this cannot be disabled. If no system-wide libxml2 or expat is available, Redland will compile an internal copy of expat and use that.

`--enable-digests=LIST`

  Select the list of digests to be included if the are availble. The valid list of digests are: `md5 sha1 ripem160` (the default). The digest functions can be provided by external libraries such as the OpenSSL libcrypto library or by provided portable versions (only MD5 supported in this release).

`--with-openssl-digests`

  Enable digests provided by the OpenSSL libcrypto library (MD5, SHA1 and RIPEMD160) if the library is available. configure will automatically enable this unless disabled by setting this option to no.

`--with-xml-parser=NAME`

  Pick an XML parser to use for Raptor - either `libxml` (default) or `expat`. If this option is not given, either will be used, with libxml preferred if both are present. libxml must be present as a system library but expat is always available since it is provided inside Redland.

  If the `repat` RDF parser is also required (by default, yes) then since it always requires `expat`, then even if expat is not selected for this option, it will be compiled in. To prevent this, remove repat from the list of RDF parsers using `--enable-parsers=raptor`.

  Raptor has been tested with various combinations of these libraries that are described further in the Raptor install documentation.

WARNING If the libwww or Sleepycat/Berkeley DB libraries are installed in a non-default directory, when the final linking occurs, the libraries may not be found at run time. To fix this you will need to use a system-specific method of passing this information to the run-time loader. On Linux and Solaris you can set the LD_LIBRARY_PATH environment variable to include the directory where the libwww libraries are found. You can also configure it via a system wide file - see the `ld`, `ld.so` or`ld.so.1` manual pages for details. The alternative, to link libwww statically, works but is difficult to enable.

### 2.3 Configuring

If everything is in the default place, do:

       ./configure

More commonly you will be doing something like this, when giving the installation location of Berkeley/Sleeypcat DB:

       ./configure --with-bdb=/usr/local/berkeleydb

If you are having problems with configuring several times when adding or removing options, you may have to tidy up first with either of these:

       make clean
       rm -f config.cache

### 2.4 Compiling

       make

## 2.5. Testing

You can build and run the built-in tests with:

        make check

which should emit lots of exciting test messages to the screen but conclude with something like:
`All` n`tests passed`
if everything works correctly.

(If you have got all the required subsidiary development tools, you can also do `make distcheck` which does a longer check that the distribution installation, configuring and building works. This does not perform any additional core testing).

Each of the language APIs has it's own test and example code that can be run. See the language-specific page for further details, however they can be build and tested with:

       cd language
       make test-language

### 2.6 Installing the library

To install the C library (static and shared typically) plus the interface header (.h) files do:

       make install

The language-specific interfaces are not installed in this step. See the language-specific page for further details, however they can be be installed with:

       cd language
       make install-language

## 3. Using the library

Once the library has been configured and built, there are several C example programs that can be used. They are in the `examples` sub-directory and can be built with:

       cd examples
       make

(This may be done by the initial 'make' automatically).

Examples for the other language interfaces are in the corresponding sub-directories such as `perl/example.pl`.

If no Berkeley DB was found by configure, some of the examples will fail since there is no on-disk storage system available. To change them to use the in-memory hashes, edit the lines reading something like

      storage=librdf_new_storage("hashes", "test", "hash_type='bdb',dir='.'");

to read

      storage=librdf_new_storage("hashes", "test", "hash_type='memory',dir='.'");

### 3.1. example1.c

`example1` uses a RDF parser, if you have one available, to parse a URI of RDF/XML content, store it in multple Berkeley DB hashes on the disk and run queries against them. It takes two arguments, the first the URI of the RDF/XML content (or `file:` filename) and the second, optional one, is the name of the RDF parser to use. At present these can be `sirpac` or `libwww`

### 3.2. example2.c

`example2` does not use a RDF parser, but reads from a simple triple dump format and again stores the data on disk in multiple Berkeley DB hashes.

### 3.3. example3.c

`example3` contains a 10 line main program that creates an RDF model, a statement, adds it to the model and stores it on disk.

### 3.4. example4.c

`example4` is a utility that allows the parsing, printing and querying of an existing on disk Berkeley DB-stored RDF model by statement; source, arc or target node and allows the addition and removal of statements. To see a usage message type:

      example4

For example, to parse some RDF/XML using the repat parser into a BerkeleyDB store, print it, do some queries, you could do the following (some lines broken for clarity)

    $ cd examples
    $ example4 test parse file:../perl/dc.rdf repat
    example4: Parsing URI file:../perl/dc.rdf with repat parser

    $ example4 test print
    [[
      {[http://purl.org/net/dajobe/], [http://purl.org/dc/elements/1.1/title], "Dave Beckett's Home Page"}
      {[http://purl.org/net/dajobe/], [http://purl.org/dc/elements/1.1/creator], "Dave Beckett"}
      {[http://purl.org/net/dajobe/], [http://purl.org/dc/elements/1.1/description], "The generic home page\
    of Dave Beckett."}
    ]]

    $ example4 test targets http://purl.org/net/dajobe/ http://purl.org/dc/elements/1.1/title
    Matched node: Dave Beckett's Home Page
    example4: matching nodes: 1

    $ example4 test statements http://purl.org/net/dajobe/ - -
    Matched statement: {[http://purl.org/net/dajobe/], [http://purl.org/dc/elements/1.1/title], "Dave Becke\
    tt's Home Page"}
    Matched statement: {[http://purl.org/net/dajobe/], [http://purl.org/dc/elements/1.1/creator], "Dave Bec\
    kett"}
    Matched statement: {[http://purl.org/net/dajobe/], [http://purl.org/dc/elements/1.1/description], "The \
    generic home page of Dave Beckett."}
    example4: matching statements: 3

## 3. Using the Perl interface

See the Redland Perl Interface document for full information on installing and using Redland from Perl.

## 4. Using the Python interface

See the Redland Python Interface document for full information on installing and using Redland from Python.

## 5. Using the Tcl interface

See the Redland Tcl Interface document for full information on installing and using Redland from Tcl, and/or Tcl/Tk.

## 6. Using the Java interface

See the Redland Java Interface document for full information on installing and using Redland from Java.

## 7. Using the Ruby interface

See the Redland Ruby Interface document for full information on installing and using Redland from Ruby.

## 8. Using the PHP interface

See the Redland PHP Interface document for full information on installing and using Redland from PHP.

Copyright 2000-2001 Dave Beckett, Institute for Learning and Research Technology, University of Bristol