Deprecate $WIN32 variables name in place of $WINDOWS* variables names, and eliminate...
[scons.git] / doc / user / alias.in
1 <!--
2
3   __COPYRIGHT__
4
5   Permission is hereby granted, free of charge, to any person obtaining
6   a copy of this software and associated documentation files (the
7   "Software"), to deal in the Software without restriction, including
8   without limitation the rights to use, copy, modify, merge, publish,
9   distribute, sublicense, and/or sell copies of the Software, and to
10   permit persons to whom the Software is furnished to do so, subject to
11   the following conditions:
12
13   The above copyright notice and this permission notice shall be included
14   in all copies or substantial portions of the Software.
15
16   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17   KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18   WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20   LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 -->
25
26   <para>
27
28   We've already seen how you can use the &Alias;
29   function to create a target named <literal>install</literal>:
30
31   </para>
32
33   <scons_example name="ex1">
34      <file name="SConstruct" printme="1">
35      env = Environment()
36      hello = env.Program('hello.c')
37      env.Install('__ROOT__/usr/bin', hello)
38      env.Alias('install', '__ROOT__/usr/bin')
39      </file>
40      <file name="hello.c">
41      int main() { printf("Hello, world!\n"); }
42      </file>
43   </scons_example>
44
45   <para>
46
47   You can then use this alias on the command line
48   to tell &SCons; more naturally that you want to install files:
49
50   </para>
51
52   <scons_output example="ex1" os="posix">
53      <scons_output_command>scons -Q install</scons_output_command>
54   </scons_output>
55
56   <para>
57
58   Like other &Builder; methods, though,
59   the &Alias; method returns an object
60   representing the alias being built.
61   You can then use this object as input to anothother &Builder;.
62   This is especially useful if you use such an object
63   as input to another call to the &Alias; &Builder;,
64   allowing you to create a hierarchy
65   of nested aliases:
66
67   </para>
68
69   <scons_example name="ex2">
70      <file name="SConstruct" printme="1">
71      env = Environment()
72      p = env.Program('foo.c')
73      l = env.Library('bar.c')
74      env.Install('__ROOT__/usr/bin', p)
75      env.Install('__ROOT__/usr/lib', l)
76      ib = env.Alias('install-bin', '__ROOT__/usr/bin')
77      il = env.Alias('install-lib', '__ROOT__/usr/lib')
78      env.Alias('install', [ib, il])
79      </file>
80      <file name="foo.c">
81      int main() { printf("foo.c\n"); }
82      </file>
83      <file name="bar.c">
84      void bar() { printf("bar.c\n"); }
85      </file>
86   </scons_example>
87
88   <para>
89
90   This example defines separate <literal>install</literal>,
91   <literal>install-bin</literal>,
92   and <literal>install-lib</literal> aliases,
93   allowing you finer control over what gets installed:
94
95   </para>
96
97   <scons_output example="ex2" os="posix">
98      <scons_output_command>scons -Q install-bin</scons_output_command>
99      <scons_output_command>scons -Q install-lib</scons_output_command>
100      <scons_output_command>scons -Q -c __ROOT__/</scons_output_command>
101      <scons_output_command>scons -Q install</scons_output_command>
102   </scons_output>