b72e43ce34adeca436dcb2159fb0025d562f66ae
[p5sagit/p5-mst-13.2.git] / INSTALL
1 =head1 NAME
2
3 Install - Build and Installation guide for perl5.
4
5 =head1 SYNOPSIS
6
7 The basic steps to build and install perl5 are:
8
9         rm -f config.sh
10         sh Configure
11         make
12         make test
13         make install
14
15 Each of these is explained in further detail below.
16
17 =head1 BUILDING PERL5
18
19 =head1 Start with a Fresh Distribution.
20
21 The results of a Configure run are stored in the config.sh file.  If
22 you are upgrading from a previous version of perl, or if you change
23 systems or compilers or make other significant changes, or if you are
24 experiencing difficulties building perl, you should probably I<not>
25 re-use your old config.sh.  Simply remove it or rename it, e.g.
26
27         mv config.sh config.sh.old
28         
29 Then run Configure.
30
31 =head1 Run Configure.
32
33 Configure will figure out various things about your system.  Some
34 things Configure will figure out for itself, other things it will ask
35 you about.  To accept the default, just press C<RETURN>.   The default
36 is almost always ok.
37
38 After it runs, Configure will perform variable substitution on all the
39 F<*.SH> files and offer to run B<make depend>.
40
41 Configure supports a number of useful options.  Run B<Configure -h>
42 to get a listing.  To compile with gcc, for example, you can run
43
44         sh Configure -Dcc=gcc
45
46 This is the preferred way to specify gcc (or another alternative
47 compiler) so that the hints files can set appropriate defaults.
48
49 If you are willing to accept all the defaults, and you want terse
50 output, you can run
51
52         sh Configure -des
53
54 By default, for most systems, perl will be installed in
55 /usr/local/{bin, lib, man}.  You can specify a different 'prefix' for
56 the default installation directory, when Configure prompts you or by
57 using the Configure command line option -Dprefix='/some/directory',
58 e.g.
59
60         Configure -Dprefix=/opt/local
61
62 By default, Configure will compile perl to use dynamic loading, if
63 your system supports it.  If you want to force perl to be compiled
64 statically, you can either choose this when Configure prompts you or by
65 using the Configure command line option -Uusedl.
66
67 =head2 GNU-style configure
68
69 If you prefer the GNU-style B<configure> command line interface, you can
70 use the supplied B<configure> command, e.g.
71
72         CC=gcc ./configure
73
74 The B<configure> script emulates several of the more common configure
75 options.  Try
76
77         ./configure --help
78
79 for a listing.
80
81 Cross compiling is currently not supported.
82
83 =head2 Including locally-installed libraries
84
85 Perl5 comes with a number of database extensions, including interfaces
86 to dbm, ndbm, gdbm, and Berkeley db.  For each extension, if Configure
87 can find the appropriate header files and libraries, it will automatically
88 include that extension.
89
90 I<Note:>  If your database header (.h) files are not in a
91 directory normally searched by your C compiler, then you will need to
92 include the appropriate B<-I/your/directory> option when prompted by
93 Configure.  If your database library (.a) files are not in a directory
94 normally searched by your C compiler and linker, then you will need to
95 include the appropriate B<-L/your/directory> option when prompted by
96 Configure.  See the examples below.
97
98 =head2 Examples
99
100 =over 4
101
102 =item gdbm in /usr/local.
103
104 Suppose you have gdbm and want Configure to find it and build the
105 GDBM_File extension.  This examples assumes you have F<gdbm.h>
106 installed in F</usr/local/include/gdbm.h> and F<libgdbm.a> installed in
107 F</usr/local/lib/libgdbm.a>.  Configure should figure all the
108 necessary steps out automatically.
109
110 Specifically, when Configure prompts you for flags for
111 your C compiler, you should include  C<-I/usr/local/include>.
112
113 When Configure prompts you for linker flags, you should include
114 C<-L/usr/local/lib>.
115
116 If you are using dynamic loading, then when Configure prompts you for
117 linker flags for dynamic loading, you should again include
118 C<-L/usr/local/lib>.
119
120 Again, this should all happen automatically.  If you want to accept the
121 defaults for all the questions and have Configure print out only terse
122 messages, then you can just run
123
124         sh Configure -des
125
126 and Configure should include the GDBM_File extension automatically.
127
128 This should actually work if you have gdbm installed in any of
129 (/usr/local, /opt/local, /usr/gnu, /opt/gnu, /usr/GNU, or /opt/GNU).
130
131 =item gdbm in /usr/you
132
133 Suppose you have gdbm installed in some place other than /usr/local/,
134 but you still want Configure to find it.  To be specific, assume  you
135 have F</usr/you/include/gdbm.h> and F</usr/you/lib/libgdbm.a>.  You
136 still have to add B<-I/usr/you/include> to cc flags, but you have to take
137 an extra step to help Configure find F<libgdbm.a>.  Specifically, when
138 Configure prompts you for library directories, you have to add
139 F</usr/you/lib> to the list.
140
141 It is possible to specify this from the command line too (all on one
142 line):
143
144         sh Configure -des \
145                 -Dlocincpth="/usr/you/include" \
146                 -Dloclibpth="/usr/you/lib"
147
148 C<locincpth> is a space-separated list of include directories to search.
149 Configure will automatically add the appropriate B<-I> directives.
150
151 C<loclibpth> is a space-separated list of library directories to search.
152 Configure will automatically add the appropriate B<-L> directives.  If
153 you have some libraries under F</usr/local/> and others under
154 F</usr/you>, then you have to include both, namely
155
156         sh Configure -des \
157                 -Dlocincpth="/usr/you/include /usr/local/include" \
158                 -Dloclibpth="/usr/you/lib /usr/local/lib"
159
160 =back
161
162 =head2 Changing the installation directory
163
164 Configure distinguishes between the directory in which perl (and its
165 associated files) should be installed and the directory in which it
166 will eventually reside.  For most sites, these two are the same; for
167 sites that use AFS, this distinction is handled automatically.
168 However, sites that use software such as B<depot> to manage software
169 packages may also wish to install perl into a different directory and
170 use that management software to move perl to its final destination.
171 This section describes how to do this.  Someday, Configure may support
172 an option C<-Dinstallprefix=/foo> to simplify this.
173
174 Suppose you want to install perl under the F</tmp/perl5> directory.
175 You can edit F<config.sh> and change all the install* variables to
176 point to F</tmp/perl5> instead of F</usr/local/wherever>.  You could
177 also set them all from the Configure command line.  Or, you can
178 automate this process by placing the following lines in a file
179 F<config.over> B<before> you run Configure (replace /tmp/perl5 by a
180 directory of your choice):
181
182     installprefix=/tmp/perl5
183     test -d $installprefix || mkdir $installprefix
184     test -d $installprefix/bin || mkdir $installprefix/bin
185     installarchlib=`echo $installarchlib | sed "s!$prefix!$installprefix!"`
186     installbin=`echo $installbin | sed "s!$prefix!$installprefix!"`
187     installman1dir=`echo $installman1dir | sed "s!$prefix!$installprefix!"`
188     installman3dir=`echo $installman3dir | sed "s!$prefix!$installprefix!"`
189     installprivlib=`echo $installprivlib | sed "s!$prefix!$installprefix!"`
190     installscript=`echo $installscript | sed "s!$prefix!$installprefix!"`
191     installsitelib=`echo $installsitelib | sed "s!$prefix!$installprefix!"`
192
193 Then, you can Configure and install in the usual way:
194
195     sh ./Configure -des
196     make
197     make test
198     make install
199
200 =head2 Creating an installable tar archive
201
202 If you need to install perl on many identical systems, it is
203 convenient to compile it once and create an archive that can be
204 installed on multiple systems.  Here's one way to do that:
205
206     # Set up config.over to install perl into a different directory,
207     # e.g. /tmp/perl5 (see previous part).
208     sh ./Configure -des
209     make
210     make test
211     make install
212     cd /tmp/perl5
213     tar cvf ../perl5-archive.tar .
214     # Then, on each machine where you want to install perl,
215     cd /usr/local  # Or wherever you specified as $prefix
216     tar xvf perl5-archive.tar
217
218 =head2 What if it doesn't work?
219
220 =over 4
221
222 =item Hint files.
223
224 The perl distribution includes a number of system-specific hints files
225 in the hints/ directory.  If one of them matches your system, Configure
226 will offer to use that hint file.
227
228 Several of the hint files contain additional important information.
229 If you have any problems, it is a good idea to read the relevant hint
230 file for further information.  See F<hints/solaris_2.sh> for an
231 extensive example.
232
233 =item Changing Compilers
234
235 If you change compilers or make other significant changes, you should
236 probably I<not> re-use your old config.sh.  Simply remove it or
237 rename it, e.g. mv config.sh config.sh.old.  Then rerun Configure
238 with the options you want to use.
239
240 This is a common source of problems.  If you change from B<cc> to
241 B<gcc>, you should almost always remove your old config.sh.
242
243 =item Propagating your changes
244
245 If you later make any changes to F<config.sh>, you should propagate
246 them to all the .SH files by running  B<Configure -S>.
247
248 =item config.over
249
250 You can also supply a shell script config.over to over-ride Configure's
251 guesses.  It will get loaded up at the very end, just before config.sh
252 is created.  You have to be careful with this, however, as Configure
253 does no checking that your changes make sense.
254
255 =item config.h
256
257 Many of the system dependencies are contained in F<config.h>.
258 F<Configure> builds F<config.h> by running the F<config_h.SH> script.
259 The values for the variables are taken from F<config.sh>.
260
261 If there are any problems, you can edit F<config.h> directly.  Beware,
262 though, that the next time you run B<Configure>, your changes will be
263 lost.
264
265 =item cflags
266
267 If you have any additional changes to make to the C compiler command
268 line, they can be made in F<cflags.SH>.  For instance, to turn off the
269 optimizer on F<toke.c>, find the line in the switch structure for
270 F<toke.c> and put the command C<optimize='-g'> before the C<;;>.  You
271 can also edit F<cflags> directly, but beware that your changes will be
272 lost the next time you run B<Configure>.
273
274 To change the C flags for all the files, edit F<config.sh>
275 and change either C<$ccflags> or C<$optimize>,
276 and then re-run  B<Configure -S ; make depend>.
277
278 =item No sh.
279
280 If you don't have sh, you'll have to copy the sample file config_H to
281 config.h and edit the config.h to reflect your system's peculiarities.
282 You'll probably also have to extensively modify the extension building
283 mechanism.
284
285 =back
286
287 =head1 make depend
288
289 This will look for all the includes.
290 The output is stored in F<makefile>.  The only difference between
291 F<Makefile> and F<makefile> is the dependencies at the bottom of
292 F<makefile>.  If you have to make any changes, you should edit
293 F<makefile>, not F<Makefile> since the Unix B<make> command reads
294 F<makefile>.
295
296 Configure will offer to do this step for you, so it isn't listed
297 explicitly above.
298
299 =head1 make
300
301 This will attempt to make perl in the current directory.
302
303 If you can't compile successfully, try some of the following ideas.
304
305 =over 4
306
307 =item *
308
309 If you used a hint file, try reading the comments in the hint file
310 for further tips and information.
311
312 =item *
313
314 If you can't compile successfully, try adding a C<-DCRIPPLED_CC> flag.
315 (Just because you get no errors doesn't mean it compiled right!)
316 This simplifies some complicated expressions for compilers that
317 get indigestion easily.  If that has no effect, try turning off
318 optimization.  If you have missing routines, you probably need to
319 add some library or other, or you need to undefine some feature that
320 Configure thought was there but is defective or incomplete.
321
322 =item *
323
324 Some compilers will not compile or optimize the larger files without
325 some extra switches to use larger jump offsets or allocate larger
326 internal tables.  You can customize the switches for each file in
327 F<cflags>.  It's okay to insert rules for specific files into
328 F<makefile> since a default rule only takes effect in the absence of a
329 specific rule.
330
331 =item *
332
333 If you can successfully build F<miniperl>, but the process crashes
334 during the building of extensions, you should run
335
336         make minitest
337
338 to test your version of miniperl.
339
340 =item *
341
342 Some additional things that have been reported for either perl4 or perl5:
343
344 Genix may need to use libc rather than libc_s, or #undef VARARGS.
345
346 NCR Tower 32 (OS 2.01.01) may need -W2,-Sl,2000 and #undef MKDIR.
347
348 UTS may need one or more of B<-DCRIPPLED_CC>, B<-K> or B<-g>, and undef LSTAT.
349
350 If you get syntax errors on '(', try -DCRIPPLED_CC.
351
352 Machines with half-implemented dbm routines will need to #undef I_ODBM
353
354 SCO prior to 3.2.4 may be missing dbmclose().  An upgrade to 3.2.4
355 that includes libdbm.nfs (which includes dbmclose()) may be available.
356
357 If you get duplicates upon linking for malloc et al, say -DHIDEMYMALLOC.
358
359 If you get duplicate function definitions (a perl function has the
360 same name as another function on your system) try -DEMBED.
361
362 If you get varags problems with gcc, be sure that gcc is installed
363 correctly.  When using gcc, you should probably have i_stdarg='define'
364 and i_varags='undef' in config.sh.  The problem is usually solved
365 by running fixincludes correctly.
366
367 If you wish to use dynamic loading on SunOS or Solaris, and you
368 have GNU as and GNU ld installed, you may need to add B<-B/bin/> to
369 your $ccflags and $ldflags so that the system's versions of as
370 and ld are used.
371
372 If you run into dynamic loading problems, check your setting of
373 the LD_LIBRARY_PATH environment variable.  Perl should build
374 fine with LD_LIBRARY_PATH unset, though that may depend on details
375 of your local set-up.
376
377 =back
378
379 =head1 make test
380
381 This will run the regression tests on the perl you just made.  If it
382 doesn't say "All tests successful" then something went wrong.  See the
383 file F<t/README> in the F<t> subdirectory.  Note that you can't run it
384 in background if this disables opening of /dev/tty.  If B<make test>
385 bombs out, just B<cd> to the F<t> directory and run B<TEST> by hand
386 to see if it makes any difference.
387 If individual tests bomb, you can run them by hand, e.g.,
388
389         ./perl op/groups.t
390
391 =head1 INSTALLING PERL5
392
393 =head1 make install
394
395 This will put perl into the public directory you specified to
396 B<Configure>; by default this is F</usr/local/bin>.  It will also try
397 to put the man pages in a reasonable place.  It will not nroff the man
398 page, however.  You may need to be root to run B<make install>.  If you
399 are not root, you must own the directories in question and you should
400 ignore any messages about chown not working.
401
402 If you want to see exactly what will happen without installing
403 anything, you can run
404         
405         ./perl installperl -n
406         ./perl installman -n
407
408 B<make install> will install the following:
409
410         perl,
411             perl5.nnn   where nnn is the current release number.  This
412                         will be a link to perl.
413         suidperl,
414             sperl5.nnn  If you requested setuid emulation.
415         a2p             awk-to-perl translator
416         cppstdin        This is used by perl -P, if your cc -E can't
417                         read from stdin.
418         c2ph, pstruct   Scripts for handling C structures in header files.
419         s2p             sed-to-perl translator
420         find2perl       find-to-perl translator
421         h2xs            Converts C .h header files to Perl extensions.
422         perldoc         Tool to read perl's pod documentation.
423         pod2html,       Converters from perl's pod documentation format
424         pod2latex, and  to other useful formats.
425         pod2man
426
427         library files   in $privlib and $archlib specified to
428                         Configure, usually under /usr/local/lib/perl5/.
429         man pages       in the location specified to Configure, usually
430                         something like /usr/local/man/man1.
431         module          in the location specified to Configure, usually
432         man pages       under /usr/local/lib/perl5/man/man3.
433         pod/*.pod       in $privlib/pod/.
434
435 Perl's *.h header files and the libperl.a library are also
436 installed under $archlib so that any user may later build new
437 extensions even if the Perl source is no longer available.
438
439 The libperl.a library is only needed for building new
440 extensions and linking them statically into a new perl executable.
441 If you will not be doing that, then you may safely delete
442 $archlib/libperl.a after perl is installed.
443
444 make install may also offer to install perl in a "standard" location.
445
446 Most of the documentation in the pod/ directory is also available
447 in HTML and LaTeX format.  Type
448
449         cd pod; make html; cd ..
450
451 to generate the html versions, and
452
453         cd pod; make tex; cd ..
454
455 to generate the LaTeX versions.
456
457 =head1 Coexistence with perl4
458
459 You can safely install perl5 even if you want to keep perl4 around.
460
461 By default, the perl5 libraries go into F</usr/local/lib/perl5/>, so
462 they don't override the perl4 libraries in F</usr/local/lib/perl/>.
463
464 In your /usr/local/bin directory, you should have a binary named
465 F<perl4.036>.  That will not be touched by the perl5 installation
466 process.  Most perl4 scripts should run just fine under perl5.
467 However, if you have any scripts that require perl4, you can replace
468 the C<#!> line at the top of them by C<#!/usr/local/bin/perl4.036>
469 (or whatever the appropriate pathname is).
470
471 =head1 DOCUMENTATION
472
473 Read the manual entries before running perl.  The main documentation is
474 in the pod/ subdirectory and should have been installed during the
475 build process.  Type B<man perl> to get started.  Alternatively, you
476 can type B<perldoc perl> to use the supplied B<perldoc> script.  This
477 is sometimes useful for finding things in the library modules.
478
479 =head1 AUTHOR
480
481 Andy Dougherty <doughera@lafcol.lafayette.edu>, borrowing I<very> heavily
482 from the original README by Larry Wall.
483
484 18 October 1995