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