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 my $perm_dir = $self->{PERL_CORE} ? 770 : 755; 2138 $self->{PERM_DIR} = $perm_dir unless defined $self->{PERM_DIR}; 2139 $self->{PERM_RW} = 644 unless defined $self->{PERM_RW}; 2140 $self->{PERM_RWX} = 755 unless defined $self->{PERM_RWX}; 2141 2142 return 1; 2143} 2144 2145 2146=item init_xs 2147 2148 $mm->init_xs 2149 2150Sets up macros having to do with XS code. Currently just INST_STATIC, 2151INST_DYNAMIC and INST_BOOT. 2152 2153=cut 2154 2155sub init_xs { 2156 my $self = shift; 2157 2158 if ($self->has_link_code()) { 2159 $self->{INST_STATIC} = 2160 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT)$(LIB_EXT)'); 2161 $self->{INST_DYNAMIC} = 2162 $self->catfile('$(INST_ARCHAUTODIR)', '$(DLBASE).$(DLEXT)'); 2163 $self->{INST_BOOT} = 2164 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT).bs'); 2165 if ($self->{XSMULTI}) { 2166 my @exts = $self->_xs_list_basenames; 2167 my (@statics, @dynamics, @boots); 2168 for my $ext (@exts) { 2169 my ($v, $d, $f) = File::Spec->splitpath($ext); 2170 my @d = File::Spec->splitdir($d); 2171 shift @d if defined $d[0] and $d[0] eq 'lib'; 2172 my $instdir = $self->catdir('$(INST_ARCHLIB)', 'auto', @d, $f); 2173 my $instfile = $self->catfile($instdir, $f); 2174 push @statics, "$instfile\$(LIB_EXT)"; 2175 2176 # Dynamic library names may need special handling. 2177 my $dynfile = $instfile; 2178 eval { require DynaLoader }; 2179 if (defined &DynaLoader::mod2fname) { 2180 $dynfile = $self->catfile($instdir, &DynaLoader::mod2fname([@d, $f])); 2181 } 2182 2183 push @dynamics, "$dynfile.\$(DLEXT)"; 2184 push @boots, "$instfile.bs"; 2185 } 2186 $self->{INST_STATIC} = join ' ', @statics; 2187 $self->{INST_DYNAMIC} = join ' ', @dynamics; 2188 $self->{INST_BOOT} = join ' ', @boots; 2189 } 2190 } else { 2191 $self->{INST_STATIC} = ''; 2192 $self->{INST_DYNAMIC} = ''; 2193 $self->{INST_BOOT} = ''; 2194 } 2195} 2196 2197=item install (o) 2198 2199Defines the install target. 2200 2201=cut 2202 2203sub install { 2204 my($self, %attribs) = @_; 2205 my(@m); 2206 2207 push @m, q{ 2208install :: pure_install doc_install 2209 $(NOECHO) $(NOOP) 2210 2211install_perl :: pure_perl_install doc_perl_install 2212 $(NOECHO) $(NOOP) 2213 2214install_site :: pure_site_install doc_site_install 2215 $(NOECHO) $(NOOP) 2216 2217install_vendor :: pure_vendor_install doc_vendor_install 2218 $(NOECHO) $(NOOP) 2219 2220pure_install :: pure_$(INSTALLDIRS)_install 2221 $(NOECHO) $(NOOP) 2222 2223doc_install :: doc_$(INSTALLDIRS)_install 2224 $(NOECHO) $(NOOP) 2225 2226pure__install : pure_site_install 2227 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site 2228 2229doc__install : doc_site_install 2230 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site 2231 2232pure_perl_install :: all 2233 $(NOECHO) $(MOD_INSTALL) \ 2234}; 2235 2236 push @m, 2237q{ read "}.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{" \ 2238 write "}.$self->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{" \ 2239} unless $self->{NO_PACKLIST}; 2240 2241 push @m, 2242q{ "$(INST_LIB)" "$(DESTINSTALLPRIVLIB)" \ 2243 "$(INST_ARCHLIB)" "$(DESTINSTALLARCHLIB)" \ 2244 "$(INST_BIN)" "$(DESTINSTALLBIN)" \ 2245 "$(INST_SCRIPT)" "$(DESTINSTALLSCRIPT)" \ 2246 "$(INST_MAN1DIR)" "$(DESTINSTALLMAN1DIR)" \ 2247 "$(INST_MAN3DIR)" "$(DESTINSTALLMAN3DIR)" 2248 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ 2249 "}.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{" 2250 2251 2252pure_site_install :: all 2253 $(NOECHO) $(MOD_INSTALL) \ 2254}; 2255 push @m, 2256q{ read "}.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{" \ 2257 write "}.$self->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{" \ 2258} unless $self->{NO_PACKLIST}; 2259 2260 push @m, 2261q{ "$(INST_LIB)" "$(DESTINSTALLSITELIB)" \ 2262 "$(INST_ARCHLIB)" "$(DESTINSTALLSITEARCH)" \ 2263 "$(INST_BIN)" "$(DESTINSTALLSITEBIN)" \ 2264 "$(INST_SCRIPT)" "$(DESTINSTALLSITESCRIPT)" \ 2265 "$(INST_MAN1DIR)" "$(DESTINSTALLSITEMAN1DIR)" \ 2266 "$(INST_MAN3DIR)" "$(DESTINSTALLSITEMAN3DIR)" 2267 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ 2268 "}.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{" 2269 2270pure_vendor_install :: all 2271 $(NOECHO) $(MOD_INSTALL) \ 2272}; 2273 push @m, 2274q{ read "}.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{" \ 2275 write "}.$self->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').q{" \ 2276} unless $self->{NO_PACKLIST}; 2277 2278 push @m, 2279q{ "$(INST_LIB)" "$(DESTINSTALLVENDORLIB)" \ 2280 "$(INST_ARCHLIB)" "$(DESTINSTALLVENDORARCH)" \ 2281 "$(INST_BIN)" "$(DESTINSTALLVENDORBIN)" \ 2282 "$(INST_SCRIPT)" "$(DESTINSTALLVENDORSCRIPT)" \ 2283 "$(INST_MAN1DIR)" "$(DESTINSTALLVENDORMAN1DIR)" \ 2284 "$(INST_MAN3DIR)" "$(DESTINSTALLVENDORMAN3DIR)" 2285 2286}; 2287 2288 push @m, q{ 2289doc_perl_install :: all 2290 $(NOECHO) $(NOOP) 2291 2292doc_site_install :: all 2293 $(NOECHO) $(NOOP) 2294 2295doc_vendor_install :: all 2296 $(NOECHO) $(NOOP) 2297 2298} if $self->{NO_PERLLOCAL}; 2299 2300 push @m, q{ 2301doc_perl_install :: all 2302 $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod" 2303 -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)" 2304 -$(NOECHO) $(DOC_INSTALL) \ 2305 "Module" "$(NAME)" \ 2306 "installed into" "$(INSTALLPRIVLIB)" \ 2307 LINKTYPE "$(LINKTYPE)" \ 2308 VERSION "$(VERSION)" \ 2309 EXE_FILES "$(EXE_FILES)" \ 2310 >> "}.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{" 2311 2312doc_site_install :: all 2313 $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod" 2314 -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)" 2315 -$(NOECHO) $(DOC_INSTALL) \ 2316 "Module" "$(NAME)" \ 2317 "installed into" "$(INSTALLSITELIB)" \ 2318 LINKTYPE "$(LINKTYPE)" \ 2319 VERSION "$(VERSION)" \ 2320 EXE_FILES "$(EXE_FILES)" \ 2321 >> "}.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{" 2322 2323doc_vendor_install :: all 2324 $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod" 2325 -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)" 2326 -$(NOECHO) $(DOC_INSTALL) \ 2327 "Module" "$(NAME)" \ 2328 "installed into" "$(INSTALLVENDORLIB)" \ 2329 LINKTYPE "$(LINKTYPE)" \ 2330 VERSION "$(VERSION)" \ 2331 EXE_FILES "$(EXE_FILES)" \ 2332 >> "}.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{" 2333 2334} unless $self->{NO_PERLLOCAL}; 2335 2336 push @m, q{ 2337uninstall :: uninstall_from_$(INSTALLDIRS)dirs 2338 $(NOECHO) $(NOOP) 2339 2340uninstall_from_perldirs :: 2341 $(NOECHO) $(UNINSTALL) "}.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{" 2342 2343uninstall_from_sitedirs :: 2344 $(NOECHO) $(UNINSTALL) "}.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{" 2345 2346uninstall_from_vendordirs :: 2347 $(NOECHO) $(UNINSTALL) "}.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{" 2348}; 2349 2350 join("",@m); 2351} 2352 2353=item installbin (o) 2354 2355Defines targets to make and to install EXE_FILES. 2356 2357=cut 2358 2359sub installbin { 2360 my($self) = shift; 2361 2362 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY"; 2363 my @exefiles = sort @{$self->{EXE_FILES}}; 2364 return "" unless @exefiles; 2365 2366 @exefiles = map vmsify($_), @exefiles if $Is{VMS}; 2367 2368 my %fromto; 2369 for my $from (@exefiles) { 2370 my($path)= $self->catfile('$(INST_SCRIPT)', basename($from)); 2371 2372 local($_) = $path; # for backwards compatibility 2373 my $to = $self->libscan($path); 2374 print "libscan($from) => '$to'\n" if ($Verbose >=2); 2375 2376 $to = vmsify($to) if $Is{VMS}; 2377 $fromto{$from} = $to; 2378 } 2379 my @to = sort values %fromto; 2380 2381 my @m; 2382 push(@m, qq{ 2383EXE_FILES = @exefiles 2384 2385pure_all :: @to 2386 \$(NOECHO) \$(NOOP) 2387 2388realclean :: 2389}); 2390 2391 # realclean can get rather large. 2392 push @m, map "\t$_\n", $self->split_command('$(RM_F)', @to); 2393 push @m, "\n"; 2394 2395 # A target for each exe file. 2396 my @froms = sort keys %fromto; 2397 for my $from (@froms) { 2398 # 1 2 2399 push @m, _sprintf562 <<'MAKE', $from, $fromto{$from}; 2400%2$s : %1$s $(FIRST_MAKEFILE) $(INST_SCRIPT)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists 2401 $(NOECHO) $(RM_F) %2$s 2402 $(CP) %1$s %2$s 2403 $(FIXIN) %2$s 2404 -$(NOECHO) $(CHMOD) $(PERM_RWX) %2$s 2405 2406MAKE 2407 2408 } 2409 2410 join "", @m; 2411} 2412 2413=item linkext (o) 2414 2415Defines the linkext target which in turn defines the LINKTYPE. 2416 2417=cut 2418 2419# LINKTYPE => static or dynamic or '' 2420sub linkext { 2421 my($self, %attribs) = @_; 2422 my $linktype = $attribs{LINKTYPE}; 2423 $linktype = $self->{LINKTYPE} unless defined $linktype; 2424 if (defined $linktype and $linktype eq '') { 2425 warn "Warning: LINKTYPE set to '', no longer necessary\n"; 2426 } 2427 $linktype = '$(LINKTYPE)' unless defined $linktype; 2428 " 2429linkext :: $linktype 2430 \$(NOECHO) \$(NOOP) 2431"; 2432} 2433 2434=item lsdir 2435 2436Takes as arguments a directory name and a regular expression. Returns 2437all entries in the directory that match the regular expression. 2438 2439=cut 2440 2441sub lsdir { 2442 # $self 2443 my(undef, $dir, $regex) = @_; 2444 opendir(my $dh, defined($dir) ? $dir : ".") 2445 or return; 2446 my @ls = readdir $dh; 2447 closedir $dh; 2448 @ls = grep(/$regex/, @ls) if defined $regex; 2449 @ls; 2450} 2451 2452=item macro (o) 2453 2454Simple subroutine to insert the macros defined by the macro attribute 2455into the Makefile. 2456 2457=cut 2458 2459sub macro { 2460 my($self,%attribs) = @_; 2461 my @m; 2462 foreach my $key (sort keys %attribs) { 2463 my $val = $attribs{$key}; 2464 push @m, "$key = $val\n"; 2465 } 2466 join "", @m; 2467} 2468 2469=item makeaperl (o) 2470 2471Called by staticmake. Defines how to write the Makefile to produce a 2472static new perl. 2473 2474By default the Makefile produced includes all the static extensions in 2475the perl library. (Purified versions of library files, e.g., 2476DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.) 2477 2478=cut 2479 2480sub makeaperl { 2481 my($self, %attribs) = @_; 2482 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) = 2483 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)}; 2484 s/^(.*)/"-I$1"/ for @{$perlinc || []}; 2485 my(@m); 2486 push @m, " 2487# --- MakeMaker makeaperl section --- 2488MAP_TARGET = $target 2489FULLPERL = $self->{FULLPERL} 2490MAP_PERLINC = @{$perlinc || []} 2491"; 2492 return join '', @m if $self->{PARENT}; 2493 2494 my($dir) = join ":", @{$self->{DIR}}; 2495 2496 unless ($self->{MAKEAPERL}) { 2497 push @m, q{ 2498$(MAP_TARGET) :: $(MAKE_APERL_FILE) 2499 $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@ 2500 2501$(MAKE_APERL_FILE) : static $(FIRST_MAKEFILE) pm_to_blib 2502 $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) 2503 $(NOECHO) $(PERLRUNINST) \ 2504 Makefile.PL DIR="}, $dir, q{" \ 2505 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ 2506 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=}; 2507 2508 foreach (@ARGV){ 2509 my $arg = $_; # avoid lvalue aliasing 2510 if ( $arg =~ /(^.*?=)(.*['\s].*)/ ) { 2511 $arg = $1 . $self->quote_literal($2); 2512 } 2513 push @m, " \\\n\t\t$arg"; 2514 } 2515 push @m, "\n"; 2516 2517 return join '', @m; 2518 } 2519 2520 my $cccmd = $self->const_cccmd($libperl); 2521 $cccmd =~ s/^CCCMD\s*=\s*//; 2522 $cccmd =~ s/\$\(INC\)/ "-I$self->{PERL_INC}" /; 2523 $cccmd .= " $Config{cccdlflags}" 2524 if ($Config{useshrplib} eq 'true'); 2525 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/; 2526 2527 # The front matter of the linkcommand... 2528 my $linkcmd = join ' ', "\$(CC)", 2529 grep($_, @Config{qw(ldflags ccdlflags)}); 2530 $linkcmd =~ s/\s+/ /g; 2531 $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,; 2532 2533 # Which *.a files could we make use of... 2534 my $staticlib21 = $self->_find_static_libs($searchdirs); 2535 # We trust that what has been handed in as argument, will be buildable 2536 $static = [] unless $static; 2537 @$staticlib21{@{$static}} = (1) x @{$static}; 2538 2539 $extra = [] unless $extra && ref $extra eq 'ARRAY'; 2540 for (sort keys %$staticlib21) { 2541 next unless /\Q$self->{LIB_EXT}\E\z/; 2542 $_ = dirname($_) . "/extralibs.ld"; 2543 push @$extra, $_; 2544 } 2545 2546 s/^(.*)/"-I$1"/ for @{$perlinc || []}; 2547 2548 $target ||= "perl"; 2549 $tmp ||= "."; 2550 2551# MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we 2552# regenerate the Makefiles, MAP_STATIC and the dependencies for 2553# extralibs.all are computed correctly 2554 my @map_static = reverse sort keys %$staticlib21; 2555 push @m, " 2556MAP_LINKCMD = $linkcmd 2557MAP_STATIC = ", join(" \\\n\t", map { qq{"$_"} } @map_static), " 2558MAP_STATICDEP = ", join(' ', map { $self->quote_dep($_) } @map_static), " 2559 2560MAP_PRELIBS = $Config{perllibs} $Config{cryptlib} 2561"; 2562 2563 my $lperl; 2564 if (defined $libperl) { 2565 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/; 2566 } 2567 unless ($libperl && -f $lperl) { # Ilya's code... 2568 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE"; 2569 $dir = "$self->{PERL_ARCHLIB}/.." if $self->{UNINSTALLED_PERL}; 2570 $libperl ||= "libperl$self->{LIB_EXT}"; 2571 $libperl = "$dir/$libperl"; 2572 $lperl ||= "libperl$self->{LIB_EXT}"; 2573 $lperl = "$dir/$lperl"; 2574 2575 if (! -f $libperl and ! -f $lperl) { 2576 # We did not find a static libperl. Maybe there is a shared one? 2577 if ($Is{SunOS}) { 2578 $lperl = $libperl = "$dir/$Config{libperl}"; 2579 # SUNOS ld does not take the full path to a shared library 2580 $libperl = '' if $Is{SunOS4}; 2581 } 2582 } 2583 2584 print <<EOF unless -f $lperl || defined($self->{PERL_SRC}); 2585Warning: $libperl not found 2586If you're going to build a static perl binary, make sure perl is installed 2587otherwise ignore this warning 2588EOF 2589 } 2590 2591 # SUNOS ld does not take the full path to a shared library 2592 my $llibperl = $libperl ? '$(MAP_LIBPERL)' : '-lperl'; 2593 my $libperl_dep = $self->quote_dep($libperl); 2594 2595 push @m, " 2596MAP_LIBPERL = $libperl 2597MAP_LIBPERLDEP = $libperl_dep 2598LLIBPERL = $llibperl 2599"; 2600 2601 push @m, ' 2602$(INST_ARCHAUTODIR)/extralibs.all : $(INST_ARCHAUTODIR)$(DFSEP).exists '.join(" \\\n\t", @$extra).' 2603 $(NOECHO) $(RM_F) $@ 2604 $(NOECHO) $(TOUCH) $@ 2605'; 2606 2607 foreach my $catfile (@$extra){ 2608 push @m, "\tcat $catfile >> \$\@\n"; 2609 } 2610 2611 my $ldfrom = $self->{XSMULTI} ? '' : '$(LDFROM)'; 2612 # 1 2 3 4 2613 push @m, _sprintf562 <<'EOF', $tmp, $ldfrom, $self->xs_obj_opt('$@'), $makefilename; 2614$(MAP_TARGET) :: %1$s/perlmain$(OBJ_EXT) $(MAP_LIBPERLDEP) $(MAP_STATICDEP) $(INST_ARCHAUTODIR)/extralibs.all 2615 $(MAP_LINKCMD) %2$s $(OPTIMIZE) %1$s/perlmain$(OBJ_EXT) %3$s $(MAP_STATIC) "$(LLIBPERL)" `cat $(INST_ARCHAUTODIR)/extralibs.all` $(MAP_PRELIBS) 2616 $(NOECHO) $(ECHO) "To install the new '$(MAP_TARGET)' binary, call" 2617 $(NOECHO) $(ECHO) " $(MAKE) $(USEMAKEFILE) %4$s inst_perl MAP_TARGET=$(MAP_TARGET)" 2618 $(NOECHO) $(ECHO) " $(MAKE) $(USEMAKEFILE) %4$s map_clean" 2619 2620%1$s/perlmain\$(OBJ_EXT): %1$s/perlmain.c 2621EOF 2622 push @m, "\t".$self->cd($tmp, qq[$cccmd "-I\$(PERL_INC)" perlmain.c])."\n"; 2623 2624 my $maybe_DynaLoader = $Config{usedl} ? 'q(DynaLoader)' : ''; 2625 push @m, _sprintf562 <<'EOF', $tmp, $makefilename, $maybe_DynaLoader; 2626 2627%1$s/perlmain.c: %2$s 2628 $(NOECHO) $(ECHO) Writing $@ 2629 $(NOECHO) $(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \ 2630 -e "writemain(grep(s#.*/auto/##s, @ARGV), %3$s)" $(MAP_STATIC) > $@t 2631 $(MV) $@t $@ 2632 2633EOF 2634 push @m, "\t", q{$(NOECHO) $(PERL) "$(INSTALLSCRIPT)/fixpmain" 2635} if (defined (&Dos::UseLFN) && Dos::UseLFN()==0); 2636 2637 2638 push @m, q{ 2639doc_inst_perl : 2640 $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod" 2641 -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)" 2642 -$(NOECHO) $(DOC_INSTALL) \ 2643 "Perl binary" "$(MAP_TARGET)" \ 2644 MAP_STATIC "$(MAP_STATIC)" \ 2645 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \ 2646 MAP_LIBPERL "$(MAP_LIBPERL)" \ 2647 >> "}.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{" 2648 2649}; 2650 2651 push @m, q{ 2652inst_perl : pure_inst_perl doc_inst_perl 2653 2654pure_inst_perl : $(MAP_TARGET) 2655 }.$self->{CP}.q{ $(MAP_TARGET) "}.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{" 2656 2657clean :: map_clean 2658 2659map_clean : 2660 }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all 2661}; 2662 2663 join '', @m; 2664} 2665 2666# utility method 2667sub _find_static_libs { 2668 my ($self, $searchdirs) = @_; 2669 # don't use File::Spec here because on Win32 F::F still uses "/" 2670 my $installed_version = join('/', 2671 'auto', $self->{FULLEXT}, "$self->{BASEEXT}$self->{LIB_EXT}" 2672 ); 2673 my %staticlib21; 2674 require File::Find; 2675 File::Find::find(sub { 2676 if ($File::Find::name =~ m{/auto/share\z}) { 2677 # in a subdir of auto/share, prune because e.g. 2678 # Alien::pkgconfig uses File::ShareDir to put .a files 2679 # there. do not want 2680 $File::Find::prune = 1; 2681 return; 2682 } 2683 2684 return unless m/\Q$self->{LIB_EXT}\E$/; 2685 2686 return unless -f 'extralibs.ld'; # this checks is a "proper" XS installation 2687 2688 # Skip perl's libraries. 2689 return if m/^libperl/ or m/^perl\Q$self->{LIB_EXT}\E$/; 2690 2691 # Skip purified versions of libraries 2692 # (e.g., DynaLoader_pure_p1_c0_032.a) 2693 return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure"; 2694 2695 if( exists $self->{INCLUDE_EXT} ){ 2696 my $found = 0; 2697 2698 (my $xx = $File::Find::name) =~ s,.*?/auto/,,s; 2699 $xx =~ s,/?$_,,; 2700 $xx =~ s,/,::,g; 2701 2702 # Throw away anything not explicitly marked for inclusion. 2703 # DynaLoader is implied. 2704 foreach my $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){ 2705 if( $xx eq $incl ){ 2706 $found++; 2707 last; 2708 } 2709 } 2710 return unless $found; 2711 } 2712 elsif( exists $self->{EXCLUDE_EXT} ){ 2713 (my $xx = $File::Find::name) =~ s,.*?/auto/,,s; 2714 $xx =~ s,/?$_,,; 2715 $xx =~ s,/,::,g; 2716 2717 # Throw away anything explicitly marked for exclusion 2718 foreach my $excl (@{$self->{EXCLUDE_EXT}}){ 2719 return if( $xx eq $excl ); 2720 } 2721 } 2722 2723 # don't include the installed version of this extension. I 2724 # leave this line here, although it is not necessary anymore: 2725 # I patched minimod.PL instead, so that Miniperl.pm won't 2726 # include duplicates 2727 2728 # Once the patch to minimod.PL is in the distribution, I can 2729 # drop it 2730 return if $File::Find::name =~ m:\Q$installed_version\E\z:; 2731 return if !$self->xs_static_lib_is_xs($_); 2732 use Cwd 'cwd'; 2733 $staticlib21{cwd() . "/" . $_}++; 2734 }, grep( -d $_, map { $self->catdir($_, 'auto') } @{$searchdirs || []}) ); 2735 return \%staticlib21; 2736} 2737 2738=item xs_static_lib_is_xs (o) 2739 2740Called by a utility method of makeaperl. Checks whether a given file 2741is an XS library by seeing whether it defines any symbols starting 2742with C<boot_>. 2743 2744=cut 2745 2746sub xs_static_lib_is_xs { 2747 my ($self, $libfile) = @_; 2748 my $devnull = File::Spec->devnull; 2749 return `nm $libfile 2>$devnull` =~ /\bboot_/; 2750} 2751 2752=item makefile (o) 2753 2754Defines how to rewrite the Makefile. 2755 2756=cut 2757 2758sub makefile { 2759 my($self) = shift; 2760 my $m; 2761 # We do not know what target was originally specified so we 2762 # must force a manual rerun to be sure. But as it should only 2763 # happen very rarely it is not a significant problem. 2764 $m = ' 2765$(OBJECT) : $(FIRST_MAKEFILE) 2766 2767' if $self->{OBJECT}; 2768 2769 my $newer_than_target = $Is{VMS} ? '$(MMS$SOURCE_LIST)' : '$?'; 2770 my $mpl_args = join " ", map qq["$_"], @ARGV; 2771 my $cross = ''; 2772 if (defined $::Cross::platform) { 2773 # Inherited from win32/buildext.pl 2774 $cross = "-MCross=$::Cross::platform "; 2775 } 2776 $m .= sprintf <<'MAKE_FRAG', $newer_than_target, $cross, $mpl_args; 2777# We take a very conservative approach here, but it's worth it. 2778# We move Makefile to Makefile.old here to avoid gnu make looping. 2779$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) 2780 $(NOECHO) $(ECHO) "Makefile out-of-date with respect to %s" 2781 $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." 2782 -$(NOECHO) $(RM_F) $(MAKEFILE_OLD) 2783 -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) 2784 - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL) 2785 $(PERLRUN) %sMakefile.PL %s 2786 $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" 2787 $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <==" 2788 $(FALSE) 2789 2790MAKE_FRAG 2791 2792 return $m; 2793} 2794 2795 2796=item maybe_command 2797 2798Returns true, if the argument is likely to be a command. 2799 2800=cut 2801 2802sub maybe_command { 2803 my($self,$file) = @_; 2804 return $file if -x $file && ! -d $file; 2805 return; 2806} 2807 2808 2809=item needs_linking (o) 2810 2811Does this module need linking? Looks into subdirectory objects (see 2812also has_link_code()) 2813 2814=cut 2815 2816sub needs_linking { 2817 my($self) = shift; 2818 2819 my $caller = (caller(0))[3]; 2820 confess("needs_linking called too early") if 2821 $caller =~ /^ExtUtils::MakeMaker::/; 2822 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING}; 2823 if ($self->has_link_code or $self->{MAKEAPERL}){ 2824 $self->{NEEDS_LINKING} = 1; 2825 return 1; 2826 } 2827 foreach my $child (keys %{$self->{CHILDREN}}) { 2828 if ($self->{CHILDREN}->{$child}->needs_linking) { 2829 $self->{NEEDS_LINKING} = 1; 2830 return 1; 2831 } 2832 } 2833 return $self->{NEEDS_LINKING} = 0; 2834} 2835 2836 2837=item parse_abstract 2838 2839parse a file and return what you think is the ABSTRACT 2840 2841=cut 2842 2843sub parse_abstract { 2844 my($self,$parsefile) = @_; 2845 my $result; 2846 2847 local $/ = "\n"; 2848 open(my $fh, '<', $parsefile) or die "Could not open '$parsefile': $!"; 2849 binmode $fh; 2850 my $inpod = 0; 2851 my $pod_encoding; 2852 my $package = $self->{DISTNAME}; 2853 $package =~ s/-/::/g; 2854 while (<$fh>) { 2855 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod; 2856 next if !$inpod; 2857 s#\r*\n\z##; # handle CRLF input 2858 2859 if ( /^=encoding\s*(.*)$/i ) { 2860 $pod_encoding = $1; 2861 } 2862 2863 if ( /^($package(?:\.pm)? \s+ -+ \s+)(.*)/x ) { 2864 $result = $2; 2865 next; 2866 } 2867 next unless $result; 2868 2869 if ( $result && ( /^\s*$/ || /^\=/ ) ) { 2870 last; 2871 } 2872 $result = join ' ', $result, $_; 2873 } 2874 close $fh; 2875 2876 if ( $pod_encoding and !( $] < 5.008 or !$Config{useperlio} ) ) { 2877 # Have to wrap in an eval{} for when running under PERL_CORE 2878 # Encode isn't available during build phase and parsing 2879 # ABSTRACT isn't important there 2880 eval { 2881 require Encode; 2882 $result = Encode::decode($pod_encoding, $result); 2883 } 2884 } 2885 2886 return $result; 2887} 2888 2889=item parse_version 2890 2891 my $version = MM->parse_version($file); 2892 2893Parse a $file and return what $VERSION is set to by the first assignment. 2894It will return the string "undef" if it can't figure out what $VERSION 2895is. $VERSION should be for all to see, so C<our $VERSION> or plain $VERSION 2896are okay, but C<my $VERSION> is not. 2897 2898C<<package Foo VERSION>> is also checked for. The first version 2899declaration found is used, but this may change as it differs from how 2900Perl does it. 2901 2902parse_version() will try to C<use version> before checking for 2903C<$VERSION> so the following will work. 2904 2905 $VERSION = qv(1.2.3); 2906 2907=cut 2908 2909sub parse_version { 2910 my($self,$parsefile) = @_; 2911 my $result; 2912 2913 local $/ = "\n"; 2914 local $_; 2915 open(my $fh, '<', $parsefile) or die "Could not open '$parsefile': $!"; 2916 my $inpod = 0; 2917 while (<$fh>) { 2918 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod; 2919 next if $inpod || /^\s*#/; 2920 chop; 2921 next if /^\s*(if|unless|elsif)/; 2922 if ( m{^ \s* package \s+ \w[\w\:\']* \s+ (v?[0-9._]+) \s* (;|\{) }x ) { 2923 local $^W = 0; 2924 $result = $1; 2925 } 2926 elsif ( m{(?<!\\) ([\$*]) (([\w\:\']*) \bVERSION)\b .* (?<![<>=!])\=[^=]}x ) { 2927 $result = $self->get_version($parsefile, $1, $2); 2928 } 2929 else { 2930 next; 2931 } 2932 last if defined $result; 2933 } 2934 close $fh; 2935 2936 if ( defined $result && $result !~ /^v?[\d_\.]+$/ ) { 2937 require version; 2938 my $normal = eval { version->new( $result ) }; 2939 $result = $normal if defined $normal; 2940 } 2941 $result = "undef" unless defined $result; 2942 return $result; 2943} 2944 2945sub get_version { 2946 my ($self, $parsefile, $sigil, $name) = @_; 2947 my $line = $_; # from the while() loop in parse_version 2948 { 2949 package ExtUtils::MakeMaker::_version; 2950 undef *version; # in case of unexpected version() sub 2951 eval { 2952 require version; 2953 version::->import; 2954 }; 2955 no strict; 2956 local *{$name}; 2957 local $^W = 0; 2958 $line = $1 if $line =~ m{^(.+)}s; 2959 eval($line); ## no critic 2960 return ${$name}; 2961 } 2962} 2963 2964=item pasthru (o) 2965 2966Defines the string that is passed to recursive make calls in 2967subdirectories. The variables like C<PASTHRU_DEFINE> are used in each 2968level, and passed downwards on the command-line with e.g. the value of 2969that level's DEFINE. Example: 2970 2971 # Level 0 has DEFINE = -Dfunky 2972 # This code will define level 0's PASTHRU=PASTHRU_DEFINE="$(DEFINE) 2973 # $(PASTHRU_DEFINE)" 2974 # Level 0's $(CCCMD) will include macros $(DEFINE) and $(PASTHRU_DEFINE) 2975 # So will level 1's, so when level 1 compiles, it will get right values 2976 # And so ad infinitum 2977 2978=cut 2979 2980sub pasthru { 2981 my($self) = shift; 2982 my(@m); 2983 2984 my(@pasthru); 2985 my($sep) = $Is{VMS} ? ',' : ''; 2986 $sep .= "\\\n\t"; 2987 2988 foreach my $key (qw(LIB LIBPERL_A LINKTYPE OPTIMIZE 2989 PREFIX INSTALL_BASE) 2990 ) 2991 { 2992 next unless defined $self->{$key}; 2993 push @pasthru, "$key=\"\$($key)\""; 2994 } 2995 2996 foreach my $key (qw(DEFINE INC)) { 2997 # default to the make var 2998 my $val = qq{\$($key)}; 2999 # expand within perl if given since need to use quote_literal 3000 # since INC might include space-protecting ""! 3001 chomp($val = $self->{$key}) if defined $self->{$key}; 3002 $val .= " \$(PASTHRU_$key)"; 3003 my $quoted = $self->quote_literal($val); 3004 push @pasthru, qq{PASTHRU_$key=$quoted}; 3005 } 3006 3007 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n"; 3008 join "", @m; 3009} 3010 3011=item perl_script 3012 3013Takes one argument, a file name, and returns the file name, if the 3014argument is likely to be a perl script. On MM_Unix this is true for 3015any ordinary, readable file. 3016 3017=cut 3018 3019sub perl_script { 3020 my($self,$file) = @_; 3021 return $file if -r $file && -f _; 3022 return; 3023} 3024 3025=item perldepend (o) 3026 3027Defines the dependency from all *.h files that come with the perl 3028distribution. 3029 3030=cut 3031 3032sub perldepend { 3033 my($self) = shift; 3034 my(@m); 3035 3036 my $make_config = $self->cd('$(PERL_SRC)', '$(MAKE) lib/Config.pm'); 3037 3038 push @m, sprintf <<'MAKE_FRAG', $make_config if $self->{PERL_SRC}; 3039# Check for unpropogated config.sh changes. Should never happen. 3040# We do NOT just update config.h because that is not sufficient. 3041# An out of date config.h is not fatal but complains loudly! 3042$(PERL_INCDEP)/config.h: $(PERL_SRC)/config.sh 3043 -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; $(FALSE) 3044 3045$(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh 3046 $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh" 3047 %s 3048MAKE_FRAG 3049 3050 return join "", @m unless $self->needs_linking; 3051 3052 if ($self->{OBJECT}) { 3053 # Need to add an object file dependency on the perl headers. 3054 # this is very important for XS modules in perl.git development. 3055 push @m, $self->_perl_header_files_fragment("/"); # Directory separator between $(PERL_INC)/header.h 3056 } 3057 3058 push @m, join(" ", sort values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}}; 3059 3060 return join "\n", @m; 3061} 3062 3063 3064=item pm_to_blib 3065 3066Defines target that copies all files in the hash PM to their 3067destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION> 3068 3069=cut 3070 3071sub pm_to_blib { 3072 my $self = shift; 3073 my($autodir) = $self->catdir('$(INST_LIB)','auto'); 3074 my $r = q{ 3075pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM) 3076}; 3077 3078 # VMS will swallow '' and PM_FILTER is often empty. So use q[] 3079 my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']); 3080pm_to_blib({\@ARGV}, '$autodir', q[\$(PM_FILTER)], '\$(PERM_DIR)') 3081CODE 3082 3083 my @cmds = $self->split_command($pm_to_blib, 3084 map { ($self->quote_literal($_) => $self->quote_literal($self->{PM}->{$_})) } sort keys %{$self->{PM}}); 3085 3086 $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds; 3087 $r .= qq{\t\$(NOECHO) \$(TOUCH) pm_to_blib\n}; 3088 3089 return $r; 3090} 3091 3092# transform dot-separated version string into comma-separated quadruple 3093# examples: '1.2.3.4.5' => '1,2,3,4' 3094# '1.2.3' => '1,2,3,0' 3095sub _ppd_version { 3096 my ($self, $string) = @_; 3097 return join ',', ((split /\./, $string), (0) x 4)[0..3]; 3098} 3099 3100=item ppd 3101 3102Defines target that creates a PPD (Perl Package Description) file 3103for a binary distribution. 3104 3105=cut 3106 3107sub ppd { 3108 my($self) = @_; 3109 3110 my $abstract = $self->{ABSTRACT} || ''; 3111 $abstract =~ s/\n/\\n/sg; 3112 $abstract =~ s/</</g; 3113 $abstract =~ s/>/>/g; 3114 3115 my $author = join(', ',@{ ref $self->{AUTHOR} eq 'ARRAY' ? $self->{AUTHOR} : [ $self->{AUTHOR} || '']}); 3116 $author =~ s/</</g; 3117 $author =~ s/>/>/g; 3118 3119 my $ppd_file = "$self->{DISTNAME}.ppd"; 3120 3121 my @ppd_chunks = qq(<SOFTPKG NAME="$self->{DISTNAME}" VERSION="$self->{VERSION}">\n); 3122 3123 push @ppd_chunks, sprintf <<'PPD_HTML', $abstract, $author; 3124 <ABSTRACT>%s</ABSTRACT> 3125 <AUTHOR>%s</AUTHOR> 3126PPD_HTML 3127 3128 push @ppd_chunks, " <IMPLEMENTATION>\n"; 3129 if ( $self->{MIN_PERL_VERSION} ) { 3130 my $min_perl_version = $self->_ppd_version($self->{MIN_PERL_VERSION}); 3131 push @ppd_chunks, sprintf <<'PPD_PERLVERS', $min_perl_version; 3132 <PERLCORE VERSION="%s" /> 3133PPD_PERLVERS 3134 3135 } 3136 3137 # Don't add "perl" to requires. perl dependencies are 3138 # handles by ARCHITECTURE. 3139 my %prereqs = %{$self->{PREREQ_PM}}; 3140 delete $prereqs{perl}; 3141 3142 # Build up REQUIRE 3143 foreach my $prereq (sort keys %prereqs) { 3144 my $name = $prereq; 3145 $name .= '::' unless $name =~ /::/; 3146 my $version = $prereqs{$prereq}; 3147 3148 my %attrs = ( NAME => $name ); 3149 $attrs{VERSION} = $version if $version; 3150 my $attrs = join " ", map { qq[$_="$attrs{$_}"] } sort keys %attrs; 3151 push @ppd_chunks, qq( <REQUIRE $attrs />\n); 3152 } 3153 3154 my $archname = $Config{archname}; 3155 if ($] >= 5.008) { 3156 # archname did not change from 5.6 to 5.8, but those versions may 3157 # not be not binary compatible so now we append the part of the 3158 # version that changes when binary compatibility may change 3159 $archname .= "-$Config{PERL_REVISION}.$Config{PERL_VERSION}"; 3160 } 3161 push @ppd_chunks, sprintf <<'PPD_OUT', $archname; 3162 <ARCHITECTURE NAME="%s" /> 3163PPD_OUT 3164 3165 if ($self->{PPM_INSTALL_SCRIPT}) { 3166 if ($self->{PPM_INSTALL_EXEC}) { 3167 push @ppd_chunks, sprintf qq{ <INSTALL EXEC="%s">%s</INSTALL>\n}, 3168 $self->{PPM_INSTALL_EXEC}, $self->{PPM_INSTALL_SCRIPT}; 3169 } 3170 else { 3171 push @ppd_chunks, sprintf qq{ <INSTALL>%s</INSTALL>\n}, 3172 $self->{PPM_INSTALL_SCRIPT}; 3173 } 3174 } 3175 3176 if ($self->{PPM_UNINSTALL_SCRIPT}) { 3177 if ($self->{PPM_UNINSTALL_EXEC}) { 3178 push @ppd_chunks, sprintf qq{ <UNINSTALL EXEC="%s">%s</UNINSTALL>\n}, 3179 $self->{PPM_UNINSTALL_EXEC}, $self->{PPM_UNINSTALL_SCRIPT}; 3180 } 3181 else { 3182 push @ppd_chunks, sprintf qq{ <UNINSTALL>%s</UNINSTALL>\n}, 3183 $self->{PPM_UNINSTALL_SCRIPT}; 3184 } 3185 } 3186 3187 my ($bin_location) = $self->{BINARY_LOCATION} || ''; 3188 $bin_location =~ s/\\/\\\\/g; 3189 3190 push @ppd_chunks, sprintf <<'PPD_XML', $bin_location; 3191 <CODEBASE HREF="%s" /> 3192 </IMPLEMENTATION> 3193</SOFTPKG> 3194PPD_XML 3195 3196 my @ppd_cmds = $self->stashmeta(join('', @ppd_chunks), $ppd_file); 3197 3198 return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds; 3199# Creates a PPD (Perl Package Description) for a binary distribution. 3200ppd : 3201 %s 3202PPD_OUT 3203 3204} 3205 3206=item prefixify 3207 3208 $MM->prefixify($var, $prefix, $new_prefix, $default); 3209 3210Using either $MM->{uc $var} || $Config{lc $var}, it will attempt to 3211replace it's $prefix with a $new_prefix. 3212 3213Should the $prefix fail to match I<AND> a PREFIX was given as an 3214argument to WriteMakefile() it will set it to the $new_prefix + 3215$default. This is for systems whose file layouts don't neatly fit into 3216our ideas of prefixes. 3217 3218This is for heuristics which attempt to create directory structures 3219that mirror those of the installed perl. 3220 3221For example: 3222 3223 $MM->prefixify('installman1dir', '/usr', '/home/foo', 'man/man1'); 3224 3225this will attempt to remove '/usr' from the front of the 3226$MM->{INSTALLMAN1DIR} path (initializing it to $Config{installman1dir} 3227if necessary) and replace it with '/home/foo'. If this fails it will 3228simply use '/home/foo/man/man1'. 3229 3230=cut 3231 3232sub prefixify { 3233 my($self,$var,$sprefix,$rprefix,$default) = @_; 3234 3235 my $path = $self->{uc $var} || 3236 $Config_Override{lc $var} || $Config{lc $var} || ''; 3237 3238 $rprefix .= '/' if $sprefix =~ m|/$|; 3239 3240 warn " prefixify $var => $path\n" if $Verbose >= 2; 3241 warn " from $sprefix to $rprefix\n" if $Verbose >= 2; 3242 3243 if( $self->{ARGS}{PREFIX} && 3244 $path !~ s{^\Q$sprefix\E\b}{$rprefix}s ) 3245 { 3246 3247 warn " cannot prefix, using default.\n" if $Verbose >= 2; 3248 warn " no default!\n" if !$default && $Verbose >= 2; 3249 3250 $path = $self->catdir($rprefix, $default) if $default; 3251 } 3252 3253 print " now $path\n" if $Verbose >= 2; 3254 return $self->{uc $var} = $path; 3255} 3256 3257 3258=item processPL (o) 3259 3260Defines targets to run *.PL files. 3261 3262=cut 3263 3264sub processPL { 3265 my $self = shift; 3266 my $pl_files = $self->{PL_FILES}; 3267 3268 return "" unless $pl_files; 3269 3270 my $m = ''; 3271 foreach my $plfile (sort keys %$pl_files) { 3272 my $list = ref($pl_files->{$plfile}) 3273 ? $pl_files->{$plfile} 3274 : [$pl_files->{$plfile}]; 3275 3276 foreach my $target (@$list) { 3277 if( $Is{VMS} ) { 3278 $plfile = vmsify($self->eliminate_macros($plfile)); 3279 $target = vmsify($self->eliminate_macros($target)); 3280 } 3281 3282 # Normally a .PL file runs AFTER pm_to_blib so it can have 3283 # blib in its @INC and load the just built modules. BUT if 3284 # the generated module is something in $(TO_INST_PM) which 3285 # pm_to_blib depends on then it can't depend on pm_to_blib 3286 # else we have a dependency loop. 3287 my $pm_dep; 3288 my $perlrun; 3289 if( defined $self->{PM}{$target} ) { 3290 $pm_dep = ''; 3291 $perlrun = 'PERLRUN'; 3292 } 3293 else { 3294 $pm_dep = 'pm_to_blib'; 3295 $perlrun = 'PERLRUNINST'; 3296 } 3297 3298 $m .= <<MAKE_FRAG; 3299 3300pure_all :: $target 3301 \$(NOECHO) \$(NOOP) 3302 3303$target :: $plfile $pm_dep 3304 \$($perlrun) $plfile $target 3305MAKE_FRAG 3306 3307 } 3308 } 3309 3310 return $m; 3311} 3312 3313=item specify_shell 3314 3315Specify SHELL if needed - not done on Unix. 3316 3317=cut 3318 3319sub specify_shell { 3320 return ''; 3321} 3322 3323=item quote_paren 3324 3325Backslashes parentheses C<()> in command line arguments. 3326Doesn't handle recursive Makefile C<$(...)> constructs, 3327but handles simple ones. 3328 3329=cut 3330 3331sub quote_paren { 3332 my $arg = shift; 3333 $arg =~ s{\$\((.+?)\)}{\$\\\\($1\\\\)}g; # protect $(...) 3334 $arg =~ s{(?<!\\)([()])}{\\$1}g; # quote unprotected 3335 $arg =~ s{\$\\\\\((.+?)\\\\\)}{\$($1)}g; # unprotect $(...) 3336 return $arg; 3337} 3338 3339=item replace_manpage_separator 3340 3341 my $man_name = $MM->replace_manpage_separator($file_path); 3342 3343Takes the name of a package, which may be a nested package, in the 3344form 'Foo/Bar.pm' and replaces the slash with C<::> or something else 3345safe for a man page file name. Returns the replacement. 3346 3347=cut 3348 3349sub replace_manpage_separator { 3350 my($self,$man) = @_; 3351 3352 $man =~ s,/+,::,g; 3353 return $man; 3354} 3355 3356 3357=item cd 3358 3359=cut 3360 3361sub cd { 3362 my($self, $dir, @cmds) = @_; 3363 3364 # No leading tab and no trailing newline makes for easier embedding 3365 my $make_frag = join "\n\t", map { "cd $dir && $_" } @cmds; 3366 3367 return $make_frag; 3368} 3369 3370=item oneliner 3371 3372=cut 3373 3374sub oneliner { 3375 my($self, $cmd, $switches) = @_; 3376 $switches = [] unless defined $switches; 3377 3378 # Strip leading and trailing newlines 3379 $cmd =~ s{^\n+}{}; 3380 $cmd =~ s{\n+$}{}; 3381 3382 my @cmds = split /\n/, $cmd; 3383 $cmd = join " \n\t -e ", map $self->quote_literal($_), @cmds; 3384 $cmd = $self->escape_newlines($cmd); 3385 3386 $switches = join ' ', @$switches; 3387 3388 return qq{\$(ABSPERLRUN) $switches -e $cmd --}; 3389} 3390 3391 3392=item quote_literal 3393 3394Quotes macro literal value suitable for being used on a command line so 3395that when expanded by make, will be received by command as given to 3396this method: 3397 3398 my $quoted = $mm->quote_literal(q{it isn't}); 3399 # returns: 3400 # 'it isn'\''t' 3401 print MAKEFILE "target:\n\techo $quoted\n"; 3402 # when run "make target", will output: 3403 # it isn't 3404 3405=cut 3406 3407sub quote_literal { 3408 my($self, $text, $opts) = @_; 3409 $opts->{allow_variables} = 1 unless defined $opts->{allow_variables}; 3410 3411 # Quote single quotes 3412 $text =~ s{'}{'\\''}g; 3413 3414 $text = $opts->{allow_variables} 3415 ? $self->escape_dollarsigns($text) : $self->escape_all_dollarsigns($text); 3416 3417 return "'$text'"; 3418} 3419 3420 3421=item escape_newlines 3422 3423=cut 3424 3425sub escape_newlines { 3426 my($self, $text) = @_; 3427 3428 $text =~ s{\n}{\\\n}g; 3429 3430 return $text; 3431} 3432 3433 3434=item max_exec_len 3435 3436Using POSIX::ARG_MAX. Otherwise falling back to 4096. 3437 3438=cut 3439 3440sub max_exec_len { 3441 my $self = shift; 3442 3443 if (!defined $self->{_MAX_EXEC_LEN}) { 3444 if (my $arg_max = eval { require POSIX; &POSIX::ARG_MAX }) { 3445 $self->{_MAX_EXEC_LEN} = $arg_max; 3446 } 3447 else { # POSIX minimum exec size 3448 $self->{_MAX_EXEC_LEN} = 4096; 3449 } 3450 } 3451 3452 return $self->{_MAX_EXEC_LEN}; 3453} 3454 3455 3456=item static (o) 3457 3458Defines the static target. 3459 3460=cut 3461 3462sub static { 3463# --- Static Loading Sections --- 3464 3465 my($self) = shift; 3466 ' 3467## $(INST_PM) has been moved to the all: target. 3468## It remains here for awhile to allow for old usage: "make static" 3469static :: $(FIRST_MAKEFILE) $(INST_STATIC) 3470 $(NOECHO) $(NOOP) 3471'; 3472} 3473 3474sub static_lib { 3475 my($self) = @_; 3476 return '' unless $self->has_link_code; 3477 my(@m); 3478 my @libs; 3479 if ($self->{XSMULTI}) { 3480 for my $ext ($self->_xs_list_basenames) { 3481 my ($v, $d, $f) = File::Spec->splitpath($ext); 3482 my @d = File::Spec->splitdir($d); 3483 shift @d if $d[0] eq 'lib'; 3484 my $instdir = $self->catdir('$(INST_ARCHLIB)', 'auto', @d, $f); 3485 my $instfile = $self->catfile($instdir, "$f\$(LIB_EXT)"); 3486 my $objfile = "$ext\$(OBJ_EXT)"; 3487 push @libs, [ $objfile, $instfile, $instdir ]; 3488 } 3489 } else { 3490 @libs = ([ qw($(OBJECT) $(INST_STATIC) $(INST_ARCHAUTODIR)) ]); 3491 } 3492 push @m, map { $self->xs_make_static_lib(@$_); } @libs; 3493 join "\n", @m; 3494} 3495 3496=item xs_make_static_lib 3497 3498Defines the recipes for the C<static_lib> section. 3499 3500=cut 3501 3502sub xs_make_static_lib { 3503 my ($self, $from, $to, $todir) = @_; 3504 my @m = sprintf '%s: %s $(MYEXTLIB) %s$(DFSEP).exists'."\n", $to, $from, $todir; 3505 push @m, "\t\$(RM_F) \"\$\@\"\n"; 3506 push @m, $self->static_lib_fixtures; 3507 push @m, $self->static_lib_pure_cmd($from); 3508 push @m, "\t\$(CHMOD) \$(PERM_RWX) \$\@\n"; 3509 push @m, $self->static_lib_closures($todir); 3510 join '', @m; 3511} 3512 3513=item static_lib_closures 3514 3515Records C<$(EXTRALIBS)> in F<extralibs.ld> and F<$(PERL_SRC)/ext.libs>. 3516 3517=cut 3518 3519sub static_lib_closures { 3520 my ($self, $todir) = @_; 3521 my @m = sprintf <<'MAKE_FRAG', $todir; 3522 $(NOECHO) $(ECHO) "$(EXTRALIBS)" > %s$(DFSEP)extralibs.ld 3523MAKE_FRAG 3524 # Old mechanism - still available: 3525 push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS}; 3526 $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)$(DFSEP)ext.libs 3527MAKE_FRAG 3528 @m; 3529} 3530 3531=item static_lib_fixtures 3532 3533Handles copying C<$(MYEXTLIB)> as starter for final static library that 3534then gets added to. 3535 3536=cut 3537 3538sub static_lib_fixtures { 3539 my ($self) = @_; 3540 # If this extension has its own library (eg SDBM_File) 3541 # then copy that to $(INST_STATIC) and add $(OBJECT) into it. 3542 return unless $self->{MYEXTLIB}; 3543 "\t\$(CP) \$(MYEXTLIB) \"\$\@\"\n"; 3544} 3545 3546=item static_lib_pure_cmd 3547 3548Defines how to run the archive utility. 3549 3550=cut 3551 3552sub static_lib_pure_cmd { 3553 my ($self, $from) = @_; 3554 my $ar; 3555 if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) { 3556 # Prefer the absolute pathed ar if available so that PATH 3557 # doesn't confuse us. Perl itself is built with the full_ar. 3558 $ar = 'FULL_AR'; 3559 } else { 3560 $ar = 'AR'; 3561 } 3562 sprintf <<'MAKE_FRAG', $ar, $from; 3563 $(%s) $(AR_STATIC_ARGS) "$@" %s 3564 $(RANLIB) "$@" 3565MAKE_FRAG 3566} 3567 3568=item staticmake (o) 3569 3570Calls makeaperl. 3571 3572=cut 3573 3574sub staticmake { 3575 my($self, %attribs) = @_; 3576 my(@static); 3577 3578 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB}); 3579 3580 # And as it's not yet built, we add the current extension 3581 # but only if it has some C code (or XS code, which implies C code) 3582 if (@{$self->{C}}) { 3583 @static = $self->catfile($self->{INST_ARCHLIB}, 3584 "auto", 3585 $self->{FULLEXT}, 3586 "$self->{BASEEXT}$self->{LIB_EXT}" 3587 ); 3588 } 3589 3590 # Either we determine now, which libraries we will produce in the 3591 # subdirectories or we do it at runtime of the make. 3592 3593 # We could ask all subdir objects, but I cannot imagine, why it 3594 # would be necessary. 3595 3596 # Instead we determine all libraries for the new perl at 3597 # runtime. 3598 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB}); 3599 3600 $self->makeaperl(MAKE => $self->{MAKEFILE}, 3601 DIRS => \@searchdirs, 3602 STAT => \@static, 3603 INCL => \@perlinc, 3604 TARGET => $self->{MAP_TARGET}, 3605 TMP => "", 3606 LIBPERL => $self->{LIBPERL_A} 3607 ); 3608} 3609 3610=item subdir_x (o) 3611 3612Helper subroutine for subdirs 3613 3614=cut 3615 3616sub subdir_x { 3617 my($self, $subdir) = @_; 3618 3619 my $subdir_cmd = $self->cd($subdir, 3620 '$(MAKE) $(USEMAKEFILE) $(FIRST_MAKEFILE) all $(PASTHRU)' 3621 ); 3622 return sprintf <<'EOT', $subdir_cmd; 3623 3624subdirs :: 3625 $(NOECHO) %s 3626EOT 3627 3628} 3629 3630=item subdirs (o) 3631 3632Defines targets to process subdirectories. 3633 3634=cut 3635 3636sub subdirs { 3637# --- Sub-directory Sections --- 3638 my($self) = shift; 3639 my(@m); 3640 # This method provides a mechanism to automatically deal with 3641 # subdirectories containing further Makefile.PL scripts. 3642 # It calls the subdir_x() method for each subdirectory. 3643 foreach my $dir (@{$self->{DIR}}){ 3644 push @m, $self->subdir_x($dir); 3645#### print "Including $dir subdirectory\n"; 3646 } 3647 if (@m){ 3648 unshift @m, <<'EOF'; 3649 3650# The default clean, realclean and test targets in this Makefile 3651# have automatically been given entries for each subdir. 3652 3653EOF 3654 } else { 3655 push(@m, "\n# none") 3656 } 3657 join('',@m); 3658} 3659 3660=item test (o) 3661 3662Defines the test targets. 3663 3664=cut 3665 3666sub test { 3667 my($self, %attribs) = @_; 3668 my $tests = $attribs{TESTS} || ''; 3669 if (!$tests && -d 't' && defined $attribs{RECURSIVE_TEST_FILES}) { 3670 $tests = $self->find_tests_recursive; 3671 } 3672 elsif (!$tests && -d 't') { 3673 $tests = $self->find_tests; 3674 } 3675 # have to do this because nmake is broken 3676 $tests =~ s!/!\\!g if $self->is_make_type('nmake'); 3677 # note: 'test.pl' name is also hardcoded in init_dirscan() 3678 my @m; 3679 my $default_testtype = $Config{usedl} ? 'dynamic' : 'static'; 3680 push @m, <<EOF; 3681TEST_VERBOSE=0 3682TEST_TYPE=test_\$(LINKTYPE) 3683TEST_FILE = test.pl 3684TEST_FILES = $tests 3685TESTDB_SW = -d 3686 3687testdb :: testdb_\$(LINKTYPE) 3688 \$(NOECHO) \$(NOOP) 3689 3690test :: \$(TEST_TYPE) 3691 \$(NOECHO) \$(NOOP) 3692 3693# Occasionally we may face this degenerate target: 3694test_ : test_$default_testtype 3695 \$(NOECHO) \$(NOOP) 3696 3697EOF 3698 3699 for my $linktype (qw(dynamic static)) { 3700 my $directdeps = join ' ', grep !$self->{SKIPHASH}{$_}, $linktype, "pure_all"; # no depend on a linktype if SKIPped 3701 push @m, "subdirs-test_$linktype :: $directdeps\n"; 3702 foreach my $dir (@{ $self->{DIR} }) { 3703 my $test = $self->cd($dir, "\$(MAKE) test_$linktype \$(PASTHRU)"); 3704 push @m, "\t\$(NOECHO) $test\n"; 3705 } 3706 push @m, "\n"; 3707 if ($tests or -f "test.pl") { 3708 for my $testspec ([ '', '' ], [ 'db', ' $(TESTDB_SW)' ]) { 3709 my ($db, $switch) = @$testspec; 3710 my ($command, $deps); 3711 # if testdb, build all but don't test all 3712 $deps = $db eq 'db' ? $directdeps : "subdirs-test_$linktype"; 3713 if ($linktype eq 'static' and $self->needs_linking) { 3714 my $target = File::Spec->rel2abs('$(MAP_TARGET)'); 3715 $command = qq{"$target" \$(MAP_PERLINC)}; 3716 $deps .= ' $(MAP_TARGET)'; 3717 } else { 3718 $command = '$(FULLPERLRUN)' . $switch; 3719 } 3720 push @m, "test${db}_$linktype :: $deps\n"; 3721 if ($db eq 'db') { 3722 push @m, $self->test_via_script($command, '$(TEST_FILE)') 3723 } else { 3724 push @m, $self->test_via_script($command, '$(TEST_FILE)') 3725 if -f "test.pl"; 3726 push @m, $self->test_via_harness($command, '$(TEST_FILES)') 3727 if $tests; 3728 } 3729 push @m, "\n"; 3730 } 3731 } else { 3732 push @m, _sprintf562 <<'EOF', $linktype; 3733testdb_%1$s test_%1$s :: subdirs-test_%1$s 3734 $(NOECHO) $(ECHO) 'No tests defined for $(NAME) extension.' 3735 3736EOF 3737 } 3738 } 3739 3740 join "", @m; 3741} 3742 3743=item test_via_harness (override) 3744 3745For some reason which I forget, Unix machines like to have 3746PERL_DL_NONLAZY set for tests. 3747 3748=cut 3749 3750sub test_via_harness { 3751 my($self, $perl, $tests) = @_; 3752 return $self->SUPER::test_via_harness("PERL_DL_NONLAZY=1 $perl", $tests); 3753} 3754 3755=item test_via_script (override) 3756 3757Again, the PERL_DL_NONLAZY thing. 3758 3759=cut 3760 3761sub test_via_script { 3762 my($self, $perl, $script) = @_; 3763 return $self->SUPER::test_via_script("PERL_DL_NONLAZY=1 $perl", $script); 3764} 3765 3766 3767=item tool_xsubpp (o) 3768 3769Determines typemaps, xsubpp version, prototype behaviour. 3770 3771=cut 3772 3773sub tool_xsubpp { 3774 my($self) = shift; 3775 return "" unless $self->needs_linking; 3776 3777 my $xsdir; 3778 my @xsubpp_dirs = @INC; 3779 3780 # Make sure we pick up the new xsubpp if we're building perl. 3781 unshift @xsubpp_dirs, $self->{PERL_LIB} if $self->{PERL_CORE}; 3782 3783 my $foundxsubpp = 0; 3784 foreach my $dir (@xsubpp_dirs) { 3785 $xsdir = $self->catdir($dir, 'ExtUtils'); 3786 if( -r $self->catfile($xsdir, "xsubpp") ) { 3787 $foundxsubpp = 1; 3788 last; 3789 } 3790 } 3791 die "ExtUtils::MM_Unix::tool_xsubpp : Can't find xsubpp" if !$foundxsubpp; 3792 3793 my $tmdir = $self->catdir($self->{PERL_LIB},"ExtUtils"); 3794 my(@tmdeps) = $self->catfile($tmdir,'typemap'); 3795 if( $self->{TYPEMAPS} ){ 3796 foreach my $typemap (@{$self->{TYPEMAPS}}){ 3797 if( ! -f $typemap ) { 3798 warn "Typemap $typemap not found.\n"; 3799 } 3800 else { 3801 $typemap = vmsify($typemap) if $Is{VMS}; 3802 push(@tmdeps, $typemap); 3803 } 3804 } 3805 } 3806 push(@tmdeps, "typemap") if -f "typemap"; 3807 # absolutised because with deep-located typemaps, eg "lib/XS/typemap", 3808 # if xsubpp is called from top level with 3809 # $(XSUBPP) ... -typemap "lib/XS/typemap" "lib/XS/Test.xs" 3810 # it says: 3811 # Can't find lib/XS/type map in (fulldir)/lib/XS 3812 # because ExtUtils::ParseXS::process_file chdir's to .xs file's 3813 # location. This is the only way to get all specified typemaps used, 3814 # wherever located. 3815 my @tmargs = map { '-typemap '.$self->quote_literal(File::Spec->rel2abs($_)) } @tmdeps; 3816 $_ = $self->quote_dep($_) for @tmdeps; 3817 if( exists $self->{XSOPT} ){ 3818 unshift( @tmargs, $self->{XSOPT} ); 3819 } 3820 3821 if ($Is{VMS} && 3822 $Config{'ldflags'} && 3823 $Config{'ldflags'} =~ m!/Debug!i && 3824 (!exists($self->{XSOPT}) || $self->{XSOPT} !~ /linenumbers/) 3825 ) 3826 { 3827 unshift(@tmargs,'-nolinenumbers'); 3828 } 3829 3830 3831 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG}; 3832 my $xsdirdep = $self->quote_dep($xsdir); 3833 # -dep for use when dependency not command 3834 3835 return qq{ 3836XSUBPPDIR = $xsdir 3837XSUBPP = "\$(XSUBPPDIR)\$(DFSEP)xsubpp" 3838XSUBPPRUN = \$(PERLRUN) \$(XSUBPP) 3839XSPROTOARG = $self->{XSPROTOARG} 3840XSUBPPDEPS = @tmdeps $xsdirdep\$(DFSEP)xsubpp 3841XSUBPPARGS = @tmargs 3842XSUBPP_EXTRA_ARGS = 3843}; 3844} 3845 3846 3847=item all_target 3848 3849Build man pages, too 3850 3851=cut 3852 3853sub all_target { 3854 my $self = shift; 3855 3856 return <<'MAKE_EXT'; 3857all :: pure_all manifypods 3858 $(NOECHO) $(NOOP) 3859MAKE_EXT 3860} 3861 3862=item top_targets (o) 3863 3864Defines the targets all, subdirs, config, and O_FILES 3865 3866=cut 3867 3868sub top_targets { 3869# --- Target Sections --- 3870 3871 my($self) = shift; 3872 my(@m); 3873 3874 push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'}; 3875 3876 push @m, sprintf <<'EOF'; 3877pure_all :: config pm_to_blib subdirs linkext 3878 $(NOECHO) $(NOOP) 3879 3880 $(NOECHO) $(NOOP) 3881 3882subdirs :: $(MYEXTLIB) 3883 $(NOECHO) $(NOOP) 3884 3885config :: $(FIRST_MAKEFILE) blibdirs 3886 $(NOECHO) $(NOOP) 3887EOF 3888 3889 push @m, ' 3890$(O_FILES) : $(H_FILES) 3891' if @{$self->{O_FILES} || []} && @{$self->{H} || []}; 3892 3893 push @m, q{ 3894help : 3895 perldoc ExtUtils::MakeMaker 3896}; 3897 3898 join('',@m); 3899} 3900 3901=item writedoc 3902 3903Obsolete, deprecated method. Not used since Version 5.21. 3904 3905=cut 3906 3907sub writedoc { 3908# --- perllocal.pod section --- 3909 my($self,$what,$name,@attribs)=@_; 3910 my $time = gmtime($ENV{SOURCE_DATE_EPOCH} || time); 3911 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n"; 3912 print join "\n\n=item *\n\n", map("C<$_>",@attribs); 3913 print "\n\n=back\n\n"; 3914} 3915 3916=item xs_c (o) 3917 3918Defines the suffix rules to compile XS files to C. 3919 3920=cut 3921 3922sub xs_c { 3923 my($self) = shift; 3924 return '' unless $self->needs_linking(); 3925 ' 3926.xs.c: 3927 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc 3928 $(MV) $*.xsc $*.c 3929'; 3930} 3931 3932=item xs_cpp (o) 3933 3934Defines the suffix rules to compile XS files to C++. 3935 3936=cut 3937 3938sub xs_cpp { 3939 my($self) = shift; 3940 return '' unless $self->needs_linking(); 3941 ' 3942.xs.cpp: 3943 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc 3944 $(MV) $*.xsc $*.cpp 3945'; 3946} 3947 3948=item xs_o (o) 3949 3950Defines suffix rules to go from XS to object files directly. This was 3951originally only intended for broken make implementations, but is now 3952necessary for per-XS file under C<XSMULTI>, since each XS file might 3953have an individual C<$(VERSION)>. 3954 3955=cut 3956 3957sub xs_o { 3958 my ($self) = @_; 3959 return '' unless $self->needs_linking(); 3960 my $m_o = $self->{XSMULTI} ? $self->xs_obj_opt('$*$(OBJ_EXT)') : ''; 3961 my $frag = ''; 3962 # dmake makes noise about ambiguous rule 3963 $frag .= sprintf <<'EOF', $m_o unless $self->is_make_type('dmake'); 3964.xs$(OBJ_EXT) : 3965 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc 3966 $(MV) $*.xsc $*.c 3967 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c %s 3968EOF 3969 if ($self->{XSMULTI}) { 3970 for my $ext ($self->_xs_list_basenames) { 3971 my $pmfile = "$ext.pm"; 3972 croak "$ext.xs has no matching $pmfile: $!" unless -f $pmfile; 3973 my $version = $self->parse_version($pmfile); 3974 my $cccmd = $self->{CONST_CCCMD}; 3975 $cccmd =~ s/^\s*CCCMD\s*=\s*//; 3976 $cccmd =~ s/\$\(DEFINE_VERSION\)/-DVERSION=\\"$version\\"/; 3977 $cccmd =~ s/\$\(XS_DEFINE_VERSION\)/-DXS_VERSION=\\"$version\\"/; 3978 $self->_xsbuild_replace_macro($cccmd, 'xs', $ext, 'INC'); 3979 my $define = '$(DEFINE)'; 3980 $self->_xsbuild_replace_macro($define, 'xs', $ext, 'DEFINE'); 3981 # 1 2 3 4 3982 $frag .= _sprintf562 <<'EOF', $ext, $cccmd, $m_o, $define; 3983 3984%1$s$(OBJ_EXT): %1$s.xs 3985 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc 3986 $(MV) $*.xsc $*.c 3987 %2$s $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) %4$s $*.c %3$s 3988EOF 3989 } 3990 } 3991 $frag; 3992} 3993 3994# param gets modified 3995sub _xsbuild_replace_macro { 3996 my ($self, undef, $xstype, $ext, $varname) = @_; 3997 my $value = $self->_xsbuild_value($xstype, $ext, $varname); 3998 return unless defined $value; 3999 $_[1] =~ s/\$\($varname\)/$value/; 4000} 4001 4002sub _xsbuild_value { 4003 my ($self, $xstype, $ext, $varname) = @_; 4004 return $self->{XSBUILD}{$xstype}{$ext}{$varname} 4005 if $self->{XSBUILD}{$xstype}{$ext}{$varname}; 4006 return $self->{XSBUILD}{$xstype}{all}{$varname} 4007 if $self->{XSBUILD}{$xstype}{all}{$varname}; 4008 (); 4009} 4010 40111; 4012 4013=back 4014 4015=head1 SEE ALSO 4016 4017L<ExtUtils::MakeMaker> 4018 4019=cut 4020 4021__END__ 4022