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