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