Eliminate / replace remaining cPickle references in test scripts.
[scons.git] / doc / user / alias.xml
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   <programlisting>
34      env = Environment()
35      hello = env.Program('hello.c')
36      env.Install('/usr/bin', hello)
37      env.Alias('install', '/usr/bin')
38   </programlisting>
39
40   <para>
41
42   You can then use this alias on the command line
43   to tell &SCons; more naturally that you want to install files:
44
45   </para>
46
47   <screen>
48      % <userinput>scons -Q install</userinput>
49      cc -o hello.o -c hello.c
50      cc -o hello hello.o
51      Install file: "hello" as "/usr/bin/hello"
52   </screen>
53
54   <para>
55
56   Like other &Builder; methods, though,
57   the &Alias; method returns an object
58   representing the alias being built.
59   You can then use this object as input to anothother &Builder;.
60   This is especially useful if you use such an object
61   as input to another call to the &Alias; &Builder;,
62   allowing you to create a hierarchy
63   of nested aliases:
64
65   </para>
66
67   <programlisting>
68      env = Environment()
69      p = env.Program('foo.c')
70      l = env.Library('bar.c')
71      env.Install('/usr/bin', p)
72      env.Install('/usr/lib', l)
73      ib = env.Alias('install-bin', '/usr/bin')
74      il = env.Alias('install-lib', '/usr/lib')
75      env.Alias('install', [ib, il])
76   </programlisting>
77
78   <para>
79
80   This example defines separate <literal>install</literal>,
81   <literal>install-bin</literal>,
82   and <literal>install-lib</literal> aliases,
83   allowing you finer control over what gets installed:
84
85   </para>
86
87   <screen>
88      % <userinput>scons -Q install-bin</userinput>
89      cc -o foo.o -c foo.c
90      cc -o foo foo.o
91      Install file: "foo" as "/usr/bin/foo"
92      % <userinput>scons -Q install-lib</userinput>
93      cc -o bar.o -c bar.c
94      ar rc libbar.a bar.o
95      ranlib libbar.a
96      Install file: "libbar.a" as "/usr/lib/libbar.a"
97      % <userinput>scons -Q -c /</userinput>
98      Removed foo.o
99      Removed foo
100      Removed /usr/bin/foo
101      Removed bar.o
102      Removed libbar.a
103      Removed /usr/lib/libbar.a
104      % <userinput>scons -Q install</userinput>
105      cc -o foo.o -c foo.c
106      cc -o foo foo.o
107      Install file: "foo" as "/usr/bin/foo"
108      cc -o bar.o -c bar.c
109      ar rc libbar.a bar.o
110      ranlib libbar.a
111      Install file: "libbar.a" as "/usr/lib/libbar.a"
112   </screen>