1 package ExtUtils::MakeMaker;
3 $Version = 3.8; # Last edited 17th Jan 1995 by Andreas Koenig
11 @EXPORT = qw(&WriteMakefile &mkbootstrap $Verbose);
12 @EXPORT_OK = qw($Version %att %skip %Recognized_Att_Keys
13 @MM_Sections %MM_Sections
16 $Is_VMS = $Config{'osname'} eq 'VMS';
17 require ExtUtils::MM_VMS if $Is_VMS;
21 $Version = $Version;# avoid typo warning
28 ExtUtils::MakeMaker - create an extension Makefile
32 use ExtUtils::MakeMaker;
34 WriteMakefile( ATTRIBUTE => VALUE [, ...] );
38 This utility is designed to write a Makefile for an extension module
39 from a Makefile.PL. It is based on the Makefile.SH model provided by
40 Andy Dougherty and the perl5-porters.
42 It splits the task of generating the Makefile into several subroutines
43 that can be individually overridden. Each subroutine returns the text
44 it wishes to have written to the Makefile.
46 =head2 Default Makefile Behaviour
48 The automatically generated Makefile enables the user of the extension
56 (This section is yet to be completed ...)
58 =head2 Determination of Perl Library and Installation Locations
60 MakeMaker needs to know, or to guess, where certain things are located.
61 Especially INST_LIB, INST_ARCHLIB, PERL_LIB, PERL_ARCHLIB and PERL_SRC.
63 Extensions may be built anywhere within the file system after perl has
64 been installed correctly. Before perl is installed extensions have to
65 be built below the C<ext/> directory within the tree of the perl
66 source, i.e. where all the standard extensions are being built. The
67 generated Makefile will recognize, which of the two is the current
68 configuration and will set some variables accordingly.
70 Only if the extension is being built in PERL_SRC/ext, the variable
71 PERL_SRC is defined, otherwise it is undefined. Consequently
72 MakeMaker will default PERL_LIB and PERL_ARCHLIB to PERL_SRC/lib only
73 if PERL_SRC is defined, otherwise PERL_*LIB will default to the public
76 INST_LIB and INST_ARCHLIB default to PERL_LIB and PERL_ARCHLIB if we
77 are building below the PERL_SRC/ext directory. Else they default to
80 =head2 Useful Default Makefile Macros
82 FULLEXT = Pathname for extension directory (eg DBD/Oracle).
84 BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
86 ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
88 PERL_LIB = Directory where we read the perl library files
90 PERL_ARCHLIB = Same as above for architecture dependent files
92 INST_LIB = Directory where we put library files of this extension
93 while building it. If we are building below PERL_SRC/ext
94 we default to PERL_SRC/lib, else we default to ./blib.
96 INST_ARCHLIB = Same as above for architecture dependent files
98 INST_LIBDIR = $(INST_LIB)$(ROOTEXT)
100 INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT)
102 INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT)
104 =head2 Customizing The Generated Makefile
106 If the Makefile generated does not fit your purpose you can change it
107 using the mechanisms described below.
109 =head2 Using Attributes (and Parameters)
111 The following attributes can be specified as arguments to WriteMakefile()
112 or as NAME=VALUE pairs on the command line:
114 This description is not yet documented; you can get at the description
116 perl -e 'use ExtUtils::MakeMaker qw(&help); &help;'
118 =head2 Overriding MakeMaker Methods
120 If you cannot achieve the desired Makefile behaviour by specifying
121 attributes you may define private subroutines in the Makefile.PL.
122 Each subroutines returns the text it wishes to have written to
123 the Makefile. To override a section of the Makefile you can
126 sub MY::c_o { "new literal text" }
128 or you can edit the default by saying something like:
130 sub MY::c_o { $_=MM->c_o; s/old text/new text/; $_ }
132 If you still need a different solution, try to develop another
133 subroutine, that fits your needs and submit the diffs to
134 perl5-porters@nicoh.com or comp.lang.perl as appropriate.
139 Andy Dougherty <doughera@lafcol.lafayette.edu>, Andreas Koenig
140 <k@franz.ww.TU-Berlin.DE>, Tim Bunce <Tim.Bunce@ig.co.uk>
142 =head1 MODIFICATION HISTORY
144 v1, August 1994; by Andreas Koenig. Based on Andy Dougherty's Makefile.SH.
145 v2, September 1994 by Tim Bunce.
146 v3.0 October 1994 by Tim Bunce.
147 v3.1 November 11th 1994 by Tim Bunce.
148 v3.2 November 18th 1994 by Tim Bunce.
149 v3.3 November 27th 1994 by Andreas Koenig.
150 v3.4 December 7th 1994 by Andreas Koenig and Tim Bunce.
151 v3.5 December 15th 1994 by Tim Bunce.
152 v3.6 December 15th 1994 by Tim Bunce.
154 Added C and H attributes and corresponding macros. These default to the
155 list of *.c and *.h files in the directory. C also includes *.c file
156 names corresponding to any *.xs files in the directory. ARMAYBE should
157 now be specified as an attribute of the dynamic_lib section. The installpm
158 section now accepts a SPLITLIB attribute. This defaults to '$(INST_LIB)'.
159 Improved automatic setting of INST_ARCHLIB. Newlines in OBJECT now translate
160 into <space><backslash><newline><tab> for better formatting. Improved
161 descriptive comments for EXTRALIBS, LDLOADLIBS and BSLOADLIBS. Bootstrap
162 files are now always installed - (after a small patch) the DynaLoader will
163 only read a non-empty bootstrap file. Subdirectory dependencies have
164 been improved. The .c files produced from .xs files now depend on
165 XSUBPPDEPS (the typemaps).
167 v3.7 December 30th By Tim Bunce
169 Most, if not all, the MakeMaker support for no perl source is now
170 included. Recent ld and mkbootstrap patches applied. -lX11_s suffix
173 Also contained patches to Makefile.SH, ext/DynaLoader/DynaLoader.pm,
174 ext/util/make_ext, and h2xs
176 v3.8 January 9th By Andreas Koenig and Tim Bunce
178 - Introduces ./blib as the directory, where the ready-to-use module
179 will live for the time of the building process if PERL_SRC/lib is not
180 available. ./blib is turned into an absolute pathname and gets passed
181 to subdirectories when writing the Makefile.
183 - INST_ARCHLIB will now be set equal to INST_LIB if we cannot
184 determine it with the methods near line 620 (in the intialize
187 - Introduced the install subroutine, that calls another make
188 recursively with INST_LIB, and INST_ARCHLIB set according to the local
191 - Since version 3.6 all *.al and *.ix files are installed into
192 $installprivlib. In perl5.000 they were installed into
193 $installarchlib. Version 3.8 takes precautions to delete old *.{al,ix}
194 files that are left over in $installarchlib. Installperl is also
195 patched to both delete old *.al and *.ix files, that were put into
196 $installarchlib, and to install them properly from now on.
198 - h2xs is patched by Dean Roehrich to reintroduce the C<-A> option and
199 reconsiders the use of the AutoLoader. Also podifies h2xs.
201 - Patches to {DB_File,Fcntl,GDBM_File,POSIX,Socket}.pm, eliminating
202 AutoLoader from @ISA (by Dean Roehrich).
204 - A patch to AutoSplit.pm makes sure, the target directory of the
207 - installperl now installs all *.h files into $installarchlib/CORE.
209 - added a simple help function
213 Turned two constants into package variables.
214 Modified the default for &autosplit to be $CheckModTime=1.
215 Added warning and comment if auto dir does not exist.
216 Enhanced AutoLoader check (POSIX.pm was not getting AutoSplit!)
217 Improved logging if $Verbose>=2.
221 EXPORT_OK lsdir(), it's very handy.
222 Deleted much of the early revision history.
223 Changed LDTARGET (bad name) to LDFROM (better, but not great :)
224 INST_ARCHLIB for ./blib found via mapping from INST_LIB ./blib
225 (this allows error message if INST_ARCHLIB still undefined)
226 Added optional regex filter to &lsdir.
227 Added cute auto handling of a ./$(BASEEXT)/*.pm directory as
228 per recent messages with Nick re ext/nTk/nTk/Text.pm
229 Added NOOP, RM_F, RM_RF, TOUCH, CP to %att.
230 NOOP is now "" on Unix, "<tab>" caused problems (see makefile section)
231 RM_F etc now expanded when Makefile written.
232 Old AUTOSPLITLIB definition deleted.
233 See new dynamic_lib section for new ARMAYBE handling.
234 install section now uses $(INSTALLPRIVLIB) because on some
235 systems INSTALLPRIVLIB != PRIVLIB (ditto for archlib)
239 MakeMaker development work still to be done:
241 Needs more complete documentation.
243 The ext.libs file mechanism will need to be revised to allow a
244 make-a-perl [list-of-static-extensions] script to work.
246 Add method to take a list of files and wrap it in a Makefile
247 compatible way (<space><backslash><newline><tab>).
252 # Setup dummy package:
253 # MY exists for overriding methods to be defined within
254 unshift(@MY::ISA, qw(MM));
256 # Dummy package MM inherits actual methods from OS-specific
257 # default packages. We use this intermediate package so
258 # MY->func() can call MM->func() and get the proper
259 # default routine without having to know under what OS
261 unshift(@MM::ISA, $Is_VMS ? qw(ExtUtils::MM_VMS MM_Unix) : qw(MM_Unix));
263 $Attrib_Help = <<'END';
264 NAME: Perl module name for this extension (DBD::Oracle)
265 This defaults to the directory name.
267 DISTNAME: Your name for distributing the package (by tar file)
268 This defaults to NAME above.
270 VERSION: Your version number for distributing the package.
271 This defaults to 0.1.
273 INST_LIB: Perl library directory to install the module into.
274 INST_ARCHLIB: Perl architecture-dependent library to install into
275 (defaults to INST_LIB)
277 PERL_LIB: Directory containing the Perl library to use.
278 PERL_SRC: Directory containing the Perl source code
279 (use of this should be avoided, it may be undefined)
281 INC: Include file dirs eg: '-I/usr/5include -I/path/to/inc'
282 DEFINE: something like "-DHAVE_UNISTD_H"
283 OBJECT: List of object files, defaults to '$(BASEEXT).o',
284 but can be a long string containing all object files,
285 e.g. "tkpBind.o tkpButton.o tkpCanvas.o"
286 MYEXTLIB: If the extension links to a library that it builds
287 set this to the name of the library (see SDBM_File)
289 LIBS: An anonymous array of alternative library specifications
290 to be searched for (in order) until at least one library
292 'LIBS' => [ "-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs" ]
293 Mind, that any element of the array contains a complete
294 set of arguments for the ld command. So do not specify
295 'LIBS' => ["-ltcl", "-ltk", "-lX11" ], #wrong
296 See ODBM_File/Makefile.PL for an example, where an
297 array is needed. If you specify a scalar as in
298 'LIBS' => "-ltcl -ltk -lX11"
299 MakeMaker will turn it into an array with one element.
301 LDFROM: defaults to "$(OBJECT)" and is used in the ld command
302 to specify what files to link/load from
303 (also see dynamic_lib below for how to specify ld flags)
305 DIR: Ref to array of subdirectories containing Makefile.PLs
306 e.g. [ 'sdbm' ] in ext/SDBM_File
308 PM: Hashref of .pm files and *.pl files to be installed.
309 e.g. { 'name_of_file.pm' => '$(INST_LIBDIR)/install_as.pm' }
310 By default this will include *.pm and *.pl. If a lib directory
311 exists and is not listed in DIR (above) then any *.pm and
312 *.pl files it contains will also be included by default.
314 XS: Hashref of .xs files. MakeMaker will default this.
315 e.g. { 'name_of_file.xs' => 'name_of_file.c' }
316 The .c files will automatically be included in the list
317 of files deleted by a make clean.
319 C: Ref to array of *.c file names. Initialised from a directory scan
320 and the values portion of the XS attribute hash. This is not
321 currently used by MakeMaker but may be handy in Makefile.PLs.
323 H: Ref to array of *.h file names. Similar to C: above.
325 LINKTYPE: =>'static' or 'dynamic' (default unless usedl=undef in config.sh)
326 Should only be used to force static linking (also see linkext below).
328 CONFIG: =>[qw(archname manext)] defines ARCHNAME & MANEXT from config.sh
329 SKIP: =>[qw(name1 name2)] skip (do not write) sections of the Makefile
334 Additional lowercase attributes can be used to pass parameters to the
335 methods which implement that part of the Makefile. These are not
338 installpm: {SPLITLIB => '$(INST_LIB)' (default) or '$(INST_ARCHLIB)'}
339 linkext: {LINKTYPE => 'static', 'dynamic' or ''}
340 dynamic_lib {ARMAYBE => 'ar', OTHERLDFLAGS => '...'}
341 clean: {FILES => "*.xyz foo"}
342 realclean: {FILES => '$(INST_ARCHAUTODIR)/*.xyz'}
343 distclean: {TARNAME=>'MyTarFile', TARFLAGS=>'cvfF', COMPRESS=>'gzip'}
344 tool_autosplit: {MAXLEN => 8}
347 sub help {print $Attrib_Help;}
349 @MM_Sections_spec = (
350 'post_initialize' => {},
352 'const_config' => {},
353 'const_loadlibs' => {},
355 'tool_autosplit' => {},
358 'post_constants' => {},
381 %MM_Sections = @MM_Sections_spec; # looses section ordering
382 @MM_Sections = grep(!ref, @MM_Sections_spec); # keeps order
384 %Recognized_Att_Keys = %MM_Sections; # All sections are valid keys.
385 foreach(split(/\n/,$Attrib_Help)){
387 next unless m/^\s*(\w+):\s*(.*)/;
388 $Recognized_Att_Keys{$1} = $2;
389 print "Attribute '$1' => '$2'\n" if ($Verbose >= 2);
397 return 'skipped' if $skip{$section};
406 print STDOUT "MakeMaker" if $Verbose;
408 parse_args(\%att, @ARGV);
409 my(%initial_att) = %att; # record initial attributes
411 MY->initialize(@ARGV);
413 print STDOUT "Writing Makefile for $att{NAME}";
415 unlink("Makefile", "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : '');
416 open MAKE, ">MakeMaker.tmp" or die "Unable to open MakeMaker.tmp: $!";
417 select MAKE; $|=1; select STDOUT;
419 print MAKE "# This Makefile is for the $att{NAME} extension to perl.\n#";
420 print MAKE "# It was generated automatically by MakeMaker from the contents";
421 print MAKE "# of Makefile.PL. Don't edit this file, edit Makefile.PL instead.";
422 print MAKE "#\n# ANY CHANGES MADE HERE WILL BE LOST! \n#";
423 print MAKE "# MakeMaker Parameters: ";
424 foreach $key (sort keys %initial_att){
425 my($v) = neatvalue($initial_att{$key});
427 print MAKE "# $key => $v";
430 # build hash for SKIP to make testing easy
431 %skip = map( ($_,1), @{$att{'SKIP'} || []});
433 foreach $section ( @MM_Sections ){
434 print "Processing Makefile '$section' section" if ($Verbose >= 2);
435 my($skipit) = skipcheck($section);
437 print MAKE "\n# --- MakeMaker $section section $skipit.";
439 my(%a) = %{$att{$section} || {}};
440 print MAKE "\n# --- MakeMaker $section section:";
441 print MAKE "# ",%a if ($Verbose >= 2);
442 print(MAKE MY->nicetext(MY->$section( %a )));
447 print MAKE "\n# Full list of MakeMaker attribute values:";
448 foreach $key (sort keys %att){
449 my($v) = neatvalue($att{$key});
451 print MAKE "# $key => $v";
455 print MAKE "\n# End.";
457 my($finalname) = $Is_VMS ? "Descrip.MMS" : "Makefile";
458 rename("MakeMaker.tmp", $finalname);
460 chmod 0644, $finalname;
461 system("$Config{'eunicefix'} $finalname") unless $Config{'eunicefix'} eq ":";
468 parse_args(\%att, @ARGV);
474 my($attr, @args) = @_;
476 next unless m/(.*?)=(.*)/;
479 # catch old-style 'potential_libs' and inform user how to 'upgrade'
480 if (defined $$attr{'potential_libs'}){
481 my($msg)="'potential_libs' => '$$attr{potential_libs}' should be";
482 if ($$attr{'potential_libs'}){
483 print STDERR "$msg changed to:\n\t'LIBS' => ['$$attr{potential_libs}']\n";
485 print STDERR "$msg deleted.\n";
487 $$attr{LIBS} = [$$attr{'potential_libs'}];
488 delete $$attr{'potential_libs'};
490 # catch old-style 'ARMAYBE' and inform user how to 'upgrade'
491 if (defined $$attr{'ARMAYBE'}){
492 my($armaybe) = $$attr{'ARMAYBE'};
493 print STDERR "ARMAYBE => '$armaybe' should be changed to:\n",
494 "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n";
495 my(%dl) = %{$$attr{'dynamic_lib'} || {}};
496 $$attr{'dynamic_lib'} = { %dl, ARMAYBE => $armaybe};
497 delete $$attr{'ARMAYBE'};
499 foreach(sort keys %{$attr}){
500 print STDOUT " $_ => ".neatvalue($$attr{$_}) if ($Verbose);
501 warn "'$_' is not a known MakeMaker parameter name.\n"
502 unless exists $Recognized_Att_Keys{$_};
510 return "'$v'" unless $t;
511 return "[ ".join(', ',map("'$_'",@$v))." ]" if ($t eq 'ARRAY');
512 return "$v" unless $t eq 'HASH';
514 push(@m,"$key=>".neatvalue($val)) while (($key,$val) = each %$v);
515 return "{ ".join(', ',@m)." }";
519 # ------ Define the MakeMaker default methods in package MM_Unix ------
528 Exporter::import('ExtUtils::MakeMaker',
529 qw(%att %skip %Recognized_Att_Keys $Verbose));
531 # These attributes cannot be overridden externally
532 @Other_Att_Keys{qw(EXTRALIBS BSLOADLIBS LDLOADLIBS)} = (1) x 3;
534 if ($Is_VMS = $Config{'osname'} eq 'VMS') {
535 require File::VMSspec;
536 import File::VMSspec 'vmsify';
541 # Find out directory name. This may contain the extension name.
542 my($pwd) = fastcwd(); # from Cwd.pm
544 # --- Initialize PERL_LIB, INST_LIB, PERL_SRC
546 # *Real* information: where did we get these two from? ...
547 $inc_config_dir = dirname($INC{'Config.pm'});
548 $inc_carp_dir = dirname($INC{'Carp.pm'});
550 # Typically PERL_* and INST_* will be identical but that need
551 # not be the case (e.g., installing into project libraries etc).
553 # Perl Macro: With source No source
554 # PERL_LIB ../../lib /usr/local/lib/perl5
555 # PERL_ARCHLIB ../../lib /usr/local/lib/perl5/sun4-sunos
556 # PERL_SRC ../.. (undefined)
558 # INST Macro: Locally Publically
559 # INST_LIB ../../lib ./blib
560 # INST_ARCHLIB ../../lib ./blib
562 unless ($att{PERL_SRC}){
563 foreach(qw(../.. ../../.. ../../../..)){
564 ($att{PERL_SRC}=$_, last) if -f "$_/config.sh";
567 unless ($att{PERL_SRC}){
568 warn "Unable to locate perl source.\n";
569 # we should also consider $ENV{PERL5LIB} here
570 $att{PERL_LIB} = $Config{'privlib'} unless $att{PERL_LIB};
571 $att{PERL_ARCHLIB} = $Config{'archlib'} unless $att{PERL_ARCHLIB};
572 $att{PERL_INC} = "$att{PERL_ARCHLIB}/CORE"; # wild guess for now
573 die "Try setting PERL_SRC in Makefile.PL or on command line.\n"
574 unless (-f "$att{PERL_INC}/perl.h");
576 $att{PERL_LIB} = "$att{PERL_SRC}/lib" unless $att{PERL_LIB};
577 $att{PERL_ARCHLIB} = $att{PERL_LIB};
578 $att{PERL_INC} = $att{PERL_SRC};
581 # INST_LIB typically pre-set if building an extension after
582 # perl has been built and installed. Setting INST_LIB allows
583 # you to build directly into privlib and avoid installperl.
584 unless ($att{INST_LIB}){
585 if (defined $att{PERL_SRC}) {
586 $att{INST_LIB} = $att{PERL_LIB};
588 $att{INST_LIB} = "$pwd/blib";
591 # Try to work out what INST_ARCHLIB should be if not set:
592 unless ($att{INST_ARCHLIB}){
594 "$pwd/blib" => "$pwd/blib", # our private build lib
595 $att{PERL_LIB} => $att{PERL_ARCHLIB},
596 $Config{'privlib'} => $Config{'archlib'},
597 $Config{'installprivlib'} => $Config{'installarchlib'},
598 $inc_carp_dir => $inc_config_dir,
600 $att{INST_ARCHLIB} = $archmap{$att{INST_LIB}};
601 die "Unable to determine INST_ARCHLIB. Please define it explicitly.\n"
602 unless $att{INST_ARCHLIB};
605 # make a few simple checks
606 die "PERL_LIB ($att{PERL_LIB}) is not a perl library directory"
607 unless (-f "$att{PERL_LIB}/Exporter.pm");
609 # --- Initialize Module Name and Paths
611 # NAME = The perl module name for this extension (eg DBD::Oracle).
612 # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
613 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
614 # ROOTEXT = Directory part of FULLEXT with leading /.
615 unless($att{NAME}){ # we have to guess our name
618 $name =~ s:.*?([^.\]]+)\]:$1: unless ($name =~ s:.*[.\[]ext\.::);
619 ($att{NAME}=$name) =~ s#[.\]]#::#g;
621 $name =~ s:.*/:: unless ($name =~ s:^.*/ext/::);
622 ($att{NAME} =$name) =~ s#/#::#g;
625 ($att{FULLEXT} =$att{NAME}) =~ s#::#/#g ; #eg. BSD/Foo/Socket
626 ($att{BASEEXT} =$att{NAME}) =~ s#.*::##; #eg. Socket
627 ($att{ROOTEXT} =$att{FULLEXT}) =~ s#/?\Q$att{BASEEXT}\E$## ; # eg. /BSD/Foo
628 $att{ROOTEXT} = "/$att{ROOTEXT}" if $att{ROOTEXT};
629 $att{ROOTEXT} = "" if $Is_VMS;
631 ($att{DISTNAME}=$att{NAME}) =~ s#(::)#-#g;
632 $att{VERSION} = "0.1" unless $att{VERSION};
635 # --- Initialize Perl Binary Locations
637 # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL'
638 # will be working versions of perl 5.
639 $att{'PERL'} = MY->find_perl(5.0, [ qw(perl5 perl miniperl) ],
640 [ $att{PERL_SRC}, split(":", $ENV{PATH}), $Config{'bin'} ], 0 )
641 unless ($att{'PERL'} && -x $att{'PERL'});
643 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
644 ($att{'FULLPERL'} = $att{'PERL'}) =~ s/miniperl/perl/
645 unless ($att{'FULLPERL'} && -x $att{'FULLPERL'});
648 ($att{'PERL'} = 'MCR ' . vmsify($att{'PERL'})) =~ s:.*/::;
649 ($att{'FULLPERL'} = 'MCR ' . vmsify($att{'FULLPERL'})) =~ s:.*/::;
652 # --- Initialize File and Directory Lists (.xs .pm etc)
655 my($name, %dir, %xs, %pm, %c, %h, %ignore);
656 $ignore{'test.pl'} = 1;
657 $ignore{'makefile.pl'} = 1 if $Is_VMS;
658 foreach $name (lsdir(".")){
659 next if ($name =~ /^\./ or $ignore{$name});
661 $dir{$name} = $name if (-f "$name/Makefile.PL");
662 }elsif ($name =~ /\.xs$/){
663 my($c); ($c = $name) =~ s/\.xs$/.c/;
666 }elsif ($name =~ /\.c$/){
668 }elsif ($name =~ /\.h$/){
670 }elsif ($name =~ /\.p[ml]$/){
671 $pm{$name} = "\$(INST_LIBDIR)/$name";
675 # If we have a ./lib dir that does NOT contain a Makefile.PL
676 # then add in any .pm and .pl files in that directory.
677 # This makes it easy and tidy to ship a number of perl files.
678 if (-d "lib" and !$dir{'lib'}){
679 foreach $name (lsdir("lib", '\.p[ml]$')){
680 # next unless ($name =~ /\.p[ml]$/);
681 $pm{"lib/$name"} = "\$(INST_LIBDIR)/$name";
685 # Similarly, if we have a ./$(BASEEXT) dir without a Makefile.PL
686 # we treat it as a directory containing *.pm files for modules
687 # which are nested below this one. E.g., ./Tk.pm & ./Tk/Text.pm
688 if (-d $att{BASEEXT} and !$dir{$att{BASEEXT}}){
689 foreach $name (lsdir($att{BASEEXT}, '\.p[ml]$')){
690 # next unless ($name =~ /\.p[ml]$/);
691 $pm{"$att{BASEEXT}/$name"} = "\$(INST_LIBDIR)/$att{BASEEXT}/$name";
695 $att{DIR} = [sort keys %dir] unless $att{DIRS};
696 $att{XS} = \%xs unless $att{XS};
697 $att{PM} = \%pm unless $att{PM};
698 $att{C} = [sort keys %c] unless $att{C};
699 $att{H} = [sort keys %h] unless $att{H};
702 # --- Initialize Other Attributes
704 for $key (keys(%Recognized_Att_Keys), keys(%Other_Att_Keys)){
705 # avoid warnings for uninitialized vars
706 next if exists $att{$key};
710 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $att{'LIBS'}
711 # Lets look at $att{LIBS} carefully: It may be an anon array, a string or
712 # undefined. In any case we turn it into an anon array:
713 $att{LIBS}=[] unless $att{LIBS};
714 $att{LIBS}=[$att{LIBS}] if ref \$att{LIBS} eq SCALAR;
715 foreach ( @{$att{'LIBS'}} ){
716 s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
717 my(@libs) = MY->extliblist($_);
718 if ($libs[0] or $libs[1] or $libs[2]){
719 @att{EXTRALIBS, BSLOADLIBS, LDLOADLIBS} = @libs;
724 warn "CONFIG must be an array ref\n"
725 if ($att{CONFIG} and ref $att{CONFIG} ne 'ARRAY');
726 $att{CONFIG} = [] unless (ref $att{CONFIG});
727 push(@{$att{CONFIG}},
728 qw( cc libc ldflags lddlflags ccdlflags cccdlflags
729 ranlib so dlext dlsrc installprivlib installarchlib
731 push(@{$att{CONFIG}}, 'shellflags') if $Config{'shellflags'};
734 # This will not make other Makefile.PLs portable. Any Makefile.PL
735 # which says OBJECT => "foo.o bar.o" will fail on VMS. It might
736 # be better to fix the c_o section to produce .o files.
737 $att{OBJECT} = '$(BASEEXT).obj' unless $att{OBJECT};
738 $att{OBJECT} =~ s/[^,\s]\s+/, /g;
739 $att{OBJECT} =~ s/\n+/, /g;
741 $att{OBJECT} = '$(BASEEXT).o' unless $att{OBJECT};
742 $att{OBJECT} =~ s/\n+/ \\\n\t/g;
744 $att{BOOTDEP} = (-f "$att{BASEEXT}_BS") ? "$att{BASEEXT}_BS" : "";
745 $att{LD} = ($Config{'ld'} || 'ld') unless $att{LD};
746 $att{LDFROM} = '$(OBJECT)' unless $att{LDFROM};
747 $att{LINKTYPE} = ($Config{'usedl'}) ? 'dynamic' : 'static'
748 unless $att{LINKTYPE};
750 # These get overridden for VMS and maybe some other systems
752 $att{RM_F} = "rm -f";
753 $att{RM_RF} = "rm -rf";
754 $att{TOUCH} = "touch";
760 my($dir, $regex) = @_;
762 opendir(DIR, $_[0] || ".") or die "opendir: $!";
765 @ls = grep(/$regex/, @ls) if $regex;
771 my($self, $ver, $names, $dirs, $trace) = @_;
773 print "Looking for perl $ver by these names: @$names, in these dirs: @$dirs\n"
775 foreach $dir (@$dirs){
776 next unless defined $dir; # $att{PERL_SRC} may be undefined
777 foreach $name (@$names){
778 print "checking $dir/$name\n" if ($trace >= 2);
780 $name .= ".exe" unless -x "$dir/$name";
782 next unless -x "$dir/$name";
783 print "executing $dir/$name\n" if ($trace);
786 my($vmscmd) = 'MCR ' . vmsify("$dir/$name");
787 $out = `$vmscmd -e "require $ver; print ""VER_OK\n"""`;
789 $out = `$dir/$name -e 'require $ver; print "VER_OK\n" ' 2>&1`;
791 return "$dir/$name" if $out =~ /VER_OK/;
794 warn "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
795 0; # false and not empty
809 DISTNAME = $att{DISTNAME}
810 VERSION = $att{VERSION}
812 # In which library should we install this extension?
813 # This is typically the same as PERL_LIB.
814 # (also see INST_LIBDIR and relationship to ROOTEXT)
815 INST_LIB = $att{INST_LIB}
816 INST_ARCHLIB = $att{INST_ARCHLIB}
818 # Perl library to use when building the extension
819 PERL_LIB = $att{PERL_LIB}
820 PERL_ARCHLIB = $att{PERL_ARCHLIB}
822 # Where is the perl source code located? (Eventually we should
823 # be able to build extensions without requiring the perl source
824 # but that's a way off yet).
825 PERL_SRC = $att{PERL_SRC}
826 # Perl header files (will eventually be under PERL_LIB)
827 PERL_INC = $att{PERL_INC}
830 FULLPERL = $att{'FULLPERL'}
832 # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
833 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
834 # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
835 FULLEXT = $att{FULLEXT}
836 BASEEXT = $att{BASEEXT}
837 ROOTEXT = $att{ROOTEXT}
839 # These will be removed later. Use PERL_SRC and BASEEXT instead.
841 EXT = CHANGE_EXT_TO_BASEEXT
844 DEFINE = $att{DEFINE}
845 OBJECT = $att{OBJECT}
846 LDFROM = $att{LDFROM}
847 LINKTYPE = $att{LINKTYPE}
850 XS= ".join(" \\\n\t", sort keys %{$att{XS}})."
851 C = ".join(" \\\n\t", @{$att{C}})."
852 H = ".join(" \\\n\t", @{$att{H}})."
858 .PHONY: all config static dynamic test
860 # This extension may link to it's own library (see SDBM_File)
861 MYEXTLIB = $att{MYEXTLIB}
863 # Where is the Config.pm that we are using/depend on
864 CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm
868 # Where to put things:
869 INST_LIBDIR = $(INST_LIB)$(ROOTEXT)
870 INST_ARCHLIBDIR = $(INST_ARCHLIB)$(ROOTEXT)
875 INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT)
876 INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT)
880 INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
881 INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(BASEEXT).$(DLEXT)
882 INST_STATIC = $(BASEEXT).a
883 INST_PM = '.join(" \\\n\t", sort values %{$att{PM}}).'
891 # This is implemented in the
892 # same manner as extliblist, e.g., do both and compare results during
893 # the transition period.
894 my($cc,$ccflags,$optimize,$large,$split)=@Config{qw(cc ccflags optimize large split)};
897 chop($old = `cd $att{PERL_SRC}; sh $Config{'shellflags'} ./cflags $att{BASEEXT}.c`)
900 # Why is this written this way ?
901 if ($prog = $Config{"$att{BASEEXT}_cflags"}) {
904 optimize=\"$optimize\"
909 echo ccflags=\$ccflags
910 echo optimize=\$optimize
917 if ($line =~ /(.*?)\s*=\s*(.*)\s*$/){
919 print STDERR " $1 = $2" if $Verbose;
922 ($cc,$ccflags,$optimize,$large,$split)=@cflags{qw(cc ccflags optimize large split)};
925 my($new) = "$cc -c $ccflags $optimize $large $split";
926 if (defined($old) and $new ne $old) {
927 warn "Warning (non-fatal): cflags evaluation in MakeMaker differs from shell output\n"
928 ." package: $att{NAME}\n"
931 ." Using 'old' set.\n"
932 ."Please notify perl5-porters\@nicoh.com\n";
934 my($cccmd)=($old) ? $old : $new;
939 # --- Constants Sections ---
943 push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
945 foreach $m (@{$att{'CONFIG'}}){
946 next if $once_only{$m};
947 warn "CONFIG key '$m' does not exist in Config.pm\n"
948 unless exists $Config{$m};
949 push @m, "\U$m\E = $Config{$m}\n";
958 # $att{NAME} might depend on some other libraries:
959 # (These comments may need revising:)
961 # Dependent libraries can be linked in one of three ways:
963 # 1. (For static extensions) by the ld command when the perl binary
964 # is linked with the extension library. See EXTRALIBS below.
966 # 2. (For dynamic extensions) by the ld command when the shared
967 # object is built/linked. See LDLOADLIBS below.
969 # 3. (For dynamic extensions) by the DynaLoader when the shared
970 # object is loaded. See BSLOADLIBS below.
972 # EXTRALIBS = List of libraries that need to be linked with when
973 # linking a perl binary which includes this extension
974 # Only those libraries that actually exist are included.
975 # These are written to a file and used when linking perl.
977 # LDLOADLIBS = List of those libraries which can or must be linked into
978 # the shared library when created using ld. These may be
979 # static or dynamic libraries.
981 # BSLOADLIBS = List of those libraries that are needed but can be
982 # linked in dynamically at run time on this platform.
983 # SunOS/Solaris does not need this because ld records
984 # the information (from LDLOADLIBS) into the object file.
985 # This list is used to create a .bs (bootstrap) file.
986 # The bootstrap file is installed only if it's not empty.
988 EXTRALIBS = $att{'EXTRALIBS'}
989 LDLOADLIBS = $att{'LDLOADLIBS'}
990 BSLOADLIBS = $att{'BSLOADLIBS'}
995 # --- Tool Sections ---
998 my($self, %attribs) = @_;
1000 $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
1002 # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
1003 # Remark: the "" around the -I switches are helpful for the VMS support
1004 AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;}.$asl.q{ AutoSplit::autosplit_file($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
1010 my($xsdir) = '$(PERL_LIB)/ExtUtils';
1011 # drop back to old location if xsubpp is not in new location yet
1012 $xsdir = '$(PERL_SRC)/ext' unless (-f "$att{PERL_LIB}/ExtUtils/xsubpp");
1013 my(@tmdeps) = ('$(XSUBPPDIR)/typemap');
1014 push(@tmdeps, "typemap") if -f "typemap";
1015 my(@tmargs) = map("-typemap $_", @tmdeps);
1018 XSUBPP = \$(XSUBPPDIR)/xsubpp
1019 XSUBPPDEPS = @tmdeps
1020 XSUBPPARGS = @tmargs
1034 # The following is a portable way to say mkdir -p
1035 MKPATH = $(PERL) -wle '$$"="/"; foreach $$p (@ARGV){ my(@p); foreach(split(/\//,$$p)){ push(@p,$$_); next if -d "@p/"; print "mkdir @p"; mkdir("@p",0777)||die $$! }} exit 0;'
1045 # --- Translation Sections ---
1050 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $(INC) $*.c
1057 $(PERL) $(XSUBPP) $(XSUBPPARGS) $*.xs >xstmp.c && mv xstmp.c $@
1061 sub xs_o { # many makes are too dumb to use xs_c then c_o
1064 $(PERL) $(XSUBPP) $(XSUBPPARGS) $*.xs >xstmp.c && mv xstmp.c $*.c
1065 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $(INC) $*.c
1070 # --- Target Sections ---
1074 all :: config linkext $(INST_PM)
1078 @$(MKPATH) $(INST_LIBDIR)
1079 @$(MKPATH) $(INST_ARCHAUTODIR)
1084 my($self, %attribs) = @_;
1085 # LINKTYPE => static or dynamic
1086 my($linktype) = $attribs{LINKTYPE} || '$(LINKTYPE)';
1088 linkext :: $linktype
1094 # --- Dynamic Loading Sections ---
1098 # $(INST_PM) has been moved to the all: target.
1099 # It remains here for awhile to allow for old usage: "make dynamic"
1100 dynamic :: $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM)
1106 my($self, %attribs) = @_;
1108 BOOTSTRAP = '."$att{BASEEXT}.bs".'
1110 # As MakeMaker mkbootstrap might not write a file (if none is required)
1111 # we use touch to prevent make continually trying to remake it.
1112 # The DynaLoader only reads a non-empty file.
1113 $(BOOTSTRAP): '.$att{BOOTDEP}.' $(CONFIGDEP) Makefile.PL
1114 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
1115 -e \'use ExtUtils::MakeMaker; &mkbootstrap("$(BSLOADLIBS)");\' \
1116 INST_LIB=$(INST_LIB) INST_ARCHLIB=$(INST_ARCHLIB) PERL_SRC=$(PERL_SRC) NAME=$(NAME)
1117 @$(TOUCH) $(BOOTSTRAP)
1119 $(INST_BOOT): $(BOOTSTRAP)
1120 @'.$att{RM_RF}.' $(INST_BOOT)
1121 '.$att{CP}.' $(BOOTSTRAP) $(INST_BOOT)
1126 my($self, %attribs) = @_;
1127 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
1128 my($armaybe) = $attribs{ARMAYBE} || $att{ARMAYBE} || ":";
1129 my($ldfrom) = '$(LDFROM)';
1132 ARMAYBE = '.$armaybe.'
1133 OTHERLDFLAGS = '.$otherldflags.'
1135 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP)
1136 @$(MKPATH) $(INST_ARCHAUTODIR)
1138 if ($armaybe ne ':'){
1140 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
1141 push(@m,' $(RANLIB) '."$ldfrom\n");
1143 push(@m,' $(LD) $(LDDLFLAGS) -o $@ '.$ldfrom.
1144 ' $(OTHERLDFLAGS) $(MYEXTLIB) $(LDLOADLIBS)'."\n");
1149 # --- Static Loading Sections ---
1153 # $(INST_PM) has been moved to the all: target.
1154 # It remains here for awhile to allow for old usage: "make static"
1155 static :: $(INST_STATIC) $(INST_PM)
1163 $(INST_STATIC): $(OBJECT) $(MYEXTLIB)
1165 # If this extension has it's own library (eg SDBM_File)
1166 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
1167 push(@m, " $att{CP} \$(MYEXTLIB) \$\@\n") if $att{MYEXTLIB};
1170 ar cr $@ $(OBJECT) && $(RANLIB) $@
1171 @: New mechanism - not yet used:
1172 @echo $(EXTRALIBS) > $(INST_ARCHAUTODIR)/extralibs.ld
1173 $(CP) $@ $(INST_ARCHAUTODIR)/
1175 push(@m, <<'END') if $att{PERL_SRC};
1176 @: Old mechanism - still needed:
1177 @echo $(EXTRALIBS) >> $(PERL_SRC)/ext.libs
1184 my($self, %attribs) = @_;
1185 # By default .pm files are split into the architecture independent
1186 # library. This is a good thing. If a specific module requires that
1187 # it's .pm files are split into the architecture specific library
1188 # then it should use: installpm => {SPLITLIB=>'$(INST_ARCHLIB)'}
1189 # Note that installperl currently interferes with this (Config.pm)
1190 # User can disable split by saying: installpm => {SPLITLIB=>''}
1191 my($splitlib) = '$(INST_LIB)'; # NOT arch specific by default
1192 $splitlib = $attribs{SPLITLIB} if exists $attribs{SPLITLIB};
1194 foreach $dist (sort keys %{$att{PM}}){
1195 my($inst) = $att{PM}->{$dist};
1196 push(@m, "\n# installpm: $dist => $inst, splitlib=$splitlib\n");
1197 push(@m, MY->installpm_x($dist, $inst, $splitlib));
1203 sub installpm_x { # called by installpm per file
1204 my($self, $dist, $inst, $splitlib) = @_;
1205 my($instdir) = $inst =~ m|(.*)/|;
1209 ".' @'.$att{RM_F}.' $@
1210 @$(MKPATH) '.$instdir.'
1213 push(@m, "\t\$(AUTOSPLITFILE) \$@ $splitlib/auto\n")
1214 if ($splitlib and $inst =~ m/\.pm$/);
1219 # --- Sub-directory Sections ---
1223 # This method provides a mechanism to automatically deal with
1224 # subdirectories containing further Makefile.PL scripts.
1225 # It calls the subdir_x() method for each subdirectory.
1226 foreach(<*/Makefile.PL>){
1227 s:/Makefile\.PL$:: ;
1228 print "Including $_ subdirectory" if ($Verbose);
1229 push(@m, MY->subdir_x($_));
1233 # The default clean, realclean and test targets in this Makefile
1234 # have automatically been given entries for each subdir.
1239 push(@m, "\n# none")
1244 sub runsubdirpl{ # Experimental! See subdir_x section
1245 my($self,$subdir) = @_;
1246 chdir($subdir) or die "chdir($subdir): $!";
1247 require "Makefile.PL";
1251 my($self, $subdir) = @_;
1253 # The intention is that the calling Makefile.PL should define the
1254 # $(SUBDIR_MAKEFILE_PL_ARGS) make macro to contain whatever
1255 # information needs to be passed down to the other Makefile.PL scripts.
1256 # If this does not suit your needs you'll need to write your own
1257 # MY::subdir_x() method to override this one.
1259 config :: $subdir/Makefile
1260 cd $subdir ; \$(MAKE) config INST_LIB=\$(INST_LIB) INST_ARCHLIB=\$(INST_ARCHLIB) LINKTYPE=\$(LINKTYPE)
1262 $subdir/Makefile: $subdir/Makefile.PL \$(CONFIGDEP)
1263 }.' @echo "Rebuilding $@ ..."
1264 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \\
1265 -e "use ExtUtils::MakeMaker; MM->runsubdirpl(qw('.$subdir.'))" \\
1266 INST_LIB=$(INST_LIB) INST_ARCHLIB=$(INST_ARCHLIB) \\
1267 $(SUBDIR_MAKEFILE_PL_ARGS)
1268 @echo "Rebuild of $@ complete."
1272 cd $subdir ; \$(MAKE) all LINKTYPE=\$(LINKTYPE)
1278 # --- Cleanup and Distribution Sections ---
1281 my($self, %attribs) = @_;
1284 # Delete temporary files but do not touch installed files. We don\'t delete
1285 # the Makefile here so a later make realclean still has a makefile to use.
1289 # clean subdirectories first
1290 push(@m, map("\t-cd $_ && test -f Makefile && \$(MAKE) clean\n",@{$att{DIR}}));
1291 push(@m, " $att{RM_F} *~ t/*~ *.o *.a mon.out core so_locations \$(BOOTSTRAP) \$(BASEEXT).bso\n");
1293 # Automatically delete the .c files generated from *.xs files:
1294 push(@otherfiles, values %{$att{XS}});
1295 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
1296 push(@m, " $att{RM_RF} @otherfiles\n") if @otherfiles;
1297 push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
1302 my($self, %attribs) = @_;
1305 # Delete temporary files (via clean) and also delete installed files
1306 realclean purge :: clean
1308 # clean subdirectories first
1309 push(@m, map("\t-cd $_ && test -f Makefile && \$(MAKE) realclean\n",@{$att{DIR}}));
1310 # try to clean those files first, where we might have no permissions, so Makefile won't be lost
1311 push(@m, " $att{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n");
1312 push(@m, " $att{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT) \$(INST_PM)\n");
1313 push(@m, " $att{RM_F} Makefile \$(INST_STATIC)\n");
1315 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
1316 push(@m, " $att{RM_RF} @otherfiles\n") if @otherfiles;
1317 push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
1323 my($self, %attribs) = @_;
1324 # VERSION should be sanitised before use as a file name
1325 my($tarname) = $attribs{TARNAME} || '$(DISTNAME)-$(VERSION)';
1326 my($tarflags) = $attribs{TARFLAGS} || 'cvf';
1327 my($compress) = $attribs{COMPRESS} || 'compress'; # eg gzip
1328 my($preop) = $attribs{PREOP} || '@:'; # e.g., update MANIFEST
1329 my($postop) = $attribs{POSTOP} || '@:';
1330 my($mkfiles) = join(' ', map("$_/Makefile", ".", @{$att{DIR}}));
1335 cd ..; tar $tarflags $tarname.tar \$(BASEEXT)
1336 cd ..; $compress $tarname.tar
1342 # --- Test and Installation Sections ---
1345 my($self, %attribs) = @_;
1346 my($tests) = $attribs{TESTS} || (-d "t" ? "t/*.t" : "");
1351 push(@m, <<"END") if $tests;
1352 \$(FULLPERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) -e 'use Test::Harness; runtests \@ARGV;' $tests
1354 push(@m, <<'END') if -f "test.pl";
1355 $(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) test.pl
1357 push(@m, map("\tcd $_ && test -f Makefile && \$(MAKE) test LINKTYPE=\$(LINKTYPE)\n",@{$att{DIR}}));
1358 push(@m, "\t\@echo 'No tests defined for \$(NAME) extension.'\n") unless @m > 1;
1364 my($self, %attribs) = @_;
1369 # install subdirectories first
1370 push(@m, map("\tcd $_ && test -f Makefile && \$(MAKE) install\n",@{$att{DIR}}));
1372 push(@m, "\t: perl5.000 used to autosplit into INST_ARCHLIB, we delete these old files here
1373 $att{RM_F} \$(INSTALLARCHLIB)/auto/\$(FULLEXT)/*.al \$(INSTALLARCHLIB)/auto/\$(FULLEXT)/*.ix
1374 make INST_LIB=\$(INSTALLPRIVLIB) INST_ARCHLIB=\$(INSTALLARCHLIB)
1381 '# Phony target to force checking subdirectories.
1390 PERL_HDRS = $(PERL_INC)/EXTERN.h $(PERL_INC)/INTERN.h \
1391 $(PERL_INC)/XSUB.h $(PERL_INC)/av.h $(PERL_INC)/cop.h \
1392 $(PERL_INC)/cv.h $(PERL_INC)/dosish.h $(PERL_INC)/embed.h \
1393 $(PERL_INC)/form.h $(PERL_INC)/gv.h $(PERL_INC)/handy.h \
1394 $(PERL_INC)/hv.h $(PERL_INC)/keywords.h $(PERL_INC)/mg.h \
1395 $(PERL_INC)/op.h $(PERL_INC)/opcode.h $(PERL_INC)/patchlevel.h \
1396 $(PERL_INC)/perl.h $(PERL_INC)/perly.h $(PERL_INC)/pp.h \
1397 $(PERL_INC)/proto.h $(PERL_INC)/regcomp.h $(PERL_INC)/regexp.h \
1398 $(PERL_INC)/scope.h $(PERL_INC)/sv.h $(PERL_INC)/unixish.h \
1401 $(OBJECT) : $(PERL_HDRS)
1405 $(PERL_INC)/config.h: $(PERL_SRC)/config.sh; cd $(PERL_SRC); /bin/sh config_h.SH
1406 ') if $att{PERL_SRC};
1408 # This needs a better home:
1409 push(@m, join(" ", values %{$att{XS}})." : \$(XSUBPPDEPS)\n")
1416 # We do not know what target was originally specified so we
1417 # must force a manual rerun to be sure. But as it would only
1418 # happen very rarely it is not a significant problem.
1420 # This dependency, with no_op, causes problems. Make tries to build OBJECT via no_op!
1421 # So we'll just drop it for now.
1422 #$(OBJECT) : Makefile
1426 Makefile: Makefile.PL $(CONFIGDEP)
1427 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL
1428 @echo "Now you must rerun make."; false
1438 # --- Determine libraries to use and how to use them ---
1441 my($self, $libs) = @_;
1442 return ("", "", "") unless $libs;
1443 print STDERR "Potential libraries are '$libs':" if $Verbose;
1444 my(@new) = MY->new_extliblist($libs);
1446 if ($att{PERL_SRC}){
1447 my(@old) = MY->old_extliblist($libs);
1448 my($oldlibs) = join(" : ",@old);
1449 my($newlibs) = join(" : ",@new);
1450 warn "Warning (non-fatal): $att{NAME} extliblist consistency check failed:\n".
1453 "Using 'new' set. Please notify perl5-porters\@nicoh.com.\n"
1454 if ("$newlibs" ne "$oldlibs");
1460 sub old_extliblist {
1461 my($self, $potential_libs)=@_;
1462 return ("", "", "") unless $potential_libs;
1463 die "old_extliblist requires PERL_SRC" unless $att{PERL_SRC};
1466 # Now run ext/util/extliblist to discover what *libs definitions
1467 # are required for the needs of $potential_libs
1468 $ENV{'potential_libs'} = $potential_libs;
1469 my(@o)=`. $att{PERL_SRC}/config.sh
1470 . $att{PERL_SRC}/ext/util/extliblist;
1471 echo EXTRALIBS=\$extralibs
1472 echo BSLOADLIBS=\$dynaloadlibs
1473 echo LDLOADLIBS=\$statloadlibs
1477 if ($line =~ /(.*)\s*=\s*(.*)\s*$/){
1479 print STDERR " $1 = $2" if $Verbose;
1484 print STDERR "Messages from extliblist:\n", join("\n",@w,'')
1486 @attrib{qw(EXTRALIBS BSLOADLIBS LDLOADLIBS)};
1490 sub new_extliblist {
1491 my($self, $potential_libs)=@_;
1492 return ("", "", "") unless $potential_libs;
1494 my($so) = $Config{'so'};
1495 my($libs) = $Config{'libs'};
1497 # compute $extralibs, $bsloadlibs and $ldloadlibs from
1499 # this is a rewrite of Andy Dougherty's extliblist in perl
1500 # its home is in <distribution>/ext/util
1502 my(@searchpath); # from "-L/path" entries in $potential_libs
1503 my(@libpath) = split " ", $Config{'libpth'};
1508 my($pwd) = fastcwd(); # from Cwd.pm
1510 foreach $thislib (split ' ', $potential_libs){
1512 # Handle possible linker path arguments.
1513 if ($thislib =~ s/^(-[LR])//){ # save path flag type
1515 unless (-d $thislib){
1516 warn "$ptype$thislib ignored, directory does not exist\n"
1520 if ($thislib !~ m|^/|) {
1521 warn "Warning: $ptype$thislib changed to $ptype$pwd/$thislib\n";
1522 $thislib = "$pwd/$thislib";
1524 push(@searchpath, $thislib);
1525 push(@extralibs, "$ptype$thislib");
1526 push(@ldloadlibs, "$ptype$thislib");
1530 # Handle possible library arguments.
1531 unless ($thislib =~ s/^-l//){
1532 warn "Unrecognized argument in LIBS ignored: '$thislib'\n";
1537 foreach $thispth (@searchpath, @libpath){
1539 if (@fullname=<${thispth}/lib${thislib}.${so}.[0-9]*>){
1540 $fullname=$fullname[-1]; #ATTN: 10 looses against 9!
1541 } elsif (-f ($fullname="$thispth/lib$thislib.$so")){
1542 } elsif (-f ($fullname="$thispth/lib${thislib}_s.a")
1543 && ($thislib .= "_s") ){ # we must explicitly ask for _s version
1544 } elsif (-f ($fullname="$thispth/lib$thislib.a")){
1545 } elsif (-f ($fullname="$thispth/Slib$thislib.a")){
1547 warn "$thislib not found in $thispth\n" if $Verbose;
1550 warn "'-l$thislib' found at $fullname\n" if $Verbose;
1553 # Now update library lists
1555 # what do we know about this library...
1556 my $is_dyna = ($fullname !~ /\.a$/);
1557 my $in_perl = ($libs =~ /\B-l${thislib}\b/s);
1559 # Do not add it into the list if it is already linked in
1560 # with the main perl executable.
1561 # We have to special-case the NeXT, because all the math is also in libsys_s
1562 unless ( $in_perl || ($Config{'osname'} eq 'next' && $thislib eq 'm') ){
1563 push(@extralibs, "-l$thislib");
1567 # We might be able to load this archive file dynamically
1568 if ( $Config{'dlsrc'} =~ /dl_next|dl_dld/){
1569 # We push -l$thislib instead of $fullname because
1570 # it avoids hardwiring a fixed path into the .bs file.
1571 # mkbootstrap will automatically add dl_findfile() to
1572 # the .bs file if it sees a name in the -l format.
1573 # USE THIS LATER: push(@bsloadlibs, "-l$thislib"); # " $fullname";
1574 # USE THIS while checking results against old_extliblist
1575 push(@bsloadlibs, "$fullname");
1578 # For SunOS4, do not add in this shared library if
1579 # it is already linked in the main perl executable
1580 push(@ldloadlibs, "-l$thislib")
1581 unless ($in_perl and $Config{'osname'} eq 'sunos');
1583 push(@ldloadlibs, "-l$thislib");
1586 last; # found one here so don't bother looking further
1588 warn "Warning (non-fatal): No library found for -l$thislib\n" unless $found_lib>0;
1590 ("@extralibs", "@bsloadlibs", "@ldloadlibs");
1594 # --- Write a DynaLoader bootstrap file if required
1604 Make a bootstrap file for use by this system's DynaLoader.
1605 It typically gets called from an extension Makefile.
1607 There is no .bs file supplied with the extension. Instead a _BS file
1608 which has code for the special cases, like posix for berkeley db on the
1611 This file will get parsed, and produce a maybe empty
1612 @DynaLoader::dl_resolve_using array for the current architecture.
1613 That will be extended by $BSLOADLIBS, which was computed by Andy's
1614 extliblist script. If this array still is empty, we do nothing, else
1615 we write a .bs file with an @DynaLoader::dl_resolve_using array, but
1616 without any C<if>s, because there is no longer a need to deal with
1619 The _BS file can put some code into the generated .bs file by placing
1620 it in $bscode. This is a handy 'escape' mechanism that may prove
1621 useful in complex situations.
1623 If @DynaLoader::dl_resolve_using contains C<-L*> or C<-l*> entries then
1624 mkbootstrap will automatically add a dl_findfile() call to the
1629 Andreas Koenig <k@otto.ww.TU-Berlin.DE>, Tim Bunce
1630 <Tim.Bunce@ig.co.uk>, Andy Dougherty <doughera@lafcol.lafayette.edu>
1634 my($self, @bsloadlibs)=@_;
1636 @bsloadlibs = grep($_, @bsloadlibs); # strip empty libs
1638 print STDERR " bsloadlibs=@bsloadlibs\n" if $Verbose;
1640 # We need DynaLoader here because we and/or the *_BS file may
1641 # call dl_findfile(). We don't say `use' here because when
1642 # first building perl extensions the DynaLoader will not have
1643 # been built when MakeMaker gets first used.
1647 initialize(@ARGV) unless defined $att{'BASEEXT'};
1649 rename "$att{BASEEXT}.bs", "$att{BASEEXT}.bso";
1651 if (-f "$att{BASEEXT}_BS"){
1652 $_ = "$att{BASEEXT}_BS";
1653 package DynaLoader; # execute code as if in DynaLoader
1654 local($osname, $dlsrc) = (); # avoid warnings
1655 ($osname, $dlsrc) = @Config::Config{qw(osname dlsrc)};
1662 if ($Config{'dlsrc'} =~ /^dl_dld/){
1664 push(@dl_resolve_using, dl_findfile('-lc'));
1667 my(@all) = (@bsloadlibs, @DynaLoader::dl_resolve_using);
1670 open BS, ">$att{BASEEXT}.bs"
1671 or die "Unable to open $att{BASEEXT}.bs: $!";
1672 print STDOUT "Writing $att{BASEEXT}.bs\n";
1673 print STDOUT " containing: @all" if $Verbose;
1674 print BS "# $att{BASEEXT} DynaLoader bootstrap file for $Config{'osname'} architecture.\n";
1675 print BS "# Do not edit this file, changes will be lost.\n";
1676 print BS "# This file was automatically generated by the\n";
1677 print BS "# mkbootstrap routine in ExtUtils/MakeMaker.pm.\n";
1678 print BS "\@DynaLoader::dl_resolve_using = ";
1679 # If @all contains names in the form -lxxx or -Lxxx then it's asking for
1680 # runtime library location so we automatically add a call to dl_findfile()
1681 if (" @all" =~ m/ -[lLR]/){
1682 print BS " dl_findfile(qw(\n @all\n ));\n";
1684 print BS " qw(@all);\n";
1686 # write extra code if *_BS says so
1687 print BS $DynaLoader::bscode if $DynaLoader::bscode;
1692 # special handling for systems which needs a list of all global
1693 # symbols exported by a modules to be dynamically linked.
1694 if ($Config{'dlsrc'} =~ /^dl_aix/){
1696 ($bootfunc = $att{NAME}) =~ s/\W/_/g;
1697 open EXP, ">$att{BASEEXT}.exp";
1698 print EXP "#!\nboot_$bootfunc\n";
1704 # --- Output postprocessing section ---
1705 #nicetext is included to make VMS support easier
1706 sub nicetext { # Just return the input - no action needed
1707 my($self,$text) = @_;
1711 # the following keeps AutoSplit happy
1712 package ExtUtils::MakeMaker;