1 package ExtUtils::MakeMaker;
3 $Version = 4.094; # Last edited 17 Apr 1995 by Andy Dougherty
11 @EXPORT = qw(&WriteMakefile $Verbose);
12 @EXPORT_OK = qw($Version %att %skip %Recognized_Att_Keys
13 @MM_Sections %MM_Sections
14 &help &lsdir &neatvalue &mkbootstrap &mksymlists);
16 $Is_VMS = $Config{'osname'} eq 'VMS';
17 require ExtUtils::MM_VMS if $Is_VMS;
21 $Version = $Version;# avoid typo warning
27 ExtUtils::MakeMaker - create an extension Makefile
31 C<use ExtUtils::MakeMaker;>
33 C<WriteMakefile( ATTRIBUTE =E<gt> VALUE [, ...] );>
37 This utility is designed to write a Makefile for an extension module
38 from a Makefile.PL. It is based on the Makefile.SH model provided by
39 Andy Dougherty and the perl5-porters.
41 It splits the task of generating the Makefile into several subroutines
42 that can be individually overridden. Each subroutine returns the text
43 it wishes to have written to the Makefile.
45 MakeMaker.pm uses the architecture specific information from
46 Config.pm. In addition the extension may contribute to the C<%Config>
47 hash table of Config.pm by supplying hints files in a C<hints/>
48 directory. The hints files are expected to be named like their
49 counterparts in C<PERL_SRC/hints>, but with an C<.pl> file name
50 extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by MakeMaker
51 within the WriteMakefile() subroutine, and can be used to execute
52 commands as well as to include special variables. If there is no
53 hintsfile for the actual system, but for some previous releases of the
54 same operating system, the latest one of those is used.
56 =head2 Default Makefile Behaviour
58 The automatically generated Makefile enables the user of the extension
63 make test # optionally set TEST_VERBOSE=1
64 make install # See below
66 The Makefile to be produced may be altered by adding arguments of the
67 form C<KEY=VALUE>. If the user wants to have the extension installed
68 into a directory different from C<$Config{"installprivlib"}> it can be
71 perl Makefile.PL INST_LIB=~/myperllib INST_EXE=~/bin
73 Note, that in this example MakeMaker does the tilde expansion for you
74 and INST_ARCHLIB is set to either C<INST_LIB/$Config{"archname"}> if
75 that directory exists and otherwise to INST_LIB.
77 Other interesting targets in the generated Makefile are
79 make config # to check if the Makefile is up-to-date
80 make clean # delete local temporary files (Makefile gets renamed)
81 make realclean # delete all derived files (including installed files)
82 make dist # produce a gzipped file ready for shipping
84 The macros in the produced Makefile may be overridden on the command
85 line to the make call as in the following example:
87 make INST_LIB=/some/where INST_ARCHLIB=/some/where INST_EXE=/u/k/bin
89 Note, that this is a solution provided by C<make> in general, so tilde
90 expansion will probably not be available and INST_ARCHLIB will not be
91 set automatically when INST_LIB is given as argument.
93 The generated Makefile does not set any permissions. The installer has
94 to decide, which umask should be in effect.
96 =head2 Special case C<make install>
98 The I<install> target of the generated Makefile is for system
99 administrators only that have writing permissions on the
100 system-specific directories $Config{installprivlib},
101 $Config{installarchlib}, and $Config{installbin}. This works, because
102 C<make> alone in fact puts all relevant files into directories that
103 are named by the macros INST_LIB, INST_ARCHLIB, and INST_EXE. All
104 three default to ./blib if you are not building below the perl source
105 directory. C<make install> is just a recursive call to C<make> with
106 the three relevant parameters set accordingly to the system-wide
109 C<make install> per default writes some documentation of what has been
110 done into the file C<$Config{'installarchlib'}/perllocal.pod>. This is
111 an experimental feature. It can be bypassed by calling C<make
114 Users that do not have privileges on the system but want to install
115 the relevant files of the module into their private library or binary
116 directories do not call C<make install>. In priciple they have the
119 # case: trust the module
120 perl Makefile.PL INST_LIB=~/perllib INST_EXE=~/bin
126 # case: want to run tests before installation
130 make INST_LIB=/some/where INST_ARCHLIB=/foo/bar INST_EXE=/somebin
132 (C<make test> is not necessarily supported for all modules.)
134 =head2 Support to Link a new Perl Binary
136 An extension that is built with the above steps is ready to use on
137 systems supporting dynamic loading. On systems that do not support
138 dynamic loading, any newly created extension has to be linked together
139 with the available ressources. MakeMaker supports the linking process
140 by creating appropriate targets in the Makefile whenever an extension
141 is built. You can invoke the corresponding section of the makefile with
145 That produces a new perl binary in the current directory with all
146 extensions linked in that can be found in INST_ARCHLIB and
149 The binary can be installed into the directory where perl normally
150 resides on your machine with
154 To produce a perl binary with a different name than C<perl>, either say
156 perl Makefile.PL MAP_TARGET=myperl
163 make myperl MAP_TARGET=myperl
164 make inst_perl MAP_TARGET=myperl
166 In any case you will be prompted with the correct invocation of the
167 C<inst_perl> target that installs the new binary into
168 $Config{'installbin'}.
170 Note, that there is a C<makeaperl> scipt in the perl distribution,
171 that supports the linking of a new perl binary in a similar fashion,
172 but with more options.
174 C<make inst_perl> per default writes some documentation of what has been
175 done into the file C<$Config{'installarchlib'}/perllocal.pod>. This
176 can be bypassed by calling C<make pure_inst_perl>.
178 Warning: the inst_perl: target is rather mighty and will probably
179 overwrite your existing perl binary. Use with care!
181 =head2 Determination of Perl Library and Installation Locations
183 MakeMaker needs to know, or to guess, where certain things are
184 located. Especially INST_LIB and INST_ARCHLIB (where to install files
185 into), PERL_LIB and PERL_ARCHLIB (where to read existing modules
186 from), and PERL_INC (header files and C<libperl*.*>).
188 Extensions may be built either using the contents of the perl source
189 directory tree or from an installed copy of the perl library.
191 If an extension is being built below the C<ext/> directory of the perl
192 source then MakeMaker will set PERL_SRC automatically (e.g., C<../..>).
193 If PERL_SRC is defined then other variables default to the following:
196 PERL_LIB = PERL_SRC/lib
197 PERL_ARCHLIB = PERL_SRC/lib
199 INST_ARCHLIB = PERL_ARCHLIB
201 If an extension is being built away from the perl source then MakeMaker
202 will leave PERL_SRC undefined and default to using the installed copy
203 of the perl library. The other variables default to the following:
205 PERL_INC = $archlib/CORE
207 PERL_ARCHLIB = $archlib
209 INST_ARCHLIB = ./blib
211 If perl has not yet been installed then PERL_SRC can be defined on the
212 command line as shown in the previous section.
214 =head2 Useful Default Makefile Macros
216 FULLEXT = Pathname for extension directory (eg DBD/Oracle).
218 BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
220 ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
222 PERL_LIB = Directory where we read the perl library files
224 PERL_ARCHLIB = Same as above for architecture dependent files
226 INST_LIB = Directory where we put library files of this extension
227 while building it. If we are building below PERL_SRC/ext
228 we default to PERL_SRC/lib, else we default to ./blib.
230 INST_ARCHLIB = Same as above for architecture dependent files
232 INST_LIBDIR = C<$(INST_LIB)$(ROOTEXT)>
234 INST_AUTODIR = C<$(INST_LIB)/auto/$(FULLEXT)>
236 INST_ARCHAUTODIR = C<$(INST_ARCHLIB)/auto/$(FULLEXT)>
238 =head2 Customizing The Generated Makefile
240 If the Makefile generated does not fit your purpose you can change it
241 using the mechanisms described below.
243 =head2 Using Attributes (and Parameters)
245 The following attributes can be specified as arguments to WriteMakefile()
246 or as NAME=VALUE pairs on the command line:
248 This description is not yet documented; you can get at the description
251 C<perl Makefile.PL help> (if you already have a basic Makefile.PL)
255 C<perl -e 'use ExtUtils::MakeMaker qw(&help); &help;'>
257 =head2 Overriding MakeMaker Methods
259 If you cannot achieve the desired Makefile behaviour by specifying
260 attributes you may define private subroutines in the Makefile.PL.
261 Each subroutines returns the text it wishes to have written to
262 the Makefile. To override a section of the Makefile you can
265 sub MY::c_o { "new literal text" }
267 or you can edit the default by saying something like:
269 sub MY::c_o { $_=MM->c_o; s/old text/new text/; $_ }
271 If you still need a different solution, try to develop another
272 subroutine, that fits your needs and submit the diffs to
273 F<perl5-porters@nicoh.com> or F<comp.lang.perl> as appropriate.
278 # We allow extension-specific hints files.
280 # First we look for the best hintsfile we have
282 my($hint)="$Config{'osname'}_$Config{'osvers'}";
285 opendir DIR, "hints";
286 while (defined ($_ = readdir DIR)) {
288 next unless s/\.pl$//;
289 next unless /^$Config{'osname'}/;
290 # Don't trust a hintfile for a later OS version:
299 return unless @goodhints; # There was no hintsfile
300 # the last one in lexical ordering is our choice:
301 $hint=(sort @goodhints)[-1];
303 # execute the hintsfile:
304 open HINTS, "hints/$hint.pl";
305 @goodhints = <HINTS>;
307 print STDOUT "Processing hints file hints/$hint.pl";
308 eval join('',@goodhints);
309 print STDOUT $@ if $@;
312 # Setup dummy package:
313 # MY exists for overriding methods to be defined within
314 unshift(@MY::ISA, qw(MM));
316 # Dummy package MM inherits actual methods from OS-specific
317 # default packages. We use this intermediate package so
318 # MY->func() can call MM->func() and get the proper
319 # default routine without having to know under what OS
321 unshift(@MM::ISA, $Is_VMS ? qw(ExtUtils::MM_VMS MM_Unix) : qw(MM_Unix));
323 $Attrib_Help = <<'END';
324 NAME: Perl module name for this extension (DBD::Oracle)
325 This will default to the directory name but should
326 be explicitly defined in the Makefile.PL.
328 DISTNAME: Your name for distributing the package (by tar file)
329 This defaults to NAME above.
331 VERSION: Your version number for distributing the package.
332 This defaults to 0.1.
334 INST_LIB: Perl library directory to install the module into.
335 INST_ARCHLIB: Perl architecture-dependent library to install into
336 (defaults to INST_LIB)
338 PERL_LIB: Directory containing the Perl library to use.
339 PERL_SRC: Directory containing the Perl source code
340 (use of this should be avoided, it may be undefined)
342 INC: Include file dirs eg: '-I/usr/5include -I/path/to/inc'
343 DEFINE: something like "-DHAVE_UNISTD_H"
344 OBJECT: List of object files, defaults to '$(BASEEXT).o',
345 but can be a long string containing all object files,
346 e.g. "tkpBind.o tkpButton.o tkpCanvas.o"
347 MYEXTLIB: If the extension links to a library that it builds
348 set this to the name of the library (see SDBM_File)
350 LIBS: An anonymous array of alternative library specifications
351 to be searched for (in order) until at least one library
353 'LIBS' => [ "-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs" ]
354 Mind, that any element of the array contains a complete
355 set of arguments for the ld command. So do not specify
356 'LIBS' => ["-ltcl", "-ltk", "-lX11" ], #wrong
357 See ODBM_File/Makefile.PL for an example, where an
358 array is needed. If you specify a scalar as in
359 'LIBS' => "-ltcl -ltk -lX11"
360 MakeMaker will turn it into an array with one element.
362 LDFROM: defaults to "$(OBJECT)" and is used in the ld command
363 to specify what files to link/load from
364 (also see dynamic_lib below for how to specify ld flags)
366 DIR: Ref to array of subdirectories containing Makefile.PLs
367 e.g. [ 'sdbm' ] in ext/SDBM_File
369 PMLIBDIRS: Ref to array of subdirectories containing library files.
370 Defaults to [ 'lib', $(BASEEXT) ]. The directories will
371 be scanned and any files they contain will
372 be installed in the corresponding location in the library.
373 A MY::libscan() function can be used to alter the behaviour.
374 Defining PM in the Makefile.PL will override PMLIBDIRS.
376 PM: Hashref of .pm files and *.pl files to be installed.
377 e.g. { 'name_of_file.pm' => '$(INST_LIBDIR)/install_as.pm' }
378 By default this will include *.pm and *.pl. If a lib directory
379 exists and is not listed in DIR (above) then any *.pm and
380 *.pl files it contains will also be included by default.
381 Defining PM in the Makefile.PL will override PMLIBDIRS.
383 XS: Hashref of .xs files. MakeMaker will default this.
384 e.g. { 'name_of_file.xs' => 'name_of_file.c' }
385 The .c files will automatically be included in the list
386 of files deleted by a make clean.
388 C: Ref to array of *.c file names. Initialised from a directory scan
389 and the values portion of the XS attribute hash. This is not
390 currently used by MakeMaker but may be handy in Makefile.PLs.
392 H: Ref to array of *.h file names. Similar to C: above.
394 PL_FILES: Ref to hash of files to be processed as perl programs. MakeMaker
395 will default to any found C<*.PL> file (except C<Makefile.PL>) being
396 keys and the basename of the file being the value. E.g.
397 C<{ 'foobar.PL' => 'foobar' }>. The C<*.PL> files are expected to
398 produce output to the target files themselves.
400 EXE_FILES: Ref to array of executable files. The files will be copied to
401 the INST_EXE directory. The installed files will be deleted
404 INST_EXE: Directory, where executable scripts should be installed. Defaults
405 to "./blib", just to have a dummy location during testing.
406 C<make install> will set INST_EXE to $Config{'installbin'}.
408 LINKTYPE: =>'static' or 'dynamic' (default unless usedl=undef in config.sh)
409 Should only be used to force static linking (also see linkext below).
411 DL_FUNCS: Hashref of symbol names for routines to be made available as
412 universal symbols. Each key/value pair consists of the package
413 name and an array of routine names in that package. Used only
414 under AIX (export lists) and VMS (linker options) at present.
415 The routine names supplied will be expanded in the same way
416 as XSUB names are expanded by the XS() macro.
417 Defaults to { "$(NAME)" => [ "boot_$(NAME)" ] }.
418 (e.g. { "RPC" => [qw( boot_rpcb rpcb_gettime getnetconfigent )],
419 "NetconfigPtr" => [ 'DESTROY'] } )
421 DL_VARS: Array of symbol names for variables to be made available as
422 universal symbols. Used only under AIX (export lists) and VMS
423 (linker options) at present. Defaults to [].
424 (e.g. [ qw( Foo_version Foo_numstreams Foo_tree ) ])
426 CONFIG: =>[qw(archname manext)] defines ARCHNAME & MANEXT from config.sh
427 SKIP: =>[qw(name1 name2)] skip (do not write) sections of the Makefile
429 MAP_TARGET: If it is intended, that a new perl binary be produced, this variable
430 may hold a name for that binary. Defaults to C<perl>
432 LIBPERL_A: The filename of the perllibrary that will be used together
433 with this extension. Defaults to C<libperl.a>.
438 Additional lowercase attributes can be used to pass parameters to the
439 methods which implement that part of the Makefile. These are not
442 installpm: {SPLITLIB => '$(INST_LIB)' (default) or '$(INST_ARCHLIB)'}
443 linkext: {LINKTYPE => 'static', 'dynamic' or ''}
444 dynamic_lib: {ARMAYBE => 'ar', OTHERLDFLAGS => '...'}
445 clean: {FILES => "*.xyz foo"}
446 realclean: {FILES => '$(INST_ARCHAUTODIR)/*.xyz'}
447 dist: {TARNAME=>'MyTarFile', TARFLAGS=>'cvfF', COMPRESS=>'gzip'}
448 tool_autosplit: {MAXLEN => 8}
451 sub help {print $Attrib_Help;}
453 @MM_Sections_spec = (
454 'post_initialize' => {},
455 'const_config' => {},
457 'const_loadlibs' => {},
459 'tool_autosplit' => {},
462 'post_constants' => {},
490 %MM_Sections = @MM_Sections_spec; # looses section ordering
491 @MM_Sections = grep(!ref, @MM_Sections_spec); # keeps order
493 %Recognized_Att_Keys = %MM_Sections; # All sections are valid keys.
494 foreach(split(/\n/,$Attrib_Help)){
496 next unless m/^\s*(\w+):\s*(.*)/;
497 $Recognized_Att_Keys{$1} = $2;
498 print "Attribute '$1' => '$2'\n" if ($Verbose >= 2);
506 if ($section eq 'dynamic') {
507 print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets "
508 . "in skipped section 'dynamic_bs'\n"
509 if $skip{'dynamic_bs'} && $Verbose;
510 print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets "
511 . "in skipped section 'dynamic_lib'\n"
512 if $skip{'dynamic_lib'} && $Verbose;
514 if ($section eq 'dynamic_lib') {
515 print STDOUT "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on "
516 . "targets in skipped section 'dynamic_bs'\n"
517 if $skip{'dynamic_bs'} && $Verbose;
519 if ($section eq 'static') {
520 print STDOUT "Warning (non-fatal): Target 'static' depends on targets "
521 . "in skipped section 'static_lib'\n"
522 if $skip{'static_lib'} && $Verbose;
524 return 'skipped' if $skip{$section};
533 print STDOUT "MakeMaker" if $Verbose;
535 parse_args(\%att, @ARGV);
536 my(%initial_att) = %att; # record initial attributes
544 print STDOUT "Writing Makefile for $att{NAME}";
549 unlink("Makefile", "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : '');
550 open MAKE, ">MakeMaker.tmp" or die "Unable to open MakeMaker.tmp: $!";
551 select MAKE; $|=1; select STDOUT;
553 print MAKE "# This Makefile is for the $att{NAME} extension to perl.\n#";
554 print MAKE "# It was generated automatically by MakeMaker version $Version from the contents";
555 print MAKE "# of Makefile.PL. Don't edit this file, edit Makefile.PL instead.";
556 print MAKE "#\n# ANY CHANGES MADE HERE WILL BE LOST! \n#";
557 print MAKE "# MakeMaker Parameters: ";
558 foreach $key (sort keys %initial_att){
559 my($v) = neatvalue($initial_att{$key});
561 print MAKE "# $key => $v";
564 # build hash for SKIP to make testing easy
565 %skip = map( ($_,1), @{$att{'SKIP'} || []});
568 foreach $section ( @MM_Sections ){
569 print "Processing Makefile '$section' section" if ($Verbose >= 2);
570 my($skipit) = skipcheck($section);
572 print MAKE "\n# --- MakeMaker $section section $skipit.";
574 my(%a) = %{$att{$section} || {}};
575 print MAKE "\n# --- MakeMaker $section section:";
576 print MAKE "# ", join ", ", %a if $Verbose;
577 print(MAKE MY->nicetext(MY->$section( %a )));
582 print MAKE "\n# Full list of MakeMaker attribute values:";
583 foreach $key (sort keys %att){
584 my($v) = neatvalue($att{$key});
586 print MAKE "# $key => $v";
590 print MAKE "\n# End.";
592 my($finalname) = $Is_VMS ? "Descrip.MMS" : "Makefile";
593 rename("MakeMaker.tmp", $finalname);
595 chmod 0644, $finalname;
596 system("$Config{'eunicefix'} $finalname") unless $Config{'eunicefix'} eq ":";
603 parse_args(\%att, @ARGV);
609 parse_args(\%att, @ARGV);
614 my($attr, @args) = @_;
616 unless (m/(.*?)=(.*)/){
617 help(),exit 1 if m/^help$/;
618 ++$Verbose if m/^verb/;
621 my($name, $value) = ($1, $2);
622 if ($value =~ m/^~(\w+)?/){ # tilde with optional username
623 my($home) = ($1) ? (getpwnam($1))[7] : (getpwuid($>))[7];
624 $value =~ s/^~(\w+)?/$home/;
626 $$attr{$name} = $value;
628 # catch old-style 'potential_libs' and inform user how to 'upgrade'
629 if (defined $$attr{'potential_libs'}){
630 my($msg)="'potential_libs' => '$$attr{potential_libs}' should be";
631 if ($$attr{'potential_libs'}){
632 print STDOUT "$msg changed to:\n\t'LIBS' => ['$$attr{potential_libs}']\n";
634 print STDOUT "$msg deleted.\n";
636 $$attr{LIBS} = [$$attr{'potential_libs'}];
637 delete $$attr{'potential_libs'};
639 # catch old-style 'ARMAYBE' and inform user how to 'upgrade'
640 if (defined $$attr{'ARMAYBE'}){
641 my($armaybe) = $$attr{'ARMAYBE'};
642 print STDOUT "ARMAYBE => '$armaybe' should be changed to:\n",
643 "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n";
644 my(%dl) = %{$$attr{'dynamic_lib'} || {}};
645 $$attr{'dynamic_lib'} = { %dl, ARMAYBE => $armaybe};
646 delete $$attr{'ARMAYBE'};
648 if (defined $$attr{'LDTARGET'}){
649 print STDOUT "LDTARGET should be changed to LDFROM\n";
650 $$attr{'LDFROM'} = $$attr{'LDTARGET'};
651 delete $$attr{'LDTARGET'};
653 foreach(sort keys %{$attr}){
654 print STDOUT " $_ => ".neatvalue($$attr{$_}) if ($Verbose);
655 print STDOUT "'$_' is not a known MakeMaker parameter name.\n"
656 unless exists $Recognized_Att_Keys{$_};
663 return "undef" unless defined $v;
665 return "'$v'" unless $t;
666 return "[ ".join(', ',map("'$_'",@$v))." ]" if ($t eq 'ARRAY');
667 return "$v" unless $t eq 'HASH';
669 push(@m,"$key=>".neatvalue($val)) while (($key,$val) = each %$v);
670 return "{ ".join(', ',@m)." }";
673 # ------ Define the MakeMaker default methods in package MM_Unix ------
682 Exporter::import('ExtUtils::MakeMaker',
683 qw(%att %skip %Recognized_Att_Keys $Verbose));
685 # These attributes cannot be overridden externally
686 @Other_Att_Keys{qw(EXTRALIBS BSLOADLIBS LDLOADLIBS)} = (1) x 3;
688 if ($Is_VMS = $Config{'osname'} eq 'VMS') {
689 require VMS::Filespec;
690 import VMS::Filespec 'vmsify';
695 # Find out directory name. This may contain the extension name.
696 my($pwd) = fastcwd(); # from Cwd.pm
698 # --- Initialize PERL_LIB, INST_LIB, PERL_SRC
700 # *Real* information: where did we get these two from? ...
701 my $inc_config_dir = dirname($INC{'Config.pm'});
702 my $inc_carp_dir = dirname($INC{'Carp.pm'});
704 # Typically PERL_* and INST_* will be identical but that need
705 # not be the case (e.g., installing into project libraries etc).
707 # Perl Macro: With source No source
708 # PERL_LIB ../../lib /usr/local/lib/perl5
709 # PERL_ARCHLIB ../../lib /usr/local/lib/perl5/sun4-sunos
710 # PERL_SRC ../.. (undefined)
712 # INST Macro: Locally Publically
713 # INST_LIB ../../lib ./blib
714 # INST_ARCHLIB ../../lib ./blib
716 unless ($att{PERL_SRC}){
717 foreach(qw(../.. ../../.. ../../../..)){
718 if ( -f "$_/config.sh" && -f "$_/perl.h" && -f "$_/lib/Exporter.pm") {
724 unless ($att{PERL_SRC}){
725 # we should also consider $ENV{PERL5LIB} here
726 $att{PERL_LIB} = $Config{'privlib'} unless $att{PERL_LIB};
727 $att{PERL_ARCHLIB} = $Config{'archlib'} unless $att{PERL_ARCHLIB};
728 $att{PERL_INC} = "$att{PERL_ARCHLIB}/CORE"; # wild guess for now
729 die "Unable to locate Perl source. Try setting PERL_SRC in Makefile.PL or on command line.\n"
730 unless (-f "$att{PERL_INC}/perl.h");
731 print STDOUT "Using header files found in $att{PERL_INC}" if $Verbose;
733 $att{PERL_LIB} = "$att{PERL_SRC}/lib" unless $att{PERL_LIB};
734 $att{PERL_ARCHLIB} = $att{PERL_LIB};
735 $att{PERL_INC} = $att{PERL_SRC};
736 # catch an situation that has occurred a few times in the past:
737 warn <<EOM unless -s "$att{PERL_SRC}/cflags";
738 You cannot build extensions below the perl source tree after executing
739 a 'make clean' in the perl source tree.
741 To rebuild extensions distributed with the perl source you should
742 simply Configure (to include those extensions) and then build perl as
743 normal. After installing perl the source tree can be deleted. It is not
744 needed for building extensions.
746 It is recommended that you unpack and build additional extensions away
747 from the perl source tree.
751 # INST_LIB typically pre-set if building an extension after
752 # perl has been built and installed. Setting INST_LIB allows
753 # you to build directly into privlib and avoid installperl.
754 unless ($att{INST_LIB}){
755 if (defined $att{PERL_SRC}) {
756 $att{INST_LIB} = $att{PERL_LIB};
758 $att{INST_LIB} = "./blib";
761 # Try to work out what INST_ARCHLIB should be if not set:
762 unless ($att{INST_ARCHLIB}){
764 "./blib" => "./blib", # our private build lib
765 $att{PERL_LIB} => $att{PERL_ARCHLIB},
766 $Config{'privlib'} => $Config{'archlib'},
767 $Config{'installprivlib'} => $Config{'installarchlib'},
768 $inc_carp_dir => $inc_config_dir,
770 $att{INST_ARCHLIB} = $archmap{$att{INST_LIB}};
771 unless($att{INST_ARCHLIB}){
772 # Oh dear, we'll have to default it and warn the user
773 my($archname) = $Config{'archname'};
774 if (-d "$att{INST_LIB}/$archname"){
775 $att{INST_ARCHLIB} = "$att{INST_LIB}/$archname";
776 print STDOUT "Defaulting INST_ARCHLIB to INST_LIB/$archname\n";
778 $att{INST_ARCHLIB} = $att{INST_LIB};
779 print STDOUT "Warning: Defaulting INST_ARCHLIB to INST_LIB ",
780 "(not architecture independent).\n";
783 $att{INST_EXE} = "./blib" unless $att{INST_EXE};
784 $att{MAP_TARGET} = "perl" unless $att{MAP_TARGET};
785 $att{LIBPERL_A} = $Is_VMS ? 'libperl.olb' : 'libperl.a'
786 unless $att{LIBPERL_A};
789 # make a few simple checks
790 die "PERL_LIB ($att{PERL_LIB}) is not a perl library directory"
791 unless (-f "$att{PERL_LIB}/Exporter.pm");
793 # --- Initialize Module Name and Paths
795 # NAME = The perl module name for this extension (eg DBD::Oracle).
796 # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
797 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
798 # ROOTEXT = Directory part of FULLEXT with leading /.
799 unless($att{NAME}){ # we have to guess our name
802 $name =~ s:.*?([^.\]]+)\]:$1: unless ($name =~ s:.*[.\[]ext\.(.*)\]:$1:i);
803 ($att{NAME}=$name) =~ s#[.\]]#::#g;
805 $name =~ s:.*/:: unless ($name =~ s:^.*/ext/::);
806 ($att{NAME} =$name) =~ s#/#::#g;
809 ($att{FULLEXT} =$att{NAME}) =~ s#::#/#g ; #eg. BSD/Foo/Socket
810 ($att{BASEEXT} =$att{NAME}) =~ s#.*::##; #eg. Socket
811 ($att{ROOTEXT} =$att{FULLEXT}) =~ s#/?\Q$att{BASEEXT}\E$## ; # eg. /BSD/Foo
812 $att{ROOTEXT} = ($Is_VMS ? '' : '/') . $att{ROOTEXT} if $att{ROOTEXT};
814 ($att{DISTNAME}=$att{NAME}) =~ s#(::)#-#g unless $att{DISTNAME};
815 $att{VERSION} = "0.1" unless $att{VERSION};
818 # --- Initialize Perl Binary Locations
820 # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL'
821 # will be working versions of perl 5. miniperl has priority over perl
822 # for PERL to ensure that $(PERL) is usable while building ./ext/*
823 $att{'PERL'} = MY->find_perl(5.0, [ qw(miniperl perl) ],
824 [ grep defined $_, $att{PERL_SRC}, split(":", $ENV{PATH}), $Config{'bin'} ], $Verbose )
825 unless ($att{'PERL'} && -x $att{'PERL'});
827 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
828 ($att{'FULLPERL'} = $att{'PERL'}) =~ s/miniperl/perl/
829 unless ($att{'FULLPERL'} && -x $att{'FULLPERL'});
832 $att{'PERL'} = 'MCR ' . vmsify($att{'PERL'});
833 $att{'FULLPERL'} = 'MCR ' . vmsify($att{'FULLPERL'});
838 sub init_dirscan { # --- File and Directory Lists (.xs .pm etc)
840 my($name, %dir, %xs, %c, %h, %ignore, %pl_files);
841 local(%pm); #the sub in find() has to see this hash
842 $ignore{'test.pl'} = 1;
843 $ignore{'makefile.pl'} = 1 if $Is_VMS;
844 foreach $name (lsdir(".")){
845 next if ($name =~ /^\./ or $ignore{$name});
847 $dir{$name} = $name if (-f "$name/Makefile.PL");
848 } elsif ($name =~ /\.xs$/){
849 my($c); ($c = $name) =~ s/\.xs$/.c/;
852 } elsif ($name =~ /\.c$/){
854 } elsif ($name =~ /\.h$/){
856 } elsif ($name =~ /\.p[ml]$/){
857 $pm{$name} = "\$(INST_LIBDIR)/$name";
858 } elsif ($name =~ /\.PL$/ && $name ne "Makefile.PL") {
859 ($pl_files{$name} = $name) =~ s/\.PL$// ;
863 # Some larger extensions often wish to install a number of *.pm/pl
864 # files into the library in various locations.
866 # The attribute PMLIBDIRS holds an array reference which lists
867 # subdirectories which we should search for library files to
868 # install. PMLIBDIRS defaults to [ 'lib', $att{BASEEXT} ].
869 # We recursively search through the named directories (skipping
870 # any which don't exist or contain Makefile.PL files).
872 # For each *.pm or *.pl file found MY->libscan() is called with
873 # the default installation path in $_. The return value of libscan
874 # defines the actual installation location.
875 # The default libscan function simply returns $_.
876 # The file is skipped if libscan returns false.
878 # The default installation location passed to libscan in $_ is:
880 # ./*.pm => $(INST_LIBDIR)/*.pm
881 # ./xyz/... => $(INST_LIBDIR)/xyz/...
882 # ./lib/... => $(INST_LIB)/...
884 # In this way the 'lib' directory is seen as the root of the actual
885 # perl library whereas the others are relative to INST_LIBDIR
886 # (which includes ROOTEXT). This is a subtle distinction but one
887 # that's important for nested modules.
889 $att{PMLIBDIRS} = [ 'lib', $att{BASEEXT} ] unless $att{PMLIBDIRS};
891 #only existing directories that aren't in $dir are allowed
892 @{$att{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$att{PMLIBDIRS}};
894 if (@{$att{PMLIBDIRS}}){
895 print "Searching PMLIBDIRS: @{$att{PMLIBDIRS}}"
897 use File::Find; # try changing to require !
898 File::Find::find(sub {
899 # We now allow any file in PMLIBDIRS to be installed. nTk needs that, and
900 # we should allow it.
901 # return unless m/\.p[ml]$/;
902 return if -d $_; # anything else that Can't be copied?
903 my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)');
905 $prefix = '$(INST_LIB)' if (($striplibpath = $path) =~ s:^lib/::);
906 local($_) = "$prefix/$striplibpath";
907 my($inst) = MY->libscan();
908 print "libscan($path) => '$inst'" if ($Verbose >= 2);
911 }, @{$att{PMLIBDIRS}});
914 $att{DIR} = [sort keys %dir] unless $att{DIRS};
915 $att{XS} = \%xs unless $att{XS};
916 $att{PM} = \%pm unless $att{PM};
917 $att{C} = [sort keys %c] unless $att{C};
918 my(@o_files) = @{$att{C}};
919 my($sufx) = $Is_VMS ? '.obj' : '.o';
920 $att{O_FILES} = [grep s/\.c$/$sufx/, @o_files] ;
921 $att{H} = [sort keys %h] unless $att{H};
922 $att{PL_FILES} = \%pl_files unless $att{PL_FILES};
927 return undef if m:/RCS/: ;
931 sub init_others { # --- Initialize Other Attributes
933 for $key (keys(%Recognized_Att_Keys), keys(%Other_Att_Keys)){
934 # avoid warnings for uninitialized vars
935 next if exists $att{$key};
939 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $att{'LIBS'}
940 # Lets look at $att{LIBS} carefully: It may be an anon array, a string or
941 # undefined. In any case we turn it into an anon array:
942 $att{LIBS}=[] unless $att{LIBS};
943 $att{LIBS}=[$att{LIBS}] if ref \$att{LIBS} eq SCALAR;
944 foreach ( @{$att{'LIBS'}} ){
945 s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
946 my(@libs) = MY->extliblist($_);
947 if ($libs[0] or $libs[1] or $libs[2]){
948 @att{EXTRALIBS, BSLOADLIBS, LDLOADLIBS} = @libs;
953 print STDOUT "CONFIG must be an array ref\n"
954 if ($att{CONFIG} and ref $att{CONFIG} ne 'ARRAY');
955 $att{CONFIG} = [] unless (ref $att{CONFIG});
956 push(@{$att{CONFIG}},
957 qw( cc libc ldflags lddlflags ccdlflags cccdlflags
958 ranlib so dlext dlsrc installprivlib installarchlib
960 push(@{$att{CONFIG}}, 'shellflags') if $Config{'shellflags'};
963 $att{OBJECT} = '$(BASEEXT).obj' unless $att{OBJECT};
964 $att{OBJECT} =~ s/[^,\s]\s+/, /g;
965 $att{OBJECT} =~ s/\n+/, /g;
966 $att{OBJECT} =~ s#\.o,#\.obj,#;
968 $att{OBJECT} = '$(BASEEXT).o' unless $att{OBJECT};
969 $att{OBJECT} =~ s/\n+/ \\\n\t/g;
971 $att{BOOTDEP} = (-f "$att{BASEEXT}_BS") ? "$att{BASEEXT}_BS" : "";
972 $att{LD} = ($Config{'ld'} || 'ld') unless $att{LD};
973 $att{LDFROM} = '$(OBJECT)' unless $att{LDFROM};
974 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
975 # the 'dynamic' section of MM. We don't have this problem with
976 # 'static', since we either must use it (%Config says we can't
977 # use dynamic loading) or the caller asked for it explicitly.
978 if (!$att{LINKTYPE}) {
979 $att{LINKTYPE} = grep(/dynamic/,@{$att{SKIP} || []})
981 : ($Config{'usedl'} ? 'dynamic' : 'static');
984 # These get overridden for VMS and maybe some other systems
986 $att{MAKEFILE} = "Makefile";
987 $att{RM_F} = "rm -f";
988 $att{RM_RF} = "rm -rf";
989 $att{TOUCH} = "touch";
996 my($dir, $regex) = @_;
998 opendir(DIR, $_[0] || ".") or die "opendir: $!";
1001 @ls = grep(/$regex/, @ls) if $regex;
1007 my($self, $ver, $names, $dirs, $trace) = @_;
1010 print "Looking for perl $ver by these names: ";
1012 print "in these dirs:";
1015 foreach $dir (@$dirs){
1016 next unless defined $dir; # $att{PERL_SRC} may be undefined
1017 foreach $name (@$names){
1018 print "Checking $dir/$name " if ($trace >= 2);
1020 $name .= ".exe" unless -x "$dir/$name";
1022 next unless -x "$dir/$name";
1023 print "Executing $dir/$name" if ($trace >= 2);
1026 my($vmscmd) = 'MCR ' . vmsify("$dir/$name");
1027 $out = `$vmscmd -e "require $ver; print ""VER_OK\n"""`;
1029 $out = `$dir/$name -e 'require $ver; print "VER_OK\n" ' 2>&1`;
1031 if ($out =~ /VER_OK/) {
1032 print "Using $dir/$name" if $trace;
1033 return "$dir/$name";
1037 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
1038 0; # false and not empty
1042 sub post_initialize{
1052 DISTNAME = $att{DISTNAME}
1053 VERSION = $att{VERSION}
1055 # In which library should we install this extension?
1056 # This is typically the same as PERL_LIB.
1057 # (also see INST_LIBDIR and relationship to ROOTEXT)
1058 INST_LIB = $att{INST_LIB}
1059 INST_ARCHLIB = $att{INST_ARCHLIB}
1060 INST_EXE = $att{INST_EXE}
1062 # Perl library to use when building the extension
1063 PERL_LIB = $att{PERL_LIB}
1064 PERL_ARCHLIB = $att{PERL_ARCHLIB}
1065 LIBPERL_A = $att{LIBPERL_A}
1068 # Define I_PERL_LIBS to include the required -Ipaths
1069 # To be cute we only include PERL_ARCHLIB if different
1070 # To be portable we add quotes for VMS
1071 my(@i_perl_libs) = qw{-I$(PERL_ARCHLIB) -I$(PERL_LIB)};
1072 shift(@i_perl_libs) if ($att{PERL_ARCHLIB} eq $att{PERL_LIB});
1074 push @m, "I_PERL_LIBS = \"".join('" "',@i_perl_libs)."\"\n";
1076 push @m, "I_PERL_LIBS = ".join(' ',@i_perl_libs)."\n";
1080 # Where is the perl source code located?
1081 PERL_SRC = $att{PERL_SRC}\n" if $att{PERL_SRC};
1084 # Perl header files (will eventually be under PERL_LIB)
1085 PERL_INC = $att{PERL_INC}
1088 FULLPERL = $att{'FULLPERL'}
1091 # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
1092 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
1093 # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
1094 FULLEXT = $att{FULLEXT}
1095 BASEEXT = $att{BASEEXT}
1096 ROOTEXT = $att{ROOTEXT}
1100 DEFINE = $att{DEFINE}
1101 OBJECT = $att{OBJECT}
1102 LDFROM = $att{LDFROM}
1103 LINKTYPE = $att{LINKTYPE}
1105 # Handy lists of source code files:
1106 XS_FILES= ".join(" \\\n\t", sort keys %{$att{XS}})."
1107 C_FILES = ".join(" \\\n\t", @{$att{C}})."
1108 O_FILES = ".join(" \\\n\t", @{$att{O_FILES}})."
1109 H_FILES = ".join(" \\\n\t", @{$att{H}})."
1115 .PHONY: all config static dynamic test linkext
1117 # This extension may link to it's own library (see SDBM_File)
1118 MYEXTLIB = $att{MYEXTLIB}
1120 # Where is the Config information that we are using/depend on
1121 CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm \$(PERL_INC)/config.h
1125 # Where to put things:
1126 INST_LIBDIR = $(INST_LIB)$(ROOTEXT)
1127 INST_ARCHLIBDIR = $(INST_ARCHLIB)$(ROOTEXT)
1129 INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT)
1130 INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT)
1134 INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT).a
1135 INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(BASEEXT).$(DLEXT)
1136 INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
1137 INST_PM = '.join(" \\\n\t", sort values %{$att{PM}}).'
1143 $Const_cccmd=0; # package global
1146 my($self,$libperl)=@_;
1147 $libperl or $libperl = $att{LIBPERL_A} || "libperl.a" ;
1148 # This is implemented in the same manner as extliblist,
1149 # e.g., do both and compare results during the transition period.
1150 my($cc,$ccflags,$optimize,$large,$split, $shflags)
1151 = @Config{qw(cc ccflags optimize large split shellflags)};
1154 $shflags = '' unless $shflags;
1155 my($prog, $old, $uc, $perltype);
1157 unless ($Const_cccmd++){
1158 chop($old = `cd $att{PERL_SRC}; sh $shflags ./cflags $libperl $att{BASEEXT}.c`)
1160 $Const_cccmd++; # shut up typo warning
1166 DE => '-DDEBUGGING -DEMBED',
1167 M => '-DEMBED -DMULTIPLICITY',
1168 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
1171 if ($libperl =~ /libperl(\w*)\.a/){
1174 $uc = ""; # avoid warning
1176 $perltype = $map{$uc} ? $map{$uc} : "";
1184 ( $name = $att{NAME} . "_cflags" ) =~ s/:/_/g ;
1185 if ($prog = $Config{$name}) {
1186 # Expand hints for this extension via the shell
1187 print STDOUT "Processing $name hint:\n" if $Verbose;
1189 ccflags=\"$ccflags\"
1190 optimize=\"$optimize\"
1191 perltype=\"$perltype\"
1192 optdebug=\"$optdebug\"
1197 echo ccflags=\$ccflags
1198 echo optimize=\$optimize
1199 echo perltype=\$perltype
1200 echo optdebug=\$optdebug
1207 if ($line =~ /(.*?)=\s*(.*)\s*$/){
1209 print STDOUT " $1 = $2" if $Verbose;
1211 print STDOUT "Unrecognised result from hint: '$line'\n";
1214 ( $cc,$ccflags,$perltype,$optdebug,$optimize,$large,$split )=@cflags{
1215 qw( cc ccflags perltype optdebug optimize large split)};
1219 $optimize = $optdebug;
1222 my($new) = "$cc -c $ccflags $optimize $perltype $large $split";
1223 if (defined($old) and $new ne $old) {
1224 print STDOUT "Warning (non-fatal): cflags evaluation in MakeMaker differs from shell output\n"
1225 ." package: $att{NAME}\n"
1228 ." Using 'old' set.\n"
1229 ."Please notify perl5-porters\@nicoh.com\n";
1231 my($cccmd)=($old) ? $old : $new;
1232 $cccmd =~ s/^\s*\Q$Config{'cc'}\E\s/\$(CC) /;
1237 # --- Constants Sections ---
1241 push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
1243 foreach $m (@{$att{'CONFIG'}}){
1244 next if $once_only{$m};
1245 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
1246 unless exists $Config{$m};
1247 push @m, "\U$m\E = $Config{$m}\n";
1256 # $att{NAME} might depend on some other libraries:
1257 # (These comments may need revising:)
1259 # Dependent libraries can be linked in one of three ways:
1261 # 1. (For static extensions) by the ld command when the perl binary
1262 # is linked with the extension library. See EXTRALIBS below.
1264 # 2. (For dynamic extensions) by the ld command when the shared
1265 # object is built/linked. See LDLOADLIBS below.
1267 # 3. (For dynamic extensions) by the DynaLoader when the shared
1268 # object is loaded. See BSLOADLIBS below.
1270 # EXTRALIBS = List of libraries that need to be linked with when
1271 # linking a perl binary which includes this extension
1272 # Only those libraries that actually exist are included.
1273 # These are written to a file and used when linking perl.
1275 # LDLOADLIBS = List of those libraries which can or must be linked into
1276 # the shared library when created using ld. These may be
1277 # static or dynamic libraries.
1279 # BSLOADLIBS = List of those libraries that are needed but can be
1280 # linked in dynamically at run time on this platform.
1281 # SunOS/Solaris does not need this because ld records
1282 # the information (from LDLOADLIBS) into the object file.
1283 # This list is used to create a .bs (bootstrap) file.
1285 EXTRALIBS = $att{'EXTRALIBS'}
1286 LDLOADLIBS = $att{'LDLOADLIBS'}
1287 BSLOADLIBS = $att{'BSLOADLIBS'}
1292 # --- Tool Sections ---
1295 my($self, %attribs) = @_;
1297 $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
1299 # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
1300 AUTOSPLITFILE = $(PERL) $(I_PERL_LIBS) -e 'use AutoSplit;}.$asl.q{autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
1306 my($xsdir) = '$(PERL_LIB)/ExtUtils';
1307 # drop back to old location if xsubpp is not in new location yet
1308 $xsdir = '$(PERL_SRC)/ext' unless (-f "$att{PERL_LIB}/ExtUtils/xsubpp");
1309 my(@tmdeps) = ('$(XSUBPPDIR)/typemap');
1310 push(@tmdeps, "typemap") if -f "typemap";
1311 my(@tmargs) = map("-typemap $_", @tmdeps);
1314 XSUBPP = \$(XSUBPPDIR)/xsubpp
1315 XSUBPPDEPS = @tmdeps
1316 XSUBPPARGS = @tmargs
1331 # The following is a portable way to say mkdir -p
1332 MKPATH = $(PERL) -wle '$$"="/"; foreach $$p (@ARGV){ next if -d $$p; my(@p); foreach(split(/\//,$$p)){ push(@p,$$_); next if -d "@p/"; print "mkdir @p"; mkdir("@p",0777)||die $$! }} exit 0;'
1342 my(@m,@pasthru,$key);
1343 # It has to be considered carefully, which variables are apt to be passed through, e.g. PERL_SRC
1344 # is not suited for subdirectories, as it might be relativ to the parent directory.
1345 # Probably we need a PASTHRU2 variable. PASTHRU1 is a conservative approach, that hardly changes
1346 # MakeMaker between version 4.086 and 4.09.
1347 push @m, "\nPASTHRU1 = ";
1348 foreach $key (qw(INST_ARCHLIB INST_EXE INST_LIB LIBPERL_A LINKTYPE)){
1349 push @pasthru, "$key=\"\$($key)\"";
1351 push @m, join "\\\n\t", @pasthru;
1355 # --- Translation Sections ---
1361 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $(INC) $*.c
1369 $(PERL) $(XSUBPP) $(XSUBPPARGS) $*.xs >$*.tc && mv $*.tc $@
1373 sub xs_o { # many makes are too dumb to use xs_c then c_o
1376 $(PERL) $(XSUBPP) $(XSUBPPARGS) $*.xs >xstmp.c && mv xstmp.c $*.c
1377 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $(INC) $*.c
1382 # --- Target Sections ---
1387 all :: config linkext $(INST_PM)
1390 config :: '.$att{MAKEFILE}.' $(INST_LIBDIR)/.exists $(INST_ARCHAUTODIR)/.exists
1393 push @m, MM->dir_target('$(INST_LIBDIR)', '$(INST_ARCHAUTODIR)');
1396 $(O_FILES): $(H_FILES)
1397 ' if @{$att{O_FILES} || []} && @{$att{H} || []};
1402 my($self, %attribs) = @_;
1403 # LINKTYPE => static or dynamic
1404 my($linktype) = $attribs{LINKTYPE} || '$(LINKTYPE)';
1406 linkext :: $linktype
1412 my($self,%attribs) = @_;
1414 return '' if ($Config{'osname'} ne 'aix');
1416 my($funcs) = $attribs{DL_FUNCS} || $att{DL_FUNCS} || {};
1417 my($vars) = $attribs{DL_VARS} || $att{DL_VARS} || [];
1421 dynamic :: $att{BASEEXT}.exp
1423 ") unless $skip{'dynamic'};
1426 static :: $att{BASEEXT}.exp
1428 ") unless $skip{'static'};
1431 $att{BASEEXT}.exp: Makefile.PL
1432 ",' $(PERL) $(I_PERL_LIBS) -e \'use ExtUtils::MakeMaker qw(&mksymlists); \\
1433 &mksymlists(DL_FUNCS => ',
1434 %$funcs ? neatvalue($funcs) : '""',', DL_VARS => ',
1435 @$vars ? neatvalue($vars) : '""', ", NAME => \"$att{NAME}\")'
1441 # --- Dynamic Loading Sections ---
1445 # $(INST_PM) has been moved to the all: target.
1446 # It remains here for awhile to allow for old usage: "make dynamic"
1447 dynamic :: '.$att{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM)
1453 my($self, %attribs) = @_;
1455 BOOTSTRAP = '."$att{BASEEXT}.bs".'
1457 # As MakeMaker mkbootstrap might not write a file (if none is required)
1458 # we use touch to prevent make continually trying to remake it.
1459 # The DynaLoader only reads a non-empty file.
1460 $(BOOTSTRAP): '."$att{MAKEFILE} $att{BOOTDEP}".'
1461 @ echo "Running mkbootstrap for $(NAME) ($(BSLOADLIBS))"
1462 @ $(PERL) $(I_PERL_LIBS) \
1463 -e \'use ExtUtils::MakeMaker qw(&mkbootstrap); &mkbootstrap("$(BSLOADLIBS)");\' \
1464 INST_LIB=$(INST_LIB) INST_ARCHLIB=$(INST_ARCHLIB) PERL_SRC=$(PERL_SRC) NAME=$(NAME)
1465 @ $(TOUCH) $(BOOTSTRAP)
1467 $(INST_BOOT): $(BOOTSTRAP)
1468 @ '.$att{RM_RF}.' $(INST_BOOT)
1469 -'.$att{CP}.' $(BOOTSTRAP) $(INST_BOOT)
1475 my($self, %attribs) = @_;
1476 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
1477 my($armaybe) = $attribs{ARMAYBE} || $att{ARMAYBE} || ":";
1478 my($ldfrom) = '$(LDFROM)';
1479 my($osname) = $Config{'osname'};
1480 $armaybe = 'ar' if ($osname eq 'dec_osf' and $armaybe eq ':');
1483 # This section creates the dynamically loadable $(INST_DYNAMIC)
1484 # from $(OBJECT) and possibly $(MYEXTLIB).
1485 ARMAYBE = '.$armaybe.'
1486 OTHERLDFLAGS = '.$otherldflags.'
1488 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists
1490 if ($armaybe ne ':'){
1492 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
1493 push(@m,' $(RANLIB) '."$ldfrom\n");
1495 $ldfrom = "-all $ldfrom -none" if ($osname eq 'dec_osf');
1496 push(@m,' $(LD) -o $@ $(LDDLFLAGS) '.$ldfrom.
1497 ' $(OTHERLDFLAGS) $(MYEXTLIB) $(LDLOADLIBS)'."\n");
1499 push @m, MM->dir_target('$(INST_ARCHAUTODIR)');
1504 # --- Static Loading Sections ---
1508 # $(INST_PM) has been moved to the all: target.
1509 # It remains here for awhile to allow for old usage: "make static"
1510 static :: '.$att{MAKEFILE}.' $(INST_STATIC) $(INST_PM)
1518 $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists
1520 # If this extension has it's own library (eg SDBM_File)
1521 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
1522 push(@m, " $att{CP} \$(MYEXTLIB) \$\@\n") if $att{MYEXTLIB};
1525 ar cr $@ $(OBJECT) && $(RANLIB) $@
1526 @echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
1529 # Old mechanism - still available:
1531 push(@m, <<'END') if $att{PERL_SRC};
1532 @ echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
1534 push @m, MM->dir_target('$(INST_ARCHAUTODIR)');
1540 my($self, %attribs) = @_;
1541 # By default .pm files are split into the architecture independent
1542 # library. This is a good thing. If a specific module requires that
1543 # it's .pm files are split into the architecture specific library
1544 # then it should use: installpm => {SPLITLIB=>'$(INST_ARCHLIB)'}
1545 # Note that installperl currently interferes with this (Config.pm)
1546 # User can disable split by saying: installpm => {SPLITLIB=>''}
1547 my($splitlib) = '$(INST_LIB)'; # NOT arch specific by default
1548 $splitlib = $attribs{SPLITLIB} if exists $attribs{SPLITLIB};
1550 foreach $dist (sort keys %{$att{PM}}){
1551 my($inst) = $att{PM}->{$dist};
1552 push(@m, "\n# installpm: $dist => $inst, splitlib=$splitlib\n");
1553 push(@m, MY->installpm_x($dist, $inst, $splitlib));
1559 sub installpm_x { # called by installpm per file
1560 my($self, $dist, $inst, $splitlib) = @_;
1561 my($instdir) = $inst =~ m|(.*)/|;
1564 $inst: $dist Makefile $instdir/.exists
1565 ".' @ '.$att{RM_F}.' $@
1566 '."$att{CP} $dist".' $@
1568 push(@m, "\t\@\$(AUTOSPLITFILE) \$@ $splitlib/auto\n")
1569 if ($splitlib and $inst =~ m/\.pm$/);
1571 push @m, MM->dir_target($instdir);
1576 return "" unless $att{PL_FILES};
1578 foreach $plfile (sort keys %{$att{PL_FILES}}) {
1580 all :: $att{PL_FILES}->{$plfile}
1582 $att{PL_FILES}->{$plfile} :: $plfile
1583 \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile
1590 return "" unless $att{EXE_FILES} && ref $att{EXE_FILES} eq "ARRAY";
1591 my(@m, $from, $to, %fromto, @to);
1592 for $from (@{$att{EXE_FILES}}) {
1593 local($_)= '$(INST_EXE)/' . basename($from);
1594 $to = MY->exescan();
1595 print "exescan($from) => '$to'" if ($Verbose >=2);
1598 @to = values %fromto;
1600 EXE_FILES = @{$att{EXE_FILES}}
1608 while (($from,$to) = each %fromto) {
1610 $to: $from $att{MAKEFILE}
1620 # --- Sub-directory Sections ---
1624 # This method provides a mechanism to automatically deal with
1625 # subdirectories containing further Makefile.PL scripts.
1626 # It calls the subdir_x() method for each subdirectory.
1627 foreach(grep -d, &lsdir()){
1629 next unless -f "$_/Makefile\.PL" ;
1630 print "Including $_ subdirectory" if ($Verbose);
1631 push(@m, MY->subdir_x($_));
1635 # The default clean, realclean and test targets in this Makefile
1636 # have automatically been given entries for each subdir.
1641 push(@m, "\n# none")
1646 sub runsubdirpl{ # Experimental! See subdir_x section
1647 my($self,$subdir) = @_;
1648 chdir($subdir) or die "chdir($subdir): $!";
1649 ExtUtils::MakeMaker::check_hints();
1650 require "Makefile.PL";
1654 my($self, $subdir) = @_;
1656 # The intention is that the calling Makefile.PL should define the
1657 # $(SUBDIR_MAKEFILE_PL_ARGS) make macro to contain whatever
1658 # information needs to be passed down to the other Makefile.PL scripts.
1659 # If this does not suit your needs you'll need to write your own
1660 # MY::subdir_x() method to override this one.
1662 config :: $subdir/$att{MAKEFILE}
1663 cd $subdir && \$(MAKE) config \$(PASTHRU1) \$(SUBDIR_MAKEFILE_PL_ARGS)
1665 $subdir/$att{MAKEFILE}: $subdir/Makefile.PL \$(CONFIGDEP)
1666 }.' @echo "Rebuilding $@ ..."
1667 $(PERL) $(I_PERL_LIBS) \\
1668 -e "use ExtUtils::MakeMaker; MM->runsubdirpl(qw('.$subdir.'))" \\
1669 $(PASTHRU1) $(SUBDIR_MAKEFILE_PL_ARGS)
1670 @echo "Rebuild of $@ complete."
1674 cd $subdir && \$(MAKE) all \$(PASTHRU1)
1680 # --- Cleanup and Distribution Sections ---
1683 my($self, %attribs) = @_;
1686 # Delete temporary files but do not touch installed files. We don\'t delete
1687 # the Makefile here so a later make realclean still has a makefile to use.
1691 # clean subdirectories first
1692 push(@m, map("\t-cd $_ && test -f $att{MAKEFILE} && \$(MAKE) clean\n",@{$att{DIR}}));
1693 my(@otherfiles) = values %{$att{XS}}; # .c files from *.xs files
1694 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
1695 push(@otherfiles, "./blib");
1696 push(@m, " -$att{RM_RF} *~ t/*~ *.o *.a mon.out core so_locations "
1697 ."\$(BOOTSTRAP) \$(BASEEXT).bso \$(BASEEXT).exp @otherfiles\n");
1698 # See realclean and ext/utils/make_ext for usage of Makefile.old
1699 push(@m, " -$att{MV} $att{MAKEFILE} $att{MAKEFILE}.old 2>/dev/null\n");
1700 push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
1705 my($self, %attribs) = @_;
1708 # Delete temporary files (via clean) and also delete installed files
1709 realclean purge :: clean
1711 # realclean subdirectories first (already cleaned)
1712 my $sub = "\t-cd %s && test -f %s && \$(MAKE) %s realclean\n";
1713 foreach(@{$att{DIR}}){
1714 push(@m, sprintf($sub,$_,"$att{MAKEFILE}.old","-f $att{MAKEFILE}.old"));
1715 push(@m, sprintf($sub,$_,"$att{MAKEFILE}",''));
1717 push(@m, " $att{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n");
1718 push(@m, " $att{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n");
1719 push(@m, " $att{RM_F} \$(INST_STATIC) \$(INST_PM)\n");
1720 my(@otherfiles) = ($att{MAKEFILE},
1721 "$att{MAKEFILE}.old"); # Makefiles last
1722 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
1723 push(@m, " $att{RM_RF} @otherfiles\n") if @otherfiles;
1724 push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
1730 my($self, %attribs) = @_;
1731 # VERSION should be sanitised before use as a file name
1732 my($tarname) = $attribs{TARNAME} || '$(DISTNAME)-$(VERSION)';
1733 my($tarflags) = $attribs{TARFLAGS} || 'cvf';
1734 my($compress) = $attribs{COMPRESS} || 'compress'; # eg gzip
1735 my($preop) = $attribs{PREOP} || '@:'; # e.g., update MANIFEST
1736 my($postop) = $attribs{POSTOP} || '@:';
1737 my($mkfiles) = join(' ', map("$_/$att{MAKEFILE} $_/$att{MAKEFILE}.old", ".", @{$att{DIR}}));
1742 cd .. && tar $tarflags $tarname.tar \$(BASEEXT)
1743 cd .. && $compress $tarname.tar
1749 # --- Test and Installation Sections ---
1752 my($self, %attribs) = @_;
1753 my($tests) = $attribs{TESTS} || (-d "t" ? "t/*.t" : "");
1760 push(@m, <<"END") if $tests;
1761 \$(FULLPERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) -e 'use Test::Harness qw(&runtests \$\$verbose); \$\$verbose=\$(TEST_VERBOSE); runtests \@ARGV;' $tests
1763 push(@m, <<'END') if -f "test.pl";
1764 $(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) test.pl
1766 push(@m, map("\tcd $_ && test -f $att{MAKEFILE} && \$(MAKE) test \$(PASTHRU)\n",
1768 push(@m, "\t\@echo 'No tests defined for \$(NAME) extension.'\n") unless @m > 1;
1774 my($self, %attribs) = @_;
1778 @ $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \\
1779 -e "use ExtUtils::MakeMaker; MM->writedoc('Module', '$(NAME)', \\
1780 'LINKTYPE=$(LINKTYPE)', 'VERSION=$(VERSION)', 'EXE_FILES=$(EXE_FILES)')"
1784 install :: pure_install doc_install
1788 # install subdirectories first
1789 push(@m, map("\tcd $_ && test -f $att{MAKEFILE} && \$(MAKE) install\n",@{$att{DIR}}));
1791 push(@m, "\t: perl5.000 and MM pre 3.8 autosplit into INST_ARCHLIB, we delete these old files here
1792 $att{RM_F} $Config{'installarchlib'}/auto/\$(FULLEXT)/*.al
1793 $att{RM_F} $Config{'installarchlib'}/auto/\$(FULLEXT)/*.ix
1794 \$(MAKE) INST_LIB=$Config{'installprivlib'} INST_ARCHLIB=$Config{'installarchlib'} INST_EXE=$Config{'installbin'}
1801 '# Phony target to force checking subdirectories.
1810 PERL_HDRS = $(PERL_INC)/EXTERN.h $(PERL_INC)/INTERN.h \
1811 $(PERL_INC)/XSUB.h $(PERL_INC)/av.h $(PERL_INC)/cop.h \
1812 $(PERL_INC)/cv.h $(PERL_INC)/dosish.h $(PERL_INC)/embed.h \
1813 $(PERL_INC)/form.h $(PERL_INC)/gv.h $(PERL_INC)/handy.h \
1814 $(PERL_INC)/hv.h $(PERL_INC)/keywords.h $(PERL_INC)/mg.h \
1815 $(PERL_INC)/op.h $(PERL_INC)/opcode.h $(PERL_INC)/patchlevel.h \
1816 $(PERL_INC)/perl.h $(PERL_INC)/perly.h $(PERL_INC)/pp.h \
1817 $(PERL_INC)/proto.h $(PERL_INC)/regcomp.h $(PERL_INC)/regexp.h \
1818 $(PERL_INC)/scope.h $(PERL_INC)/sv.h $(PERL_INC)/unixish.h \
1819 $(PERL_INC)/util.h $(PERL_INC)/config.h
1821 $(OBJECT) : $(PERL_HDRS)
1825 # Check for unpropogated config.sh changes. Should never happen.
1826 # We do NOT just update config.h because that is not sufficient.
1827 # An out of date config.h is not fatal but complains loudly!
1828 $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
1829 -@echo "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
1831 $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
1832 @echo "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
1833 cd $(PERL_SRC) && $(MAKE) lib/Config.pm
1834 ') if $att{PERL_SRC};
1836 push(@m, join(" ", values %{$att{XS}})." : \$(XSUBPPDEPS)\n")
1843 # We do not know what target was originally specified so we
1844 # must force a manual rerun to be sure. But as it should only
1845 # happen very rarely it is not a significant problem.
1847 $(OBJECT) : '.$att{MAKEFILE}.'
1849 # We take a very conservative approach here, but it\'s worth it.
1850 # We move Makefile to Makefile.old here to avoid gnu make looping.
1851 '.$att{MAKEFILE}.': Makefile.PL $(CONFIGDEP)
1852 @echo "Makefile out-of-date with respect to $?"
1853 @echo "Cleaning current config before rebuilding Makefile..."
1854 -@mv '."$att{MAKEFILE} $att{MAKEFILE}.old".'
1855 -$(MAKE) -f '.$att{MAKEFILE}.'.old clean >/dev/null 2>&1 || true
1856 $(PERL) $(I_PERL_LIBS) Makefile.PL '."@ARGV".'
1857 @echo "Now you must rerun make."; false
1865 # --- Make-Directories section (internal method) ---
1866 # dir_target(@array) returns a Makefile entry for the file .exists in each
1867 # named directory. Returns nothing, if the entry has already been processed.
1868 # We're helpless though, if the same directory comes as $(FOO) _and_ as "bar".
1869 # Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the
1870 # prerequisite, because there has to be one, something that doesn't change
1872 %Dir_Target = (); # package global
1877 foreach $dir (@dirs) {
1878 next if $Dir_Target{$dir};
1880 $dir/.exists :: \$(PERL)
1882 \@ \$(TOUCH) $dir/.exists
1884 $Dir_Target{$dir}++;
1889 # --- Make-A-Perl section ---
1892 my($self, %attribs) = @_;
1894 my(%searchdirs)=($att{PERL_ARCHLIB} => 1, $att{INST_ARCHLIB} => 1);
1895 my(@searchdirs)=keys %searchdirs;
1896 # And as it's not yet built, we add the current extension
1897 my(@static)="$att{INST_ARCHLIB}/auto/$att{FULLEXT}/$att{BASEEXT}.a";
1898 my(@perlinc) = ($att{INST_ARCHLIB}, $att{INST_LIB}, $att{PERL_ARCHLIB}, $att{PERL_LIB});
1899 MY->makeaperl('MAKE' => $att{MAKEFILE},
1900 'DIRS' => \@searchdirs,
1902 'INCL' => \@perlinc,
1903 'TARGET' => $att{MAP_TARGET},
1905 'LIBPERL' => $att{LIBPERL_A}
1910 my($self, %attribs) = @_;
1911 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
1912 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
1914 my($cccmd, $linkcmd);
1916 # This emulates cflags to get the compiler invocation...
1917 $cccmd = MY->const_cccmd($libperl);
1918 $cccmd =~ s/^CCCMD\s*=\s*//;
1920 $cccmd =~ s/\s/ -I$att{PERL_INC} /;
1921 $cccmd .= " $Config{'cccdlflags'}" if ($Config{'d_shrplib'});
1923 # The front matter of the linkcommand...
1924 $linkcmd = join ' ', "\$(CC)",
1925 grep($_, @Config{qw(large split ldflags ccdlflags)});
1926 $linkcmd =~ s/\s+/ /g;
1928 # Which *.a files could we make use of...
1930 File::Find::find(sub {
1931 return unless m/\.a$/;
1932 return if m/^libperl/;
1933 # don't include the installed version of this extension
1934 return if $File::Find::name =~ m:auto/$att{FULLEXT}/$att{BASEEXT}.a$:;
1935 $static{fastcwd() . "/" . $_}++;
1936 }, grep( -d $_, @{$searchdirs || []}) );
1938 # We trust that what has been handed in as argument, will be buildable
1939 $static = [] unless $static;
1940 @static{@{$static}} = (1) x @{$static};
1942 $extra = [] unless $extra && ref $extra eq 'ARRAY';
1943 for (sort keys %static) {
1945 $_ = dirname($_) . "/extralibs.ld";
1949 grep(s/^/-I/, @$perlinc);
1951 $target = "perl" unless $target;
1952 $tmp = "." unless $tmp;
1955 # --- MakeMaker makeaperl section ---
1956 MAP_TARGET = $target
1957 FULLPERL = $att{'FULLPERL'}
1958 MAP_LINKCMD = $linkcmd
1959 MAP_PERLINC = @{$perlinc}
1961 join(" ", sort keys %static), "
1962 MAP_PRELIBS = $Config{'libs'} $Config{'cryptlib'}
1965 unless ($libperl && -f $libperl) {
1966 my $dir = (defined $att{PERL_SRC}) ? $att{PERL_SRC}
1967 : "$Config{'installarchlib'}/CORE";
1968 $libperl = "libperl.a" unless $libperl;
1969 $libperl = "$dir/$libperl";
1970 print STDOUT "Warning: $libperl not found"
1971 unless (-f $libperl || defined($att{PERL_SRC}));
1975 MAP_LIBPERL = $libperl
1979 extralibs.ld: @$extra
1985 push @m, "\tcat $_ >> \$\@\n";
1989 \$(MAP_TARGET): $tmp/perlmain.o \$(MAP_LIBPERL) \$(MAP_STATIC) extralibs.ld
1990 \$(MAP_LINKCMD) -o \$\@ $tmp/perlmain.o \$(MAP_LIBPERL) \$(MAP_STATIC) `cat extralibs.ld` \$(MAP_PRELIBS)
1991 @ echo 'To install the new \"\$(MAP_TARGET)\" binary, call'
1992 @ echo ' make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
1993 @ echo 'To remove the intermediate files say'
1994 @ echo ' make -f $makefilename map_clean'
1996 $tmp/perlmain.o: $tmp/perlmain.c
1998 push @m, "\tcd $tmp && $cccmd perlmain.c\n";
2001 $tmp/perlmain.c: $makefilename}, q{
2003 @ $(FULLPERL) $(MAP_PERLINC) -e 'use ExtUtils::Miniperl; \\
2004 writemain(grep s#.*/auto/##, qw|$(MAP_STATIC)|)' > $@.tmp && mv $@.tmp $@
2008 # We write EXTRA outside the perl program to have it eval'd by the shell
2011 @ $(FULLPERL) -e 'use ExtUtils::MakeMaker; MM->writedoc("Perl binary",' \\
2012 -e '"$(MAP_TARGET)", "MAP_STATIC=$(MAP_STATIC)",' \\
2013 -e '"MAP_EXTRA=@ARGV", "MAP_LIBPERL=$(MAP_LIBPERL)")' -- `cat extralibs.ld`
2017 inst_perl: pure_inst_perl doc_inst_perl
2019 pure_inst_perl: \$(MAP_TARGET)
2020 $att{CP} \$(MAP_TARGET) $Config{'installbin'}/\$(MAP_TARGET)
2022 realclean :: map_clean
2024 distclean :: realclean
2027 $att{RM_F} $tmp/perlmain.o $tmp/perlmain.c $makefilename
2033 # --- Determine libraries to use and how to use them ---
2036 my($self, $potential_libs)=@_;
2037 return ("", "", "") unless $potential_libs;
2038 print STDOUT "Potential libraries are '$potential_libs':" if $Verbose;
2040 my($so) = $Config{'so'};
2041 my($libs) = $Config{'libs'};
2043 # compute $extralibs, $bsloadlibs and $ldloadlibs from
2045 # this is a rewrite of Andy Dougherty's extliblist in perl
2046 # its home is in <distribution>/ext/util
2048 my(@searchpath); # from "-L/path" entries in $potential_libs
2049 my(@libpath) = split " ", $Config{'libpth'};
2050 my(@ldloadlibs, @bsloadlibs, @extralibs);
2051 my($fullname, $thislib, $thispth, @fullname);
2052 my($pwd) = fastcwd(); # from Cwd.pm
2055 foreach $thislib (split ' ', $potential_libs){
2057 # Handle possible linker path arguments.
2058 if ($thislib =~ s/^(-[LR])//){ # save path flag type
2060 unless (-d $thislib){
2061 print STDOUT "$ptype$thislib ignored, directory does not exist\n"
2065 if ($thislib !~ m|^/|) {
2066 print STDOUT "Warning: $ptype$thislib changed to $ptype$pwd/$thislib\n";
2067 $thislib = "$pwd/$thislib";
2069 push(@searchpath, $thislib);
2070 push(@extralibs, "$ptype$thislib");
2071 push(@ldloadlibs, "$ptype$thislib");
2075 # Handle possible library arguments.
2076 unless ($thislib =~ s/^-l//){
2077 print STDOUT "Unrecognized argument in LIBS ignored: '$thislib'\n";
2082 foreach $thispth (@searchpath, @libpath){
2084 # Try to find the full name of the library. We need this to
2085 # determine whether it's a dynamically-loadable library or not.
2086 # This tends to be subject to various os-specific quirks.
2087 # For gcc-2.6.2 on linux (March 1995), DLD can not load
2088 # .sa libraries, with the exception of libm.sa, so we
2089 # deliberately skip them.
2090 if (@fullname = lsdir($thispth,"^lib$thislib\.$so\.[0-9]+")){
2091 # Take care that libfoo.so.10 wins against libfoo.so.9.
2092 # Compare two libraries to find the most recent version
2093 # number. E.g. if you have libfoo.so.9.0.7 and
2094 # libfoo.so.10.1, first convert all digits into two
2095 # decimal places. Then we'll add ".00" to the shorter
2096 # strings so that we're comparing strings of equal length
2097 # Thus we'll compare libfoo.so.09.07.00 with
2098 # libfoo.so.10.01.00. Some libraries might have letters
2099 # in the version. We don't know what they mean, but will
2100 # try to skip them gracefully -- we'll set any letter to
2101 # '0'. Finally, sort in reverse so we can take the
2103 $fullname = "$thispth/" .
2104 (sort { my($ma) = $a;
2106 $ma =~ tr/A-Za-z/0/s;
2107 $ma =~ s/\b(\d)\b/0$1/g;
2108 $mb =~ tr/A-Za-z/0/s;
2109 $mb =~ s/\b(\d)\b/0$1/g;
2110 while (length($ma) < length($mb)) { $ma .= ".00"; }
2111 while (length($mb) < length($ma)) { $mb .= ".00"; }
2112 # Comparison deliberately backwards
2113 $mb cmp $ma;} @fullname)[0];
2114 } elsif (-f ($fullname="$thispth/lib$thislib.$so")
2115 && (($Config{'dlsrc'} ne "dl_dld.xs") || ($thislib eq "m"))){
2116 } elsif (-f ($fullname="$thispth/lib${thislib}_s.a")
2117 && ($thislib .= "_s") ){ # we must explicitly use _s version
2118 } elsif (-f ($fullname="$thispth/lib$thislib.a")){
2119 } elsif (-f ($fullname="$thispth/Slib$thislib.a")){
2121 print STDOUT "$thislib not found in $thispth" if $Verbose;
2124 print STDOUT "'-l$thislib' found at $fullname" if $Verbose;
2128 # Now update library lists
2130 # what do we know about this library...
2131 my $is_dyna = ($fullname !~ /\.a$/);
2132 my $in_perl = ($libs =~ /\B-l${thislib}\b/s);
2134 # Do not add it into the list if it is already linked in
2135 # with the main perl executable.
2136 # We have to special-case the NeXT, because all the math
2137 # is also in libsys_s
2139 ($Config{'osname'} eq 'next' && $thislib eq 'm') ){
2140 push(@extralibs, "-l$thislib");
2143 # We might be able to load this archive file dynamically
2144 if ( $Config{'dlsrc'} =~ /dl_next|dl_dld/){
2145 # We push -l$thislib instead of $fullname because
2146 # it avoids hardwiring a fixed path into the .bs file.
2147 # mkbootstrap will automatically add dl_findfile() to
2148 # the .bs file if it sees a name in the -l format.
2149 # USE THIS, when dl_findfile() is fixed:
2150 # push(@bsloadlibs, "-l$thislib");
2151 # OLD USE WAS while checking results against old_extliblist
2152 push(@bsloadlibs, "$fullname");
2155 # For SunOS4, do not add in this shared library if
2156 # it is already linked in the main perl executable
2157 push(@ldloadlibs, "-l$thislib")
2158 unless ($in_perl and $Config{'osname'} eq 'sunos');
2160 push(@ldloadlibs, "-l$thislib");
2163 last; # found one here so don't bother looking further
2165 print STDOUT "Warning (non-fatal): No library found for -l$thislib"
2166 unless $found_lib>0;
2168 return ('','','') unless $found;
2169 ("@extralibs", "@bsloadlibs", "@ldloadlibs");
2173 # --- Write a DynaLoader bootstrap file if required
2177 =head1 USEFUL SUBROUTINES
2179 =head2 mkbootstrap()
2181 Make a bootstrap file for use by this system's DynaLoader. It
2182 typically gets called from an extension Makefile.
2184 There is no C<*.bs> file supplied with the extension. Instead a
2185 C<*_BS> file which has code for the special cases, like posix for
2186 berkeley db on the NeXT.
2188 This file will get parsed, and produce a maybe empty
2189 C<@DynaLoader::dl_resolve_using> array for the current architecture.
2190 That will be extended by $BSLOADLIBS, which was computed by Andy's
2191 extliblist script. If this array still is empty, we do nothing, else
2192 we write a .bs file with an C<@DynaLoader::dl_resolve_using> array, but
2193 without any C<if>s, because there is no longer a need to deal with
2196 The C<*_BS> file can put some code into the generated C<*.bs> file by placing
2197 it in C<$bscode>. This is a handy 'escape' mechanism that may prove
2198 useful in complex situations.
2200 If @DynaLoader::dl_resolve_using contains C<-L*> or C<-l*> entries then
2201 mkbootstrap will automatically add a dl_findfile() call to the
2202 generated C<*.bs> file.
2206 my($self, @bsloadlibs)=@_;
2208 @bsloadlibs = grep($_, @bsloadlibs); # strip empty libs
2210 print STDOUT " bsloadlibs=@bsloadlibs\n" if $Verbose;
2212 # We need DynaLoader here because we and/or the *_BS file may
2213 # call dl_findfile(). We don't say `use' here because when
2214 # first building perl extensions the DynaLoader will not have
2215 # been built when MakeMaker gets first used.
2219 init_main() unless defined $att{'BASEEXT'};
2221 rename "$att{BASEEXT}.bs", "$att{BASEEXT}.bso";
2223 if (-f "$att{BASEEXT}_BS"){
2224 $_ = "$att{BASEEXT}_BS";
2225 package DynaLoader; # execute code as if in DynaLoader
2226 local($osname, $dlsrc) = (); # avoid warnings
2227 ($osname, $dlsrc) = @Config::Config{qw(osname dlsrc)};
2234 if ($Config{'dlsrc'} =~ /^dl_dld/){
2236 push(@dl_resolve_using, dl_findfile('-lc'));
2239 my(@all) = (@bsloadlibs, @DynaLoader::dl_resolve_using);
2242 open BS, ">$att{BASEEXT}.bs"
2243 or die "Unable to open $att{BASEEXT}.bs: $!";
2244 print STDOUT "Writing $att{BASEEXT}.bs\n";
2245 print STDOUT " containing: @all" if $Verbose;
2246 print BS "# $att{BASEEXT} DynaLoader bootstrap file for $Config{'osname'} architecture.\n";
2247 print BS "# Do not edit this file, changes will be lost.\n";
2248 print BS "# This file was automatically generated by the\n";
2249 print BS "# mkbootstrap routine in ExtUtils/MakeMaker.pm.\n";
2250 print BS "\@DynaLoader::dl_resolve_using = ";
2251 # If @all contains names in the form -lxxx or -Lxxx then it's asking for
2252 # runtime library location so we automatically add a call to dl_findfile()
2253 if (" @all" =~ m/ -[lLR]/){
2254 print BS " dl_findfile(qw(\n @all\n ));\n";
2256 print BS " qw(@all);\n";
2258 # write extra code if *_BS says so
2259 print BS $DynaLoader::bscode if $DynaLoader::bscode;
2269 # only AIX requires a symbol list at this point
2270 # (so does VMS, but that's handled by the MM_VMS package)
2271 return '' unless $Config{'osname'} eq 'aix';
2273 init_main(@ARGV) unless defined $att{'BASEEXT'};
2274 if (! $att{DL_FUNCS}) {
2276 ($bootfunc = $att{NAME}) =~ s/\W/_/g;
2277 $att{DL_FUNCS} = {$att{BASEEXT} => ["boot_$bootfunc"]};
2279 rename "$att{BASEEXT}.exp", "$att{BASEEXT}.exp_old";
2281 open(EXP,">$att{BASEEXT}.exp") or die $!;
2282 print EXP join("\n",@{$att{DL_VARS}}) if $att{DL_VARS};
2283 foreach $pkg (keys %{$att{DL_FUNCS}}) {
2284 (my($prefix) = $pkg) =~ s/\W/_/g;
2286 foreach $func (@{$att{DL_FUNCS}->{$pkg}}) {
2287 $func = "XS_${prefix}_$func" unless $func =~ /^boot_/;
2288 print EXP "$func\n";
2294 # --- Output postprocessing section ---
2295 #nicetext is included to make VMS support easier
2296 sub nicetext { # Just return the input - no action needed
2297 my($self,$text) = @_;
2301 # --- perllocal.pod section ---
2303 my($self,$what,$name,@attribs)=@_;
2304 -w $Config{'installarchlib'} or die "No write permission to $Config{'installarchlib'}";
2305 my($localpod) = "$Config{'installarchlib'}/perllocal.pod";
2308 print "Appending installation info to $localpod\n";
2309 open POD, ">>$localpod" or die "Couldn't open $localpod";
2311 print "Writing new file $localpod\n";
2312 open POD, ">$localpod" or die "Couldn't open $localpod";
2313 print POD "=head1 NAME
2315 perllocal - locally installed modules and perl binaries
2316 \n=head1 HISTORY OF LOCAL INSTALLATIONS
2321 chop($time = ctime(time));
2322 print POD "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
2323 print POD join "\n\n=item *\n\n", map("C<$_>",@attribs);
2324 print POD "\n\n=back\n\n";
2331 Andy Dougherty F<E<lt>doughera@lafcol.lafayette.eduE<gt>>, Andreas
2332 Koenig F<E<lt>k@franz.ww.TU-Berlin.DEE<gt>>, Tim Bunce
2333 F<E<lt>Tim.Bunce@ig.co.ukE<gt>>. VMS support by Charles Bailey
2334 F<E<lt>bailey@HMIVAX.HUMGEN.UPENN.EDUE<gt>>.
2336 =head1 MODIFICATION HISTORY
2338 v1, August 1994; by Andreas Koenig. Based on Andy Dougherty's Makefile.SH.
2339 v2, September 1994 by Tim Bunce.
2340 v3.0 October 1994 by Tim Bunce.
2341 v3.1 November 11th 1994 by Tim Bunce.
2342 v3.2 November 18th 1994 by Tim Bunce.
2343 v3.3 November 27th 1994 by Andreas Koenig.
2344 v3.4 December 7th 1994 by Andreas Koenig and Tim Bunce.
2345 v3.5 December 15th 1994 by Tim Bunce.
2346 v3.6 December 15th 1994 by Tim Bunce.
2347 v3.7 December 30th 1994 By Tim Bunce
2348 v3.8 January 17th 1995 By Andreas Koenig and Tim Bunce
2349 v3.9 January 19th 1995 By Tim Bunce
2350 v3.10 January 23rd 1995 By Tim Bunce
2351 v3.11 January 24th 1995 By Andreas Koenig
2352 v4.00 January 24th 1995 By Tim Bunce
2353 v4.01 January 25th 1995 By Tim Bunce
2354 v4.02 January 29th 1995 By Andreas Koenig
2355 v4.03 January 30th 1995 By Andreas Koenig
2356 v4.04 Februeary 5th 1995 By Andreas Koenig
2357 v4.05 February 8th 1995 By Andreas Koenig
2358 v4.06 February 10th 1995 By Andreas Koenig
2359 v4.061 February 12th 1995 By Andreas Koenig
2360 v4.08 - 4.085 February 14th-21st 1995 by Andreas Koenig
2362 Introduces EXE_FILES and INST_EXE for installing executable scripts
2363 and fixes documentation to reflect the new variable.
2365 Introduces the automated documentation of the installation history. Every
2369 add some documentation to the file C<$installarchlib/perllocal.pod>.
2370 This is done by the writedoc() routine in the MM_Unix class. The
2371 documentation is rudimentary until we find an agreement, what
2372 information is supposed to go into the pod.
2374 Added ability to specify the another name than C<perl> for a new binary.
2376 Both C<make perl> and C<makeaperl> now prompt the user, how to install
2377 the new binary after the build.
2379 Reduced noise during the make.
2381 Variable LIBPERL_A enables indirect setting of the switches -DEMBED,
2382 -DDEBUGGING and -DMULTIPLICITY in the same way as done by cflags.
2384 old_extliblist() code deleted, new_extliblist() renamed to extliblist().
2386 Improved algorithm in extliblist, that returns ('','','') if no
2387 library has been found, even if a -L directory has been found.
2389 Fixed a bug that didn't allow lib/ directory work as documented.
2391 Allowed C<make test TEST_VERBOSE=1>
2393 v4.086 March 9 1995 by Andy Dougherty
2395 Fixed some AIX buglets. Fixed DLD support for Linux with gcc 2.6.2.
2397 v4.09 March 31 1995 by Andreas Koenig
2399 Patches from Tim (/usr/local/lib/perl5/hpux/CORE/libperl.a not found
2400 message eliminated, and a small makeaperl patch).
2402 blib now is a relative directory (./blib).
2404 Documentation bug fixed.
2406 Chdir in the Makefile always followed by "&&", not by ";".
2408 The output of cflags is no longer directed to /dev/null, but the shell
2409 version of cflags is now only called once.
2411 The result of MakeMaker's cflags takes precedence over
2414 Introduced a $(PASTHRU) variable, that doesn't have much effect yet,
2415 but now it's easier to add variables that have to be passed to
2418 'make config' will now always reapply the original arguments to the
2421 MKPATH will be called only once for any directory (should speed up Tk
2422 building and installation considerably).
2424 "Subroutine mkbootstrap redefined" message eliminated. It was
2425 necessary to move &mkbootstrap and &mksymlists from @EXPORT to
2428 C<*.PL> files will be processed by C<$(PERL)>.
2430 Turned some globals into my() variables, where it was obvious to be an
2433 Changed some continuation lines so that they work on Solaris and Unicos.
2435 v4.091 April 3 1995 by Andy Dougherty
2437 Another attempt to fix writedoc() from Dean Roehrich.
2439 v4.092 April 11 1994 by Andreas Koenig
2441 Fixed a docu bug in hint file description. Added printing of a warning
2442 from eval in the hintfile section if the eval has errors. Moved
2443 check_hints() into the WriteMakefile() subroutine to avoid evaling
2444 hintsfiles for other uses of the module (mkbootstrap, mksymlists).
2446 Eliminated csh globbing to work around buggy Linux csh.
2448 In extliblist() libfoo.so.10 now wins against libfoo.so.9.
2450 Use $(CC) instead of $Config{'cc'} everywhere to allow overriding
2451 according to a patch by Dean Roehrich.
2453 Introduce a ./extralibs.ld file that contains the contents of all
2454 relevant extralibs.ld files for a static build to shorten the command
2455 line for the linking of a new static perl.
2459 v4.093 April 12 1994 by Andy Dougherty
2461 Rename distclean target to plain dist. Insert a dummy distclean
2462 target that's the same as realclean. This is more consistent with the
2465 Fix up extliblist() so even bizarre names like libfoo.so.10.0.1
2468 Include Tim's suggestions about $verbose and more careful substitution
2469 of $(CC) for $Config{'cc'}.
2471 v4.094 April 12 1994 by Andy Dougherty
2473 Include Andreas' improvement of $(CC) detection.
2477 MakeMaker development work still to be done:
2479 Needs more complete documentation.
2481 Add a html: target when there has been found a general solution to
2482 installing html files.
2484 Add an uninstall target.
2486 Add a FLAVOR variable that makes it easier to build debugging,
2487 embedded or multiplicity perls.
2491 # the following keeps AutoSplit happy
2492 package ExtUtils::MakeMaker;