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