### 1.4 Installation and porting ¶

#### 1.4.1 Installation ¶

Blitz++ uses GNU Autoconf, which handles rewriting Makefiles for various platforms and compilers. It has greatly simplified installation and porting. Many thanks to John W. Eaton and Brendan Kehoe for their help with this.

To install blitz, unpack the `blitz-VERSION.tar.gz` file (it will install into a subdirectory `blitz-VERSION`). For example:

    [tveldhui@n2001:~] 32: ls -l blitz*.gz
    -rw-r--r--   1 tveldhui users      480953 Jun 23 15:20 blitz-0.5.tar.gz
    [tveldhui@n2001:~] 33: gunzip blitz-0.5.tar.gz
    [tveldhui@n2001:~] 34: tar xvf blitz-0.5.tar
    blitz-0.5/CHANGELOG
    blitz-0.5/COPYING
    blitz-0.5/INSTALL
    blitz-0.5/Makefile.in
    blitz-0.5/README
    blitz-0.5/THANKS
      .
      .

Then go into the `blitz-VERSION` directory, and type:

    ./configure CXX=[compiler]

where [compiler] is one of `xlc++`, `icpc`, `pathCC`, `xlC`, `cxx`, `aCC`, `CC`, `g++`, `KCC`, `pgCC` or `FCC`. (If you do not choose a C++ compiler, the configure script will attempt to find an appropriate compiler for the current platform.)

By default, the configure script will use a particular set of options with each C++ compiler. You can disable these default settings and then substitute your own preferred compiler options with the CXXFLAGS variable, using this syntax:

    ./configure CXX=g++ --disable-cxx-flags-preset CXXFLAGS="-ftemplate-depth-50"

If you are interested in benchmarking, you may want to use the option `--with-blas=...` to specify the path where the blas library is found. Run the configure script with the option `--help` to see all the available options.

Once the configure script is done, you can do any of these things:

`make lib`

  Check the compiler and create `libblitz.a`.

`make check-testsuite`

  Make the blitz library plus build and run the testsuite.

`make check-examples`

  Make the blitz library plus build and run the examples.

`make check-benchmarks`

  Make the blitz library plus build and run the benchmarks.

`make all`

  Do all of the above. This may take a long time.

`make install`

  Build the blitz library and documentation and install, along with the blitz header files, in prefix directory.

Building the benchmark programs requires both a Fortran 77 and Fortran 90 compiler.

#### 1.4.2 The Blitz++ directory tree ¶

The main Blitz++ directory contains these subdirectories:

`blitz`

  Blitz++ headers and source code files

`random`

  Random number generators

`src`

  Source code for `libblitz.a`

`lib`

  Location of `libblitz.a`

`doc`

  Documentation in HTML and PostScript

`testsuite`

  Testsuite programs

`examples`

  Example programs

`benchmarks`

  Benchmark programs

#### 1.4.3 Porting Blitz++ ¶

If you want to try porting Blitz++ to a new compiler or platform, I suggest the following approach:

- First check the Blitz++ web page to make sure you have the latest snapshot, and that someone hasn’t already ported blitz to your platform.
- Install autoconf (from e.g. ftp://prep.ai.mit.edu/pub/gnu) if you don’t have it already.
- Run the configure script with CXX=[compiler]. This will exercise your compiler to see what language features it supports. If it doesn’t have member templates and enum computations, just give up. You may need to set CXXFLAGS to use compiler options that enable some language features.
- Once you know what compiler options are needed, you can make these the default settings for your C++ compiler. Make a backup of `m4/ac_cxx_flags_preset.m4`, and then edit the file to add an appropriate case for your compiler. Invoke autoconf to regenerate the configure script. Then try configure with your new preset flags.