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