This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[ID 19991104.005] modified hints file for UnixWare7 ( svr5)
[perl5.git] / lib / ExtUtils / MM_Win32.pm
CommitLineData
68dc0745
PP
1package ExtUtils::MM_Win32;
2
3=head1 NAME
4
5ExtUtils::MM_Win32 - methods to override UN*X behaviour in ExtUtils::MakeMaker
6
7=head1 SYNOPSIS
8
9 use ExtUtils::MM_Win32; # Done internally by ExtUtils::MakeMaker if needed
10
11=head1 DESCRIPTION
12
13See ExtUtils::MM_Unix for a documentation of the methods provided
14there. This package overrides the implementation of these methods, not
15the semantics.
16
17=over
18
19=cut
20
3e3baf6d 21use Config;
68dc0745
PP
22#use Cwd;
23use File::Basename;
24require Exporter;
25
26Exporter::import('ExtUtils::MakeMaker',
27 qw( $Verbose &neatvalue));
28
29$ENV{EMXSHELL} = 'sh'; # to run `commands`
30unshift @MM::ISA, 'ExtUtils::MM_Win32';
31
3e3baf6d 32$BORLAND = 1 if $Config{'cc'} =~ /^bcc/i;
5b0d9cbe 33$GCC = 1 if $Config{'cc'} =~ /^gcc/i;
3e3baf6d
TB
34$DMAKE = 1 if $Config{'make'} =~ /^dmake/i;
35$NMAKE = 1 if $Config{'make'} =~ /^nmake/i;
dc0d354b 36$PERLMAKE = 1 if $Config{'make'} =~ /^pmake/i;
9d8a25dc 37$OBJ = 1 if $Config{'ccflags'} =~ /PERL_OBJECT/i;
3e3baf6d 38
8ec44883
GS
39# a few workarounds for command.com (very basic)
40if (Win32::IsWin95()) {
41 package ExtUtils::MM_Win95;
42 unshift @MM::ISA, 'ExtUtils::MM_Win95';
43
44 sub xs_c {
45 my($self) = shift;
46 return '' unless $self->needs_linking();
47 '
48.xs.c:
49 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) \\
50 $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.c
51 '
52 }
53
54 sub xs_cpp {
55 my($self) = shift;
56 return '' unless $self->needs_linking();
57 '
58.xs.cpp:
59 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) \\
60 $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.cpp
61 ';
62 }
63
64 # many makes are too dumb to use xs_c then c_o
65 sub xs_o {
66 my($self) = shift;
67 return '' unless $self->needs_linking();
68 # Dmake gets confused with 2 ways of making things
69 return '' if $ExtUtils::MM_Win32::DMAKE;
70 '
71.xs$(OBJ_EXT):
72 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) \\
73 $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.c
74 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
75 ';
76 }
77}
78
68dc0745
PP
79sub dlsyms {
80 my($self,%attribs) = @_;
81
82 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
83 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
762efda7 84 my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
68dc0745
PP
85 my($imports) = $attribs{IMPORTS} || $self->{IMPORTS} || {};
86 my(@m);
87 (my $boot = $self->{NAME}) =~ s/:/_/g;
88
89 if (not $self->{SKIPHASH}{'dynamic'}) {
90 push(@m,"
91$self->{BASEEXT}.def: Makefile.PL
92",
93 q! $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Mksymlists \\
94 -e "Mksymlists('NAME' => '!, $self->{NAME},
95 q!', 'DLBASE' => '!,$self->{DLBASE},
96 q!', 'DL_FUNCS' => !,neatvalue($funcs),
762efda7 97 q!, 'FUNCLIST' => !,neatvalue($funclist),
68dc0745
PP
98 q!, 'IMPORTS' => !,neatvalue($imports),
99 q!, 'DL_VARS' => !, neatvalue($vars), q!);"
100!);
101 }
102 join('',@m);
103}
104
105sub replace_manpage_separator {
106 my($self,$man) = @_;
107 $man =~ s,/+,.,g;
108 $man;
109}
110
111sub maybe_command {
112 my($self,$file) = @_;
846f184a
GS
113 my @e = exists($ENV{'PATHEXT'})
114 ? split(/;/, $ENV{PATHEXT})
115 : qw(.com .exe .bat .cmd);
116 my $e = '';
117 for (@e) { $e .= "\Q$_\E|" }
118 chop $e;
119 # see if file ends in one of the known extensions
2b2708c8 120 if ($file =~ /($e)$/i) {
846f184a
GS
121 return $file if -e $file;
122 }
123 else {
124 for (@e) {
125 return "$file$_" if -e "$file$_";
126 }
127 }
68dc0745
PP
128 return;
129}
130
131sub file_name_is_absolute {
132 my($self,$file) = @_;
133 $file =~ m{^([a-z]:)?[\\/]}i ;
134}
135
136sub find_perl {
137 my($self, $ver, $names, $dirs, $trace) = @_;
138 my($name, $dir);
139 if ($trace >= 2){
140 print "Looking for perl $ver by these names:
141@$names
142in these dirs:
143@$dirs
144";
145 }
146 foreach $dir (@$dirs){
147 next unless defined $dir; # $self->{PERL_SRC} may be undefined
148 foreach $name (@$names){
149 my ($abs, $val);
150 if ($self->file_name_is_absolute($name)) { # /foo/bar
151 $abs = $name;
152 } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # foo
153 $abs = $self->catfile($dir, $name);
154 } else { # foo/bar
155 $abs = $self->canonpath($self->catfile($self->curdir, $name));
156 }
157 print "Checking $abs\n" if ($trace >= 2);
158 next unless $self->maybe_command($abs);
159 print "Executing $abs\n" if ($trace >= 2);
160 $val = `$abs -e "require $ver;" 2>&1`;
161 if ($? == 0) {
162 print "Using PERL=$abs\n" if $trace;
163 return $abs;
164 } elsif ($trace >= 2) {
165 print "Result: `$val'\n";
166 }
167 }
168 }
169 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
170 0; # false and not empty
171}
172
173sub catdir {
174 my $self = shift;
175 my @args = @_;
176 for (@args) {
177 # append a slash to each argument unless it has one there
178 $_ .= "\\" if $_ eq '' or substr($_,-1) ne "\\";
179 }
180 my $result = $self->canonpath(join('', @args));
181 $result;
182}
183
184=item catfile
185
186Concatenate one or more directory names and a filename to form a
187complete path ending with a filename
188
189=cut
190
191sub catfile {
192 my $self = shift @_;
193 my $file = pop @_;
194 return $file unless @_;
195 my $dir = $self->catdir(@_);
96e4d5b1
PP
196 $dir =~ s/(\\\.)$//;
197 $dir .= "\\" unless substr($dir,length($dir)-1,1) eq "\\";
68dc0745
PP
198 return $dir.$file;
199}
200
201sub init_others
202{
203 my ($self) = @_;
204 &ExtUtils::MM_Unix::init_others;
205 $self->{'TOUCH'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e touch';
206 $self->{'CHMOD'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e chmod';
207 $self->{'CP'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e cp';
208 $self->{'RM_F'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e rm_f';
209 $self->{'RM_RF'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e rm_rf';
210 $self->{'MV'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mv';
211 $self->{'NOOP'} = 'rem';
212 $self->{'TEST_F'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e test_f';
3e3baf6d
TB
213 $self->{'LD'} = $Config{'ld'} || 'link';
214 $self->{'AR'} = $Config{'ar'} || 'lib';
944acd49 215 $self->{'LDLOADLIBS'} ||= $Config{'libs'};
e47a9bbc 216 # -Lfoo must come first for Borland, so we put it in LDDLFLAGS
944acd49
GS
217 if ($BORLAND) {
218 my $libs = $self->{'LDLOADLIBS'};
219 my $libpath = '';
e47a9bbc 220 while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) {
944acd49
GS
221 $libpath .= ' ' if length $libpath;
222 $libpath .= $1;
223 }
224 $self->{'LDLOADLIBS'} = $libs;
225 $self->{'LDDLFLAGS'} ||= $Config{'lddlflags'};
226 $self->{'LDDLFLAGS'} .= " $libpath";
227 }
68dc0745
PP
228 $self->{'DEV_NULL'} = '> NUL';
229 # $self->{'NOECHO'} = ''; # till we have it working
230}
231
3e3baf6d
TB
232
233=item constants (o)
234
235Initializes lots of constants and .SUFFIXES and .PHONY
236
237=cut
238
239sub constants {
240 my($self) = @_;
241 my(@m,$tmp);
242
243 for $tmp (qw/
244
245 AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION
246 VERSION_SYM XS_VERSION INST_BIN INST_EXE INST_LIB
247 INST_ARCHLIB INST_SCRIPT PREFIX INSTALLDIRS
248 INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB
249 INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB
250 PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
251 FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC
252 PERL_INC PERL FULLPERL
253
254 / ) {
255 next unless defined $self->{$tmp};
256 push @m, "$tmp = $self->{$tmp}\n";
257 }
258
259 push @m, qq{
260VERSION_MACRO = VERSION
261DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
262XS_VERSION_MACRO = XS_VERSION
263XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
264};
265
266 push @m, qq{
267MAKEMAKER = $INC{'ExtUtils\MakeMaker.pm'}
268MM_VERSION = $ExtUtils::MakeMaker::VERSION
269};
270
271 push @m, q{
272# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
273# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
274# ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) !!! Deprecated from MM 5.32 !!!
275# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
276# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
277};
278
279 for $tmp (qw/
280 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
281 LDFROM LINKTYPE
282 / ) {
283 next unless defined $self->{$tmp};
284 push @m, "$tmp = $self->{$tmp}\n";
285 }
286
287 push @m, "
288# Handy lists of source code files:
289XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
290C_FILES = ".join(" \\\n\t", @{$self->{C}})."
291O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
292H_FILES = ".join(" \\\n\t", @{$self->{H}})."
cae6c631
JD
293HTMLLIBPODS = ".join(" \\\n\t", sort keys %{$self->{HTMLLIBPODS}})."
294HTMLSCRIPTPODS = ".join(" \\\n\t", sort keys %{$self->{HTMLSCRIPTPODS}})."
3e3baf6d
TB
295MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
296MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
297";
298
299 for $tmp (qw/
cae6c631
JD
300 INST_HTMLPRIVLIBDIR INSTALLHTMLPRIVLIBDIR
301 INST_HTMLSITELIBDIR INSTALLHTMLSITELIBDIR
302 INST_HTMLSCRIPTDIR INSTALLHTMLSCRIPTDIR
303 INST_HTMLLIBDIR HTMLEXT
304 INST_MAN1DIR INSTALLMAN1DIR MAN1EXT
305 INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
3e3baf6d
TB
306 /) {
307 next unless defined $self->{$tmp};
308 push @m, "$tmp = $self->{$tmp}\n";
309 }
310
311 push @m, qq{
312.USESHELL :
313} if $DMAKE;
314
315 push @m, q{
316.NO_CONFIG_REC: Makefile
317} if $ENV{CLEARCASE_ROOT};
318
319 # why not q{} ? -- emacs
320 push @m, qq{
321# work around a famous dec-osf make(1) feature(?):
322makemakerdflt: all
323
324.SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
325
326# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
327# some make implementations will delete the Makefile when we rebuild it. Because
328# we call false(1) when we rebuild it. So make(1) is not completely wrong when it
329# does so. Our milage may vary.
330# .PRECIOUS: Makefile # seems to be not necessary anymore
331
332.PHONY: all config static dynamic test linkext manifest
333
334# Where is the Config information that we are using/depend on
335CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h
336};
337
338 my @parentdir = split(/::/, $self->{PARENT_NAME});
339 push @m, q{
340# Where to put things:
341INST_LIBDIR = }. $self->catdir('$(INST_LIB)',@parentdir) .q{
342INST_ARCHLIBDIR = }. $self->catdir('$(INST_ARCHLIB)',@parentdir) .q{
343
344INST_AUTODIR = }. $self->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
345INST_ARCHAUTODIR = }. $self->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
346};
347
348 if ($self->has_link_code()) {
349 push @m, '
350INST_STATIC = $(INST_ARCHAUTODIR)\$(BASEEXT)$(LIB_EXT)
351INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT)
352INST_BOOT = $(INST_ARCHAUTODIR)\$(BASEEXT).bs
353';
354 } else {
355 push @m, '
356INST_STATIC =
357INST_DYNAMIC =
358INST_BOOT =
359';
360 }
361
362 $tmp = $self->export_list;
363 push @m, "
364EXPORT_LIST = $tmp
365";
366 $tmp = $self->perl_archive;
367 push @m, "
368PERL_ARCHIVE = $tmp
369";
370
371# push @m, q{
372#INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{
373#
374#PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
375#};
376
377 push @m, q{
378TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
379
380PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
381};
382
383 join('',@m);
384}
385
386
68dc0745
PP
387sub path {
388 local $^W = 1;
389 my($self) = @_;
390 my $path = $ENV{'PATH'} || $ENV{'Path'} || $ENV{'path'};
391 my @path = split(';',$path);
392 foreach(@path) { $_ = '.' if $_ eq '' }
393 @path;
394}
395
396=item static_lib (o)
397
398Defines how to produce the *.a (or equivalent) files.
399
400=cut
401
402sub static_lib {
403 my($self) = @_;
404# Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
405# return '' unless $self->needs_linking(); #might be because of a subdir
406
407 return '' unless $self->has_link_code;
408
409 my(@m);
410 push(@m, <<'END');
3e3baf6d 411$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)\.exists
68dc0745
PP
412 $(RM_RF) $@
413END
414 # If this extension has it's own library (eg SDBM_File)
415 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
416 push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
417
418 push @m,
910dfcc8
GS
419q{ $(AR) }.($BORLAND ? '$@ $(OBJECT:^"+")'
420 : ($GCC ? '-ru $@ $(OBJECT)'
421 : '-out:$@ $(OBJECT)')).q{
3e3baf6d 422 }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld
68dc0745
PP
423 $(CHMOD) 755 $@
424};
425
426# Old mechanism - still available:
427
3e3baf6d 428 push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs}."\n\n"
68dc0745
PP
429 if $self->{PERL_SRC};
430
431 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
432 join('', "\n",@m);
433}
434
3e3baf6d
TB
435=item dynamic_bs (o)
436
437Defines targets for bootstrap files.
438
439=cut
68dc0745 440
3e3baf6d
TB
441sub dynamic_bs {
442 my($self, %attribs) = @_;
443 return '
444BOOTSTRAP =
445' unless $self->has_link_code();
446
447 return '
448BOOTSTRAP = '."$self->{BASEEXT}.bs".'
449
450# As Mkbootstrap might not write a file (if none is required)
451# we use touch to prevent make continually trying to remake it.
452# The DynaLoader only reads a non-empty file.
453$(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)\.exists
454 '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
455 '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
456 -MExtUtils::Mkbootstrap \
457 -e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
458 '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP)
459 $(CHMOD) 644 $@
460
461$(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists
462 '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT)
463 -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT)
464 $(CHMOD) 644 $@
465';
466}
68dc0745
PP
467
468=item dynamic_lib (o)
469
470Defines how to produce the *.so (or equivalent) files.
471
472=cut
473
474sub dynamic_lib {
475 my($self, %attribs) = @_;
476 return '' unless $self->needs_linking(); #might be because of a subdir
477
478 return '' unless $self->has_link_code;
479
3e3baf6d 480 my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
68dc0745
PP
481 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
482 my($ldfrom) = '$(LDFROM)';
483 my(@m);
484 push(@m,'
485# This section creates the dynamically loadable $(INST_DYNAMIC)
486# from $(OBJECT) and possibly $(MYEXTLIB).
487OTHERLDFLAGS = '.$otherldflags.'
488INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
489
3e3baf6d 490$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
68dc0745 491');
5b0d9cbe
NIS
492 if ($GCC) {
493 push(@m,
910dfcc8
GS
494 q{ dlltool --def $(EXPORT_LIST) --output-exp dll.exp
495 $(LD) -o $@ -Wl,--base-file -Wl,dll.base $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp
5b0d9cbe
NIS
496 dlltool --def $(EXPORT_LIST) --base-file dll.base --output-exp dll.exp
497 $(LD) -o $@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp });
dc0d354b
GS
498 } elsif ($BORLAND) {
499 push(@m,
500 q{ $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) }.$ldfrom.q{,$@,,}
501 .($DMAKE ? q{$(PERL_ARCHIVE:s,/,\,) $(LDLOADLIBS:s,/,\,) }
502 .q{$(MYEXTLIB:s,/,\,),$(EXPORT_LIST:s,/,\,)}
503 : q{$(subst /,\,$(PERL_ARCHIVE)) $(subst /,\,$(LDLOADLIBS)) }
504 .q{$(subst /,\,$(MYEXTLIB)),$(subst /,\,$(EXPORT_LIST))})
505 .q{,$(RESFILES)});
506 } else { # VC
507 push(@m,
508 q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) }
509 .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)});
5b0d9cbe 510 }
68dc0745
PP
511 push @m, '
512 $(CHMOD) 755 $@
513';
514
515 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
516 join('',@m);
517}
518
519sub perl_archive
520{
e3b8966e 521 my ($self) = @_;
eda5ff31 522 return '$(PERL_INC)\\'.$Config{'libperl'};
68dc0745
PP
523}
524
525sub export_list
526{
527 my ($self) = @_;
528 return "$self->{BASEEXT}.def";
529}
530
531=item canonpath
532
533No physical check on the filesystem, but a logical cleanup of a
534path. On UNIX eliminated successive slashes and successive "/.".
535
536=cut
537
538sub canonpath {
539 my($self,$path) = @_;
96e4d5b1 540 $path =~ s/^([a-z]:)/\u$1/;
68dc0745 541 $path =~ s|/|\\|g;
3e3baf6d 542 $path =~ s|(.)\\+|$1\\|g ; # xx////xx -> xx/xx
68dc0745
PP
543 $path =~ s|(\\\.)+\\|\\|g ; # xx/././xx -> xx/xx
544 $path =~ s|^(\.\\)+|| unless $path eq ".\\"; # ./xx -> xx
545 $path =~ s|\\$||
546 unless $path =~ m#^([a-z]:)?\\#; # xx/ -> xx
547 $path .= '.' if $path =~ m#\\$#;
548 $path;
549}
550
551=item perl_script
552
553Takes one argument, a file name, and returns the file name, if the
554argument is likely to be a perl script. On MM_Unix this is true for
555any ordinary, readable file.
556
557=cut
558
559sub perl_script {
560 my($self,$file) = @_;
cae6c631 561 return $file if -r $file && -f _;
68dc0745 562 return "$file.pl" if -r "$file.pl" && -f _;
cae6c631 563 return "$file.bat" if -r "$file.bat" && -f _;
68dc0745
PP
564 return;
565}
566
567=item pm_to_blib
568
569Defines target that copies all files in the hash PM to their
570destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
571
572=cut
573
574sub pm_to_blib {
575 my $self = shift;
576 my($autodir) = $self->catdir('$(INST_LIB)','auto');
577 return q{
578pm_to_blib: $(TO_INST_PM)
579 }.$self->{NOECHO}.q{$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \
580 "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \
dc0d354b
GS
581 -e "pm_to_blib(}.
582 ($NMAKE ? 'qw[ <<pmfiles.dat ],'
583 : $DMAKE ? 'qw[ $(mktmp,pmfiles.dat $(PM_TO_BLIB:s,\\,\\\\,)\n) ],'
584 : '{ qw[$(PM_TO_BLIB)] },'
585 ).q{'}.$autodir.q{')"
3e3baf6d 586 }. ($NMAKE ? q{
68dc0745
PP
587$(PM_TO_BLIB)
588<<
3e3baf6d 589 } : '') . $self->{NOECHO}.q{$(TOUCH) $@
68dc0745
PP
590};
591}
592
593=item test_via_harness (o)
594
595Helper method to write the test targets
596
597=cut
598
599sub test_via_harness {
600 my($self, $perl, $tests) = @_;
601 "\t$perl".q! -Mblib -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e "use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;" !."$tests\n";
602}
603
3e3baf6d 604
68dc0745
PP
605=item tool_autosplit (override)
606
607Use Win32 quoting on command line.
608
609=cut
610
611sub tool_autosplit{
612 my($self, %attribs) = @_;
613 my($asl) = "";
614 $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
615 q{
616# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
617AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MAutoSplit }.$asl.q{ -e "autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1);"
618};
619}
620
621=item tools_other (o)
622
623Win32 overrides.
624
625Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in
626the Makefile. Also defines the perl programs MKPATH,
627WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL.
628
629=cut
630
631sub tools_other {
632 my($self) = shift;
633 my @m;
634 my $bin_sh = $Config{sh} || 'cmd /c';
635 push @m, qq{
636SHELL = $bin_sh
3e3baf6d 637} unless $DMAKE; # dmake determines its own shell
68dc0745
PP
638
639 for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) {
640 push @m, "$_ = $self->{$_}\n";
641 }
642
643 push @m, q{
644# The following is a portable way to say mkdir -p
645# To see which directories are created, change the if 0 to if 1
646MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath
647
648# This helps us to minimize the effect of the .exists files A yet
649# better solution would be to have a stable file in the perl
650# distribution with a timestamp of zero. But this solution doesn't
651# need any changes to the core distribution and works with older perls
652EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime
653};
654
655
656 return join "", @m if $self->{PARENT};
657
658 push @m, q{
659# Here we warn users that an old packlist file was found somewhere,
660# and that they should call some uninstall routine
661WARN_IF_OLD_PACKLIST = $(PERL) -lwe "exit unless -f $$ARGV[0];" \\
662-e "print 'WARNING: I have found an old package in';" \\
663-e "print ' ', $$ARGV[0], '.';" \\
664-e "print 'Please make sure the two installations are not conflicting';"
665
666UNINST=0
667VERBINST=1
668
669MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \
3e3baf6d 670-e "install({ @ARGV },'$(VERBINST)',0,'$(UNINST)');"
68dc0745
PP
671
672DOC_INSTALL = $(PERL) -e "$$\=\"\n\n\";" \
673-e "print '=head2 ', scalar(localtime), ': C<', shift, '>', ' L<', shift, '>';" \
674-e "print '=over 4';" \
3e3baf6d 675-e "while (defined($$key = shift) and defined($$val = shift)) { print '=item *';print 'C<', \"$$key: $$val\", '>'; }" \
68dc0745
PP
676-e "print '=back';"
677
678UNINSTALL = $(PERL) -MExtUtils::Install \
679-e "uninstall($$ARGV[0],1,1); print \"\nUninstall is deprecated. Please check the";" \
680-e "print \" packlist above carefully.\n There may be errors. Remove the\";" \
681-e "print \" appropriate files manually.\n Sorry for the inconveniences.\n\""
682};
683
684 return join "", @m;
685}
686
3e3baf6d
TB
687=item xs_o (o)
688
689Defines suffix rules to go from XS to object files directly. This is
690only intended for broken make implementations.
691
692=cut
693
694sub xs_o { # many makes are too dumb to use xs_c then c_o
695 my($self) = shift;
696 return ''
697}
698
699=item top_targets (o)
700
701Defines the targets all, subdirs, config, and O_FILES
702
703=cut
704
705sub top_targets {
706# --- Target Sections ---
707
708 my($self) = shift;
709 my(@m);
710 push @m, '
711#all :: config $(INST_PM) subdirs linkext manifypods
712';
713
714 push @m, '
cae6c631 715all :: pure_all htmlifypods manifypods
3e3baf6d
TB
716 '.$self->{NOECHO}.'$(NOOP)
717'
718 unless $self->{SKIPHASH}{'all'};
719
720 push @m, '
721pure_all :: config pm_to_blib subdirs linkext
722 '.$self->{NOECHO}.'$(NOOP)
723
724subdirs :: $(MYEXTLIB)
725 '.$self->{NOECHO}.'$(NOOP)
726
727config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)\.exists
728 '.$self->{NOECHO}.'$(NOOP)
729
730config :: $(INST_ARCHAUTODIR)\.exists
731 '.$self->{NOECHO}.'$(NOOP)
732
733config :: $(INST_AUTODIR)\.exists
734 '.$self->{NOECHO}.'$(NOOP)
735';
736
737 push @m, qq{
738config :: Version_check
739 $self->{NOECHO}\$(NOOP)
740
741} unless $self->{PARENT} or ($self->{PERL_SRC} && $self->{INSTALLDIRS} eq "perl") or $self->{NO_VC};
742
743 push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
744
cae6c631
JD
745 if (%{$self->{HTMLLIBPODS}}) {
746 push @m, qq[
747config :: \$(INST_HTMLLIBDIR)/.exists
748 $self->{NOECHO}\$(NOOP)
749
750];
751 push @m, $self->dir_target(qw[$(INST_HTMLLIBDIR)]);
752 }
753
754 if (%{$self->{HTMLSCRIPTPODS}}) {
755 push @m, qq[
756config :: \$(INST_HTMLSCRIPTDIR)/.exists
757 $self->{NOECHO}\$(NOOP)
758
759];
760 push @m, $self->dir_target(qw[$(INST_HTMLSCRIPTDIR)]);
761 }
762
3e3baf6d
TB
763 if (%{$self->{MAN1PODS}}) {
764 push @m, qq[
765config :: \$(INST_MAN1DIR)\\.exists
766 $self->{NOECHO}\$(NOOP)
767
768];
769 push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
770 }
771 if (%{$self->{MAN3PODS}}) {
772 push @m, qq[
773config :: \$(INST_MAN3DIR)\\.exists
774 $self->{NOECHO}\$(NOOP)
775
776];
777 push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
778 }
779
780 push @m, '
781$(O_FILES): $(H_FILES)
782' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
783
784 push @m, q{
785help:
786 perldoc ExtUtils::MakeMaker
787};
788
789 push @m, q{
790Version_check:
791 }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
792 -MExtUtils::MakeMaker=Version_check \
793 -e "Version_check('$(MM_VERSION)')"
794};
795
796 join('',@m);
797}
798
cae6c631
JD
799=item htmlifypods (o)
800
801Defines targets and routines to translate the pods into HTML manpages
802and put them into the INST_HTMLLIBDIR and INST_HTMLSCRIPTDIR
803directories.
804
805Same as MM_Unix version (changes command-line quoting).
806
807=cut
808
809sub htmlifypods {
810 my($self, %attribs) = @_;
811 return "\nhtmlifypods : pure_all\n\t$self->{NOECHO}\$(NOOP)\n" unless
812 %{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}};
813 my($dist);
814 my($pod2html_exe);
815 if (defined $self->{PERL_SRC}) {
816 $pod2html_exe = $self->catfile($self->{PERL_SRC},'pod','pod2html');
817 } else {
818 $pod2html_exe = $self->catfile($Config{scriptdirexp},'pod2html');
819 }
820 unless ($pod2html_exe = $self->perl_script($pod2html_exe)) {
821 # No pod2html but some HTMLxxxPODS to be installed
822 print <<END;
823
824Warning: I could not locate your pod2html program. Please make sure,
825 your pod2html program is in your PATH before you execute 'make'
826
827END
828 $pod2html_exe = "-S pod2html";
829 }
830 my(@m);
831 push @m,
832qq[POD2HTML_EXE = $pod2html_exe\n],
833qq[POD2HTML = \$(PERL) -we "use File::Basename; use File::Path qw(mkpath); %m=\@ARGV;for (keys %m){" \\\n],
834q[-e "next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M '],
835 $self->{MAKEFILE}, q[';" \\
836-e "print qq(Htmlifying $$m{$$_}\n);" \\
837-e "$$dir = dirname($$m{$$_}); mkpath($$dir) unless -d $$dir;" \\
838-e "system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2HTML_EXE) ].qq[$$_>$$m{$$_}])==0 or warn qq(Couldn\\047t install $$m{$$_}\n);" \\
839-e "chmod(oct($(PERM_RW))), $$m{$$_} or warn qq(chmod $(PERM_RW) $$m{$$_}: $$!\n);}"
840];
841 push @m, "\nhtmlifypods : pure_all ";
842 push @m, join " \\\n\t", keys %{$self->{HTMLLIBPODS}}, keys %{$self->{HTMLSCRIPTPODS}};
843
844 push(@m,"\n");
845 if (%{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}}) {
846 push @m, "\t$self->{NOECHO}\$(POD2HTML) \\\n\t";
847 push @m, join " \\\n\t", %{$self->{HTMLLIBPODS}}, %{$self->{HTMLSCRIPTPODS}};
848 }
849 join('', @m);
850}
851
68dc0745
PP
852=item manifypods (o)
853
cae6c631 854We don't want manpage process.
68dc0745
PP
855
856=cut
857
858sub manifypods {
846f184a 859 my($self) = shift;
68dc0745
PP
860 return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n";
861}
862
863=item dist_ci (o)
864
865Same as MM_Unix version (changes command-line quoting).
866
867=cut
868
869sub dist_ci {
870 my($self) = shift;
871 my @m;
872 push @m, q{
873ci :
874 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=maniread \\
875 -e "@all = keys %{ maniread() };" \\
876 -e "print(\"Executing $(CI) @all\n\"); system(\"$(CI) @all\");" \\
877 -e "print(\"Executing $(RCS_LABEL) ...\n\"); system(\"$(RCS_LABEL) @all\");"
878};
879 join "", @m;
880}
881
882=item dist_core (o)
883
884Same as MM_Unix version (changes command-line quoting).
885
886=cut
887
888sub dist_core {
889 my($self) = shift;
890 my @m;
891 push @m, q{
892dist : $(DIST_DEFAULT)
893 }.$self->{NOECHO}.q{$(PERL) -le "print \"Warning: Makefile possibly out of date with $$vf\" if " \
894 -e "-e ($$vf=\"$(VERSION_FROM)\") and -M $$vf < -M \"}.$self->{MAKEFILE}.q{\";"
895
896tardist : $(DISTVNAME).tar$(SUFFIX)
897
898zipdist : $(DISTVNAME).zip
899
900$(DISTVNAME).tar$(SUFFIX) : distdir
901 $(PREOP)
902 $(TO_UNIX)
903 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
904 $(RM_RF) $(DISTVNAME)
905 $(COMPRESS) $(DISTVNAME).tar
906 $(POSTOP)
907
908$(DISTVNAME).zip : distdir
909 $(PREOP)
910 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
911 $(RM_RF) $(DISTVNAME)
912 $(POSTOP)
913
914uutardist : $(DISTVNAME).tar$(SUFFIX)
915 uuencode $(DISTVNAME).tar$(SUFFIX) \\
916 $(DISTVNAME).tar$(SUFFIX) > \\
917 $(DISTVNAME).tar$(SUFFIX)_uu
918
919shdist : distdir
920 $(PREOP)
921 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
922 $(RM_RF) $(DISTVNAME)
923 $(POSTOP)
924};
925 join "", @m;
926}
927
928=item pasthru (o)
929
930Defines the string that is passed to recursive make calls in
931subdirectories.
932
933=cut
934
935sub pasthru {
936 my($self) = shift;
3e3baf6d 937 return "PASTHRU = " . ($NMAKE ? "-nologo" : "");
68dc0745
PP
938}
939
940
941
9421;
943__END__
944
945=back
946
947=cut
948
5b0d9cbe 949