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