<partintro>
  <para>Having a dictionary database fulfilling the
    requirements for inclusion into FreeDict, here you find the background
    and the steps to get your dictionary into FreeDict.</para>
</partintro>

<chapter>
  <title>FreeDict Build System</title>

  <figure>
    <title>Overview of the FreeDict Build System</title>
    <mediaobject>
      <imageobject>
	<imagedata fileref="build-system-overview.png" format="PNG"/>
      </imageobject>
      <imageobject>
	<imagedata fileref="build-system-overview.svg" format="SVG"/>
      </imageobject>
      <textobject>
	<phrase>Overview of the FreeDict Build System</phrase>
      </textobject>
      <caption>
	<para>The data flow from the point of view of the FreeDict Build System
	  originates in the FreeDict CVS repository. From there checkouts are
	  made to buildhosts, where the data is converted to the formats of
	  the supported platforms and where the FreeDict website is generated.
	  The most interesting metadata is collected in an XML file. That is used
	  to build the download and details pages on the FreeDict website. Other
	  projects may use that XML file to find out about new releases of the
	  FreeDict databases.</para>
      </caption>
    </mediaobject>
  </figure>

  <para>A strength of FreeDict is its support for different dictionary
    platforms. Once a dictionary is available in TEI format, it can be
    converted to many other formats, to be used with dictionary applications,
    spell checkers (for this only the headwords or translation equivalents are taken),
    for printing a book using XSL-FO etc.</para>
  <note>
    <para>Support for aspell and XSL-FO is still a wish.</para>
  </note>
  <para>This is enabled by two factors. First, XML is purposely very flexible.
    Second, the tools for converting the TEI files are kept in one place
    (the <literal>tools</literal> module) and are shared between the dictionary
    modules.</para> 

  <para>The backbone of the FreeDict build system is the file
    <filename>Makefile.common</filename> in the <literal>tools</literal> module.
    It is designed to be included by the <filename>Makefile</filename> of each
    dictionary module.</para>
  <para>Every <filename>Makefile</filename> of a dictionary module should start with
    these lines:</para>

  <programlisting>FREEDICTDIR ?= ..

# Adjust per dictionary variables like DISTFILES, TEI2DICTFLAGS, DICTFMTFLAGS etc.
DISTFILES = la1-la2.tei README Makefile NEWS

include $(FREEDICTDIR)/tools/Makefile.common

# Optional, space separated list of platform identifiers:
# Default: all supported
# UNSUPPORTED_PLATFORMS = evolutionary bedic

