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