Re: Debugger in beta3
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MakeMaker.pm
CommitLineData
e05e23b1 1package main;
2use vars qw(%att);
3
4# $Id: MakeMaker.pm,v 1.174 1996/02/06 17:03:12 k Exp $
5
8e07c86e 6package ExtUtils::MakeMaker::TieAtt;
7# this package will go away again, when we don't have modules around
8# anymore that import %att It ties an empty %att and records in which
9# object this %att was tied. FETCH and STORE return/store-to the
10# appropriate value from %$self
005c1a0e 11
8e07c86e 12# the warndirectuse method warns if somebody calls MM->something. It
13# has nothing to do with the tie'd %att.
005c1a0e 14
8e07c86e 15$Enough_limit = 5;
a0d0e21e 16
8e07c86e 17sub TIEHASH {
18 bless { SECRETHASH => $_[1]};
005c1a0e 19}
42793c05 20
8e07c86e 21sub FETCH {
4633a7c4 22 print "Warning (non-fatal): Importing of %att is deprecated [$_[1]]
8e07c86e 23 use \$self instead\n" unless ++$Enough>$Enough_limit;
24 print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
25 $_[0]->{SECRETHASH}->{$_[1]};
1aef975c 26}
42793c05 27
8e07c86e 28sub STORE {
4633a7c4 29 print "Warning (non-fatal): Importing of %att is deprecated [$_[1]][$_[2]]
8e07c86e 30 use \$self instead\n" unless ++$Enough>$Enough_limit;
31 print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
32 $_[0]->{SECRETHASH}->{$_[1]} = $_[2];
33}
42793c05 34
8e07c86e 35sub FIRSTKEY {
4633a7c4 36 print "Warning (non-fatal): Importing of %att is deprecated [FIRSTKEY]
8e07c86e 37 use \$self instead\n" unless ++$Enough>$Enough_limit;
38 print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
39 each %{$_[0]->{SECRETHASH}};
40}
42793c05 41
8e07c86e 42sub NEXTKEY {
43 each %{$_[0]->{SECRETHASH}};
44}
005c1a0e 45
8e07c86e 46sub DESTROY {
47}
005c1a0e 48
8e07c86e 49sub warndirectuse {
50 my($caller) = @_;
51 return if $Enough>$Enough_limit;
4633a7c4 52 print STDOUT "Warning (non-fatal): Direct use of class methods deprecated; use\n";
8e07c86e 53 my($method) = $caller =~ /.*:(\w+)$/;
864a5fa8 54 print STDOUT
8e07c86e 55' my $self = shift;
8e07c86e 56 $self->MM::', $method, "();
57 instead\n";
58 print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n"
59 if ++$Enough==$Enough_limit;
60}
005c1a0e 61
005c1a0e 62
42793c05 63
005c1a0e 64
e05e23b1 65
66
67package ExtUtils::MakeMaker;
68
69$Version = $VERSION = "5.21";
70$Version_OK = "5.05"; # Makefiles older than $Version_OK will die
8e07c86e 71 # (Will be checked from MakeMaker version 4.13 onwards)
e05e23b1 72($Revision = substr(q$Revision: 1.174 $, 10)) =~ s/\s+$//;
73
74
005c1a0e 75
8e07c86e 76use Config;
77use Carp;
78use Cwd;
79require Exporter;
80require ExtUtils::Manifest;
e05e23b1 81{
82 # Current (5.21) FileHandle doesn't work with miniperl, so we roll our own
83 # that's all copy & paste code from FileHandle.pm, version of perl5.002b3
84 package FileHandle;
85 use Symbol;
86 sub new {
87 @_ >= 1 && @_ <= 3 or croak('usage: new FileHandle [FILENAME [,MODE]]');
88 my $class = shift;
89 my $fh = gensym;
90 if (@_) {
91 FileHandle::open($fh, @_)
92 or return undef;
93 }
94 bless $fh, $class;
95 }
96 sub open {
97 @_ >= 2 && @_ <= 4 or croak('usage: $fh->open(FILENAME [,MODE [,PERMS]])');
98 my ($fh, $file) = @_;
99 if (@_ > 2) {
100 my ($mode, $perms) = @_[2, 3];
101 if ($mode =~ /^\d+$/) {
102 defined $perms or $perms = 0666;
103 return sysopen($fh, $file, $mode, $perms);
104 }
105 $file = "./" . $file unless $file =~ m#^/#;
106 $file = _open_mode_string($mode) . " $file\0";
107 }
108 open($fh, $file);
109 }
110 sub close {
111 @_ == 1 or croak('usage: $fh->close()');
112 close($_[0]);
113 }
114}
115
116use vars qw(
117 $VERSION $Version_OK $Revision
118 $Verbose %MM_Sections
119 @MM_Sections %Recognized_Att_Keys @Get_from_Config
120 %Prepend_dot_dot %Config @Parent %NORMAL_INC
121 $Setup_done
122 );
8e07c86e 123#use strict qw(refs);
005c1a0e 124
8e07c86e 125eval {require DynaLoader;}; # Get mod2fname, if defined. Will fail
126 # with miniperl.
005c1a0e 127
e05e23b1 128#
129# Set up the inheritance before we pull in the MM_* packages, because they
130# import variables and functions from here
131#
132@ISA = qw(Exporter);
133@EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt);
134@EXPORT_OK = qw($VERSION &Version_check &help &neatvalue &mkbootstrap &mksymlists
135 $Version %att); ## Import of %att is deprecated, please use OO features!
136 # $Version in mixed case will go away!
005c1a0e 137
e05e23b1 138#
139# Dummy package MM inherits actual methods from OS-specific
140# default packages. We use this intermediate package so
141# MY::XYZ->func() can call MM->func() and get the proper
142# default routine without having to know under what OS
143# it's running.
144#
145@MM::ISA = qw[ExtUtils::MM_Unix ExtUtils::Liblist ExtUtils::MakeMaker];
42793c05 146
e05e23b1 147#
148# Setup dummy package:
149# MY exists for overriding methods to be defined within
150#
151{
152 package MY;
153 @ISA = qw(MM);
154}
42793c05 155
e05e23b1 156{
157 package MM;
158 # From somwhere they will want to inherit DESTROY
159 sub DESTROY {}
160}
42793c05 161
e05e23b1 162#
163# No we can can pull in the friends
164#
165require ExtUtils::MM_Unix;
166if ($Is_VMS = ($Config{osname} eq 'VMS')) {
0d8023a2 167 require ExtUtils::MM_VMS;
168 require VMS::Filespec;
169 import VMS::Filespec '&vmsify';
170}
e05e23b1 171if ($Is_OS2 = $Config{osname} =~ m|^os/?2$|i) {
172 require ExtUtils::MM_OS2;
173}
75f92628 174
e05e23b1 175%NORMAL_INC = %INC;
176# package name for the classes into which the first object will be blessed
177$PACKNAME = "PACK000";
42793c05 178
e05e23b1 179 #####
180# # # # #####
181# # # # #
182 ##### # # #####
183 # # # # #
184# # # # # #
185 ##### #### #####
4633a7c4 186
864a5fa8 187
e05e23b1 188#
189# MakeMaker serves currently (v 5.20) only for two purposes:
190# Version_Check, and WriteMakefile. For WriteMakefile SelfLoader
191# doesn't buy us anything. But for Version_Check we win with
192# SelfLoader more than a second.
193#
194# The only subroutine we do not SelfLoad is Version_Check because it's
195# called so often. Loading this minimum still requires 1.2 secs on my
196# Indy :-(
197#
198
199sub Version_check {
200 my($checkversion) = @_;
201 die "Your Makefile was built with ExtUtils::MakeMaker v $checkversion.
202Current Version is $ExtUtils::MakeMaker::VERSION. There have been considerable
203changes in the meantime.
204Please rerun 'perl Makefile.PL' to regenerate the Makefile.\n"
205 if $checkversion < $Version_OK;
206 printf STDOUT "%s %s %s %s.\n", "Makefile built with ExtUtils::MakeMaker v",
207 $checkversion, "Current Version is", $VERSION
208 unless $checkversion == $VERSION;
8e07c86e 209}
e05e23b1 210
211# We don't selfload this, because chdir sometimes has problems
212sub eval_in_subdirs {
213 my($self) = @_;
214 my($dir);
215# print "Starting to wade through directories:\n";
216# print join "\n", @{$self->{DIR}}, "\n";
217 my $pwd = cwd();
218
219 # As strange things happened twice in the history of MakeMaker to $self->{DIR},
220 # lets be careful, maybe it helps some:
221# my(@copy_of_DIR) = @{$self->{DIR}};
222# my %copy;
223# @copy{@copy_od_DIR} = (1) x @copy_of_DIR;
224
225 # with Tk-9.02 these give me as third directory "1":
226 # foreach $dir (@($self->{DIR}){
227 # foreach $dir (@copy_of_DIR){
228
229 # this gives mi as third directory a core dump:
230 # while ($dir = shift @copy_of_DIR){
231
232 # this finishes the loop immediately:
233# foreach $dir (keys %copy){
234# print "Next to come: $dir\n";
235# chdir $dir or die "Couldn't change to directory $dir: $!";
236# package main;
237# my $fh = new FileHandle;
238# $fh->open("Makefile.PL") or carp("Couldn't open Makefile.PL in $dir");
239# my $eval = join "", <$fh>;
240# $fh->close;
241# eval $eval;
242# warn "WARNING from evaluation of $dir/Makefile.PL: $@" if $@;
243# chdir $pwd or die "Couldn't change to directory $pwd: $!";
244# }
245
246
247 # So this did the trick (did it?)
248 foreach $dir (@{$self->{DIR}}){
249# print "Next to come: $dir\n";
250 my($abs) = $self->catdir($pwd,$dir);
251 $self->eval_in_x($abs);
252 }
253
254 chdir $pwd;
255
256# print "Proudly presenting you self->{DIR}:\n";
257# print join "\n", @{$self->{DIR}}, "\n";
258
864a5fa8 259}
42793c05 260
e05e23b1 261sub eval_in_x {
262 my($self,$dir) = @_;
263 package main;
264 chdir $dir or carp("Couldn't change to directory $dir: $!");
265 my $fh = new FileHandle;
266 $fh->open("Makefile.PL") or carp("Couldn't open Makefile.PL in $dir");
267 my $eval = join "", <$fh>;
268 $fh->close;
269 eval $eval;
270 warn "WARNING from evaluation of $dir/Makefile.PL: $@" if $@;
271}
272
273# use SelfLoader;
274# sub ExtUtils::MakeMaker::full_setup ;
275# sub ExtUtils::MakeMaker::attrib_help ;
276# sub ExtUtils::MakeMaker::writeMakefile ;
277# sub ExtUtils::MakeMaker::WriteMakefile ;
278# sub ExtUtils::MakeMaker::new ;
279# sub ExtUtils::MakeMaker::check_manifest ;
280# sub ExtUtils::MakeMaker::parse_args ;
281# sub ExtUtils::MakeMaker::check_hints ;
282# sub ExtUtils::MakeMaker::mv_all_methods ;
283# sub ExtUtils::MakeMaker::prompt ;
284# sub ExtUtils::MakeMaker::help ;
285# sub ExtUtils::MakeMaker::skipcheck ;
286# sub ExtUtils::MakeMaker::flush ;
287# sub ExtUtils::MakeMaker::mkbootstrap ;
288# sub ExtUtils::MakeMaker::mksymlists ;
289# sub ExtUtils::MakeMaker::neatvalue ;
290# sub ExtUtils::MakeMaker::selfdocument ;
291
292# 1;
293
294# __DATA__
295
296#
297# We're done with inheritance setup. As we have two frequently called
298# things: Check_Version() and mod_install(), we want to reduce startup
299# time. Only WriteMakefile needs all the power here.
300#
301
302sub full_setup {
303 $Verbose ||= 0;
304 $^W=1;
305 $SIG{__WARN__} = sub {
306 $_[0] =~ /^Use of uninitialized value/ && return;
307 $_[0] =~ /used only once/ && return;
308 $_[0] =~ /^Subroutine\s+[\w:]+\s+redefined/ && return;
309 warn @_;
310 };
311
312 @MM_Sections =
313 qw(
314 post_initialize const_config constants const_loadlibs
315 const_cccmd tool_autosplit tool_xsubpp tools_other dist macro
316 depend post_constants pasthru c_o xs_c xs_o top_targets
317 linkext dlsyms dynamic dynamic_bs dynamic_lib static
318 static_lib installpm manifypods processPL installbin subdirs
319 clean realclean dist_basics dist_core dist_dir dist_test
320 dist_ci install force perldepend makefile staticmake test
321 postamble selfdocument
322 ); # loses section ordering
323
324 @MM_Sections{@MM_Sections} = {} x @MM_Sections;
325
326 # All sections are valid keys.
327 %Recognized_Att_Keys = %MM_Sections;
328
329 # we will use all these variables in the Makefile
330 @Get_from_Config =
331 qw(
332 ar cc cccdlflags ccdlflags dlext dlsrc ld lddlflags ldflags libc
333 lib_ext obj_ext ranlib sitelibexp sitearchexp so
334 );
335
336 my $item;
337 foreach $item (split(/\n/,attrib_help())){
338 next unless $item =~ m/^=item\s+(\w+)\s*$/;
339 $Recognized_Att_Keys{$1} = $2;
340 print "Attribute '$1' => '$2'\n" if ($Verbose >= 2);
341 }
342 foreach $item (@Get_from_Config) {
343 $Recognized_Att_Keys{uc $item} = $Config{$item};
344 print "Attribute '\U$item\E' => '$Config{$item}'\n"
345 if ($Verbose >= 2);
346 }
347
348 #
349 # When we pass these through to a Makefile.PL in a subdirectory, we prepend
350 # "..", so that all files to be installed end up below ./blib
351 #
352 %Prepend_dot_dot =
353 qw(
354 INST_LIB 1 INST_ARCHLIB 1 INST_EXE 1 MAP_TARGET 1 INST_MAN1DIR 1 INST_MAN3DIR 1
355 PERL_SRC 1 PERL 1 FULLPERL 1
356 );
357
358}
359
360sub attrib_help {
361 return $Attrib_Help if $Attrib_Help;
362 my $switch = 0;
363 my $help = "";
364 my $line;
365 while ($line = <DATA>) {
366 $switch ||= $line =~ /^=item C\s*$/;
367 next unless $switch;
368 last if $line =~ /^=cut/;
369 $help .= $line;
370 }
371# close DATA;
372 $Attrib_Help = $help;
373}
42793c05 374
8e07c86e 375sub writeMakefile {
376 die <<END;
232e078e 377
8e07c86e 378The extension you are trying to build apparently is rather old and
379most probably outdated. We detect that from the fact, that a
380subroutine "writeMakefile" is called, and this subroutine is not
381supported anymore since about October 1994.
40000a8c 382
4633a7c4 383Please contact the author or look into CPAN (details about CPAN can be
384found in the FAQ and at http:/www.perl.com) for a more recent version
385of the extension. If you're really desperate, you can try to change
386the subroutine name from writeMakefile to WriteMakefile and rerun
387'perl Makefile.PL', but you're most probably left alone, when you do
388so.
42793c05 389
8e07c86e 390The MakeMaker team
1aef975c 391
42793c05 392END
8e07c86e 393}
42793c05 394
8e07c86e 395sub WriteMakefile {
396 Carp::croak "WriteMakefile: Need even number of args" if @_ % 2;
397 my %att = @_;
398 MM->new(\%att)->flush;
42793c05 399}
400
8e07c86e 401sub new {
402 my($class,$self) = @_;
e05e23b1 403 full_setup() unless $Setup_done++;
404
8e07c86e 405 my($key);
42793c05 406
e05e23b1 407 print STDOUT "MakeMaker (v$VERSION)\n" if $Verbose;
8e07c86e 408 if (-f "MANIFEST" && ! -f "Makefile"){
409 check_manifest();
1aef975c 410 }
42793c05 411
8e07c86e 412 $self = {} unless (defined $self);
005c1a0e 413
864a5fa8 414 check_hints($self);
4633a7c4 415
8e07c86e 416 my(%initial_att) = %$self; # record initial attributes
005c1a0e 417
8e07c86e 418 if (defined $self->{CONFIGURE}) {
419 if (ref $self->{CONFIGURE} eq 'CODE') {
420 $self = { %$self, %{&{$self->{CONFIGURE}}}};
005c1a0e 421 } else {
8e07c86e 422 croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n";
005c1a0e 423 }
424 }
a0d0e21e 425
8e07c86e 426 # This is for old Makefiles written pre 5.00, will go away
427 if ( Carp::longmess("") =~ /runsubdirpl/s ){
e05e23b1 428 #$self->{Correct_relativ_directories}++;
429 carp("WARNING: Please rerun 'perl Makefile.PL' to regenerate your Makefiles\n");
8e07c86e 430 } else {
431 $self->{Correct_relativ_directories}=0;
432 }
5d94fbed 433
8e07c86e 434 my $class = ++$PACKNAME;
435 {
436# no strict;
e05e23b1 437 print "Blessing Object into class [$class]\n" if $Verbose>=2;
8e07c86e 438 mv_all_methods("MY",$class);
439 bless $self, $class;
e05e23b1 440 push @Parent, $self;
8e07c86e 441 @{"$class\:\:ISA"} = 'MM';
442 }
5d94fbed 443
e05e23b1 444 if (defined $Parent[-2]){
445 $self->{PARENT} = $Parent[-2];
8e07c86e 446 my $key;
e05e23b1 447 for $key (keys %Prepend_dot_dot) {
4633a7c4 448 next unless defined $self->{PARENT}{$key};
8e07c86e 449 $self->{$key} = $self->{PARENT}{$key};
450 $self->{$key} = $self->catdir("..",$self->{$key})
451 unless $self->{$key} =~ m!^/!;
452 }
453 $self->{PARENT}->{CHILDREN}->{$class} = $self if $self->{PARENT};
454 } else {
455 parse_args($self,@ARGV);
456 }
a0d0e21e 457
8e07c86e 458 $self->{NAME} ||= $self->guess_name;
a0d0e21e 459
8e07c86e 460 ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g;
a0d0e21e 461
8e07c86e 462 $self->init_main();
463
0d8023a2 464 if (! $self->{PERL_SRC} ) {
465 my($pthinks) = $INC{'Config.pm'};
466 $pthinks = vmsify($pthinks) if $Is_VMS;
e05e23b1 467 if ($pthinks ne $self->catfile($Config{archlibexp},'Config.pm')){
0d8023a2 468 $pthinks =~ s!/Config\.pm$!!;
469 $pthinks =~ s!.*/!!;
470 print STDOUT <<END;
005c1a0e 471Your perl and your Config.pm seem to have different ideas about the architecture
472they are running on.
8e07c86e 473Perl thinks: [$pthinks]
e05e23b1 474Config says: [$Config{archname}]
005c1a0e 475This may or may not cause problems. Please check your installation of perl if you
476have problems building this extension.
477END
0d8023a2 478 }
005c1a0e 479 }
480
8e07c86e 481 $self->init_dirscan();
482 $self->init_others();
75f92628 483
8e07c86e 484 push @{$self->{RESULT}}, <<END;
485# This Makefile is for the $self->{NAME} extension to perl.
486#
e05e23b1 487# It was generated automatically by MakeMaker version
488# $VERSION (Revision: $Revision) from the contents of
489# Makefile.PL. Don't edit this file, edit Makefile.PL instead.
8e07c86e 490#
491# ANY CHANGES MADE HERE WILL BE LOST!
492#
493# MakeMaker Parameters:
494END
a0d0e21e 495
42793c05 496 foreach $key (sort keys %initial_att){
497 my($v) = neatvalue($initial_att{$key});
8e07c86e 498 $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
42793c05 499 $v =~ tr/\n/ /s;
8e07c86e 500 push @{$self->{RESULT}}, "# $key => $v";
42793c05 501 }
a0d0e21e 502
8e07c86e 503 # turn the SKIP array into a SKIPHASH hash
504 my (%skip,$skip);
505 for $skip (@{$self->{SKIP} || []}) {
506 $self->{SKIPHASH}{$skip} = 1;
507 }
42793c05 508
8e07c86e 509 # We run all the subdirectories now. They don't have much to query
510 # from the parent, but the parent has to query them: if they need linking!
8e07c86e 511 unless ($self->{NORECURS}) {
e05e23b1 512 $self->eval_in_subdirs if @{$self->{DIR}};
42793c05 513 }
a0d0e21e 514
8e07c86e 515 tie %::att, ExtUtils::MakeMaker::TieAtt, $self;
516 my $section;
e05e23b1 517 foreach $section ( @MM_Sections ){
518 print "Processing Makefile '$section' section\n" if ($Verbose >= 2);
8e07c86e 519 my($skipit) = $self->skipcheck($section);
520 if ($skipit){
521 push @{$self->{RESULT}}, "\n# --- MakeMaker $section section $skipit.";
4e68a208 522 } else {
8e07c86e 523 my(%a) = %{$self->{$section} || {}};
524 push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:";
e05e23b1 525 push @{$self->{RESULT}}, "# " . join ", ", %a if $Verbose && %a;
8e07c86e 526 push @{$self->{RESULT}}, $self->nicetext($self->$section( %a ));
e05e23b1 527 }
232e078e 528 }
8e07c86e 529
e05e23b1 530 push @{$self->{RESULT}}, "\n# End.";
531 pop @Parent;
8e07c86e 532
e05e23b1 533 $self;
232e078e 534}
535
e05e23b1 536sub check_manifest {
537 print STDOUT "Checking if your kit is complete...\n";
538 $ExtUtils::Manifest::Quiet=$ExtUtils::Manifest::Quiet=1; #avoid warning
539 my(@missed)=ExtUtils::Manifest::manicheck();
540 if (@missed){
541 print STDOUT "Warning: the following files are missing in your kit:\n";
542 print "\t", join "\n\t", @missed;
543 print STDOUT "\n";
544 print STDOUT "Please inform the author.\n";
8e07c86e 545 } else {
e05e23b1 546 print STDOUT "Looks good\n";
8e07c86e 547 }
8e07c86e 548}
549
e05e23b1 550sub parse_args{
551 my($self, @args) = @_;
552 foreach (@args){
553 unless (m/(.*?)=(.*)/){
554 help(),exit 1 if m/^help$/;
555 ++$Verbose if m/^verb/;
556 next;
557 }
558 my($name, $value) = ($1, $2);
559 if ($value =~ m/^~(\w+)?/){ # tilde with optional username
560 $value =~ s [^~(\w*)]
561 [$1 ?
562 ((getpwnam($1))[7] || "~$1") :
563 (getpwuid($>))[7]
564 ]ex;
565 }
566 # This may go away, in mid 1996
567 if ($self->{Correct_relativ_directories}){
568 $value = $self->catdir("..",$value)
569 if $Prepend_dot_dot{$name} && ! $value =~ m!^/!;
570 }
571 $self->{$name} = $value;
8e07c86e 572 }
e05e23b1 573 # This may go away, in mid 1996
574 delete $self->{Correct_relativ_directories};
8e07c86e 575
e05e23b1 576 # catch old-style 'potential_libs' and inform user how to 'upgrade'
577 if (defined $self->{potential_libs}){
578 my($msg)="'potential_libs' => '$self->{potential_libs}' should be";
579 if ($self->{potential_libs}){
580 print STDOUT "$msg changed to:\n\t'LIBS' => ['$self->{potential_libs}']\n";
581 } else {
582 print STDOUT "$msg deleted.\n";
583 }
584 $self->{LIBS} = [$self->{potential_libs}];
585 delete $self->{potential_libs};
8e07c86e 586 }
e05e23b1 587 # catch old-style 'ARMAYBE' and inform user how to 'upgrade'
588 if (defined $self->{ARMAYBE}){
589 my($armaybe) = $self->{ARMAYBE};
590 print STDOUT "ARMAYBE => '$armaybe' should be changed to:\n",
591 "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n";
592 my(%dl) = %{$self->{dynamic_lib} || {}};
593 $self->{dynamic_lib} = { %dl, ARMAYBE => $armaybe};
594 delete $self->{ARMAYBE};
8e07c86e 595 }
e05e23b1 596 if (defined $self->{LDTARGET}){
597 print STDOUT "LDTARGET should be changed to LDFROM\n";
598 $self->{LDFROM} = $self->{LDTARGET};
599 delete $self->{LDTARGET};
8e07c86e 600 }
e05e23b1 601 # Turn a DIR argument on the command line into an array
602 if (defined $self->{DIR} && ref \$self->{DIR} eq 'SCALAR') {
603 # So they can choose from the command line, which extensions they want
604 # the grep enables them to have some colons too much in case they
605 # have to build a list with the shell
606 $self->{DIR} = [grep $_, split ":", $self->{DIR}];
8e07c86e 607 }
e05e23b1 608 my $mmkey;
609 foreach $mmkey (sort keys %$self){
610 print STDOUT " $mmkey => ", neatvalue($self->{$mmkey}), "\n" if $Verbose;
611 print STDOUT "'$mmkey' is not a known MakeMaker parameter name.\n"
612 unless exists $Recognized_Att_Keys{$mmkey};
613 }
614}
8e07c86e 615
e05e23b1 616sub check_hints {
617 my($self) = @_;
618 # We allow extension-specific hints files.
864a5fa8 619
e05e23b1 620 return unless -d "hints";
8e07c86e 621
e05e23b1 622 # First we look for the best hintsfile we have
623 my(@goodhints);
624 my($hint)="$Config{osname}_$Config{osvers}";
625 $hint =~ s/\./_/g;
626 $hint =~ s/_$//;
627 return unless $hint;
fed7345c 628
e05e23b1 629 # Also try without trailing minor version numbers.
630 while (1) {
631 last if -f "hints/$hint.pl"; # found
632 } continue {
633 last unless $hint =~ s/_[^_]*$//; # nothing to cut off
634 }
635 return unless -f "hints/$hint.pl"; # really there
fed7345c 636
e05e23b1 637 # execute the hintsfile:
638 my $fh = new FileHandle;
639 $fh->open("hints/$hint.pl");
640 @goodhints = <$fh>;
641 $fh->close;
642 print STDOUT "Processing hints file hints/$hint.pl\n";
643 eval join('',@goodhints);
644 print STDOUT $@ if $@;
645}
8e07c86e 646
e05e23b1 647sub mv_all_methods {
648 my($from,$to) = @_;
649 my($method);
650 my($symtab) = \%{"${from}::"};
651# no strict;
fed7345c 652
e05e23b1 653 # Here you see the *current* list of methods that are overridable
654 # from Makefile.PL via MY:: subroutines. As of VERSION 5.07 I'm
655 # still trying to reduce the list to some reasonable minimum --
656 # because I want to make it easier for the user. A.K.
40000a8c 657
e05e23b1 658 foreach $method (@MM_Sections, qw[ dir_target
659fileparse fileparse_set_fstype installpm_x libscan makeaperl
660mksymlists needs_linking subdir_x test_via_harness
661test_via_script writedoc ]) {
fed7345c 662
e05e23b1 663 # We cannot say "next" here. Nick might call MY->makeaperl
664 # which isn't defined right now
fed7345c 665
e05e23b1 666 # next unless defined &{"${from}::$method"};
fed7345c 667
e05e23b1 668 *{"${to}::$method"} = \&{"${from}::$method"};
8e07c86e 669
e05e23b1 670 # delete would do, if we were sure, nobody ever called
671 # MY->makeaperl directly
232e078e 672
e05e23b1 673 # delete $symtab->{$method};
fed7345c 674
e05e23b1 675 # If we delete a method, then it will be undefined and cannot
676 # be called. But as long as we have Makefile.PLs that rely on
677 # %MY:: being intact, we have to fill the hole with an
678 # inheriting method:
fed7345c 679
e05e23b1 680 eval "package MY; sub $method {local *$method; shift->MY::$method(\@_); }";
5d94fbed 681
5d94fbed 682 }
683
e05e23b1 684 # We have to clean out %INC also, because the current directory is
685 # changed frequently and Graham Barr prefers to get his version
686 # out of a History.pl file which is "required" so woudn't get
687 # loaded again in another extension requiring a History.pl
a0d0e21e 688
e05e23b1 689 my $inc;
690 foreach $inc (keys %INC) {
691 next if $NORMAL_INC{$inc};
692 #warn "***$inc*** deleted";
693 delete $INC{$inc};
8e07c86e 694 }
a0d0e21e 695
8e07c86e 696}
697
e05e23b1 698sub prompt {
699 my($mess,$def)=@_;
700 BEGIN { $ISA_TTY = -t STDIN && -t STDOUT }
701 Carp::confess("prompt function called without an argument") unless defined $mess;
702 $def = "" unless defined $def;
703 my $dispdef = "[$def] ";
704 my $ans;
705 if ($ISA_TTY) {
706 local $|=1;
707 print "$mess $dispdef";
708 chop($ans = <STDIN>);
8e07c86e 709 }
e05e23b1 710 return $ans if defined $ans;
711 return $def;
42793c05 712}
fed7345c 713
e05e23b1 714sub help {print &attrib_help, "\n";}
8e07c86e 715
e05e23b1 716sub skipcheck{
8e07c86e 717 my($self) = shift;
e05e23b1 718 my($section) = @_;
719 if ($section eq 'dynamic') {
720 print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
721 "in skipped section 'dynamic_bs'\n"
722 if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
723 print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
724 "in skipped section 'dynamic_lib'\n"
725 if $self->{SKIPHASH}{dynamic_lib} && $Verbose;
8e07c86e 726 }
e05e23b1 727 if ($section eq 'dynamic_lib') {
728 print STDOUT "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on ",
729 "targets in skipped section 'dynamic_bs'\n"
730 if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
731 }
732 if ($section eq 'static') {
733 print STDOUT "Warning (non-fatal): Target 'static' depends on targets ",
734 "in skipped section 'static_lib'\n"
735 if $self->{SKIPHASH}{static_lib} && $Verbose;
8e07c86e 736 }
e05e23b1 737 return 'skipped' if $self->{SKIPHASH}{$section};
738 return '';
8e07c86e 739}
740
e05e23b1 741sub flush {
742 my $self = shift;
743 my($chunk);
744 my $fh = new FileHandle;
745 print STDOUT "Writing $self->{MAKEFILE} for $self->{NAME}\n";
8e07c86e 746
e05e23b1 747 unlink($self->{MAKEFILE}, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : '');
748 $fh->open(">MakeMaker.tmp") or die "Unable to open MakeMaker.tmp: $!";
8e07c86e 749
e05e23b1 750 for $chunk (@{$self->{RESULT}}) {
751 print $fh "$chunk\n";
8e07c86e 752 }
e05e23b1 753
754 $fh->close;
755 my($finalname) = $self->{MAKEFILE};
756 rename("MakeMaker.tmp", $finalname);
757 chmod 0644, $finalname unless $Is_VMS;
758 system("$Config::Config{eunicefix} $finalname") unless $Config::Config{eunicefix} eq ":";
40000a8c 759}
760
e05e23b1 761# The following mkbootstrap() is only for installations that are calling
762# the pre-4.1 mkbootstrap() from their old Makefiles. This MakeMaker
763# writes Makefiles, that use ExtUtils::Mkbootstrap directly.
764sub mkbootstrap {
765 die <<END;
766!!! Your Makefile has been built such a long time ago, !!!
767!!! that is unlikely to work with current MakeMaker. !!!
768!!! Please rebuild your Makefile !!!
769END
8e07c86e 770}
005c1a0e 771
e05e23b1 772# Ditto for mksymlists() as of MakeMaker 5.17
773sub mksymlists {
774 die <<END;
775!!! Your Makefile has been built such a long time ago, !!!
776!!! that is unlikely to work with current MakeMaker. !!!
777!!! Please rebuild your Makefile !!!
778END
4633a7c4 779}
780
e05e23b1 781sub neatvalue {
782 my($v) = @_;
783 return "undef" unless defined $v;
784 my($t) = ref $v;
785 return "q[$v]" unless $t;
786 if ($t eq 'ARRAY') {
787 my(@m, $elem, @neat);
788 push @m, "[";
789 foreach $elem (@$v) {
790 push @neat, "q[$elem]";
791 }
792 push @m, join ", ", @neat;
793 push @m, "]";
794 return join "", @m;
795 }
796 return "$v" unless $t eq 'HASH';
797 my(@m, $key, $val);
798 push(@m,"$key=>".neatvalue($val)) while (($key,$val) = each %$v);
799 return "{ ".join(', ',@m)." }";
4e68a208 800}
801
e05e23b1 802sub selfdocument {
803 my($self) = @_;
804 my(@m);
805 if ($Verbose){
806 push @m, "\n# Full list of MakeMaker attribute values:";
807 foreach $key (sort keys %$self){
808 next if $key eq 'RESULT' || $key =~ /^[A-Z][a-z]/;
809 my($v) = neatvalue($self->{$key});
810 $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
811 $v =~ tr/\n/ /s;
812 push @m, "# $key => $v";
813 }
814 }
815 join "\n", @m;
816}
4e68a208 817
005c1a0e 818package ExtUtils::MakeMaker;
8191;
820
e05e23b1 821# Without selfLoader we need
822__DATA__
823
824
825# For SelfLoader we need
826# __END__ DATA
827
005c1a0e 828
829=head1 NAME
830
831ExtUtils::MakeMaker - create an extension Makefile
832
833=head1 SYNOPSIS
834
835C<use ExtUtils::MakeMaker;>
836
837C<WriteMakefile( ATTRIBUTE =E<gt> VALUE [, ...] );>
838
8e07c86e 839which is really
840
841C<MM-E<gt>new(\%att)-E<gt>flush;>
842
005c1a0e 843=head1 DESCRIPTION
844
845This utility is designed to write a Makefile for an extension module
846from a Makefile.PL. It is based on the Makefile.SH model provided by
847Andy Dougherty and the perl5-porters.
848
849It splits the task of generating the Makefile into several subroutines
850that can be individually overridden. Each subroutine returns the text
851it wishes to have written to the Makefile.
852
4633a7c4 853=head2 Hintsfile support
854
005c1a0e 855MakeMaker.pm uses the architecture specific information from
8e07c86e 856Config.pm. In addition it evaluates architecture specific hints files
857in a C<hints/> directory. The hints files are expected to be named
858like their counterparts in C<PERL_SRC/hints>, but with an C<.pl> file
859name extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by
860MakeMaker within the WriteMakefile() subroutine, and can be used to
861execute commands as well as to include special variables. The rules
862which hintsfile is chosen are the same as in Configure.
863
4633a7c4 864The hintsfile is eval()ed immediately after the arguments given to
865WriteMakefile are stuffed into a hash reference $self but before this
866reference becomes blessed. So if you want to do the equivalent to
867override or create an attribute you would say something like
868
869 $self->{LIBS} = ['-ldbm -lucb -lc'];
870
8e07c86e 871=head2 What's new in version 5 of MakeMaker
872
873MakeMaker 5 is pure object oriented. This allows us to write an
874unlimited number of Makefiles with a single perl process. 'perl
875Makefile.PL' with MakeMaker 5 goes through all subdirectories
876immediately and evaluates any Makefile.PL found in the next level
877subdirectories. The benefit of this approach comes in useful for both
878single and multi directories extensions.
879
880Multi directory extensions have an immediately visible speed
881advantage, because there's no startup penalty for any single
882subdirectory Makefile.
883
884Single directory packages benefit from the much improved
885needs_linking() method. As the main Makefile knows everything about
886the subdirectories, a needs_linking() method can now query all
887subdirectories if there is any linking involved down in the tree. The
888speedup for PM-only Makefiles seems to be around 1 second on my
889Indy 100 MHz.
890
891=head2 Incompatibilities between MakeMaker 5.00 and 4.23
892
893There are no incompatibilities in the short term, as all changes are
894accompanied by short-term workarounds that guarantee full backwards
895compatibility.
896
4633a7c4 897You are likely to face a few warnings that expose deprecations which
8e07c86e 898will result in incompatibilities in the long run:
899
900You should not use %att directly anymore. Instead any subroutine you
901override in the MY package will be called by the object method, so you
902can access all object attributes directly via the object in $_[0].
903
904You should not call the class methos MM->something anymore. Instead
905you should call the superclass. Something like
906
907 sub MY::constants {
908 my $self = shift;
8e07c86e 909 $self->MM::constants();
910 }
911
912Especially the libscan() and exescan() methods should be altered
913towards OO programming, that means do not expect that $_ to contain
914the path but rather $_[1].
915
8e07c86e 916Try to build several extensions simultanously to debug your
e05e23b1 917Makefile.PL. You can unpack a bunch of distributed packages within one
918directory and run
8e07c86e 919
e05e23b1 920 perl -MExtUtils::MakeMaker -e 'WriteMakefile()'
8e07c86e 921
922That's actually fun to watch :)
923
924Final suggestion: Try to delete all of your MY:: subroutines and
925watch, if you really still need them. MakeMaker might already do what
926you want without them. That's all about it.
927
005c1a0e 928
929=head2 Default Makefile Behaviour
930
931The automatically generated Makefile enables the user of the extension
932to invoke
933
934 perl Makefile.PL # optionally "perl Makefile.PL verbose"
935 make
8e07c86e 936 make test # optionally set TEST_VERBOSE=1
937 make install # See below
005c1a0e 938
939The Makefile to be produced may be altered by adding arguments of the
e05e23b1 940form C<KEY=VALUE>. E.g.
005c1a0e 941
e05e23b1 942 perl Makefile.PL PREFIX=/tmp/myperl5
005c1a0e 943
944Other interesting targets in the generated Makefile are
945
946 make config # to check if the Makefile is up-to-date
8e07c86e 947 make clean # delete local temp files (Makefile gets renamed)
948 make realclean # delete derived files (including ./blib)
e05e23b1 949 make ci # check in all the files in the MANIFEST file
005c1a0e 950 make dist # see below the Distribution Support section
951
e05e23b1 952=head2 make test
953
954MakeMaker checks for the existence of a file named "test.pl" in the
955current directory and if it exists it adds commands to the test target
956of the generated Makefile that will execute the script with the proper
957set of perl C<-I> options.
958
959MakeMaker also checks for any files matching glob("t/*.t"). It will
960add commands to the test target of the generated Makefile that execute
961all matching files via the L<Test::Harness> module with the C<-I>
962switches set correctly.
963
964=head2 make install
005c1a0e 965
8e07c86e 966make alone puts all relevant files into directories that are named by
967the macros INST_LIB, INST_ARCHLIB, INST_EXE, INST_MAN1DIR, and
e05e23b1 968INST_MAN3DIR. All these default to something below ./blib if
8e07c86e 969you are I<not> building below the perl source directory. If you I<are>
970building below the perl source, INST_LIB and INST_ARCHLIB default to
4633a7c4 971 ../../lib, and INST_EXE is not defined.
005c1a0e 972
e05e23b1 973The I<install> target of the generated Makefile copies the files found
974below each of the INST_* directories to their INSTALL*
975counterparts. Which counterparts are chosen depends on the setting of
976INSTALLDIRS according to the following table:
005c1a0e 977
e05e23b1 978 INSTALLDIRS set to
979 perl site
980
981 INST_LIB INSTALLPRIVLIB INSTALLSITELIB
982 INST_ARCHLIB INSTALLARCHLIB INSTALLSITEARCH
983 INST_EXE INSTALLBIN
984 INST_MAN1DIR INSTALLMAN1DIR
985 INST_MAN3DIR INSTALLMAN3DIR
005c1a0e 986
8e07c86e 987The INSTALL... macros in turn default to their %Config
988($Config{installprivlib}, $Config{installarchlib}, etc.) counterparts.
005c1a0e 989
e05e23b1 990If you don't want to keep the defaults, MakeMaker helps you to
991minimize the typing needed: the usual relationship between
992INSTALLPRIVLIB and INSTALLARCHLIB is determined by Configure at perl
993compilation time. MakeMaker supports the user who sets
994INSTALLPRIVLIB. If INSTALLPRIVLIB is set, but INSTALLARCHLIB not, then
995MakeMaker defaults the latter to be the same subdirectory of
996INSTALLPRIVLIB as Configure decided for the counterparts in %Config ,
997otherwise it defaults to INSTALLPRIVLIB. The same relationship holds
998for INSTALLSITELIB and INSTALLSITEARCH.
005c1a0e 999
1000MakeMaker gives you much more freedom than needed to configure
1001internal variables and get different results. It is worth to mention,
1002that make(1) also lets you configure most of the variables that are
1003used in the Makefile. But in the majority of situations this will not
1004be necessary, and should only be done, if the author of a package
1005recommends it.
1006
005c1a0e 1007
8e07c86e 1008=head2 PREFIX attribute
005c1a0e 1009
0d8023a2 1010The PREFIX attribute can be used to set the INSTALL* attributes in one
1011go. The quickest way to install a module in a non-standard place
005c1a0e 1012
8e07c86e 1013 perl Makefile.PL PREFIX=~
005c1a0e 1014
0d8023a2 1015This will replace the string specified by $Config{prefix} in all
1016$Config{install*} values.
005c1a0e 1017
1018Note, that the tilde expansion is done by MakeMaker, not by perl by
8e07c86e 1019default, nor by make.
005c1a0e 1020
005c1a0e 1021If the user has superuser privileges, and is not working on AFS
1022(Andrew File System) or relatives, then the defaults for
8e07c86e 1023INSTALLPRIVLIB, INSTALLARCHLIB, INSTALLBIN, etc. will be appropriate,
005c1a0e 1024and this incantation will be the best:
1025
1026 perl Makefile.PL; make; make test
1027 make install
1028
8e07c86e 1029make install per default writes some documentation of what has been
e05e23b1 1030done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This feature
1031can be bypassed by calling make pure_install.
8e07c86e 1032
1033=head2 AFS users
1034
1035will have to specify the installation directories as these most
1036probably have changed since perl itself has been installed. They will
1037have to do this by calling
1038
e05e23b1 1039 perl Makefile.PL INSTALLSITELIB=/afs/here/today \
8e07c86e 1040 INSTALLBIN=/afs/there/now INSTALLMAN3DIR=/afs/for/manpages
1041 make
1042
e05e23b1 1043Be careful to repeat this procedure every time you recompile an
1044extension, unless you are sure the AFS installation directories are
1045still valid.
005c1a0e 1046
8e07c86e 1047=head2 Static Linking of a new Perl Binary
005c1a0e 1048
1049An extension that is built with the above steps is ready to use on
1050systems supporting dynamic loading. On systems that do not support
1051dynamic loading, any newly created extension has to be linked together
1052with the available resources. MakeMaker supports the linking process
1053by creating appropriate targets in the Makefile whenever an extension
1054is built. You can invoke the corresponding section of the makefile with
1055
1056 make perl
1057
1058That produces a new perl binary in the current directory with all
e05e23b1 1059extensions linked in that can be found in INST_ARCHLIB , SITELIBEXP,
1060and PERL_ARCHLIB. To do that, MakeMaker writes a new Makefile, on
1061UNIX, this is called Makefile.aperl (may be system dependent). If you
1062want to force the creation of a new perl, it is recommended, that you
1063delete this Makefile.aperl, so the directories are searched-through
1064for linkable libraries again.
005c1a0e 1065
1066The binary can be installed into the directory where perl normally
1067resides on your machine with
1068
1069 make inst_perl
1070
1071To produce a perl binary with a different name than C<perl>, either say
1072
1073 perl Makefile.PL MAP_TARGET=myperl
1074 make myperl
1075 make inst_perl
1076
1077or say
1078
1079 perl Makefile.PL
1080 make myperl MAP_TARGET=myperl
1081 make inst_perl MAP_TARGET=myperl
1082
1083In any case you will be prompted with the correct invocation of the
1084C<inst_perl> target that installs the new binary into INSTALLBIN.
1085
8e07c86e 1086make inst_perl per default writes some documentation of what has been
1087done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This
1088can be bypassed by calling make pure_inst_perl.
005c1a0e 1089
e05e23b1 1090Warning: the inst_perl: target will most probably overwrite your
1091existing perl binary. Use with care!
005c1a0e 1092
8e07c86e 1093Sometimes you might want to build a statically linked perl although
1094your system supports dynamic loading. In this case you may explicitly
1095set the linktype with the invocation of the Makefile.PL or make:
1096
1097 perl Makefile.PL LINKTYPE=static # recommended
1098
1099or
1100
1101 make LINKTYPE=static # works on most systems
1102
005c1a0e 1103=head2 Determination of Perl Library and Installation Locations
1104
1105MakeMaker needs to know, or to guess, where certain things are
e05e23b1 1106located. Especially INST_LIB and INST_ARCHLIB (where to put the files
1107during the make(1) run), PERL_LIB and PERL_ARCHLIB (where to read
1108existing modules from), and PERL_INC (header files and C<libperl*.*>).
005c1a0e 1109
1110Extensions may be built either using the contents of the perl source
e05e23b1 1111directory tree or from the installed perl library. The recommended way
1112is to build extensions after you have run 'make install' on perl
1113itself. You can do that in any directory on your hard disk that is not
1114below the perl source tree. The support for extensions below the ext
1115directory of the perl distribution is only good for the standard
1116extensions that come with perl.
005c1a0e 1117
1118If an extension is being built below the C<ext/> directory of the perl
e05e23b1 1119source then MakeMaker will set PERL_SRC automatically (e.g.,
1120C<../..>). If PERL_SRC is defined and the extension is recognized as
1121a standard extension, then other variables default to the following:
005c1a0e 1122
1123 PERL_INC = PERL_SRC
1124 PERL_LIB = PERL_SRC/lib
1125 PERL_ARCHLIB = PERL_SRC/lib
1126 INST_LIB = PERL_LIB
1127 INST_ARCHLIB = PERL_ARCHLIB
1128
1129If an extension is being built away from the perl source then MakeMaker
1130will leave PERL_SRC undefined and default to using the installed copy
1131of the perl library. The other variables default to the following:
1132
e05e23b1 1133 PERL_INC = $archlibexp/CORE
1134 PERL_LIB = $privlibexp
1135 PERL_ARCHLIB = $archlibexp
1136 INST_LIB = ./blib/lib
1137 INST_ARCHLIB = ./blib/arch
005c1a0e 1138
1139If perl has not yet been installed then PERL_SRC can be defined on the
1140command line as shown in the previous section.
1141
1142=head2 Useful Default Makefile Macros
1143
1144FULLEXT = Pathname for extension directory (eg DBD/Oracle).
1145
1146BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
1147
1148ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
1149
005c1a0e 1150INST_LIBDIR = C<$(INST_LIB)$(ROOTEXT)>
1151
1152INST_AUTODIR = C<$(INST_LIB)/auto/$(FULLEXT)>
1153
1154INST_ARCHAUTODIR = C<$(INST_ARCHLIB)/auto/$(FULLEXT)>
1155
e05e23b1 1156=head2 Using Attributes and Parameters
005c1a0e 1157
1158The following attributes can be specified as arguments to WriteMakefile()
1159or as NAME=VALUE pairs on the command line:
1160
8e07c86e 1161=cut
005c1a0e 1162
864a5fa8 1163# The following "=item C" is used by the attrib_help routine
8e07c86e 1164# likewise the "=back" below. So be careful when changing it!
1165
1166=over 2
1167
864a5fa8 1168=item C
8e07c86e 1169
864a5fa8 1170Ref to array of *.c file names. Initialised from a directory scan
1171and the values portion of the XS attribute hash. This is not
1172currently used by MakeMaker but may be handy in Makefile.PLs.
8e07c86e 1173
864a5fa8 1174=item CONFIG
8e07c86e 1175
864a5fa8 1176Arrayref. E.g. [qw(archname manext)] defines ARCHNAME & MANEXT from
1177config.sh. MakeMaker will add to CONFIG the following values anyway:
1178ar
1179cc
1180cccdlflags
1181ccdlflags
1182dlext
1183dlsrc
1184ld
1185lddlflags
1186ldflags
1187libc
1188lib_ext
1189obj_ext
1190ranlib
e05e23b1 1191sitelibexp
1192sitearchexp
864a5fa8 1193so
8e07c86e 1194
1195=item CONFIGURE
1196
e05e23b1 1197CODE reference. The subroutine should return a hash reference. The
1198hash may contain further attributes, e.g. {LIBS => ...}, that have to
8e07c86e 1199be determined by some evaluation method.
1200
864a5fa8 1201=item DEFINE
8e07c86e 1202
864a5fa8 1203Something like C<"-DHAVE_UNISTD_H">
8e07c86e 1204
864a5fa8 1205=item DIR
8e07c86e 1206
864a5fa8 1207Ref to array of subdirectories containing Makefile.PLs e.g. [ 'sdbm'
1208] in ext/SDBM_File
8e07c86e 1209
864a5fa8 1210=item DISTNAME
8e07c86e 1211
e05e23b1 1212Your name for distributing the package (by tar file). This defaults to
864a5fa8 1213NAME above.
8e07c86e 1214
864a5fa8 1215=item DL_FUNCS
8e07c86e 1216
864a5fa8 1217Hashref of symbol names for routines to be made available as
1218universal symbols. Each key/value pair consists of the package name
1219and an array of routine names in that package. Used only under AIX
1220(export lists) and VMS (linker options) at present. The routine
1221names supplied will be expanded in the same way as XSUB names are
1222expanded by the XS() macro. Defaults to
8e07c86e 1223
864a5fa8 1224 {"$(NAME)" => ["boot_$(NAME)" ] }
8e07c86e 1225
864a5fa8 1226e.g.
8e07c86e 1227
864a5fa8 1228 {"RPC" => [qw( boot_rpcb rpcb_gettime getnetconfigent )],
1229 "NetconfigPtr" => [ 'DESTROY'] }
8e07c86e 1230
864a5fa8 1231=item DL_VARS
8e07c86e 1232
864a5fa8 1233Array of symbol names for variables to be made available as
1234universal symbols. Used only under AIX (export lists) and VMS
1235(linker options) at present. Defaults to []. (e.g. [ qw(
1236Foo_version Foo_numstreams Foo_tree ) ])
8e07c86e 1237
864a5fa8 1238=item EXE_FILES
8e07c86e 1239
864a5fa8 1240Ref to array of executable files. The files will be copied to the
1241INST_EXE directory. Make realclean will delete them from there
1242again.
8e07c86e 1243
864a5fa8 1244=item FIRST_MAKEFILE
1245
1246The name of the Makefile to be produced. Defaults to the contents of
1247MAKEFILE, but can be overridden. This is used for the second Makefile
1248that will be produced for the MAP_TARGET.
1249
1250=item FULLPERL
8e07c86e 1251
864a5fa8 1252Perl binary able to run this extension.
1253
1254=item H
1255
1256Ref to array of *.h file names. Similar to C.
1257
1258=item INC
1259
1260Include file dirs eg: C<"-I/usr/5include -I/path/to/inc">
1261
1262=item INSTALLARCHLIB
1263
e05e23b1 1264Used by 'make install', which copies files from INST_ARCHLIB to this
1265directory if INSTALLDIRS is set to perl.
864a5fa8 1266
1267=item INSTALLBIN
1268
e05e23b1 1269Used by 'make install' which copies files from INST_EXE to this
1270directory.
1271
1272=item INSTALLDIRS
1273
1274Determines which of the two sets of installation directories to
1275choose: installprivlib and installarchlib versus installsitelib and
1276installsitearch. The first pair is chosen with INSTALLDIRS=perl, the
1277second with INSTALLDIRS=site. Default is site.
8e07c86e 1278
1279=item INSTALLMAN1DIR
1280
864a5fa8 1281This directory gets the man pages at 'make install' time. Defaults to
1282$Config{installman1dir}.
1283
8e07c86e 1284=item INSTALLMAN3DIR
1285
864a5fa8 1286This directory gets the man pages at 'make install' time. Defaults to
1287$Config{installman3dir}.
8e07c86e 1288
864a5fa8 1289=item INSTALLPRIVLIB
8e07c86e 1290
e05e23b1 1291Used by 'make install', which copies files from INST_LIB to this
1292directory if INSTALLDIRS is set to perl.
1293
1294=item INSTALLSITELIB
1295
1296Used by 'make install', which copies files from INST_LIB to this
1297directory if INSTALLDIRS is set to site (default).
1298
1299=item INSTALLSITEARCH
1300
1301Used by 'make install', which copies files from INST_ARCHLIB to this
1302directory if INSTALLDIRS is set to site (default).
8e07c86e 1303
864a5fa8 1304=item INST_ARCHLIB
8e07c86e 1305
864a5fa8 1306Same as INST_LIB for architecture dependent files.
8e07c86e 1307
864a5fa8 1308=item INST_EXE
8e07c86e 1309
864a5fa8 1310Directory, where executable scripts should be installed during
e05e23b1 1311'make'. Defaults to "./blib/bin", just to have a dummy location during
1312testing. make install will copy the files in INST_EXE to INSTALLBIN.
8e07c86e 1313
864a5fa8 1314=item INST_LIB
8e07c86e 1315
864a5fa8 1316Directory where we put library files of this extension while building
1317it.
8e07c86e 1318
864a5fa8 1319=item INST_MAN1DIR
8e07c86e 1320
864a5fa8 1321Directory to hold the man pages at 'make' time
8e07c86e 1322
864a5fa8 1323=item INST_MAN3DIR
8e07c86e 1324
864a5fa8 1325Directory to hold the man pages at 'make' time
8e07c86e 1326
864a5fa8 1327=item LDFROM
8e07c86e 1328
864a5fa8 1329defaults to "$(OBJECT)" and is used in the ld command to specify
1330what files to link/load from (also see dynamic_lib below for how to
1331specify ld flags)
8e07c86e 1332
864a5fa8 1333=item LIBPERL_A
8e07c86e 1334
864a5fa8 1335The filename of the perllibrary that will be used together with this
1336extension. Defaults to libperl.a.
8e07c86e 1337
1338=item LIBS
1339
1340An anonymous array of alternative library
1341specifications to be searched for (in order) until
864a5fa8 1342at least one library is found. E.g.
8e07c86e 1343
1344 'LIBS' => ["-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs"]
1345
1346Mind, that any element of the array
1347contains a complete set of arguments for the ld
1348command. So do not specify
1349
1350 'LIBS' => ["-ltcl", "-ltk", "-lX11"]
1351
1352See ODBM_File/Makefile.PL for an example, where an array is needed. If
1353you specify a scalar as in
1354
1355 'LIBS' => "-ltcl -ltk -lX11"
1356
1357MakeMaker will turn it into an array with one element.
1358
864a5fa8 1359=item LINKTYPE
8e07c86e 1360
e05e23b1 1361'static' or 'dynamic' (default unless usedl=undef in
1362config.sh). Should only be used to force static linking (also see
864a5fa8 1363linkext below).
8e07c86e 1364
864a5fa8 1365=item MAKEAPERL
8e07c86e 1366
864a5fa8 1367Boolean which tells MakeMaker, that it should include the rules to
1368make a perl. This is handled automatically as a switch by
1369MakeMaker. The user normally does not need it.
8e07c86e 1370
864a5fa8 1371=item MAKEFILE
8e07c86e 1372
864a5fa8 1373The name of the Makefile to be produced.
8e07c86e 1374
864a5fa8 1375=item MAN1PODS
8e07c86e 1376
864a5fa8 1377Hashref of pod-containing files. MakeMaker will default this to all
1378EXE_FILES files that include POD directives. The files listed
1379here will be converted to man pages and installed as was requested
1380at Configure time.
8e07c86e 1381
864a5fa8 1382=item MAN3PODS
8e07c86e 1383
864a5fa8 1384Hashref of .pm and .pod files. MakeMaker will default this to all
1385 .pod and any .pm files that include POD directives. The files listed
1386here will be converted to man pages and installed as was requested
1387at Configure time.
8e07c86e 1388
864a5fa8 1389=item MAP_TARGET
8e07c86e 1390
864a5fa8 1391If it is intended, that a new perl binary be produced, this variable
1392may hold a name for that binary. Defaults to perl
8e07c86e 1393
864a5fa8 1394=item MYEXTLIB
4633a7c4 1395
864a5fa8 1396If the extension links to a library that it builds set this to the
1397name of the library (see SDBM_File)
4633a7c4 1398
864a5fa8 1399=item NAME
8e07c86e 1400
864a5fa8 1401Perl module name for this extension (DBD::Oracle). This will default
1402to the directory name but should be explicitly defined in the
1403Makefile.PL.
8e07c86e 1404
864a5fa8 1405=item NEEDS_LINKING
8e07c86e 1406
864a5fa8 1407MakeMaker will figure out, if an extension contains linkable code
1408anywhere down the directory tree, and will set this variable
1409accordingly, but you can speed it up a very little bit, if you define
1410this boolean variable yourself.
8e07c86e 1411
e05e23b1 1412=item NOECHO
1413
1414Defaults the C<@>. By setting it to an empty string you can generate a
1415Makefile that echos all commands. Mainly used in debugging MakeMaker
1416itself.
1417
864a5fa8 1418=item NORECURS
8e07c86e 1419
e05e23b1 1420Boolean. Attribute to inhibit descending into subdirectories.
8e07c86e 1421
864a5fa8 1422=item OBJECT
8e07c86e 1423
864a5fa8 1424List of object files, defaults to '$(BASEEXT)$(OBJ_EXT)', but can be a long
1425string containing all object files, e.g. "tkpBind.o
1426tkpButton.o tkpCanvas.o"
8e07c86e 1427
864a5fa8 1428=item PERL
8e07c86e 1429
864a5fa8 1430Perl binary for tasks that can be done by miniperl
8e07c86e 1431
864a5fa8 1432=item PERLMAINCC
005c1a0e 1433
864a5fa8 1434The call to the program that is able to compile perlmain.c. Defaults
1435to $(CC).
005c1a0e 1436
864a5fa8 1437=item PERL_ARCHLIB
005c1a0e 1438
864a5fa8 1439Same as above for architecture dependent files
8e07c86e 1440
864a5fa8 1441=item PERL_LIB
8e07c86e 1442
864a5fa8 1443Directory containing the Perl library to use.
8e07c86e 1444
864a5fa8 1445=item PERL_SRC
8e07c86e 1446
864a5fa8 1447Directory containing the Perl source code (use of this should be
1448avoided, it may be undefined)
8e07c86e 1449
864a5fa8 1450=item PL_FILES
8e07c86e 1451
864a5fa8 1452Ref to hash of files to be processed as perl programs. MakeMaker
1453will default to any found *.PL file (except Makefile.PL) being keys
1454and the basename of the file being the value. E.g.
8e07c86e 1455
864a5fa8 1456 {'foobar.PL' => 'foobar'}
8e07c86e 1457
864a5fa8 1458The *.PL files are expected to produce output to the target files
1459themselves.
8e07c86e 1460
864a5fa8 1461=item PM
8e07c86e 1462
864a5fa8 1463Hashref of .pm files and *.pl files to be installed. e.g.
8e07c86e 1464
864a5fa8 1465 {'name_of_file.pm' => '$(INST_LIBDIR)/install_as.pm'}
8e07c86e 1466
864a5fa8 1467By default this will include *.pm and *.pl. If a lib directory
1468exists and is not listed in DIR (above) then any *.pm and *.pl files
1469it contains will also be included by default. Defining PM in the
1470Makefile.PL will override PMLIBDIRS.
8e07c86e 1471
864a5fa8 1472=item PMLIBDIRS
8e07c86e 1473
864a5fa8 1474Ref to array of subdirectories containing library files. Defaults to
1475[ 'lib', $(BASEEXT) ]. The directories will be scanned and any files
1476they contain will be installed in the corresponding location in the
1477library. A libscan() method can be used to alter the behaviour.
1478Defining PM in the Makefile.PL will override PMLIBDIRS.
8e07c86e 1479
864a5fa8 1480=item PREFIX
8e07c86e 1481
864a5fa8 1482Can be used to set the three INSTALL* attributes in one go (except for
e05e23b1 1483probably INSTALLMAN1DIR, if it is not below PREFIX according to
1484%Config). They will have PREFIX as a common directory node and will
1485branch from that node into lib/, lib/ARCHNAME or whatever Configure
1486decided at the build time of your perl (unless you override one of
1487them, of course).
8e07c86e 1488
864a5fa8 1489=item PREREQ
8e07c86e 1490
864a5fa8 1491Placeholder, not yet implemented. Will eventually be a hashref: Names
1492of modules that need to be available to run this extension (e.g. Fcntl
1493for SDBM_File) are the keys of the hash and the desired version is the
1494value. Needs further evaluation, should probably allow to define
1495prerequisites among header files, libraries, perl version, etc.
8e07c86e 1496
864a5fa8 1497=item SKIP
8e07c86e 1498
864a5fa8 1499Arryref. E.g. [qw(name1 name2)] skip (do not write) sections of the
1500Makefile
8e07c86e 1501
864a5fa8 1502=item TYPEMAPS
8e07c86e 1503
864a5fa8 1504Ref to array of typemap file names. Use this when the typemaps are
1505in some directory other than the current directory or when they are
1506not named B<typemap>. The last typemap in the list takes
1507precedence. A typemap in the current directory has highest
1508precedence, even if it isn't listed in TYPEMAPS. The default system
1509typemap has lowest precedence.
8e07c86e 1510
864a5fa8 1511=item VERSION
8e07c86e 1512
864a5fa8 1513Your version number for distributing the package. This defaults to
15140.1.
8e07c86e 1515
0d8023a2 1516=item VERSION_FROM
1517
1518Instead of specifying the VERSION in the Makefile.PL you can let
1519MakeMaker parse a file to determine the version number. The parsing
1520routine requires that the file named by VERSION_FROM contains one
1521single line to compute the version number. The first line in the file
1522that contains the regular expression
1523
1524 /(\$[\w:]*\bVERSION)\b.*=/
1525
1526will be evaluated with eval() and the value of the named variable
1527B<after> the eval() will be assigned to the VERSION attribute of the
1528MakeMaker object. The following lines will be parsed o.k.:
1529
1530 $VERSION = '1.00';
e05e23b1 1531 ( $VERSION ) = '$Revision: 1.174 $ ' =~ /\$Revision:\s+([^\s]+)/;
0d8023a2 1532 $FOO::VERSION = '1.10';
1533
1534but these will fail:
1535
1536 my $VERSION = '1.01';
1537 local $VERSION = '1.02';
1538 local $FOO::VERSION = '1.30';
1539
1540The file named in VERSION_FROM is added as a dependency to Makefile to
1541guarantee, that the Makefile contains the correct VERSION macro after
1542a change of the file.
1543
864a5fa8 1544=item XS
8e07c86e 1545
864a5fa8 1546Hashref of .xs files. MakeMaker will default this. e.g.
8e07c86e 1547
864a5fa8 1548 {'name_of_file.xs' => 'name_of_file.c'}
8e07c86e 1549
864a5fa8 1550The .c files will automatically be included in the list of files
1551deleted by a make clean.
4633a7c4 1552
864a5fa8 1553=item XSOPT
8e07c86e 1554
864a5fa8 1555String of options to pass to xsubpp. This might include C<-C++> or
1556C<-extern>. Do not include typemaps here; the TYPEMAP parameter exists for
1557that purpose.
8e07c86e 1558
864a5fa8 1559=item XSPROTOARG
4633a7c4 1560
4e68a208 1561May be set to an empty string, which is identical to C<-prototypes>, or
864a5fa8 1562C<-noprototypes>. See the xsubpp documentation for details. MakeMaker
4e68a208 1563defaults to the empty string.
1564
0d8023a2 1565=item XS_VERSION
1566
1567Your version number for the .xs file of this package. This defaults
1568to the value of the VERSION attribute.
1569
8e07c86e 1570=back
1571
1572=head2 Additional lowercase attributes
1573
1574can be used to pass parameters to the methods which implement that
1575part of the Makefile. These are not normally required:
1576
1577=over 2
1578
864a5fa8 1579=item clean
8e07c86e 1580
864a5fa8 1581 {FILES => "*.xyz foo"}
1582
c07a80fd 1583=item depend
1584
1585 {ANY_TARGET => ANY_DEPENDECY, ...}
1586
864a5fa8 1587=item dist
1588
1589 {TARFLAGS => 'cvfF', COMPRESS => 'gzip', SUFFIX => 'gz',
1590 SHAR => 'shar -m', DIST_CP => 'ln'}
1591
1592If you specify COMPRESS, then SUFFIX should also be altered, as it is
1593needed to tell make the target file of the compression. Setting
1594DIST_CP to ln can be useful, if you need to preserve the timestamps on
1595your files. DIST_CP can take the values 'cp', which copies the file,
1596'ln', which links the file, and 'best' which copies symbolic links and
1597links the rest. Default is 'best'.
1598
1599=item dynamic_lib
1600
0d8023a2 1601 {ARMAYBE => 'ar', OTHERLDFLAGS => '...', INST_DYNAMIC_DEP => '...'}
8e07c86e 1602
1603=item installpm
1604
1605 {SPLITLIB => '$(INST_LIB)' (default) or '$(INST_ARCHLIB)'}
1606
1607=item linkext
1608
1609 {LINKTYPE => 'static', 'dynamic' or ''}
1610
864a5fa8 1611NB: Extensions that have nothing but *.pm files had to say
8e07c86e 1612
1613 {LINKTYPE => ''}
1614
864a5fa8 1615with Pre-5.0 MakeMakers. Since version 5.00 of MakeMaker such a line
1616can be deleted safely. MakeMaker recognizes, when there's nothing to
1617be linked.
8e07c86e 1618
864a5fa8 1619=item macro
8e07c86e 1620
864a5fa8 1621 {ANY_MACRO => ANY_VALUE, ...}
8e07c86e 1622
1623=item realclean
1624
1625 {FILES => '$(INST_ARCHAUTODIR)/*.xyz'}
1626
8e07c86e 1627=item tool_autosplit
1628
1629 {MAXLEN =E<gt> 8}
005c1a0e 1630
1631=back
1632
8e07c86e 1633=cut
1634
1635# bug in pod2html, so leave the =back
1636
1637# Don't delete this cut, MM depends on it!
1638
005c1a0e 1639=head2 Overriding MakeMaker Methods
1640
1641If you cannot achieve the desired Makefile behaviour by specifying
1642attributes you may define private subroutines in the Makefile.PL.
1643Each subroutines returns the text it wishes to have written to
1644the Makefile. To override a section of the Makefile you can
1645either say:
1646
1647 sub MY::c_o { "new literal text" }
1648
1649or you can edit the default by saying something like:
1650
8e07c86e 1651 sub MY::c_o {
1652 my $self = shift;
1653 local *c_o;
1654 $_=$self->MM::c_o;
1655 s/old text/new text/;
1656 $_;
1657 }
1658
1659Both methods above are available for backwards compatibility with
1660older Makefile.PLs.
005c1a0e 1661
1662If you still need a different solution, try to develop another
1663subroutine, that fits your needs and submit the diffs to
8e07c86e 1664F<perl5-porters@nicoh.com> or F<comp.lang.perl.misc> as appropriate.
005c1a0e 1665
1666=head2 Distribution Support
1667
1668For authors of extensions MakeMaker provides several Makefile
1669targets. Most of the support comes from the ExtUtils::Manifest module,
1670where additional documentation can be found.
1671
1672=over 4
1673
1674=item make distcheck
8e07c86e 1675
005c1a0e 1676reports which files are below the build directory but not in the
1677MANIFEST file and vice versa. (See ExtUtils::Manifest::fullcheck() for
1678details)
1679
4633a7c4 1680=item make skipcheck
1681
1682reports which files are skipped due to the entries in the
1683C<MANIFEST.SKIP> file (See ExtUtils::Manifest::skipcheck() for
1684details)
1685
005c1a0e 1686=item make distclean
8e07c86e 1687
005c1a0e 1688does a realclean first and then the distcheck. Note that this is not
1689needed to build a new distribution as long as you are sure, that the
1690MANIFEST file is ok.
1691
1692=item make manifest
8e07c86e 1693
005c1a0e 1694rewrites the MANIFEST file, adding all remaining files found (See
1695ExtUtils::Manifest::mkmanifest() for details)
1696
1697=item make distdir
8e07c86e 1698
005c1a0e 1699Copies all the files that are in the MANIFEST file to a newly created
1700directory with the name C<$(DISTNAME)-$(VERSION)>. If that directory
1701exists, it will be removed first.
1702
8e07c86e 1703=item make disttest
1704
1705Makes a distdir first, and runs a C<perl Makefile.PL>, a make, and
4633a7c4 1706a make test in that directory.
8e07c86e 1707
005c1a0e 1708=item make tardist
8e07c86e 1709
005c1a0e 1710First does a command $(PREOP) which defaults to a null command. Does a
1711distdir next and runs C<tar> on that directory into a tarfile. Then
1712deletes the distdir. Finishes with a command $(POSTOP) which defaults
1713to a null command.
1714
1715=item make dist
8e07c86e 1716
005c1a0e 1717Defaults to $(DIST_DEFAULT) which in turn defaults to tardist.
1718
1719=item make uutardist
8e07c86e 1720
005c1a0e 1721Runs a tardist first and uuencodes the tarfile.
1722
1723=item make shdist
8e07c86e 1724
005c1a0e 1725First does a command $(PREOP) which defaults to a null command. Does a
1726distdir next and runs C<shar> on that directory into a sharfile. Then
1727deletes the distdir. Finishes with a command $(POSTOP) which defaults
1728to a null command. Note: For shdist to work properly a C<shar>
1729program that can handle directories is mandatory.
1730
1731=item make ci
8e07c86e 1732
1733Does a $(CI) and a $(RCS_LABEL) on all files in the MANIFEST file.
1734
1735=back
005c1a0e 1736
1737Customization of the dist targets can be done by specifying a hash
1738reference to the dist attribute of the WriteMakefile call. The
1739following parameters are recognized:
1740
8e07c86e 1741 CI ('ci -u')
005c1a0e 1742 COMPRESS ('compress')
005c1a0e 1743 POSTOP ('@ :')
8e07c86e 1744 PREOP ('@ :')
1745 RCS_LABEL ('rcs -q -Nv$(VERSION_SYM):')
1746 SHAR ('shar')
1747 SUFFIX ('Z')
1748 TAR ('tar')
1749 TARFLAGS ('cvf')
005c1a0e 1750
1751An example:
1752
1753 WriteMakefile( 'dist' => { COMPRESS=>"gzip", SUFFIX=>"gz" })
1754
005c1a0e 1755
e05e23b1 1756=head1 AUTHORS
fed7345c 1757
1758Andy Dougherty F<E<lt>doughera@lafcol.lafayette.eduE<gt>>, Andreas
8e07c86e 1759KE<ouml>nig F<E<lt>A.Koenig@franz.ww.TU-Berlin.DEE<gt>>, Tim Bunce
fed7345c 1760F<E<lt>Tim.Bunce@ig.co.ukE<gt>>. VMS support by Charles Bailey
e05e23b1 1761F<E<lt>bailey@HMIVAX.HUMGEN.UPENN.EDUE<gt>>. OS/2 support by Ilya
1762Zakharevich F<E<lt>ilya@math.ohio-state.eduE<gt>>. Contact the
1763makemaker mailing list C<mailto:makemaker@franz.ww.tu-berlin.de>, if
1764you have any questions.
fed7345c 1765
1766=head1 MODIFICATION HISTORY
1767
8e07c86e 1768For a more complete documentation see the file Changes in the
1769MakeMaker distribution package.
e50aee73 1770
005c1a0e 1771=head1 TODO
f06db76b 1772
8e07c86e 1773See the file Todo in the MakeMaker distribution package.
005c1a0e 1774
1775=cut