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