1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Installing</title>
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
<link rel="start" href="../../index.html" title="Boost.Build V2 User Manual">
<link rel="up" href="../tasks.html" title="Chapter5.Common tasks">
<link rel="prev" href="alias.html" title="Alias">
<link rel="next" href="../builtins/testing.html" title="Testing">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="alias.html"><img src="../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../tasks.html"><img src="../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="../builtins/testing.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="bbv2.tasks.installing"></a>Installing</h2></div></div></div>
<p>This section describes various ways to install built target
and arbitrary files.</p>
<h3>
<a name="id2590372"></a>Basic install</h3>
<p>For installing a built target you should use the
<code class="computeroutput">install</code> rule, which follows the <a href="../advanced/targets.html#bbv2.main-target-rule-syntax">common syntax</a>. For
example:
</p>
<pre class="programlisting">
install dist : hello helpers ;
</pre>
<p>
will cause the targets <code class="computeroutput">hello</code> and <code class="computeroutput">helpers</code> to
be moved to the <code class="filename">dist</code> directory, relative to
Jamfile's directory. The directory can
be changed with the <code class="computeroutput">location</code> property:
</p>
<pre class="programlisting">
install dist : hello helpers : <location>/usr/bin ;
</pre>
<p>
While you can achieve the same effect by changing the target name to
<code class="filename">/usr/bin</code>, using the <code class="computeroutput">location</code>
property is better, because it allows you to use a mnemonic target
name.
</p>
<p>The <code class="computeroutput">location</code> property is especially handy when the location
is not fixed, but depends on build variant or environment variables:
</p>
<pre class="programlisting">
install dist : hello helpers : <variant>release:<location>dist/release
<variant>debug:<location>dist/debug ;
install dist2 : hello helpers : <location>$(DIST) ;
</pre>
<p>
See also <a href="../reference/definitions.html#bbv2.reference.variants.propcond" title="Conditional properties">conditional
properties</a> and <a href="../faq/envar.html" title="
Accessing environment variables
">environment variables</a>
</p>
<h3>
<a name="id2590501"></a>Installing with all dependencies</h3>
<p>
Specifying the names of all libraries to install can be boring. The
<code class="computeroutput">install</code> allows you to specify only the top-level executable
targets to install, and automatically install all dependencies:
</p>
<pre class="programlisting">
install dist : hello
: <install-dependencies>on <install-type>EXE
<install-type>LIB
;
</pre>
<p>
will find all targets that <code class="computeroutput">hello</code> depends on, and install
all of those which are either executables or libraries. More
specifically, for each target, other targets that were specified as
sources or as dependency properties, will be recursively found. One
exception is that targets referred with the <a href="../advanced/builtins/features.html#bbv2.builtin.features.use"><code class="computeroutput">use</code></a> feature
are not considered, because that feature is typically used to refer to
header-only libraries.
If the set of target types is specified, only targets of that type
will be installed, otherwise, all found target will be installed.
</p>
<h3>
<a name="id2590560"></a>Preserving Directory Hierarchy</h3>
<p>By default, the <code class="computeroutput">install</code> rules will stip paths from
it's sources. So, if sources include <code class="filename">a/b/c.hpp</code>,
the <code class="filename">a/b</code> part will be ignored. To make the
<code class="computeroutput">install</code> rule preserve the directory hierarchy you need
to use the <code class="computeroutput">install-source-root</code> feature to specify the
root of the hierarchy you are installing. Relative paths from that
root will be preserved. For example, if you write:
</p>
<pre class="programlisting">
install headers
: a/b/c.h
: <location>/tmp <install-source-root>a
;
</pre>
<p>
the a file named <code class="filename">/tmp/b/c.h</code> will be created.
</p>
<h3>
<a name="id2590624"></a>Installing into Several Directories</h3>
<p>The <a href="alias.html" title="Alias"><code class="computeroutput">alias</code></a>
rule can be used when targets must be installed into several
directories:
</p>
<pre class="programlisting">
alias install : install-bin install-lib ;
install install-bin : applications : /usr/bin ;
install install-lib : helper : /usr/lib ;
</pre>
<p>
</p>
<p>Because the <code class="computeroutput">install</code> rule just copies targets, most
free features <sup>[<a name="id2590665" href="#ftn.id2590665">5</a>]</sup>
have no effect when used in requirements of the <code class="computeroutput">install</code> rule.
The only two which matter are
<a href="../advanced/builtins/features.html#bbv2.builtin.features.dependency">
<code class="varname">dependency</code></a> and, on Unix,
<a href="../advanced/builtins/features.html#bbv2.reference.features.dll-path"><code class="varname">dll-path</code></a>.
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../doc/html/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
(Unix specific). On Unix, executables built with Boost.Build typically
contain the list of paths to all used dynamic libraries. For
installing, this is not desired, so Boost.Build relinks the executable
with an empty list of paths. You can also specify additional paths for
installed executables with the <code class="varname">dll-path</code> feature.
</p></td></tr>
</table></div>
<div class="footnotes">
<br><hr width="100" align="left">
<div class="footnote"><p><sup>[<a name="ftn.id2590665" href="#id2590665">5</a>] </sup>see the definition of "free" in <a href="../reference/definitions.html#bbv2.reference.features.attributes" title="Feature Attributes">the section called “Feature Attributes”</a>.</p></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><small></small></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="alias.html"><img src="../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../tasks.html"><img src="../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="../builtins/testing.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a>
</div>
</body>
</html>
|