Integrate mainline
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_Win32.pm
CommitLineData
68dc0745 1package ExtUtils::MM_Win32;
2
b75c8c73 3
68dc0745 4=head1 NAME
5
6ExtUtils::MM_Win32 - methods to override UN*X behaviour in ExtUtils::MakeMaker
7
8=head1 SYNOPSIS
9
10 use ExtUtils::MM_Win32; # Done internally by ExtUtils::MakeMaker if needed
11
12=head1 DESCRIPTION
13
14See ExtUtils::MM_Unix for a documentation of the methods provided
15there. This package overrides the implementation of these methods, not
16the semantics.
17
bbc7dcd2 18=over 4
68dc0745 19
20=cut
21
3e3baf6d 22use Config;
68dc0745 23use File::Basename;
ecf68df6 24use File::Spec;
f6d6199c 25use ExtUtils::MakeMaker qw( neatvalue );
68dc0745 26
f6d6199c 27use vars qw(@ISA $VERSION $BORLAND $GCC $DMAKE $NMAKE $PERLMAKE);
28
29require ExtUtils::MM_Any;
30require ExtUtils::MM_Unix;
31@ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix );
75e2e551 32$VERSION = '1.04_01';
68dc0745 33
34$ENV{EMXSHELL} = 'sh'; # to run `commands`
68dc0745 35
3e3baf6d 36$BORLAND = 1 if $Config{'cc'} =~ /^bcc/i;
5b0d9cbe 37$GCC = 1 if $Config{'cc'} =~ /^gcc/i;
3e3baf6d 38$DMAKE = 1 if $Config{'make'} =~ /^dmake/i;
39$NMAKE = 1 if $Config{'make'} =~ /^nmake/i;
dc0d354b 40$PERLMAKE = 1 if $Config{'make'} =~ /^pmake/i;
3e3baf6d 41
68dc0745 42sub dlsyms {
43 my($self,%attribs) = @_;
44
45 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
46 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
762efda7 47 my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
68dc0745 48 my($imports) = $attribs{IMPORTS} || $self->{IMPORTS} || {};
49 my(@m);
50 (my $boot = $self->{NAME}) =~ s/:/_/g;
51
52 if (not $self->{SKIPHASH}{'dynamic'}) {
53 push(@m,"
54$self->{BASEEXT}.def: Makefile.PL
55",
f6d6199c 56 q! $(PERLRUN) -MExtUtils::Mksymlists \\
5e687e55 57 -e "Mksymlists('NAME'=>\"!, $self->{NAME},
58 q!\", 'DLBASE' => '!,$self->{DLBASE},
59 # The above two lines quoted differently to work around
60 # a bug in the 4DOS/4NT command line interpreter. The visible
61 # result of the bug was files named q('extension_name',) *with the
62 # single quotes and the comma* in the extension build directories.
68dc0745 63 q!', 'DL_FUNCS' => !,neatvalue($funcs),
762efda7 64 q!, 'FUNCLIST' => !,neatvalue($funclist),
68dc0745 65 q!, 'IMPORTS' => !,neatvalue($imports),
66 q!, 'DL_VARS' => !, neatvalue($vars), q!);"
67!);
68 }
69 join('',@m);
70}
71
72sub replace_manpage_separator {
73 my($self,$man) = @_;
74 $man =~ s,/+,.,g;
75 $man;
76}
77
78sub maybe_command {
79 my($self,$file) = @_;
846f184a 80 my @e = exists($ENV{'PATHEXT'})
81 ? split(/;/, $ENV{PATHEXT})
82 : qw(.com .exe .bat .cmd);
83 my $e = '';
84 for (@e) { $e .= "\Q$_\E|" }
85 chop $e;
86 # see if file ends in one of the known extensions
2b2708c8 87 if ($file =~ /($e)$/i) {
846f184a 88 return $file if -e $file;
89 }
90 else {
91 for (@e) {
92 return "$file$_" if -e "$file$_";
93 }
94 }
68dc0745 95 return;
96}
97
68dc0745 98
99sub find_perl {
100 my($self, $ver, $names, $dirs, $trace) = @_;
39234879 101 $trace ||= 0;
102
68dc0745 103 my($name, $dir);
104 if ($trace >= 2){
105 print "Looking for perl $ver by these names:
106@$names
107in these dirs:
108@$dirs
109";
110 }
111 foreach $dir (@$dirs){
112 next unless defined $dir; # $self->{PERL_SRC} may be undefined
113 foreach $name (@$names){
114 my ($abs, $val);
f6d6199c 115 if (File::Spec->file_name_is_absolute($name)) { # /foo/bar
68dc0745 116 $abs = $name;
f6d6199c 117 } elsif (File::Spec->canonpath($name) eq
118 File::Spec->canonpath(basename($name))) # foo
119 {
ecf68df6 120 $abs = File::Spec->catfile($dir, $name);
f6d6199c 121 } else { # foo/bar
122 $abs = File::Spec->canonpath(
123 File::Spec->catfile(File::Spec->curdir, $name)
124 );
68dc0745 125 }
126 print "Checking $abs\n" if ($trace >= 2);
127 next unless $self->maybe_command($abs);
128 print "Executing $abs\n" if ($trace >= 2);
f6d6199c 129 (my($safe_abs) = $abs) =~ s{(\s)}{\\$1}g;
130 $val = `$safe_abs -e "require $ver;" 2>&1`;
68dc0745 131 if ($? == 0) {
132 print "Using PERL=$abs\n" if $trace;
133 return $abs;
134 } elsif ($trace >= 2) {
135 print "Result: `$val'\n";
136 }
137 }
138 }
139 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
140 0; # false and not empty
141}
142
68dc0745 143sub init_others
144{
145 my ($self) = @_;
f6d6199c 146 $self->SUPER::init_others;
147 $self->{'TOUCH'} = '$(PERLRUN) -MExtUtils::Command -e touch';
148 $self->{'CHMOD'} = '$(PERLRUN) -MExtUtils::Command -e chmod';
149 $self->{'CP'} = '$(PERLRUN) -MExtUtils::Command -e cp';
150 $self->{'RM_F'} = '$(PERLRUN) -MExtUtils::Command -e rm_f';
151 $self->{'RM_RF'} = '$(PERLRUN) -MExtUtils::Command -e rm_rf';
152 $self->{'MV'} = '$(PERLRUN) -MExtUtils::Command -e mv';
68dc0745 153 $self->{'NOOP'} = 'rem';
f6d6199c 154 $self->{'TEST_F'} = '$(PERLRUN) -MExtUtils::Command -e test_f';
3e3baf6d 155 $self->{'LD'} = $Config{'ld'} || 'link';
156 $self->{'AR'} = $Config{'ar'} || 'lib';
944acd49 157 $self->{'LDLOADLIBS'} ||= $Config{'libs'};
e47a9bbc 158 # -Lfoo must come first for Borland, so we put it in LDDLFLAGS
944acd49 159 if ($BORLAND) {
160 my $libs = $self->{'LDLOADLIBS'};
161 my $libpath = '';
e47a9bbc 162 while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) {
944acd49 163 $libpath .= ' ' if length $libpath;
164 $libpath .= $1;
165 }
166 $self->{'LDLOADLIBS'} = $libs;
167 $self->{'LDDLFLAGS'} ||= $Config{'lddlflags'};
168 $self->{'LDDLFLAGS'} .= " $libpath";
169 }
68dc0745 170 $self->{'DEV_NULL'} = '> NUL';
68dc0745 171}
172
3e3baf6d 173
174=item constants (o)
175
176Initializes lots of constants and .SUFFIXES and .PHONY
177
178=cut
179
180sub constants {
181 my($self) = @_;
182 my(@m,$tmp);
183
184 for $tmp (qw/
185
186 AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION
80a5d8e7 187 VERSION_SYM XS_VERSION INST_BIN INST_LIB
3e3baf6d 188 INST_ARCHLIB INST_SCRIPT PREFIX INSTALLDIRS
189 INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB
190 INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB
191 PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
192 FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC
75e2e551 193 PERL_INC PERL FULLPERL PERLRUN FULLPERLRUN PERLRUNINST
80a5d8e7 194 FULLPERLRUNINST ABSPERL ABSPERLRUN ABSPERLRUNINST
195 FULL_AR PERL_CORE
3e3baf6d 196
197 / ) {
198 next unless defined $self->{$tmp};
199 push @m, "$tmp = $self->{$tmp}\n";
200 }
201
202 push @m, qq{
203VERSION_MACRO = VERSION
204DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
205XS_VERSION_MACRO = XS_VERSION
206XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
207};
208
209 push @m, qq{
39234879 210MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'}
3e3baf6d 211MM_VERSION = $ExtUtils::MakeMaker::VERSION
212};
213
214 push @m, q{
215# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
216# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
3e3baf6d 217# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
218# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
219};
220
221 for $tmp (qw/
222 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
223 LDFROM LINKTYPE
224 / ) {
225 next unless defined $self->{$tmp};
226 push @m, "$tmp = $self->{$tmp}\n";
227 }
228
229 push @m, "
230# Handy lists of source code files:
231XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
232C_FILES = ".join(" \\\n\t", @{$self->{C}})."
233O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
234H_FILES = ".join(" \\\n\t", @{$self->{H}})."
235MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
236MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
237";
238
239 for $tmp (qw/
cae6c631 240 INST_MAN1DIR INSTALLMAN1DIR MAN1EXT
241 INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
3e3baf6d 242 /) {
243 next unless defined $self->{$tmp};
244 push @m, "$tmp = $self->{$tmp}\n";
245 }
246
247 push @m, qq{
248.USESHELL :
249} if $DMAKE;
250
251 push @m, q{
252.NO_CONFIG_REC: Makefile
253} if $ENV{CLEARCASE_ROOT};
254
255 # why not q{} ? -- emacs
256 push @m, qq{
257# work around a famous dec-osf make(1) feature(?):
258makemakerdflt: all
259
260.SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
261
39234879 262# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to
263# recall, that some make implementations will delete the Makefile when we
264# rebuild it. Because we call false(1) when we rebuild it. So make(1) is
265# not completely wrong when it does so. Our milage may vary.
3e3baf6d 266# .PRECIOUS: Makefile # seems to be not necessary anymore
267
268.PHONY: all config static dynamic test linkext manifest
269
270# Where is the Config information that we are using/depend on
271CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h
272};
273
274 my @parentdir = split(/::/, $self->{PARENT_NAME});
275 push @m, q{
276# Where to put things:
ecf68df6 277INST_LIBDIR = }. File::Spec->catdir('$(INST_LIB)',@parentdir) .q{
278INST_ARCHLIBDIR = }. File::Spec->catdir('$(INST_ARCHLIB)',@parentdir) .q{
3e3baf6d 279
ecf68df6 280INST_AUTODIR = }. File::Spec->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
281INST_ARCHAUTODIR = }. File::Spec->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
3e3baf6d 282};
283
284 if ($self->has_link_code()) {
285 push @m, '
286INST_STATIC = $(INST_ARCHAUTODIR)\$(BASEEXT)$(LIB_EXT)
287INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT)
288INST_BOOT = $(INST_ARCHAUTODIR)\$(BASEEXT).bs
289';
290 } else {
291 push @m, '
292INST_STATIC =
293INST_DYNAMIC =
294INST_BOOT =
295';
296 }
297
298 $tmp = $self->export_list;
299 push @m, "
300EXPORT_LIST = $tmp
301";
302 $tmp = $self->perl_archive;
303 push @m, "
304PERL_ARCHIVE = $tmp
305";
306
3e3baf6d 307 push @m, q{
308TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
309
310PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
311};
312
313 join('',@m);
314}
315
316
68dc0745 317=item static_lib (o)
318
319Defines how to produce the *.a (or equivalent) files.
320
321=cut
322
323sub static_lib {
324 my($self) = @_;
325# Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
326# return '' unless $self->needs_linking(); #might be because of a subdir
327
328 return '' unless $self->has_link_code;
329
330 my(@m);
331 push(@m, <<'END');
3e3baf6d 332$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)\.exists
68dc0745 333 $(RM_RF) $@
334END
022735b4 335 # If this extension has its own library (eg SDBM_File)
68dc0745 336 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
337 push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
338
339 push @m,
910dfcc8 340q{ $(AR) }.($BORLAND ? '$@ $(OBJECT:^"+")'
341 : ($GCC ? '-ru $@ $(OBJECT)'
342 : '-out:$@ $(OBJECT)')).q{
3e3baf6d 343 }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld
68dc0745 344 $(CHMOD) 755 $@
345};
346
347# Old mechanism - still available:
348
3e3baf6d 349 push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs}."\n\n"
68dc0745 350 if $self->{PERL_SRC};
351
352 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
353 join('', "\n",@m);
354}
355
3e3baf6d 356=item dynamic_bs (o)
357
358Defines targets for bootstrap files.
359
360=cut
68dc0745 361
3e3baf6d 362sub dynamic_bs {
363 my($self, %attribs) = @_;
364 return '
365BOOTSTRAP =
366' unless $self->has_link_code();
367
368 return '
369BOOTSTRAP = '."$self->{BASEEXT}.bs".'
370
371# As Mkbootstrap might not write a file (if none is required)
372# we use touch to prevent make continually trying to remake it.
373# The DynaLoader only reads a non-empty file.
374$(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)\.exists
375 '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
f6d6199c 376 '.$self->{NOECHO}.'$(PERLRUN) \
3e3baf6d 377 -MExtUtils::Mkbootstrap \
378 -e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
379 '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP)
380 $(CHMOD) 644 $@
381
382$(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists
383 '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT)
384 -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT)
385 $(CHMOD) 644 $@
386';
387}
68dc0745 388
389=item dynamic_lib (o)
390
391Defines how to produce the *.so (or equivalent) files.
392
393=cut
394
395sub dynamic_lib {
396 my($self, %attribs) = @_;
397 return '' unless $self->needs_linking(); #might be because of a subdir
398
399 return '' unless $self->has_link_code;
400
3e3baf6d 401 my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
68dc0745 402 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
403 my($ldfrom) = '$(LDFROM)';
404 my(@m);
7a958ec3 405
5db10396 406# one thing for GCC/Mingw32:
407# we try to overcome non-relocateable-DLL problems by generating
7a958ec3 408# a (hopefully unique) image-base from the dll's name
409# -- BKS, 10-19-1999
410 if ($GCC) {
7a958ec3 411 my $dllname = $self->{BASEEXT} . "." . $self->{DLEXT};
412 $dllname =~ /(....)(.{0,4})/;
413 my $baseaddr = unpack("n", $1 ^ $2);
414 $otherldflags .= sprintf("-Wl,--image-base,0x%x0000 ", $baseaddr);
415 }
416
68dc0745 417 push(@m,'
418# This section creates the dynamically loadable $(INST_DYNAMIC)
419# from $(OBJECT) and possibly $(MYEXTLIB).
420OTHERLDFLAGS = '.$otherldflags.'
421INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
422
3e3baf6d 423$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
68dc0745 424');
5b0d9cbe 425 if ($GCC) {
426 push(@m,
910dfcc8 427 q{ dlltool --def $(EXPORT_LIST) --output-exp dll.exp
428 $(LD) -o $@ -Wl,--base-file -Wl,dll.base $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp
5b0d9cbe 429 dlltool --def $(EXPORT_LIST) --base-file dll.base --output-exp dll.exp
430 $(LD) -o $@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp });
dc0d354b 431 } elsif ($BORLAND) {
432 push(@m,
433 q{ $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) }.$ldfrom.q{,$@,,}
434 .($DMAKE ? q{$(PERL_ARCHIVE:s,/,\,) $(LDLOADLIBS:s,/,\,) }
435 .q{$(MYEXTLIB:s,/,\,),$(EXPORT_LIST:s,/,\,)}
436 : q{$(subst /,\,$(PERL_ARCHIVE)) $(subst /,\,$(LDLOADLIBS)) }
437 .q{$(subst /,\,$(MYEXTLIB)),$(subst /,\,$(EXPORT_LIST))})
438 .q{,$(RESFILES)});
439 } else { # VC
440 push(@m,
441 q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) }
442 .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)});
5b0d9cbe 443 }
68dc0745 444 push @m, '
445 $(CHMOD) 755 $@
446';
447
448 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
449 join('',@m);
450}
451
562c1c19 452sub clean
453{
f6d6199c 454 my ($self) = shift;
455 my $s = $self->SUPER::clean(@_);
1f50c5a9 456 my $clean = $GCC ? 'dll.base dll.exp' : '*.pdb';
457 $s .= <<END;
562c1c19 458clean ::
1f50c5a9 459 -\$(RM_F) $clean
562c1c19 460
461END
1f50c5a9 462 return $s;
562c1c19 463}
464
465
466
68dc0745 467sub perl_archive
468{
e3b8966e 469 my ($self) = @_;
eda5ff31 470 return '$(PERL_INC)\\'.$Config{'libperl'};
68dc0745 471}
472
473sub export_list
474{
475 my ($self) = @_;
476 return "$self->{BASEEXT}.def";
477}
478
68dc0745 479=item perl_script
480
481Takes one argument, a file name, and returns the file name, if the
482argument is likely to be a perl script. On MM_Unix this is true for
483any ordinary, readable file.
484
485=cut
486
487sub perl_script {
488 my($self,$file) = @_;
cae6c631 489 return $file if -r $file && -f _;
68dc0745 490 return "$file.pl" if -r "$file.pl" && -f _;
cae6c631 491 return "$file.bat" if -r "$file.bat" && -f _;
68dc0745 492 return;
493}
494
495=item pm_to_blib
496
497Defines target that copies all files in the hash PM to their
498destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
499
500=cut
501
502sub pm_to_blib {
503 my $self = shift;
ecf68df6 504 my($autodir) = File::Spec->catdir('$(INST_LIB)','auto');
68dc0745 505 return q{
506pm_to_blib: $(TO_INST_PM)
f6d6199c 507 }.$self->{NOECHO}.q{$(PERLRUNINST) -MExtUtils::Install \
dc0d354b 508 -e "pm_to_blib(}.
509 ($NMAKE ? 'qw[ <<pmfiles.dat ],'
510 : $DMAKE ? 'qw[ $(mktmp,pmfiles.dat $(PM_TO_BLIB:s,\\,\\\\,)\n) ],'
511 : '{ qw[$(PM_TO_BLIB)] },'
131aa089 512 ).q{'}.$autodir.q{','$(PM_FILTER)')"
80a5d8e7 513}. ($NMAKE ? q{
68dc0745 514$(PM_TO_BLIB)
515<<
3e3baf6d 516 } : '') . $self->{NOECHO}.q{$(TOUCH) $@
68dc0745 517};
518}
519
3e3baf6d 520
68dc0745 521=item tool_autosplit (override)
522
523Use Win32 quoting on command line.
524
525=cut
526
527sub tool_autosplit{
528 my($self, %attribs) = @_;
529 my($asl) = "";
530 $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
531 q{
532# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
f6d6199c 533AUTOSPLITFILE = $(PERLRUN) -MAutoSplit }.$asl.q{ -e "autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1);"
68dc0745 534};
535}
536
537=item tools_other (o)
538
539Win32 overrides.
540
541Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in
542the Makefile. Also defines the perl programs MKPATH,
543WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL.
544
545=cut
546
547sub tools_other {
548 my($self) = shift;
549 my @m;
550 my $bin_sh = $Config{sh} || 'cmd /c';
551 push @m, qq{
552SHELL = $bin_sh
3e3baf6d 553} unless $DMAKE; # dmake determines its own shell
68dc0745 554
555 for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) {
556 push @m, "$_ = $self->{$_}\n";
557 }
558
559 push @m, q{
560# The following is a portable way to say mkdir -p
561# To see which directories are created, change the if 0 to if 1
f6d6199c 562MKPATH = $(PERLRUN) -MExtUtils::Command -e mkpath
68dc0745 563
564# This helps us to minimize the effect of the .exists files A yet
565# better solution would be to have a stable file in the perl
566# distribution with a timestamp of zero. But this solution doesn't
567# need any changes to the core distribution and works with older perls
f6d6199c 568EQUALIZE_TIMESTAMP = $(PERLRUN) -MExtUtils::Command -e eqtime
68dc0745 569};
570
571
572 return join "", @m if $self->{PARENT};
573
574 push @m, q{
575# Here we warn users that an old packlist file was found somewhere,
576# and that they should call some uninstall routine
577WARN_IF_OLD_PACKLIST = $(PERL) -lwe "exit unless -f $$ARGV[0];" \\
578-e "print 'WARNING: I have found an old package in';" \\
579-e "print ' ', $$ARGV[0], '.';" \\
580-e "print 'Please make sure the two installations are not conflicting';"
581
582UNINST=0
583VERBINST=1
584
585MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \
3e3baf6d 586-e "install({ @ARGV },'$(VERBINST)',0,'$(UNINST)');"
68dc0745 587
588DOC_INSTALL = $(PERL) -e "$$\=\"\n\n\";" \
83bb2f05 589-e "print '=head2 ', scalar(localtime), ': C<', shift, '>', ' L<', $$arg=shift, '|', $$arg, '>';" \
68dc0745 590-e "print '=over 4';" \
3e3baf6d 591-e "while (defined($$key = shift) and defined($$val = shift)) { print '=item *';print 'C<', \"$$key: $$val\", '>'; }" \
68dc0745 592-e "print '=back';"
593
594UNINSTALL = $(PERL) -MExtUtils::Install \
595-e "uninstall($$ARGV[0],1,1); print \"\nUninstall is deprecated. Please check the";" \
596-e "print \" packlist above carefully.\n There may be errors. Remove the\";" \
597-e "print \" appropriate files manually.\n Sorry for the inconveniences.\n\""
598};
599
600 return join "", @m;
601}
602
3e3baf6d 603=item xs_o (o)
604
605Defines suffix rules to go from XS to object files directly. This is
606only intended for broken make implementations.
607
608=cut
609
610sub xs_o { # many makes are too dumb to use xs_c then c_o
611 my($self) = shift;
612 return ''
613}
614
615=item top_targets (o)
616
617Defines the targets all, subdirs, config, and O_FILES
618
619=cut
620
621sub top_targets {
622# --- Target Sections ---
623
624 my($self) = shift;
625 my(@m);
3e3baf6d 626
627 push @m, '
f6d6199c 628all :: pure_all manifypods
3e3baf6d 629 '.$self->{NOECHO}.'$(NOOP)
630'
631 unless $self->{SKIPHASH}{'all'};
632
633 push @m, '
634pure_all :: config pm_to_blib subdirs linkext
635 '.$self->{NOECHO}.'$(NOOP)
636
637subdirs :: $(MYEXTLIB)
638 '.$self->{NOECHO}.'$(NOOP)
639
640config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)\.exists
641 '.$self->{NOECHO}.'$(NOOP)
642
643config :: $(INST_ARCHAUTODIR)\.exists
644 '.$self->{NOECHO}.'$(NOOP)
645
646config :: $(INST_AUTODIR)\.exists
647 '.$self->{NOECHO}.'$(NOOP)
648';
649
3e3baf6d 650 push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
651
652 if (%{$self->{MAN1PODS}}) {
653 push @m, qq[
654config :: \$(INST_MAN1DIR)\\.exists
655 $self->{NOECHO}\$(NOOP)
656
657];
658 push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
659 }
660 if (%{$self->{MAN3PODS}}) {
661 push @m, qq[
662config :: \$(INST_MAN3DIR)\\.exists
663 $self->{NOECHO}\$(NOOP)
664
665];
666 push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
667 }
668
669 push @m, '
670$(O_FILES): $(H_FILES)
671' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
672
673 push @m, q{
674help:
675 perldoc ExtUtils::MakeMaker
676};
677
3e3baf6d 678 join('',@m);
679}
680
68dc0745 681=item manifypods (o)
682
cae6c631 683We don't want manpage process.
68dc0745 684
685=cut
686
687sub manifypods {
846f184a 688 my($self) = shift;
68dc0745 689 return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n";
690}
691
692=item dist_ci (o)
693
694Same as MM_Unix version (changes command-line quoting).
695
696=cut
697
698sub dist_ci {
699 my($self) = shift;
700 my @m;
701 push @m, q{
702ci :
f6d6199c 703 $(PERLRUN) -MExtUtils::Manifest=maniread \\
68dc0745 704 -e "@all = keys %{ maniread() };" \\
705 -e "print(\"Executing $(CI) @all\n\"); system(\"$(CI) @all\");" \\
706 -e "print(\"Executing $(RCS_LABEL) ...\n\"); system(\"$(RCS_LABEL) @all\");"
707};
708 join "", @m;
709}
710
711=item dist_core (o)
712
713Same as MM_Unix version (changes command-line quoting).
714
715=cut
716
717sub dist_core {
718 my($self) = shift;
719 my @m;
720 push @m, q{
721dist : $(DIST_DEFAULT)
722 }.$self->{NOECHO}.q{$(PERL) -le "print \"Warning: Makefile possibly out of date with $$vf\" if " \
723 -e "-e ($$vf=\"$(VERSION_FROM)\") and -M $$vf < -M \"}.$self->{MAKEFILE}.q{\";"
724
725tardist : $(DISTVNAME).tar$(SUFFIX)
726
727zipdist : $(DISTVNAME).zip
728
729$(DISTVNAME).tar$(SUFFIX) : distdir
730 $(PREOP)
731 $(TO_UNIX)
732 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
733 $(RM_RF) $(DISTVNAME)
734 $(COMPRESS) $(DISTVNAME).tar
735 $(POSTOP)
736
737$(DISTVNAME).zip : distdir
738 $(PREOP)
739 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
740 $(RM_RF) $(DISTVNAME)
741 $(POSTOP)
742
743uutardist : $(DISTVNAME).tar$(SUFFIX)
744 uuencode $(DISTVNAME).tar$(SUFFIX) \\
745 $(DISTVNAME).tar$(SUFFIX) > \\
746 $(DISTVNAME).tar$(SUFFIX)_uu
747
748shdist : distdir
749 $(PREOP)
750 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
751 $(RM_RF) $(DISTVNAME)
752 $(POSTOP)
753};
754 join "", @m;
755}
756
757=item pasthru (o)
758
759Defines the string that is passed to recursive make calls in
760subdirectories.
761
762=cut
763
764sub pasthru {
765 my($self) = shift;
3e3baf6d 766 return "PASTHRU = " . ($NMAKE ? "-nologo" : "");
68dc0745 767}
768
769
68dc0745 7701;
771__END__
772
773=back
774
775=cut
776
5b0d9cbe 777