# Alias Targets

We've already seen how you can use the &Alias; function to create a target named `install`:

env = Environment() hello = env.Program('hello.c') env.Install('__ROOT__/usr/bin', hello) env.Alias('install', '__ROOT__/usr/bin')
int main() { printf("Hello, world!\n"); }

You can then use this alias on the command line to tell &SCons; more naturally that you want to install files:

scons -Q install

Like other &Builder; methods, though, the &Alias; method returns an object representing the alias being built. You can then use this object as input to anothother &Builder;. This is especially useful if you use such an object as input to another call to the &Alias; &Builder;, allowing you to create a hierarchy of nested aliases:

env = Environment() p = env.Program('foo.c') l = env.Library('bar.c') env.Install('__ROOT__/usr/bin', p) env.Install('__ROOT__/usr/lib', l) ib = env.Alias('install-bin', '__ROOT__/usr/bin') il = env.Alias('install-lib', '__ROOT__/usr/lib') env.Alias('install', [ib, il])
int main() { printf("foo.c\n"); }
void bar() { printf("bar.c\n"); }

This example defines separate `install`, `install-bin`, and `install-lib` aliases, allowing you finer control over what gets installed:

scons -Q install-bin
scons -Q install-lib
scons -Q -c __ROOT__/
scons -Q install