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