# Add targets specific for this dictionary module,
# eg. instructions how to create the TEI file from
# another source format.
</programlisting>

  <para>In the first line, <envar>FREEDICTDIR</envar> is per default set to the
    parent directory. If you have set <envar>FREEDICTDIR</envar> to something
    else, that value will be used. In the next lines you can optionally adjust
    some variables. After that, the <filename>Makefile.common</filename> is
    included from the <filename>tools</filename> subdirectory of the FreeDict
    directory.</para>
  <para><filename>Makefile.common</filename> provides the support for the
    following targets (as well as some more internally used targets):</para>

  <variablelist><title>public targets in <filename>Makefile.common</filename></title>
    <varlistentry>
      <term><literal>validation</literal></term>
      <listitem>
	<para>validates the TEI file of the dictionary module.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>find-homographs</literal></term>
      <listitem>
	<para>Looks for "double-entries" in the TEI file of the dictionary
	  module, ie. entries with headwords that follow the same
	  orthography.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>test</literal></term>
      <term><literal>test-reverse</literal></term>
      <listitem>
	<para>tests whether all words can be looked up from the dictionary
	  in dictd by extracting a list of headwords, starting a
	  <application>dictd</application> server and looking up each headword
	  in turn</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>release-dict-tgz</literal></term>
      <term><literal>release-dict-tgz-reverse</literal></term>
      <term><literal>release-dict-tbz2</literal></term>
      <term><literal>release-dict-tbz2-reverse</literal></term>
      <term><literal>release-dict-tbz2-c5</literal></term>
      <term><literal>release-dict-tbz2-c5-reverse</literal></term>
      <term><literal>release-evolutionary</literal></term>
      <term><literal>release-rpm</literal></term>
      <term><literal>release-bedic</literal></term>
      <term><literal>release-zaurus</literal></term>
      <listitem>
	<para>puts a release file for the specified platform into the
	  corresponding directory of <filename>$(FREEDICTDIR)/release</filename>.
	</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>query-<replaceable>PLATFORM</replaceable></literal></term>
      <listitem>
	Make will exit with an error message and an exit status of 1 if the
	<replaceable>PLATFORM</replaceable> in question is not supported by
	this dictionary module. Which platforms are supported is determined by
	the <literal>UNSUPPORTED_PLATFORMS</literal> variable. This target is
	used by the
	<literal>release-<replaceable>PLATFORM</replaceable></literal> targets
	as a guard to prevent builds for unsupported platforms. The support
	status information is also saved in
	<filename>freedict-database.xml</filename>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>dist</literal></term>
      <listitem>
	<para>puts a release file of the dictionary module source into
	  <filename>$(FREEDICTDIR)/release/src</filename>.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>commit</literal></term>
      <listitem>
	<para>shortcut for <command>cvs -z3 commit</command>. The <option>-z3</option>
	  is forgotten too often.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>version</literal></term>
      <term><literal>sourceURL</literal></term>
      <term><literal>status</literal></term>
      <listitem>
	<para>extracts these pieces from the TEI header and prints them
	  on STDOUT. Used during <literal>dbupdate</literal>.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>dbupdate</literal></term>
      <listitem>
	<para>extracts interesting information from the dictionary module
	  and writes it into <filename>freedict-database.xml</filename>.</para>
      </listitem>
      </varlistentry>
      <varlistentry>
	<term><literal>all</literal></term>
	<listitem>
	  <para>default target. It currently converts to dictd database format
	    without packaging the result as a release. In the future it would
	    make sense to generate the files for all supported platforms when
	    this target is invoked.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><literal>clean</literal></term>
	<listitem>
	  <para>removes the non-source files generated during the build of
	    anything from the dictionary module.</para>
	</listitem>
      </varlistentry>
    </variablelist>
  </chapter>

  <chapter>
    <title>The FreeDict CVS Repository</title>
    <para>The <ulink url="http://sourceforge.net/cvs/?group_id=1419">FreeDict CVS
      Repository</ulink> is provided by <ulink url="http://sourceforge.net/">SourceForge</ulink>.
      The repository name as specified to the <command>cvs</command> command is
      <literal>freedict.cvs.sourceforge.net:/cvsroot/freedict</literal>. SourceForge provides two
      different access methods, <literal>ext</literal> (using SSH) for developers and
      <literal>pserver</literal> for anonymous read-only access.</para>
      
    <para>The modules in the repository fall into two groups: <firstterm>dictionary
     modules</firstterm> and <firstterm>"special modules"</firstterm>. Special modules
     are presently only the <filename>tools</filename>
     and <literal>howto</literal> module. The former contains conversion scripts, XSLT
     stylesheets, test scripts etc. used by most dictionary modules. The latter contains
     the XML source of this HOWTO.</para>
    <note>
      <title>Unused modules</title>
      <para>The following modules are unused: <filename>website, htdocs, spa-spa,
	eng-ger, ger-eng</filename>. One of the first two should be reactivated,
	though.</para>
    </note>

    <section>
      <title>Naming convention for dictionary modules</title>
      <para>For naming the dictionary modules and their TEI files we use the format
	<filename><replaceable>la1</replaceable>-<replaceable>la2</replaceable>.tei</filename>,
	where <replaceable>la1</replaceable> and <replaceable>la2</replaceable>
	are <ulink url="http://www.w3.org/WAI/ER/IG/ert/iso639.htm">ISO
	  639-2/T</ulink> 3-letter language codes (ISO 639-1 defines the two
	letter codes; the "T" stands for "Terminology"). See also the <ulink
	  url="http://www.loc.gov/standards/iso639-2/">ISO
	  639-2 Registration Authority</ulink>, where this standard is
	made.</para>
    </section>

    <section>
      <title>Importing new dictionary modules</title>
      <para>If you are a developer of FreeDict and have write access to the
	repository, you can import this way:</para>

      <para><userinput>cd <replaceable>la1</replaceable>-<replaceable>la2</replaceable></userinput></para>

      <para>This step assumed you keep all files related to your new
	dictionary in a directory
	<filename><replaceable>la1</replaceable>-<replaceable>la2</replaceable></filename>,
	obviously.</para>

      <warning>
	<para>Importing has to be done from the directory itself, otherwise CVS will
	  create an ugly subdirectory like <filename>la1-la2/la1-la2</filename>
	  that will not be removable from CVS again (it contents can be removed, but
	  not the directory itself) - so please be careful!</para>
      </warning>

      <para><userinput>cvs -z3 -d:ext:<replaceable>developername</replaceable>@freedict.cvs.sourceforge.net:/cvsroot/freedict import <replaceable>la1</replaceable>-<replaceable>la2</replaceable> <replaceable>vendortag</replaceable> <replaceable>releasetag</replaceable></userinput></para>

      <para>If your dictionary doesn't come from another place, you can invent dummy values
	for <replaceable>vendortag</replaceable> and <replaceable>releasetag</replaceable>.
	Otherwise, use them as intended by <application>CVS</application>: If you
	import files from some upstream project, use that project's
	name as <replaceable>vendortag</replaceable> and that project's release version
	as <replaceable>releasetag</replaceable>.</para>
    
      <para>If you do not have CVS write access, ask a developer to import your
	TEI file (or eventual code to create the TEI file from a different format)
	into the FreeDict CVS repository.</para>
      <note><para>At present it is still undefined whether to import a TEI file as
	  well, when it can be made from other sources. The cleanest solution in such
	  case would be not to import it, but to import the sources and create
	  a file release of the TEI file.</para></note>
    </section>

  </chapter>

  <chapter>
    <title>FreeDict Build Tree</title>
    <para>If you have a directory containing the tools module as well as one or
      more dictionary modules, you already have a FreeDict build tree.</para>
    <para>If you sometimes work on dictionary modules outside the FreeDict
      build tree (hey, it is a synonym of FREEDICTDIR!), you can set up
      the environment variable <envar>FREEDICTDIR</envar> to point to that
      directory. Afterwards the <filename>Makefile</filename> will be able to
      find the <filename>tools</filename> directory.</para>
    
    <para>There also is a special kind of build tree, the <firstterm>release build
      tree</firstterm>. This tree does not contain the latest CVS revisions of
      all files, but it is intended to contain only the revisions that the
      maintainers of the dictionary modules have marked as stable. For more
      information, please refer to the <filename>manage-buildtree.pl</filename>
      script in the <filename>tools</filename> directory.</para>
  </chapter>


