Subsections

- Prerequisites
- Building on Mac OS X
- Building on Microsoft Windows
- Building from tarball
- Building darcs from the repository
- Submitting patches to darcs

# Building darcs

This chapter should walk you through the steps necessary to build darcs for yourself. There are in general two ways to build darcs. One is for building released versions from tarballs, and the other is to build the latest and greatest darcs, from the darcs repo itself.

Please let me know if you have any problems building darcs, or don't have problems described in this chapter and think there's something obsolete here, so I can keep this page up-to-date.

# Prerequisites

To build darcs you will need to have `ghc`, the Glorious Glasgow Haskell Compiler. You should have at the very minimum version 6.4.

It is a good idea (but not required) to have software installed that provide darcs network access. The `libwww-dev`, `libwww-ssl-dev` or `libcurl` packages newer than than 7.18.0 are recommended because they provide pipelining support speed up HTTP access. They have to be explicitly chosen with `-with-libwww` or `-with-curl-pipelining`. Otherwise, darcs will automatically look for one of libcurl, `curl` or `wget`. You also might want to have scp available if you want to grab your repos over ssh...

To use the `diff` command of darcs, a `diff` program supporting options `-r` (recursive diff) and `-N` (show new files as differences against an empty file) is required. The `configure` script will look for `gdiff`, `gnudiff` and `diff` in this order. You can force the use of another program by setting the `DIFF` environment variable before running `configure`.

To rebuild the documentation (which should not be necessary since it is included in html form with the tarballs), you will need to have latex installed, as well as latex2html if you want to build it in html form.

# Building on Mac OS X

To build on Mac OS X, you will need the Apple Developer Tools and the ghc 6.4 package installed.

# Building on Microsoft Windows

To build on Microsoft Windows, you will need:

- MinGW which provides the GCC toolchain for win32.
- MSYS which provides a unix build environment for win32. Be sure to download the separate msysDTK, autoconf and automake.
- zlib-1.2.1+ library and headers.
- curl-7.12.2+ library and headers.
- If building with an SSL enabled curl you will need the OpenSSL libraries, unofficial builds are available at
  http://www.slproweb.com/products/Win32OpenSSL.html.

Copy the zlib and curl libraries and headers to both GHC and MinGW. GHC stores C headers in `<ghc-dir>/gcc-lib/include` and libraries in `<ghc-dir>/gcc-lib`. MinGW stores headers in `<mingw-dir>/include` and libraries in `<mingw-dir>/lib`.

Set PATH to include the `<msys-dir>/bin`, `<mingw-dir>/bin`, `<curl-dir>`, and a directory containing a pre-built darcs.exe if you want the build's patch context stored for ``darcs --exact-version`'.

    C:\darcs> cd <darcs-source-dir>
    C:\darcs> sh

    $ export GHC=/c/<ghc-dir>/bin/ghc.exe
    $ autoconf
    $ ./configure --target=mingw
    $ make

# Building from tarball

If you get darcs from a tarball, the procedure (after unpacking the tarball itself) is as follows:

    % ./configure
    % make
    # Optional, but recommended
    % make test
    % make install

There are options to configure that you may want to check out with

    % ./configure --help

If your header files are installed in a non-standard location, you may need to define the `CFLAGS` and `CPPFLAGS` environment variables to include the path to the headers. e.g. on NetBSD, you may need to run

    % CFLAGS=-I/usr/pkg/include CPPFLAGS=-I/usr/pkg/include ./configure

# Building darcs from the repository

To build the latest darcs from its repository, you will first need a working copy of Darcs 2. You can get darcs using:

    % darcs get -v http://darcs.net/

and once you have the darcs repository you can bring it up to date with a

    % darcs pull

The repository doesn't hold automatically generated files, which include the configure script and the HTML documentation, so you need to run `autoconf` first.

You'll need `autoconf` 2.50 or higher. Some systems have more than one version of `autoconf` installed. For example, `autoconf` may point to version 2.13, while `autoconf259` runs version 2.59.

Also note that `make` is really "GNU make". On some systems, such as the *BSDs, you may need to type `gmake` instead of make for this to work.

If you want to create readable documentation you'll need to have latex installed.

    % autoconf
    % ./configure
    % make
    % make install

If you want to tweak the configure options, you'll need to run `./configure` yourself after the make, and then run make again.

# Submitting patches to darcs

I know, this doesn't really belong in this chapter, but if you're using the repository version of darcs it's really easy to submit patches to me using darcs. In fact, even if you don't know any Haskell, you could submit fixes or additions to this document (by editing `building_darcs.tex`) based on your experience building darcs...

To do so, just record your changes (which you made in the darcs repository)

    % darcs record --no-test

making sure to give the patch a nice descriptive name. The `--no-test` options keeps darcs from trying to run the unit tests, which can be rather time-consuming. Then you can send the patch to the darcs-devel mailing list by email by

    % darcs send

If you are using darcs 2.0.0 or earlier, please use

    % darcs send -u

instead. The darcs repository stores the email address to which patches should be sent by default. The email address you see is actually my own, but when darcs notices that you haven't signed the patch with my GPG key, it will forward the message to darcs-devel.