Storable.thaw segv on blessed reference to overloaded object
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MakeMaker.pm
CommitLineData
2e65e370 1# $Id: /local/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm 66493 2008-09-27T21:35:25.560547Z schwern $
e05e23b1 2package ExtUtils::MakeMaker;
3
a592ba15 4use strict;
5
6BEGIN {require 5.006;}
57b1a898 7
8e07c86e 8require Exporter;
7292dc67 9use ExtUtils::MakeMaker::Config;
3b03c0f3 10use Carp ();
dedf98bc 11use File::Path;
e05e23b1 12
a592ba15 13our $Verbose = 0; # exported
14our @Parent; # needs to be localized
15our @Get_from_Config; # referenced by MM_Unix
2e65e370 16our @MM_Sections;
17our @Overridable;
a592ba15 18my @Prepend_parent;
19my %Recognized_Att_Keys;
005c1a0e 20
2e65e370 21our $VERSION = '6.46';
22our ($Revision) = q$Revision: 66493 $ =~ /Revision:\s+(\S+)/;
a592ba15 23our $Filename = __FILE__; # referenced outside MakeMaker
7292dc67 24
a592ba15 25our @ISA = qw(Exporter);
26our @EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt);
27our @EXPORT_OK = qw($VERSION &neatvalue &mkbootstrap &mksymlists
28 &WriteEmptyMakefile);
42793c05 29
f6d6199c 30# These will go away once the last of the Win32 & VMS specific code is
31# purged.
5e9e174b 32my $Is_VMS = $^O eq 'VMS';
5e9e174b 33my $Is_Win32 = $^O eq 'MSWin32';
3b03c0f3 34
9ab29e2b 35full_setup();
864a5fa8 36
f6d6199c 37require ExtUtils::MM; # Things like CPAN assume loading ExtUtils::MakeMaker
38 # will give them MM.
e05e23b1 39
45bc4d3a 40require ExtUtils::MY; # XXX pre-5.8 versions of ExtUtils::Embed expect
41 # loading ExtUtils::MakeMaker will give them MY.
2e65e370 42 # This will go when Embed is its own CPAN module.
45bc4d3a 43
f1387719 44
3b03c0f3 45sub WriteMakefile {
46 Carp::croak "WriteMakefile: Need even number of args" if @_ % 2;
f1387719 47
f6d6199c 48 require ExtUtils::MY;
3b03c0f3 49 my %att = @_;
69ff8adf 50
51 _verify_att(\%att);
52
e0678a30 53 my $mm = MM->new(\%att);
54 $mm->flush;
55
56 return $mm;
3b03c0f3 57}
58
69ff8adf 59
d5d4ec93 60# Basic signatures of the attributes WriteMakefile takes. Each is the
61# reference type. Empty value indicate it takes a non-reference
62# scalar.
479d2113 63my %Att_Sigs;
64my %Special_Sigs = (
bfdac1b8 65 C => 'ARRAY',
66 CONFIG => 'ARRAY',
67 CONFIGURE => 'CODE',
68 DIR => 'ARRAY',
69 DL_FUNCS => 'HASH',
70 DL_VARS => 'ARRAY',
71 EXCLUDE_EXT => 'ARRAY',
72 EXE_FILES => 'ARRAY',
73 FUNCLIST => 'ARRAY',
74 H => 'ARRAY',
75 IMPORTS => 'HASH',
76 INCLUDE_EXT => 'ARRAY',
77 LIBS => ['ARRAY',''],
78 MAN1PODS => 'HASH',
79 MAN3PODS => 'HASH',
2e65e370 80 META_ADD => 'HASH',
81 META_MERGE => 'HASH',
bfdac1b8 82 PL_FILES => 'HASH',
83 PM => 'HASH',
84 PMLIBDIRS => 'ARRAY',
85 PMLIBPARENTDIRS => 'ARRAY',
86 PREREQ_PM => 'HASH',
87 SKIP => 'ARRAY',
88 TYPEMAPS => 'ARRAY',
89 XS => 'HASH',
90 VERSION => ['version',''],
479d2113 91 _KEEP_AFTER_FLUSH => '',
69ff8adf 92
bfdac1b8 93 clean => 'HASH',
94 depend => 'HASH',
95 dist => 'HASH',
96 dynamic_lib=> 'HASH',
97 linkext => 'HASH',
98 macro => 'HASH',
99 postamble => 'HASH',
100 realclean => 'HASH',
101 test => 'HASH',
102 tool_autosplit => 'HASH',
69ff8adf 103);
104
479d2113 105@Att_Sigs{keys %Recognized_Att_Keys} = ('') x keys %Recognized_Att_Keys;
106@Att_Sigs{keys %Special_Sigs} = values %Special_Sigs;
107
69ff8adf 108
109sub _verify_att {
110 my($att) = @_;
111
112 while( my($key, $val) = each %$att ) {
113 my $sig = $Att_Sigs{$key};
d5d4ec93 114 unless( defined $sig ) {
115 warn "WARNING: $key is not a known parameter.\n";
116 next;
117 }
118
119 my @sigs = ref $sig ? @$sig : $sig;
bfdac1b8 120 my $given = ref $val;
121 unless( grep { $given eq $_ || ($_ && eval{$val->isa($_)}) } @sigs ) {
122 my $takes = join " or ", map { _format_att($_) } @sigs;
123
124 my $has = _format_att($given);
69ff8adf 125 warn "WARNING: $key takes a $takes not a $has.\n".
126 " Please inform the author.\n";
69ff8adf 127 }
128 }
129}
130
bfdac1b8 131
132sub _format_att {
133 my $given = shift;
134
135 return $given eq '' ? "string/number"
136 : uc $given eq $given ? "$given reference"
137 : "$given object"
138 ;
139}
140
141
a592ba15 142sub prompt ($;$) { ## no critic
479d2113 143 my($mess, $def) = @_;
e0678a30 144 Carp::confess("prompt function called without an argument")
145 unless defined $mess;
479d2113 146
147 my $isa_tty = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ;
148
f1387719 149 my $dispdef = defined $def ? "[$def] " : " ";
150 $def = defined $def ? $def : "";
479d2113 151
13bc20ff 152 local $|=1;
f6d6199c 153 local $\;
13bc20ff 154 print "$mess $dispdef";
479d2113 155
156 my $ans;
157 if ($ENV{PERL_MM_USE_DEFAULT} || (!$isa_tty && eof STDIN)) {
158 print "$def\n";
159 }
160 else {
f6d6199c 161 $ans = <STDIN>;
162 if( defined $ans ) {
163 chomp $ans;
164 }
165 else { # user hit ctrl-D
166 print "\n";
167 }
168 }
479d2113 169
f6d6199c 170 return (!defined $ans || $ans eq '') ? $def : $ans;
3b03c0f3 171}
172
e05e23b1 173sub eval_in_subdirs {
174 my($self) = @_;
a8112c7f 175 use Cwd qw(cwd abs_path);
f582e489 176 my $pwd = cwd() || die "Can't figure out your cwd!";
177
3593a55e 178 local @INC = map eval {abs_path($_) if -e} || $_, @INC;
f6d6199c 179 push @INC, '.'; # '.' has to always be at the end of @INC
e05e23b1 180
5e9e174b 181 foreach my $dir (@{$self->{DIR}}){
f6d6199c 182 my($abs) = $self->catdir($pwd,$dir);
a7d1454b 183 eval { $self->eval_in_x($abs); };
184 last if $@;
e05e23b1 185 }
e05e23b1 186 chdir $pwd;
a7d1454b 187 die $@ if $@;
864a5fa8 188}
42793c05 189
e05e23b1 190sub eval_in_x {
191 my($self,$dir) = @_;
6626a13a 192 chdir $dir or Carp::carp("Couldn't change to directory $dir: $!");
5e9e174b 193
f6d6199c 194 {
195 package main;
196 do './Makefile.PL';
197 };
f1387719 198 if ($@) {
f6d6199c 199# if ($@ =~ /prerequisites/) {
200# die "MakeMaker WARNING: $@";
201# } else {
202# warn "WARNING from evaluation of $dir/Makefile.PL: $@";
203# }
45bc4d3a 204 die "ERROR from evaluation of $dir/Makefile.PL: $@";
f1387719 205 }
e05e23b1 206}
207
479d2113 208
209# package name for the classes into which the first object will be blessed
210my $PACKNAME = 'PACK000';
211
e05e23b1 212sub full_setup {
213 $Verbose ||= 0;
3b03c0f3 214
5e9e174b 215 my @attrib_help = qw/
3b03c0f3 216
762efda7 217 AUTHOR ABSTRACT ABSTRACT_FROM BINARY_LOCATION
218 C CAPI CCFLAGS CONFIG CONFIGURE DEFINE DIR DISTNAME DL_FUNCS DL_VARS
2e65e370 219 EXCLUDE_EXT EXE_FILES FIRST_MAKEFILE
75e2e551 220 FULLPERL FULLPERLRUN FULLPERLRUNINST
221 FUNCLIST H IMPORTS
431b0fc4 222
45bc4d3a 223 INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB INST_MAN1DIR INST_MAN3DIR
5c161494 224 INSTALLDIRS
2977d345 225 DESTDIR PREFIX INSTALL_BASE
479d2113 226 PERLPREFIX SITEPREFIX VENDORPREFIX
5c161494 227 INSTALLPRIVLIB INSTALLSITELIB INSTALLVENDORLIB
228 INSTALLARCHLIB INSTALLSITEARCH INSTALLVENDORARCH
45bc4d3a 229 INSTALLBIN INSTALLSITEBIN INSTALLVENDORBIN
230 INSTALLMAN1DIR INSTALLMAN3DIR
231 INSTALLSITEMAN1DIR INSTALLSITEMAN3DIR
232 INSTALLVENDORMAN1DIR INSTALLVENDORMAN3DIR
002b9267 233 INSTALLSCRIPT INSTALLSITESCRIPT INSTALLVENDORSCRIPT
5c161494 234 PERL_LIB PERL_ARCHLIB
235 SITELIBEXP SITEARCHEXP
431b0fc4 236
2977d345 237 INC INCLUDE_EXT LDFROM LIB LIBPERL_A LIBS LICENSE
2e65e370 238 LINKTYPE MAKE MAKEAPERL MAKEFILE MAKEFILE_OLD MAN1PODS MAN3PODS MAP_TARGET
239 META_ADD META_MERGE
2530b651 240 MYEXTLIB NAME NEEDS_LINKING NOECHO NO_META NORECURS NO_VC OBJECT OPTIMIZE
431b0fc4 241 PERL_MALLOC_OK PERL PERLMAINCC PERLRUN PERLRUNINST PERL_CORE
5c161494 242 PERL_SRC PERM_RW PERM_RWX
2977d345 243 PL_FILES PM PM_FILTER PMLIBDIRS PMLIBPARENTDIRS POLLUTE PPM_INSTALL_EXEC
5c161494 244 PPM_INSTALL_SCRIPT PREREQ_FATAL PREREQ_PM PREREQ_PRINT PRINT_PREREQ
bb68fe9e 245 SIGN SKIP TYPEMAPS VERSION VERSION_FROM XS XSOPT XSPROTOARG
f1387719 246 XS_VERSION clean depend dist dynamic_lib linkext macro realclean
762efda7 247 tool_autosplit
431b0fc4 248
084592ab 249 MACPERL_SRC MACPERL_LIB MACLIBS_68K MACLIBS_PPC MACLIBS_SC MACLIBS_MRC
250 MACLIBS_ALL_68K MACLIBS_ALL_PPC MACLIBS_SHARED
f6d6199c 251 /;
3b03c0f3 252
875fa795 253 # IMPORTS is used under OS/2 and Win32
f1387719 254
255 # @Overridable is close to @MM_Sections but not identical. The
256 # order is important. Many subroutines declare macros. These
257 # depend on each other. Let's try to collect the macros up front,
258 # then pasthru, then the rules.
259
260 # MM_Sections are the sections we have to call explicitly
261 # in Overridable we have subroutines that are used indirectly
3b03c0f3 262
e05e23b1 263
264 @MM_Sections =
f6d6199c 265 qw(
3b03c0f3 266
479d2113 267 post_initialize const_config constants platform_constants
268 tool_autosplit tool_xsubpp tools_other
269
270 makemakerdflt
271
272 dist macro depend cflags const_loadlibs const_cccmd
f1387719 273 post_constants
274
275 pasthru
276
479d2113 277 special_targets
278 c_o xs_c xs_o
af7522e5 279 top_targets blibdirs linkext dlsyms dynamic dynamic_bs
f6d6199c 280 dynamic_lib static static_lib manifypods processPL
cae6c631 281 installbin subdirs
479d2113 282 clean_subdirs clean realclean_subdirs realclean
7292dc67 283 metafile signature
284 dist_basics dist_core distdir dist_test dist_ci distmeta distsignature
8f993c78 285 install force perldepend makefile staticmake test ppd
3b03c0f3 286
f6d6199c 287 ); # loses section ordering
e05e23b1 288
3b03c0f3 289 @Overridable = @MM_Sections;
f1387719 290 push @Overridable, qw[
291
af7522e5 292 libscan makeaperl needs_linking perm_rw perm_rwx
2977d345 293 subdir_x test_via_harness test_via_script
294
295 init_VERSION init_dist init_INST init_INSTALL init_DEST init_dirscan
296 init_PM init_MANPODS init_xs init_PERL init_DIRFILESEP init_linker
f6d6199c 297 ];
3b03c0f3 298
f1387719 299 push @MM_Sections, qw[
3b03c0f3 300
f1387719 301 pm_to_blib selfdocument
302
f6d6199c 303 ];
f1387719 304
305 # Postamble needs to be the last that was always the case
306 push @MM_Sections, "postamble";
307 push @Overridable, "postamble";
e05e23b1 308
309 # All sections are valid keys.
3b03c0f3 310 @Recognized_Att_Keys{@MM_Sections} = (1) x @MM_Sections;
e05e23b1 311
312 # we will use all these variables in the Makefile
313 @Get_from_Config =
f6d6199c 314 qw(
2977d345 315 ar cc cccdlflags ccdlflags dlext dlsrc exe_ext full_ar ld
316 lddlflags ldflags libc lib_ext obj_ext osname osvers ranlib
317 sitelibexp sitearchexp so
f6d6199c 318 );
e05e23b1 319
479d2113 320 # 5.5.3 doesn't have any concept of vendor libs
321 push @Get_from_Config, qw( vendorarchexp vendorlibexp ) if $] >= 5.006;
322
5e9e174b 323 foreach my $item (@attrib_help){
f6d6199c 324 $Recognized_Att_Keys{$item} = 1;
e05e23b1 325 }
5e9e174b 326 foreach my $item (@Get_from_Config) {
f6d6199c 327 $Recognized_Att_Keys{uc $item} = $Config{$item};
328 print "Attribute '\U$item\E' => '$Config{$item}'\n"
329 if ($Verbose >= 2);
e05e23b1 330 }
331
332 #
3b03c0f3 333 # When we eval a Makefile.PL in a subdirectory, that one will ask
334 # us (the parent) for the values and will prepend "..", so that
335 # all files to be installed end up below OUR ./blib
e05e23b1 336 #
e0678a30 337 @Prepend_parent = qw(
338 INST_BIN INST_LIB INST_ARCHLIB INST_SCRIPT
f6d6199c 339 MAP_TARGET INST_MAN1DIR INST_MAN3DIR PERL_SRC
340 PERL FULLPERL
341 );
e05e23b1 342}
42793c05 343
8e07c86e 344sub writeMakefile {
345 die <<END;
232e078e 346
8e07c86e 347The extension you are trying to build apparently is rather old and
348most probably outdated. We detect that from the fact, that a
349subroutine "writeMakefile" is called, and this subroutine is not
350supported anymore since about October 1994.
40000a8c 351
4633a7c4 352Please contact the author or look into CPAN (details about CPAN can be
353found in the FAQ and at http:/www.perl.com) for a more recent version
354of the extension. If you're really desperate, you can try to change
355the subroutine name from writeMakefile to WriteMakefile and rerun
356'perl Makefile.PL', but you're most probably left alone, when you do
357so.
42793c05 358
8e07c86e 359The MakeMaker team
1aef975c 360
42793c05 361END
8e07c86e 362}
42793c05 363
f6d6199c 364sub new {
8e07c86e 365 my($class,$self) = @_;
366 my($key);
42793c05 367
479d2113 368 # Store the original args passed to WriteMakefile()
369 foreach my $k (keys %$self) {
370 $self->{ARGS}{$k} = $self->{$k};
371 }
372
88d69b28 373 if ("@ARGV" =~ /\bPREREQ_PRINT\b/) {
f6d6199c 374 require Data::Dumper;
88d69b28 375 print Data::Dumper->Dump([$self->{PREREQ_PM}], [qw(PREREQ_PM)]);
919b8535 376 exit 0;
f6d6199c 377 }
88d69b28 378
379 # PRINT_PREREQ is RedHatism.
380 if ("@ARGV" =~ /\bPRINT_PREREQ\b/) {
2c91f887 381 print join(" ", map { "perl($_)>=$self->{PREREQ_PM}->{$_} " }
382 sort keys %{$self->{PREREQ_PM}}), "\n";
f6d6199c 383 exit 0;
88d69b28 384 }
385
e05e23b1 386 print STDOUT "MakeMaker (v$VERSION)\n" if $Verbose;
8e07c86e 387 if (-f "MANIFEST" && ! -f "Makefile"){
f6d6199c 388 check_manifest();
1aef975c 389 }
42793c05 390
8e07c86e 391 $self = {} unless (defined $self);
005c1a0e 392
864a5fa8 393 check_hints($self);
4633a7c4 394
c3be8c6e 395 my %configure_att; # record &{$self->{CONFIGURE}} attributes
8e07c86e 396 my(%initial_att) = %$self; # record initial attributes
005c1a0e 397
a4260cbc 398 my(%unsatisfied) = ();
5e9e174b 399 foreach my $prereq (sort keys %{$self->{PREREQ_PM}}) {
479d2113 400 # 5.8.0 has a bug with require Foo::Bar alone in an eval, so an
401 # extra statement is a workaround.
a7d1454b 402 my $file = "$prereq.pm";
403 $file =~ s{::}{/}g;
404 eval { require $file };
f6d6199c 405
e0678a30 406 my $pr_version = $prereq->VERSION || 0;
407
479d2113 408 # convert X.Y_Z alpha version #s to X.YZ for easier comparisons
409 $pr_version =~ s/(\d+)\.(\d+)_(\d+)/$1.$2$3/;
410
f6d6199c 411 if ($@) {
412 warn sprintf "Warning: prerequisite %s %s not found.\n",
413 $prereq, $self->{PREREQ_PM}{$prereq}
414 unless $self->{PREREQ_FATAL};
415 $unsatisfied{$prereq} = 'not installed';
e0678a30 416 } elsif ($pr_version < $self->{PREREQ_PM}->{$prereq} ){
45bc4d3a 417 warn sprintf "Warning: prerequisite %s %s not found. We have %s.\n",
f6d6199c 418 $prereq, $self->{PREREQ_PM}{$prereq},
e0678a30 419 ($pr_version || 'unknown version')
f6d6199c 420 unless $self->{PREREQ_FATAL};
421 $unsatisfied{$prereq} = $self->{PREREQ_PM}->{$prereq} ?
422 $self->{PREREQ_PM}->{$prereq} : 'unknown version' ;
423 }
f1387719 424 }
6d6be53e 425
426 if (%unsatisfied && $self->{PREREQ_FATAL}){
427 my $failedprereqs = join "\n", map {" $_ $unsatisfied{$_}"}
428 sort { $a cmp $b } keys %unsatisfied;
429 die <<"END";
430MakeMaker FATAL: prerequisites not found.
431$failedprereqs
432
433Please install these modules first and rerun 'perl Makefile.PL'.
434END
435 }
436
8e07c86e 437 if (defined $self->{CONFIGURE}) {
f6d6199c 438 if (ref $self->{CONFIGURE} eq 'CODE') {
439 %configure_att = %{&{$self->{CONFIGURE}}};
440 $self = { %$self, %configure_att };
441 } else {
442 Carp::croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n";
443 }
005c1a0e 444 }
a0d0e21e 445
8e07c86e 446 # This is for old Makefiles written pre 5.00, will go away
447 if ( Carp::longmess("") =~ /runsubdirpl/s ){
f6d6199c 448 Carp::carp("WARNING: Please rerun 'perl Makefile.PL' to regenerate your Makefiles\n");
8e07c86e 449 }
5d94fbed 450
ccd13d1e 451 my $newclass = ++$PACKNAME;
f6d6199c 452 local @Parent = @Parent; # Protect against non-local exits
8e07c86e 453 {
f6d6199c 454 print "Blessing Object into class [$newclass]\n" if $Verbose>=2;
455 mv_all_methods("MY",$newclass);
456 bless $self, $newclass;
457 push @Parent, $self;
458 require ExtUtils::MY;
a592ba15 459
460 no strict 'refs'; ## no critic;
f6d6199c 461 @{"$newclass\:\:ISA"} = 'MM';
8e07c86e 462 }
5d94fbed 463
e05e23b1 464 if (defined $Parent[-2]){
f6d6199c 465 $self->{PARENT} = $Parent[-2];
a592ba15 466 for my $key (@Prepend_parent) {
f6d6199c 467 next unless defined $self->{PARENT}{$key};
531e2ba1 468
469 # Don't stomp on WriteMakefile() args.
46442182 470 next if defined $self->{ARGS}{$key} and
471 $self->{ARGS}{$key} eq $self->{$key};
472
473 $self->{$key} = $self->{PARENT}{$key};
531e2ba1 474
479d2113 475 unless ($Is_VMS && $key =~ /PERL$/) {
f6d6199c 476 $self->{$key} = $self->catdir("..",$self->{$key})
477 unless $self->file_name_is_absolute($self->{$key});
478 } else {
479 # PERL or FULLPERL will be a command verb or even a
480 # command with an argument instead of a full file
481 # specification under VMS. So, don't turn the command
482 # into a filespec, but do add a level to the path of
483 # the argument if not already absolute.
484 my @cmd = split /\s+/, $self->{$key};
485 $cmd[1] = $self->catfile('[-]',$cmd[1])
486 unless (@cmd < 2) || $self->file_name_is_absolute($cmd[1]);
487 $self->{$key} = join(' ', @cmd);
488 }
489 }
490 if ($self->{PARENT}) {
491 $self->{PARENT}->{CHILDREN}->{$newclass} = $self;
85f2ef06 492 foreach my $opt (qw(POLLUTE PERL_CORE LINKTYPE)) {
f6d6199c 493 if (exists $self->{PARENT}->{$opt}
494 and not exists $self->{$opt})
495 {
496 # inherit, but only if already unspecified
497 $self->{$opt} = $self->{PARENT}->{$opt};
498 }
499 }
500 }
501 my @fm = grep /^FIRST_MAKEFILE=/, @ARGV;
502 parse_args($self,@fm) if @fm;
8e07c86e 503 } else {
f6d6199c 504 parse_args($self,split(' ', $ENV{PERL_MM_OPT} || ''),@ARGV);
8e07c86e 505 }
bfdac1b8 506
a0d0e21e 507
8e07c86e 508 $self->{NAME} ||= $self->guess_name;
a0d0e21e 509
8e07c86e 510 ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g;
a0d0e21e 511
2977d345 512 $self->init_MAKE;
479d2113 513 $self->init_main;
514 $self->init_VERSION;
515 $self->init_dist;
516 $self->init_INST;
517 $self->init_INSTALL;
531e2ba1 518 $self->init_DEST;
479d2113 519 $self->init_dirscan;
2977d345 520 $self->init_PM;
521 $self->init_MANPODS;
479d2113 522 $self->init_xs;
523 $self->init_PERL;
524 $self->init_DIRFILESEP;
525 $self->init_linker;
2977d345 526 $self->init_ABSTRACT;
8e07c86e 527
0d8023a2 528 if (! $self->{PERL_SRC} ) {
f6d6199c 529 require VMS::Filespec if $Is_VMS;
530 my($pthinks) = $self->canonpath($INC{'Config.pm'});
531 my($cthinks) = $self->catfile($Config{'archlibexp'},'Config.pm');
532 $pthinks = VMS::Filespec::vmsify($pthinks) if $Is_VMS;
533 if ($pthinks ne $cthinks &&
534 !($Is_Win32 and lc($pthinks) eq lc($cthinks))) {
3e3baf6d 535 print "Have $pthinks expected $cthinks\n";
f6d6199c 536 if ($Is_Win32) {
537 $pthinks =~ s![/\\]Config\.pm$!!i; $pthinks =~ s!.*[/\\]!!;
538 }
539 else {
540 $pthinks =~ s!/Config\.pm$!!; $pthinks =~ s!.*/!!;
541 }
542 print STDOUT <<END unless $self->{UNINSTALLED_PERL};
543Your perl and your Config.pm seem to have different ideas about the
544architecture they are running on.
8e07c86e 545Perl thinks: [$pthinks]
e05e23b1 546Config says: [$Config{archname}]
f6d6199c 547This may or may not cause problems. Please check your installation of perl
548if you have problems building this extension.
005c1a0e 549END
f6d6199c 550 }
005c1a0e 551 }
552
8e07c86e 553 $self->init_others();
479d2113 554 $self->init_platform();
e0678a30 555 $self->init_PERM();
6071deed 556 my($argv) = neatvalue(\@ARGV);
557 $argv =~ s/^\[/(/;
558 $argv =~ s/\]$/)/;
75f92628 559
8e07c86e 560 push @{$self->{RESULT}}, <<END;
561# This Makefile is for the $self->{NAME} extension to perl.
562#
e05e23b1 563# It was generated automatically by MakeMaker version
564# $VERSION (Revision: $Revision) from the contents of
565# Makefile.PL. Don't edit this file, edit Makefile.PL instead.
8e07c86e 566#
f6d6199c 567# ANY CHANGES MADE HERE WILL BE LOST!
8e07c86e 568#
6071deed 569# MakeMaker ARGV: $argv
570#
8e07c86e 571# MakeMaker Parameters:
572END
a0d0e21e 573
5e9e174b 574 foreach my $key (sort keys %initial_att){
479d2113 575 next if $key eq 'ARGS';
576
f6d6199c 577 my($v) = neatvalue($initial_att{$key});
578 $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
579 $v =~ tr/\n/ /s;
580 push @{$self->{RESULT}}, "# $key => $v";
42793c05 581 }
c3be8c6e 582 undef %initial_att; # free memory
583
584 if (defined $self->{CONFIGURE}) {
585 push @{$self->{RESULT}}, <<END;
586
587# MakeMaker 'CONFIGURE' Parameters:
588END
589 if (scalar(keys %configure_att) > 0) {
5e9e174b 590 foreach my $key (sort keys %configure_att){
479d2113 591 next if $key eq 'ARGS';
c3be8c6e 592 my($v) = neatvalue($configure_att{$key});
593 $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
594 $v =~ tr/\n/ /s;
595 push @{$self->{RESULT}}, "# $key => $v";
596 }
597 }
598 else
599 {
600 push @{$self->{RESULT}}, "# no values returned";
601 }
602 undef %configure_att; # free memory
603 }
a0d0e21e 604
8e07c86e 605 # turn the SKIP array into a SKIPHASH hash
a592ba15 606 for my $skip (@{$self->{SKIP} || []}) {
f6d6199c 607 $self->{SKIPHASH}{$skip} = 1;
8e07c86e 608 }
3b03c0f3 609 delete $self->{SKIP}; # free memory
610
611 if ($self->{PARENT}) {
479d2113 612 for (qw/install dist dist_basics dist_core distdir dist_test dist_ci/) {
f6d6199c 613 $self->{SKIPHASH}{$_} = 1;
614 }
3b03c0f3 615 }
42793c05 616
8e07c86e 617 # We run all the subdirectories now. They don't have much to query
618 # from the parent, but the parent has to query them: if they need linking!
8e07c86e 619 unless ($self->{NORECURS}) {
f6d6199c 620 $self->eval_in_subdirs if @{$self->{DIR}};
42793c05 621 }
a0d0e21e 622
5e9e174b 623 foreach my $section ( @MM_Sections ){
479d2113 624 # Support for new foo_target() methods.
625 my $method = $section;
626 $method .= '_target' unless $self->can($method);
627
f6d6199c 628 print "Processing Makefile '$section' section\n" if ($Verbose >= 2);
629 my($skipit) = $self->skipcheck($section);
630 if ($skipit){
631 push @{$self->{RESULT}}, "\n# --- MakeMaker $section section $skipit.";
632 } else {
633 my(%a) = %{$self->{$section} || {}};
634 push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:";
635 push @{$self->{RESULT}}, "# " . join ", ", %a if $Verbose && %a;
6d6be53e 636 push @{$self->{RESULT}}, $self->maketext_filter(
637 $self->$method( %a )
638 );
f6d6199c 639 }
232e078e 640 }
8e07c86e 641
e05e23b1 642 push @{$self->{RESULT}}, "\n# End.";
8e07c86e 643
e05e23b1 644 $self;
232e078e 645}
646
1b171b8d 647sub WriteEmptyMakefile {
1e65eb70 648 Carp::croak "WriteEmptyMakefile: Need an even number of args" if @_ % 2;
a8112c7f 649
650 my %att = @_;
651 my $self = MM->new(\%att);
bfdac1b8 652
653 my $new = $self->{MAKEFILE};
1151960e 654 my $old = $self->{MAKEFILE_OLD};
655 if (-f $old) {
bfdac1b8 656 _unlink($old) or warn "unlink $old: $!";
479d2113 657 }
1151960e 658 if ( -f $new ) {
659 _rename($new, $old) or warn "rename $new => $old: $!"
a8112c7f 660 }
a592ba15 661 open my $mfh, '>', $new or die "open $new for write: $!";
662 print $mfh <<'EOP';
3a0105ce 663all :
1b171b8d 664
3a0105ce 665clean :
1b171b8d 666
3a0105ce 667install :
1b171b8d 668
3a0105ce 669makemakerdflt :
1b171b8d 670
3a0105ce 671test :
1b171b8d 672
673EOP
a592ba15 674 close $mfh or die "close $new for write: $!";
1b171b8d 675}
676
e05e23b1 677sub check_manifest {
678 print STDOUT "Checking if your kit is complete...\n";
3b03c0f3 679 require ExtUtils::Manifest;
5e9e174b 680 # avoid warning
681 $ExtUtils::Manifest::Quiet = $ExtUtils::Manifest::Quiet = 1;
682 my(@missed) = ExtUtils::Manifest::manicheck();
683 if (@missed) {
f6d6199c 684 print STDOUT "Warning: the following files are missing in your kit:\n";
685 print "\t", join "\n\t", @missed;
686 print STDOUT "\n";
687 print STDOUT "Please inform the author.\n";
8e07c86e 688 } else {
f6d6199c 689 print STDOUT "Looks good\n";
8e07c86e 690 }
8e07c86e 691}
692
e05e23b1 693sub parse_args{
694 my($self, @args) = @_;
5e9e174b 695 foreach (@args) {
f6d6199c 696 unless (m/(.*?)=(.*)/) {
f6d6199c 697 ++$Verbose if m/^verb/;
698 next;
699 }
700 my($name, $value) = ($1, $2);
701 if ($value =~ m/^~(\w+)?/) { # tilde with optional username
702 $value =~ s [^~(\w*)]
703 [$1 ?
704 ((getpwnam($1))[7] || "~$1") :
705 (getpwuid($>))[7]
706 ]ex;
707 }
479d2113 708
709 # Remember the original args passed it. It will be useful later.
710 $self->{ARGS}{uc $name} = $self->{uc $name} = $value;
8e07c86e 711 }
8e07c86e 712
e05e23b1 713 # catch old-style 'potential_libs' and inform user how to 'upgrade'
714 if (defined $self->{potential_libs}){
f6d6199c 715 my($msg)="'potential_libs' => '$self->{potential_libs}' should be";
716 if ($self->{potential_libs}){
717 print STDOUT "$msg changed to:\n\t'LIBS' => ['$self->{potential_libs}']\n";
718 } else {
719 print STDOUT "$msg deleted.\n";
720 }
721 $self->{LIBS} = [$self->{potential_libs}];
722 delete $self->{potential_libs};
8e07c86e 723 }
e05e23b1 724 # catch old-style 'ARMAYBE' and inform user how to 'upgrade'
725 if (defined $self->{ARMAYBE}){
f6d6199c 726 my($armaybe) = $self->{ARMAYBE};
727 print STDOUT "ARMAYBE => '$armaybe' should be changed to:\n",
728 "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n";
729 my(%dl) = %{$self->{dynamic_lib} || {}};
730 $self->{dynamic_lib} = { %dl, ARMAYBE => $armaybe};
731 delete $self->{ARMAYBE};
8e07c86e 732 }
e05e23b1 733 if (defined $self->{LDTARGET}){
f6d6199c 734 print STDOUT "LDTARGET should be changed to LDFROM\n";
735 $self->{LDFROM} = $self->{LDTARGET};
736 delete $self->{LDTARGET};
8e07c86e 737 }
e05e23b1 738 # Turn a DIR argument on the command line into an array
739 if (defined $self->{DIR} && ref \$self->{DIR} eq 'SCALAR') {
f6d6199c 740 # So they can choose from the command line, which extensions they want
741 # the grep enables them to have some colons too much in case they
742 # have to build a list with the shell
743 $self->{DIR} = [grep $_, split ":", $self->{DIR}];
8e07c86e 744 }
f1387719 745 # Turn a INCLUDE_EXT argument on the command line into an array
746 if (defined $self->{INCLUDE_EXT} && ref \$self->{INCLUDE_EXT} eq 'SCALAR') {
f6d6199c 747 $self->{INCLUDE_EXT} = [grep $_, split '\s+', $self->{INCLUDE_EXT}];
f1387719 748 }
749 # Turn a EXCLUDE_EXT argument on the command line into an array
750 if (defined $self->{EXCLUDE_EXT} && ref \$self->{EXCLUDE_EXT} eq 'SCALAR') {
f6d6199c 751 $self->{EXCLUDE_EXT} = [grep $_, split '\s+', $self->{EXCLUDE_EXT}];
f1387719 752 }
5e9e174b 753
754 foreach my $mmkey (sort keys %$self){
479d2113 755 next if $mmkey eq 'ARGS';
f6d6199c 756 print STDOUT " $mmkey => ", neatvalue($self->{$mmkey}), "\n" if $Verbose;
757 print STDOUT "'$mmkey' is not a known MakeMaker parameter name.\n"
758 unless exists $Recognized_Att_Keys{$mmkey};
e05e23b1 759 }
f1387719 760 $| = 1 if $Verbose;
e05e23b1 761}
8e07c86e 762
e05e23b1 763sub check_hints {
764 my($self) = @_;
765 # We allow extension-specific hints files.
864a5fa8 766
479d2113 767 require File::Spec;
768 my $curdir = File::Spec->curdir;
769
770 my $hint_dir = File::Spec->catdir($curdir, "hints");
771 return unless -d $hint_dir;
8e07c86e 772
e05e23b1 773 # First we look for the best hintsfile we have
f1387719 774 my($hint)="${^O}_$Config{osvers}";
e05e23b1 775 $hint =~ s/\./_/g;
776 $hint =~ s/_$//;
777 return unless $hint;
fed7345c 778
e05e23b1 779 # Also try without trailing minor version numbers.
780 while (1) {
479d2113 781 last if -f File::Spec->catfile($hint_dir, "$hint.pl"); # found
e05e23b1 782 } continue {
f6d6199c 783 last unless $hint =~ s/_[^_]*$//; # nothing to cut off
e05e23b1 784 }
479d2113 785 my $hint_file = File::Spec->catfile($hint_dir, "$hint.pl");
6626a13a 786
787 return unless -f $hint_file; # really there
fed7345c 788
f6d6199c 789 _run_hintfile($self, $hint_file);
790}
791
792sub _run_hintfile {
a592ba15 793 our $self;
f6d6199c 794 local($self) = shift; # make $self available to the hint file.
795 my($hint_file) = shift;
796
479d2113 797 local($@, $!);
39234879 798 print STDERR "Processing hints file $hint_file\n";
479d2113 799
800 # Just in case the ./ isn't on the hint file, which File::Spec can
801 # often strip off, we bung the curdir into @INC
802 local @INC = (File::Spec->curdir, @INC);
803 my $ret = do $hint_file;
804 if( !defined $ret ) {
805 my $error = $@ || $!;
806 print STDERR $error;
75e2e551 807 }
e05e23b1 808}
8e07c86e 809
e05e23b1 810sub mv_all_methods {
811 my($from,$to) = @_;
fed7345c 812
e05e23b1 813 # Here you see the *current* list of methods that are overridable
814 # from Makefile.PL via MY:: subroutines. As of VERSION 5.07 I'm
815 # still trying to reduce the list to some reasonable minimum --
816 # because I want to make it easier for the user. A.K.
40000a8c 817
57b1a898 818 local $SIG{__WARN__} = sub {
819 # can't use 'no warnings redefined', 5.6 only
820 warn @_ unless $_[0] =~ /^Subroutine .* redefined/
821 };
5e9e174b 822 foreach my $method (@Overridable) {
fed7345c 823
f6d6199c 824 # We cannot say "next" here. Nick might call MY->makeaperl
825 # which isn't defined right now
826
827 # Above statement was written at 4.23 time when Tk-b8 was
828 # around. As Tk-b9 only builds with 5.002something and MM 5 is
829 # standard, we try to enable the next line again. It was
830 # commented out until MM 5.23
831
832 next unless defined &{"${from}::$method"};
fed7345c 833
a592ba15 834 {
835 no strict 'refs'; ## no critic
836 *{"${to}::$method"} = \&{"${from}::$method"};
837
838 # If we delete a method, then it will be undefined and cannot
839 # be called. But as long as we have Makefile.PLs that rely on
840 # %MY:: being intact, we have to fill the hole with an
841 # inheriting method:
842
843 {
844 package MY;
845 my $super = "SUPER::".$method;
846 *{$method} = sub {
847 shift->$super(@_);
848 };
849 }
850 }
5d94fbed 851 }
852
e05e23b1 853 # We have to clean out %INC also, because the current directory is
854 # changed frequently and Graham Barr prefers to get his version
855 # out of a History.pl file which is "required" so woudn't get
856 # loaded again in another extension requiring a History.pl
a0d0e21e 857
f1387719 858 # With perl5.002_01 the deletion of entries in %INC caused Tk-b11
859 # to core dump in the middle of a require statement. The required
860 # file was Tk/MMutil.pm. The consequence is, we have to be
861 # extremely careful when we try to give perl a reason to reload a
862 # library with same name. The workaround prefers to drop nothing
863 # from %INC and teach the writers not to use such libraries.
864
865# my $inc;
866# foreach $inc (keys %INC) {
f6d6199c 867# #warn "***$inc*** deleted";
868# delete $INC{$inc};
f1387719 869# }
8e07c86e 870}
871
3b03c0f3 872sub skipcheck {
8e07c86e 873 my($self) = shift;
e05e23b1 874 my($section) = @_;
875 if ($section eq 'dynamic') {
f6d6199c 876 print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
877 "in skipped section 'dynamic_bs'\n"
e05e23b1 878 if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
879 print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
f6d6199c 880 "in skipped section 'dynamic_lib'\n"
e05e23b1 881 if $self->{SKIPHASH}{dynamic_lib} && $Verbose;
8e07c86e 882 }
e05e23b1 883 if ($section eq 'dynamic_lib') {
884 print STDOUT "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on ",
f6d6199c 885 "targets in skipped section 'dynamic_bs'\n"
e05e23b1 886 if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
887 }
888 if ($section eq 'static') {
889 print STDOUT "Warning (non-fatal): Target 'static' depends on targets ",
f6d6199c 890 "in skipped section 'static_lib'\n"
e05e23b1 891 if $self->{SKIPHASH}{static_lib} && $Verbose;
8e07c86e 892 }
e05e23b1 893 return 'skipped' if $self->{SKIPHASH}{$section};
894 return '';
8e07c86e 895}
896
e05e23b1 897sub flush {
898 my $self = shift;
bfdac1b8 899
900 my $finalname = $self->{MAKEFILE};
1151960e 901 print STDOUT "Writing $finalname for $self->{NAME}\n";
8e07c86e 902
1151960e 903 unlink($finalname, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : ());
a592ba15 904 open(my $fh,">", "MakeMaker.tmp")
905 or die "Unable to open MakeMaker.tmp: $!";
8e07c86e 906
a592ba15 907 for my $chunk (@{$self->{RESULT}}) {
908 print $fh "$chunk\n";
8e07c86e 909 }
e05e23b1 910
a592ba15 911 close $fh;
479d2113 912 _rename("MakeMaker.tmp", $finalname) or
913 warn "rename MakeMaker.tmp => $finalname: $!";
e05e23b1 914 chmod 0644, $finalname unless $Is_VMS;
3b03c0f3 915
479d2113 916 my %keep = map { ($_ => 1) } qw(NEEDS_LINKING HAS_LINK_CODE);
917
e0678a30 918 if ($self->{PARENT} && !$self->{_KEEP_AFTER_FLUSH}) {
f6d6199c 919 foreach (keys %$self) { # safe memory
479d2113 920 delete $self->{$_} unless $keep{$_};
f6d6199c 921 }
3b03c0f3 922 }
923
e05e23b1 924 system("$Config::Config{eunicefix} $finalname") unless $Config::Config{eunicefix} eq ":";
40000a8c 925}
926
479d2113 927
928# This is a rename for OS's where the target must be unlinked first.
929sub _rename {
930 my($src, $dest) = @_;
931 chmod 0666, $dest;
932 unlink $dest;
933 return rename $src, $dest;
934}
935
dedf98bc 936# This is an unlink for OS's where the target must be writable first.
937sub _unlink {
938 my @files = @_;
939 chmod 0666, @files;
940 return unlink @files;
941}
942
479d2113 943
e05e23b1 944# The following mkbootstrap() is only for installations that are calling
945# the pre-4.1 mkbootstrap() from their old Makefiles. This MakeMaker
946# writes Makefiles, that use ExtUtils::Mkbootstrap directly.
947sub mkbootstrap {
948 die <<END;
949!!! Your Makefile has been built such a long time ago, !!!
950!!! that is unlikely to work with current MakeMaker. !!!
951!!! Please rebuild your Makefile !!!
952END
8e07c86e 953}
005c1a0e 954
e05e23b1 955# Ditto for mksymlists() as of MakeMaker 5.17
956sub mksymlists {
957 die <<END;
958!!! Your Makefile has been built such a long time ago, !!!
959!!! that is unlikely to work with current MakeMaker. !!!
960!!! Please rebuild your Makefile !!!
961END
4633a7c4 962}
963
e05e23b1 964sub neatvalue {
965 my($v) = @_;
966 return "undef" unless defined $v;
967 my($t) = ref $v;
968 return "q[$v]" unless $t;
969 if ($t eq 'ARRAY') {
f6d6199c 970 my(@m, @neat);
971 push @m, "[";
972 foreach my $elem (@$v) {
973 push @neat, "q[$elem]";
974 }
975 push @m, join ", ", @neat;
976 push @m, "]";
977 return join "", @m;
e05e23b1 978 }
979 return "$v" unless $t eq 'HASH';
980 my(@m, $key, $val);
3b03c0f3 981 while (($key,$val) = each %$v){
f6d6199c 982 last unless defined $key; # cautious programming in case (undef,undef) is true
983 push(@m,"$key=>".neatvalue($val)) ;
3b03c0f3 984 }
e05e23b1 985 return "{ ".join(', ',@m)." }";
4e68a208 986}
987
e05e23b1 988sub selfdocument {
989 my($self) = @_;
990 my(@m);
991 if ($Verbose){
f6d6199c 992 push @m, "\n# Full list of MakeMaker attribute values:";
993 foreach my $key (sort keys %$self){
994 next if $key eq 'RESULT' || $key =~ /^[A-Z][a-z]/;
995 my($v) = neatvalue($self->{$key});
996 $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
997 $v =~ tr/\n/ /s;
998 push @m, "# $key => $v";
999 }
e05e23b1 1000 }
1001 join "\n", @m;
1002}
4e68a208 1003
3b03c0f3 10041;
1005
1006__END__
005c1a0e 1007
1008=head1 NAME
1009
479d2113 1010ExtUtils::MakeMaker - Create a module Makefile
005c1a0e 1011
1012=head1 SYNOPSIS
1013
e0678a30 1014 use ExtUtils::MakeMaker;
005c1a0e 1015
e0678a30 1016 WriteMakefile( ATTRIBUTE => VALUE [, ...] );
8e07c86e 1017
005c1a0e 1018=head1 DESCRIPTION
1019
1020This utility is designed to write a Makefile for an extension module
1021from a Makefile.PL. It is based on the Makefile.SH model provided by
1022Andy Dougherty and the perl5-porters.
1023
1024It splits the task of generating the Makefile into several subroutines
1025that can be individually overridden. Each subroutine returns the text
1026it wishes to have written to the Makefile.
1027
f1387719 1028MakeMaker is object oriented. Each directory below the current
e0678a30 1029directory that contains a Makefile.PL is treated as a separate
f1387719 1030object. This makes it possible to write an unlimited number of
1031Makefiles with a single invocation of WriteMakefile().
8e07c86e 1032
f1387719 1033=head2 How To Write A Makefile.PL
8e07c86e 1034
479d2113 1035See ExtUtils::MakeMaker::Tutorial.
8e07c86e 1036
bab2b58e 1037The long answer is the rest of the manpage :-)
005c1a0e 1038
1039=head2 Default Makefile Behaviour
1040
f1387719 1041The generated Makefile enables the user of the extension to invoke
005c1a0e 1042
1043 perl Makefile.PL # optionally "perl Makefile.PL verbose"
1044 make
8e07c86e 1045 make test # optionally set TEST_VERBOSE=1
1046 make install # See below
005c1a0e 1047
1048The Makefile to be produced may be altered by adding arguments of the
e05e23b1 1049form C<KEY=VALUE>. E.g.
005c1a0e 1050
58d32538 1051 perl Makefile.PL INSTALL_BASE=~
005c1a0e 1052
1053Other interesting targets in the generated Makefile are
1054
1055 make config # to check if the Makefile is up-to-date
8e07c86e 1056 make clean # delete local temp files (Makefile gets renamed)
1057 make realclean # delete derived files (including ./blib)
e05e23b1 1058 make ci # check in all the files in the MANIFEST file
005c1a0e 1059 make dist # see below the Distribution Support section
1060
e05e23b1 1061=head2 make test
1062
bab2b58e 1063MakeMaker checks for the existence of a file named F<test.pl> in the
d5d4ec93 1064current directory and if it exists it execute the script with the
1065proper set of perl C<-I> options.
e05e23b1 1066
1067MakeMaker also checks for any files matching glob("t/*.t"). It will
d5d4ec93 1068execute all matching files in alphabetical order via the
1069L<Test::Harness> module with the C<-I> switches set correctly.
1070
1071If you'd like to see the raw output of your tests, set the
1072C<TEST_VERBOSE> variable to true.
1073
1074 make test TEST_VERBOSE=1
e05e23b1 1075
bab2b58e 1076=head2 make testdb
1077
1078A useful variation of the above is the target C<testdb>. It runs the
1079test under the Perl debugger (see L<perldebug>). If the file
1080F<test.pl> exists in the current directory, it is used for the test.
1081
d5d4ec93 1082If you want to debug some other testfile, set the C<TEST_FILE> variable
bab2b58e 1083thusly:
1084
1085 make testdb TEST_FILE=t/mytest.t
1086
1087By default the debugger is called using C<-d> option to perl. If you
d5d4ec93 1088want to specify some other option, set the C<TESTDB_SW> variable:
bab2b58e 1089
1090 make testdb TESTDB_SW=-Dx
1091
e05e23b1 1092=head2 make install
005c1a0e 1093
8e07c86e 1094make alone puts all relevant files into directories that are named by
f6d6199c 1095the macros INST_LIB, INST_ARCHLIB, INST_SCRIPT, INST_MAN1DIR and
1096INST_MAN3DIR. All these default to something below ./blib if you are
1097I<not> building below the perl source directory. If you I<are>
1098building below the perl source, INST_LIB and INST_ARCHLIB default to
1099../../lib, and INST_SCRIPT is not defined.
005c1a0e 1100
e05e23b1 1101The I<install> target of the generated Makefile copies the files found
1102below each of the INST_* directories to their INSTALL*
1103counterparts. Which counterparts are chosen depends on the setting of
1104INSTALLDIRS according to the following table:
005c1a0e 1105
f6d6199c 1106 INSTALLDIRS set to
5c161494 1107 perl site vendor
e05e23b1 1108
479d2113 1109 PERLPREFIX SITEPREFIX VENDORPREFIX
5c161494 1110 INST_ARCHLIB INSTALLARCHLIB INSTALLSITEARCH INSTALLVENDORARCH
1111 INST_LIB INSTALLPRIVLIB INSTALLSITELIB INSTALLVENDORLIB
1112 INST_BIN INSTALLBIN INSTALLSITEBIN INSTALLVENDORBIN
002b9267 1113 INST_SCRIPT INSTALLSCRIPT INSTALLSITESCRIPT INSTALLVENDORSCRIPT
5c161494 1114 INST_MAN1DIR INSTALLMAN1DIR INSTALLSITEMAN1DIR INSTALLVENDORMAN1DIR
1115 INST_MAN3DIR INSTALLMAN3DIR INSTALLSITEMAN3DIR INSTALLVENDORMAN3DIR
005c1a0e 1116
8e07c86e 1117The INSTALL... macros in turn default to their %Config
1118($Config{installprivlib}, $Config{installarchlib}, etc.) counterparts.
005c1a0e 1119
3b03c0f3 1120You can check the values of these variables on your system with
1121
bab2b58e 1122 perl '-V:install.*'
3b03c0f3 1123
f1387719 1124And to check the sequence in which the library directories are
1125searched by perl, run
005c1a0e 1126
f1387719 1127 perl -le 'print join $/, @INC'
005c1a0e 1128
a7d1454b 1129Sometimes older versions of the module you're installing live in other
1130directories in @INC. Because Perl loads the first version of a module it
1131finds, not the newest, you might accidentally get one of these older
1132versions even after installing a brand new version. To delete I<all other
1133versions of the module you're installing> (not simply older ones) set the
1134C<UNINST> variable.
1135
1136 make install UNINST=1
1137
005c1a0e 1138
58d32538 1139=head2 INSTALL_BASE
1140
1141INSTALL_BASE can be passed into Makefile.PL to change where your
1142module will be installed. INSTALL_BASE is more like what everyone
1143else calls "prefix" than PREFIX is.
1144
1145To have everything installed in your home directory, do the following.
1146
1e65eb70 1147 # Unix users, INSTALL_BASE=~ works fine
1148 perl Makefile.PL INSTALL_BASE=/path/to/your/home/dir
58d32538 1149
1150Like PREFIX, it sets several INSTALL* attributes at once. Unlike
1151PREFIX it is easy to predict where the module will end up. The
1152installation pattern looks like this:
1153
1154 INSTALLARCHLIB INSTALL_BASE/lib/perl5/$Config{archname}
1155 INSTALLPRIVLIB INSTALL_BASE/lib/perl5
1156 INSTALLBIN INSTALL_BASE/bin
1157 INSTALLSCRIPT INSTALL_BASE/bin
1158 INSTALLMAN1DIR INSTALL_BASE/man/man1
1159 INSTALLMAN3DIR INSTALL_BASE/man/man3
1160
1161INSTALL_BASE in MakeMaker and C<--install_base> in Module::Build (as
1162of 0.28) install to the same location. If you want MakeMaker and
1163Module::Build to install to the same location simply set INSTALL_BASE
1164and C<--install_base> to the same location.
1165
1166INSTALL_BASE was added in 6.31.
1167
1168
bab2b58e 1169=head2 PREFIX and LIB attribute
1170
1171PREFIX and LIB can be used to set several INSTALL* attributes in one
58d32538 1172go. Here's an example for installing into your home directory.
bab2b58e 1173
1e65eb70 1174 # Unix users, PREFIX=~ works fine
1175 perl Makefile.PL PREFIX=/path/to/your/home/dir
005c1a0e 1176
f6d6199c 1177This will install all files in the module under your home directory,
1178with man pages and libraries going into an appropriate place (usually
58d32538 1179~/man and ~/lib). How the exact location is determined is complicated
1180and depends on how your Perl was configured. INSTALL_BASE works more
1181like what other build systems call "prefix" than PREFIX and we
1182recommend you use that instead.
bab2b58e 1183
1184Another way to specify many INSTALL directories with a single
f6d6199c 1185parameter is LIB.
005c1a0e 1186
f6d6199c 1187 perl Makefile.PL LIB=~/lib
005c1a0e 1188
f6d6199c 1189This will install the module's architecture-independent files into
1190~/lib, the architecture-dependent files into ~/lib/$archname.
005c1a0e 1191
bab2b58e 1192Note, that in both cases the tilde expansion is done by MakeMaker, not
e35b8f9e 1193by perl by default, nor by make.
1194
f6d6199c 1195Conflicts between parameters LIB, PREFIX and the various INSTALL*
1196arguments are resolved so that:
e35b8f9e 1197
1198=over 4
1199
1200=item *
1201
1202setting LIB overrides any setting of INSTALLPRIVLIB, INSTALLARCHLIB,
1203INSTALLSITELIB, INSTALLSITEARCH (and they are not affected by PREFIX);
1204
1205=item *
1206
1207without LIB, setting PREFIX replaces the initial C<$Config{prefix}>
1208part of those INSTALL* arguments, even if the latter are explicitly
1209set (but are set to still start with C<$Config{prefix}>).
1210
1211=back
005c1a0e 1212
f6d6199c 1213If the user has superuser privileges, and is not working on AFS or
1214relatives, then the defaults for INSTALLPRIVLIB, INSTALLARCHLIB,
1215INSTALLSCRIPT, etc. will be appropriate, and this incantation will be
1216the best:
005c1a0e 1217
e0678a30 1218 perl Makefile.PL;
1219 make;
1220 make test
005c1a0e 1221 make install
1222
8e07c86e 1223make install per default writes some documentation of what has been
e05e23b1 1224done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This feature
1225can be bypassed by calling make pure_install.
8e07c86e 1226
1227=head2 AFS users
1228
1229will have to specify the installation directories as these most
1230probably have changed since perl itself has been installed. They will
1231have to do this by calling
1232
e05e23b1 1233 perl Makefile.PL INSTALLSITELIB=/afs/here/today \
f6d6199c 1234 INSTALLSCRIPT=/afs/there/now INSTALLMAN3DIR=/afs/for/manpages
8e07c86e 1235 make
1236
e05e23b1 1237Be careful to repeat this procedure every time you recompile an
1238extension, unless you are sure the AFS installation directories are
1239still valid.
005c1a0e 1240
8e07c86e 1241=head2 Static Linking of a new Perl Binary
005c1a0e 1242
1243An extension that is built with the above steps is ready to use on
1244systems supporting dynamic loading. On systems that do not support
1245dynamic loading, any newly created extension has to be linked together
1246with the available resources. MakeMaker supports the linking process
1247by creating appropriate targets in the Makefile whenever an extension
1248is built. You can invoke the corresponding section of the makefile with
1249
1250 make perl
1251
1252That produces a new perl binary in the current directory with all
da7f727a 1253extensions linked in that can be found in INST_ARCHLIB, SITELIBEXP,
e05e23b1 1254and PERL_ARCHLIB. To do that, MakeMaker writes a new Makefile, on
1255UNIX, this is called Makefile.aperl (may be system dependent). If you
1256want to force the creation of a new perl, it is recommended, that you
1257delete this Makefile.aperl, so the directories are searched-through
1258for linkable libraries again.
005c1a0e 1259
1260The binary can be installed into the directory where perl normally
1261resides on your machine with
1262
1263 make inst_perl
1264
1265To produce a perl binary with a different name than C<perl>, either say
1266
1267 perl Makefile.PL MAP_TARGET=myperl
1268 make myperl
1269 make inst_perl
1270
1271or say
1272
1273 perl Makefile.PL
1274 make myperl MAP_TARGET=myperl
1275 make inst_perl MAP_TARGET=myperl
1276
1277In any case you will be prompted with the correct invocation of the
1278C<inst_perl> target that installs the new binary into INSTALLBIN.
1279
8e07c86e 1280make inst_perl per default writes some documentation of what has been
1281done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This
1282can be bypassed by calling make pure_inst_perl.
005c1a0e 1283
e05e23b1 1284Warning: the inst_perl: target will most probably overwrite your
1285existing perl binary. Use with care!
005c1a0e 1286
8e07c86e 1287Sometimes you might want to build a statically linked perl although
1288your system supports dynamic loading. In this case you may explicitly
1289set the linktype with the invocation of the Makefile.PL or make:
1290
1291 perl Makefile.PL LINKTYPE=static # recommended
1292
1293or
1294
1295 make LINKTYPE=static # works on most systems
1296
005c1a0e 1297=head2 Determination of Perl Library and Installation Locations
1298
1299MakeMaker needs to know, or to guess, where certain things are
e05e23b1 1300located. Especially INST_LIB and INST_ARCHLIB (where to put the files
1301during the make(1) run), PERL_LIB and PERL_ARCHLIB (where to read
1302existing modules from), and PERL_INC (header files and C<libperl*.*>).
005c1a0e 1303
1304Extensions may be built either using the contents of the perl source
e05e23b1 1305directory tree or from the installed perl library. The recommended way
1306is to build extensions after you have run 'make install' on perl
1307itself. You can do that in any directory on your hard disk that is not
1308below the perl source tree. The support for extensions below the ext
1309directory of the perl distribution is only good for the standard
1310extensions that come with perl.
005c1a0e 1311
1312If an extension is being built below the C<ext/> directory of the perl
e05e23b1 1313source then MakeMaker will set PERL_SRC automatically (e.g.,
1314C<../..>). If PERL_SRC is defined and the extension is recognized as
1315a standard extension, then other variables default to the following:
005c1a0e 1316
1317 PERL_INC = PERL_SRC
1318 PERL_LIB = PERL_SRC/lib
1319 PERL_ARCHLIB = PERL_SRC/lib
1320 INST_LIB = PERL_LIB
1321 INST_ARCHLIB = PERL_ARCHLIB
1322
1323If an extension is being built away from the perl source then MakeMaker
1324will leave PERL_SRC undefined and default to using the installed copy
1325of the perl library. The other variables default to the following:
1326
e05e23b1 1327 PERL_INC = $archlibexp/CORE
1328 PERL_LIB = $privlibexp
1329 PERL_ARCHLIB = $archlibexp
1330 INST_LIB = ./blib/lib
1331 INST_ARCHLIB = ./blib/arch
005c1a0e 1332
1333If perl has not yet been installed then PERL_SRC can be defined on the
1334command line as shown in the previous section.
1335
005c1a0e 1336
f1387719 1337=head2 Which architecture dependent directory?
005c1a0e 1338
f1387719 1339If you don't want to keep the defaults for the INSTALL* macros,
1340MakeMaker helps you to minimize the typing needed: the usual
1341relationship between INSTALLPRIVLIB and INSTALLARCHLIB is determined
1342by Configure at perl compilation time. MakeMaker supports the user who
1343sets INSTALLPRIVLIB. If INSTALLPRIVLIB is set, but INSTALLARCHLIB not,
1344then MakeMaker defaults the latter to be the same subdirectory of
1345INSTALLPRIVLIB as Configure decided for the counterparts in %Config ,
1346otherwise it defaults to INSTALLPRIVLIB. The same relationship holds
1347for INSTALLSITELIB and INSTALLSITEARCH.
005c1a0e 1348
f1387719 1349MakeMaker gives you much more freedom than needed to configure
1350internal variables and get different results. It is worth to mention,
1351that make(1) also lets you configure most of the variables that are
1352used in the Makefile. But in the majority of situations this will not
a7665c5e 1353be necessary, and should only be done if the author of a package
f1387719 1354recommends it (or you know what you're doing).
005c1a0e 1355
e05e23b1 1356=head2 Using Attributes and Parameters
005c1a0e 1357
a884ca7c 1358The following attributes may be specified as arguments to WriteMakefile()
1359or as NAME=VALUE pairs on the command line.
005c1a0e 1360
875fa795 1361=over 2
005c1a0e 1362
875fa795 1363=item ABSTRACT
1364
1365One line description of the module. Will be included in PPD file.
1366
1367=item ABSTRACT_FROM
1368
1369Name of the file that contains the package description. MakeMaker looks
1370for a line in the POD matching /^($package\s-\s)(.*)/. This is typically
1371the first line in the "=head1 NAME" section. $2 becomes the abstract.
1372
e35b8f9e 1373=item AUTHOR
1374
1375String containing name (and email address) of package author(s). Is used
1376in PPD (Perl Package Description) files for PPM (Perl Package Manager).
1377
875fa795 1378=item BINARY_LOCATION
1379
1380Used when creating PPD files for binary packages. It can be set to a
1381full or relative path or URL to the binary archive for a particular
1382architecture. For example:
1383
f6d6199c 1384 perl Makefile.PL BINARY_LOCATION=x86/Agent.tar.gz
875fa795 1385
1386builds a PPD package that references a binary of the C<Agent> package,
20e08411 1387located in the C<x86> directory relative to the PPD itself.
8e07c86e 1388
864a5fa8 1389=item C
8e07c86e 1390
864a5fa8 1391Ref to array of *.c file names. Initialised from a directory scan
1392and the values portion of the XS attribute hash. This is not
1393currently used by MakeMaker but may be handy in Makefile.PLs.
8e07c86e 1394
84902520 1395=item CCFLAGS
1396
1397String that will be included in the compiler call command line between
1398the arguments INC and OPTIMIZE.
1399
864a5fa8 1400=item CONFIG
8e07c86e 1401
864a5fa8 1402Arrayref. E.g. [qw(archname manext)] defines ARCHNAME & MANEXT from
1403config.sh. MakeMaker will add to CONFIG the following values anyway:
1404ar
1405cc
1406cccdlflags
1407ccdlflags
1408dlext
1409dlsrc
1410ld
1411lddlflags
1412ldflags
1413libc
1414lib_ext
1415obj_ext
1416ranlib
e05e23b1 1417sitelibexp
1418sitearchexp
864a5fa8 1419so
8e07c86e 1420
1421=item CONFIGURE
1422
e05e23b1 1423CODE reference. The subroutine should return a hash reference. The
1fef88e7 1424hash may contain further attributes, e.g. {LIBS =E<gt> ...}, that have to
8e07c86e 1425be determined by some evaluation method.
1426
864a5fa8 1427=item DEFINE
8e07c86e 1428
864a5fa8 1429Something like C<"-DHAVE_UNISTD_H">
8e07c86e 1430
479d2113 1431=item DESTDIR
1432
1433This is the root directory into which the code will be installed. It
1434I<prepends itself to the normal prefix>. For example, if your code
5dca256e 1435would normally go into F</usr/local/lib/perl> you could set DESTDIR=~/tmp/
1436and installation would go into F<~/tmp/usr/local/lib/perl>.
479d2113 1437
1438This is primarily of use for people who repackage Perl modules.
1439
531e2ba1 1440NOTE: Due to the nature of make, it is important that you put the trailing
5dca256e 1441slash on your DESTDIR. F<~/tmp/> not F<~/tmp>.
479d2113 1442
864a5fa8 1443=item DIR
8e07c86e 1444
864a5fa8 1445Ref to array of subdirectories containing Makefile.PLs e.g. [ 'sdbm'
1446] in ext/SDBM_File
8e07c86e 1447
864a5fa8 1448=item DISTNAME
8e07c86e 1449
479d2113 1450A safe filename for the package.
1451
1452Defaults to NAME above but with :: replaced with -.
1453
1454For example, Foo::Bar becomes Foo-Bar.
1455
1456=item DISTVNAME
1457
1458Your name for distributing the package with the version number
1459included. This is used by 'make dist' to name the resulting archive
1460file.
1461
1462Defaults to DISTNAME-VERSION.
1463
1464For example, version 1.04 of Foo::Bar becomes Foo-Bar-1.04.
1465
1466On some OS's where . has special meaning VERSION_SYM may be used in
1467place of VERSION.
8e07c86e 1468
864a5fa8 1469=item DL_FUNCS
8e07c86e 1470
875fa795 1471Hashref of symbol names for routines to be made available as universal
1472symbols. Each key/value pair consists of the package name and an
1473array of routine names in that package. Used only under AIX, OS/2,
1474VMS and Win32 at present. The routine names supplied will be expanded
1475in the same way as XSUB names are expanded by the XS() macro.
1476Defaults to
8e07c86e 1477
864a5fa8 1478 {"$(NAME)" => ["boot_$(NAME)" ] }
8e07c86e 1479
864a5fa8 1480e.g.
8e07c86e 1481
864a5fa8 1482 {"RPC" => [qw( boot_rpcb rpcb_gettime getnetconfigent )],
1483 "NetconfigPtr" => [ 'DESTROY'] }
8e07c86e 1484
875fa795 1485Please see the L<ExtUtils::Mksymlists> documentation for more information
1486about the DL_FUNCS, DL_VARS and FUNCLIST attributes.
1487
864a5fa8 1488=item DL_VARS
8e07c86e 1489
875fa795 1490Array of symbol names for variables to be made available as universal symbols.
1491Used only under AIX, OS/2, VMS and Win32 at present. Defaults to [].
1492(e.g. [ qw(Foo_version Foo_numstreams Foo_tree ) ])
8e07c86e 1493
f1387719 1494=item EXCLUDE_EXT
1495
1496Array of extension names to exclude when doing a static build. This
1497is ignored if INCLUDE_EXT is present. Consult INCLUDE_EXT for more
1498details. (e.g. [ qw( Socket POSIX ) ] )
1499
1500This attribute may be most useful when specified as a string on the
de592821 1501command line: perl Makefile.PL EXCLUDE_EXT='Socket Safe'
f1387719 1502
864a5fa8 1503=item EXE_FILES
8e07c86e 1504
864a5fa8 1505Ref to array of executable files. The files will be copied to the
f1387719 1506INST_SCRIPT directory. Make realclean will delete them from there
864a5fa8 1507again.
8e07c86e 1508
2530b651 1509If your executables start with something like #!perl or
1510#!/usr/bin/perl MakeMaker will change this to the path of the perl
1511'Makefile.PL' was invoked with so the programs will be sure to run
1512properly even if perl is not in /usr/bin/perl.
1513
864a5fa8 1514=item FIRST_MAKEFILE
1515
479d2113 1516The name of the Makefile to be produced. This is used for the second
1517Makefile that will be produced for the MAP_TARGET.
1518
1519Defaults to 'Makefile' or 'Descrip.MMS' on VMS.
1520
1521(Note: we couldn't use MAKEFILE because dmake uses this for something
1522else).
864a5fa8 1523
1524=item FULLPERL
8e07c86e 1525
75e2e551 1526Perl binary able to run this extension, load XS modules, etc...
1527
1528=item FULLPERLRUN
1529
1530Like PERLRUN, except it uses FULLPERL.
1531
1532=item FULLPERLRUNINST
1533
1534Like PERLRUNINST, except it uses FULLPERL.
864a5fa8 1535
762efda7 1536=item FUNCLIST
1537
1538This provides an alternate means to specify function names to be
1539exported from the extension. Its value is a reference to an
1540array of function names to be exported by the extension. These
1541names are passed through unaltered to the linker options file.
1542
864a5fa8 1543=item H
1544
1545Ref to array of *.h file names. Similar to C.
1546
84902520 1547=item IMPORTS
1548
875fa795 1549This attribute is used to specify names to be imported into the
69ff8adf 1550extension. Takes a hash ref.
1551
1552It is only used on OS/2 and Win32.
84902520 1553
864a5fa8 1554=item INC
1555
1556Include file dirs eg: C<"-I/usr/5include -I/path/to/inc">
1557
f1387719 1558=item INCLUDE_EXT
1559
1560Array of extension names to be included when doing a static build.
1561MakeMaker will normally build with all of the installed extensions when
1562doing a static build, and that is usually the desired behavior. If
1563INCLUDE_EXT is present then MakeMaker will build only with those extensions
1564which are explicitly mentioned. (e.g. [ qw( Socket POSIX ) ])
1565
1566It is not necessary to mention DynaLoader or the current extension when
1567filling in INCLUDE_EXT. If the INCLUDE_EXT is mentioned but is empty then
1568only DynaLoader and the current extension will be included in the build.
1569
1570This attribute may be most useful when specified as a string on the
de592821 1571command line: perl Makefile.PL INCLUDE_EXT='POSIX Socket Devel::Peek'
f1387719 1572
864a5fa8 1573=item INSTALLARCHLIB
1574
e05e23b1 1575Used by 'make install', which copies files from INST_ARCHLIB to this
1576directory if INSTALLDIRS is set to perl.
864a5fa8 1577
1578=item INSTALLBIN
1579
5c161494 1580Directory to install binary files (e.g. tkperl) into if
1581INSTALLDIRS=perl.
e05e23b1 1582
1583=item INSTALLDIRS
1584
5c161494 1585Determines which of the sets of installation directories to choose:
1586perl, site or vendor. Defaults to site.
8e07c86e 1587
1588=item INSTALLMAN1DIR
1589
1590=item INSTALLMAN3DIR
1591
5c161494 1592These directories get the man pages at 'make install' time if
1593INSTALLDIRS=perl. Defaults to $Config{installman*dir}.
8e07c86e 1594
5c161494 1595If set to 'none', no man pages will be installed.
e0678a30 1596
864a5fa8 1597=item INSTALLPRIVLIB
8e07c86e 1598
e05e23b1 1599Used by 'make install', which copies files from INST_LIB to this
1600directory if INSTALLDIRS is set to perl.
1601
5c161494 1602Defaults to $Config{installprivlib}.
1603
f1387719 1604=item INSTALLSCRIPT
1605
1606Used by 'make install' which copies files from INST_SCRIPT to this
002b9267 1607directory if INSTALLDIRS=perl.
f1387719 1608
875fa795 1609=item INSTALLSITEARCH
e05e23b1 1610
875fa795 1611Used by 'make install', which copies files from INST_ARCHLIB to this
e05e23b1 1612directory if INSTALLDIRS is set to site (default).
1613
5c161494 1614=item INSTALLSITEBIN
1615
1616Used by 'make install', which copies files from INST_BIN to this
1617directory if INSTALLDIRS is set to site (default).
1618
875fa795 1619=item INSTALLSITELIB
e05e23b1 1620
875fa795 1621Used by 'make install', which copies files from INST_LIB to this
e05e23b1 1622directory if INSTALLDIRS is set to site (default).
8e07c86e 1623
5c161494 1624=item INSTALLSITEMAN1DIR
1625
1626=item INSTALLSITEMAN3DIR
1627
1628These directories get the man pages at 'make install' time if
1629INSTALLDIRS=site (default). Defaults to
1630$(SITEPREFIX)/man/man$(MAN*EXT).
1631
1632If set to 'none', no man pages will be installed.
1633
002b9267 1634=item INSTALLSITESCRIPT
1635
1636Used by 'make install' which copies files from INST_SCRIPT to this
1637directory if INSTALLDIRS is set to site (default).
1638
5c161494 1639=item INSTALLVENDORARCH
1640
1641Used by 'make install', which copies files from INST_ARCHLIB to this
1642directory if INSTALLDIRS is set to vendor.
1643
1644=item INSTALLVENDORBIN
1645
1646Used by 'make install', which copies files from INST_BIN to this
1647directory if INSTALLDIRS is set to vendor.
1648
1649=item INSTALLVENDORLIB
1650
1651Used by 'make install', which copies files from INST_LIB to this
1652directory if INSTALLDIRS is set to vendor.
1653
1654=item INSTALLVENDORMAN1DIR
1655
1656=item INSTALLVENDORMAN3DIR
1657
1658These directories get the man pages at 'make install' time if
1659INSTALLDIRS=vendor. Defaults to $(VENDORPREFIX)/man/man$(MAN*EXT).
1660
1661If set to 'none', no man pages will be installed.
1662
002b9267 1663=item INSTALLVENDORSCRIPT
1664
1665Used by 'make install' which copies files from INST_SCRIPT to this
1666directory if INSTALLDIRS is set to is set to vendor.
1667
864a5fa8 1668=item INST_ARCHLIB
8e07c86e 1669
864a5fa8 1670Same as INST_LIB for architecture dependent files.
8e07c86e 1671
f1387719 1672=item INST_BIN
1673
1674Directory to put real binary files during 'make'. These will be copied
1675to INSTALLBIN during 'make install'
1676
e35b8f9e 1677=item INST_LIB
1678
1679Directory where we put library files of this extension while building
1680it.
1681
864a5fa8 1682=item INST_MAN1DIR
8e07c86e 1683
864a5fa8 1684Directory to hold the man pages at 'make' time
8e07c86e 1685
864a5fa8 1686=item INST_MAN3DIR
8e07c86e 1687
864a5fa8 1688Directory to hold the man pages at 'make' time
8e07c86e 1689
f1387719 1690=item INST_SCRIPT
1691
1692Directory, where executable files should be installed during
c3fed81c 1693'make'. Defaults to "./blib/script", just to have a dummy location during
f1387719 1694testing. make install will copy the files in INST_SCRIPT to
1695INSTALLSCRIPT.
1696
479d2113 1697=item LD
1698
1699Program to be used to link libraries for dynamic loading.
1700
1701Defaults to $Config{ld}.
1702
a884ca7c 1703=item LDDLFLAGS
1704
1705Any special flags that might need to be passed to ld to create a
1706shared library suitable for dynamic loading. It is up to the makefile
1707to use it. (See L<Config/lddlflags>)
1708
1709Defaults to $Config{lddlflags}.
1710
864a5fa8 1711=item LDFROM
8e07c86e 1712
69ff8adf 1713Defaults to "$(OBJECT)" and is used in the ld command to specify
864a5fa8 1714what files to link/load from (also see dynamic_lib below for how to
1715specify ld flags)
8e07c86e 1716
bab2b58e 1717=item LIB
1718
e35b8f9e 1719LIB should only be set at C<perl Makefile.PL> time but is allowed as a
f6d6199c 1720MakeMaker argument. It has the effect of setting both INSTALLPRIVLIB
1721and INSTALLSITELIB to that value regardless any explicit setting of
1722those arguments (or of PREFIX). INSTALLARCHLIB and INSTALLSITEARCH
1723are set to the corresponding architecture subdirectory.
bab2b58e 1724
762efda7 1725=item LIBPERL_A
1726
1727The filename of the perllibrary that will be used together with this
1728extension. Defaults to libperl.a.
1729
8e07c86e 1730=item LIBS
1731
1732An anonymous array of alternative library
1733specifications to be searched for (in order) until
864a5fa8 1734at least one library is found. E.g.
8e07c86e 1735
1736 'LIBS' => ["-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs"]
1737
1738Mind, that any element of the array
1739contains a complete set of arguments for the ld
1740command. So do not specify
1741
1742 'LIBS' => ["-ltcl", "-ltk", "-lX11"]
1743
1744See ODBM_File/Makefile.PL for an example, where an array is needed. If
1745you specify a scalar as in
1746
1747 'LIBS' => "-ltcl -ltk -lX11"
1748
1749MakeMaker will turn it into an array with one element.
1750
2977d345 1751=item LICENSE
1752
1753The licensing terms of your distribution. Generally its "perl" for the
1754same license as Perl itself.
1755
a592ba15 1756See L<Module::Build::API> for the list of options.
2977d345 1757
1758Defaults to "unknown".
1759
864a5fa8 1760=item LINKTYPE
8e07c86e 1761
e05e23b1 1762'static' or 'dynamic' (default unless usedl=undef in
1763config.sh). Should only be used to force static linking (also see
864a5fa8 1764linkext below).
8e07c86e 1765
2977d345 1766=item MAKE
1767
1768Variant of make you intend to run the generated Makefile with. This
1769parameter lets Makefile.PL know what make quirks to account for when
1770generating the Makefile.
1771
1772MakeMaker also honors the MAKE environment variable. This parameter
1773takes precedent.
1774
1775Currently the only significant values are 'dmake' and 'nmake' for Windows
1776users.
1777
1778Defaults to $Config{make}.
1779
864a5fa8 1780=item MAKEAPERL
8e07c86e 1781
864a5fa8 1782Boolean which tells MakeMaker, that it should include the rules to
1783make a perl. This is handled automatically as a switch by
1784MakeMaker. The user normally does not need it.
8e07c86e 1785
479d2113 1786=item MAKEFILE_OLD
1787
1788When 'make clean' or similar is run, the $(FIRST_MAKEFILE) will be
1789backed up at this location.
8e07c86e 1790
479d2113 1791Defaults to $(FIRST_MAKEFILE).old or $(FIRST_MAKEFILE)_old on VMS.
8e07c86e 1792
864a5fa8 1793=item MAN1PODS
8e07c86e 1794
864a5fa8 1795Hashref of pod-containing files. MakeMaker will default this to all
1796EXE_FILES files that include POD directives. The files listed
1797here will be converted to man pages and installed as was requested
1798at Configure time.
8e07c86e 1799
864a5fa8 1800=item MAN3PODS
8e07c86e 1801
bfa2a9ad 1802Hashref that assigns to *.pm and *.pod files the files into which the
1803manpages are to be written. MakeMaker parses all *.pod and *.pm files
1804for POD directives. Files that contain POD will be the default keys of
1805the MAN3PODS hashref. These will then be converted to man pages during
1806C<make> and will be installed during C<make install>.
8e07c86e 1807
864a5fa8 1808=item MAP_TARGET
8e07c86e 1809
864a5fa8 1810If it is intended, that a new perl binary be produced, this variable
1811may hold a name for that binary. Defaults to perl
8e07c86e 1812
2e65e370 1813=item META_ADD
1814
1815=item META_MERGE
1816
1817A hashrefs of items to add to the F<META.yml>.
1818
1819They differ in how they behave if they have the same key as the
1820default metadata. META_ADD will override the default value with it's
1821own. META_MERGE will merge its value with the default.
1822
1823Unless you want to override the defaults, prefer META_MERGE so as to
1824get the advantage of any future defaults.
1825
864a5fa8 1826=item MYEXTLIB
4633a7c4 1827
864a5fa8 1828If the extension links to a library that it builds set this to the
1829name of the library (see SDBM_File)
4633a7c4 1830
864a5fa8 1831=item NAME
8e07c86e 1832
864a5fa8 1833Perl module name for this extension (DBD::Oracle). This will default
1834to the directory name but should be explicitly defined in the
1835Makefile.PL.
8e07c86e 1836
864a5fa8 1837=item NEEDS_LINKING
8e07c86e 1838
a7665c5e 1839MakeMaker will figure out if an extension contains linkable code
864a5fa8 1840anywhere down the directory tree, and will set this variable
a7665c5e 1841accordingly, but you can speed it up a very little bit if you define
864a5fa8 1842this boolean variable yourself.
8e07c86e 1843
e05e23b1 1844=item NOECHO
1845
479d2113 1846Command so make does not print the literal commands its running.
1847
1848By setting it to an empty string you can generate a Makefile that
1849prints all commands. Mainly used in debugging MakeMaker itself.
1850
1851Defaults to C<@>.
e05e23b1 1852
864a5fa8 1853=item NORECURS
8e07c86e 1854
e05e23b1 1855Boolean. Attribute to inhibit descending into subdirectories.
8e07c86e 1856
1df8d179 1857=item NO_META
1858
1859When true, suppresses the generation and addition to the MANIFEST of
1860the META.yml module meta-data file during 'make distdir'.
1861
1862Defaults to false.
1863
762efda7 1864=item NO_VC
1865
a7665c5e 1866In general, any generated Makefile checks for the current version of
762efda7 1867MakeMaker and the version the Makefile was built under. If NO_VC is
1868set, the version check is neglected. Do not write this into your
1869Makefile.PL, use it interactively instead.
1870
864a5fa8 1871=item OBJECT
8e07c86e 1872
864a5fa8 1873List of object files, defaults to '$(BASEEXT)$(OBJ_EXT)', but can be a long
1874string containing all object files, e.g. "tkpBind.o
1875tkpButton.o tkpCanvas.o"
8e07c86e 1876
e35b8f9e 1877(Where BASEEXT is the last component of NAME, and OBJ_EXT is $Config{obj_ext}.)
1878
3b03c0f3 1879=item OPTIMIZE
1880
1881Defaults to C<-O>. Set it to C<-g> to turn debugging on. The flag is
1882passed to subdirectory makes.
1883
864a5fa8 1884=item PERL
8e07c86e 1885
864a5fa8 1886Perl binary for tasks that can be done by miniperl
8e07c86e 1887
da7f727a 1888=item PERL_CORE
1889
1890Set only when MakeMaker is building the extensions of the Perl core
1891distribution.
1892
864a5fa8 1893=item PERLMAINCC
005c1a0e 1894
864a5fa8 1895The call to the program that is able to compile perlmain.c. Defaults
1896to $(CC).
005c1a0e 1897
864a5fa8 1898=item PERL_ARCHLIB
005c1a0e 1899
da7f727a 1900Same as for PERL_LIB, but for architecture dependent files.
1901
1902Used only when MakeMaker is building the extensions of the Perl core
1903distribution (because normally $(PERL_ARCHLIB) is automatically in @INC,
1904and adding it would get in the way of PERL5LIB).
8e07c86e 1905
864a5fa8 1906=item PERL_LIB
8e07c86e 1907
864a5fa8 1908Directory containing the Perl library to use.
8e07c86e 1909
da7f727a 1910Used only when MakeMaker is building the extensions of the Perl core
1911distribution (because normally $(PERL_LIB) is automatically in @INC,
1912and adding it would get in the way of PERL5LIB).
1913
e35b8f9e 1914=item PERL_MALLOC_OK
1915
1916defaults to 0. Should be set to TRUE if the extension can work with
1917the memory allocation routines substituted by the Perl malloc() subsystem.
1918This should be applicable to most extensions with exceptions of those
1919
1920=over 4
1921
1922=item *
1923
1924with bugs in memory allocations which are caught by Perl's malloc();
1925
1926=item *
1927
1928which interact with the memory allocator in other ways than via
1929malloc(), realloc(), free(), calloc(), sbrk() and brk();
1930
1931=item *
1932
1933which rely on special alignment which is not provided by Perl's malloc().
1934
1935=back
1936
1937B<NOTE.> Negligence to set this flag in I<any one> of loaded extension
1938nullifies many advantages of Perl's malloc(), such as better usage of
1939system resources, error detection, memory usage reporting, catchable failure
1940of memory allocations, etc.
1941
479d2113 1942=item PERLPREFIX
1943
1944Directory under which core modules are to be installed.
1945
1946Defaults to $Config{installprefixexp} falling back to
1947$Config{installprefix}, $Config{prefixexp} or $Config{prefix} should
1948$Config{installprefixexp} not exist.
1949
1950Overridden by PREFIX.
1951
da7f727a 1952=item PERLRUN
1953
75e2e551 1954Use this instead of $(PERL) when you wish to run perl. It will set up
1955extra necessary flags for you.
f6d6199c 1956
ffbaec2a 1957=item PERLRUNINST
f6d6199c 1958
75e2e551 1959Use this instead of $(PERL) when you wish to run perl to work with
1960modules. It will add things like -I$(INST_ARCH) and other necessary
1961flags so perl can see the modules you're about to install.
f6d6199c 1962
864a5fa8 1963=item PERL_SRC
8e07c86e 1964
864a5fa8 1965Directory containing the Perl source code (use of this should be
1966avoided, it may be undefined)
8e07c86e 1967
2366100d 1968=item PERM_RW
1969
de592821 1970Desired permission for read/writable files. Defaults to C<644>.
2366100d 1971See also L<MM_Unix/perm_rw>.
1972
1973=item PERM_RWX
1974
1975Desired permission for executable files. Defaults to C<755>.
1976See also L<MM_Unix/perm_rwx>.
1977
864a5fa8 1978=item PL_FILES
8e07c86e 1979
7292dc67 1980MakeMaker can run programs to generate files for you at build time.
1981By default any file named *.PL (except Makefile.PL and Build.PL) in
1982the top level directory will be assumed to be a Perl program and run
1983passing its own basename in as an argument. For example...
1984
1985 perl foo.PL foo
1986
1987This behavior can be overridden by supplying your own set of files to
1988search. PL_FILES accepts a hash ref, the key being the file to run
1989and the value is passed in as the first argument when the PL file is run.
1990
41e5fcb0 1991 PL_FILES => {'bin/foobar.PL' => 'bin/foobar'}
7292dc67 1992
1993Would run bin/foobar.PL like this:
1994
1995 perl bin/foobar.PL bin/foobar
1996
1997If multiple files from one program are desired an array ref can be used.
1998
41e5fcb0 1999 PL_FILES => {'bin/foobar.PL' => [qw(bin/foobar1 bin/foobar2)]}
8e07c86e 2000
7292dc67 2001In this case the program will be run multiple times using each target file.
8e07c86e 2002
7292dc67 2003 perl bin/foobar.PL bin/foobar1
2004 perl bin/foobar.PL bin/foobar2
3aa35033 2005
4325052d 2006PL files are normally run B<after> pm_to_blib and include INST_LIB and
2007INST_ARCH in its C<@INC> so the just built modules can be
2008accessed... unless the PL file is making a module (or anything else in
2009PM) in which case it is run B<before> pm_to_blib and does not include
2010INST_LIB and INST_ARCH in its C<@INC>. This apparently odd behavior
2011is there for backwards compatibility (and its somewhat DWIM).
41e5fcb0 2012
8e07c86e 2013
864a5fa8 2014=item PM
8e07c86e 2015
864a5fa8 2016Hashref of .pm files and *.pl files to be installed. e.g.
8e07c86e 2017
864a5fa8 2018 {'name_of_file.pm' => '$(INST_LIBDIR)/install_as.pm'}
8e07c86e 2019
a3cb178b 2020By default this will include *.pm and *.pl and the files found in
2021the PMLIBDIRS directories. Defining PM in the
864a5fa8 2022Makefile.PL will override PMLIBDIRS.
8e07c86e 2023
864a5fa8 2024=item PMLIBDIRS
8e07c86e 2025
864a5fa8 2026Ref to array of subdirectories containing library files. Defaults to
a3cb178b 2027[ 'lib', $(BASEEXT) ]. The directories will be scanned and I<any> files
864a5fa8 2028they contain will be installed in the corresponding location in the
2029library. A libscan() method can be used to alter the behaviour.
2030Defining PM in the Makefile.PL will override PMLIBDIRS.
8e07c86e 2031
e35b8f9e 2032(Where BASEEXT is the last component of NAME.)
2033
131aa089 2034=item PM_FILTER
2035
2036A filter program, in the traditional Unix sense (input from stdin, output
2037to stdout) that is passed on each .pm file during the build (in the
2038pm_to_blib() phase). It is empty by default, meaning no filtering is done.
2039
2040Great care is necessary when defining the command if quoting needs to be
2041done. For instance, you would need to say:
2042
2043 {'PM_FILTER' => 'grep -v \\"^\\#\\"'}
2044
3c4b39be 2045to remove all the leading comments on the fly during the build. The
131aa089 2046extra \\ are necessary, unfortunately, because this variable is interpolated
2047within the context of a Perl program built on the command line, and double
2048quotes are what is used with the -e switch to build that command line. The
2049# is escaped for the Makefile, since what is going to be generated will then
2050be:
2051
2052 PM_FILTER = grep -v \"^\#\"
2053
2054Without the \\ before the #, we'd have the start of a Makefile comment,
2055and the macro would be incorrectly defined.
2056
2aea4d40 2057=item POLLUTE
2058
2059Release 5.005 grandfathered old global symbol names by providing preprocessor
a7665c5e 2060macros for extension source compatibility. As of release 5.6, these
2aea4d40 2061preprocessor definitions are not available by default. The POLLUTE flag
2062specifies that the old names should still be defined:
2063
2064 perl Makefile.PL POLLUTE=1
2065
2066Please inform the module author if this is necessary to successfully install
a7665c5e 2067a module under 5.6 or later.
2aea4d40 2068
875fa795 2069=item PPM_INSTALL_EXEC
2070
20e08411 2071Name of the executable used to run C<PPM_INSTALL_SCRIPT> below. (e.g. perl)
875fa795 2072
2073=item PPM_INSTALL_SCRIPT
2074
2075Name of the script that gets executed by the Perl Package Manager after
2076the installation of a package.
2077
864a5fa8 2078=item PREFIX
8e07c86e 2079
f6d6199c 2080This overrides all the default install locations. Man pages,
2081libraries, scripts, etc... MakeMaker will try to make an educated
2082guess about where to place things under the new PREFIX based on your
2083Config defaults. Failing that, it will fall back to a structure
2084which should be sensible for your platform.
2085
2086If you specify LIB or any INSTALL* variables they will not be effected
2087by the PREFIX.
a4260cbc 2088
b2340c53 2089=item PREREQ_FATAL
2090
2091Bool. If this parameter is true, failing to have the required modules
bfdac1b8 2092(or the right versions thereof) will be fatal. C<perl Makefile.PL>
2093will C<die> instead of simply informing the user of the missing dependencies.
b2340c53 2094
bfdac1b8 2095It is I<extremely> rare to have to use C<PREREQ_FATAL>. Its use by module
2096authors is I<strongly discouraged> and should never be used lightly.
2097Module installation tools have ways of resolving umet dependencies but
2098to do that they need a F<Makefile>. Using C<PREREQ_FATAL> breaks this.
2099That's bad.
b2340c53 2100
bfdac1b8 2101The only situation where it is appropriate is when you have
2102dependencies that are indispensible to actually I<write> a
2103F<Makefile>. For example, MakeMaker's F<Makefile.PL> needs L<File::Spec>.
2104If its not available it cannot write the F<Makefile>.
b2340c53 2105
bfdac1b8 2106Note: see L<Test::Harness> for a shortcut for stopping tests early
2107if you are missing dependencies and are afraid that users might
2108use your module with an incomplete environment.
b2340c53 2109
d5d4ec93 2110=item PREREQ_PM
2111
2112Hashref: Names of modules that need to be available to run this
2113extension (e.g. Fcntl for SDBM_File) are the keys of the hash and the
2114desired version is the value. If the required version number is 0, we
2115only check if any version is installed already.
2116
88d69b28 2117=item PREREQ_PRINT
2118
2119Bool. If this parameter is true, the prerequisites will be printed to
2c91f887 2120stdout and MakeMaker will exit. The output format is an evalable hash
2121ref.
88d69b28 2122
2123$PREREQ_PM = {
2124 'A::B' => Vers1,
2125 'C::D' => Vers2,
2126 ...
2127 };
2128
2129=item PRINT_PREREQ
2130
2131RedHatism for C<PREREQ_PRINT>. The output format is different, though:
2132
2133 perl(A::B)>=Vers1 perl(C::D)>=Vers2 ...
2134
5c161494 2135=item SITEPREFIX
2136
479d2113 2137Like PERLPREFIX, but only for the site install locations.
2138
2139Defaults to $Config{siteprefixexp}. Perls prior to 5.6.0 didn't have
2140an explicit siteprefix in the Config. In those cases
2141$Config{installprefix} will be used.
5c161494 2142
479d2113 2143Overridable by PREFIX
5c161494 2144
bb68fe9e 2145=item SIGN
2146
7292dc67 2147When true, perform the generation and addition to the MANIFEST of the
2148SIGNATURE file in the distdir during 'make distdir', via 'cpansign
2149-s'.
bb68fe9e 2150
2151Note that you need to install the Module::Signature module to
2152perform this operation.
2153
2154Defaults to false.
2155
864a5fa8 2156=item SKIP
8e07c86e 2157
da7f727a 2158Arrayref. E.g. [qw(name1 name2)] skip (do not write) sections of the
a7665c5e 2159Makefile. Caution! Do not use the SKIP attribute for the negligible
2160speedup. It may seriously damage the resulting Makefile. Only use it
f1387719 2161if you really need it.
8e07c86e 2162
864a5fa8 2163=item TYPEMAPS
8e07c86e 2164
864a5fa8 2165Ref to array of typemap file names. Use this when the typemaps are
2166in some directory other than the current directory or when they are
2167not named B<typemap>. The last typemap in the list takes
2168precedence. A typemap in the current directory has highest
2169precedence, even if it isn't listed in TYPEMAPS. The default system
2170typemap has lowest precedence.
8e07c86e 2171
5c161494 2172=item VENDORPREFIX
2173
479d2113 2174Like PERLPREFIX, but only for the vendor install locations.
2175
2176Defaults to $Config{vendorprefixexp}.
5c161494 2177
479d2113 2178Overridable by PREFIX
5c161494 2179
45bc4d3a 2180=item VERBINST
2181
2182If true, make install will be verbose
2183
864a5fa8 2184=item VERSION
8e07c86e 2185
864a5fa8 2186Your version number for distributing the package. This defaults to
21870.1.
8e07c86e 2188
0d8023a2 2189=item VERSION_FROM
2190
2191Instead of specifying the VERSION in the Makefile.PL you can let
2192MakeMaker parse a file to determine the version number. The parsing
2193routine requires that the file named by VERSION_FROM contains one
2194single line to compute the version number. The first line in the file
2195that contains the regular expression
2196
84902520 2197 /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/
0d8023a2 2198
2199will be evaluated with eval() and the value of the named variable
2200B<after> the eval() will be assigned to the VERSION attribute of the
2201MakeMaker object. The following lines will be parsed o.k.:
2202
a592ba15 2203 $VERSION = '1.00';
2204 *VERSION = \'1.01';
2e65e370 2205 ($VERSION) = q$Revision: 66493 $ =~ /(\d+)/g;
0d8023a2 2206 $FOO::VERSION = '1.10';
84902520 2207 *FOO::VERSION = \'1.11';
0d8023a2 2208
2209but these will fail:
2210
a592ba15 2211 # Bad
2212 my $VERSION = '1.01';
2213 local $VERSION = '1.02';
0d8023a2 2214 local $FOO::VERSION = '1.30';
2215
a592ba15 2216"Version strings" are incompatible should not be used.
bfdac1b8 2217
a592ba15 2218 # Bad
2219 $VERSION = 1.2.3;
2220 $VERSION = v1.2.3;
bfdac1b8 2221
a592ba15 2222L<version> objects are fine. As of MakeMaker 6.35 version.pm will be
2223automatically loaded, but you must declare the dependency on version.pm.
2224For compatibility with older MakeMaker you should load on the same line
2225as $VERSION is declared.
bfdac1b8 2226
2227 # All on one line
2228 use version; our $VERSION = qv(1.2.3);
2229
e35b8f9e 2230(Putting C<my> or C<local> on the preceding line will work o.k.)
2231
84902520 2232The file named in VERSION_FROM is not added as a dependency to
2233Makefile. This is not really correct, but it would be a major pain
2234during development to have to rewrite the Makefile for any smallish
2235change in that file. If you want to make sure that the Makefile
2236contains the correct VERSION macro after any change of the file, you
2237would have to do something like
2238
2239 depend => { Makefile => '$(VERSION_FROM)' }
2240
2241See attribute C<depend> below.
0d8023a2 2242
479d2113 2243=item VERSION_SYM
2244
2245A sanitized VERSION with . replaced by _. For places where . has
2246special meaning (some filesystems, RCS labels, etc...)
2247
864a5fa8 2248=item XS
8e07c86e 2249
864a5fa8 2250Hashref of .xs files. MakeMaker will default this. e.g.
8e07c86e 2251
864a5fa8 2252 {'name_of_file.xs' => 'name_of_file.c'}
8e07c86e 2253
864a5fa8 2254The .c files will automatically be included in the list of files
2255deleted by a make clean.
4633a7c4 2256
864a5fa8 2257=item XSOPT
8e07c86e 2258
864a5fa8 2259String of options to pass to xsubpp. This might include C<-C++> or
2260C<-extern>. Do not include typemaps here; the TYPEMAP parameter exists for
2261that purpose.
8e07c86e 2262
864a5fa8 2263=item XSPROTOARG
4633a7c4 2264
4e68a208 2265May be set to an empty string, which is identical to C<-prototypes>, or
864a5fa8 2266C<-noprototypes>. See the xsubpp documentation for details. MakeMaker
4e68a208 2267defaults to the empty string.
2268
0d8023a2 2269=item XS_VERSION
2270
2271Your version number for the .xs file of this package. This defaults
2272to the value of the VERSION attribute.
2273
8e07c86e 2274=back
2275
2276=head2 Additional lowercase attributes
2277
2278can be used to pass parameters to the methods which implement that
531e2ba1 2279part of the Makefile. Parameters are specified as a hash ref but are
2280passed to the method as a hash.
8e07c86e 2281
2282=over 2
2283
864a5fa8 2284=item clean
8e07c86e 2285
864a5fa8 2286 {FILES => "*.xyz foo"}
2287
c07a80fd 2288=item depend
2289
3c4b39be 2290 {ANY_TARGET => ANY_DEPENDENCY, ...}
c07a80fd 2291
e35b8f9e 2292(ANY_TARGET must not be given a double-colon rule by MakeMaker.)
2293
864a5fa8 2294=item dist
2295
5f8e730b 2296 {TARFLAGS => 'cvfF', COMPRESS => 'gzip', SUFFIX => '.gz',
3b03c0f3 2297 SHAR => 'shar -m', DIST_CP => 'ln', ZIP => '/bin/zip',
f1387719 2298 ZIPFLAGS => '-rl', DIST_DEFAULT => 'private tardist' }
864a5fa8 2299
2300If you specify COMPRESS, then SUFFIX should also be altered, as it is
2301needed to tell make the target file of the compression. Setting
2302DIST_CP to ln can be useful, if you need to preserve the timestamps on
2303your files. DIST_CP can take the values 'cp', which copies the file,
2304'ln', which links the file, and 'best' which copies symbolic links and
2305links the rest. Default is 'best'.
2306
2307=item dynamic_lib
2308
0d8023a2 2309 {ARMAYBE => 'ar', OTHERLDFLAGS => '...', INST_DYNAMIC_DEP => '...'}
8e07c86e 2310
8e07c86e 2311=item linkext
2312
2313 {LINKTYPE => 'static', 'dynamic' or ''}
2314
864a5fa8 2315NB: Extensions that have nothing but *.pm files had to say
8e07c86e 2316
2317 {LINKTYPE => ''}
2318
864a5fa8 2319with Pre-5.0 MakeMakers. Since version 5.00 of MakeMaker such a line
a7665c5e 2320can be deleted safely. MakeMaker recognizes when there's nothing to
864a5fa8 2321be linked.
8e07c86e 2322
864a5fa8 2323=item macro
8e07c86e 2324
864a5fa8 2325 {ANY_MACRO => ANY_VALUE, ...}
8e07c86e 2326
531e2ba1 2327=item postamble
2328
2329Anything put here will be passed to MY::postamble() if you have one.
2330
8e07c86e 2331=item realclean
2332
2333 {FILES => '$(INST_ARCHAUTODIR)/*.xyz'}
2334
f2f614a6 2335=item test
2336
2337 {TESTS => 't/*.t'}
2338
8e07c86e 2339=item tool_autosplit
2340
f2f614a6 2341 {MAXLEN => 8}
005c1a0e 2342
2343=back
2344
2345=head2 Overriding MakeMaker Methods
2346
2347If you cannot achieve the desired Makefile behaviour by specifying
2348attributes you may define private subroutines in the Makefile.PL.
e0678a30 2349Each subroutine returns the text it wishes to have written to
005c1a0e 2350the Makefile. To override a section of the Makefile you can
2351either say:
2352
f6d6199c 2353 sub MY::c_o { "new literal text" }
005c1a0e 2354
2355or you can edit the default by saying something like:
2356
e0678a30 2357 package MY; # so that "SUPER" works right
2358 sub c_o {
f6d6199c 2359 my $inherited = shift->SUPER::c_o(@_);
2360 $inherited =~ s/old text/new text/;
2361 $inherited;
2362 }
8e07c86e 2363
bdda3fbd 2364If you are running experiments with embedding perl as a library into
2365other applications, you might find MakeMaker is not sufficient. You'd
2366better have a look at ExtUtils::Embed which is a collection of utilities
2367for embedding.
005c1a0e 2368
2369If you still need a different solution, try to develop another
bdda3fbd 2370subroutine that fits your needs and submit the diffs to
a7d1454b 2371C<makemaker@perl.org>
005c1a0e 2372
e0678a30 2373For a complete description of all MakeMaker methods see
2374L<ExtUtils::MM_Unix>.
3b03c0f3 2375
2376Here is a simple example of how to add a new target to the generated
2377Makefile:
2378
2379 sub MY::postamble {
e0678a30 2380 return <<'MAKE_FRAG';
3b03c0f3 2381 $(MYEXTLIB): sdbm/Makefile
f6d6199c 2382 cd sdbm && $(MAKE) all
e0678a30 2383
2384 MAKE_FRAG
3b03c0f3 2385 }
2386
a884ca7c 2387=head2 The End Of Cargo Cult Programming
2388
2389WriteMakefile() now does some basic sanity checks on its parameters to
2390protect against typos and malformatted values. This means some things
2391which happened to work in the past will now throw warnings and
2392possibly produce internal errors.
2393
2394Some of the most common mistakes:
2395
2396=over 2
2397
76ca89ed 2398=item C<< MAN3PODS => ' ' >>
a884ca7c 2399
3c4b39be 2400This is commonly used to suppress the creation of man pages. MAN3PODS
a884ca7c 2401takes a hash ref not a string, but the above worked by accident in old
2402versions of MakeMaker.
2403
76ca89ed 2404The correct code is C<< MAN3PODS => { } >>.
a884ca7c 2405
2406=back
2407
3b03c0f3 2408
f1387719 2409=head2 Hintsfile support
2410
2411MakeMaker.pm uses the architecture specific information from
2412Config.pm. In addition it evaluates architecture specific hints files
2413in a C<hints/> directory. The hints files are expected to be named
2414like their counterparts in C<PERL_SRC/hints>, but with an C<.pl> file
2415name extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by
2416MakeMaker within the WriteMakefile() subroutine, and can be used to
2417execute commands as well as to include special variables. The rules
2418which hintsfile is chosen are the same as in Configure.
2419
2420The hintsfile is eval()ed immediately after the arguments given to
2421WriteMakefile are stuffed into a hash reference $self but before this
2422reference becomes blessed. So if you want to do the equivalent to
2423override or create an attribute you would say something like
2424
2425 $self->{LIBS} = ['-ldbm -lucb -lc'];
2426
005c1a0e 2427=head2 Distribution Support
2428
2429For authors of extensions MakeMaker provides several Makefile
2430targets. Most of the support comes from the ExtUtils::Manifest module,
2431where additional documentation can be found.
2432
2433=over 4
2434
2435=item make distcheck
8e07c86e 2436
005c1a0e 2437reports which files are below the build directory but not in the
2438MANIFEST file and vice versa. (See ExtUtils::Manifest::fullcheck() for
2439details)
2440
4633a7c4 2441=item make skipcheck
2442
2443reports which files are skipped due to the entries in the
2444C<MANIFEST.SKIP> file (See ExtUtils::Manifest::skipcheck() for
2445details)
2446
005c1a0e 2447=item make distclean
8e07c86e 2448
005c1a0e 2449does a realclean first and then the distcheck. Note that this is not
a7665c5e 2450needed to build a new distribution as long as you are sure that the
005c1a0e 2451MANIFEST file is ok.
2452
2453=item make manifest
8e07c86e 2454
005c1a0e 2455rewrites the MANIFEST file, adding all remaining files found (See
2456ExtUtils::Manifest::mkmanifest() for details)
2457
2458=item make distdir
8e07c86e 2459
005c1a0e 2460Copies all the files that are in the MANIFEST file to a newly created
2461directory with the name C<$(DISTNAME)-$(VERSION)>. If that directory
2462exists, it will be removed first.
2463
7292dc67 2464Additionally, it will create a META.yml module meta-data file in the
bfdac1b8 2465distdir and add this to the distdir's MANIFEST. You can shut this
7292dc67 2466behavior off with the NO_META flag.
1df8d179 2467
f6d6199c 2468=item make disttest
8e07c86e 2469
2470Makes a distdir first, and runs a C<perl Makefile.PL>, a make, and
4633a7c4 2471a make test in that directory.
8e07c86e 2472
005c1a0e 2473=item make tardist
8e07c86e 2474
3b03c0f3 2475First does a distdir. Then a command $(PREOP) which defaults to a null
bfdac1b8 2476command, followed by $(TO_UNIX), which defaults to a null command under
f1387719 2477UNIX, and will convert files in distribution directory to UNIX format
2478otherwise. Next it runs C<tar> on that directory into a tarfile and
3b03c0f3 2479deletes the directory. Finishes with a command $(POSTOP) which
2480defaults to a null command.
005c1a0e 2481
2482=item make dist
8e07c86e 2483
005c1a0e 2484Defaults to $(DIST_DEFAULT) which in turn defaults to tardist.
2485
2486=item make uutardist
8e07c86e 2487
005c1a0e 2488Runs a tardist first and uuencodes the tarfile.
2489
2490=item make shdist
8e07c86e 2491
3b03c0f3 2492First does a distdir. Then a command $(PREOP) which defaults to a null
2493command. Next it runs C<shar> on that directory into a sharfile and
2494deletes the intermediate directory again. Finishes with a command
2495$(POSTOP) which defaults to a null command. Note: For shdist to work
2496properly a C<shar> program that can handle directories is mandatory.
2497
2498=item make zipdist
2499
2500First does a distdir. Then a command $(PREOP) which defaults to a null
2501command. Runs C<$(ZIP) $(ZIPFLAGS)> on that directory into a
2502zipfile. Then deletes that directory. Finishes with a command
2503$(POSTOP) which defaults to a null command.
005c1a0e 2504
2505=item make ci
8e07c86e 2506
2507Does a $(CI) and a $(RCS_LABEL) on all files in the MANIFEST file.
2508
2509=back
005c1a0e 2510
2511Customization of the dist targets can be done by specifying a hash
2512reference to the dist attribute of the WriteMakefile call. The
2513following parameters are recognized:
2514
8e07c86e 2515 CI ('ci -u')
5f8e730b 2516 COMPRESS ('gzip --best')
005c1a0e 2517 POSTOP ('@ :')
8e07c86e 2518 PREOP ('@ :')
f1387719 2519 TO_UNIX (depends on the system)
8e07c86e 2520 RCS_LABEL ('rcs -q -Nv$(VERSION_SYM):')
2521 SHAR ('shar')
5f8e730b 2522 SUFFIX ('.gz')
8e07c86e 2523 TAR ('tar')
2524 TARFLAGS ('cvf')
3b03c0f3 2525 ZIP ('zip')
2526 ZIPFLAGS ('-r')
005c1a0e 2527
2528An example:
2529
5f8e730b 2530 WriteMakefile( 'dist' => { COMPRESS=>"bzip2", SUFFIX=>".bz2" })
005c1a0e 2531
1df8d179 2532
2533=head2 Module Meta-Data
2534
2535Long plaguing users of MakeMaker based modules has been the problem of
2536getting basic information about the module out of the sources
2537I<without> running the F<Makefile.PL> and doing a bunch of messy
2538heuristics on the resulting F<Makefile>. To this end a simple module
2539meta-data file has been introduced, F<META.yml>.
2540
2541F<META.yml> is a YAML document (see http://www.yaml.org) containing
2542basic information about the module (name, version, prerequisites...)
2543in an easy to read format. The format is developed and defined by the
64964e6d 2544Module::Build developers (see
2545http://module-build.sourceforge.net/META-spec.html)
1df8d179 2546
2547MakeMaker will automatically generate a F<META.yml> file for you and
2548add it to your F<MANIFEST> as part of the 'distdir' target (and thus
2549the 'dist' target). This is intended to seamlessly and rapidly
2550populate CPAN with module meta-data. If you wish to shut this feature
2551off, set the C<NO_META> C<WriteMakefile()> flag to true.
2552
2553
1b171b8d 2554=head2 Disabling an extension
2555
2556If some events detected in F<Makefile.PL> imply that there is no way
2557to create the Module, but this is a normal state of things, then you
2558can create a F<Makefile> which does nothing, but succeeds on all the
2559"usual" build targets. To do so, use
2560
1e65eb70 2561 use ExtUtils::MakeMaker qw(WriteEmptyMakefile);
2562 WriteEmptyMakefile();
1b171b8d 2563
2564instead of WriteMakefile().
2565
2566This may be useful if other modules expect this module to be I<built>
2567OK, as opposed to I<work> OK (say, this system-dependent module builds
2568in a subdirectory of some other distribution, or is listed as a
2569dependency in a CPAN::Bundle, but the functionality is supported by
2570different means on the current architecture).
2571
479d2113 2572=head2 Other Handy Functions
2573
2574=over 4
2575
2576=item prompt
2577
2578 my $value = prompt($message);
2579 my $value = prompt($message, $default);
2580
2581The C<prompt()> function provides an easy way to request user input
2582used to write a makefile. It displays the $message as a prompt for
2583input. If a $default is provided it will be used as a default. The
2584function returns the $value selected by the user.
2585
2586If C<prompt()> detects that it is not running interactively and there
2587is nothing on STDIN or if the PERL_MM_USE_DEFAULT environment variable
2588is set to true, the $default will be used without prompting. This
2589prevents automated processes from blocking on user input.
2590
2591If no $default is provided an empty string will be used instead.
2592
2593=back
2594
2595
6ce21ffa 2596=head1 ENVIRONMENT
2597
479d2113 2598=over 4
6ce21ffa 2599
2443aee5 2600=item PERL_MM_OPT
6ce21ffa 2601
2602Command line options used by C<MakeMaker-E<gt>new()>, and thus by
2603C<WriteMakefile()>. The string is split on whitespace, and the result
2604is processed before any actual command line arguments are processed.
2605
9d05ba64 2606=item PERL_MM_USE_DEFAULT
2607
2608If set to a true value then MakeMaker's prompt function will
2609always return the default without waiting for user input.
2610
41e5fcb0 2611=item PERL_CORE
2612
2613Same as the PERL_CORE parameter. The parameter overrides this.
2614
6ce21ffa 2615=back
2616
f1387719 2617=head1 SEE ALSO
2618
562c8117 2619L<Module::Build> is a pure-Perl alternative to MakeMaker which does
2620not rely on make or any other external utility. It is easier to
2621extend to suit your needs.
2622
2623L<Module::Install> is a wrapper around MakeMaker which adds features
2624not normally available.
2625
2626L<ExtUtils::ModuleMaker> and L<Module::Starter> are both modules to
2627help you setup your distribution.
005c1a0e 2628
e05e23b1 2629=head1 AUTHORS
fed7345c 2630
a7d1454b 2631Andy Dougherty C<doughera@lafayette.edu>, Andreas KE<ouml>nig
2632C<andreas.koenig@mind.de>, Tim Bunce C<timb@cpan.org>. VMS
2633support by Charles Bailey C<bailey@newman.upenn.edu>. OS/2 support
2634by Ilya Zakharevich C<ilya@math.ohio-state.edu>.
de90321e 2635
a7d1454b 2636Currently maintained by Michael G Schwern C<schwern@pobox.com>
f6d6199c 2637
a7d1454b 2638Send patches and ideas to C<makemaker@perl.org>.
e8012c20 2639
e0678a30 2640Send bug reports via http://rt.cpan.org/. Please send your
2641generated Makefile along with your report.
2642
a7d1454b 2643For more up-to-date information, see L<http://www.makemaker.org>.
fed7345c 2644
479d2113 2645=head1 LICENSE
2646
2647This program is free software; you can redistribute it and/or
2648modify it under the same terms as Perl itself.
2649
a7d1454b 2650See L<http://www.perl.com/perl/misc/Artistic.html>
479d2113 2651
2652
005c1a0e 2653=cut