3 Install - Build and Installation guide for perl5.
7 The basic steps to build and install perl5 are:
15 Each of these is explained in further detail below.
19 =head1 Start with a Fresh Distribution.
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.
27 mv config.sh config.sh.old
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
38 After it runs, Configure will perform variable substitution on all the
39 F<*.SH> files and offer to run B<make depend>.
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
46 This is the preferred way to specify gcc (or another alternative
47 compiler) so that the hints files can set appropriate defaults.
49 If you are willing to accept all the defaults, and you want terse
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',
60 Configure -Dprefix=/opt/local
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.
67 =head2 GNU-style configure
69 If you prefer the GNU-style B<configure> command line interface, you can
70 use the supplied B<configure> command, e.g.
74 The B<configure> script emulates several of the more common configure
81 Cross compiling is currently not supported.
83 =head2 Including locally-installed libraries
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.
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.
102 =item gdbm in /usr/local.
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.
110 Specifically, when Configure prompts you for flags for
111 your C compiler, you should include C<-I/usr/local/include>.
113 When Configure prompts you for linker flags, you should include
116 If you are using dynamic loading, then when Configure prompts you for
117 linker flags for dynamic loading, you should again include
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
126 and Configure should include the GDBM_File extension automatically.
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).
131 =item gdbm in /usr/you
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.
141 It is possible to specify this from the command line too (all on one
145 -Dlocincpth="/usr/you/include" \
146 -Dloclibpth="/usr/you/lib"
148 C<locincpth> is a space-separated list of include directories to search.
149 Configure will automatically add the appropriate B<-I> directives.
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
157 -Dlocincpth="/usr/you/include /usr/local/include" \
158 -Dloclibpth="/usr/you/lib /usr/local/lib"
162 =head2 Changing the installation directory
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.
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):
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!"`
193 Then, you can Configure and install in the usual way:
200 =head2 Creating an installable tar archive
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:
206 # Set up config.over to install perl into a different directory,
207 # e.g. /tmp/perl5 (see previous part).
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
218 =head2 What if it doesn't work?
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.
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
233 =item Changing Compilers
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.
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.
243 =item Propagating your changes
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>.
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.
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>.
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
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>.
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>.
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
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
296 Configure will offer to do this step for you, so it isn't listed
301 This will attempt to make perl in the current directory.
303 If you can't compile successfully, try some of the following ideas.
309 If you used a hint file, try reading the comments in the hint file
310 for further tips and information.
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.
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
333 If you can successfully build F<miniperl>, but the process crashes
334 during the building of extensions, you should run
338 to test your version of miniperl.
342 Some additional things that have been reported for either perl4 or perl5:
344 Genix may need to use libc rather than libc_s, or #undef VARARGS.
346 NCR Tower 32 (OS 2.01.01) may need -W2,-Sl,2000 and #undef MKDIR.
348 UTS may need one or more of B<-DCRIPPLED_CC>, B<-K> or B<-g>, and undef LSTAT.
350 If you get syntax errors on '(', try -DCRIPPLED_CC.
352 Machines with half-implemented dbm routines will need to #undef I_ODBM
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.
357 If you get duplicates upon linking for malloc et al, say -DHIDEMYMALLOC.
359 If you get duplicate function definitions (a perl function has the
360 same name as another function on your system) try -DEMBED.
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.
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
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.
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.,
391 =head1 INSTALLING PERL5
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.
402 If you want to see exactly what will happen without installing
403 anything, you can run
405 ./perl installperl -n
408 B<make install> will install the following:
411 perl5.nnn where nnn is the current release number. This
412 will be a link to perl.
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
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.
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/.
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.
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.
444 make install may also offer to install perl in a "standard" location.
446 Most of the documentation in the pod/ directory is also available
447 in HTML and LaTeX format. Type
449 cd pod; make html; cd ..
451 to generate the html versions, and
453 cd pod; make tex; cd ..
455 to generate the LaTeX versions.
457 =head1 Coexistence with perl4
459 You can safely install perl5 even if you want to keep perl4 around.
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/>.
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).
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.
481 Andy Dougherty <doughera@lafcol.lafayette.edu>, borrowing I<very> heavily
482 from the original README by Larry Wall.