<page xmlns="http://projectmallard.org/1.0/" type="guide" id="libraries">
<info>
    <link type="guide" xref="index#recipes"/>
</info>

<title>Libraries</title>

<p>
A <em>library</em> is a piece of executable code that can be shared between different <link xref="programs">programs</link>.
</p>
<p>
To specify a library you need to set <code>libraries.<em>id</em>.*</code> <link xref="variables">variables</link> where <em>id</em> is a unique ID for the library.
The following variables are allowed:
</p>
<table frame="all" shade="rows">
<thead>
<tr>
  <td><p>Name</p></td>
  <td><p>Description</p></td>
</tr>
</thead>
<tr>
  <td><p>name</p></td>
  <td><p>The name of this library (optional, defaults to the ID)</p></td>
</tr>
<tr>
  <td><p>compiler</p></td>
  <td><p>Compiler to compile with (optional, defaults to automatic detection)</p></td>
</tr>
<tr>
  <td><p>sources</p></td>
  <td><p>The files that make up this library (required)</p></td>
</tr>
<tr>
  <td><p>version</p></td>
  <td><p>The version of the library</p></td>
</tr>
<tr>
  <td><p>install</p></td>
  <td><p>If this library should be installed into the system (defaults to true)</p></td>
</tr>
<tr>
  <td><p>install-directory</p></td>
  <td><p>Directory to install the library to (defaults to system directory)</p></td>
</tr>
<tr>
  <td><p>gettext-domain</p></td>
  <td><p>Translation domain to use for translatable strings</p></td>
</tr>
</table>
<note>
<p>
The ID must be a valid variable name and cannot contain period characters.
If you require period characters set the <em>name</em> variable.
</p>
</note>
<p>
Bake will attempt to <link xref="building">build</link> your library by checking the filenames in the <code>sources</code> variable and generating the required <link xref="rules">rules</link>.
Depending on what <link xref="index#programs-and-libraries">language</link> your library uses additional variables may be allowed.
</p>
<example>
<p>
The following describes a simple <link xref="c">C library</link> that is built from one C file:
</p>
<code>
libraries.lib1 {
  sources = lib1.c
}
</code>
<p>
When building Bake will compile lib1.c and produce the library <em>lib1</em>.
When <link xref="installing">installing</link> Bake will install <em>lib1</em> into the appropriate directory.
</p>
</example>
</page>
