763c13e0cef784f47805f9b099c4138aac31bc62
[scons.git] / doc / user / build-install.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   This chapter will take you through the basic steps
29   of installing &SCons; on your system,
30   and building &SCons; if you don't have a
31   pre-built package available
32   (or simply prefer the flexibility of building it yourself).
33   Before that, however, this chapter will also describe the basic steps
34   involved in installing Python on your system,
35   in case that is necessary.
36   Fortunately, both &SCons; and Python
37   are very easy to install on almost any system,
38   and Python already comes installed on many systems.
39
40   </para>
41
42   <!--
43
44   <para>
45
46   Lastly, this chapter also contains a section that
47   provides a brief overview of the Python programming language,
48   which is the language used to implement &SCons;,
49   and which forms the basis of the &SCons; configuration files.
50   Becoming familiar with some Python concepts will make it easier
51   to understand many of the examples in this User's Guide.
52   Nevertheless, it <emphasis>is</emphasis> possible
53   to configure simple &SCons; builds without knowing Python,
54   so you can skip this section if you
55   want to dive in and pick up things
56   by example- -or, of course, if you are 
57   already familiar with Python.
58
59   </para>
60
61   -->
62
63   <section>
64   <title>Installing Python</title>
65
66     <para>
67
68     Because &SCons; is written in Python,
69     you must obviously have Python installed on your system
70     to use &SCons;
71     Before you try to install Python,
72     you should check to see if Python is already
73     available on your system  by typing
74     <userinput>python</userinput>
75     at your system's command-line prompt.
76     You should see something like the following
77     on a UNIX or Linux system that has Python installed:
78
79     </para>
80
81     <!--
82     Robert P.J. Day has suggested using "python -V",
83     but that's not supported in 1.5.2, so we're going
84     to leave this as is for now.
85     -->
86
87     <screen>
88        $ <userinput>python</userinput>
89        Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
90        [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
91        Type "help", "copyright", "credits" or "license" for more information.
92        >>> <userinput>^D</userinput>
93     </screen>
94
95     <para>
96
97     And on a Windows system with Python installed:
98
99     </para>
100
101     <screen>
102        C:\><userinput>python</userinput>
103        Python 2.2.2 (#34, Apr 9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
104        Type "help", "copyright", "credits" or "license" for more information.
105        >>> <userinput>^Z</userinput>
106     </screen>
107
108     <para>
109
110     The <prompt>>>></prompt> is the input prompt
111     for the Python interpreter.
112     The <userinput>^D</userinput> and <userinput>^Z</userinput>
113     represent the CTRL-D and CTRL-Z characters
114     that you will need to type to get out of the interpreter
115     before proceeding to installing &SCons;.
116
117     </para>
118
119     <para>
120
121     If Python is not installed on your system,
122     you will see an error message
123     stating something like "command not found"
124     (on UNIX or Linux)
125     or "'python' is not recognized
126     as an internal or external command, operable progam or batch file"
127     (on Windows).
128     In that case, you need to install Python
129     before you can install &SCons;.
130
131     </para>
132
133     <para>
134
135     The standard location for information
136     about downloading and installing Python is
137     <ulink url="http://www.python.org/download/">http://www.python.org/download/</ulink>.
138     See that page for information about
139     how to download and install Python on your system.
140
141     </para>
142
143   </section>
144
145   <section>
146   <title>Installing &SCons; From Pre-Built Packages</title>
147
148     <para>
149
150     &SCons; comes pre-packaged for installation on a number of systems,
151     including Linux and Windows systems.
152     You do not need to read this entire section,
153     you should only need to read the section
154     appropriate to the type of system you're running on.
155
156     </para>
157
158     <section>
159     <title>Installing &SCons; on Red Hat (and Other RPM-based) Linux Systems</title>
160
161       <para>
162
163       &SCons; comes in RPM (Red Hat Package Manager) format,
164       pre-built and ready to install on Red Hat Linux,
165       Fedora Core,
166       or any other Linux distribution that uses RPM.
167       Your distribution may
168       already have an &SCons; RPM built specifically for it;
169       many do, including SuSe, Mandrake and Fedora.
170       You can check for the availability of an &SCons; RPM
171       on your distribution's download servers,
172       or by consulting an RPM search site like
173       <ulink url="http://www.rpmfind.net/">http://www.rpmfind.net/</ulink> or
174       <ulink url="http://rpm.pbone.net/">http://rpm.pbone.net/</ulink>.
175
176       </para>
177
178       <para>
179
180       If your Linux distribution does not already have
181       a specific &SCons; RPM file,
182       you can download and install from the
183       generic RPM provided by the &SCons; project.
184       This will install the 
185       SCons script(s) in <filename>/usr/bin</filename>,
186       and the SCons library modules in
187       <filename>/usr/lib/scons</filename>.
188
189       </para>
190
191       <para>
192
193       To install from the command line, simply download the
194       appropriate <filename>.rpm</filename> file,
195       and then run:
196
197       </para>
198
199       <screen>
200         # <userinput>rpm -Uvh scons-0.96-1.noarch.rpm</userinput>
201       </screen>
202
203       <para>
204
205       Or, you can use a graphical RPM package manager
206       like <application>gnorpm</application>.
207       See your package manager application's documention
208       for specific instructions about
209       how to use it to install a downloaded RPM.
210
211       </para>
212
213     </section>
214
215     <section>
216     <title>Installing &SCons; on Debian Linux Systems</title>
217
218       <para>
219
220       Debian Linux systems use a different package management
221       format that also makes it very easy to install &SCons;.
222
223       </para>
224
225       <para>
226
227       If your system is connected to the Internet,
228       you can install the latest official Debian package
229       by running:
230
231       </para>
232
233       <screen>
234         # <userinput>apt-get install scons</userinput>
235       </screen>
236
237       <!--
238
239       <para>
240
241       Alternatively,
242       you can download the Debian package built
243       by the &SCons; project
244       and install it manually by running:
245
246       </para>
247
248       <screen>
249         # <userinput>db-XXX scons-*.deb</userinput>
250       </screen>
251
252       -->
253
254     </section>
255
256     <section>
257     <title>Installing &SCons; on Windows Systems</title>
258
259       <para>
260
261       &SCons; provides a Windows installer
262       that makes installation extremely easy.
263       Download the <filename>scons-0.95.win32.exe</filename>
264       file from the &SCons; download page at
265       <ulink url="http://www.scons.org/download.html">http://www.scons.org/download.html</ulink>.
266       Then all you need to do is execute the file
267       (usually by clicking on its icon in Windows Explorer).
268       These will take you through a small
269       sequence of windows that will install
270       &SCons; on your system.
271
272       <!--
273       Things are a little more complicated
274       if you are using the Cygwin version of Python.
275       This is because Cygwin
276       tries to make a Windows system look more
277       POSIX-like (or UNIX-like or Linux-like, if you prefer)
278       by having the Cygwin utilities,
279       including Cygwin Python,
280       interpret file name arguments on the command line
281       using the forward-slash (<filename>/</filename>)
282       as the directory separator,
283       instead of the normal Windows behavior of the
284       backslash (<filename>\</filename>) as the directory separator.
285       -->
286
287       </para>
288
289       <!--
290
291       <section>
292       <title>Installing &SCons; on Windows Systems Without Cygwin Python</title>
293
294         <para>
295
296         XXX
297
298         </para>
299
300       </section>
301
302       <section>
303       <title>Installing &SCons; on Windows Systems With Cygwin Python</title>
304
305         <para>
306
307         XXX
308
309         </para>
310
311       </section>
312
313       -->
314
315       <!--
316
317       XXX - don't have the kinks worked out on how to
318       get these to display properly in all formats,
319       so comment them out for now.
320
321       <screenshot>
322       <mediaobject>
323         <imageobject>
324           <imagedata fileref="SCons-win32-install-1.jpg" format="jpg" align="center">
325         </imageobject>
326       </mediaobject>
327       </screenshot>
328
329       <screenshot>
330       <mediaobject>
331         <imageobject>
332           <imagedata fileref="SCons-win32-install-2.jpg" format="jpg" align="center">
333         </imageobject>
334       </mediaobject>
335       </screenshot>
336
337       <screenshot>
338       <mediaobject>
339         <imageobject>
340           <imagedata fileref="SCons-win32-install-3.jpg" format="jpg" align="center">
341         </imageobject>
342       </mediaobject>
343       </screenshot>
344
345       <screenshot>
346       <mediaobject>
347         <imageobject>
348           <imagedata fileref="SCons-win32-install-4.jpg" format="jpg" align="center">
349         </imageobject>
350       </mediaobject>
351       </screenshot>
352
353       -->
354
355     </section>
356
357   </section>
358
359   <section>
360   <title>Building and Installing &SCons; on Any System</title>
361
362     <para>
363
364     If a pre-built &SCons; package is not available for your system,
365     then you can still easily build and install &SCons; using the native
366     Python <filename>distutils</filename> package.
367
368     </para>
369
370     <para>
371
372     The first step is to download either the
373     <filename>scons-__VERSION__.tar.gz</filename>
374     or <filename>scons-__VERSION__.zip</filename>,
375     which are available from the SCons download page at
376     <ulink url="http://www.scons.org/download.html">http://www.scons.org/download.html</ulink>.
377
378     </para>
379
380     <para>
381
382     Unpack the archive you downloaded,
383     using a utility like <application>tar</application>
384     on Linux or UNIX,
385     or <application>WinZip</application> on Windows.
386     This will create a directory called
387     <filename>scons-__VERSION__</filename>,
388     usually in your local directory.
389     Then change your working directory to that directory
390     and install &SCons; by executing the following commands:
391
392     </para>
393
394     <screen>
395       # <userinput>cd scons-__VERSION__</userinput>
396       # <userinput>python setup.py install</userinput>
397     </screen>
398
399     <para>
400
401     This will build &SCons;,
402     install the <application>scons</application> script
403     in the default system scripts directory
404     (<filename>/usr/local/bin</filename> or
405     <filename>C:\Python2.2\Scripts</filename>),
406     and will install the &SCons; build engine
407     in an appropriate stand-alone library directory
408     (<filename>/usr/local/lib/scons</filename> or
409     <filename>C:\Python2.2\scons</filename>).
410     Because these are system directories,
411     you may need root (on Linux or UNIX) or Administrator (on Windows)
412     privileges to install &SCons; like this.
413
414     </para>
415
416     <!--
417
418     <section>
419     <title>Building and Installing &SCons; in the Standard Python Library Directories</title>
420
421       <para>
422
423       XXX
424
425       </para>
426
427     </section>
428
429     -->
430
431     <section>
432     <title>Building and Installing Multiple Versions of &SCons; Side-by-Side</title>
433
434       <para>
435
436       The &SCons; <filename>setup.py</filename> script
437       has some extensions that support
438       easy installation of multiple versions of &SCons;
439       in side-by-side locations.
440       This makes it easier to download and
441       experiment with different versions of &SCons;
442       before moving your official build process to a new version,
443       for example.
444
445       </para>
446
447       <para>
448
449       To install &SCons; in a version-specific location,
450       add the <option>--version-lib</option> option
451       when you call <filename>setup.py</filename>:
452
453       </para>
454
455       <screen>
456         # <userinput>python setup.py install --version-lib</userinput>
457       </screen>
458
459       <para>
460
461       This will install the &SCons; build engine
462       in the
463       <filename>/usr/lib/scons-__VERSION__</filename>
464       or
465       <filename>C:\Python2.2\scons-__VERSION__</filename>
466       directory, for example.
467
468       </para>
469
470       <para>
471
472       If you use the <option>--version-lib</option> option
473       the first time you install &SCons;,
474       you do not need to specify it each time you install
475       a new version.
476       The &SCons; <filename>setup.py</filename> script
477       will detect the version-specific directory name(s)
478       and assume you want to install all versions
479       in version-specific directories.
480       You can override that assumption in the future
481       by explicitly specifying the <option>--standalone-lib</option> option.
482
483       </para>
484
485     </section>
486
487     <section>
488     <title>Installing &SCons; in Other Locations</title>
489
490       <para>
491
492       You can install &SCons; in locations other than
493       the default by specifying the <option>--prefix=</option> option:
494
495       </para>
496
497       <screen>
498         # <userinput>python setup.py install --prefix=/opt/scons</userinput>
499       </screen>
500
501       <para>
502
503       This would
504       install the <application>scons</application> script in
505       <filename>/opt/scons/bin</filename>
506       and the build engine in 
507       <filename>/opt/scons/lib/scons</filename>,
508
509       </para>
510
511       <para>
512
513       Note that you can specify both the <option>--prefix=</option>
514       and the <option>--version-lib</option> options
515       at the same type,
516       in which case <filename>setup.py</filename>
517       will install the build engine
518       in a version-specific directory
519       relative to the specified prefix.
520       Adding <option>--version-lib</option> to the
521       above example would install the build engine in
522       <filename>/opt/scons/lib/scons-__VERSION__</filename>.
523
524       </para>
525
526     </section>
527
528     <section>
529     <title>Building and Installing &SCons; Without Administrative Privileges</title>
530
531       <para>
532
533       If you don't have the right privileges to install &SCons;
534       in a system location,
535       simply use the <literal>--prefix=</literal> option
536       to install it in a location of your choosing.
537       For example,
538       to install &SCons; in appropriate locations
539       relative to the user's <literal>$HOME</literal> directory,
540       the <application>scons</application> script in
541       <filename>$HOME/bin</filename>
542       and the build engine in 
543       <filename>$HOME/lib/scons</filename>,
544       simply type:
545
546       </para>
547
548       <screen>
549         $ <userinput>python setup.py install --prefix=$HOME</userinput>
550       </screen>
551
552       <para>
553
554       You may, of course, specify any other location you prefer,
555       and may use the <option>--version-lib</option> option
556       if you would like to install version-specific directories
557       relative to the specified prefix.
558
559       </para>
560
561     </section>
562
563   </section>
564
565   <!--
566
567   <section>
568   <title>Python Basics</title>
569
570     <para>
571
572     This section will provide a brief overview of
573     the Python programming language.
574     Skip this section if you are already familiar with Python
575     (or you're really intent on diving into &SCons;
576     and just picking up things as you go).
577
578     </para>
579
580     <para>
581
582     Python has a lot of good
583     documentation freely available on-line
584     to help you get started.
585     The standard tutorial is available at XXX.
586
587
588     </para>
589
590     <para>
591
592     Python is very easy to pick up.
593
594     </para>
595
596     <para>
597
598     Python variables must be assigned to before they can be referenced.
599
600     </para>
601
602     <para>
603
604     Assignment is like most programming languages:
605
606     x = 1 + 2
607     z = 3 * x
608
609     </para>
610
611     <para>
612
613     Function calls look like most language function calls:
614
615     a = f(g)
616
617     </para>
618
619     <para>
620
621     Define functions like so:
622
623         def func(arg1, arg2):
624             return arg1 * arg 2
625
626     The number of parameters
627
628     </para>
629
630     <para>
631
632     Strings can be enclosed in single quotes or double quotes,
633     backslashes are used to escape characters,
634     triple-quote syntax lets you include quotes and newlines,
635     raw strings begin with 'r'.
636
637     </para>
638
639     <para>
640
641     Lists are enclosed in square brackets,
642     list items are separated by commas.
643     List references use square brackets and integer index values,
644     slice notation lets you select, delete or replace a range.
645
646     </para>
647
648     <para>
649
650     Dictionaries (hashes) are enclosed in curly brackets,
651     : separates keys from values,
652     , separates items.
653     Dictionary values are referenced using square brackets.
654
655     </para>
656
657     <para>
658
659     Access class attributes (including methods) using a '.'.
660
661     </para>
662
663     <para>
664
665     if: statements look like
666
667     elif: statements look like
668
669     else: statements look like
670
671     </para>
672
673     <para>
674
675     for: statements look like
676
677     while: statements look like
678
679     break statements look like
680     
681     continue statements look like
682
683     </para>
684
685     <para>
686
687     pass
688
689     </para>
690
691   </section>
692
693   -->