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