This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldoc under OS/2
[perl5.git] / lib / ExtUtils / MM_Unix.pm
CommitLineData
1e44e2bf
PP
1package ExtUtils::MM_Unix;
2
dbc738d9 3use Exporter ();
f1387719
PP
4use Config;
5use File::Basename qw(basename dirname fileparse);
6use DirHandle;
dbc738d9 7use strict;
137443ea 8use vars qw($VERSION $Is_Mac $Is_OS2 $Is_VMS $Is_Win32
a1f8e286 9 $Verbose %pm %static $Xsubpp_Version);
dbc738d9 10
68dc0745 11$VERSION = substr q$Revision: 1.114 $, 10;
ff0cee69 12# $Id: MM_Unix.pm,v 1.113 1997/02/11 21:54:09 k Exp $
1e44e2bf
PP
13
14Exporter::import('ExtUtils::MakeMaker',
15 qw( $Verbose &neatvalue));
16
bab2b58e 17$Is_OS2 = $^O eq 'os2';
137443ea
PP
18$Is_Mac = $^O eq 'MacOS';
19$Is_Win32 = $^O eq 'MSWin32';
f1387719
PP
20
21if ($Is_VMS = $^O eq 'VMS') {
22 require VMS::Filespec;
23 import VMS::Filespec qw( &vmsify );
24}
1e44e2bf
PP
25
26=head1 NAME
27
28ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
29
30=head1 SYNOPSIS
31
32C<require ExtUtils::MM_Unix;>
33
34=head1 DESCRIPTION
35
36The methods provided by this package are designed to be used in
37conjunction with ExtUtils::MakeMaker. When MakeMaker writes a
38Makefile, it creates one or more objects that inherit their methods
39from a package C<MM>. MM itself doesn't provide any methods, but it
40ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating
41specific packages take the responsibility for all the methods provided
42by MM_Unix. We are trying to reduce the number of the necessary
43overrides by defining rather primitive operations within
44ExtUtils::MM_Unix.
45
46If you are going to write a platform specific MM package, please try
1fef88e7
JM
47to limit the necessary overrides to primitive methods, and if it is not
48possible to do so, let's work out how to achieve that gain.
1e44e2bf 49
f4ae0f5e
PP
50If you are overriding any of these methods in your Makefile.PL (in the
51MY class), please report that to the makemaker mailing list. We are
52trying to minimize the necessary method overrides and switch to data
53driven Makefile.PLs wherever possible. In the long run less methods
54will be overridable via the MY class.
55
1e44e2bf
PP
56=head1 METHODS
57
58The following description of methods is still under
59development. Please refer to the code for not suitably documented
60sections and complain loudly to the makemaker mailing list.
61
f1387719 62Not all of the methods below are overridable in a
f4ae0f5e
PP
63Makefile.PL. Overridable methods are marked as (o). All methods are
64overridable by a platform specific MM_*.pm file (See
bab2b58e 65L<ExtUtils::MM_VMS>) and L<ExtUtils::MM_OS2>).
f4ae0f5e 66
1e44e2bf
PP
67=head2 Preloaded methods
68
69=over 2
70
f1387719
PP
71=item canonpath
72
73No physical check on the filesystem, but a logical cleanup of a
74path. On UNIX eliminated successive slashes and successive "/.".
75
76=cut
77
78sub canonpath {
79 my($self,$path) = @_;
80 $path =~ s|/+|/|g ; # xx////xx -> xx/xx
81 $path =~ s|(/\.)+/|/|g ; # xx/././xx -> xx/xx
82 $path =~ s|^(\./)+|| unless $path eq "./"; # ./xx -> xx
83 $path =~ s|/$|| unless $path eq "/"; # xx/ -> xx
84 $path;
85}
86
1e44e2bf
PP
87=item catdir
88
89Concatenate two or more directory names to form a complete path ending
f1387719
PP
90with a directory. But remove the trailing slash from the resulting
91string, because it doesn't look good, isn't necessary and confuses
92OS2. Of course, if this is the root directory, don't cut off the
93trailing slash :-)
1e44e2bf
PP
94
95=cut
96
97# ';
98
f1387719 99sub catdir {
1e44e2bf 100 shift;
f1387719
PP
101 my @args = @_;
102 for (@args) {
103 # append a slash to each argument unless it has one there
93f9cb4b 104 $_ .= "/" if $_ eq '' or substr($_,-1) ne "/";
f1387719
PP
105 }
106 my $result = join('', @args);
107 # remove a trailing slash unless we are root
93f9cb4b
PP
108 substr($result,-1) = ""
109 if length($result) > 1 && substr($result,-1) eq "/";
1e44e2bf
PP
110 $result;
111}
112
113=item catfile
114
f1387719 115Concatenate one or more directory names and a filename to form a
1e44e2bf
PP
116complete path ending with a filename
117
118=cut
119
120sub catfile {
f1387719
PP
121 my $self = shift @_;
122 my $file = pop @_;
123 return $file unless @_;
124 my $dir = $self->catdir(@_);
125 for ($dir) {
126 $_ .= "/" unless substr($_,length($_)-1,1) eq "/";
127 }
128 return $dir.$file;
1e44e2bf
PP
129}
130
f1387719
PP
131=item curdir
132
133Returns a string representing of the current directory. "." on UNIX.
134
135=cut
136
137sub curdir {
138 return "." ;
139}
140
141=item rootdir
142
143Returns a string representing of the root directory. "/" on UNIX.
144
145=cut
146
147sub rootdir {
148 return "/";
149}
150
151=item updir
152
153Returns a string representing of the parent directory. ".." on UNIX.
154
155=cut
156
157sub updir {
158 return "..";
159}
160
161sub ExtUtils::MM_Unix::c_o ;
162sub ExtUtils::MM_Unix::clean ;
163sub ExtUtils::MM_Unix::const_cccmd ;
f4ae0f5e 164sub ExtUtils::MM_Unix::const_config ;
f4ae0f5e 165sub ExtUtils::MM_Unix::const_loadlibs ;
f1387719 166sub ExtUtils::MM_Unix::constants ;
f4ae0f5e 167sub ExtUtils::MM_Unix::depend ;
f1387719
PP
168sub ExtUtils::MM_Unix::dir_target ;
169sub ExtUtils::MM_Unix::dist ;
170sub ExtUtils::MM_Unix::dist_basics ;
171sub ExtUtils::MM_Unix::dist_ci ;
172sub ExtUtils::MM_Unix::dist_core ;
173sub ExtUtils::MM_Unix::dist_dir ;
174sub ExtUtils::MM_Unix::dist_test ;
f4ae0f5e
PP
175sub ExtUtils::MM_Unix::dlsyms ;
176sub ExtUtils::MM_Unix::dynamic ;
177sub ExtUtils::MM_Unix::dynamic_bs ;
178sub ExtUtils::MM_Unix::dynamic_lib ;
f1387719 179sub ExtUtils::MM_Unix::exescan ;
68dc0745 180sub ExtUtils::MM_Unix::export_list ;
f1387719
PP
181sub ExtUtils::MM_Unix::extliblist ;
182sub ExtUtils::MM_Unix::file_name_is_absolute ;
183sub ExtUtils::MM_Unix::find_perl ;
184sub ExtUtils::MM_Unix::force ;
185sub ExtUtils::MM_Unix::guess_name ;
186sub ExtUtils::MM_Unix::has_link_code ;
187sub ExtUtils::MM_Unix::init_dirscan ;
188sub ExtUtils::MM_Unix::init_main ;
189sub ExtUtils::MM_Unix::init_others ;
190sub ExtUtils::MM_Unix::install ;
191sub ExtUtils::MM_Unix::installbin ;
192sub ExtUtils::MM_Unix::libscan ;
193sub ExtUtils::MM_Unix::linkext ;
194sub ExtUtils::MM_Unix::lsdir ;
195sub ExtUtils::MM_Unix::macro ;
196sub ExtUtils::MM_Unix::makeaperl ;
197sub ExtUtils::MM_Unix::makefile ;
f4ae0f5e 198sub ExtUtils::MM_Unix::manifypods ;
f1387719
PP
199sub ExtUtils::MM_Unix::maybe_command ;
200sub ExtUtils::MM_Unix::maybe_command_in_dirs ;
201sub ExtUtils::MM_Unix::needs_linking ;
202sub ExtUtils::MM_Unix::nicetext ;
203sub ExtUtils::MM_Unix::parse_version ;
204sub ExtUtils::MM_Unix::pasthru ;
205sub ExtUtils::MM_Unix::path ;
68dc0745 206sub ExtUtils::MM_Unix::perl_archive;
f1387719
PP
207sub ExtUtils::MM_Unix::perl_script ;
208sub ExtUtils::MM_Unix::perldepend ;
209sub ExtUtils::MM_Unix::pm_to_blib ;
210sub ExtUtils::MM_Unix::post_constants ;
211sub ExtUtils::MM_Unix::post_initialize ;
212sub ExtUtils::MM_Unix::postamble ;
213sub ExtUtils::MM_Unix::prefixify ;
f4ae0f5e 214sub ExtUtils::MM_Unix::processPL ;
f4ae0f5e 215sub ExtUtils::MM_Unix::realclean ;
f1387719
PP
216sub ExtUtils::MM_Unix::replace_manpage_separator ;
217sub ExtUtils::MM_Unix::static ;
218sub ExtUtils::MM_Unix::static_lib ;
f4ae0f5e 219sub ExtUtils::MM_Unix::staticmake ;
f1387719
PP
220sub ExtUtils::MM_Unix::subdir_x ;
221sub ExtUtils::MM_Unix::subdirs ;
f4ae0f5e
PP
222sub ExtUtils::MM_Unix::test ;
223sub ExtUtils::MM_Unix::test_via_harness ;
224sub ExtUtils::MM_Unix::test_via_script ;
f1387719
PP
225sub ExtUtils::MM_Unix::tool_autosplit ;
226sub ExtUtils::MM_Unix::tool_xsubpp ;
227sub ExtUtils::MM_Unix::tools_other ;
228sub ExtUtils::MM_Unix::top_targets ;
f4ae0f5e 229sub ExtUtils::MM_Unix::writedoc ;
f1387719
PP
230sub ExtUtils::MM_Unix::xs_c ;
231sub ExtUtils::MM_Unix::xs_o ;
232sub ExtUtils::MM_Unix::xsubpp_version ;
f4ae0f5e
PP
233
234package ExtUtils::MM_Unix;
235
93f9cb4b 236use SelfLoader;
f4ae0f5e
PP
237
2381;
93f9cb4b
PP
239
240__DATA__
f4ae0f5e 241
bab2b58e
AK
242=back
243
f4ae0f5e
PP
244=head2 SelfLoaded methods
245
bab2b58e
AK
246=over 2
247
f1387719 248=item c_o (o)
1e44e2bf 249
f1387719
PP
250Defines the suffix rules to compile different flavors of C files to
251object files.
1e44e2bf
PP
252
253=cut
254
f1387719
PP
255sub c_o {
256# --- Translation Sections ---
1e44e2bf 257
f1387719
PP
258 my($self) = shift;
259 return '' unless $self->needs_linking();
260 my(@m);
261 push @m, '
262.c$(OBJ_EXT):
042ade60 263 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
a0d6894c
PP
264';
265 push @m, '
f1387719
PP
266.C$(OBJ_EXT):
267 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.C
3e3baf6d 268' if $^O ne 'os2' and $^O ne 'MSWin32'; # Case-specific
a0d6894c 269 push @m, '
f1387719
PP
270.cpp$(OBJ_EXT):
271 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cpp
1e44e2bf 272
f1387719
PP
273.cxx$(OBJ_EXT):
274 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cxx
1e44e2bf 275
f1387719
PP
276.cc$(OBJ_EXT):
277 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cc
278';
279 join "", @m;
1e44e2bf
PP
280}
281
f1387719 282=item cflags (o)
1e44e2bf 283
f1387719
PP
284Does very much the same as the cflags script in the perl
285distribution. It doesn't return the whole compiler command line, but
286initializes all of its parts. The const_cccmd method then actually
287returns the definition of the CCCMD macro which uses these parts.
1e44e2bf
PP
288
289=cut
290
f1387719 291#'
1e44e2bf 292
f1387719
PP
293sub cflags {
294 my($self,$libperl)=@_;
295 return $self->{CFLAGS} if $self->{CFLAGS};
296 return '' unless $self->needs_linking();
1e44e2bf 297
f1387719
PP
298 my($prog, $uc, $perltype, %cflags);
299 $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
300 $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
1e44e2bf 301
f1387719
PP
302 @cflags{qw(cc ccflags optimize large split shellflags)}
303 = @Config{qw(cc ccflags optimize large split shellflags)};
304 my($optdebug) = "";
1e44e2bf 305
f1387719 306 $cflags{shellflags} ||= '';
1e44e2bf 307
f1387719
PP
308 my(%map) = (
309 D => '-DDEBUGGING',
310 E => '-DEMBED',
311 DE => '-DDEBUGGING -DEMBED',
312 M => '-DEMBED -DMULTIPLICITY',
313 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
314 );
1e44e2bf 315
f1387719
PP
316 if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
317 $uc = uc($1);
318 } else {
319 $uc = ""; # avoid warning
320 }
321 $perltype = $map{$uc} ? $map{$uc} : "";
1e44e2bf 322
f1387719
PP
323 if ($uc =~ /^D/) {
324 $optdebug = "-g";
325 }
1e44e2bf 326
1e44e2bf 327
f1387719
PP
328 my($name);
329 ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
330 if ($prog = $Config::Config{$name}) {
331 # Expand hints for this extension via the shell
332 print STDOUT "Processing $name hint:\n" if $Verbose;
333 my(@o)=`cc=\"$cflags{cc}\"
334 ccflags=\"$cflags{ccflags}\"
335 optimize=\"$cflags{optimize}\"
336 perltype=\"$cflags{perltype}\"
337 optdebug=\"$cflags{optdebug}\"
338 large=\"$cflags{large}\"
339 split=\"$cflags{'split'}\"
340 eval '$prog'
341 echo cc=\$cc
342 echo ccflags=\$ccflags
343 echo optimize=\$optimize
344 echo perltype=\$perltype
345 echo optdebug=\$optdebug
346 echo large=\$large
347 echo split=\$split
348 `;
349 my($line);
350 foreach $line (@o){
351 chomp $line;
352 if ($line =~ /(.*?)=\s*(.*)\s*$/){
353 $cflags{$1} = $2;
354 print STDOUT " $1 = $2\n" if $Verbose;
355 } else {
356 print STDOUT "Unrecognised result from hint: '$line'\n";
357 }
358 }
359 }
1e44e2bf 360
f1387719
PP
361 if ($optdebug) {
362 $cflags{optimize} = $optdebug;
363 }
1e44e2bf 364
f1387719
PP
365 for (qw(ccflags optimize perltype large split)) {
366 $cflags{$_} =~ s/^\s+//;
367 $cflags{$_} =~ s/\s+/ /g;
368 $cflags{$_} =~ s/\s+$//;
369 $self->{uc $_} ||= $cflags{$_}
370 }
1e44e2bf 371
f1387719
PP
372 return $self->{CFLAGS} = qq{
373CCFLAGS = $self->{CCFLAGS}
374OPTIMIZE = $self->{OPTIMIZE}
375PERLTYPE = $self->{PERLTYPE}
376LARGE = $self->{LARGE}
377SPLIT = $self->{SPLIT}
378};
1e44e2bf 379
1e44e2bf
PP
380}
381
f1387719 382=item clean (o)
1e44e2bf 383
f1387719 384Defines the clean target.
1e44e2bf
PP
385
386=cut
387
f1387719
PP
388sub clean {
389# --- Cleanup and Distribution Sections ---
1e44e2bf 390
f1387719
PP
391 my($self, %attribs) = @_;
392 my(@m,$dir);
393 push(@m, '
394# Delete temporary files but do not touch installed files. We don\'t delete
395# the Makefile here so a later make realclean still has a makefile to use.
1e44e2bf 396
f1387719
PP
397clean ::
398');
399 # clean subdirectories first
400 for $dir (@{$self->{DIR}}) {
68dc0745 401 push @m, "\t-cd $dir && \$(TEST_F) $self->{MAKEFILE} && \$(MAKE) clean\n";
1e44e2bf 402 }
f1387719
PP
403
404 my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
405 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
406 push(@otherfiles, qw[./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all
407 perlmain.c mon.out core so_locations pm_to_blib
408 *~ */*~ */*/*~ *$(OBJ_EXT) *$(LIB_EXT) perl.exe
409 $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def
410 $(BASEEXT).exp
411 ]);
412 push @m, "\t-$self->{RM_RF} @otherfiles\n";
413 # See realclean and ext/utils/make_ext for usage of Makefile.old
414 push(@m,
68dc0745 415 "\t-$self->{MV} $self->{MAKEFILE} $self->{MAKEFILE}.old \$(DEV_NULL)\n");
f1387719
PP
416 push(@m,
417 "\t$attribs{POSTOP}\n") if $attribs{POSTOP};
418 join("", @m);
1e44e2bf
PP
419}
420
f1387719 421=item const_cccmd (o)
1e44e2bf 422
f1387719
PP
423Returns the full compiler call for C programs and stores the
424definition in CONST_CCCMD.
1e44e2bf
PP
425
426=cut
427
f1387719
PP
428sub const_cccmd {
429 my($self,$libperl)=@_;
430 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
431 return '' unless $self->needs_linking();
432 return $self->{CONST_CCCMD} =
433 q{CCCMD = $(CC) -c $(INC) $(CCFLAGS) $(OPTIMIZE) \\
434 $(PERLTYPE) $(LARGE) $(SPLIT) $(DEFINE_VERSION) \\
435 $(XS_DEFINE_VERSION)};
1e44e2bf
PP
436}
437
f1387719 438=item const_config (o)
1e44e2bf 439
f1387719
PP
440Defines a couple of constants in the Makefile that are imported from
441%Config.
1e44e2bf
PP
442
443=cut
444
f1387719
PP
445sub const_config {
446# --- Constants Sections ---
447
448 my($self) = shift;
449 my(@m,$m);
450 push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
451 push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n");
452 my(%once_only);
453 foreach $m (@{$self->{CONFIG}}){
454 # SITE*EXP macros are defined in &constants; avoid duplicates here
455 next if $once_only{$m} or $m eq 'sitelibexp' or $m eq 'sitearchexp';
456 push @m, "\U$m\E = ".$self->{uc $m}."\n";
457 $once_only{$m} = 1;
458 }
459 join('', @m);
1e44e2bf
PP
460}
461
f1387719 462=item const_loadlibs (o)
1e44e2bf 463
f1387719
PP
464Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. See
465L<ExtUtils::Liblist> for details.
1e44e2bf
PP
466
467=cut
468
f1387719
PP
469sub const_loadlibs {
470 my($self) = shift;
471 return "" unless $self->needs_linking;
472 my @m;
473 push @m, qq{
474# $self->{NAME} might depend on some other libraries:
475# See ExtUtils::Liblist for details
476#
477};
478 my($tmp);
479 for $tmp (qw/
480 EXTRALIBS LDLOADLIBS BSLOADLIBS LD_RUN_PATH
481 /) {
482 next unless defined $self->{$tmp};
483 push @m, "$tmp = $self->{$tmp}\n";
484 }
485 return join "", @m;
1e44e2bf
PP
486}
487
f1387719 488=item constants (o)
1e44e2bf 489
f1387719 490Initializes lots of constants and .SUFFIXES and .PHONY
1e44e2bf
PP
491
492=cut
493
f1387719 494sub constants {
1e44e2bf 495 my($self) = @_;
f1387719 496 my(@m,$tmp);
1e44e2bf 497
f1387719 498 for $tmp (qw/
1e44e2bf 499
f1387719
PP
500 AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION
501 VERSION_SYM XS_VERSION INST_BIN INST_EXE INST_LIB
bab2b58e 502 INST_ARCHLIB INST_SCRIPT PREFIX INSTALLDIRS
f1387719
PP
503 INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB
504 INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB
505 PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
506 FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC
507 PERL_INC PERL FULLPERL
1e44e2bf 508
f1387719
PP
509 / ) {
510 next unless defined $self->{$tmp};
511 push @m, "$tmp = $self->{$tmp}\n";
1e44e2bf
PP
512 }
513
f1387719
PP
514 push @m, qq{
515VERSION_MACRO = VERSION
516DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
517XS_VERSION_MACRO = XS_VERSION
518XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
519};
1e44e2bf 520
f1387719
PP
521 push @m, qq{
522MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'}
523MM_VERSION = $ExtUtils::MakeMaker::VERSION
524};
1e44e2bf 525
f1387719
PP
526 push @m, q{
527# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
528# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
529# ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) !!! Deprecated from MM 5.32 !!!
530# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
531# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
532};
1e44e2bf 533
f1387719
PP
534 for $tmp (qw/
535 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
536 LDFROM LINKTYPE
537 / ) {
538 next unless defined $self->{$tmp};
539 push @m, "$tmp = $self->{$tmp}\n";
540 }
1e44e2bf 541
f1387719
PP
542 push @m, "
543# Handy lists of source code files:
544XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
545C_FILES = ".join(" \\\n\t", @{$self->{C}})."
546O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
547H_FILES = ".join(" \\\n\t", @{$self->{H}})."
548MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
549MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
550";
1e44e2bf 551
f1387719
PP
552 for $tmp (qw/
553 INST_MAN1DIR INSTALLMAN1DIR MAN1EXT INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
554 /) {
555 next unless defined $self->{$tmp};
556 push @m, "$tmp = $self->{$tmp}\n";
557 }
1e44e2bf 558
f1387719
PP
559 push @m, q{
560.NO_CONFIG_REC: Makefile
561} if $ENV{CLEARCASE_ROOT};
1e44e2bf 562
f1387719
PP
563 # why not q{} ? -- emacs
564 push @m, qq{
565# work around a famous dec-osf make(1) feature(?):
566makemakerdflt: all
1e44e2bf 567
f1387719 568.SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
1e44e2bf 569
f1387719
PP
570# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
571# some make implementations will delete the Makefile when we rebuild it. Because
572# we call false(1) when we rebuild it. So make(1) is not completely wrong when it
573# does so. Our milage may vary.
574# .PRECIOUS: Makefile # seems to be not necessary anymore
1e44e2bf 575
f1387719 576.PHONY: all config static dynamic test linkext manifest
1e44e2bf 577
f1387719
PP
578# Where is the Config information that we are using/depend on
579CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm \$(PERL_INC)/config.h
dbc738d9 580};
1e44e2bf 581
dbc738d9
PP
582 my @parentdir = split(/::/, $self->{PARENT_NAME});
583 push @m, q{
f1387719 584# Where to put things:
dbc738d9
PP
585INST_LIBDIR = }. $self->catdir('$(INST_LIB)',@parentdir) .q{
586INST_ARCHLIBDIR = }. $self->catdir('$(INST_ARCHLIB)',@parentdir) .q{
1e44e2bf 587
dbc738d9
PP
588INST_AUTODIR = }. $self->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
589INST_ARCHAUTODIR = }. $self->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
f1387719 590};
1e44e2bf 591
f1387719
PP
592 if ($self->has_link_code()) {
593 push @m, '
594INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT)
595INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT)
596INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
597';
598 } else {
599 push @m, '
600INST_STATIC =
601INST_DYNAMIC =
602INST_BOOT =
603';
1e44e2bf
PP
604 }
605
68dc0745 606 $tmp = $self->export_list;
f1387719
PP
607 push @m, "
608EXPORT_LIST = $tmp
609";
68dc0745 610 $tmp = $self->perl_archive;
f1387719
PP
611 push @m, "
612PERL_ARCHIVE = $tmp
613";
1e44e2bf 614
f1387719
PP
615# push @m, q{
616#INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{
617#
618#PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
619#};
1e44e2bf 620
f1387719
PP
621 push @m, q{
622TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
1e44e2bf 623
f1387719
PP
624PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
625};
1e44e2bf 626
f1387719
PP
627 join('',@m);
628}
1e44e2bf 629
f1387719 630=item depend (o)
1e44e2bf 631
f1387719 632Same as macro for the depend attribute.
1e44e2bf 633
f1387719 634=cut
1e44e2bf 635
f1387719
PP
636sub depend {
637 my($self,%attribs) = @_;
638 my(@m,$key,$val);
639 while (($key,$val) = each %attribs){
640 last unless defined $key;
641 push @m, "$key: $val\n";
1e44e2bf 642 }
f1387719
PP
643 join "", @m;
644}
1e44e2bf 645
f1387719 646=item dir_target (o)
1e44e2bf 647
f1387719
PP
648Takes an array of directories that need to exist and returns a
649Makefile entry for a .exists file in these directories. Returns
650nothing, if the entry has already been processed. We're helpless
651though, if the same directory comes as $(FOO) _and_ as "bar". Both of
652them get an entry, that's why we use "::".
1e44e2bf 653
f1387719 654=cut
1e44e2bf 655
f1387719
PP
656sub dir_target {
657# --- Make-Directories section (internal method) ---
658# dir_target(@array) returns a Makefile entry for the file .exists in each
659# named directory. Returns nothing, if the entry has already been processed.
660# We're helpless though, if the same directory comes as $(FOO) _and_ as "bar".
661# Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the
662# prerequisite, because there has to be one, something that doesn't change
663# too often :)
1e44e2bf 664
f1387719 665 my($self,@dirs) = @_;
8cc95fdb 666 my(@m,$dir,$targdir);
f1387719
PP
667 foreach $dir (@dirs) {
668 my($src) = $self->catfile($self->{PERL_INC},'perl.h');
669 my($targ) = $self->catfile($dir,'.exists');
8cc95fdb
PP
670 # catfile may have adapted syntax of $dir to target OS, so...
671 if ($Is_VMS) { # Just remove file name; dirspec is often in macro
672 ($targdir = $targ) =~ s:/?\.exists$::;
673 }
674 else { # while elsewhere we expect to see the dir separator in $targ
675 $targdir = dirname($targ);
676 }
f1387719
PP
677 next if $self->{DIR_TARGET}{$self}{$targdir}++;
678 push @m, qq{
679$targ :: $src
680 $self->{NOECHO}\$(MKPATH) $targdir
681 $self->{NOECHO}\$(EQUALIZE_TIMESTAMP) $src $targ
682};
683 push(@m,qq{
684 -$self->{NOECHO}\$(CHMOD) 755 $targdir
685}) unless $Is_VMS;
686 }
687 join "", @m;
688}
1e44e2bf 689
f1387719 690=item dist (o)
1e44e2bf 691
f1387719 692Defines a lot of macros for distribution support.
1e44e2bf 693
f1387719 694=cut
1e44e2bf 695
f1387719
PP
696sub dist {
697 my($self, %attribs) = @_;
1e44e2bf 698
f1387719
PP
699 my(@m);
700 # VERSION should be sanitised before use as a file name
701 my($version) = $attribs{VERSION} || '$(VERSION)';
702 my($name) = $attribs{NAME} || '$(DISTNAME)';
703 my($tar) = $attribs{TAR} || 'tar'; # eg /usr/bin/gnutar
704 my($tarflags) = $attribs{TARFLAGS} || 'cvf';
705 my($zip) = $attribs{ZIP} || 'zip'; # eg pkzip Yuck!
706 my($zipflags) = $attribs{ZIPFLAGS} || '-r';
707 my($compress) = $attribs{COMPRESS} || 'compress'; # eg gzip
708 my($suffix) = $attribs{SUFFIX} || '.Z'; # eg .gz
709 my($shar) = $attribs{SHAR} || 'shar'; # eg "shar --gzip"
710 my($preop) = $attribs{PREOP} || "$self->{NOECHO}\$(NOOP)"; # eg update MANIFEST
711 my($postop) = $attribs{POSTOP} || "$self->{NOECHO}\$(NOOP)"; # eg remove the distdir
1e44e2bf 712
f1387719
PP
713 my($to_unix) = $attribs{TO_UNIX} || ($Is_OS2
714 ? "$self->{NOECHO}"
68dc0745 715 . '$(TEST_F) tmp.zip && $(RM) tmp.zip;'
f1387719
PP
716 . ' $(ZIP) -ll -mr tmp.zip $(DISTVNAME) && unzip -o tmp.zip && $(RM) tmp.zip'
717 : "$self->{NOECHO}\$(NOOP)");
1e44e2bf 718
f1387719
PP
719 my($ci) = $attribs{CI} || 'ci -u';
720 my($rcs_label)= $attribs{RCS_LABEL}|| 'rcs -Nv$(VERSION_SYM): -q';
721 my($dist_cp) = $attribs{DIST_CP} || 'best';
722 my($dist_default) = $attribs{DIST_DEFAULT} || 'tardist';
1e44e2bf 723
f1387719
PP
724 push @m, "
725DISTVNAME = ${name}-$version
726TAR = $tar
727TARFLAGS = $tarflags
728ZIP = $zip
729ZIPFLAGS = $zipflags
730COMPRESS = $compress
731SUFFIX = $suffix
732SHAR = $shar
733PREOP = $preop
734POSTOP = $postop
735TO_UNIX = $to_unix
736CI = $ci
737RCS_LABEL = $rcs_label
738DIST_CP = $dist_cp
739DIST_DEFAULT = $dist_default
740";
741 join "", @m;
1e44e2bf
PP
742}
743
f1387719 744=item dist_basics (o)
1e44e2bf 745
f1387719 746Defines the targets distclean, distcheck, skipcheck, manifest.
1e44e2bf
PP
747
748=cut
749
f1387719
PP
750sub dist_basics {
751 my($self) = shift;
752 my @m;
753 push @m, q{
754distclean :: realclean distcheck
755};
1e44e2bf 756
f1387719
PP
757 push @m, q{
758distcheck :
68dc0745
PP
759 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=fullcheck \\
760 -e fullcheck
f1387719 761};
1e44e2bf 762
f1387719
PP
763 push @m, q{
764skipcheck :
68dc0745
PP
765 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=skipcheck \\
766 -e skipcheck
f1387719 767};
1e44e2bf 768
f1387719
PP
769 push @m, q{
770manifest :
68dc0745
PP
771 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=mkmanifest \\
772 -e mkmanifest
f1387719
PP
773};
774 join "", @m;
1e44e2bf
PP
775}
776
f1387719 777=item dist_ci (o)
1e44e2bf 778
f1387719 779Defines a check in target for RCS.
1e44e2bf
PP
780
781=cut
782
f1387719 783sub dist_ci {
1e44e2bf 784 my($self) = shift;
f1387719
PP
785 my @m;
786 push @m, q{
787ci :
68dc0745
PP
788 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=maniread \\
789 -e "@all = keys %{ maniread() };" \\
f1387719
PP
790 -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \\
791 -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");'
792};
793 join "", @m;
794}
1e44e2bf 795
f1387719 796=item dist_core (o)
1e44e2bf 797
f1387719 798Defeines the targets dist, tardist, zipdist, uutardist, shdist
1e44e2bf 799
f1387719 800=cut
1e44e2bf 801
f1387719
PP
802sub dist_core {
803 my($self) = shift;
804 my @m;
805 push @m, q{
806dist : $(DIST_DEFAULT)
807 }.$self->{NOECHO}.q{$(PERL) -le 'print "Warning: Makefile possibly out of date with $$vf" if ' \
808 -e '-e ($$vf="$(VERSION_FROM)") and -M $$vf < -M "}.$self->{MAKEFILE}.q{";'
1e44e2bf 809
f1387719 810tardist : $(DISTVNAME).tar$(SUFFIX)
1e44e2bf 811
f1387719 812zipdist : $(DISTVNAME).zip
1e44e2bf 813
f1387719
PP
814$(DISTVNAME).tar$(SUFFIX) : distdir
815 $(PREOP)
816 $(TO_UNIX)
817 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
818 $(RM_RF) $(DISTVNAME)
819 $(COMPRESS) $(DISTVNAME).tar
820 $(POSTOP)
1e44e2bf 821
f1387719
PP
822$(DISTVNAME).zip : distdir
823 $(PREOP)
824 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
825 $(RM_RF) $(DISTVNAME)
826 $(POSTOP)
1e44e2bf 827
f1387719
PP
828uutardist : $(DISTVNAME).tar$(SUFFIX)
829 uuencode $(DISTVNAME).tar$(SUFFIX) \\
830 $(DISTVNAME).tar$(SUFFIX) > \\
831 $(DISTVNAME).tar$(SUFFIX)_uu
f4ae0f5e 832
f1387719
PP
833shdist : distdir
834 $(PREOP)
835 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
836 $(RM_RF) $(DISTVNAME)
837 $(POSTOP)
838};
839 join "", @m;
f4ae0f5e
PP
840}
841
f1387719 842=item dist_dir (o)
f4ae0f5e 843
f1387719
PP
844Defines the scratch directory target that will hold the distribution
845before tar-ing (or shar-ing).
1e44e2bf
PP
846
847=cut
848
f1387719
PP
849sub dist_dir {
850 my($self) = shift;
851 my @m;
852 push @m, q{
853distdir :
854 $(RM_RF) $(DISTVNAME)
855 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=manicopy,maniread \\
68dc0745 856 -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
f1387719
PP
857};
858 join "", @m;
1e44e2bf
PP
859}
860
f1387719 861=item dist_test (o)
1e44e2bf 862
f1387719
PP
863Defines a target that produces the distribution in the
864scratchdirectory, and runs 'perl Makefile.PL; make ;make test' in that
865subdirectory.
1e44e2bf
PP
866
867=cut
868
f1387719 869sub dist_test {
1e44e2bf 870 my($self) = shift;
f1387719
PP
871 my @m;
872 push @m, q{
873disttest : distdir
874 cd $(DISTVNAME) && $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL
875 cd $(DISTVNAME) && $(MAKE)
876 cd $(DISTVNAME) && $(MAKE) test
877};
878 join "", @m;
1e44e2bf
PP
879}
880
f1387719 881=item dlsyms (o)
1e44e2bf 882
f1387719
PP
883Used by AIX and VMS to define DL_FUNCS and DL_VARS and write the *.exp
884files.
1e44e2bf
PP
885
886=cut
887
f1387719
PP
888sub dlsyms {
889 my($self,%attribs) = @_;
1e44e2bf 890
f1387719 891 return '' unless ($^O eq 'aix' && $self->needs_linking() );
1e44e2bf 892
f1387719
PP
893 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
894 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
895 my(@m);
1e44e2bf 896
f1387719
PP
897 push(@m,"
898dynamic :: $self->{BASEEXT}.exp
1e44e2bf 899
f1387719 900") unless $self->{SKIPHASH}{'dynamic'}; # dynamic and static are subs, so...
1e44e2bf 901
f1387719
PP
902 push(@m,"
903static :: $self->{BASEEXT}.exp
1e44e2bf 904
f1387719 905") unless $self->{SKIPHASH}{'static'}; # we avoid a warning if we tick them
1e44e2bf 906
f1387719
PP
907 push(@m,"
908$self->{BASEEXT}.exp: Makefile.PL
909",' $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\
910 Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ',
911 neatvalue($funcs),', "DL_VARS" => ', neatvalue($vars), ');\'
912');
1e44e2bf 913
f1387719
PP
914 join('',@m);
915}
1e44e2bf 916
f1387719 917=item dynamic (o)
1e44e2bf 918
f1387719 919Defines the dynamic target.
1e44e2bf 920
f1387719 921=cut
1e44e2bf 922
f1387719
PP
923sub dynamic {
924# --- Dynamic Loading Sections ---
1e44e2bf 925
f1387719
PP
926 my($self) = shift;
927 '
928## $(INST_PM) has been moved to the all: target.
929## It remains here for awhile to allow for old usage: "make dynamic"
930#dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM)
931dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT)
932 '.$self->{NOECHO}.'$(NOOP)
933';
934}
1e44e2bf 935
f1387719 936=item dynamic_bs (o)
1e44e2bf 937
f1387719 938Defines targets for bootstrap files.
1e44e2bf 939
f1387719 940=cut
1e44e2bf 941
f1387719
PP
942sub dynamic_bs {
943 my($self, %attribs) = @_;
944 return '
945BOOTSTRAP =
946' unless $self->has_link_code();
1e44e2bf 947
f1387719
PP
948 return '
949BOOTSTRAP = '."$self->{BASEEXT}.bs".'
1e44e2bf 950
f1387719
PP
951# As Mkbootstrap might not write a file (if none is required)
952# we use touch to prevent make continually trying to remake it.
953# The DynaLoader only reads a non-empty file.
954$(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)/.exists
955 '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
956 '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
68dc0745
PP
957 -MExtUtils::Mkbootstrap \
958 -e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
f1387719
PP
959 '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP)
960 $(CHMOD) 644 $@
1e44e2bf 961
f1387719
PP
962$(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists
963 '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT)
964 -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT)
965 $(CHMOD) 644 $@
1e44e2bf 966';
f1387719 967}
1e44e2bf 968
f1387719 969=item dynamic_lib (o)
1e44e2bf 970
f1387719
PP
971Defines how to produce the *.so (or equivalent) files.
972
973=cut
974
975sub dynamic_lib {
976 my($self, %attribs) = @_;
977 return '' unless $self->needs_linking(); #might be because of a subdir
1e44e2bf 978
f1387719 979 return '' unless $self->has_link_code;
f4ae0f5e 980
f1387719
PP
981 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
982 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
983 my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
984 my($ldfrom) = '$(LDFROM)';
985 $armaybe = 'ar' if ($^O eq 'dec_osf' and $armaybe eq ':');
986 my(@m);
987 push(@m,'
988# This section creates the dynamically loadable $(INST_DYNAMIC)
989# from $(OBJECT) and possibly $(MYEXTLIB).
990ARMAYBE = '.$armaybe.'
991OTHERLDFLAGS = '.$otherldflags.'
992INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
f4ae0f5e 993
f1387719
PP
994$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
995');
996 if ($armaybe ne ':'){
997 $ldfrom = 'tmp$(LIB_EXT)';
998 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
999 push(@m,' $(RANLIB) '."$ldfrom\n");
1000 }
1001 $ldfrom = "-all $ldfrom -none" if ($^O eq 'dec_osf');
ff0cee69
PP
1002
1003 # Brain dead solaris linker does not use LD_RUN_PATH?
1004 # This fixes dynamic extensions which need shared libs
1005 my $ldrun = '';
1006 $ldrun = join ' ', map "-R$_", split /:/, $self->{LD_RUN_PATH}
1007 if ($^O eq 'solaris');
1008
1009 push(@m,' LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ '.$ldrun.' $(LDDLFLAGS) '.$ldfrom.
042ade60 1010 ' $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) $(EXPORT_LIST)');
f1387719
PP
1011 push @m, '
1012 $(CHMOD) 755 $@
1013';
1e44e2bf 1014
f1387719 1015 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
1e44e2bf
PP
1016 join('',@m);
1017}
1018
f1387719 1019=item exescan
1e44e2bf 1020
f1387719 1021Deprecated method. Use libscan instead.
1e44e2bf
PP
1022
1023=cut
1024
f1387719
PP
1025sub exescan {
1026 my($self,$path) = @_;
1027 $path;
1e44e2bf
PP
1028}
1029
f1387719 1030=item extliblist
1e44e2bf 1031
f1387719
PP
1032Called by init_others, and calls ext ExtUtils::Liblist. See
1033L<ExtUtils::Liblist> for details.
1e44e2bf
PP
1034
1035=cut
1036
f1387719
PP
1037sub extliblist {
1038 my($self,$libs) = @_;
1039 require ExtUtils::Liblist;
1040 $self->ext($libs, $Verbose);
1041}
f4ae0f5e 1042
f1387719 1043=item file_name_is_absolute
f4ae0f5e 1044
1fef88e7 1045Takes as argument a path and returns true, if it is an absolute path.
1e44e2bf 1046
f1387719 1047=cut
1e44e2bf 1048
f1387719
PP
1049sub file_name_is_absolute {
1050 my($self,$file) = @_;
1051 $file =~ m:^/: ;
1052}
1e44e2bf 1053
f1387719 1054=item find_perl
1e44e2bf 1055
f1387719 1056Finds the executables PERL and FULLPERL
1e44e2bf 1057
f1387719 1058=cut
1e44e2bf 1059
f1387719
PP
1060sub find_perl {
1061 my($self, $ver, $names, $dirs, $trace) = @_;
1062 my($name, $dir);
1063 if ($trace >= 2){
1064 print "Looking for perl $ver by these names:
1065@$names
1066in these dirs:
1067@$dirs
1068";
1069 }
1070 foreach $dir (@$dirs){
1071 next unless defined $dir; # $self->{PERL_SRC} may be undefined
1072 foreach $name (@$names){
a1f8e286 1073 my ($abs, $val);
f1387719
PP
1074 if ($self->file_name_is_absolute($name)) { # /foo/bar
1075 $abs = $name;
1076 } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # foo
1077 $abs = $self->catfile($dir, $name);
1078 } else { # foo/bar
1079 $abs = $self->canonpath($self->catfile($self->curdir, $name));
1080 }
1081 print "Checking $abs\n" if ($trace >= 2);
1082 next unless $self->maybe_command($abs);
1083 print "Executing $abs\n" if ($trace >= 2);
a1f8e286
IZ
1084 $val = `$abs -e 'require $ver; print "VER_OK\n" ' 2>&1`;
1085 if ($val =~ /VER_OK/) {
f1387719
PP
1086 print "Using PERL=$abs\n" if $trace;
1087 return $abs;
a1f8e286
IZ
1088 } elsif ($trace >= 2) {
1089 print "Result: `$val'\n";
1e44e2bf
PP
1090 }
1091 }
1e44e2bf 1092 }
f1387719
PP
1093 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
1094 0; # false and not empty
1095}
1e44e2bf 1096
bab2b58e
AK
1097=back
1098
f1387719 1099=head2 Methods to actually produce chunks of text for the Makefile
1e44e2bf 1100
bab2b58e
AK
1101The methods here are called for each MakeMaker object in the order
1102specified by @ExtUtils::MakeMaker::MM_Sections.
1103
1104=over 2
f4ae0f5e 1105
f1387719
PP
1106=item force (o)
1107
1108Just writes FORCE:
1109
1110=cut
1e44e2bf 1111
f1387719
PP
1112sub force {
1113 my($self) = shift;
1114 '# Phony target to force checking subdirectories.
1115FORCE:
3e3baf6d 1116 '.$self->{NOECHO}.'$(NOOP)
f1387719 1117';
1e44e2bf
PP
1118}
1119
f1387719 1120=item guess_name
1e44e2bf 1121
f1387719
PP
1122Guess the name of this package by examining the working directory's
1123name. MakeMaker calls this only if the developer has not supplied a
1124NAME attribute.
1e44e2bf 1125
f1387719 1126=cut
f4ae0f5e 1127
f1387719
PP
1128# ';
1129
1130sub guess_name {
1131 my($self) = @_;
1132 use Cwd 'cwd';
1133 my $name = basename(cwd());
1134 $name =~ s|[\-_][\d\.\-]+$||; # this is new with MM 5.00, we
1135 # strip minus or underline
1136 # followed by a float or some such
1137 print "Warning: Guessing NAME [$name] from current directory name.\n";
1138 $name;
1139}
1140
1141=item has_link_code
1142
1143Returns true if C, XS, MYEXTLIB or similar objects exist within this
1144object that need a compiler. Does not descend into subdirectories as
1145needs_linking() does.
f4ae0f5e
PP
1146
1147=cut
1148
f1387719
PP
1149sub has_link_code {
1150 my($self) = shift;
1151 return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
1152 if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
1153 $self->{HAS_LINK_CODE} = 1;
1154 return 1;
f4ae0f5e 1155 }
f1387719 1156 return $self->{HAS_LINK_CODE} = 0;
f4ae0f5e
PP
1157}
1158
f1387719 1159=item init_dirscan
f4ae0f5e 1160
f1387719
PP
1161Initializes DIR, XS, PM, C, O_FILES, H, PL_FILES, MAN*PODS, EXE_FILES.
1162
1163=cut
1164
1165sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
1166 my($self) = @_;
1167 my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods);
1168 local(%pm); #the sub in find() has to see this hash
1169 $ignore{'test.pl'} = 1;
1170 $ignore{'makefile.pl'} = 1 if $Is_VMS;
1171 foreach $name ($self->lsdir($self->curdir)){
4ecf31dc 1172 next if $name =~ /\#/;
f1387719
PP
1173 next if $name eq $self->curdir or $name eq $self->updir or $ignore{$name};
1174 next unless $self->libscan($name);
1175 if (-d $name){
760ac839 1176 next if -l $name; # We do not support symlinks at all
f1387719
PP
1177 $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL"));
1178 } elsif ($name =~ /\.xs$/){
1179 my($c); ($c = $name) =~ s/\.xs$/.c/;
1180 $xs{$name} = $c;
1181 $c{$c} = 1;
1182 } elsif ($name =~ /\.c(pp|xx|c)?$/i){ # .c .C .cpp .cxx .cc
1183 $c{$name} = 1
1184 unless $name =~ m/perlmain\.c/; # See MAP_TARGET
1185 } elsif ($name =~ /\.h$/i){
1186 $h{$name} = 1;
1187 } elsif ($name =~ /\.(p[ml]|pod)$/){
1188 $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name);
1189 } elsif ($name =~ /\.PL$/ && $name ne "Makefile.PL") {
1190 ($pl_files{$name} = $name) =~ s/\.PL$// ;
1191 } elsif ($Is_VMS && $name =~ /\.pl$/ && $name ne 'makefile.pl' &&
1192 $name ne 'test.pl') { # case-insensitive filesystem
1193 ($pl_files{$name} = $name) =~ s/\.pl$// ;
1194 }
1195 }
f4ae0f5e 1196
f1387719
PP
1197 # Some larger extensions often wish to install a number of *.pm/pl
1198 # files into the library in various locations.
f4ae0f5e 1199
f1387719
PP
1200 # The attribute PMLIBDIRS holds an array reference which lists
1201 # subdirectories which we should search for library files to
1202 # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
1203 # recursively search through the named directories (skipping any
1204 # which don't exist or contain Makefile.PL files).
f4ae0f5e 1205
f1387719
PP
1206 # For each *.pm or *.pl file found $self->libscan() is called with
1207 # the default installation path in $_[1]. The return value of
1208 # libscan defines the actual installation location. The default
1209 # libscan function simply returns the path. The file is skipped
1210 # if libscan returns false.
f4ae0f5e 1211
f1387719
PP
1212 # The default installation location passed to libscan in $_[1] is:
1213 #
1214 # ./*.pm => $(INST_LIBDIR)/*.pm
1215 # ./xyz/... => $(INST_LIBDIR)/xyz/...
1216 # ./lib/... => $(INST_LIB)/...
1217 #
1218 # In this way the 'lib' directory is seen as the root of the actual
1219 # perl library whereas the others are relative to INST_LIBDIR
1220 # (which includes PARENT_NAME). This is a subtle distinction but one
1221 # that's important for nested modules.
1e44e2bf 1222
f1387719
PP
1223 $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}]
1224 unless $self->{PMLIBDIRS};
1e44e2bf 1225
f1387719 1226 #only existing directories that aren't in $dir are allowed
1e44e2bf 1227
f1387719
PP
1228 # Avoid $_ wherever possible:
1229 # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
1230 my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
1231 my ($pmlibdir);
1232 @{$self->{PMLIBDIRS}} = ();
1233 foreach $pmlibdir (@pmlibdirs) {
1234 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
1e44e2bf 1235 }
1e44e2bf 1236
f1387719
PP
1237 if (@{$self->{PMLIBDIRS}}){
1238 print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
1239 if ($Verbose >= 2);
1240 require File::Find;
1241 File::Find::find(sub {
1242 if (-d $_){
1243 if ($_ eq "CVS" || $_ eq "RCS"){
1244 $File::Find::prune = 1;
1245 }
1246 return;
1247 }
4ecf31dc 1248 return if /\#/;
f1387719
PP
1249 my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)');
1250 my($striplibpath,$striplibname);
93f9cb4b 1251 $prefix = '$(INST_LIB)' if (($striplibpath = $path) =~ s:^(\W*)lib\W:$1:i);
f1387719
PP
1252 ($striplibname,$striplibpath) = fileparse($striplibpath);
1253 my($inst) = $self->catfile($prefix,$striplibpath,$striplibname);
1254 local($_) = $inst; # for backwards compatibility
1255 $inst = $self->libscan($inst);
1256 print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
1257 return unless $inst;
1258 $pm{$path} = $inst;
1259 }, @{$self->{PMLIBDIRS}});
1260 }
1e44e2bf 1261
f1387719
PP
1262 $self->{DIR} = [sort keys %dir] unless $self->{DIR};
1263 $self->{XS} = \%xs unless $self->{XS};
1264 $self->{PM} = \%pm unless $self->{PM};
1265 $self->{C} = [sort keys %c] unless $self->{C};
1266 my(@o_files) = @{$self->{C}};
1267 $self->{O_FILES} = [grep s/\.c(pp|xx|c)?$/$self->{OBJ_EXT}/i, @o_files] ;
1268 $self->{H} = [sort keys %h] unless $self->{H};
1269 $self->{PL_FILES} = \%pl_files unless $self->{PL_FILES};
1e44e2bf 1270
f1387719
PP
1271 # Set up names of manual pages to generate from pods
1272 if ($self->{MAN1PODS}) {
1273 } elsif ( $self->{INST_MAN1DIR} =~ /^(none|\s*)$/ ) {
1274 $self->{MAN1PODS} = {};
1275 } else {
1276 my %manifypods = ();
1277 if ( exists $self->{EXE_FILES} ) {
1278 foreach $name (@{$self->{EXE_FILES}}) {
1279# use FileHandle ();
1280# my $fh = new FileHandle;
1281 local *FH;
1282 my($ispod)=0;
1283 # one day test, if $/ can be set to '' safely (is the bug fixed that was in 5.001m?)
1284# if ($fh->open("<$name")) {
1285 if (open(FH,"<$name")) {
1286# while (<$fh>) {
1287 while (<FH>) {
1288 if (/^=head1\s+\w+/) {
1289 $ispod=1;
1290 last;
1291 }
1292 }
1293# $fh->close;
1294 close FH;
1295 } else {
1296 # If it doesn't exist yet, we assume, it has pods in it
1297 $ispod = 1;
1e44e2bf 1298 }
f1387719
PP
1299 if( $ispod ) {
1300 $manifypods{$name} = $self->catfile('$(INST_MAN1DIR)',basename($name).'.$(MAN1EXT)');
1e44e2bf 1301 }
f1387719 1302 }
1e44e2bf 1303 }
f1387719 1304 $self->{MAN1PODS} = \%manifypods;
1e44e2bf 1305 }
f1387719
PP
1306 if ($self->{MAN3PODS}) {
1307 } elsif ( $self->{INST_MAN3DIR} =~ /^(none|\s*)$/ ) {
1308 $self->{MAN3PODS} = {};
1e44e2bf 1309 } else {
f1387719
PP
1310 my %manifypods = (); # we collect the keys first, i.e. the files
1311 # we have to convert to pod
1312 foreach $name (keys %{$self->{PM}}) {
1313 if ($name =~ /\.pod$/ ) {
1314 $manifypods{$name} = $self->{PM}{$name};
1315 } elsif ($name =~ /\.p[ml]$/ ) {
1316# use FileHandle ();
1317# my $fh = new FileHandle;
1318 local *FH;
1319 my($ispod)=0;
1320# $fh->open("<$name");
1321 if (open(FH,"<$name")) {
1322 # while (<$fh>) {
1323 while (<FH>) {
1324 if (/^=head1\s+\w+/) {
1325 $ispod=1;
1326 last;
1327 }
1328 }
1329 # $fh->close;
1330 close FH;
1331 } else {
1332 $ispod = 1;
1333 }
1334 if( $ispod ) {
1335 $manifypods{$name} = $self->{PM}{$name};
1336 }
1337 }
1338 }
1339
1340 # Remove "Configure.pm" and similar, if it's not the only pod listed
1341 # To force inclusion, just name it "Configure.pod", or override MAN3PODS
1342 foreach $name (keys %manifypods) {
1343 if ($name =~ /(config|setup).*\.pm/i) {
1344 delete $manifypods{$name};
1345 next;
1346 }
1347 my($manpagename) = $name;
1348 unless ($manpagename =~ s!^\W*lib\W+!!) { # everything below lib is ok
1349 $manpagename = $self->catfile(split(/::/,$self->{PARENT_NAME}),$manpagename);
1350 }
1351 $manpagename =~ s/\.p(od|m|l)$//;
1352 $manpagename = $self->replace_manpage_separator($manpagename);
1353 $manifypods{$name} = $self->catfile("\$(INST_MAN3DIR)","$manpagename.\$(MAN3EXT)");
1e44e2bf 1354 }
f1387719 1355 $self->{MAN3PODS} = \%manifypods;
1e44e2bf 1356 }
f1387719 1357}
1e44e2bf 1358
f1387719 1359=item init_main
1e44e2bf 1360
f1387719
PP
1361Initializes NAME, FULLEXT, BASEEXT, PARENT_NAME, DLBASE, PERL_SRC,
1362PERL_LIB, PERL_ARCHLIB, PERL_INC, INSTALLDIRS, INST_*, INSTALL*,
8cc95fdb 1363PREFIX, CONFIG, AR, AR_STATIC_ARGS, LD, OBJ_EXT, LIB_EXT, EXE_EXT, MAP_TARGET,
f1387719 1364LIBPERL_A, VERSION_FROM, VERSION, DISTNAME, VERSION_SYM.
f4ae0f5e 1365
f1387719 1366=cut
1e44e2bf 1367
f1387719
PP
1368sub init_main {
1369 my($self) = @_;
1e44e2bf 1370
f1387719 1371 # --- Initialize Module Name and Paths
1e44e2bf 1372
f1387719
PP
1373 # NAME = Foo::Bar::Oracle
1374 # FULLEXT = Foo/Bar/Oracle
1375 # BASEEXT = Oracle
1376 # ROOTEXT = Directory part of FULLEXT with leading /. !!! Deprecated from MM 5.32 !!!
1377 # PARENT_NAME = Foo::Bar
1378### Only UNIX:
1379### ($self->{FULLEXT} =
1380### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
1381 $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME});
1e44e2bf 1382
1e44e2bf 1383
f1387719 1384 # Copied from DynaLoader:
1e44e2bf 1385
f1387719
PP
1386 my(@modparts) = split(/::/,$self->{NAME});
1387 my($modfname) = $modparts[-1];
1e44e2bf 1388
f1387719
PP
1389 # Some systems have restrictions on files names for DLL's etc.
1390 # mod2fname returns appropriate file base name (typically truncated)
1391 # It may also edit @modparts if required.
1392 if (defined &DynaLoader::mod2fname) {
1393 $modfname = &DynaLoader::mod2fname(\@modparts);
bab2b58e 1394 }
1e44e2bf 1395
f1387719
PP
1396 ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!([\w:]+::)?(\w+)$! ;
1397
760ac839 1398 if (defined &DynaLoader::mod2fname) {
f1387719
PP
1399 # As of 5.001m, dl_os2 appends '_'
1400 $self->{DLBASE} = $modfname;
1401 } else {
1402 $self->{DLBASE} = '$(BASEEXT)';
1403 }
1404
1e44e2bf 1405
f1387719
PP
1406 ### ROOTEXT deprecated from MM 5.32
1407### ($self->{ROOTEXT} =
1408### $self->{FULLEXT}) =~ s#/?\Q$self->{BASEEXT}\E$## ; #eg. /BSD/Foo
1409### $self->{ROOTEXT} = ($Is_VMS ? '' : '/') . $self->{ROOTEXT} if $self->{ROOTEXT};
1e44e2bf 1410
1e44e2bf 1411
f1387719 1412 # --- Initialize PERL_LIB, INST_LIB, PERL_SRC
1e44e2bf 1413
f1387719
PP
1414 # *Real* information: where did we get these two from? ...
1415 my $inc_config_dir = dirname($INC{'Config.pm'});
1416 my $inc_carp_dir = dirname($INC{'Carp.pm'});
1e44e2bf 1417
f1387719
PP
1418 unless ($self->{PERL_SRC}){
1419 my($dir);
1420 foreach $dir ($self->updir(),$self->catdir($self->updir(),$self->updir()),$self->catdir($self->updir(),$self->updir(),$self->updir())){
1421 if (
1422 -f $self->catfile($dir,"config.sh")
1423 &&
1424 -f $self->catfile($dir,"perl.h")
1425 &&
1426 -f $self->catfile($dir,"lib","Exporter.pm")
1427 ) {
1428 $self->{PERL_SRC}=$dir ;
1429 last;
1430 }
1431 }
1432 }
1433 if ($self->{PERL_SRC}){
1434 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
1435 $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
137443ea 1436 $self->{PERL_INC} = ($Is_Win32) ? $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
1e44e2bf 1437
137443ea 1438 # catch a situation that has occurred a few times in the past:
bab2b58e
AK
1439 unless (
1440 -s $self->catfile($self->{PERL_SRC},'cflags')
1441 or
1442 $Is_VMS
1443 &&
1444 -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')
1445 or
1446 $Is_Mac
137443ea
PP
1447 or
1448 $Is_Win32
bab2b58e
AK
1449 ){
1450 warn qq{
f1387719
PP
1451You cannot build extensions below the perl source tree after executing
1452a 'make clean' in the perl source tree.
1e44e2bf 1453
f1387719
PP
1454To rebuild extensions distributed with the perl source you should
1455simply Configure (to include those extensions) and then build perl as
1456normal. After installing perl the source tree can be deleted. It is
1457not needed for building extensions by running 'perl Makefile.PL'
1458usually without extra arguments.
1e44e2bf 1459
f1387719
PP
1460It is recommended that you unpack and build additional extensions away
1461from the perl source tree.
bab2b58e
AK
1462};
1463 }
f1387719
PP
1464 } else {
1465 # we should also consider $ENV{PERL5LIB} here
1466 $self->{PERL_LIB} ||= $Config::Config{privlibexp};
1467 $self->{PERL_ARCHLIB} ||= $Config::Config{archlibexp};
1468 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
1469 my $perl_h;
bab2b58e
AK
1470 unless (-f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))){
1471 die qq{
f1387719 1472Error: Unable to locate installed Perl libraries or Perl source code.
f4ae0f5e 1473
f1387719 1474It is recommended that you install perl in a standard location before
bab2b58e
AK
1475building extensions. Some precompiled versions of perl do not contain
1476these header files, so you cannot build extensions. In such a case,
1477please build and install your perl from a fresh perl distribution. It
1478usually solves this kind of problem.
f4ae0f5e 1479
bab2b58e
AK
1480\(You get this message, because MakeMaker could not find "$perl_h"\)
1481};
1482 }
f1387719
PP
1483# print STDOUT "Using header files found in $self->{PERL_INC}\n"
1484# if $Verbose && $self->needs_linking();
1e44e2bf 1485
f1387719 1486 }
1e44e2bf 1487
f1387719
PP
1488 # We get SITELIBEXP and SITEARCHEXP directly via
1489 # Get_from_Config. When we are running standard modules, these
1490 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
1491 # set it to "site". I prefer that INSTALLDIRS be set from outside
1492 # MakeMaker.
1493 $self->{INSTALLDIRS} ||= "site";
1e44e2bf 1494
f1387719
PP
1495 # INST_LIB typically pre-set if building an extension after
1496 # perl has been built and installed. Setting INST_LIB allows
1497 # you to build directly into, say $Config::Config{privlibexp}.
1498 unless ($self->{INST_LIB}){
1e44e2bf 1499
1e44e2bf 1500
f1387719 1501 ##### XXXXX We have to change this nonsense
1e44e2bf 1502
f1387719
PP
1503 if (defined $self->{PERL_SRC} and $self->{INSTALLDIRS} eq "perl") {
1504 $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
1505 } else {
1506 $self->{INST_LIB} = $self->catdir($self->curdir,"blib","lib");
1507 }
1508 }
1509 $self->{INST_ARCHLIB} ||= $self->catdir($self->curdir,"blib","arch");
1510 $self->{INST_BIN} ||= $self->catdir($self->curdir,'blib','bin');
1e44e2bf 1511
93f9cb4b
PP
1512 # We need to set up INST_LIBDIR before init_libscan() for VMS
1513 my @parentdir = split(/::/, $self->{PARENT_NAME});
1514 $self->{INST_LIBDIR} = $self->catdir('$(INST_LIB)',@parentdir);
1515 $self->{INST_ARCHLIBDIR} = $self->catdir('$(INST_ARCHLIB)',@parentdir);
1516 $self->{INST_AUTODIR} = $self->catdir('$(INST_LIB)','auto','$(FULLEXT)');
1517 $self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)');
1518
f1387719
PP
1519 # INST_EXE is deprecated, should go away March '97
1520 $self->{INST_EXE} ||= $self->catdir($self->curdir,'blib','script');
1521 $self->{INST_SCRIPT} ||= $self->catdir($self->curdir,'blib','script');
1e44e2bf 1522
f1387719
PP
1523 # The user who requests an installation directory explicitly
1524 # should not have to tell us a architecture installation directory
bab2b58e 1525 # as well. We look if a directory exists that is named after the
f1387719
PP
1526 # architecture. If not we take it as a sign that it should be the
1527 # same as the requested installation directory. Otherwise we take
1528 # the found one.
1529 # We do the same thing twice: for privlib/archlib and for sitelib/sitearch
1530 my($libpair);
1531 for $libpair ({l=>"privlib", a=>"archlib"}, {l=>"sitelib", a=>"sitearch"}) {
1532 my $lib = "install$libpair->{l}";
1533 my $Lib = uc $lib;
1534 my $Arch = uc "install$libpair->{a}";
1535 if( $self->{$Lib} && ! $self->{$Arch} ){
1536 my($ilib) = $Config{$lib};
1537 $ilib = VMS::Filespec::unixify($ilib) if $Is_VMS;
1e44e2bf 1538
f1387719
PP
1539 $self->prefixify($Arch,$ilib,$self->{$Lib});
1540
1541 unless (-d $self->{$Arch}) {
1542 print STDOUT "Directory $self->{$Arch} not found, thusly\n" if $Verbose;
1543 $self->{$Arch} = $self->{$Lib};
1544 }
1545 print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
1546 }
1e44e2bf 1547 }
f4ae0f5e 1548
f1387719
PP
1549 # we have to look at the relation between $Config{prefix} and the
1550 # requested values. We're going to set the $Config{prefix} part of
1551 # all the installation path variables to literally $(PREFIX), so
1552 # the user can still say make PREFIX=foo
bab2b58e 1553 my($configure_prefix) = $Config{'prefix'};
8cc95fdb 1554 $configure_prefix = VMS::Filespec::unixify($configure_prefix) if $Is_VMS;
bab2b58e
AK
1555 $self->{PREFIX} ||= $configure_prefix;
1556
1557
1558 my($install_variable,$search_prefix,$replace_prefix);
1559
1560 # The rule, taken from Configure, is that if prefix contains perl,
1561 # we shape the tree
1562 # perlprefix/lib/ INSTALLPRIVLIB
1563 # perlprefix/lib/pod/
1564 # perlprefix/lib/site_perl/ INSTALLSITELIB
1565 # perlprefix/bin/ INSTALLBIN
1566 # perlprefix/man/ INSTALLMAN1DIR
1567 # else
1568 # prefix/lib/perl5/ INSTALLPRIVLIB
1569 # prefix/lib/perl5/pod/
1570 # prefix/lib/perl5/site_perl/ INSTALLSITELIB
1571 # prefix/bin/ INSTALLBIN
1572 # prefix/lib/perl5/man/ INSTALLMAN1DIR
1573
1574 $replace_prefix = qq[\$\(PREFIX\)];
1575 for $install_variable (qw/
1576 INSTALLBIN
1577 INSTALLSCRIPT
1578 /) {
1579 $self->prefixify($install_variable,$configure_prefix,$replace_prefix);
1580 }
1581 $search_prefix = $configure_prefix =~ /perl/ ?
1582 $self->catdir($configure_prefix,"lib") :
1583 $self->catdir($configure_prefix,"lib","perl5");
1584 if ($self->{LIB}) {
1585 $self->{INSTALLPRIVLIB} = $self->{INSTALLSITELIB} = $self->{LIB};
1586 $self->{INSTALLARCHLIB} = $self->{INSTALLSITEARCH} =
1587 $self->catdir($self->{LIB},$Config{'archname'});
1588 } else {
1589 $replace_prefix = $self->{PREFIX} =~ /perl/ ?
1590 $self->catdir(qq[\$\(PREFIX\)],"lib") :
1591 $self->catdir(qq[\$\(PREFIX\)],"lib","perl5");
1592 for $install_variable (qw/
1593 INSTALLPRIVLIB
1594 INSTALLARCHLIB
1595 INSTALLSITELIB
1596 INSTALLSITEARCH
1597 /) {
1598 $self->prefixify($install_variable,$search_prefix,$replace_prefix);
1599 }
f1387719 1600 }
bab2b58e
AK
1601 $search_prefix = $configure_prefix =~ /perl/ ?
1602 $self->catdir($configure_prefix,"man") :
1603 $self->catdir($configure_prefix,"lib","perl5","man");
1604 $replace_prefix = $self->{PREFIX} =~ /perl/ ?
1605 $self->catdir(qq[\$\(PREFIX\)],"man") :
1606 $self->catdir(qq[\$\(PREFIX\)],"lib","perl5","man");
f1387719 1607 for $install_variable (qw/
bab2b58e
AK
1608 INSTALLMAN1DIR
1609 INSTALLMAN3DIR
f1387719 1610 /) {
bab2b58e 1611 $self->prefixify($install_variable,$search_prefix,$replace_prefix);
f1387719 1612 }
1e44e2bf 1613
f1387719
PP
1614 # Now we head at the manpages. Maybe they DO NOT want manpages
1615 # installed
1616 $self->{INSTALLMAN1DIR} = $Config::Config{installman1dir}
1617 unless defined $self->{INSTALLMAN1DIR};
1618 unless (defined $self->{INST_MAN1DIR}){
1619 if ($self->{INSTALLMAN1DIR} =~ /^(none|\s*)$/){
1620 $self->{INST_MAN1DIR} = $self->{INSTALLMAN1DIR};
1621 } else {
1622 $self->{INST_MAN1DIR} = $self->catdir($self->curdir,'blib','man1');
1623 }
1624 }
1625 $self->{MAN1EXT} ||= $Config::Config{man1ext};
1e44e2bf 1626
f1387719
PP
1627 $self->{INSTALLMAN3DIR} = $Config::Config{installman3dir}
1628 unless defined $self->{INSTALLMAN3DIR};
1629 unless (defined $self->{INST_MAN3DIR}){
1630 if ($self->{INSTALLMAN3DIR} =~ /^(none|\s*)$/){
1631 $self->{INST_MAN3DIR} = $self->{INSTALLMAN3DIR};
1632 } else {
1633 $self->{INST_MAN3DIR} = $self->catdir($self->curdir,'blib','man3');
1634 }
1e44e2bf 1635 }
f1387719
PP
1636 $self->{MAN3EXT} ||= $Config::Config{man3ext};
1637
1638
1639 # Get some stuff out of %Config if we haven't yet done so
1640 print STDOUT "CONFIG must be an array ref\n"
1641 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
1642 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
1643 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
1644 push(@{$self->{CONFIG}}, 'shellflags') if $Config::Config{shellflags};
1645 my(%once_only,$m);
1646 foreach $m (@{$self->{CONFIG}}){
1647 next if $once_only{$m};
1648 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
1649 unless exists $Config::Config{$m};
1650 $self->{uc $m} ||= $Config::Config{$m};
1651 $once_only{$m} = 1;
1e44e2bf 1652 }
1e44e2bf 1653
f1387719
PP
1654# This is too dangerous:
1655# if ($^O eq "next") {
1656# $self->{AR} = "libtool";
1657# $self->{AR_STATIC_ARGS} = "-o";
1658# }
1659# But I leave it as a placeholder
1e44e2bf 1660
f1387719 1661 $self->{AR_STATIC_ARGS} ||= "cr";
1e44e2bf 1662
f1387719
PP
1663 # These should never be needed
1664 $self->{LD} ||= 'ld';
1665 $self->{OBJ_EXT} ||= '.o';
1666 $self->{LIB_EXT} ||= '.a';
1667
1668 $self->{MAP_TARGET} ||= "perl";
1669
1670 $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
1671
1672 # make a simple check if we find Exporter
1673 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
1674 (Exporter.pm not found)"
1675 unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") ||
1676 $self->{NAME} eq "ExtUtils::MakeMaker";
1e44e2bf 1677
f1387719
PP
1678 # Determine VERSION and VERSION_FROM
1679 ($self->{DISTNAME}=$self->{NAME}) =~ s#(::)#-#g unless $self->{DISTNAME};
1680 if ($self->{VERSION_FROM}){
1681 $self->{VERSION} = $self->parse_version($self->{VERSION_FROM}) or
1682 Carp::carp "WARNING: Setting VERSION via file '$self->{VERSION_FROM}' failed\n"
1e44e2bf 1683 }
f1387719
PP
1684
1685 # strip blanks
1686 if ($self->{VERSION}) {
1687 $self->{VERSION} =~ s/^\s+//;
1688 $self->{VERSION} =~ s/\s+$//;
1e44e2bf 1689 }
1e44e2bf 1690
f1387719
PP
1691 $self->{VERSION} ||= "0.10";
1692 ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g;
1e44e2bf
PP
1693
1694
f1387719
PP
1695 # Graham Barr and Paul Marquess had some ideas how to ensure
1696 # version compatibility between the *.pm file and the
1697 # corresponding *.xs file. The bottomline was, that we need an
1698 # XS_VERSION macro that defaults to VERSION:
1699 $self->{XS_VERSION} ||= $self->{VERSION};
1e44e2bf 1700
f1387719
PP
1701 # --- Initialize Perl Binary Locations
1702
1703 # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL'
1704 # will be working versions of perl 5. miniperl has priority over perl
1705 # for PERL to ensure that $(PERL) is usable while building ./ext/*
1706 my ($component,@defpath);
1707 foreach $component ($self->{PERL_SRC}, $self->path(), $Config::Config{binexp}) {
1708 push @defpath, $component if defined $component;
1e44e2bf 1709 }
ff0cee69 1710 $self->{PERL} ||=
f1387719 1711 $self->find_perl(5.0, [ $^X, 'miniperl','perl','perl5',"perl$]" ],
ff0cee69 1712 \@defpath, $Verbose );
f1387719
PP
1713 # don't check if perl is executable, maybe they have decided to
1714 # supply switches with perl
1715
1716 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
1717 ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/perl/i
1718 unless ($self->{FULLPERL});
1e44e2bf
PP
1719}
1720
f1387719 1721=item init_others
1e44e2bf 1722
f1387719
PP
1723Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH,
1724OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, NOOP, FIRST_MAKEFILE,
68dc0745 1725MAKEFILE, NOECHO, RM_F, RM_RF, TEST_F, TOUCH, CP, MV, CHMOD, UMASK_NULL
1e44e2bf
PP
1726
1727=cut
1728
f1387719 1729sub init_others { # --- Initialize Other Attributes
1e44e2bf 1730 my($self) = shift;
1e44e2bf 1731
f1387719
PP
1732 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1733 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
1734 # undefined. In any case we turn it into an anon array:
1e44e2bf 1735
f1387719
PP
1736 # May check $Config{libs} too, thus not empty.
1737 $self->{LIBS}=[''] unless $self->{LIBS};
f4ae0f5e 1738
a1f8e286 1739 $self->{LIBS}=[$self->{LIBS}] if ref \$self->{LIBS} eq 'SCALAR';
f1387719
PP
1740 $self->{LD_RUN_PATH} = "";
1741 my($libs);
1742 foreach $libs ( @{$self->{LIBS}} ){
1743 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1744 my(@libs) = $self->extliblist($libs);
1745 if ($libs[0] or $libs[1] or $libs[2]){
1746 # LD_RUN_PATH now computed by ExtUtils::Liblist
1747 ($self->{EXTRALIBS}, $self->{BSLOADLIBS}, $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
1748 last;
1749 }
1750 }
f4ae0f5e 1751
f1387719
PP
1752 if ( $self->{OBJECT} ) {
1753 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
1754 } else {
1755 # init_dirscan should have found out, if we have C files
1756 $self->{OBJECT} = "";
1757 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
1e44e2bf 1758 }
f1387719
PP
1759 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1760 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
1761 $self->{PERLMAINCC} ||= '$(CC)';
1762 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1e44e2bf 1763
f1387719
PP
1764 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1765 # the 'dynamic' section of MM. We don't have this problem with
1766 # 'static', since we either must use it (%Config says we can't
1767 # use dynamic loading) or the caller asked for it explicitly.
1768 if (!$self->{LINKTYPE}) {
1769 $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
1770 ? 'static'
1771 : ($Config::Config{usedl} ? 'dynamic' : 'static');
1772 };
1773
1774 # These get overridden for VMS and maybe some other systems
55497cff 1775 $self->{NOOP} ||= '$(SHELL) -c true';
f1387719
PP
1776 $self->{FIRST_MAKEFILE} ||= "Makefile";
1777 $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
1778 $self->{MAKE_APERL_FILE} ||= "Makefile.aperl";
1779 $self->{NOECHO} = '@' unless defined $self->{NOECHO};
1780 $self->{RM_F} ||= "rm -f";
1781 $self->{RM_RF} ||= "rm -rf";
1782 $self->{TOUCH} ||= "touch";
68dc0745 1783 $self->{TEST_F} ||= "test -f";
f1387719
PP
1784 $self->{CP} ||= "cp";
1785 $self->{MV} ||= "mv";
1786 $self->{CHMOD} ||= "chmod";
1787 $self->{UMASK_NULL} ||= "umask 0";
68dc0745 1788 $self->{DEV_NULL} ||= "> /dev/null 2>&1";
1e44e2bf
PP
1789}
1790
f1387719 1791=item install (o)
1e44e2bf 1792
f1387719 1793Defines the install target.
1e44e2bf
PP
1794
1795=cut
1796
f1387719
PP
1797sub install {
1798 my($self, %attribs) = @_;
1e44e2bf 1799 my(@m);
a5f75d66 1800
f1387719
PP
1801 push @m, q{
1802install :: all pure_install doc_install
1e44e2bf 1803
f1387719 1804install_perl :: all pure_perl_install doc_perl_install
1e44e2bf 1805
f1387719 1806install_site :: all pure_site_install doc_site_install
1e44e2bf 1807
f1387719
PP
1808install_ :: install_site
1809 @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
1e44e2bf 1810
f1387719 1811pure_install :: pure_$(INSTALLDIRS)_install
1e44e2bf 1812
f1387719
PP
1813doc_install :: doc_$(INSTALLDIRS)_install
1814 }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
1e44e2bf 1815
f1387719
PP
1816pure__install : pure_site_install
1817 @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
1e44e2bf 1818
f1387719
PP
1819doc__install : doc_site_install
1820 @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
1e44e2bf 1821
f1387719
PP
1822pure_perl_install ::
1823 }.$self->{NOECHO}.q{$(MOD_INSTALL) \
1824 read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
1825 write }.$self->catfile('$(INSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
1826 $(INST_LIB) $(INSTALLPRIVLIB) \
1827 $(INST_ARCHLIB) $(INSTALLARCHLIB) \
1828 $(INST_BIN) $(INSTALLBIN) \
1829 $(INST_SCRIPT) $(INSTALLSCRIPT) \
1830 $(INST_MAN1DIR) $(INSTALLMAN1DIR) \
1831 $(INST_MAN3DIR) $(INSTALLMAN3DIR)
1832 }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \
1833 }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
1e44e2bf 1834
1e44e2bf 1835
f1387719
PP
1836pure_site_install ::
1837 }.$self->{NOECHO}.q{$(MOD_INSTALL) \
1838 read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
1839 write }.$self->catfile('$(INSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
1840 $(INST_LIB) $(INSTALLSITELIB) \
1841 $(INST_ARCHLIB) $(INSTALLSITEARCH) \
1842 $(INST_BIN) $(INSTALLBIN) \
1843 $(INST_SCRIPT) $(INSTALLSCRIPT) \
1844 $(INST_MAN1DIR) $(INSTALLMAN1DIR) \
1845 $(INST_MAN3DIR) $(INSTALLMAN3DIR)
1846 }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \
1847 }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
1e44e2bf 1848
f1387719
PP
1849doc_perl_install ::
1850 }.$self->{NOECHO}.q{$(DOC_INSTALL) \
dbc738d9 1851 "Module" "$(NAME)" \
f1387719
PP
1852 "installed into" "$(INSTALLPRIVLIB)" \
1853 LINKTYPE "$(LINKTYPE)" \
1854 VERSION "$(VERSION)" \
1855 EXE_FILES "$(EXE_FILES)" \
1856 >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
1e44e2bf 1857
f1387719
PP
1858doc_site_install ::
1859 }.$self->{NOECHO}.q{$(DOC_INSTALL) \
dbc738d9 1860 "Module" "$(NAME)" \
f1387719
PP
1861 "installed into" "$(INSTALLSITELIB)" \
1862 LINKTYPE "$(LINKTYPE)" \
1863 VERSION "$(VERSION)" \
1864 EXE_FILES "$(EXE_FILES)" \
1865 >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
1e44e2bf 1866
f1387719 1867};
1e44e2bf 1868
f1387719
PP
1869 push @m, q{
1870uninstall :: uninstall_from_$(INSTALLDIRS)dirs
f4ae0f5e 1871
f1387719
PP
1872uninstall_from_perldirs ::
1873 }.$self->{NOECHO}.
1874 q{$(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
1e44e2bf 1875
f1387719
PP
1876uninstall_from_sitedirs ::
1877 }.$self->{NOECHO}.
1878 q{$(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
1879};
1e44e2bf 1880
f1387719
PP
1881 join("",@m);
1882}
1e44e2bf 1883
f1387719 1884=item installbin (o)
1e44e2bf 1885
f1387719 1886Defines targets to install EXE_FILES.
1e44e2bf 1887
f1387719 1888=cut
1e44e2bf 1889
f1387719
PP
1890sub installbin {
1891 my($self) = shift;
1892 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
1893 return "" unless @{$self->{EXE_FILES}};
1894 my(@m, $from, $to, %fromto, @to);
1895 push @m, $self->dir_target(qw[$(INST_SCRIPT)]);
1896 for $from (@{$self->{EXE_FILES}}) {
1897 my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
1898 local($_) = $path; # for backwards compatibility
1899 $to = $self->libscan($path);
1900 print "libscan($from) => '$to'\n" if ($Verbose >=2);
1901 $fromto{$from}=$to;
1902 }
1903 @to = values %fromto;
1904 push(@m, "
1905EXE_FILES = @{$self->{EXE_FILES}}
1e44e2bf 1906
f1387719 1907all :: @to
2d6e8844 1908 $self->{NOECHO}\$(NOOP)
1e44e2bf 1909
f1387719
PP
1910realclean ::
1911 $self->{RM_F} @to
1912");
1e44e2bf 1913
f1387719
PP
1914 while (($from,$to) = each %fromto) {
1915 last unless defined $from;
1916 my $todir = dirname($to);
1917 push @m, "
3e3baf6d 1918$to: $from $self->{MAKEFILE} ".$self->catfile($todir,'.exists')."
f1387719
PP
1919 $self->{NOECHO}$self->{RM_F} $to
1920 $self->{CP} $from $to
1921";
1e44e2bf 1922 }
f1387719
PP
1923 join "", @m;
1924}
1e44e2bf 1925
f1387719 1926=item libscan (o)
1e44e2bf 1927
f1387719
PP
1928Takes a path to a file that is found by init_dirscan and returns false
1929if we don't want to include this file in the library. Mainly used to
1930exclude RCS, CVS, and SCCS directories from installation.
1e44e2bf 1931
f1387719 1932=cut
1e44e2bf 1933
f1387719 1934# ';
1e44e2bf 1935
f1387719
PP
1936sub libscan {
1937 my($self,$path) = @_;
1938 return '' if $path =~ m:\b(RCS|CVS|SCCS)\b: ;
1939 $path;
1e44e2bf
PP
1940}
1941
f4ae0f5e 1942=item linkext (o)
1e44e2bf 1943
f4ae0f5e 1944Defines the linkext target which in turn defines the LINKTYPE.
1e44e2bf
PP
1945
1946=cut
1947
1948sub linkext {
1949 my($self, %attribs) = @_;
1e44e2bf
PP
1950 # LINKTYPE => static or dynamic or ''
1951 my($linktype) = defined $attribs{LINKTYPE} ?
1952 $attribs{LINKTYPE} : '$(LINKTYPE)';
1953 "
1954linkext :: $linktype
f4ae0f5e 1955 $self->{NOECHO}\$(NOOP)
1e44e2bf
PP
1956";
1957}
1958
f1387719 1959=item lsdir
1e44e2bf 1960
f1387719
PP
1961Takes as arguments a directory name and a regular expression. Returns
1962all entries in the directory that match the regular expression.
1e44e2bf
PP
1963
1964=cut
1965
f1387719
PP
1966sub lsdir {
1967 my($self) = shift;
1968 my($dir, $regex) = @_;
1969 my(@ls);
1970 my $dh = new DirHandle;
1971 $dh->open($dir || ".") or return ();
1972 @ls = $dh->read;
1973 $dh->close;
1974 @ls = grep(/$regex/, @ls) if $regex;
1975 @ls;
1976}
1977
1978=item macro (o)
1979
1980Simple subroutine to insert the macros defined by the macro attribute
1981into the Makefile.
1982
1983=cut
1984
1985sub macro {
1e44e2bf 1986 my($self,%attribs) = @_;
f1387719
PP
1987 my(@m,$key,$val);
1988 while (($key,$val) = each %attribs){
1989 last unless defined $key;
1990 push @m, "$key = $val\n";
1e44e2bf 1991 }
f1387719
PP
1992 join "", @m;
1993}
1e44e2bf 1994
f1387719 1995=item makeaperl (o)
1e44e2bf 1996
f1387719
PP
1997Called by staticmake. Defines how to write the Makefile to produce a
1998static new perl.
1999
55497cff
PP
2000By default the Makefile produced includes all the static extensions in
2001the perl library. (Purified versions of library files, e.g.,
2002DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.)
2003
f1387719
PP
2004=cut
2005
2006sub makeaperl {
2007 my($self, %attribs) = @_;
2008 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2009 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
1e44e2bf 2010 my(@m);
f1387719
PP
2011 push @m, "
2012# --- MakeMaker makeaperl section ---
2013MAP_TARGET = $target
2014FULLPERL = $self->{FULLPERL}
2015";
2016 return join '', @m if $self->{PARENT};
1e44e2bf 2017
f1387719 2018 my($dir) = join ":", @{$self->{DIR}};
1e44e2bf 2019
f1387719
PP
2020 unless ($self->{MAKEAPERL}) {
2021 push @m, q{
2022$(MAP_TARGET) :: static $(MAKE_APERL_FILE)
2023 $(MAKE) -f $(MAKE_APERL_FILE) $@
1e44e2bf 2024
f1387719
PP
2025$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
2026 }.$self->{NOECHO}.q{echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2027 }.$self->{NOECHO}.q{$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
2028 Makefile.PL DIR=}, $dir, q{ \
2029 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2030 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
1e44e2bf 2031
f1387719
PP
2032 foreach (@ARGV){
2033 if( /\s/ ){
2034 s/=(.*)/='$1'/;
2035 }
2036 push @m, " \\\n\t\t$_";
2037 }
2038# push @m, map( " \\\n\t\t$_", @ARGV );
2039 push @m, "\n";
1e44e2bf 2040
f1387719
PP
2041 return join '', @m;
2042 }
1e44e2bf 2043
1e44e2bf 2044
1e44e2bf 2045
f1387719 2046 my($cccmd, $linkcmd, $lperl);
1e44e2bf 2047
1e44e2bf 2048
f1387719
PP
2049 $cccmd = $self->const_cccmd($libperl);
2050 $cccmd =~ s/^CCCMD\s*=\s*//;
2051 $cccmd =~ s/\$\(INC\)/ -I$self->{PERL_INC} /;
bab2b58e 2052 $cccmd .= " $Config::Config{cccdlflags}"
042ade60 2053 if ($Config::Config{useshrplib} eq 'true');
f1387719 2054 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
1e44e2bf 2055
f1387719
PP
2056 # The front matter of the linkcommand...
2057 $linkcmd = join ' ', "\$(CC)",
2058 grep($_, @Config{qw(large split ldflags ccdlflags)});
2059 $linkcmd =~ s/\s+/ /g;
93f9cb4b 2060 $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
1e44e2bf 2061
f1387719
PP
2062 # Which *.a files could we make use of...
2063 local(%static);
2064 require File::Find;
2065 File::Find::find(sub {
2066 return unless m/\Q$self->{LIB_EXT}\E$/;
2067 return if m/^libperl/;
55497cff
PP
2068 # Skip purified versions of libraries (e.g., DynaLoader_pure_p1_c0_032.a)
2069 return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
1e44e2bf 2070
f1387719
PP
2071 if( exists $self->{INCLUDE_EXT} ){
2072 my $found = 0;
2073 my $incl;
2074 my $xx;
2075
2076 ($xx = $File::Find::name) =~ s,.*?/auto/,,;
2077 $xx =~ s,/?$_,,;
2078 $xx =~ s,/,::,g;
2079
2080 # Throw away anything not explicitly marked for inclusion.
2081 # DynaLoader is implied.
2082 foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
2083 if( $xx eq $incl ){
2084 $found++;
2085 last;
2086 }
2087 }
2088 return unless $found;
2089 }
2090 elsif( exists $self->{EXCLUDE_EXT} ){
2091 my $excl;
2092 my $xx;
1e44e2bf 2093
f1387719
PP
2094 ($xx = $File::Find::name) =~ s,.*?/auto/,,;
2095 $xx =~ s,/?$_,,;
2096 $xx =~ s,/,::,g;
1e44e2bf 2097
f1387719
PP
2098 # Throw away anything explicitly marked for exclusion
2099 foreach $excl (@{$self->{EXCLUDE_EXT}}){
2100 return if( $xx eq $excl );
2101 }
2102 }
2103
2104 # don't include the installed version of this extension. I
2105 # leave this line here, although it is not necessary anymore:
2106 # I patched minimod.PL instead, so that Miniperl.pm won't
2107 # enclude duplicates
2108
2109 # Once the patch to minimod.PL is in the distribution, I can
2110 # drop it
2111 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}$:;
2112 use Cwd 'cwd';
2113 $static{cwd() . "/" . $_}++;
2114 }, grep( -d $_, @{$searchdirs || []}) );
2115
2116 # We trust that what has been handed in as argument, will be buildable
2117 $static = [] unless $static;
2118 @static{@{$static}} = (1) x @{$static};
2119
2120 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2121 for (sort keys %static) {
2122 next unless /\Q$self->{LIB_EXT}\E$/;
2123 $_ = dirname($_) . "/extralibs.ld";
2124 push @$extra, $_;
1e44e2bf 2125 }
1e44e2bf 2126
f1387719 2127 grep(s/^/-I/, @{$perlinc || []});
1e44e2bf 2128
f1387719
PP
2129 $target = "perl" unless $target;
2130 $tmp = "." unless $tmp;
1e44e2bf 2131
f1387719
PP
2132# MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2133# regenerate the Makefiles, MAP_STATIC and the dependencies for
2134# extralibs.all are computed correctly
2135 push @m, "
2136MAP_LINKCMD = $linkcmd
2137MAP_PERLINC = @{$perlinc || []}
2138MAP_STATIC = ",
2139join(" \\\n\t", reverse sort keys %static), "
1e44e2bf 2140
f1387719
PP
2141MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
2142";
2143
2144 if (defined $libperl) {
2145 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2146 }
2147 unless ($libperl && -f $lperl) { # Ilya's code...
2148 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
2149 $libperl ||= "libperl$self->{LIB_EXT}";
2150 $libperl = "$dir/$libperl";
2151 $lperl ||= "libperl$self->{LIB_EXT}";
2152 $lperl = "$dir/$lperl";
ff0cee69
PP
2153
2154 if (! -f $libperl and ! -f $lperl) {
2155 # We did not find a static libperl. Maybe there is a shared one?
2156 if ($^O eq 'solaris' or $^O eq 'sunos') {
2157 $lperl = $libperl = "$dir/$Config::Config{libperl}";
2158 # SUNOS ld does not take the full path to a shared library
2159 $libperl = '' if $^O eq 'sunos';
2160 }
2161 }
2162
f1387719
PP
2163 print STDOUT "Warning: $libperl not found
2164 If you're going to build a static perl binary, make sure perl is installed
2165 otherwise ignore this warning\n"
2166 unless (-f $lperl || defined($self->{PERL_SRC}));
2167 }
1e44e2bf 2168
f1387719
PP
2169 push @m, "
2170MAP_LIBPERL = $libperl
2171";
1e44e2bf 2172
f1387719
PP
2173 push @m, "
2174\$(INST_ARCHAUTODIR)/extralibs.all: \$(INST_ARCHAUTODIR)/.exists ".join(" \\\n\t", @$extra)."
2175 $self->{NOECHO}$self->{RM_F} \$\@
2176 $self->{NOECHO}\$(TOUCH) \$\@
2177";
1e44e2bf 2178
f1387719
PP
2179 my $catfile;
2180 foreach $catfile (@$extra){
2181 push @m, "\tcat $catfile >> \$\@\n";
1e44e2bf 2182 }
ff0cee69
PP
2183 # SUNOS ld does not take the full path to a shared library
2184 my $llibperl = ($libperl)?'$(MAP_LIBPERL)':'-lperl';
1e44e2bf 2185
ff0cee69
PP
2186 # Brain dead solaris linker does not use LD_RUN_PATH?
2187 # This fixes dynamic extensions which need shared libs
2188 my $ldfrom = ($^O eq 'solaris')?
2189 join(' ', map "-R$_", split /:/, $self->{LD_RUN_PATH}):'';
2190
2191push @m, "
f1387719 2192\$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
ff0cee69 2193 \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) $ldfrom $llibperl \$(MAP_STATIC) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
f1387719
PP
2194 $self->{NOECHO}echo 'To install the new \"\$(MAP_TARGET)\" binary, call'
2195 $self->{NOECHO}echo ' make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
2196 $self->{NOECHO}echo 'To remove the intermediate files say'
2197 $self->{NOECHO}echo ' make -f $makefilename map_clean'
1e44e2bf 2198
f1387719
PP
2199$tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
2200";
2201 push @m, "\tcd $tmp && $cccmd -I\$(PERL_INC) perlmain.c\n";
1e44e2bf 2202
f1387719
PP
2203 push @m, qq{
2204$tmp/perlmain.c: $makefilename}, q{
2205 }.$self->{NOECHO}.q{echo Writing $@
68dc0745
PP
2206 }.$self->{NOECHO}.q{$(PERL) $(MAP_PERLINC) -MExtUtils::Miniperl \\
2207 -e "writemain(grep s#.*/auto/##, qw|$(MAP_STATIC)|)" > $@t && $(MV) $@t $@
1e44e2bf 2208
f1387719 2209};
1e44e2bf 2210
f1387719
PP
2211 push @m, q{
2212doc_inst_perl:
2213 }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
2214 }.$self->{NOECHO}.q{$(DOC_INSTALL) \
dbc738d9 2215 "Perl binary" "$(MAP_TARGET)" \
f1387719
PP
2216 MAP_STATIC "$(MAP_STATIC)" \
2217 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
2218 MAP_LIBPERL "$(MAP_LIBPERL)" \
2219 >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
1e44e2bf 2220
f1387719 2221};
1e44e2bf 2222
f1387719
PP
2223 push @m, q{
2224inst_perl: pure_inst_perl doc_inst_perl
1e44e2bf 2225
f1387719
PP
2226pure_inst_perl: $(MAP_TARGET)
2227 }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(INSTALLBIN)','$(MAP_TARGET)').q{
1e44e2bf 2228
f1387719
PP
2229clean :: map_clean
2230
2231map_clean :
2232 }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
2233};
2234
2235 join '', @m;
1e44e2bf
PP
2236}
2237
f1387719 2238=item makefile (o)
1e44e2bf 2239
f1387719 2240Defines how to rewrite the Makefile.
1e44e2bf
PP
2241
2242=cut
2243
f1387719
PP
2244sub makefile {
2245 my($self) = shift;
2246 my @m;
2247 # We do not know what target was originally specified so we
2248 # must force a manual rerun to be sure. But as it should only
2249 # happen very rarely it is not a significant problem.
2250 push @m, '
2251$(OBJECT) : $(FIRST_MAKEFILE)
2252' if $self->{OBJECT};
1e44e2bf 2253
f1387719
PP
2254 push @m, q{
2255# We take a very conservative approach here, but it\'s worth it.
2256# We move Makefile to Makefile.old here to avoid gnu make looping.
2257}.$self->{MAKEFILE}.q{ : Makefile.PL $(CONFIGDEP)
2258 }.$self->{NOECHO}.q{echo "Makefile out-of-date with respect to $?"
2259 }.$self->{NOECHO}.q{echo "Cleaning current config before rebuilding Makefile..."
68dc0745
PP
2260 -}.$self->{NOECHO}.q{$(MV) }."$self->{MAKEFILE} $self->{MAKEFILE}.old".q{
2261 -$(MAKE) -f }.$self->{MAKEFILE}.q{.old clean $(DEV_NULL) || $(NOOP)
f1387719 2262 $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL }.join(" ",map(qq["$_"],@ARGV)).q{
68dc0745
PP
2263 }.$self->{NOECHO}.q{echo "==> Your Makefile has been rebuilt. <=="
2264 }.$self->{NOECHO}.q{echo "==> Please rerun the make command. <=="
2265 false
1e44e2bf 2266
f1387719
PP
2267# To change behavior to :: would be nice, but would break Tk b9.02
2268# so you find such a warning below the dist target.
2269#}.$self->{MAKEFILE}.q{ :: $(VERSION_FROM)
2270# }.$self->{NOECHO}.q{echo "Warning: Makefile possibly out of date with $(VERSION_FROM)"
1e44e2bf
PP
2271};
2272
f1387719 2273 join "", @m;
1e44e2bf
PP
2274}
2275
f4ae0f5e 2276=item manifypods (o)
1e44e2bf 2277
f4ae0f5e
PP
2278Defines targets and routines to translate the pods into manpages and
2279put them into the INST_* directories.
1e44e2bf
PP
2280
2281=cut
2282
2283sub manifypods {
2284 my($self, %attribs) = @_;
f1387719 2285 return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n" unless %{$self->{MAN3PODS}} or %{$self->{MAN1PODS}};
1e44e2bf
PP
2286 my($dist);
2287 my($pod2man_exe);
2288 if (defined $self->{PERL_SRC}) {
2289 $pod2man_exe = $self->catfile($self->{PERL_SRC},'pod','pod2man');
2290 } else {
f1387719 2291 $pod2man_exe = $self->catfile($Config{scriptdirexp},'pod2man');
1e44e2bf
PP
2292 }
2293 unless ($self->perl_script($pod2man_exe)) {
2294 # No pod2man but some MAN3PODS to be installed
2295 print <<END;
2296
2297Warning: I could not locate your pod2man program. Please make sure,
2298 your pod2man program is in your PATH before you execute 'make'
2299
2300END
2301 $pod2man_exe = "-S pod2man";
2302 }
2303 my(@m);
2304 push @m,
2305qq[POD2MAN_EXE = $pod2man_exe\n],
2306q[POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \\
2307-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "].$self->{MAKEFILE}.q[";' \\
2308-e 'print "Manifying $$m{$$_}\n";' \\
f1387719 2309-e 'system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2MAN_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\
1e44e2bf
PP
2310-e 'chmod 0644, $$m{$$_} or warn "chmod 644 $$m{$$_}: $$!\n";}'
2311];
2312 push @m, "\nmanifypods : ";
2313 push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}};
f1387719
PP
2314
2315 push(@m,"\n");
2316 if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) {
2317 push @m, "\t$self->{NOECHO}\$(POD2MAN) \\\n\t";
2318 push @m, join " \\\n\t", %{$self->{MAN1PODS}}, %{$self->{MAN3PODS}};
1e44e2bf 2319 }
f1387719 2320 join('', @m);
1e44e2bf
PP
2321}
2322
f1387719 2323=item maybe_command
1e44e2bf 2324
f1387719 2325Returns true, if the argument is likely to be a command.
1e44e2bf
PP
2326
2327=cut
2328
f1387719
PP
2329sub maybe_command {
2330 my($self,$file) = @_;
2331 return $file if -x $file && ! -d $file;
2332 return;
1e44e2bf
PP
2333}
2334
f1387719 2335=item maybe_command_in_dirs
1e44e2bf 2336
f1387719 2337method under development. Not yet used. Ask Ilya :-)
1e44e2bf
PP
2338
2339=cut
2340
f1387719
PP
2341sub maybe_command_in_dirs { # $ver is optional argument if looking for perl
2342# Ilya's suggestion. Not yet used, want to understand it first, but at least the code is here
2343 my($self, $names, $dirs, $trace, $ver) = @_;
2344 my($name, $dir);
2345 foreach $dir (@$dirs){
2346 next unless defined $dir; # $self->{PERL_SRC} may be undefined
2347 foreach $name (@$names){
2348 my($abs,$tryabs);
2349 if ($self->file_name_is_absolute($name)) { # /foo/bar
2350 $abs = $name;
2351 } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # bar
2352 $abs = $self->catfile($dir, $name);
2353 } else { # foo/bar
2354 $abs = $self->catfile($self->curdir, $name);
2355 }
2356 print "Checking $abs for $name\n" if ($trace >= 2);
2357 next unless $tryabs = $self->maybe_command($abs);
2358 print "Substituting $tryabs instead of $abs\n"
2359 if ($trace >= 2 and $tryabs ne $abs);
2360 $abs = $tryabs;
2361 if (defined $ver) {
2362 print "Executing $abs\n" if ($trace >= 2);
2363 if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
2364 print "Using PERL=$abs\n" if $trace;
2365 return $abs;
2366 }
2367 } else { # Do not look for perl
2368 return $abs;
2369 }
2370 }
1e44e2bf 2371 }
1e44e2bf
PP
2372}
2373
f1387719 2374=item needs_linking (o)
1e44e2bf 2375
f1387719
PP
2376Does this module need linking? Looks into subdirectory objects (see
2377also has_link_code())
1e44e2bf
PP
2378
2379=cut
2380
f1387719
PP
2381sub needs_linking {
2382 my($self) = shift;
2383 my($child,$caller);
2384 $caller = (caller(0))[3];
2385 Carp::confess("Needs_linking called too early") if $caller =~ /^ExtUtils::MakeMaker::/;
2386 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
2387 if ($self->has_link_code or $self->{MAKEAPERL}){
2388 $self->{NEEDS_LINKING} = 1;
2389 return 1;
1e44e2bf 2390 }
f1387719
PP
2391 foreach $child (keys %{$self->{CHILDREN}}) {
2392 if ($self->{CHILDREN}->{$child}->needs_linking) {
2393 $self->{NEEDS_LINKING} = 1;
2394 return 1;
2395 }
1e44e2bf 2396 }
f1387719 2397 return $self->{NEEDS_LINKING} = 0;
1e44e2bf
PP
2398}
2399
f1387719 2400=item nicetext
1e44e2bf 2401
f1387719
PP
2402misnamed method (will have to be changed). The MM_Unix method just
2403returns the argument without further processing.
2404
2405On VMS used to insure that colons marking targets are preceded by
2406space - most Unix Makes don't need this, but it's necessary under VMS
2407to distinguish the target delimiter from a colon appearing as part of
2408a filespec.
1e44e2bf
PP
2409
2410=cut
2411
f1387719
PP
2412sub nicetext {
2413 my($self,$text) = @_;
2414 $text;
2415}
1e44e2bf 2416
f1387719 2417=item parse_version
1e44e2bf 2418
f1387719 2419parse a file and return what you think is $VERSION in this file set to
1e44e2bf 2420
f1387719
PP
2421=cut
2422
2423sub parse_version {
2424 my($self,$parsefile) = @_;
2425 my $result;
2426 local *FH;
2427 local $/ = "\n";
2428 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2429 my $inpod = 0;
2430 while (<FH>) {
2431 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2432 next if $inpod;
2433 chop;
2434 next unless /\$(([\w\:\']*)\bVERSION)\b.*\=/;
dbc738d9
PP
2435 my $eval = qq{
2436 package ExtUtils::MakeMaker::_version;
a1f8e286 2437 no strict;
bab2b58e
AK
2438
2439 \$$1=undef; do {
2440 $_
dbc738d9
PP
2441 }; \$$1
2442 };
2443 local($^W) = 0;
2444 $result = eval($eval) || 0;
f1387719 2445 die "Could not eval '$eval' in $parsefile: $@" if $@;
f1387719
PP
2446 last;
2447 }
2448 close FH;
2449 return $result;
1e44e2bf
PP
2450}
2451
1e44e2bf 2452
f1387719
PP
2453=item pasthru (o)
2454
2455Defines the string that is passed to recursive make calls in
2456subdirectories.
1e44e2bf
PP
2457
2458=cut
2459
f1387719 2460sub pasthru {
1e44e2bf 2461 my($self) = shift;
f1387719 2462 my(@m,$key);
1e44e2bf 2463
f1387719 2464 my(@pasthru);
bbce6d69
PP
2465 my($sep) = $Is_VMS ? ',' : '';
2466 $sep .= "\\\n\t";
1e44e2bf 2467
bab2b58e 2468 foreach $key (qw(LIB LIBPERL_A LINKTYPE PREFIX OPTIMIZE)){
f1387719
PP
2469 push @pasthru, "$key=\"\$($key)\"";
2470 }
f4ae0f5e 2471
bbce6d69 2472 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n";
f1387719
PP
2473 join "", @m;
2474}
1e44e2bf 2475
f1387719 2476=item path
f4ae0f5e 2477
f1387719 2478Takes no argument, returns the environment variable PATH as an array.
1e44e2bf 2479
f1387719
PP
2480=cut
2481
2482sub path {
2483 my($self) = @_;
2484 my $path_sep = $Is_OS2 ? ";" : ":";
2485 my $path = $ENV{PATH};
2486 $path =~ s:\\:/:g if $Is_OS2;
2487 my @path = split $path_sep, $path;
93f9cb4b
PP
2488 foreach(@path) { $_ = '.' if $_ eq '' }
2489 @path;
1e44e2bf
PP
2490}
2491
f1387719 2492=item perl_script
1e44e2bf 2493
f1387719
PP
2494Takes one argument, a file name, and returns the file name, if the
2495argument is likely to be a perl script. On MM_Unix this is true for
2496any ordinary, readable file.
1e44e2bf
PP
2497
2498=cut
2499
f1387719
PP
2500sub perl_script {
2501 my($self,$file) = @_;
2502 return $file if -r $file && -f _;
2503 return;
1e44e2bf
PP
2504}
2505
f1387719 2506=item perldepend (o)
1e44e2bf 2507
f1387719
PP
2508Defines the dependency from all *.h files that come with the perl
2509distribution.
1e44e2bf
PP
2510
2511=cut
2512
f1387719 2513sub perldepend {
1e44e2bf 2514 my($self) = shift;
f1387719
PP
2515 my(@m);
2516 push @m, q{
2517# Check for unpropogated config.sh changes. Should never happen.
2518# We do NOT just update config.h because that is not sufficient.
2519# An out of date config.h is not fatal but complains loudly!
2520$(PERL_INC)/config.h: $(PERL_SRC)/config.sh
2521 -}.$self->{NOECHO}.q{echo "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
2522
2523$(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
2524 }.$self->{NOECHO}.q{echo "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
2525 cd $(PERL_SRC) && $(MAKE) lib/Config.pm
2526} if $self->{PERL_SRC};
2527
2528 return join "", @m unless $self->needs_linking;
2529
1e44e2bf 2530 push @m, q{
f1387719
PP
2531PERL_HDRS = \
2532$(PERL_INC)/EXTERN.h $(PERL_INC)/gv.h $(PERL_INC)/pp.h \
2533$(PERL_INC)/INTERN.h $(PERL_INC)/handy.h $(PERL_INC)/proto.h \
2534$(PERL_INC)/XSUB.h $(PERL_INC)/hv.h $(PERL_INC)/regcomp.h \
2535$(PERL_INC)/av.h $(PERL_INC)/keywords.h $(PERL_INC)/regexp.h \
2536$(PERL_INC)/config.h $(PERL_INC)/mg.h $(PERL_INC)/scope.h \
2537$(PERL_INC)/cop.h $(PERL_INC)/op.h $(PERL_INC)/sv.h \
2538$(PERL_INC)/cv.h $(PERL_INC)/opcode.h $(PERL_INC)/unixish.h \
2539$(PERL_INC)/dosish.h $(PERL_INC)/patchlevel.h $(PERL_INC)/util.h \
2540$(PERL_INC)/embed.h $(PERL_INC)/perl.h \
2541$(PERL_INC)/form.h $(PERL_INC)/perly.h
2542
2543$(OBJECT) : $(PERL_HDRS)
2544} if $self->{OBJECT};
2545
2546 push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}};
2547
2548 join "\n", @m;
1e44e2bf
PP
2549}
2550
f1387719 2551=item pm_to_blib
1e44e2bf 2552
f1387719 2553Defines target that copies all files in the hash PM to their
55497cff 2554destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
1e44e2bf
PP
2555
2556=cut
2557
f1387719
PP
2558sub pm_to_blib {
2559 my $self = shift;
2560 my($autodir) = $self->catdir('$(INST_LIB)','auto');
2561 return q{
2562pm_to_blib: $(TO_INST_PM)
2563 }.$self->{NOECHO}.q{$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \
2564 "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \
68dc0745 2565 -e "pm_to_blib({qw{$(PM_TO_BLIB)}},'}.$autodir.q{')"
f1387719 2566 }.$self->{NOECHO}.q{$(TOUCH) $@
1e44e2bf 2567};
1e44e2bf
PP
2568}
2569
f1387719 2570=item post_constants (o)
1e44e2bf 2571
f1387719
PP
2572Returns an empty string per default. Dedicated to overrides from
2573within Makefile.PL after all constants have been defined.
1e44e2bf
PP
2574
2575=cut
2576
f1387719
PP
2577sub post_constants{
2578 my($self) = shift;
2579 "";
2580}
1e44e2bf 2581
f1387719 2582=item post_initialize (o)
1e44e2bf 2583
1fef88e7 2584Returns an empty string per default. Used in Makefile.PLs to add some
f1387719 2585chunk of text to the Makefile after the object is initialized.
1e44e2bf 2586
f1387719 2587=cut
1e44e2bf 2588
f1387719
PP
2589sub post_initialize {
2590 my($self) = shift;
2591 "";
2592}
1e44e2bf 2593
f1387719 2594=item postamble (o)
1e44e2bf 2595
f1387719
PP
2596Returns an empty string. Can be used in Makefile.PLs to write some
2597text to the Makefile at the end.
1e44e2bf 2598
f1387719 2599=cut
1e44e2bf 2600
f1387719
PP
2601sub postamble {
2602 my($self) = shift;
2603 "";
2604}
1e44e2bf 2605
f1387719 2606=item prefixify
1e44e2bf 2607
f1387719
PP
2608Check a path variable in $self from %Config, if it contains a prefix,
2609and replace it with another one.
1e44e2bf 2610
f1387719
PP
2611Takes as arguments an attribute name, a search prefix and a
2612replacement prefix. Changes the attribute in the object.
1e44e2bf 2613
f1387719 2614=cut
1e44e2bf 2615
f1387719
PP
2616sub prefixify {
2617 my($self,$var,$sprefix,$rprefix) = @_;
2618 $self->{uc $var} ||= $Config{lc $var};
2619 $self->{uc $var} = VMS::Filespec::unixpath($self->{uc $var}) if $Is_VMS;
2620 $self->{uc $var} =~ s/\Q$sprefix\E/$rprefix/;
2621}
1e44e2bf 2622
f1387719 2623=item processPL (o)
1e44e2bf 2624
f1387719 2625Defines targets to run *.PL files.
1e44e2bf 2626
f1387719 2627=cut
1e44e2bf 2628
f1387719
PP
2629sub processPL {
2630 my($self) = shift;
2631 return "" unless $self->{PL_FILES};
2632 my(@m, $plfile);
2633 foreach $plfile (sort keys %{$self->{PL_FILES}}) {
2634 push @m, "
2635all :: $self->{PL_FILES}->{$plfile}
2d6e8844 2636 $self->{NOECHO}\$(NOOP)
1e44e2bf 2637
f1387719
PP
2638$self->{PL_FILES}->{$plfile} :: $plfile
2639 \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile
2640";
2641 }
2642 join "", @m;
1e44e2bf
PP
2643}
2644
f1387719 2645=item realclean (o)
1e44e2bf 2646
f1387719 2647Defines the realclean target.
1e44e2bf
PP
2648
2649=cut
2650
f1387719
PP
2651sub realclean {
2652 my($self, %attribs) = @_;
2653 my(@m);
2654 push(@m,'
2655# Delete temporary files (via clean) and also delete installed files
2656realclean purge :: clean
2657');
2658 # realclean subdirectories first (already cleaned)
68dc0745 2659 my $sub = "\t-cd %s && \$(TEST_F) %s && \$(MAKE) %s realclean\n";
f1387719
PP
2660 foreach(@{$self->{DIR}}){
2661 push(@m, sprintf($sub,$_,"$self->{MAKEFILE}.old","-f $self->{MAKEFILE}.old"));
2662 push(@m, sprintf($sub,$_,"$self->{MAKEFILE}",''));
1e44e2bf 2663 }
f1387719
PP
2664 push(@m, " $self->{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n");
2665 if( $self->has_link_code ){
2666 push(@m, " $self->{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n");
2667 push(@m, " $self->{RM_F} \$(INST_STATIC)\n");
2668 }
2669 push(@m, " $self->{RM_F} " . join(" ", values %{$self->{PM}}) . "\n");
2670 my(@otherfiles) = ($self->{MAKEFILE},
2671 "$self->{MAKEFILE}.old"); # Makefiles last
2672 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
2673 push(@m, " $self->{RM_RF} @otherfiles\n") if @otherfiles;
2674 push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
2675 join("", @m);
1e44e2bf
PP
2676}
2677
f1387719 2678=item replace_manpage_separator
1e44e2bf 2679
f1387719
PP
2680Takes the name of a package, which may be a nested package, in the
2681form Foo/Bar and replaces the slash with C<::>. Returns the replacement.
1e44e2bf
PP
2682
2683=cut
2684
f1387719
PP
2685sub replace_manpage_separator {
2686 my($self,$man) = @_;
2687 $man =~ s,/+,::,g;
2688 $man;
2689}
1e44e2bf 2690
f1387719 2691=item static (o)
1e44e2bf 2692
f1387719 2693Defines the static target.
1e44e2bf 2694
f1387719 2695=cut
1e44e2bf 2696
f1387719
PP
2697sub static {
2698# --- Static Loading Sections ---
1e44e2bf 2699
f1387719
PP
2700 my($self) = shift;
2701 '
2702## $(INST_PM) has been moved to the all: target.
2703## It remains here for awhile to allow for old usage: "make static"
2704#static :: '.$self->{MAKEFILE}.' $(INST_STATIC) $(INST_PM)
2705static :: '.$self->{MAKEFILE}.' $(INST_STATIC)
2706 '.$self->{NOECHO}.'$(NOOP)
2707';
1e44e2bf
PP
2708}
2709
f1387719 2710=item static_lib (o)
1e44e2bf 2711
f1387719 2712Defines how to produce the *.a (or equivalent) files.
1e44e2bf
PP
2713
2714=cut
2715
f1387719
PP
2716sub static_lib {
2717 my($self) = @_;
2718# Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
2719# return '' unless $self->needs_linking(); #might be because of a subdir
1e44e2bf 2720
f1387719
PP
2721 return '' unless $self->has_link_code;
2722
2723 my(@m);
2724 push(@m, <<'END');
2725$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists
760ac839 2726 $(RM_RF) $@
f1387719
PP
2727END
2728 # If this extension has it's own library (eg SDBM_File)
2729 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
2730 push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
f4ae0f5e 2731
f1387719 2732 push @m,
760ac839 2733q{ $(AR) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
f1387719 2734 $(CHMOD) 755 $@
0328fe61 2735 }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
f4ae0f5e 2736};
0328fe61
CS
2737 # Old mechanism - still available:
2738 push @m,
2739"\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
2740} if $self->{PERL_SRC} && $self->{EXTRALIBS};
2741 push @m, "\n";
f1387719
PP
2742
2743 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
2744 join('', "\n",@m);
1e44e2bf
PP
2745}
2746
f4ae0f5e 2747=item staticmake (o)
1e44e2bf 2748
f4ae0f5e 2749Calls makeaperl.
1e44e2bf
PP
2750
2751=cut
2752
2753sub staticmake {
2754 my($self, %attribs) = @_;
1e44e2bf
PP
2755 my(@static);
2756
2757 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
2758
2759 # And as it's not yet built, we add the current extension
2760 # but only if it has some C code (or XS code, which implies C code)
2761 if (@{$self->{C}}) {
f4ae0f5e
PP
2762 @static = $self->catfile($self->{INST_ARCHLIB},
2763 "auto",
2764 $self->{FULLEXT},
2765 "$self->{BASEEXT}$self->{LIB_EXT}"
2766 );
1e44e2bf
PP
2767 }
2768
2769 # Either we determine now, which libraries we will produce in the
2770 # subdirectories or we do it at runtime of the make.
2771
2772 # We could ask all subdir objects, but I cannot imagine, why it
2773 # would be necessary.
2774
2775 # Instead we determine all libraries for the new perl at
2776 # runtime.
2777 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
2778
2779 $self->makeaperl(MAKE => $self->{MAKEFILE},
2780 DIRS => \@searchdirs,
2781 STAT => \@static,
2782 INCL => \@perlinc,
2783 TARGET => $self->{MAP_TARGET},
2784 TMP => "",
2785 LIBPERL => $self->{LIBPERL_A}
2786 );
2787}
2788
f1387719
PP
2789=item subdir_x (o)
2790
2791Helper subroutine for subdirs
2792
2793=cut
2794
2795sub subdir_x {
2796 my($self, $subdir) = @_;
2797 my(@m);
2798 qq{
2799
2800subdirs ::
2801 $self->{NOECHO}cd $subdir && \$(MAKE) all \$(PASTHRU)
2802
2803};
2804}
2805
2806=item subdirs (o)
2807
2808Defines targets to process subdirectories.
2809
2810=cut
2811
2812sub subdirs {
2813# --- Sub-directory Sections ---
2814 my($self) = shift;
2815 my(@m,$dir);
2816 # This method provides a mechanism to automatically deal with
2817 # subdirectories containing further Makefile.PL scripts.
2818 # It calls the subdir_x() method for each subdirectory.
2819 foreach $dir (@{$self->{DIR}}){
2820 push(@m, $self->subdir_x($dir));
2821#### print "Including $dir subdirectory\n";
2822 }
2823 if (@m){
2824 unshift(@m, "
2825# The default clean, realclean and test targets in this Makefile
2826# have automatically been given entries for each subdir.
2827
2828");
2829 } else {
2830 push(@m, "\n# none")
2831 }
2832 join('',@m);
2833}
2834
f4ae0f5e 2835=item test (o)
1e44e2bf 2836
f4ae0f5e 2837Defines the test targets.
1e44e2bf
PP
2838
2839=cut
2840
2841sub test {
2842# --- Test and Installation Sections ---
2843
2844 my($self, %attribs) = @_;
96e4d5b1
PP
2845 my $tests = $attribs{TESTS};
2846 if (!$tests && -d 't') {
2847 $tests = $Is_Win32 ? join(' ', <t\\*.t>) : 't/*.t';
2848 }
1e44e2bf
PP
2849 my(@m);
2850 push(@m,"
2851TEST_VERBOSE=0
2852TEST_TYPE=test_\$(LINKTYPE)
f1387719
PP
2853TEST_FILE = test.pl
2854TESTDB_SW = -d
1e44e2bf 2855
f4ae0f5e 2856testdb :: testdb_\$(LINKTYPE)
f1387719
PP
2857
2858test :: \$(TEST_TYPE)
1e44e2bf 2859");
68dc0745 2860 push(@m, map("\t$self->{NOECHO}cd $_ && \$(TEST_F) $self->{MAKEFILE} && \$(MAKE) test \$(PASTHRU)\n",
1e44e2bf
PP
2861 @{$self->{DIR}}));
2862 push(@m, "\t$self->{NOECHO}echo 'No tests defined for \$(NAME) extension.'\n")
2863 unless $tests or -f "test.pl" or @{$self->{DIR}};
2864 push(@m, "\n");
2865
f4ae0f5e 2866 push(@m, "test_dynamic :: pure_all\n");
1e44e2bf
PP
2867 push(@m, $self->test_via_harness('$(FULLPERL)', $tests)) if $tests;
2868 push(@m, $self->test_via_script('$(FULLPERL)', 'test.pl')) if -f "test.pl";
2869 push(@m, "\n");
2870
f1387719
PP
2871 push(@m, "testdb_dynamic :: pure_all\n");
2872 push(@m, $self->test_via_script('$(FULLPERL) $(TESTDB_SW)', '$(TEST_FILE)'));
2873 push(@m, "\n");
f4ae0f5e 2874
1e44e2bf
PP
2875 # Occasionally we may face this degenerate target:
2876 push @m, "test_ : test_dynamic\n\n";
2877
2878 if ($self->needs_linking()) {
f4ae0f5e 2879 push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
1e44e2bf
PP
2880 push(@m, $self->test_via_harness('./$(MAP_TARGET)', $tests)) if $tests;
2881 push(@m, $self->test_via_script('./$(MAP_TARGET)', 'test.pl')) if -f "test.pl";
2882 push(@m, "\n");
f1387719
PP
2883 push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
2884 push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
2885 push(@m, "\n");
1e44e2bf
PP
2886 } else {
2887 push @m, "test_static :: test_dynamic\n";
f4ae0f5e 2888 push @m, "testdb_static :: testdb_dynamic\n";
1e44e2bf
PP
2889 }
2890 join("", @m);
2891}
2892
f4ae0f5e 2893=item test_via_harness (o)
1e44e2bf 2894
f4ae0f5e 2895Helper method to write the test targets
1e44e2bf
PP
2896
2897=cut
2898
2899sub test_via_harness {
2900 my($self, $perl, $tests) = @_;
10dd38fc
GS
2901 $perl = "PERL_DL_NONLAZY=1 $perl" unless $Is_Win32;
2902 "\t$perl".q! -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' !."$tests\n";
1e44e2bf
PP
2903}
2904
f4ae0f5e 2905=item test_via_script (o)
1e44e2bf 2906
f4ae0f5e 2907Other helper method for test.
1e44e2bf
PP
2908
2909=cut
2910
2911sub test_via_script {
2912 my($self, $perl, $script) = @_;
10dd38fc
GS
2913 $perl = "PERL_DL_NONLAZY=1 $perl" unless $Is_Win32;
2914 qq{\t$perl}.q{ -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) }.qq{$script
1e44e2bf
PP
2915};
2916}
2917
f1387719 2918=item tool_autosplit (o)
1e44e2bf 2919
f1387719
PP
2920Defines a simple perl call that runs autosplit. May be deprecated by
2921pm_to_blib soon.
1e44e2bf
PP
2922
2923=cut
2924
f1387719
PP
2925sub tool_autosplit {
2926# --- Tool Sections ---
2927
2928 my($self, %attribs) = @_;
2929 my($asl) = "";
2930 $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
2931 q{
2932# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
2933AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;}.$asl.q{autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
2934};
1e44e2bf
PP
2935}
2936
f1387719 2937=item tools_other (o)
1e44e2bf 2938
f1387719
PP
2939Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in
2940the Makefile. Also defines the perl programs MKPATH,
2941WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL.
1e44e2bf
PP
2942
2943=cut
2944
f1387719
PP
2945sub tools_other {
2946 my($self) = shift;
2947 my @m;
2948 my $bin_sh = $Config{sh} || '/bin/sh';
2949 push @m, qq{
2950SHELL = $bin_sh
2951};
2952
68dc0745 2953 for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) {
f1387719 2954 push @m, "$_ = $self->{$_}\n";
1e44e2bf 2955 }
1e44e2bf 2956
f1387719
PP
2957 push @m, q{
2958# The following is a portable way to say mkdir -p
2959# To see which directories are created, change the if 0 to if 1
68dc0745 2960MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath
1e44e2bf 2961
f1387719
PP
2962# This helps us to minimize the effect of the .exists files A yet
2963# better solution would be to have a stable file in the perl
2964# distribution with a timestamp of zero. But this solution doesn't
2965# need any changes to the core distribution and works with older perls
68dc0745 2966EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime
f1387719 2967};
1e44e2bf 2968
68dc0745 2969
f1387719 2970 return join "", @m if $self->{PARENT};
1e44e2bf 2971
f1387719
PP
2972 push @m, q{
2973# Here we warn users that an old packlist file was found somewhere,
2974# and that they should call some uninstall routine
2975WARN_IF_OLD_PACKLIST = $(PERL) -we 'exit unless -f $$ARGV[0];' \\
2976-e 'print "WARNING: I have found an old package in\n";' \\
2977-e 'print "\t$$ARGV[0].\n";' \\
2978-e 'print "Please make sure the two installations are not conflicting\n";'
1e44e2bf 2979
f1387719
PP
2980UNINST=0
2981VERBINST=1
1e44e2bf 2982
f1387719 2983MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \
68dc0745 2984-e "install({@ARGV},'$(VERBINST)',0,'$(UNINST)');"
1e44e2bf 2985
dbc738d9
PP
2986DOC_INSTALL = $(PERL) -e '$$\="\n\n";' \
2987-e 'print "=head2 ", scalar(localtime), ": C<", shift, ">", " L<", shift, ">";' \
f1387719
PP
2988-e 'print "=over 4";' \
2989-e 'while (defined($$key = shift) and defined($$val = shift)){print "=item *";print "C<$$key: $$val>";}' \
2990-e 'print "=back";'
1e44e2bf 2991
f1387719 2992UNINSTALL = $(PERL) -MExtUtils::Install \
8fe37c6d
CS
2993-e 'uninstall($$ARGV[0],1,1); print "\nUninstall is deprecated. Please check the";' \
2994-e 'print " packlist above carefully.\n There may be errors. Remove the";' \
2995-e 'print " appropriate files manually.\n Sorry for the inconveniences.\n"'
f1387719 2996};
1e44e2bf 2997
f1387719
PP
2998 return join "", @m;
2999}
1e44e2bf 3000
f1387719 3001=item tool_xsubpp (o)
1e44e2bf 3002
f1387719 3003Determines typemaps, xsubpp version, prototype behaviour.
1e44e2bf 3004
f1387719 3005=cut
1e44e2bf 3006
f1387719
PP
3007sub tool_xsubpp {
3008 my($self) = shift;
3009 return "" unless $self->needs_linking;
3010 my($xsdir) = $self->catdir($self->{PERL_LIB},"ExtUtils");
3011 my(@tmdeps) = $self->catdir('$(XSUBPPDIR)','typemap');
3012 if( $self->{TYPEMAPS} ){
3013 my $typemap;
3014 foreach $typemap (@{$self->{TYPEMAPS}}){
3015 if( ! -f $typemap ){
3016 warn "Typemap $typemap not found.\n";
3017 }
3018 else{
3019 push(@tmdeps, $typemap);
3020 }
3021 }
3022 }
3023 push(@tmdeps, "typemap") if -f "typemap";
3024 my(@tmargs) = map("-typemap $_", @tmdeps);
3025 if( exists $self->{XSOPT} ){
3026 unshift( @tmargs, $self->{XSOPT} );
1e44e2bf
PP
3027 }
3028
1e44e2bf 3029
f1387719 3030 my $xsubpp_version = $self->xsubpp_version($self->catfile($xsdir,"xsubpp"));
1e44e2bf 3031
f1387719
PP
3032 # What are the correct thresholds for version 1 && 2 Paul?
3033 if ( $xsubpp_version > 1.923 ){
3034 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
3035 } else {
3036 if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) {
3037 print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp.
3038 Your version of xsubpp is $xsubpp_version and cannot handle this.
3039 Please upgrade to a more recent version of xsubpp.
3040};
3041 } else {
3042 $self->{XSPROTOARG} = "";
3043 }
1e44e2bf
PP
3044 }
3045
f1387719
PP
3046 return qq{
3047XSUBPPDIR = $xsdir
3048XSUBPP = \$(XSUBPPDIR)/xsubpp
3049XSPROTOARG = $self->{XSPROTOARG}
3050XSUBPPDEPS = @tmdeps
3051XSUBPPARGS = @tmargs
3052};
3053};
1e44e2bf 3054
f1387719
PP
3055sub xsubpp_version
3056{
3057 my($self,$xsubpp) = @_;
3058 return $Xsubpp_Version if defined $Xsubpp_Version; # global variable
1e44e2bf 3059
f1387719 3060 my ($version) ;
1e44e2bf 3061
f1387719 3062 # try to figure out the version number of the xsubpp on the system
1e44e2bf 3063
f1387719 3064 # first try the -v flag, introduced in 1.921 & 2.000a2
1e44e2bf 3065
f1387719 3066 return "" unless $self->needs_linking;
1e44e2bf 3067
f1387719
PP
3068 my $command = "$self->{PERL} -I$self->{PERL_LIB} $xsubpp -v 2>&1";
3069 print "Running $command\n" if $Verbose >= 2;
3070 $version = `$command` ;
3071 warn "Running '$command' exits with status " . ($?>>8) if $?;
3072 chop $version ;
1e44e2bf 3073
f1387719 3074 return $Xsubpp_Version = $1 if $version =~ /^xsubpp version (.*)/ ;
1e44e2bf 3075
f1387719 3076 # nope, then try something else
1e44e2bf 3077
f1387719
PP
3078 my $counter = '000';
3079 my ($file) = 'temp' ;
3080 $counter++ while -e "$file$counter"; # don't overwrite anything
3081 $file .= $counter;
1e44e2bf 3082
f1387719
PP
3083 open(F, ">$file") or die "Cannot open file '$file': $!\n" ;
3084 print F <<EOM ;
3085MODULE = fred PACKAGE = fred
1e44e2bf 3086
f1387719
PP
3087int
3088fred(a)
3089 int a;
3090EOM
1e44e2bf 3091
f1387719 3092 close F ;
1e44e2bf 3093
f1387719
PP
3094 $command = "$self->{PERL} $xsubpp $file 2>&1";
3095 print "Running $command\n" if $Verbose >= 2;
3096 my $text = `$command` ;
3097 warn "Running '$command' exits with status " . ($?>>8) if $?;
3098 unlink $file ;
3099
3100 # gets 1.2 -> 1.92 and 2.000a1
3101 return $Xsubpp_Version = $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/ ;
3102
3103 # it is either 1.0 or 1.1
3104 return $Xsubpp_Version = 1.1 if $text =~ /^Warning: ignored semicolon/ ;
3105
3106 # none of the above, so 1.0
3107 return $Xsubpp_Version = "1.0" ;
1e44e2bf
PP
3108}
3109
f1387719 3110=item top_targets (o)
1e44e2bf 3111
f1387719 3112Defines the targets all, subdirs, config, and O_FILES
1e44e2bf
PP
3113
3114=cut
3115
f1387719
PP
3116sub top_targets {
3117# --- Target Sections ---
1e44e2bf 3118
f1387719
PP
3119 my($self) = shift;
3120 my(@m);
3121 push @m, '
3122#all :: config $(INST_PM) subdirs linkext manifypods
68dc0745 3123';
1e44e2bf 3124
68dc0745 3125 push @m, '
f1387719
PP
3126all :: pure_all manifypods
3127 '.$self->{NOECHO}.'$(NOOP)
68dc0745
PP
3128'
3129 unless $self->{SKIPHASH}{'all'};
3130
3131 push @m, '
f1387719
PP
3132pure_all :: config pm_to_blib subdirs linkext
3133 '.$self->{NOECHO}.'$(NOOP)
1e44e2bf 3134
f1387719
PP
3135subdirs :: $(MYEXTLIB)
3136 '.$self->{NOECHO}.'$(NOOP)
1e44e2bf 3137
f1387719
PP
3138config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)/.exists
3139 '.$self->{NOECHO}.'$(NOOP)
3140
3141config :: $(INST_ARCHAUTODIR)/.exists
3142 '.$self->{NOECHO}.'$(NOOP)
3143
3144config :: $(INST_AUTODIR)/.exists
3145 '.$self->{NOECHO}.'$(NOOP)
3146';
3147
3148 push @m, qq{
3149config :: Version_check
3150 $self->{NOECHO}\$(NOOP)
3151
3152} unless $self->{PARENT} or ($self->{PERL_SRC} && $self->{INSTALLDIRS} eq "perl") or $self->{NO_VC};
3153
3154 push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
3155
3156 if (%{$self->{MAN1PODS}}) {
3157 push @m, qq[
3158config :: \$(INST_MAN1DIR)/.exists
3159 $self->{NOECHO}\$(NOOP)
3160
3161];
3162 push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
1e44e2bf 3163 }
f1387719
PP
3164 if (%{$self->{MAN3PODS}}) {
3165 push @m, qq[
3166config :: \$(INST_MAN3DIR)/.exists
3167 $self->{NOECHO}\$(NOOP)
3168
3169];
3170 push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
1e44e2bf 3171 }
1e44e2bf 3172
f1387719
PP
3173 push @m, '
3174$(O_FILES): $(H_FILES)
3175' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
1e44e2bf 3176
f1387719
PP
3177 push @m, q{
3178help:
3179 perldoc ExtUtils::MakeMaker
3180};
1e44e2bf 3181
f1387719
PP
3182 push @m, q{
3183Version_check:
3184 }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
3185 -MExtUtils::MakeMaker=Version_check \
68dc0745 3186 -e "Version_check('$(MM_VERSION)')"
f1387719 3187};
1e44e2bf 3188
f1387719 3189 join('',@m);
1e44e2bf
PP
3190}
3191
3192=item writedoc
3193
f4ae0f5e 3194Obsolete, depecated method. Not used since Version 5.21.
1e44e2bf
PP
3195
3196=cut
3197
3198sub writedoc {
3199# --- perllocal.pod section ---
3200 my($self,$what,$name,@attribs)=@_;
1e44e2bf
PP
3201 my $time = localtime;
3202 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
3203 print join "\n\n=item *\n\n", map("C<$_>",@attribs);
3204 print "\n\n=back\n\n";
3205}
3206
f1387719
PP
3207=item xs_c (o)
3208
3209Defines the suffix rules to compile XS files to C.
3210
3211=cut
3212
3213sub xs_c {
3214 my($self) = shift;
3215 return '' unless $self->needs_linking();
3216 '
3217.xs.c:
68dc0745 3218 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >$*.tc && $(MV) $*.tc $@
f1387719
PP
3219';
3220}
3221
3222=item xs_o (o)
3223
3224Defines suffix rules to go from XS to object files directly. This is
3225only intended for broken make implementations.
3226
3227=cut
3228
3229sub xs_o { # many makes are too dumb to use xs_c then c_o
3230 my($self) = shift;
3231 return '' unless $self->needs_linking();
3232 '
3233.xs$(OBJ_EXT):
68dc0745 3234 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >xstmp.c && $(MV) xstmp.c $*.c
042ade60 3235 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
f1387719
PP
3236';
3237}
3238
68dc0745
PP
3239=item perl_archive
3240
3241This is internal method that returns path to libperl.a equivalent
3242to be linked to dynamic extensions. UNIX does not have one but OS2
3243and Win32 do.
3244
3245=cut
3246
3247sub perl_archive
3248{
3249 return "";
3250}
3251
3252=item export_list
3253
3254This is internal method that returns name of a file that is
3255passed to linker to define symbols to be exported.
3256UNIX does not have one but OS2 and Win32 do.
3257
3258=cut
3259
3260sub export_list
3261{
3262 return "";
3263}
3264
3265
f4ae0f5e
PP
32661;
3267
bab2b58e 3268=back
f4ae0f5e 3269
1e44e2bf
PP
3270=head1 SEE ALSO
3271
3272L<ExtUtils::MakeMaker>
3273
3274=cut
3275
f4ae0f5e 3276__END__