1package ExtUtils::MM_Unix; 2 3require 5.006; 4 5use strict; 6 7use Carp; 8use ExtUtils::MakeMaker::Config; 9use File::Basename qw(basename dirname); 10use DirHandle; 11 12our %Config_Override; 13 14use ExtUtils::MakeMaker qw($Verbose neatvalue); 15 16# If we make $VERSION an our variable parse_version() breaks 17use vars qw($VERSION); 18$VERSION = '6.98'; 19$VERSION = eval $VERSION; ## no critic [BuiltinFunctions::ProhibitStringyEval] 20 21require ExtUtils::MM_Any; 22our @ISA = qw(ExtUtils::MM_Any); 23 24my %Is; 25BEGIN { 26 $Is{OS2} = $^O eq 'os2'; 27 $Is{Win32} = $^O eq 'MSWin32' || $Config{osname} eq 'NetWare'; 28 $Is{Dos} = $^O eq 'dos'; 29 $Is{VMS} = $^O eq 'VMS'; 30 $Is{OSF} = $^O eq 'dec_osf'; 31 $Is{IRIX} = $^O eq 'irix'; 32 $Is{NetBSD} = $^O eq 'netbsd'; 33 $Is{Interix} = $^O eq 'interix'; 34 $Is{SunOS4} = $^O eq 'sunos'; 35 $Is{Solaris} = $^O eq 'solaris'; 36 $Is{SunOS} = $Is{SunOS4} || $Is{Solaris}; 37 $Is{BSD} = ($^O =~ /^(?:free|net|open)bsd$/ or 38 grep( $^O eq $_, qw(bsdos interix dragonfly) ) 39 ); 40 $Is{Android} = $^O =~ /android/; 41} 42 43BEGIN { 44 if( $Is{VMS} ) { 45 # For things like vmsify() 46 require VMS::Filespec; 47 VMS::Filespec->import; 48 } 49} 50 51 52=head1 NAME 53 54ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker 55 56=head1 SYNOPSIS 57 58C<require ExtUtils::MM_Unix;> 59 60=head1 DESCRIPTION 61 62The methods provided by this package are designed to be used in 63conjunction with ExtUtils::MakeMaker. When MakeMaker writes a 64Makefile, it creates one or more objects that inherit their methods 65from a package C<MM>. MM itself doesn't provide any methods, but it 66ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating 67specific packages take the responsibility for all the methods provided 68by MM_Unix. We are trying to reduce the number of the necessary 69overrides by defining rather primitive operations within 70ExtUtils::MM_Unix. 71 72If you are going to write a platform specific MM package, please try 73to limit the necessary overrides to primitive methods, and if it is not 74possible to do so, let's work out how to achieve that gain. 75 76If you are overriding any of these methods in your Makefile.PL (in the 77MY class), please report that to the makemaker mailing list. We are 78trying to minimize the necessary method overrides and switch to data 79driven Makefile.PLs wherever possible. In the long run less methods 80will be overridable via the MY class. 81 82=head1 METHODS 83 84The following description of methods is still under 85development. Please refer to the code for not suitably documented 86sections and complain loudly to the makemaker@perl.org mailing list. 87Better yet, provide a patch. 88 89Not all of the methods below are overridable in a 90Makefile.PL. Overridable methods are marked as (o). All methods are 91overridable by a platform specific MM_*.pm file. 92 93Cross-platform methods are being moved into MM_Any. If you can't find 94something that used to be in here, look in MM_Any. 95 96=cut 97 98# So we don't have to keep calling the methods over and over again, 99# we have these globals to cache the values. Faster and shrtr. 100my $Curdir = __PACKAGE__->curdir; 101my $Rootdir = __PACKAGE__->rootdir; 102my $Updir = __PACKAGE__->updir; 103 104 105=head2 Methods 106 107=over 4 108 109=item os_flavor 110 111Simply says that we're Unix. 112 113=cut 114 115sub os_flavor { 116 return('Unix'); 117} 118 119 120=item c_o (o) 121 122Defines the suffix rules to compile different flavors of C files to 123object files. 124 125=cut 126 127sub c_o { 128# --- Translation Sections --- 129 130 my($self) = shift; 131 return '' unless $self->needs_linking(); 132 my(@m); 133 134 my $command = '$(CCCMD)'; 135 my $flags = '$(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE)'; 136 137 if (my $cpp = $Config{cpprun}) { 138 my $cpp_cmd = $self->const_cccmd; 139 $cpp_cmd =~ s/^CCCMD\s*=\s*\$\(CC\)/$cpp/; 140 push @m, qq{ 141.c.i: 142 $cpp_cmd $flags \$*.c > \$*.i 143}; 144 } 145 146 push @m, qq{ 147.c.s: 148 $command -S $flags \$*.c 149 150.c\$(OBJ_EXT): 151 $command $flags \$*.c 152 153.cpp\$(OBJ_EXT): 154 $command $flags \$*.cpp 155 156.cxx\$(OBJ_EXT): 157 $command $flags \$*.cxx 158 159.cc\$(OBJ_EXT): 160 $command $flags \$*.cc 161}; 162 163 push @m, qq{ 164.C\$(OBJ_EXT): 165 $command $flags \$*.C 166} if !$Is{OS2} and !$Is{Win32} and !$Is{Dos}; #Case-specific 167 168 return join "", @m; 169} 170 171=item cflags (o) 172 173Does very much the same as the cflags script in the perl 174distribution. It doesn't return the whole compiler command line, but 175initializes all of its parts. The const_cccmd method then actually 176returns the definition of the CCCMD macro which uses these parts. 177 178=cut 179 180#' 181 182sub cflags { 183 my($self,$libperl)=@_; 184 return $self->{CFLAGS} if $self->{CFLAGS}; 185 return '' unless $self->needs_linking(); 186 187 my($prog, $uc, $perltype, %cflags); 188 $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ; 189 $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/; 190 191 @cflags{qw(cc ccflags optimize shellflags)} 192 = @Config{qw(cc ccflags optimize shellflags)}; 193 my($optdebug) = ""; 194 195 $cflags{shellflags} ||= ''; 196 197 my(%map) = ( 198 D => '-DDEBUGGING', 199 E => '-DEMBED', 200 DE => '-DDEBUGGING -DEMBED', 201 M => '-DEMBED -DMULTIPLICITY', 202 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY', 203 ); 204 205 if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){ 206 $uc = uc($1); 207 } else { 208 $uc = ""; # avoid warning 209 } 210 $perltype = $map{$uc} ? $map{$uc} : ""; 211 212 if ($uc =~ /^D/) { 213 $optdebug = "-g"; 214 } 215 216 217 my($name); 218 ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ; 219 if ($prog = $Config{$name}) { 220 # Expand hints for this extension via the shell 221 print "Processing $name hint:\n" if $Verbose; 222 my(@o)=`cc=\"$cflags{cc}\" 223 ccflags=\"$cflags{ccflags}\" 224 optimize=\"$cflags{optimize}\" 225 perltype=\"$cflags{perltype}\" 226 optdebug=\"$cflags{optdebug}\" 227 eval '$prog' 228 echo cc=\$cc 229 echo ccflags=\$ccflags 230 echo optimize=\$optimize 231 echo perltype=\$perltype 232 echo optdebug=\$optdebug 233 `; 234 foreach my $line (@o){ 235 chomp $line; 236 if ($line =~ /(.*?)=\s*(.*)\s*$/){ 237 $cflags{$1} = $2; 238 print " $1 = $2\n" if $Verbose; 239 } else { 240 print "Unrecognised result from hint: '$line'\n"; 241 } 242 } 243 } 244 245 if ($optdebug) { 246 $cflags{optimize} = $optdebug; 247 } 248 249 for (qw(ccflags optimize perltype)) { 250 $cflags{$_} ||= ''; 251 $cflags{$_} =~ s/^\s+//; 252 $cflags{$_} =~ s/\s+/ /g; 253 $cflags{$_} =~ s/\s+$//; 254 $self->{uc $_} ||= $cflags{$_}; 255 } 256 257 if ($self->{POLLUTE}) { 258 $self->{CCFLAGS} .= ' -DPERL_POLLUTE '; 259 } 260 261 my $pollute = ''; 262 if ($Config{usemymalloc} and not $Config{bincompat5005} 263 and not $Config{ccflags} =~ /-DPERL_POLLUTE_MALLOC\b/ 264 and $self->{PERL_MALLOC_OK}) { 265 $pollute = '$(PERL_MALLOC_DEF)'; 266 } 267 268 $self->{CCFLAGS} = quote_paren($self->{CCFLAGS}); 269 $self->{OPTIMIZE} = quote_paren($self->{OPTIMIZE}); 270 271 return $self->{CFLAGS} = qq{ 272CCFLAGS = $self->{CCFLAGS} 273OPTIMIZE = $self->{OPTIMIZE} 274PERLTYPE = $self->{PERLTYPE} 275MPOLLUTE = $pollute 276}; 277 278} 279 280 281=item const_cccmd (o) 282 283Returns the full compiler call for C programs and stores the 284definition in CONST_CCCMD. 285 286=cut 287 288sub const_cccmd { 289 my($self,$libperl)=@_; 290 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD}; 291 return '' unless $self->needs_linking(); 292 return $self->{CONST_CCCMD} = 293 q{CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \\ 294 $(CCFLAGS) $(OPTIMIZE) \\ 295 $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\ 296 $(XS_DEFINE_VERSION)}; 297} 298 299=item const_config (o) 300 301Defines a couple of constants in the Makefile that are imported from 302%Config. 303 304=cut 305 306sub const_config { 307# --- Constants Sections --- 308 309 my($self) = shift; 310 my @m = <<"END"; 311 312# These definitions are from config.sh (via $INC{'Config.pm'}). 313# They may have been overridden via Makefile.PL or on the command line. 314END 315 316 my(%once_only); 317 foreach my $key (@{$self->{CONFIG}}){ 318 # SITE*EXP macros are defined in &constants; avoid duplicates here 319 next if $once_only{$key}; 320 $self->{uc $key} = quote_paren($self->{uc $key}); 321 push @m, uc($key) , ' = ' , $self->{uc $key}, "\n"; 322 $once_only{$key} = 1; 323 } 324 join('', @m); 325} 326 327=item const_loadlibs (o) 328 329Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. See 330L<ExtUtils::Liblist> for details. 331 332=cut 333 334sub const_loadlibs { 335 my($self) = shift; 336 return "" unless $self->needs_linking; 337 my @m; 338 push @m, qq{ 339# $self->{NAME} might depend on some other libraries: 340# See ExtUtils::Liblist for details 341# 342}; 343 for my $tmp (qw/ 344 EXTRALIBS LDLOADLIBS BSLOADLIBS 345 /) { 346 next unless defined $self->{$tmp}; 347 push @m, "$tmp = $self->{$tmp}\n"; 348 } 349 # don't set LD_RUN_PATH if empty 350 for my $tmp (qw/ 351 LD_RUN_PATH 352 /) { 353 next unless $self->{$tmp}; 354 push @m, "$tmp = $self->{$tmp}\n"; 355 } 356 return join "", @m; 357} 358 359=item constants (o) 360 361 my $make_frag = $mm->constants; 362 363Prints out macros for lots of constants. 364 365=cut 366 367sub constants { 368 my($self) = @_; 369 my @m = (); 370 371 $self->{DFSEP} = '$(DIRFILESEP)'; # alias for internal use 372 373 for my $macro (qw( 374 375 AR_STATIC_ARGS DIRFILESEP DFSEP 376 NAME NAME_SYM 377 VERSION VERSION_MACRO VERSION_SYM DEFINE_VERSION 378 XS_VERSION XS_VERSION_MACRO XS_DEFINE_VERSION 379 INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB 380 INST_MAN1DIR INST_MAN3DIR 381 MAN1EXT MAN3EXT 382 INSTALLDIRS INSTALL_BASE DESTDIR PREFIX 383 PERLPREFIX SITEPREFIX VENDORPREFIX 384 ), 385 (map { ("INSTALL".$_, 386 "DESTINSTALL".$_) 387 } $self->installvars), 388 qw( 389 PERL_LIB 390 PERL_ARCHLIB 391 LIBPERL_A MYEXTLIB 392 FIRST_MAKEFILE MAKEFILE_OLD MAKE_APERL_FILE 393 PERLMAINCC PERL_SRC PERL_INC 394 PERL FULLPERL ABSPERL 395 PERLRUN FULLPERLRUN ABSPERLRUN 396 PERLRUNINST FULLPERLRUNINST ABSPERLRUNINST 397 PERL_CORE 398 PERM_DIR PERM_RW PERM_RWX 399 400 ) ) 401 { 402 next unless defined $self->{$macro}; 403 404 # pathnames can have sharp signs in them; escape them so 405 # make doesn't think it is a comment-start character. 406 $self->{$macro} =~ s/#/\\#/g; 407 push @m, "$macro = $self->{$macro}\n"; 408 } 409 410 push @m, qq{ 411MAKEMAKER = $self->{MAKEMAKER} 412MM_VERSION = $self->{MM_VERSION} 413MM_REVISION = $self->{MM_REVISION} 414}; 415 416 push @m, q{ 417# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). 418# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) 419# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) 420# DLBASE = Basename part of dynamic library. May be just equal BASEEXT. 421}; 422 423 for my $macro (qw/ 424 MAKE 425 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT 426 LDFROM LINKTYPE BOOTDEP 427 / ) 428 { 429 next unless defined $self->{$macro}; 430 push @m, "$macro = $self->{$macro}\n"; 431 } 432 433 push @m, " 434# Handy lists of source code files: 435XS_FILES = ".$self->wraplist(sort keys %{$self->{XS}})." 436C_FILES = ".$self->wraplist(@{$self->{C}})." 437O_FILES = ".$self->wraplist(@{$self->{O_FILES}})." 438H_FILES = ".$self->wraplist(@{$self->{H}})." 439MAN1PODS = ".$self->wraplist(sort keys %{$self->{MAN1PODS}})." 440MAN3PODS = ".$self->wraplist(sort keys %{$self->{MAN3PODS}})." 441"; 442 443 444 push @m, q{ 445# Where is the Config information that we are using/depend on 446CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h 447} if -e File::Spec->catfile( $self->{PERL_INC}, 'config.h' ); 448 449 450 push @m, qq{ 451# Where to build things 452INST_LIBDIR = $self->{INST_LIBDIR} 453INST_ARCHLIBDIR = $self->{INST_ARCHLIBDIR} 454 455INST_AUTODIR = $self->{INST_AUTODIR} 456INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR} 457 458INST_STATIC = $self->{INST_STATIC} 459INST_DYNAMIC = $self->{INST_DYNAMIC} 460INST_BOOT = $self->{INST_BOOT} 461}; 462 463 464 push @m, qq{ 465# Extra linker info 466EXPORT_LIST = $self->{EXPORT_LIST} 467PERL_ARCHIVE = $self->{PERL_ARCHIVE} 468PERL_ARCHIVE_AFTER = $self->{PERL_ARCHIVE_AFTER} 469}; 470 471 push @m, " 472 473TO_INST_PM = ".$self->wraplist(sort keys %{$self->{PM}})." 474 475PM_TO_BLIB = ".$self->wraplist(map { ($_ => $self->{PM}->{$_}) } sort keys %{$self->{PM}})." 476"; 477 478 join('',@m); 479} 480 481 482=item depend (o) 483 484Same as macro for the depend attribute. 485 486=cut 487 488sub depend { 489 my($self,%attribs) = @_; 490 my(@m,$key,$val); 491 while (($key,$val) = each %attribs){ 492 last unless defined $key; 493 push @m, "$key : $val\n"; 494 } 495 join "", @m; 496} 497 498 499=item init_DEST 500 501 $mm->init_DEST 502 503Defines the DESTDIR and DEST* variables paralleling the INSTALL*. 504 505=cut 506 507sub init_DEST { 508 my $self = shift; 509 510 # Initialize DESTDIR 511 $self->{DESTDIR} ||= ''; 512 513 # Make DEST variables. 514 foreach my $var ($self->installvars) { 515 my $destvar = 'DESTINSTALL'.$var; 516 $self->{$destvar} ||= '$(DESTDIR)$(INSTALL'.$var.')'; 517 } 518} 519 520 521=item init_dist 522 523 $mm->init_dist; 524 525Defines a lot of macros for distribution support. 526 527 macro description default 528 529 TAR tar command to use tar 530 TARFLAGS flags to pass to TAR cvf 531 532 ZIP zip command to use zip 533 ZIPFLAGS flags to pass to ZIP -r 534 535 COMPRESS compression command to gzip --best 536 use for tarfiles 537 SUFFIX suffix to put on .gz 538 compressed files 539 540 SHAR shar command to use shar 541 542 PREOP extra commands to run before 543 making the archive 544 POSTOP extra commands to run after 545 making the archive 546 547 TO_UNIX a command to convert linefeeds 548 to Unix style in your archive 549 550 CI command to checkin your ci -u 551 sources to version control 552 RCS_LABEL command to label your sources rcs -Nv$(VERSION_SYM): -q 553 just after CI is run 554 555 DIST_CP $how argument to manicopy() best 556 when the distdir is created 557 558 DIST_DEFAULT default target to use to tardist 559 create a distribution 560 561 DISTVNAME name of the resulting archive $(DISTNAME)-$(VERSION) 562 (minus suffixes) 563 564=cut 565 566sub init_dist { 567 my $self = shift; 568 569 $self->{TAR} ||= 'tar'; 570 $self->{TARFLAGS} ||= 'cvf'; 571 $self->{ZIP} ||= 'zip'; 572 $self->{ZIPFLAGS} ||= '-r'; 573 $self->{COMPRESS} ||= 'gzip --best'; 574 $self->{SUFFIX} ||= '.gz'; 575 $self->{SHAR} ||= 'shar'; 576 $self->{PREOP} ||= '$(NOECHO) $(NOOP)'; # eg update MANIFEST 577 $self->{POSTOP} ||= '$(NOECHO) $(NOOP)'; # eg remove the distdir 578 $self->{TO_UNIX} ||= '$(NOECHO) $(NOOP)'; 579 580 $self->{CI} ||= 'ci -u'; 581 $self->{RCS_LABEL}||= 'rcs -Nv$(VERSION_SYM): -q'; 582 $self->{DIST_CP} ||= 'best'; 583 $self->{DIST_DEFAULT} ||= 'tardist'; 584 585 ($self->{DISTNAME} = $self->{NAME}) =~ s{::}{-}g unless $self->{DISTNAME}; 586 $self->{DISTVNAME} ||= $self->{DISTNAME}.'-'.$self->{VERSION}; 587} 588 589=item dist (o) 590 591 my $dist_macros = $mm->dist(%overrides); 592 593Generates a make fragment defining all the macros initialized in 594init_dist. 595 596%overrides can be used to override any of the above. 597 598=cut 599 600sub dist { 601 my($self, %attribs) = @_; 602 603 my $make = ''; 604 if ( $attribs{SUFFIX} && $attribs{SUFFIX} !~ m!^\.! ) { 605 $attribs{SUFFIX} = '.' . $attribs{SUFFIX}; 606 } 607 foreach my $key (qw( 608 TAR TARFLAGS ZIP ZIPFLAGS COMPRESS SUFFIX SHAR 609 PREOP POSTOP TO_UNIX 610 CI RCS_LABEL DIST_CP DIST_DEFAULT 611 DISTNAME DISTVNAME 612 )) 613 { 614 my $value = $attribs{$key} || $self->{$key}; 615 $make .= "$key = $value\n"; 616 } 617 618 return $make; 619} 620 621=item dist_basics (o) 622 623Defines the targets distclean, distcheck, skipcheck, manifest, veryclean. 624 625=cut 626 627sub dist_basics { 628 my($self) = shift; 629 630 return <<'MAKE_FRAG'; 631distclean :: realclean distcheck 632 $(NOECHO) $(NOOP) 633 634distcheck : 635 $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck 636 637skipcheck : 638 $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck 639 640manifest : 641 $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest 642 643veryclean : realclean 644 $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old 645 646MAKE_FRAG 647 648} 649 650=item dist_ci (o) 651 652Defines a check in target for RCS. 653 654=cut 655 656sub dist_ci { 657 my($self) = shift; 658 return q{ 659ci : 660 $(PERLRUN) "-MExtUtils::Manifest=maniread" \\ 661 -e "@all = keys %{ maniread() };" \\ 662 -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \\ 663 -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});" 664}; 665} 666 667=item dist_core (o) 668 669 my $dist_make_fragment = $MM->dist_core; 670 671Puts the targets necessary for 'make dist' together into one make 672fragment. 673 674=cut 675 676sub dist_core { 677 my($self) = shift; 678 679 my $make_frag = ''; 680 foreach my $target (qw(dist tardist uutardist tarfile zipdist zipfile 681 shdist)) 682 { 683 my $method = $target.'_target'; 684 $make_frag .= "\n"; 685 $make_frag .= $self->$method(); 686 } 687 688 return $make_frag; 689} 690 691 692=item B<dist_target> 693 694 my $make_frag = $MM->dist_target; 695 696Returns the 'dist' target to make an archive for distribution. This 697target simply checks to make sure the Makefile is up-to-date and 698depends on $(DIST_DEFAULT). 699 700=cut 701 702sub dist_target { 703 my($self) = shift; 704 705 my $date_check = $self->oneliner(<<'CODE', ['-l']); 706print 'Warning: Makefile possibly out of date with $(VERSION_FROM)' 707 if -e '$(VERSION_FROM)' and -M '$(VERSION_FROM)' < -M '$(FIRST_MAKEFILE)'; 708CODE 709 710 return sprintf <<'MAKE_FRAG', $date_check; 711dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) 712 $(NOECHO) %s 713MAKE_FRAG 714} 715 716=item B<tardist_target> 717 718 my $make_frag = $MM->tardist_target; 719 720Returns the 'tardist' target which is simply so 'make tardist' works. 721The real work is done by the dynamically named tardistfile_target() 722method, tardist should have that as a dependency. 723 724=cut 725 726sub tardist_target { 727 my($self) = shift; 728 729 return <<'MAKE_FRAG'; 730tardist : $(DISTVNAME).tar$(SUFFIX) 731 $(NOECHO) $(NOOP) 732MAKE_FRAG 733} 734 735=item B<zipdist_target> 736 737 my $make_frag = $MM->zipdist_target; 738 739Returns the 'zipdist' target which is simply so 'make zipdist' works. 740The real work is done by the dynamically named zipdistfile_target() 741method, zipdist should have that as a dependency. 742 743=cut 744 745sub zipdist_target { 746 my($self) = shift; 747 748 return <<'MAKE_FRAG'; 749zipdist : $(DISTVNAME).zip 750 $(NOECHO) $(NOOP) 751MAKE_FRAG 752} 753 754=item B<tarfile_target> 755 756 my $make_frag = $MM->tarfile_target; 757 758The name of this target is the name of the tarball generated by 759tardist. This target does the actual work of turning the distdir into 760a tarball. 761 762=cut 763 764sub tarfile_target { 765 my($self) = shift; 766 767 return <<'MAKE_FRAG'; 768$(DISTVNAME).tar$(SUFFIX) : distdir 769 $(PREOP) 770 $(TO_UNIX) 771 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) 772 $(RM_RF) $(DISTVNAME) 773 $(COMPRESS) $(DISTVNAME).tar 774 $(NOECHO) $(ECHO) 'Created $(DISTVNAME).tar$(SUFFIX)' 775 $(POSTOP) 776MAKE_FRAG 777} 778 779=item zipfile_target 780 781 my $make_frag = $MM->zipfile_target; 782 783The name of this target is the name of the zip file generated by 784zipdist. This target does the actual work of turning the distdir into 785a zip file. 786 787=cut 788 789sub zipfile_target { 790 my($self) = shift; 791 792 return <<'MAKE_FRAG'; 793$(DISTVNAME).zip : distdir 794 $(PREOP) 795 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) 796 $(RM_RF) $(DISTVNAME) 797 $(NOECHO) $(ECHO) 'Created $(DISTVNAME).zip' 798 $(POSTOP) 799MAKE_FRAG 800} 801 802=item uutardist_target 803 804 my $make_frag = $MM->uutardist_target; 805 806Converts the tarfile into a uuencoded file 807 808=cut 809 810sub uutardist_target { 811 my($self) = shift; 812 813 return <<'MAKE_FRAG'; 814uutardist : $(DISTVNAME).tar$(SUFFIX) 815 uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu 816 $(NOECHO) $(ECHO) 'Created $(DISTVNAME).tar$(SUFFIX)_uu' 817MAKE_FRAG 818} 819 820 821=item shdist_target 822 823 my $make_frag = $MM->shdist_target; 824 825Converts the distdir into a shell archive. 826 827=cut 828 829sub shdist_target { 830 my($self) = shift; 831 832 return <<'MAKE_FRAG'; 833shdist : distdir 834 $(PREOP) 835 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar 836 $(RM_RF) $(DISTVNAME) 837 $(NOECHO) $(ECHO) 'Created $(DISTVNAME).shar' 838 $(POSTOP) 839MAKE_FRAG 840} 841 842 843=item dlsyms (o) 844 845Used by some OS' to define DL_FUNCS and DL_VARS and write the *.exp files. 846 847Normally just returns an empty string. 848 849=cut 850 851sub dlsyms { 852 return ''; 853} 854 855 856=item dynamic_bs (o) 857 858Defines targets for bootstrap files. 859 860=cut 861 862sub dynamic_bs { 863 my($self, %attribs) = @_; 864 return ' 865BOOTSTRAP = 866' unless $self->has_link_code(); 867 868 my $target = $Is{VMS} ? '$(MMS$TARGET)' : '$@'; 869 870 return sprintf <<'MAKE_FRAG', ($target) x 2; 871BOOTSTRAP = $(BASEEXT).bs 872 873# As Mkbootstrap might not write a file (if none is required) 874# we use touch to prevent make continually trying to remake it. 875# The DynaLoader only reads a non-empty file. 876$(BOOTSTRAP) : $(FIRST_MAKEFILE) $(BOOTDEP) $(INST_ARCHAUTODIR)$(DFSEP).exists 877 $(NOECHO) $(ECHO) "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))" 878 $(NOECHO) $(PERLRUN) \ 879 "-MExtUtils::Mkbootstrap" \ 880 -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');" 881 $(NOECHO) $(TOUCH) %s 882 $(CHMOD) $(PERM_RW) %s 883MAKE_FRAG 884} 885 886=item dynamic_lib (o) 887 888Defines how to produce the *.so (or equivalent) files. 889 890=cut 891 892sub dynamic_lib { 893 my($self, %attribs) = @_; 894 return '' unless $self->needs_linking(); #might be because of a subdir 895 896 return '' unless $self->has_link_code; 897 898 my($otherldflags) = $attribs{OTHERLDFLAGS} || ""; 899 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || ""; 900 my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":"; 901 my($ldfrom) = '$(LDFROM)'; 902 $armaybe = 'ar' if ($Is{OSF} and $armaybe eq ':'); 903 my(@m); 904 my $ld_opt = $Is{OS2} ? '$(OPTIMIZE) ' : ''; # Useful on other systems too? 905 my $ld_fix = $Is{OS2} ? '|| ( $(RM_F) $@ && sh -c false )' : ''; 906 push(@m,' 907# This section creates the dynamically loadable $(INST_DYNAMIC) 908# from $(OBJECT) and possibly $(MYEXTLIB). 909ARMAYBE = '.$armaybe.' 910OTHERLDFLAGS = '.$ld_opt.$otherldflags.' 911INST_DYNAMIC_DEP = '.$inst_dynamic_dep.' 912INST_DYNAMIC_FIX = '.$ld_fix.' 913 914$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP) 915'); 916 if ($armaybe ne ':'){ 917 $ldfrom = 'tmp$(LIB_EXT)'; 918 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n"); 919 push(@m,' $(RANLIB) '."$ldfrom\n"); 920 } 921 $ldfrom = "-all $ldfrom -none" if $Is{OSF}; 922 923 # The IRIX linker doesn't use LD_RUN_PATH 924 my $ldrun = $Is{IRIX} && $self->{LD_RUN_PATH} ? 925 qq{-rpath "$self->{LD_RUN_PATH}"} : ''; 926 927 # For example in AIX the shared objects/libraries from previous builds 928 # linger quite a while in the shared dynalinker cache even when nobody 929 # is using them. This is painful if one for instance tries to restart 930 # a failed build because the link command will fail unnecessarily 'cos 931 # the shared object/library is 'busy'. 932 push(@m,' $(RM_F) $@ 933'); 934 935 my $libs = '$(LDLOADLIBS)'; 936 937 if (($Is{NetBSD} || $Is{Interix} || $Is{Android}) && $Config{'useshrplib'} eq 'true') { 938 # Use nothing on static perl platforms, and to the flags needed 939 # to link against the shared libperl library on shared perl 940 # platforms. We peek at lddlflags to see if we need -Wl,-R 941 # or -R to add paths to the run-time library search path. 942 if ($Config{'lddlflags'} =~ /-Wl,-R/) { 943 $libs .= ' -L$(PERL_INC) -Wl,-R$(INSTALLARCHLIB)/CORE -Wl,-R$(PERL_ARCHLIB)/CORE -lperl'; 944 } elsif ($Config{'lddlflags'} =~ /-R/) { 945 $libs .= ' -L$(PERL_INC) -R$(INSTALLARCHLIB)/CORE -R$(PERL_ARCHLIB)/CORE -lperl'; 946 } elsif ( $Is{Android} ) { 947 # The Android linker will not recognize symbols from 948 # libperl unless the module explicitly depends on it. 949 $libs .= ' -L$(PERL_INC) -lperl'; 950 } 951 } 952 953 my $ld_run_path_shell = ""; 954 if ($self->{LD_RUN_PATH} ne "") { 955 $ld_run_path_shell = 'LD_RUN_PATH="$(LD_RUN_PATH)" '; 956 } 957 958 push @m, sprintf <<'MAKE', $ld_run_path_shell, $ldrun, $ldfrom, $libs; 959 %s$(LD) %s $(LDDLFLAGS) %s $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) \ 960 $(PERL_ARCHIVE) %s $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \ 961 $(INST_DYNAMIC_FIX) 962MAKE 963 964 push @m, <<'MAKE'; 965 $(CHMOD) $(PERM_RWX) $@ 966 $(NOECHO) $(RM_RF) $(BOOTSTRAP) 967 - $(CP_NONEMPTY) $(BOOTSTRAP) $(INST_BOOT) $(PERM_RW) 968MAKE 969 970 return join('',@m); 971} 972 973=item exescan 974 975Deprecated method. Use libscan instead. 976 977=cut 978 979sub exescan { 980 my($self,$path) = @_; 981 $path; 982} 983 984=item extliblist 985 986Called by init_others, and calls ext ExtUtils::Liblist. See 987L<ExtUtils::Liblist> for details. 988 989=cut 990 991sub extliblist { 992 my($self,$libs) = @_; 993 require ExtUtils::Liblist; 994 $self->ext($libs, $Verbose); 995} 996 997=item find_perl 998 999Finds the executables PERL and FULLPERL 1000 1001=cut 1002 1003sub find_perl { 1004 my($self, $ver, $names, $dirs, $trace) = @_; 1005 1006 if ($trace >= 2){ 1007 print "Looking for perl $ver by these names: 1008@$names 1009in these dirs: 1010@$dirs 1011"; 1012 } 1013 1014 my $stderr_duped = 0; 1015 local *STDERR_COPY; 1016 1017 unless ($Is{BSD}) { 1018 # >& and lexical filehandles together give 5.6.2 indigestion 1019 if( open(STDERR_COPY, '>&STDERR') ) { ## no critic 1020 $stderr_duped = 1; 1021 } 1022 else { 1023 warn <<WARNING; 1024find_perl() can't dup STDERR: $! 1025You might see some garbage while we search for Perl 1026WARNING 1027 } 1028 } 1029 1030 foreach my $name (@$names){ 1031 foreach my $dir (@$dirs){ 1032 next unless defined $dir; # $self->{PERL_SRC} may be undefined 1033 my ($abs, $val); 1034 if ($self->file_name_is_absolute($name)) { # /foo/bar 1035 $abs = $name; 1036 } elsif ($self->canonpath($name) eq 1037 $self->canonpath(basename($name))) { # foo 1038 $abs = $self->catfile($dir, $name); 1039 } else { # foo/bar 1040 $abs = $self->catfile($Curdir, $name); 1041 } 1042 print "Checking $abs\n" if ($trace >= 2); 1043 next unless $self->maybe_command($abs); 1044 print "Executing $abs\n" if ($trace >= 2); 1045 1046 my $version_check = qq{$abs -le "require $ver; print qq{VER_OK}"}; 1047 1048 # To avoid using the unportable 2>&1 to suppress STDERR, 1049 # we close it before running the command. 1050 # However, thanks to a thread library bug in many BSDs 1051 # ( http://www.freebsd.org/cgi/query-pr.cgi?pr=51535 ) 1052 # we cannot use the fancier more portable way in here 1053 # but instead need to use the traditional 2>&1 construct. 1054 if ($Is{BSD}) { 1055 $val = `$version_check 2>&1`; 1056 } else { 1057 close STDERR if $stderr_duped; 1058 $val = `$version_check`; 1059 1060 # 5.6.2's 3-arg open doesn't work with >& 1061 open STDERR, ">&STDERR_COPY" ## no critic 1062 if $stderr_duped; 1063 } 1064 1065 if ($val =~ /^VER_OK/m) { 1066 print "Using PERL=$abs\n" if $trace; 1067 return $abs; 1068 } elsif ($trace >= 2) { 1069 print "Result: '$val' ".($? >> 8)."\n"; 1070 } 1071 } 1072 } 1073 print "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n"; 1074 0; # false and not empty 1075} 1076 1077 1078=item fixin 1079 1080 $mm->fixin(@files); 1081 1082Inserts the sharpbang or equivalent magic number to a set of @files. 1083 1084=cut 1085 1086sub fixin { # stolen from the pink Camel book, more or less 1087 my ( $self, @files ) = @_; 1088 1089 for my $file (@files) { 1090 my $file_new = "$file.new"; 1091 my $file_bak = "$file.bak"; 1092 1093 open( my $fixin, '<', $file ) or croak "Can't process '$file': $!"; 1094 local $/ = "\n"; 1095 chomp( my $line = <$fixin> ); 1096 next unless $line =~ s/^\s*\#!\s*//; # Not a shebang file. 1097 1098 my $shb = $self->_fixin_replace_shebang( $file, $line ); 1099 next unless defined $shb; 1100 1101 open( my $fixout, ">", "$file_new" ) or do { 1102 warn "Can't create new $file: $!\n"; 1103 next; 1104 }; 1105 1106 # Print out the new #! line (or equivalent). 1107 local $\; 1108 local $/; 1109 print $fixout $shb, <$fixin>; 1110 close $fixin; 1111 close $fixout; 1112 1113 chmod 0666, $file_bak; 1114 unlink $file_bak; 1115 unless ( _rename( $file, $file_bak ) ) { 1116 warn "Can't rename $file to $file_bak: $!"; 1117 next; 1118 } 1119 unless ( _rename( $file_new, $file ) ) { 1120 warn "Can't rename $file_new to $file: $!"; 1121 unless ( _rename( $file_bak, $file ) ) { 1122 warn "Can't rename $file_bak back to $file either: $!"; 1123 warn "Leaving $file renamed as $file_bak\n"; 1124 } 1125 next; 1126 } 1127 unlink $file_bak; 1128 } 1129 continue { 1130 system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; 1131 } 1132} 1133 1134 1135sub _rename { 1136 my($old, $new) = @_; 1137 1138 foreach my $file ($old, $new) { 1139 if( $Is{VMS} and basename($file) !~ /\./ ) { 1140 # rename() in 5.8.0 on VMS will not rename a file if it 1141 # does not contain a dot yet it returns success. 1142 $file = "$file."; 1143 } 1144 } 1145 1146 return rename($old, $new); 1147} 1148 1149sub _fixin_replace_shebang { 1150 my ( $self, $file, $line ) = @_; 1151 1152 # Now figure out the interpreter name. 1153 my ( $cmd, $arg ) = split ' ', $line, 2; 1154 $cmd =~ s!^.*/!!; 1155 1156 # Now look (in reverse) for interpreter in absolute PATH (unless perl). 1157 my $interpreter; 1158 if ( $cmd =~ m{^perl(?:\z|[^a-z])} ) { 1159 if ( $Config{startperl} =~ m,^\#!.*/perl, ) { 1160 $interpreter = $Config{startperl}; 1161 $interpreter =~ s,^\#!,,; 1162 } 1163 else { 1164 $interpreter = $Config{perlpath}; 1165 } 1166 } 1167 else { 1168 my (@absdirs) 1169 = reverse grep { $self->file_name_is_absolute($_) } $self->path; 1170 $interpreter = ''; 1171 1172 foreach my $dir (@absdirs) { 1173 if ( $self->maybe_command($cmd) ) { 1174 warn "Ignoring $interpreter in $file\n" 1175 if $Verbose && $interpreter; 1176 $interpreter = $self->catfile( $dir, $cmd ); 1177 } 1178 } 1179 } 1180 1181 # Figure out how to invoke interpreter on this machine. 1182 1183 my ($does_shbang) = $Config{'sharpbang'} =~ /^\s*\#\!/; 1184 my ($shb) = ""; 1185 if ($interpreter) { 1186 print "Changing sharpbang in $file to $interpreter" 1187 if $Verbose; 1188 # this is probably value-free on DOSISH platforms 1189 if ($does_shbang) { 1190 $shb .= "$Config{'sharpbang'}$interpreter"; 1191 $shb .= ' ' . $arg if defined $arg; 1192 $shb .= "\n"; 1193 } 1194 $shb .= qq{ 1195eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}' 1196 if 0; # not running under some shell 1197} unless $Is{Win32}; # this won't work on win32, so don't 1198 } 1199 else { 1200 warn "Can't find $cmd in PATH, $file unchanged" 1201 if $Verbose; 1202 return; 1203 } 1204 return $shb 1205} 1206 1207=item force (o) 1208 1209Writes an empty FORCE: target. 1210 1211=cut 1212 1213sub force { 1214 my($self) = shift; 1215 '# Phony target to force checking subdirectories. 1216FORCE : 1217 $(NOECHO) $(NOOP) 1218'; 1219} 1220 1221=item guess_name 1222 1223Guess the name of this package by examining the working directory's 1224name. MakeMaker calls this only if the developer has not supplied a 1225NAME attribute. 1226 1227=cut 1228 1229# '; 1230 1231sub guess_name { 1232 my($self) = @_; 1233 use Cwd 'cwd'; 1234 my $name = basename(cwd()); 1235 $name =~ s|[\-_][\d\.\-]+\z||; # this is new with MM 5.00, we 1236 # strip minus or underline 1237 # followed by a float or some such 1238 print "Warning: Guessing NAME [$name] from current directory name.\n"; 1239 $name; 1240} 1241 1242=item has_link_code 1243 1244Returns true if C, XS, MYEXTLIB or similar objects exist within this 1245object that need a compiler. Does not descend into subdirectories as 1246needs_linking() does. 1247 1248=cut 1249 1250sub has_link_code { 1251 my($self) = shift; 1252 return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE}; 1253 if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){ 1254 $self->{HAS_LINK_CODE} = 1; 1255 return 1; 1256 } 1257 return $self->{HAS_LINK_CODE} = 0; 1258} 1259 1260 1261=item init_dirscan 1262 1263Scans the directory structure and initializes DIR, XS, XS_FILES, 1264C, C_FILES, O_FILES, H, H_FILES, PL_FILES, EXE_FILES. 1265 1266Called by init_main. 1267 1268=cut 1269 1270sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) 1271 my($self) = @_; 1272 my(%dir, %xs, %c, %o, %h, %pl_files, %pm); 1273 1274 my %ignore = map {( $_ => 1 )} qw(Makefile.PL Build.PL test.pl t); 1275 1276 # ignore the distdir 1277 $Is{VMS} ? $ignore{"$self->{DISTVNAME}.dir"} = 1 1278 : $ignore{$self->{DISTVNAME}} = 1; 1279 1280 my $distprefix = $Is{VMS} ? qr/^\Q$self->{DISTNAME}\E-v?[\d\.]+\.dir$/i 1281 : qr/^\Q$self->{DISTNAME}\E-v?[\d\.]+$/; 1282 1283 @ignore{map lc, keys %ignore} = values %ignore if $Is{VMS}; 1284 1285 if ( defined $self->{XS} and !defined $self->{C} ) { 1286 my @c_files = grep { m/\.c(pp|xx)?\z/i } values %{$self->{XS}}; 1287 my @o_files = grep { m/(?:.(?:o(?:bj)?)|\$\(OBJ_EXT\))\z/i } values %{$self->{XS}}; 1288 %c = map { $_ => 1 } @c_files; 1289 %o = map { $_ => 1 } @o_files; 1290 } 1291 1292 foreach my $name ($self->lsdir($Curdir)){ 1293 next if $name =~ /\#/; 1294 next if $name =~ $distprefix && -d $name; 1295 $name = lc($name) if $Is{VMS}; 1296 next if $name eq $Curdir or $name eq $Updir or $ignore{$name}; 1297 next unless $self->libscan($name); 1298 if (-d $name){ 1299 next if -l $name; # We do not support symlinks at all 1300 next if $self->{NORECURS}; 1301 $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL")); 1302 } elsif ($name =~ /\.xs\z/){ 1303 my($c); ($c = $name) =~ s/\.xs\z/.c/; 1304 $xs{$name} = $c; 1305 $c{$c} = 1; 1306 } elsif ($name =~ /\.c(pp|xx|c)?\z/i){ # .c .C .cpp .cxx .cc 1307 $c{$name} = 1 1308 unless $name =~ m/perlmain\.c/; # See MAP_TARGET 1309 } elsif ($name =~ /\.h\z/i){ 1310 $h{$name} = 1; 1311 } elsif ($name =~ /\.PL\z/) { 1312 ($pl_files{$name} = $name) =~ s/\.PL\z// ; 1313 } elsif (($Is{VMS} || $Is{Dos}) && $name =~ /[._]pl$/i) { 1314 # case-insensitive filesystem, one dot per name, so foo.h.PL 1315 # under Unix appears as foo.h_pl under VMS or fooh.pl on Dos 1316 local($/); open(my $pl, '<', $name); my $txt = <$pl>; close $pl; 1317 if ($txt =~ /Extracting \S+ \(with variable substitutions/) { 1318 ($pl_files{$name} = $name) =~ s/[._]pl\z//i ; 1319 } 1320 else { 1321 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name); 1322 } 1323 } elsif ($name =~ /\.(p[ml]|pod)\z/){ 1324 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name); 1325 } 1326 } 1327 1328 $self->{PL_FILES} ||= \%pl_files; 1329 $self->{DIR} ||= [sort keys %dir]; 1330 $self->{XS} ||= \%xs; 1331 $self->{C} ||= [sort keys %c]; 1332 $self->{H} ||= [sort keys %h]; 1333 $self->{PM} ||= \%pm; 1334 1335 my @o_files = @{$self->{C}}; 1336 %o = (%o, map { $_ => 1 } grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files); 1337 $self->{O_FILES} = [sort keys %o]; 1338} 1339 1340 1341=item init_MANPODS 1342 1343Determines if man pages should be generated and initializes MAN1PODS 1344and MAN3PODS as appropriate. 1345 1346=cut 1347 1348sub init_MANPODS { 1349 my $self = shift; 1350 1351 # Set up names of manual pages to generate from pods 1352 foreach my $man (qw(MAN1 MAN3)) { 1353 if ( $self->{"${man}PODS"} 1354 or $self->{"INSTALL${man}DIR"} =~ /^(none|\s*)$/ 1355 ) { 1356 $self->{"${man}PODS"} ||= {}; 1357 } 1358 else { 1359 my $init_method = "init_${man}PODS"; 1360 $self->$init_method(); 1361 } 1362 } 1363} 1364 1365 1366sub _has_pod { 1367 my($self, $file) = @_; 1368 1369 my($ispod)=0; 1370 if (open( my $fh, '<', $file )) { 1371 while (<$fh>) { 1372 if (/^=(?:head\d+|item|pod)\b/) { 1373 $ispod=1; 1374 last; 1375 } 1376 } 1377 close $fh; 1378 } else { 1379 # If it doesn't exist yet, we assume, it has pods in it 1380 $ispod = 1; 1381 } 1382 1383 return $ispod; 1384} 1385 1386 1387=item init_MAN1PODS 1388 1389Initializes MAN1PODS from the list of EXE_FILES. 1390 1391=cut 1392 1393sub init_MAN1PODS { 1394 my($self) = @_; 1395 1396 if ( exists $self->{EXE_FILES} ) { 1397 foreach my $name (@{$self->{EXE_FILES}}) { 1398 next unless $self->_has_pod($name); 1399 1400 $self->{MAN1PODS}->{$name} = 1401 $self->catfile("\$(INST_MAN1DIR)", 1402 basename($name).".\$(MAN1EXT)"); 1403 } 1404 } 1405} 1406 1407 1408=item init_MAN3PODS 1409 1410Initializes MAN3PODS from the list of PM files. 1411 1412=cut 1413 1414sub init_MAN3PODS { 1415 my $self = shift; 1416 1417 my %manifypods = (); # we collect the keys first, i.e. the files 1418 # we have to convert to pod 1419 1420 foreach my $name (keys %{$self->{PM}}) { 1421 if ($name =~ /\.pod\z/ ) { 1422 $manifypods{$name} = $self->{PM}{$name}; 1423 } elsif ($name =~ /\.p[ml]\z/ ) { 1424 if( $self->_has_pod($name) ) { 1425 $manifypods{$name} = $self->{PM}{$name}; 1426 } 1427 } 1428 } 1429 1430 my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}}; 1431 1432 # Remove "Configure.pm" and similar, if it's not the only pod listed 1433 # To force inclusion, just name it "Configure.pod", or override 1434 # MAN3PODS 1435 foreach my $name (keys %manifypods) { 1436 if ($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) { 1437 delete $manifypods{$name}; 1438 next; 1439 } 1440 my($manpagename) = $name; 1441 $manpagename =~ s/\.p(od|m|l)\z//; 1442 # everything below lib is ok 1443 unless($manpagename =~ s!^\W*($parentlibs_re)\W+!!s) { 1444 $manpagename = $self->catfile( 1445 split(/::/,$self->{PARENT_NAME}),$manpagename 1446 ); 1447 } 1448 $manpagename = $self->replace_manpage_separator($manpagename); 1449 $self->{MAN3PODS}->{$name} = 1450 $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)"); 1451 } 1452} 1453 1454 1455=item init_PM 1456 1457Initializes PMLIBDIRS and PM from PMLIBDIRS. 1458 1459=cut 1460 1461sub init_PM { 1462 my $self = shift; 1463 1464 # Some larger extensions often wish to install a number of *.pm/pl 1465 # files into the library in various locations. 1466 1467 # The attribute PMLIBDIRS holds an array reference which lists 1468 # subdirectories which we should search for library files to 1469 # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We 1470 # recursively search through the named directories (skipping any 1471 # which don't exist or contain Makefile.PL files). 1472 1473 # For each *.pm or *.pl file found $self->libscan() is called with 1474 # the default installation path in $_[1]. The return value of 1475 # libscan defines the actual installation location. The default 1476 # libscan function simply returns the path. The file is skipped 1477 # if libscan returns false. 1478 1479 # The default installation location passed to libscan in $_[1] is: 1480 # 1481 # ./*.pm => $(INST_LIBDIR)/*.pm 1482 # ./xyz/... => $(INST_LIBDIR)/xyz/... 1483 # ./lib/... => $(INST_LIB)/... 1484 # 1485 # In this way the 'lib' directory is seen as the root of the actual 1486 # perl library whereas the others are relative to INST_LIBDIR 1487 # (which includes PARENT_NAME). This is a subtle distinction but one 1488 # that's important for nested modules. 1489 1490 unless( $self->{PMLIBDIRS} ) { 1491 if( $Is{VMS} ) { 1492 # Avoid logical name vs directory collisions 1493 $self->{PMLIBDIRS} = ['./lib', "./$self->{BASEEXT}"]; 1494 } 1495 else { 1496 $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}]; 1497 } 1498 } 1499 1500 #only existing directories that aren't in $dir are allowed 1501 1502 # Avoid $_ wherever possible: 1503 # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}}; 1504 my (@pmlibdirs) = @{$self->{PMLIBDIRS}}; 1505 @{$self->{PMLIBDIRS}} = (); 1506 my %dir = map { ($_ => $_) } @{$self->{DIR}}; 1507 foreach my $pmlibdir (@pmlibdirs) { 1508 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir; 1509 } 1510 1511 unless( $self->{PMLIBPARENTDIRS} ) { 1512 @{$self->{PMLIBPARENTDIRS}} = ('lib'); 1513 } 1514 1515 return if $self->{PM} and $self->{ARGS}{PM}; 1516 1517 if (@{$self->{PMLIBDIRS}}){ 1518 print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n" 1519 if ($Verbose >= 2); 1520 require File::Find; 1521 File::Find::find(sub { 1522 if (-d $_){ 1523 unless ($self->libscan($_)){ 1524 $File::Find::prune = 1; 1525 } 1526 return; 1527 } 1528 return if /\#/; 1529 return if /~$/; # emacs temp files 1530 return if /,v$/; # RCS files 1531 return if m{\.swp$}; # vim swap files 1532 1533 my $path = $File::Find::name; 1534 my $prefix = $self->{INST_LIBDIR}; 1535 my $striplibpath; 1536 1537 my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}}; 1538 $prefix = $self->{INST_LIB} 1539 if ($striplibpath = $path) =~ s{^(\W*)($parentlibs_re)\W} 1540 {$1}i; 1541 1542 my($inst) = $self->catfile($prefix,$striplibpath); 1543 local($_) = $inst; # for backwards compatibility 1544 $inst = $self->libscan($inst); 1545 print "libscan($path) => '$inst'\n" if ($Verbose >= 2); 1546 return unless $inst; 1547 $self->{PM}{$path} = $inst; 1548 }, @{$self->{PMLIBDIRS}}); 1549 } 1550} 1551 1552 1553=item init_DIRFILESEP 1554 1555Using / for Unix. Called by init_main. 1556 1557=cut 1558 1559sub init_DIRFILESEP { 1560 my($self) = shift; 1561 1562 $self->{DIRFILESEP} = '/'; 1563} 1564 1565 1566=item init_main 1567 1568Initializes AR, AR_STATIC_ARGS, BASEEXT, CONFIG, DISTNAME, DLBASE, 1569EXE_EXT, FULLEXT, FULLPERL, FULLPERLRUN, FULLPERLRUNINST, INST_*, 1570INSTALL*, INSTALLDIRS, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME, 1571OBJ_EXT, PARENT_NAME, PERL, PERL_ARCHLIB, PERL_INC, PERL_LIB, 1572PERL_SRC, PERLRUN, PERLRUNINST, PREFIX, VERSION, 1573VERSION_SYM, XS_VERSION. 1574 1575=cut 1576 1577sub init_main { 1578 my($self) = @_; 1579 1580 # --- Initialize Module Name and Paths 1581 1582 # NAME = Foo::Bar::Oracle 1583 # FULLEXT = Foo/Bar/Oracle 1584 # BASEEXT = Oracle 1585 # PARENT_NAME = Foo::Bar 1586### Only UNIX: 1587### ($self->{FULLEXT} = 1588### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket 1589 $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME}); 1590 1591 1592 # Copied from DynaLoader: 1593 1594 my(@modparts) = split(/::/,$self->{NAME}); 1595 my($modfname) = $modparts[-1]; 1596 1597 # Some systems have restrictions on files names for DLL's etc. 1598 # mod2fname returns appropriate file base name (typically truncated) 1599 # It may also edit @modparts if required. 1600 # We require DynaLoader to make sure that mod2fname is loaded 1601 eval { require DynaLoader }; 1602 if (defined &DynaLoader::mod2fname) { 1603 $modfname = &DynaLoader::mod2fname(\@modparts); 1604 } 1605 1606 ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!(?:([\w:]+)::)?(\w+)\z! ; 1607 $self->{PARENT_NAME} ||= ''; 1608 1609 if (defined &DynaLoader::mod2fname) { 1610 # As of 5.001m, dl_os2 appends '_' 1611 $self->{DLBASE} = $modfname; 1612 } else { 1613 $self->{DLBASE} = '$(BASEEXT)'; 1614 } 1615 1616 1617 # --- Initialize PERL_LIB, PERL_SRC 1618 1619 # *Real* information: where did we get these two from? ... 1620 my $inc_config_dir = dirname($INC{'Config.pm'}); 1621 my $inc_carp_dir = dirname($INC{'Carp.pm'}); 1622 1623 unless ($self->{PERL_SRC}){ 1624 foreach my $dir_count (1..8) { # 8 is the VMS limit for nesting 1625 my $dir = $self->catdir(($Updir) x $dir_count); 1626 1627 if (-f $self->catfile($dir,"config_h.SH") && 1628 -f $self->catfile($dir,"perl.h") && 1629 -f $self->catfile($dir,"lib","strict.pm") 1630 ) { 1631 $self->{PERL_SRC}=$dir ; 1632 last; 1633 } 1634 } 1635 } 1636 1637 warn "PERL_CORE is set but I can't find your PERL_SRC!\n" if 1638 $self->{PERL_CORE} and !$self->{PERL_SRC}; 1639 1640 if ($self->{PERL_SRC}){ 1641 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib"); 1642 1643 $self->{PERL_ARCHLIB} = $self->{PERL_LIB}; 1644 $self->{PERL_INC} = ($Is{Win32}) ? 1645 $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC}; 1646 1647 # catch a situation that has occurred a few times in the past: 1648 unless ( 1649 -s $self->catfile($self->{PERL_SRC},'cflags') 1650 or 1651 $Is{VMS} 1652 && 1653 -s $self->catfile($self->{PERL_SRC},'vmsish.h') 1654 or 1655 $Is{Win32} 1656 ){ 1657 warn qq{ 1658You cannot build extensions below the perl source tree after executing 1659a 'make clean' in the perl source tree. 1660 1661To rebuild extensions distributed with the perl source you should 1662simply Configure (to include those extensions) and then build perl as 1663normal. After installing perl the source tree can be deleted. It is 1664not needed for building extensions by running 'perl Makefile.PL' 1665usually without extra arguments. 1666 1667It is recommended that you unpack and build additional extensions away 1668from the perl source tree. 1669}; 1670 } 1671 } else { 1672 # we should also consider $ENV{PERL5LIB} here 1673 my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC}; 1674 $self->{PERL_LIB} ||= $Config{privlibexp}; 1675 $self->{PERL_ARCHLIB} ||= $Config{archlibexp}; 1676 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now 1677 my $perl_h; 1678 1679 if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h")) 1680 and not $old){ 1681 # Maybe somebody tries to build an extension with an 1682 # uninstalled Perl outside of Perl build tree 1683 my $lib; 1684 for my $dir (@INC) { 1685 $lib = $dir, last if -e $self->catfile($dir, "Config.pm"); 1686 } 1687 if ($lib) { 1688 # Win32 puts its header files in /perl/src/lib/CORE. 1689 # Unix leaves them in /perl/src. 1690 my $inc = $Is{Win32} ? $self->catdir($lib, "CORE" ) 1691 : dirname $lib; 1692 if (-e $self->catfile($inc, "perl.h")) { 1693 $self->{PERL_LIB} = $lib; 1694 $self->{PERL_ARCHLIB} = $lib; 1695 $self->{PERL_INC} = $inc; 1696 $self->{UNINSTALLED_PERL} = 1; 1697 print <<EOP; 1698... Detected uninstalled Perl. Trying to continue. 1699EOP 1700 } 1701 } 1702 } 1703 } 1704 1705 if ($Is{Android}) { 1706 # Android fun times! 1707 # ../../perl -I../../lib -MFile::Glob -e1 works 1708 # ../../../perl -I../../../lib -MFile::Glob -e1 fails to find 1709 # the .so for File::Glob. 1710 # This always affects core perl, but may also affect an installed 1711 # perl built with -Duserelocatableinc. 1712 $self->{PERL_LIB} = File::Spec->rel2abs($self->{PERL_LIB}); 1713 $self->{PERL_ARCHLIB} = File::Spec->rel2abs($self->{PERL_ARCHLIB}); 1714 } 1715 1716 # We get SITELIBEXP and SITEARCHEXP directly via 1717 # Get_from_Config. When we are running standard modules, these 1718 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we 1719 # set it to "site". I prefer that INSTALLDIRS be set from outside 1720 # MakeMaker. 1721 $self->{INSTALLDIRS} ||= "site"; 1722 1723 $self->{MAN1EXT} ||= $Config{man1ext}; 1724 $self->{MAN3EXT} ||= $Config{man3ext}; 1725 1726 # Get some stuff out of %Config if we haven't yet done so 1727 print "CONFIG must be an array ref\n" 1728 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY'); 1729 $self->{CONFIG} = [] unless (ref $self->{CONFIG}); 1730 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config); 1731 push(@{$self->{CONFIG}}, 'shellflags') if $Config{shellflags}; 1732 my(%once_only); 1733 foreach my $m (@{$self->{CONFIG}}){ 1734 next if $once_only{$m}; 1735 print "CONFIG key '$m' does not exist in Config.pm\n" 1736 unless exists $Config{$m}; 1737 $self->{uc $m} ||= $Config{$m}; 1738 $once_only{$m} = 1; 1739 } 1740 1741# This is too dangerous: 1742# if ($^O eq "next") { 1743# $self->{AR} = "libtool"; 1744# $self->{AR_STATIC_ARGS} = "-o"; 1745# } 1746# But I leave it as a placeholder 1747 1748 $self->{AR_STATIC_ARGS} ||= "cr"; 1749 1750 # These should never be needed 1751 $self->{OBJ_EXT} ||= '.o'; 1752 $self->{LIB_EXT} ||= '.a'; 1753 1754 $self->{MAP_TARGET} ||= "perl"; 1755 1756 $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}"; 1757 1758 # make a simple check if we find strict 1759 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory 1760 (strict.pm not found)" 1761 unless -f $self->catfile("$self->{PERL_LIB}","strict.pm") || 1762 $self->{NAME} eq "ExtUtils::MakeMaker"; 1763} 1764 1765=item init_tools 1766 1767Initializes tools to use their common (and faster) Unix commands. 1768 1769=cut 1770 1771sub init_tools { 1772 my $self = shift; 1773 1774 $self->{ECHO} ||= 'echo'; 1775 $self->{ECHO_N} ||= 'echo -n'; 1776 $self->{RM_F} ||= "rm -f"; 1777 $self->{RM_RF} ||= "rm -rf"; 1778 $self->{TOUCH} ||= "touch"; 1779 $self->{TEST_F} ||= "test -f"; 1780 $self->{TEST_S} ||= "test -s"; 1781 $self->{CP} ||= "cp"; 1782 $self->{MV} ||= "mv"; 1783 $self->{CHMOD} ||= "chmod"; 1784 $self->{FALSE} ||= 'false'; 1785 $self->{TRUE} ||= 'true'; 1786 1787 $self->{LD} ||= 'ld'; 1788 1789 return $self->SUPER::init_tools(@_); 1790 1791 # After SUPER::init_tools so $Config{shell} has a 1792 # chance to get set. 1793 $self->{SHELL} ||= '/bin/sh'; 1794 1795 return; 1796} 1797 1798 1799=item init_linker 1800 1801Unix has no need of special linker flags. 1802 1803=cut 1804 1805sub init_linker { 1806 my($self) = shift; 1807 $self->{PERL_ARCHIVE} ||= ''; 1808 $self->{PERL_ARCHIVE_AFTER} ||= ''; 1809 $self->{EXPORT_LIST} ||= ''; 1810} 1811 1812 1813=begin _protected 1814 1815=item init_lib2arch 1816 1817 $mm->init_lib2arch 1818 1819=end _protected 1820 1821=cut 1822 1823sub init_lib2arch { 1824 my($self) = shift; 1825 1826 # The user who requests an installation directory explicitly 1827 # should not have to tell us an architecture installation directory 1828 # as well. We look if a directory exists that is named after the 1829 # architecture. If not we take it as a sign that it should be the 1830 # same as the requested installation directory. Otherwise we take 1831 # the found one. 1832 for my $libpair ({l=>"privlib", a=>"archlib"}, 1833 {l=>"sitelib", a=>"sitearch"}, 1834 {l=>"vendorlib", a=>"vendorarch"}, 1835 ) 1836 { 1837 my $lib = "install$libpair->{l}"; 1838 my $Lib = uc $lib; 1839 my $Arch = uc "install$libpair->{a}"; 1840 if( $self->{$Lib} && ! $self->{$Arch} ){ 1841 my($ilib) = $Config{$lib}; 1842 1843 $self->prefixify($Arch,$ilib,$self->{$Lib}); 1844 1845 unless (-d $self->{$Arch}) { 1846 print "Directory $self->{$Arch} not found\n" 1847 if $Verbose; 1848 $self->{$Arch} = $self->{$Lib}; 1849 } 1850 print "Defaulting $Arch to $self->{$Arch}\n" if $Verbose; 1851 } 1852 } 1853} 1854 1855 1856=item init_PERL 1857 1858 $mm->init_PERL; 1859 1860Called by init_main. Sets up ABSPERL, PERL, FULLPERL and all the 1861*PERLRUN* permutations. 1862 1863 PERL is allowed to be miniperl 1864 FULLPERL must be a complete perl 1865 1866 ABSPERL is PERL converted to an absolute path 1867 1868 *PERLRUN contains everything necessary to run perl, find it's 1869 libraries, etc... 1870 1871 *PERLRUNINST is *PERLRUN + everything necessary to find the 1872 modules being built. 1873 1874=cut 1875 1876sub init_PERL { 1877 my($self) = shift; 1878 1879 my @defpath = (); 1880 foreach my $component ($self->{PERL_SRC}, $self->path(), 1881 $Config{binexp}) 1882 { 1883 push @defpath, $component if defined $component; 1884 } 1885 1886 # Build up a set of file names (not command names). 1887 my $thisperl = $self->canonpath($^X); 1888 $thisperl .= $Config{exe_ext} unless 1889 # VMS might have a file version # at the end 1890 $Is{VMS} ? $thisperl =~ m/$Config{exe_ext}(;\d+)?$/i 1891 : $thisperl =~ m/$Config{exe_ext}$/i; 1892 1893 # We need a relative path to perl when in the core. 1894 $thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE}; 1895 1896 my @perls = ($thisperl); 1897 push @perls, map { "$_$Config{exe_ext}" } 1898 ("perl$Config{version}", 'perl5', 'perl'); 1899 1900 # miniperl has priority over all but the canonical perl when in the 1901 # core. Otherwise its a last resort. 1902 my $miniperl = "miniperl$Config{exe_ext}"; 1903 if( $self->{PERL_CORE} ) { 1904 splice @perls, 1, 0, $miniperl; 1905 } 1906 else { 1907 push @perls, $miniperl; 1908 } 1909 1910 $self->{PERL} ||= 1911 $self->find_perl(5.0, \@perls, \@defpath, $Verbose ); 1912 # don't check if perl is executable, maybe they have decided to 1913 # supply switches with perl 1914 1915 # When built for debugging, VMS doesn't create perl.exe but ndbgperl.exe. 1916 my $perl_name = 'perl'; 1917 $perl_name = 'ndbgperl' if $Is{VMS} && 1918 defined $Config{usevmsdebug} && $Config{usevmsdebug} eq 'define'; 1919 1920 # XXX This logic is flawed. If "miniperl" is anywhere in the path 1921 # it will get confused. It should be fixed to work only on the filename. 1922 # Define 'FULLPERL' to be a non-miniperl (used in test: target) 1923 ($self->{FULLPERL} = $self->{PERL}) =~ s/\Q$miniperl\E$/$perl_name$Config{exe_ext}/i 1924 unless $self->{FULLPERL}; 1925 1926 # Little hack to get around VMS's find_perl putting "MCR" in front 1927 # sometimes. 1928 $self->{ABSPERL} = $self->{PERL}; 1929 my $has_mcr = $self->{ABSPERL} =~ s/^MCR\s*//; 1930 if( $self->file_name_is_absolute($self->{ABSPERL}) ) { 1931 $self->{ABSPERL} = '$(PERL)'; 1932 } 1933 else { 1934 $self->{ABSPERL} = $self->rel2abs($self->{ABSPERL}); 1935 1936 # Quote the perl command if it contains whitespace 1937 $self->{ABSPERL} = $self->quote_literal($self->{ABSPERL}) 1938 if $self->{ABSPERL} =~ /\s/; 1939 1940 $self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr; 1941 } 1942 1943 # Are we building the core? 1944 $self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE}; 1945 $self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE}; 1946 1947 # How do we run perl? 1948 foreach my $perl (qw(PERL FULLPERL ABSPERL)) { 1949 my $run = $perl.'RUN'; 1950 1951 $self->{$run} = "\$($perl)"; 1952 1953 # Make sure perl can find itself before it's installed. 1954 $self->{$run} .= q{ "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)"} 1955 if $self->{UNINSTALLED_PERL} || $self->{PERL_CORE}; 1956 1957 $self->{$perl.'RUNINST'} = 1958 sprintf q{$(%sRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"}, $perl; 1959 } 1960 1961 return 1; 1962} 1963 1964 1965=item init_platform 1966 1967=item platform_constants 1968 1969Add MM_Unix_VERSION. 1970 1971=cut 1972 1973sub init_platform { 1974 my($self) = shift; 1975 1976 $self->{MM_Unix_VERSION} = $VERSION; 1977 $self->{PERL_MALLOC_DEF} = '-DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc '. 1978 '-Dfree=Perl_mfree -Drealloc=Perl_realloc '. 1979 '-Dcalloc=Perl_calloc'; 1980 1981} 1982 1983sub platform_constants { 1984 my($self) = shift; 1985 my $make_frag = ''; 1986 1987 foreach my $macro (qw(MM_Unix_VERSION PERL_MALLOC_DEF)) 1988 { 1989 next unless defined $self->{$macro}; 1990 $make_frag .= "$macro = $self->{$macro}\n"; 1991 } 1992 1993 return $make_frag; 1994} 1995 1996 1997=item init_PERM 1998 1999 $mm->init_PERM 2000 2001Called by init_main. Initializes PERL_* 2002 2003=cut 2004 2005sub init_PERM { 2006 my($self) = shift; 2007 2008 $self->{PERM_DIR} = 755 unless defined $self->{PERM_DIR}; 2009 $self->{PERM_RW} = 644 unless defined $self->{PERM_RW}; 2010 $self->{PERM_RWX} = 755 unless defined $self->{PERM_RWX}; 2011 2012 return 1; 2013} 2014 2015 2016=item init_xs 2017 2018 $mm->init_xs 2019 2020Sets up macros having to do with XS code. Currently just INST_STATIC, 2021INST_DYNAMIC and INST_BOOT. 2022 2023=cut 2024 2025sub init_xs { 2026 my $self = shift; 2027 2028 if ($self->has_link_code()) { 2029 $self->{INST_STATIC} = 2030 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT)$(LIB_EXT)'); 2031 $self->{INST_DYNAMIC} = 2032 $self->catfile('$(INST_ARCHAUTODIR)', '$(DLBASE).$(DLEXT)'); 2033 $self->{INST_BOOT} = 2034 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT).bs'); 2035 } else { 2036 $self->{INST_STATIC} = ''; 2037 $self->{INST_DYNAMIC} = ''; 2038 $self->{INST_BOOT} = ''; 2039 } 2040} 2041 2042=item install (o) 2043 2044Defines the install target. 2045 2046=cut 2047 2048sub install { 2049 my($self, %attribs) = @_; 2050 my(@m); 2051 2052 push @m, q{ 2053install :: pure_install doc_install 2054 $(NOECHO) $(NOOP) 2055 2056install_perl :: pure_perl_install doc_perl_install 2057 $(NOECHO) $(NOOP) 2058 2059install_site :: pure_site_install doc_site_install 2060 $(NOECHO) $(NOOP) 2061 2062install_vendor :: pure_vendor_install doc_vendor_install 2063 $(NOECHO) $(NOOP) 2064 2065pure_install :: pure_$(INSTALLDIRS)_install 2066 $(NOECHO) $(NOOP) 2067 2068doc_install :: doc_$(INSTALLDIRS)_install 2069 $(NOECHO) $(NOOP) 2070 2071pure__install : pure_site_install 2072 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site 2073 2074doc__install : doc_site_install 2075 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site 2076 2077pure_perl_install :: all 2078 $(NOECHO) $(MOD_INSTALL) \ 2079}; 2080 2081 push @m, 2082q{ read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \ 2083 write }.$self->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \ 2084} unless $self->{NO_PACKLIST}; 2085 2086 push @m, 2087q{ $(INST_LIB) $(DESTINSTALLPRIVLIB) \ 2088 $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \ 2089 $(INST_BIN) $(DESTINSTALLBIN) \ 2090 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ 2091 $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \ 2092 $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR) 2093 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ 2094 }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{ 2095 2096 2097pure_site_install :: all 2098 $(NOECHO) $(MOD_INSTALL) \ 2099}; 2100 push @m, 2101q{ read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \ 2102 write }.$self->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \ 2103} unless $self->{NO_PACKLIST}; 2104 2105 push @m, 2106q{ $(INST_LIB) $(DESTINSTALLSITELIB) \ 2107 $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \ 2108 $(INST_BIN) $(DESTINSTALLSITEBIN) \ 2109 $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \ 2110 $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \ 2111 $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) 2112 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ 2113 }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{ 2114 2115pure_vendor_install :: all 2116 $(NOECHO) $(MOD_INSTALL) \ 2117}; 2118 push @m, 2119q{ read }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \ 2120 write }.$self->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').q{ \ 2121} unless $self->{NO_PACKLIST}; 2122 2123 push @m, 2124q{ $(INST_LIB) $(DESTINSTALLVENDORLIB) \ 2125 $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \ 2126 $(INST_BIN) $(DESTINSTALLVENDORBIN) \ 2127 $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \ 2128 $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \ 2129 $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR) 2130 2131}; 2132 2133 push @m, q{ 2134doc_perl_install :: all 2135 $(NOECHO) $(NOOP) 2136 2137doc_site_install :: all 2138 $(NOECHO) $(NOOP) 2139 2140doc_vendor_install :: all 2141 $(NOECHO) $(NOOP) 2142 2143} if $self->{NO_PERLLOCAL}; 2144 2145 push @m, q{ 2146doc_perl_install :: all 2147 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod 2148 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) 2149 -$(NOECHO) $(DOC_INSTALL) \ 2150 "Module" "$(NAME)" \ 2151 "installed into" "$(INSTALLPRIVLIB)" \ 2152 LINKTYPE "$(LINKTYPE)" \ 2153 VERSION "$(VERSION)" \ 2154 EXE_FILES "$(EXE_FILES)" \ 2155 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{ 2156 2157doc_site_install :: all 2158 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod 2159 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) 2160 -$(NOECHO) $(DOC_INSTALL) \ 2161 "Module" "$(NAME)" \ 2162 "installed into" "$(INSTALLSITELIB)" \ 2163 LINKTYPE "$(LINKTYPE)" \ 2164 VERSION "$(VERSION)" \ 2165 EXE_FILES "$(EXE_FILES)" \ 2166 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{ 2167 2168doc_vendor_install :: all 2169 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod 2170 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) 2171 -$(NOECHO) $(DOC_INSTALL) \ 2172 "Module" "$(NAME)" \ 2173 "installed into" "$(INSTALLVENDORLIB)" \ 2174 LINKTYPE "$(LINKTYPE)" \ 2175 VERSION "$(VERSION)" \ 2176 EXE_FILES "$(EXE_FILES)" \ 2177 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{ 2178 2179} unless $self->{NO_PERLLOCAL}; 2180 2181 push @m, q{ 2182uninstall :: uninstall_from_$(INSTALLDIRS)dirs 2183 $(NOECHO) $(NOOP) 2184 2185uninstall_from_perldirs :: 2186 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ 2187 2188uninstall_from_sitedirs :: 2189 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ 2190 2191uninstall_from_vendordirs :: 2192 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{ 2193}; 2194 2195 join("",@m); 2196} 2197 2198=item installbin (o) 2199 2200Defines targets to make and to install EXE_FILES. 2201 2202=cut 2203 2204sub installbin { 2205 my($self) = shift; 2206 2207 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY"; 2208 my @exefiles = @{$self->{EXE_FILES}}; 2209 return "" unless @exefiles; 2210 2211 @exefiles = map vmsify($_), @exefiles if $Is{VMS}; 2212 2213 my %fromto; 2214 for my $from (@exefiles) { 2215 my($path)= $self->catfile('$(INST_SCRIPT)', basename($from)); 2216 2217 local($_) = $path; # for backwards compatibility 2218 my $to = $self->libscan($path); 2219 print "libscan($from) => '$to'\n" if ($Verbose >=2); 2220 2221 $to = vmsify($to) if $Is{VMS}; 2222 $fromto{$from} = $to; 2223 } 2224 my @to = values %fromto; 2225 2226 my @m; 2227 push(@m, qq{ 2228EXE_FILES = @exefiles 2229 2230pure_all :: @to 2231 \$(NOECHO) \$(NOOP) 2232 2233realclean :: 2234}); 2235 2236 # realclean can get rather large. 2237 push @m, map "\t$_\n", $self->split_command('$(RM_F)', @to); 2238 push @m, "\n"; 2239 2240 2241 # A target for each exe file. 2242 while (my($from,$to) = each %fromto) { 2243 last unless defined $from; 2244 2245 push @m, sprintf <<'MAKE', $to, $from, $to, $from, $to, $to, $to; 2246%s : %s $(FIRST_MAKEFILE) $(INST_SCRIPT)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists 2247 $(NOECHO) $(RM_F) %s 2248 $(CP) %s %s 2249 $(FIXIN) %s 2250 -$(NOECHO) $(CHMOD) $(PERM_RWX) %s 2251 2252MAKE 2253 2254 } 2255 2256 join "", @m; 2257} 2258 2259 2260=item linkext (o) 2261 2262Defines the linkext target which in turn defines the LINKTYPE. 2263 2264=cut 2265 2266sub linkext { 2267 my($self, %attribs) = @_; 2268 # LINKTYPE => static or dynamic or '' 2269 my($linktype) = defined $attribs{LINKTYPE} ? 2270 $attribs{LINKTYPE} : '$(LINKTYPE)'; 2271 " 2272linkext :: $linktype 2273 \$(NOECHO) \$(NOOP) 2274"; 2275} 2276 2277=item lsdir 2278 2279Takes as arguments a directory name and a regular expression. Returns 2280all entries in the directory that match the regular expression. 2281 2282=cut 2283 2284sub lsdir { 2285 my($self) = shift; 2286 my($dir, $regex) = @_; 2287 my(@ls); 2288 my $dh = new DirHandle; 2289 $dh->open($dir || ".") or return (); 2290 @ls = $dh->read; 2291 $dh->close; 2292 @ls = grep(/$regex/, @ls) if $regex; 2293 @ls; 2294} 2295 2296=item macro (o) 2297 2298Simple subroutine to insert the macros defined by the macro attribute 2299into the Makefile. 2300 2301=cut 2302 2303sub macro { 2304 my($self,%attribs) = @_; 2305 my(@m,$key,$val); 2306 while (($key,$val) = each %attribs){ 2307 last unless defined $key; 2308 push @m, "$key = $val\n"; 2309 } 2310 join "", @m; 2311} 2312 2313=item makeaperl (o) 2314 2315Called by staticmake. Defines how to write the Makefile to produce a 2316static new perl. 2317 2318By default the Makefile produced includes all the static extensions in 2319the perl library. (Purified versions of library files, e.g., 2320DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.) 2321 2322=cut 2323 2324sub makeaperl { 2325 my($self, %attribs) = @_; 2326 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) = 2327 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)}; 2328 my(@m); 2329 push @m, " 2330# --- MakeMaker makeaperl section --- 2331MAP_TARGET = $target 2332FULLPERL = $self->{FULLPERL} 2333"; 2334 return join '', @m if $self->{PARENT}; 2335 2336 my($dir) = join ":", @{$self->{DIR}}; 2337 2338 unless ($self->{MAKEAPERL}) { 2339 push @m, q{ 2340$(MAP_TARGET) :: static $(MAKE_APERL_FILE) 2341 $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@ 2342 2343$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib 2344 $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) 2345 $(NOECHO) $(PERLRUNINST) \ 2346 Makefile.PL DIR=}, $dir, q{ \ 2347 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ 2348 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=}; 2349 2350 foreach (@ARGV){ 2351 if( /\s/ ){ 2352 s/=(.*)/='$1'/; 2353 } 2354 push @m, " \\\n\t\t$_"; 2355 } 2356# push @m, map( " \\\n\t\t$_", @ARGV ); 2357 push @m, "\n"; 2358 2359 return join '', @m; 2360 } 2361 2362 2363 2364 my($cccmd, $linkcmd, $lperl); 2365 2366 2367 $cccmd = $self->const_cccmd($libperl); 2368 $cccmd =~ s/^CCCMD\s*=\s*//; 2369 $cccmd =~ s/\$\(INC\)/ "-I$self->{PERL_INC}" /; 2370 $cccmd .= " $Config{cccdlflags}" 2371 if ($Config{useshrplib} eq 'true'); 2372 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/; 2373 2374 # The front matter of the linkcommand... 2375 $linkcmd = join ' ', "\$(CC)", 2376 grep($_, @Config{qw(ldflags ccdlflags)}); 2377 $linkcmd =~ s/\s+/ /g; 2378 $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,; 2379 2380 # Which *.a files could we make use of... 2381 my %static; 2382 require File::Find; 2383 File::Find::find(sub { 2384 return unless m/\Q$self->{LIB_EXT}\E$/; 2385 2386 # Skip perl's libraries. 2387 return if m/^libperl/ or m/^perl\Q$self->{LIB_EXT}\E$/; 2388 2389 # Skip purified versions of libraries 2390 # (e.g., DynaLoader_pure_p1_c0_032.a) 2391 return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure"; 2392 2393 if( exists $self->{INCLUDE_EXT} ){ 2394 my $found = 0; 2395 2396 (my $xx = $File::Find::name) =~ s,.*?/auto/,,s; 2397 $xx =~ s,/?$_,,; 2398 $xx =~ s,/,::,g; 2399 2400 # Throw away anything not explicitly marked for inclusion. 2401 # DynaLoader is implied. 2402 foreach my $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){ 2403 if( $xx eq $incl ){ 2404 $found++; 2405 last; 2406 } 2407 } 2408 return unless $found; 2409 } 2410 elsif( exists $self->{EXCLUDE_EXT} ){ 2411 (my $xx = $File::Find::name) =~ s,.*?/auto/,,s; 2412 $xx =~ s,/?$_,,; 2413 $xx =~ s,/,::,g; 2414 2415 # Throw away anything explicitly marked for exclusion 2416 foreach my $excl (@{$self->{EXCLUDE_EXT}}){ 2417 return if( $xx eq $excl ); 2418 } 2419 } 2420 2421 # don't include the installed version of this extension. I 2422 # leave this line here, although it is not necessary anymore: 2423 # I patched minimod.PL instead, so that Miniperl.pm won't 2424 # include duplicates 2425 2426 # Once the patch to minimod.PL is in the distribution, I can 2427 # drop it 2428 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}\z:; 2429 use Cwd 'cwd'; 2430 $static{cwd() . "/" . $_}++; 2431 }, grep( -d $_, @{$searchdirs || []}) ); 2432 2433 # We trust that what has been handed in as argument, will be buildable 2434 $static = [] unless $static; 2435 @static{@{$static}} = (1) x @{$static}; 2436 2437 $extra = [] unless $extra && ref $extra eq 'ARRAY'; 2438 for (sort keys %static) { 2439 next unless /\Q$self->{LIB_EXT}\E\z/; 2440 $_ = dirname($_) . "/extralibs.ld"; 2441 push @$extra, $_; 2442 } 2443 2444 s/^(.*)/"-I$1"/ for @{$perlinc || []}; 2445 2446 $target ||= "perl"; 2447 $tmp ||= "."; 2448 2449# MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we 2450# regenerate the Makefiles, MAP_STATIC and the dependencies for 2451# extralibs.all are computed correctly 2452 push @m, " 2453MAP_LINKCMD = $linkcmd 2454MAP_PERLINC = @{$perlinc || []} 2455MAP_STATIC = ", 2456join(" \\\n\t", reverse sort keys %static), " 2457 2458MAP_PRELIBS = $Config{perllibs} $Config{cryptlib} 2459"; 2460 2461 if (defined $libperl) { 2462 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/; 2463 } 2464 unless ($libperl && -f $lperl) { # Ilya's code... 2465 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE"; 2466 $dir = "$self->{PERL_ARCHLIB}/.." if $self->{UNINSTALLED_PERL}; 2467 $libperl ||= "libperl$self->{LIB_EXT}"; 2468 $libperl = "$dir/$libperl"; 2469 $lperl ||= "libperl$self->{LIB_EXT}"; 2470 $lperl = "$dir/$lperl"; 2471 2472 if (! -f $libperl and ! -f $lperl) { 2473 # We did not find a static libperl. Maybe there is a shared one? 2474 if ($Is{SunOS}) { 2475 $lperl = $libperl = "$dir/$Config{libperl}"; 2476 # SUNOS ld does not take the full path to a shared library 2477 $libperl = '' if $Is{SunOS4}; 2478 } 2479 } 2480 2481 print "Warning: $libperl not found 2482 If you're going to build a static perl binary, make sure perl is installed 2483 otherwise ignore this warning\n" 2484 unless (-f $lperl || defined($self->{PERL_SRC})); 2485 } 2486 2487 # SUNOS ld does not take the full path to a shared library 2488 my $llibperl = $libperl ? '$(MAP_LIBPERL)' : '-lperl'; 2489 2490 push @m, " 2491MAP_LIBPERL = $libperl 2492LLIBPERL = $llibperl 2493"; 2494 2495 push @m, ' 2496$(INST_ARCHAUTODIR)/extralibs.all : $(INST_ARCHAUTODIR)$(DFSEP).exists '.join(" \\\n\t", @$extra).' 2497 $(NOECHO) $(RM_F) $@ 2498 $(NOECHO) $(TOUCH) $@ 2499'; 2500 2501 foreach my $catfile (@$extra){ 2502 push @m, "\tcat $catfile >> \$\@\n"; 2503 } 2504 2505push @m, " 2506\$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all 2507 \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(LDFROM) \$(MAP_STATIC) \$(LLIBPERL) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS) 2508 \$(NOECHO) \$(ECHO) 'To install the new \"\$(MAP_TARGET)\" binary, call' 2509 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)' 2510 \$(NOECHO) \$(ECHO) 'To remove the intermediate files say' 2511 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename map_clean' 2512 2513$tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c 2514"; 2515 push @m, "\t".$self->cd($tmp, qq[$cccmd "-I\$(PERL_INC)" perlmain.c])."\n"; 2516 2517 push @m, qq{ 2518$tmp/perlmain.c: $makefilename}, q{ 2519 $(NOECHO) $(ECHO) Writing $@ 2520 $(NOECHO) $(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \\ 2521 -e "writemain(grep s#.*/auto/##s, split(q| |, q|$(MAP_STATIC)|))" > $@t && $(MV) $@t $@ 2522 2523}; 2524 push @m, "\t", q{$(NOECHO) $(PERL) $(INSTALLSCRIPT)/fixpmain 2525} if (defined (&Dos::UseLFN) && Dos::UseLFN()==0); 2526 2527 2528 push @m, q{ 2529doc_inst_perl : 2530 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod 2531 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) 2532 -$(NOECHO) $(DOC_INSTALL) \ 2533 "Perl binary" "$(MAP_TARGET)" \ 2534 MAP_STATIC "$(MAP_STATIC)" \ 2535 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \ 2536 MAP_LIBPERL "$(MAP_LIBPERL)" \ 2537 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{ 2538 2539}; 2540 2541 push @m, q{ 2542inst_perl : pure_inst_perl doc_inst_perl 2543 2544pure_inst_perl : $(MAP_TARGET) 2545 }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{ 2546 2547clean :: map_clean 2548 2549map_clean : 2550 }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all 2551}; 2552 2553 join '', @m; 2554} 2555 2556=item makefile (o) 2557 2558Defines how to rewrite the Makefile. 2559 2560=cut 2561 2562sub makefile { 2563 my($self) = shift; 2564 my $m; 2565 # We do not know what target was originally specified so we 2566 # must force a manual rerun to be sure. But as it should only 2567 # happen very rarely it is not a significant problem. 2568 $m = ' 2569$(OBJECT) : $(FIRST_MAKEFILE) 2570 2571' if $self->{OBJECT}; 2572 2573 my $newer_than_target = $Is{VMS} ? '$(MMS$SOURCE_LIST)' : '$?'; 2574 my $mpl_args = join " ", map qq["$_"], @ARGV; 2575 my $cross = ''; 2576 if (defined $::Cross::platform) { 2577 # Inherited from win32/buildext.pl 2578 $cross = "-MCross=$::Cross::platform "; 2579 } 2580 $m .= sprintf <<'MAKE_FRAG', $newer_than_target, $cross, $mpl_args; 2581# We take a very conservative approach here, but it's worth it. 2582# We move Makefile to Makefile.old here to avoid gnu make looping. 2583$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) 2584 $(NOECHO) $(ECHO) "Makefile out-of-date with respect to %s" 2585 $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." 2586 -$(NOECHO) $(RM_F) $(MAKEFILE_OLD) 2587 -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) 2588 - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL) 2589 $(PERLRUN) %sMakefile.PL %s 2590 $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" 2591 $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <==" 2592 $(FALSE) 2593 2594MAKE_FRAG 2595 2596 return $m; 2597} 2598 2599 2600=item maybe_command 2601 2602Returns true, if the argument is likely to be a command. 2603 2604=cut 2605 2606sub maybe_command { 2607 my($self,$file) = @_; 2608 return $file if -x $file && ! -d $file; 2609 return; 2610} 2611 2612 2613=item needs_linking (o) 2614 2615Does this module need linking? Looks into subdirectory objects (see 2616also has_link_code()) 2617 2618=cut 2619 2620sub needs_linking { 2621 my($self) = shift; 2622 2623 my $caller = (caller(0))[3]; 2624 confess("needs_linking called too early") if 2625 $caller =~ /^ExtUtils::MakeMaker::/; 2626 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING}; 2627 if ($self->has_link_code or $self->{MAKEAPERL}){ 2628 $self->{NEEDS_LINKING} = 1; 2629 return 1; 2630 } 2631 foreach my $child (keys %{$self->{CHILDREN}}) { 2632 if ($self->{CHILDREN}->{$child}->needs_linking) { 2633 $self->{NEEDS_LINKING} = 1; 2634 return 1; 2635 } 2636 } 2637 return $self->{NEEDS_LINKING} = 0; 2638} 2639 2640 2641=item parse_abstract 2642 2643parse a file and return what you think is the ABSTRACT 2644 2645=cut 2646 2647sub parse_abstract { 2648 my($self,$parsefile) = @_; 2649 my $result; 2650 2651 local $/ = "\n"; 2652 open(my $fh, '<', $parsefile) or die "Could not open '$parsefile': $!"; 2653 my $inpod = 0; 2654 my $package = $self->{DISTNAME}; 2655 $package =~ s/-/::/g; 2656 while (<$fh>) { 2657 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod; 2658 next if !$inpod; 2659 chop; 2660 if ( /^($package(?:\.pm)? \s+ -+ \s+)(.*)/x ) { 2661 $result = $2; 2662 next; 2663 } 2664 next unless $result; 2665 if ( $result && ( /^\s*$/ || /^\=/ ) ) { 2666 last; 2667 } 2668 $result = join ' ', $result, $_; 2669 } 2670 close $fh; 2671 2672 return $result; 2673} 2674 2675=item parse_version 2676 2677 my $version = MM->parse_version($file); 2678 2679Parse a $file and return what $VERSION is set to by the first assignment. 2680It will return the string "undef" if it can't figure out what $VERSION 2681is. $VERSION should be for all to see, so C<our $VERSION> or plain $VERSION 2682are okay, but C<my $VERSION> is not. 2683 2684C<<package Foo VERSION>> is also checked for. The first version 2685declaration found is used, but this may change as it differs from how 2686Perl does it. 2687 2688parse_version() will try to C<use version> before checking for 2689C<$VERSION> so the following will work. 2690 2691 $VERSION = qv(1.2.3); 2692 2693=cut 2694 2695sub parse_version { 2696 my($self,$parsefile) = @_; 2697 my $result; 2698 2699 local $/ = "\n"; 2700 local $_; 2701 open(my $fh, '<', $parsefile) or die "Could not open '$parsefile': $!"; 2702 my $inpod = 0; 2703 while (<$fh>) { 2704 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod; 2705 next if $inpod || /^\s*#/; 2706 chop; 2707 next if /^\s*(if|unless|elsif)/; 2708 if ( m{^ \s* package \s+ \w[\w\:\']* \s+ (v?[0-9._]+) \s* ; }x ) { 2709 local $^W = 0; 2710 $result = $1; 2711 } 2712 elsif ( m{(?<!\\) ([\$*]) (([\w\:\']*) \bVERSION)\b .* (?<![<>=!])\=[^=]}x ) { 2713 $result = $self->get_version($parsefile, $1, $2); 2714 } 2715 else { 2716 next; 2717 } 2718 last if defined $result; 2719 } 2720 close $fh; 2721 2722 if ( defined $result && $result !~ /^v?[\d_\.]+$/ ) { 2723 require version; 2724 my $normal = eval { version->parse( $result ) }; 2725 $result = $normal if defined $normal; 2726 } 2727 $result = "undef" unless defined $result; 2728 return $result; 2729} 2730 2731sub get_version 2732{ 2733 my ($self, $parsefile, $sigil, $name) = @_; 2734 my $eval = qq{ 2735 package ExtUtils::MakeMaker::_version; 2736 no strict; 2737 BEGIN { eval { 2738 # Ensure any version() routine which might have leaked 2739 # into this package has been deleted. Interferes with 2740 # version->import() 2741 undef *version; 2742 require version; 2743 "version"->import; 2744 } } 2745 2746 local $sigil$name; 2747 \$$name=undef; 2748 do { 2749 $_ 2750 }; 2751 \$$name; 2752 }; 2753 $eval = $1 if $eval =~ m{^(.+)}s; 2754 local $^W = 0; 2755 my $result = eval($eval); ## no critic 2756 warn "Could not eval '$eval' in $parsefile: $@" if $@; 2757 $result; 2758} 2759 2760 2761=item pasthru (o) 2762 2763Defines the string that is passed to recursive make calls in 2764subdirectories. 2765 2766=cut 2767 2768sub pasthru { 2769 my($self) = shift; 2770 my(@m); 2771 2772 my(@pasthru); 2773 my($sep) = $Is{VMS} ? ',' : ''; 2774 $sep .= "\\\n\t"; 2775 2776 foreach my $key (qw(LIB LIBPERL_A LINKTYPE OPTIMIZE 2777 PREFIX INSTALL_BASE) 2778 ) 2779 { 2780 next unless defined $self->{$key}; 2781 push @pasthru, "$key=\"\$($key)\""; 2782 } 2783 2784 foreach my $key (qw(DEFINE INC)) { 2785 next unless defined $self->{$key}; 2786 push @pasthru, "PASTHRU_$key=\"\$(PASTHRU_$key)\""; 2787 } 2788 2789 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n"; 2790 join "", @m; 2791} 2792 2793=item perl_script 2794 2795Takes one argument, a file name, and returns the file name, if the 2796argument is likely to be a perl script. On MM_Unix this is true for 2797any ordinary, readable file. 2798 2799=cut 2800 2801sub perl_script { 2802 my($self,$file) = @_; 2803 return $file if -r $file && -f _; 2804 return; 2805} 2806 2807=item perldepend (o) 2808 2809Defines the dependency from all *.h files that come with the perl 2810distribution. 2811 2812=cut 2813 2814sub perldepend { 2815 my($self) = shift; 2816 my(@m); 2817 2818 my $make_config = $self->cd('$(PERL_SRC)', '$(MAKE) lib/Config.pm'); 2819 2820 push @m, sprintf <<'MAKE_FRAG', $make_config if $self->{PERL_SRC}; 2821# Check for unpropogated config.sh changes. Should never happen. 2822# We do NOT just update config.h because that is not sufficient. 2823# An out of date config.h is not fatal but complains loudly! 2824$(PERL_INC)/config.h: $(PERL_SRC)/config.sh 2825 -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; $(FALSE) 2826 2827$(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh 2828 $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh" 2829 %s 2830MAKE_FRAG 2831 2832 return join "", @m unless $self->needs_linking; 2833 2834 if ($self->{OBJECT}) { 2835 # Need to add an object file dependency on the perl headers. 2836 # this is very important for XS modules in perl.git development. 2837 push @m, $self->_perl_header_files_fragment("/"); # Directory separator between $(PERL_INC)/header.h 2838 } 2839 2840 push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}}; 2841 2842 return join "\n", @m; 2843} 2844 2845 2846=item pm_to_blib 2847 2848Defines target that copies all files in the hash PM to their 2849destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION> 2850 2851=cut 2852 2853sub pm_to_blib { 2854 my $self = shift; 2855 my($autodir) = $self->catdir('$(INST_LIB)','auto'); 2856 my $r = q{ 2857pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM) 2858}; 2859 2860 # VMS will swallow '' and PM_FILTER is often empty. So use q[] 2861 my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']); 2862pm_to_blib({\@ARGV}, '$autodir', q[\$(PM_FILTER)], '\$(PERM_DIR)') 2863CODE 2864 2865 my @cmds = $self->split_command($pm_to_blib, 2866 map { ($_, $self->{PM}->{$_}) } sort keys %{$self->{PM}}); 2867 2868 $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds; 2869 $r .= qq{\t\$(NOECHO) \$(TOUCH) pm_to_blib\n}; 2870 2871 return $r; 2872} 2873 2874=item post_constants (o) 2875 2876Returns an empty string per default. Dedicated to overrides from 2877within Makefile.PL after all constants have been defined. 2878 2879=cut 2880 2881sub post_constants{ 2882 ""; 2883} 2884 2885=item post_initialize (o) 2886 2887Returns an empty string per default. Used in Makefile.PLs to add some 2888chunk of text to the Makefile after the object is initialized. 2889 2890=cut 2891 2892sub post_initialize { 2893 ""; 2894} 2895 2896=item postamble (o) 2897 2898Returns an empty string. Can be used in Makefile.PLs to write some 2899text to the Makefile at the end. 2900 2901=cut 2902 2903sub postamble { 2904 ""; 2905} 2906 2907# transform dot-separated version string into comma-separated quadruple 2908# examples: '1.2.3.4.5' => '1,2,3,4' 2909# '1.2.3' => '1,2,3,0' 2910sub _ppd_version { 2911 my ($self, $string) = @_; 2912 return join ',', ((split /\./, $string), (0) x 4)[0..3]; 2913} 2914 2915=item ppd 2916 2917Defines target that creates a PPD (Perl Package Description) file 2918for a binary distribution. 2919 2920=cut 2921 2922sub ppd { 2923 my($self) = @_; 2924 2925 my $abstract = $self->{ABSTRACT} || ''; 2926 $abstract =~ s/\n/\\n/sg; 2927 $abstract =~ s/</</g; 2928 $abstract =~ s/>/>/g; 2929 2930 my $author = join(', ',@{$self->{AUTHOR} || []}); 2931 $author =~ s/</</g; 2932 $author =~ s/>/>/g; 2933 2934 my $ppd_file = '$(DISTNAME).ppd'; 2935 2936 my @ppd_cmds = $self->echo(<<'PPD_HTML', $ppd_file, { append => 0, allow_variables => 1 }); 2937<SOFTPKG NAME="$(DISTNAME)" VERSION="$(VERSION)"> 2938PPD_HTML 2939 2940 my $ppd_xml = sprintf <<'PPD_HTML', $abstract, $author; 2941 <ABSTRACT>%s</ABSTRACT> 2942 <AUTHOR>%s</AUTHOR> 2943PPD_HTML 2944 2945 $ppd_xml .= " <IMPLEMENTATION>\n"; 2946 if ( $self->{MIN_PERL_VERSION} ) { 2947 my $min_perl_version = $self->_ppd_version($self->{MIN_PERL_VERSION}); 2948 $ppd_xml .= sprintf <<'PPD_PERLVERS', $min_perl_version; 2949 <PERLCORE VERSION="%s" /> 2950PPD_PERLVERS 2951 2952 } 2953 2954 # Don't add "perl" to requires. perl dependencies are 2955 # handles by ARCHITECTURE. 2956 my %prereqs = %{$self->{PREREQ_PM}}; 2957 delete $prereqs{perl}; 2958 2959 # Build up REQUIRE 2960 foreach my $prereq (sort keys %prereqs) { 2961 my $name = $prereq; 2962 $name .= '::' unless $name =~ /::/; 2963 my $version = $prereqs{$prereq}+0; # force numification 2964 2965 my %attrs = ( NAME => $name ); 2966 $attrs{VERSION} = $version if $version; 2967 my $attrs = join " ", map { qq[$_="$attrs{$_}"] } keys %attrs; 2968 $ppd_xml .= qq( <REQUIRE $attrs />\n); 2969 } 2970 2971 my $archname = $Config{archname}; 2972 if ($] >= 5.008) { 2973 # archname did not change from 5.6 to 5.8, but those versions may 2974 # not be not binary compatible so now we append the part of the 2975 # version that changes when binary compatibility may change 2976 $archname .= "-$Config{PERL_REVISION}.$Config{PERL_VERSION}"; 2977 } 2978 $ppd_xml .= sprintf <<'PPD_OUT', $archname; 2979 <ARCHITECTURE NAME="%s" /> 2980PPD_OUT 2981 2982 if ($self->{PPM_INSTALL_SCRIPT}) { 2983 if ($self->{PPM_INSTALL_EXEC}) { 2984 $ppd_xml .= sprintf qq{ <INSTALL EXEC="%s">%s</INSTALL>\n}, 2985 $self->{PPM_INSTALL_EXEC}, $self->{PPM_INSTALL_SCRIPT}; 2986 } 2987 else { 2988 $ppd_xml .= sprintf qq{ <INSTALL>%s</INSTALL>\n}, 2989 $self->{PPM_INSTALL_SCRIPT}; 2990 } 2991 } 2992 2993 if ($self->{PPM_UNINSTALL_SCRIPT}) { 2994 if ($self->{PPM_UNINSTALL_EXEC}) { 2995 $ppd_xml .= sprintf qq{ <UNINSTALL EXEC="%s">%s</UNINSTALL>\n}, 2996 $self->{PPM_UNINSTALL_EXEC}, $self->{PPM_UNINSTALL_SCRIPT}; 2997 } 2998 else { 2999 $ppd_xml .= sprintf qq{ <UNINSTALL>%s</UNINSTALL>\n}, 3000 $self->{PPM_UNINSTALL_SCRIPT}; 3001 } 3002 } 3003 3004 my ($bin_location) = $self->{BINARY_LOCATION} || ''; 3005 $bin_location =~ s/\\/\\\\/g; 3006 3007 $ppd_xml .= sprintf <<'PPD_XML', $bin_location; 3008 <CODEBASE HREF="%s" /> 3009 </IMPLEMENTATION> 3010</SOFTPKG> 3011PPD_XML 3012 3013 push @ppd_cmds, $self->echo($ppd_xml, $ppd_file, { append => 1 }); 3014 3015 return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds; 3016# Creates a PPD (Perl Package Description) for a binary distribution. 3017ppd : 3018 %s 3019PPD_OUT 3020 3021} 3022 3023=item prefixify 3024 3025 $MM->prefixify($var, $prefix, $new_prefix, $default); 3026 3027Using either $MM->{uc $var} || $Config{lc $var}, it will attempt to 3028replace it's $prefix with a $new_prefix. 3029 3030Should the $prefix fail to match I<AND> a PREFIX was given as an 3031argument to WriteMakefile() it will set it to the $new_prefix + 3032$default. This is for systems whose file layouts don't neatly fit into 3033our ideas of prefixes. 3034 3035This is for heuristics which attempt to create directory structures 3036that mirror those of the installed perl. 3037 3038For example: 3039 3040 $MM->prefixify('installman1dir', '/usr', '/home/foo', 'man/man1'); 3041 3042this will attempt to remove '/usr' from the front of the 3043$MM->{INSTALLMAN1DIR} path (initializing it to $Config{installman1dir} 3044if necessary) and replace it with '/home/foo'. If this fails it will 3045simply use '/home/foo/man/man1'. 3046 3047=cut 3048 3049sub prefixify { 3050 my($self,$var,$sprefix,$rprefix,$default) = @_; 3051 3052 my $path = $self->{uc $var} || 3053 $Config_Override{lc $var} || $Config{lc $var} || ''; 3054 3055 $rprefix .= '/' if $sprefix =~ m|/$|; 3056 3057 warn " prefixify $var => $path\n" if $Verbose >= 2; 3058 warn " from $sprefix to $rprefix\n" if $Verbose >= 2; 3059 3060 if( $self->{ARGS}{PREFIX} && 3061 $path !~ s{^\Q$sprefix\E\b}{$rprefix}s ) 3062 { 3063 3064 warn " cannot prefix, using default.\n" if $Verbose >= 2; 3065 warn " no default!\n" if !$default && $Verbose >= 2; 3066 3067 $path = $self->catdir($rprefix, $default) if $default; 3068 } 3069 3070 print " now $path\n" if $Verbose >= 2; 3071 return $self->{uc $var} = $path; 3072} 3073 3074 3075=item processPL (o) 3076 3077Defines targets to run *.PL files. 3078 3079=cut 3080 3081sub processPL { 3082 my $self = shift; 3083 my $pl_files = $self->{PL_FILES}; 3084 3085 return "" unless $pl_files; 3086 3087 my $m = ''; 3088 foreach my $plfile (sort keys %$pl_files) { 3089 my $list = ref($pl_files->{$plfile}) 3090 ? $pl_files->{$plfile} 3091 : [$pl_files->{$plfile}]; 3092 3093 foreach my $target (@$list) { 3094 if( $Is{VMS} ) { 3095 $plfile = vmsify($self->eliminate_macros($plfile)); 3096 $target = vmsify($self->eliminate_macros($target)); 3097 } 3098 3099 # Normally a .PL file runs AFTER pm_to_blib so it can have 3100 # blib in its @INC and load the just built modules. BUT if 3101 # the generated module is something in $(TO_INST_PM) which 3102 # pm_to_blib depends on then it can't depend on pm_to_blib 3103 # else we have a dependency loop. 3104 my $pm_dep; 3105 my $perlrun; 3106 if( defined $self->{PM}{$target} ) { 3107 $pm_dep = ''; 3108 $perlrun = 'PERLRUN'; 3109 } 3110 else { 3111 $pm_dep = 'pm_to_blib'; 3112 $perlrun = 'PERLRUNINST'; 3113 } 3114 3115 $m .= <<MAKE_FRAG; 3116 3117all :: $target 3118 \$(NOECHO) \$(NOOP) 3119 3120$target :: $plfile $pm_dep 3121 \$($perlrun) $plfile $target 3122MAKE_FRAG 3123 3124 } 3125 } 3126 3127 return $m; 3128} 3129 3130=item quote_paren 3131 3132Backslashes parentheses C<()> in command line arguments. 3133Doesn't handle recursive Makefile C<$(...)> constructs, 3134but handles simple ones. 3135 3136=cut 3137 3138sub quote_paren { 3139 my $arg = shift; 3140 $arg =~ s{\$\((.+?)\)}{\$\\\\($1\\\\)}g; # protect $(...) 3141 $arg =~ s{(?<!\\)([()])}{\\$1}g; # quote unprotected 3142 $arg =~ s{\$\\\\\((.+?)\\\\\)}{\$($1)}g; # unprotect $(...) 3143 return $arg; 3144} 3145 3146=item replace_manpage_separator 3147 3148 my $man_name = $MM->replace_manpage_separator($file_path); 3149 3150Takes the name of a package, which may be a nested package, in the 3151form 'Foo/Bar.pm' and replaces the slash with C<::> or something else 3152safe for a man page file name. Returns the replacement. 3153 3154=cut 3155 3156sub replace_manpage_separator { 3157 my($self,$man) = @_; 3158 3159 $man =~ s,/+,::,g; 3160 return $man; 3161} 3162 3163 3164=item cd 3165 3166=cut 3167 3168sub cd { 3169 my($self, $dir, @cmds) = @_; 3170 3171 # No leading tab and no trailing newline makes for easier embedding 3172 my $make_frag = join "\n\t", map { "cd $dir && $_" } @cmds; 3173 3174 return $make_frag; 3175} 3176 3177=item oneliner 3178 3179=cut 3180 3181sub oneliner { 3182 my($self, $cmd, $switches) = @_; 3183 $switches = [] unless defined $switches; 3184 3185 # Strip leading and trailing newlines 3186 $cmd =~ s{^\n+}{}; 3187 $cmd =~ s{\n+$}{}; 3188 3189 my @cmds = split /\n/, $cmd; 3190 $cmd = join " \n\t -e ", map $self->quote_literal($_), @cmds; 3191 $cmd = $self->escape_newlines($cmd); 3192 3193 $switches = join ' ', @$switches; 3194 3195 return qq{\$(ABSPERLRUN) $switches -e $cmd --}; 3196} 3197 3198 3199=item quote_literal 3200 3201=cut 3202 3203sub quote_literal { 3204 my($self, $text, $opts) = @_; 3205 $opts->{allow_variables} = 1 unless defined $opts->{allow_variables}; 3206 3207 # Quote single quotes 3208 $text =~ s{'}{'\\''}g; 3209 3210 $text = $opts->{allow_variables} 3211 ? $self->escape_dollarsigns($text) : $self->escape_all_dollarsigns($text); 3212 3213 return "'$text'"; 3214} 3215 3216 3217=item escape_newlines 3218 3219=cut 3220 3221sub escape_newlines { 3222 my($self, $text) = @_; 3223 3224 $text =~ s{\n}{\\\n}g; 3225 3226 return $text; 3227} 3228 3229 3230=item max_exec_len 3231 3232Using POSIX::ARG_MAX. Otherwise falling back to 4096. 3233 3234=cut 3235 3236sub max_exec_len { 3237 my $self = shift; 3238 3239 if (!defined $self->{_MAX_EXEC_LEN}) { 3240 if (my $arg_max = eval { require POSIX; &POSIX::ARG_MAX }) { 3241 $self->{_MAX_EXEC_LEN} = $arg_max; 3242 } 3243 else { # POSIX minimum exec size 3244 $self->{_MAX_EXEC_LEN} = 4096; 3245 } 3246 } 3247 3248 return $self->{_MAX_EXEC_LEN}; 3249} 3250 3251 3252=item static (o) 3253 3254Defines the static target. 3255 3256=cut 3257 3258sub static { 3259# --- Static Loading Sections --- 3260 3261 my($self) = shift; 3262 ' 3263## $(INST_PM) has been moved to the all: target. 3264## It remains here for awhile to allow for old usage: "make static" 3265static :: $(FIRST_MAKEFILE) $(INST_STATIC) 3266 $(NOECHO) $(NOOP) 3267'; 3268} 3269 3270=item static_lib (o) 3271 3272Defines how to produce the *.a (or equivalent) files. 3273 3274=cut 3275 3276sub static_lib { 3277 my($self) = @_; 3278 return '' unless $self->has_link_code; 3279 3280 my(@m); 3281 push(@m, <<'END'); 3282 3283$(INST_STATIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists 3284 $(RM_RF) $@ 3285END 3286 3287 # If this extension has its own library (eg SDBM_File) 3288 # then copy that to $(INST_STATIC) and add $(OBJECT) into it. 3289 push(@m, <<'MAKE_FRAG') if $self->{MYEXTLIB}; 3290 $(CP) $(MYEXTLIB) $@ 3291MAKE_FRAG 3292 3293 my $ar; 3294 if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) { 3295 # Prefer the absolute pathed ar if available so that PATH 3296 # doesn't confuse us. Perl itself is built with the full_ar. 3297 $ar = 'FULL_AR'; 3298 } else { 3299 $ar = 'AR'; 3300 } 3301 push @m, sprintf <<'MAKE_FRAG', $ar; 3302 $(%s) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@ 3303 $(CHMOD) $(PERM_RWX) $@ 3304 $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld 3305MAKE_FRAG 3306 3307 # Old mechanism - still available: 3308 push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS}; 3309 $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs 3310MAKE_FRAG 3311 3312 join('', @m); 3313} 3314 3315=item staticmake (o) 3316 3317Calls makeaperl. 3318 3319=cut 3320 3321sub staticmake { 3322 my($self, %attribs) = @_; 3323 my(@static); 3324 3325 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB}); 3326 3327 # And as it's not yet built, we add the current extension 3328 # but only if it has some C code (or XS code, which implies C code) 3329 if (@{$self->{C}}) { 3330 @static = $self->catfile($self->{INST_ARCHLIB}, 3331 "auto", 3332 $self->{FULLEXT}, 3333 "$self->{BASEEXT}$self->{LIB_EXT}" 3334 ); 3335 } 3336 3337 # Either we determine now, which libraries we will produce in the 3338 # subdirectories or we do it at runtime of the make. 3339 3340 # We could ask all subdir objects, but I cannot imagine, why it 3341 # would be necessary. 3342 3343 # Instead we determine all libraries for the new perl at 3344 # runtime. 3345 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB}); 3346 3347 $self->makeaperl(MAKE => $self->{MAKEFILE}, 3348 DIRS => \@searchdirs, 3349 STAT => \@static, 3350 INCL => \@perlinc, 3351 TARGET => $self->{MAP_TARGET}, 3352 TMP => "", 3353 LIBPERL => $self->{LIBPERL_A} 3354 ); 3355} 3356 3357=item subdir_x (o) 3358 3359Helper subroutine for subdirs 3360 3361=cut 3362 3363sub subdir_x { 3364 my($self, $subdir) = @_; 3365 3366 my $subdir_cmd = $self->cd($subdir, 3367 '$(MAKE) $(USEMAKEFILE) $(FIRST_MAKEFILE) all $(PASTHRU)' 3368 ); 3369 return sprintf <<'EOT', $subdir_cmd; 3370 3371subdirs :: 3372 $(NOECHO) %s 3373EOT 3374 3375} 3376 3377=item subdirs (o) 3378 3379Defines targets to process subdirectories. 3380 3381=cut 3382 3383sub subdirs { 3384# --- Sub-directory Sections --- 3385 my($self) = shift; 3386 my(@m); 3387 # This method provides a mechanism to automatically deal with 3388 # subdirectories containing further Makefile.PL scripts. 3389 # It calls the subdir_x() method for each subdirectory. 3390 foreach my $dir (@{$self->{DIR}}){ 3391 push(@m, $self->subdir_x($dir)); 3392#### print "Including $dir subdirectory\n"; 3393 } 3394 if (@m){ 3395 unshift(@m, " 3396# The default clean, realclean and test targets in this Makefile 3397# have automatically been given entries for each subdir. 3398 3399"); 3400 } else { 3401 push(@m, "\n# none") 3402 } 3403 join('',@m); 3404} 3405 3406=item test (o) 3407 3408Defines the test targets. 3409 3410=cut 3411 3412sub test { 3413# --- Test and Installation Sections --- 3414 3415 my($self, %attribs) = @_; 3416 my $tests = $attribs{TESTS} || ''; 3417 if (!$tests && -d 't' && defined $attribs{RECURSIVE_TEST_FILES}) { 3418 $tests = $self->find_tests_recursive; 3419 } 3420 elsif (!$tests && -d 't') { 3421 $tests = $self->find_tests; 3422 } 3423 # note: 'test.pl' name is also hardcoded in init_dirscan() 3424 my(@m); 3425 push(@m," 3426TEST_VERBOSE=0 3427TEST_TYPE=test_\$(LINKTYPE) 3428TEST_FILE = test.pl 3429TEST_FILES = $tests 3430TESTDB_SW = -d 3431 3432testdb :: testdb_\$(LINKTYPE) 3433 3434test :: \$(TEST_TYPE) subdirs-test 3435 3436subdirs-test :: 3437 \$(NOECHO) \$(NOOP) 3438 3439"); 3440 3441 foreach my $dir (@{ $self->{DIR} }) { 3442 my $test = $self->cd($dir, '$(MAKE) test $(PASTHRU)'); 3443 3444 push @m, <<END 3445subdirs-test :: 3446 \$(NOECHO) $test 3447 3448END 3449 } 3450 3451 push(@m, "\t\$(NOECHO) \$(ECHO) 'No tests defined for \$(NAME) extension.'\n") 3452 unless $tests or -f "test.pl" or @{$self->{DIR}}; 3453 push(@m, "\n"); 3454 3455 push(@m, "test_dynamic :: pure_all\n"); 3456 push(@m, $self->test_via_harness('$(FULLPERLRUN)', '$(TEST_FILES)')) 3457 if $tests; 3458 push(@m, $self->test_via_script('$(FULLPERLRUN)', '$(TEST_FILE)')) 3459 if -f "test.pl"; 3460 push(@m, "\n"); 3461 3462 push(@m, "testdb_dynamic :: pure_all\n"); 3463 push(@m, $self->test_via_script('$(FULLPERLRUN) $(TESTDB_SW)', 3464 '$(TEST_FILE)')); 3465 push(@m, "\n"); 3466 3467 # Occasionally we may face this degenerate target: 3468 push @m, "test_ : test_dynamic\n\n"; 3469 3470 if ($self->needs_linking()) { 3471 push(@m, "test_static :: pure_all \$(MAP_TARGET)\n"); 3472 push(@m, $self->test_via_harness('./$(MAP_TARGET)', '$(TEST_FILES)')) if $tests; 3473 push(@m, $self->test_via_script('./$(MAP_TARGET)', '$(TEST_FILE)')) if -f "test.pl"; 3474 push(@m, "\n"); 3475 push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n"); 3476 push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)')); 3477 push(@m, "\n"); 3478 } else { 3479 push @m, "test_static :: test_dynamic\n"; 3480 push @m, "testdb_static :: testdb_dynamic\n"; 3481 } 3482 join("", @m); 3483} 3484 3485=item test_via_harness (override) 3486 3487For some reason which I forget, Unix machines like to have 3488PERL_DL_NONLAZY set for tests. 3489 3490=cut 3491 3492sub test_via_harness { 3493 my($self, $perl, $tests) = @_; 3494 return $self->SUPER::test_via_harness("PERL_DL_NONLAZY=1 $perl", $tests); 3495} 3496 3497=item test_via_script (override) 3498 3499Again, the PERL_DL_NONLAZY thing. 3500 3501=cut 3502 3503sub test_via_script { 3504 my($self, $perl, $script) = @_; 3505 return $self->SUPER::test_via_script("PERL_DL_NONLAZY=1 $perl", $script); 3506} 3507 3508 3509=item tool_xsubpp (o) 3510 3511Determines typemaps, xsubpp version, prototype behaviour. 3512 3513=cut 3514 3515sub tool_xsubpp { 3516 my($self) = shift; 3517 return "" unless $self->needs_linking; 3518 3519 my $xsdir; 3520 my @xsubpp_dirs = @INC; 3521 3522 # Make sure we pick up the new xsubpp if we're building perl. 3523 unshift @xsubpp_dirs, $self->{PERL_LIB} if $self->{PERL_CORE}; 3524 3525 my $foundxsubpp = 0; 3526 foreach my $dir (@xsubpp_dirs) { 3527 $xsdir = $self->catdir($dir, 'ExtUtils'); 3528 if( -r $self->catfile($xsdir, "xsubpp") ) { 3529 $foundxsubpp = 1; 3530 last; 3531 } 3532 } 3533 die "ExtUtils::MM_Unix::tool_xsubpp : Can't find xsubpp" if !$foundxsubpp; 3534 3535 my $tmdir = File::Spec->catdir($self->{PERL_LIB},"ExtUtils"); 3536 my(@tmdeps) = $self->catfile($tmdir,'typemap'); 3537 if( $self->{TYPEMAPS} ){ 3538 foreach my $typemap (@{$self->{TYPEMAPS}}){ 3539 if( ! -f $typemap ) { 3540 warn "Typemap $typemap not found.\n"; 3541 } 3542 else { 3543 push(@tmdeps, $typemap); 3544 } 3545 } 3546 } 3547 push(@tmdeps, "typemap") if -f "typemap"; 3548 my(@tmargs) = map("-typemap $_", @tmdeps); 3549 if( exists $self->{XSOPT} ){ 3550 unshift( @tmargs, $self->{XSOPT} ); 3551 } 3552 3553 if ($Is{VMS} && 3554 $Config{'ldflags'} && 3555 $Config{'ldflags'} =~ m!/Debug!i && 3556 (!exists($self->{XSOPT}) || $self->{XSOPT} !~ /linenumbers/) 3557 ) 3558 { 3559 unshift(@tmargs,'-nolinenumbers'); 3560 } 3561 3562 3563 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG}; 3564 3565 return qq{ 3566XSUBPPDIR = $xsdir 3567XSUBPP = \$(XSUBPPDIR)\$(DFSEP)xsubpp 3568XSUBPPRUN = \$(PERLRUN) \$(XSUBPP) 3569XSPROTOARG = $self->{XSPROTOARG} 3570XSUBPPDEPS = @tmdeps \$(XSUBPP) 3571XSUBPPARGS = @tmargs 3572XSUBPP_EXTRA_ARGS = 3573}; 3574}; 3575 3576 3577=item all_target 3578 3579Build man pages, too 3580 3581=cut 3582 3583sub all_target { 3584 my $self = shift; 3585 3586 return <<'MAKE_EXT'; 3587all :: pure_all manifypods 3588 $(NOECHO) $(NOOP) 3589MAKE_EXT 3590} 3591 3592=item top_targets (o) 3593 3594Defines the targets all, subdirs, config, and O_FILES 3595 3596=cut 3597 3598sub top_targets { 3599# --- Target Sections --- 3600 3601 my($self) = shift; 3602 my(@m); 3603 3604 push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'}; 3605 3606 push @m, ' 3607pure_all :: config pm_to_blib subdirs linkext 3608 $(NOECHO) $(NOOP) 3609 3610subdirs :: $(MYEXTLIB) 3611 $(NOECHO) $(NOOP) 3612 3613config :: $(FIRST_MAKEFILE) blibdirs 3614 $(NOECHO) $(NOOP) 3615'; 3616 3617 push @m, ' 3618$(O_FILES): $(H_FILES) 3619' if @{$self->{O_FILES} || []} && @{$self->{H} || []}; 3620 3621 push @m, q{ 3622help : 3623 perldoc ExtUtils::MakeMaker 3624}; 3625 3626 join('',@m); 3627} 3628 3629=item writedoc 3630 3631Obsolete, deprecated method. Not used since Version 5.21. 3632 3633=cut 3634 3635sub writedoc { 3636# --- perllocal.pod section --- 3637 my($self,$what,$name,@attribs)=@_; 3638 my $time = localtime; 3639 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n"; 3640 print join "\n\n=item *\n\n", map("C<$_>",@attribs); 3641 print "\n\n=back\n\n"; 3642} 3643 3644=item xs_c (o) 3645 3646Defines the suffix rules to compile XS files to C. 3647 3648=cut 3649 3650sub xs_c { 3651 my($self) = shift; 3652 return '' unless $self->needs_linking(); 3653 ' 3654.xs.c: 3655 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c 3656'; 3657} 3658 3659=item xs_cpp (o) 3660 3661Defines the suffix rules to compile XS files to C++. 3662 3663=cut 3664 3665sub xs_cpp { 3666 my($self) = shift; 3667 return '' unless $self->needs_linking(); 3668 ' 3669.xs.cpp: 3670 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.cpp 3671'; 3672} 3673 3674=item xs_o (o) 3675 3676Defines suffix rules to go from XS to object files directly. This is 3677only intended for broken make implementations. 3678 3679=cut 3680 3681sub xs_o { # many makes are too dumb to use xs_c then c_o 3682 my($self) = shift; 3683 return '' unless $self->needs_linking(); 3684 ' 3685.xs$(OBJ_EXT): 3686 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c 3687 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c 3688'; 3689} 3690 3691 36921; 3693 3694=back 3695 3696=head1 SEE ALSO 3697 3698L<ExtUtils::MakeMaker> 3699 3700=cut 3701 3702__END__ 3703