NetWare update from C Aditya.
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_NW5.pm
CommitLineData
2986a63f 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;
2986a63f 22use File::Basename;
2986a63f 23
f6d6199c 24use vars qw(@ISA $VERSION);
25$VERSION = '2.01_01';
2986a63f 26
f6d6199c 27require ExtUtils::MM_Win32;
28@ISA = qw(ExtUtils::MM_Win32);
2986a63f 29
f6d6199c 30use ExtUtils::MakeMaker qw( &neatvalue );
2986a63f 31
f6d6199c 32$ENV{EMXSHELL} = 'sh'; # to run `commands`
2986a63f 33
cd340a5d 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;
f6d6199c 38$PERLMAKE = 1 if $Config{'make'} =~ /^pmake/i;
2986a63f 39
2986a63f 40
cd340a5d 41
2986a63f 42sub init_others
43{
44 my ($self) = @_;
f6d6199c 45 $self->SUPER::init_others(@_);
2986a63f 46
47 # incpath is copied to makefile var INCLUDE in constants sub, here just make it empty
48 my $libpth = $Config{'libpth'};
49 $libpth =~ s( )(;);
50 $self->{'LIBPTH'} = $libpth;
51 $self->{'BASE_IMPORT'} = $Config{'base_import'};
52
53 # Additional import file specified from Makefile.pl
54 if($self->{'base_import'}) {
011f1a1a 55 $self->{'BASE_IMPORT'} .= ', ' . $self->{'base_import'};
2986a63f 56 }
57
58 $self->{'NLM_VERSION'} = $Config{'nlm_version'};
59 $self->{'MPKTOOL'} = $Config{'mpktool'};
60 $self->{'TOOLPATH'} = $Config{'toolpath'};
61}
62
63
64=item constants (o)
65
66Initializes lots of constants and .SUFFIXES and .PHONY
67
68=cut
45bc4d3a 69
2986a63f 70sub const_cccmd {
71 my($self,$libperl)=@_;
72 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
73 return '' unless $self->needs_linking();
cd340a5d 74 return $self->{CONST_CCCMD} =
011f1a1a 75 q{CCCMD = $(CC) $(CCFLAGS) $(INC) $(OPTIMIZE) \\
76 $(PERLTYPE) $(MPOLLUTE) -o $@ \\
cd340a5d 77 -DVERSION=\"$(VERSION)\" -DXS_VERSION=\"$(XS_VERSION)\"};
2986a63f 78}
79
80sub constants {
81 my($self) = @_;
82 my(@m,$tmp);
83
84# Added LIBPTH, BASE_IMPORT, ABSTRACT, NLM_VERSION BOOT_SYMBOL, NLM_SHORT_NAME
85# for NETWARE
86
87 for $tmp (qw/
88
89 AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION
e0678a30 90 VERSION_SYM XS_VERSION INST_BIN INST_LIB
2986a63f 91 INST_ARCHLIB INST_SCRIPT PREFIX INSTALLDIRS
92 INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB
93 INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB
94 PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
95 FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC
75dc7936 96 PERL_INC PERL FULLPERL LIBPTH BASE_IMPORT PERLRUN
cd340a5d 97 FULLPERLRUN PERLRUNINST FULL_AR PERL_CORE FULLPERLRUNINST
98 NLM_VERSION MPKTOOL TOOLPATH
99
2986a63f 100 / ) {
101 next unless defined $self->{$tmp};
102 push @m, "$tmp = $self->{$tmp}\n";
103 }
104
cd340a5d 105 (my $boot = $self->{'NAME'}) =~ s/:/_/g;
106 $self->{'BOOT_SYMBOL'}=$boot;
107 push @m, "BOOT_SYMBOL = $self->{'BOOT_SYMBOL'}\n";
108
109 # If the final binary name is greater than 8 chars,
110 # truncate it here and rename it after creation
111 # otherwise, Watcom Linker fails
112
113 if(length($self->{'BASEEXT'}) > 8) {
114 $self->{'NLM_SHORT_NAME'} = substr($self->{'BASEEXT'},0,8);
115 push @m, "NLM_SHORT_NAME = $self->{'NLM_SHORT_NAME'}\n";
116 }
117
2986a63f 118 push @m, qq{
119VERSION_MACRO = VERSION
120DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
121XS_VERSION_MACRO = XS_VERSION
122XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
123};
124
cd340a5d 125 # Get the include path and replace the spaces with ;
126 # Copy this to makefile as INCLUDE = d:\...;d:\;
127 (my $inc = $Config{'incpath'}) =~ s/([ ]*)-I/;/g;
2986a63f 128
cd340a5d 129push @m, qq{
011f1a1a 130INCLUDE = $inc;
131};
cd340a5d 132 # Set the path to CodeWarrior binaries which might not have been set in
133 # any other place
134 push @m, qq{
2986a63f 135PATH = \$(PATH);\$(TOOLPATH)
136};
137
138 push @m, qq{
f6d6199c 139MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'}
2986a63f 140MM_VERSION = $ExtUtils::MakeMaker::VERSION
141};
142
143 push @m, q{
144# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
145# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
2986a63f 146# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
147# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
148};
149
150 for $tmp (qw/
151 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
152 LDFROM LINKTYPE
153 / ) {
154 next unless defined $self->{$tmp};
155 push @m, "$tmp = $self->{$tmp}\n";
156 }
157
158 push @m, "
159# Handy lists of source code files:
160XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
161C_FILES = ".join(" \\\n\t", @{$self->{C}})."
162O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
163H_FILES = ".join(" \\\n\t", @{$self->{H}})."
2986a63f 164MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
165MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
166";
167
168 for $tmp (qw/
2986a63f 169 INST_MAN1DIR INSTALLMAN1DIR MAN1EXT
170 INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
171 /) {
172 next unless defined $self->{$tmp};
173 push @m, "$tmp = $self->{$tmp}\n";
174 }
175
176 push @m, qq{
177.USESHELL :
178} if $DMAKE;
179
180 push @m, q{
181.NO_CONFIG_REC: Makefile
182} if $ENV{CLEARCASE_ROOT};
183
184 # why not q{} ? -- emacs
185 push @m, qq{
186# work around a famous dec-osf make(1) feature(?):
187makemakerdflt: all
188
189.SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
190
191# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
192# some make implementations will delete the Makefile when we rebuild it. Because
193# we call false(1) when we rebuild it. So make(1) is not completely wrong when it
194# does so. Our milage may vary.
195# .PRECIOUS: Makefile # seems to be not necessary anymore
196
197.PHONY: all config static dynamic test linkext manifest
198
199# Where is the Config information that we are using/depend on
200CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h
201};
202
203 my @parentdir = split(/::/, $self->{PARENT_NAME});
204 push @m, q{
205# Where to put things:
ecf68df6 206INST_LIBDIR = }. File::Spec->catdir('$(INST_LIB)',@parentdir) .q{
207INST_ARCHLIBDIR = }. File::Spec->catdir('$(INST_ARCHLIB)',@parentdir) .q{
2986a63f 208
ecf68df6 209INST_AUTODIR = }. File::Spec->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
210INST_ARCHAUTODIR = }. File::Spec->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
2986a63f 211};
212
213 if ($self->has_link_code()) {
214 push @m, '
215INST_STATIC = $(INST_ARCHAUTODIR)\$(BASEEXT)$(LIB_EXT)
216INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT)
217INST_BOOT = $(INST_ARCHAUTODIR)\$(BASEEXT).bs
218';
219 } else {
220 push @m, '
221INST_STATIC =
222INST_DYNAMIC =
223INST_BOOT =
224';
225 }
226
227 $tmp = $self->export_list;
228 push @m, "
229EXPORT_LIST = $tmp
230";
231 $tmp = $self->perl_archive;
232 push @m, "
233PERL_ARCHIVE = $tmp
234";
235
236# push @m, q{
237#INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{
238#
239#PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
240#};
241
242 push @m, q{
243TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
244
245PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
246};
247
248 join('',@m);
249}
250
cd340a5d 251sub static_lib {
252 my($self, %attribs) = @_;
253 return '' unless $self->needs_linking(); #might be because of a subdir
254
255 return '' unless $self->has_link_code;
256
257 my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
258 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
259 my($ldfrom) = '$(LDFROM)';
260 my(@m);
261 (my $boot = $self->{NAME}) =~ s/:/_/g;
262 my ($mpk);
263 push(@m,'
264# This section creates the dynamically loadable $(INST_DYNAMIC)
265# from $(OBJECT) and possibly $(MYEXTLIB).
266OTHERLDFLAGS = '.$otherldflags.'
267INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
268
269$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP)
270');
271# push(@m,
272# q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) }
273# .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)});
274
275 # Create xdc data for an MT safe NLM in case of mpk build
276# if ( scalar(keys %XS) == 0 ) { return; }
277
278 push(@m,
279 q{ @echo $(BASE_IMPORT) >> $(BASEEXT).def
280});
281 push(@m,
282 q{ @echo Import @$(PERL_INC)\perl.imp >> $(BASEEXT).def
283});
284
285 if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) {
286 $mpk=1;
287 push @m, ' $(MPKTOOL) $(XDCFLAGS) $(BASEEXT).xdc
288';
289 push @m, ' @echo xdcdata $(BASEEXT).xdc >> $(BASEEXT).def
290';
291 } else {
292 $mpk=0;
293 }
294
295 push(@m,
296 q{ $(LD) $(LDFLAGS) $(OBJECT:.obj=.obj) }
297 );
298
299 push(@m,
300 q{ -desc "Perl 5.7.3 Extension ($(BASEEXT)) XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION) }
301 );
302
303 # Taking care of long names like FileHandle, ByteLoader, SDBM_File etc
304 if($self->{NLM_SHORT_NAME}) {
305 # In case of nlms with names exceeding 8 chars, build nlm in the
306 # current dir, rename and move to auto\lib. If we create in auto\lib
307 # in the first place, we can't rename afterwards.
308 push(@m,
309 q{ -o $(NLM_SHORT_NAME).$(DLEXT)}
310 );
311 } else {
312 push(@m,
313 q{ -o $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)}
314 );
315 }
316
317
318# if ($mpk) {
319# push (@m,
320# q{ Option XDCDATA=$(BASEEXT).xdc }
321# );
322# }
323
324 # Add additional lib files if any (SDBM_File)
325 if($self->{MYEXTLIB}) {
326 push(@m,
327 q{ $(MYEXTLIB) }
328 );
329 }
330
331#For now lets comment all the Watcom lib calls
332#q{ LibPath $(LIBPTH) Library plib3s.lib Library math3s.lib Library clib3s.lib Library emu387.lib Library $(PERL_ARCHIVE) Library $(PERL_INC)\Main.lib}
333
334
335 push(@m,
336 q{ $(PERL_INC)\Main.lib}
337 .q{ -commandfile $(BASEEXT).def }
338 );
339
340 # If it is having a short name, rename it
341 if($self->{NLM_SHORT_NAME}) {
342 push @m, '
343 if exist $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT) del $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)';
344 push @m, '
345 rename $(NLM_SHORT_NAME).$(DLEXT) $(BASEEXT).$(DLEXT)';
346 push @m, '
347 move $(BASEEXT).$(DLEXT) $(INST_AUTODIR)';
348 }
349
350 push @m, '
351 $(CHMOD) 755 $@
352';
353
354 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
355# } else {
356# push @m, '
357# @$(NOOP)
358#';
359# }
360 join('',@m);
361}
362
45bc4d3a 363
2986a63f 364=item dynamic_lib (o)
365
366Defines how to produce the *.so (or equivalent) files.
367
368=cut
369
370sub dynamic_lib {
cd340a5d 371 my($self, %attribs) = @_;
2986a63f 372 return '' unless $self->needs_linking(); #might be because of a subdir
373
374 return '' unless $self->has_link_code;
375
376 my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
377 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
378 my($ldfrom) = '$(LDFROM)';
379 my(@m);
cd340a5d 380 (my $boot = $self->{NAME}) =~ s/:/_/g;
381 my ($mpk);
2986a63f 382 push(@m,'
383# This section creates the dynamically loadable $(INST_DYNAMIC)
384# from $(OBJECT) and possibly $(MYEXTLIB).
385OTHERLDFLAGS = '.$otherldflags.'
386INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
387
388$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP)
389');
cd340a5d 390# push(@m,
391# q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) }
392# .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)});
393
394 # Create xdc data for an MT safe NLM in case of mpk build
395# if ( scalar(keys %XS) == 0 ) { return; }
396 push(@m,
397 q{ @echo Export boot_$(BOOT_SYMBOL) > $(BASEEXT).def
398});
399 push(@m,
400 q{ @echo $(BASE_IMPORT) >> $(BASEEXT).def
401});
402 push(@m,
403 q{ @echo Import @$(PERL_INC)\perl.imp >> $(BASEEXT).def
404});
405
406 if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) {
407 $mpk=1;
408 push @m, ' $(MPKTOOL) $(XDCFLAGS) $(BASEEXT).xdc
409';
410 push @m, ' @echo xdcdata $(BASEEXT).xdc >> $(BASEEXT).def
411';
412 } else {
413 $mpk=0;
414 }
415
416 push(@m,
417 q{ $(LD) $(LDFLAGS) $(OBJECT:.obj=.obj) }
418 );
419
420 push(@m,
421 q{ -desc "Perl 5.7.3 Extension ($(BASEEXT)) XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION) }
422 );
423
424 # Taking care of long names like FileHandle, ByteLoader, SDBM_File etc
425 if($self->{NLM_SHORT_NAME}) {
426 # In case of nlms with names exceeding 8 chars, build nlm in the
427 # current dir, rename and move to auto\lib. If we create in auto\lib
428 # in the first place, we can't rename afterwards.
429 push(@m,
430 q{ -o $(NLM_SHORT_NAME).$(DLEXT)}
431 );
432 } else {
433 push(@m,
434 q{ -o $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)}
435 );
436 }
437
438 # Add additional lib files if any (SDBM_File)
439 if($self->{MYEXTLIB}) {
440 push(@m,
441 q{ $(MYEXTLIB) }
442 );
443 }
444
445#For now lets comment all the Watcom lib calls
446#q{ LibPath $(LIBPTH) Library plib3s.lib Library math3s.lib Library clib3s.lib Library emu387.lib Library $(PERL_ARCHIVE) Library $(PERL_INC)\Main.lib}
447
448
449 push(@m,
450 q{ $(PERL_INC)\Main.lib}
451 .q{ -commandfile $(BASEEXT).def }
452 );
453
454 # If it is having a short name, rename it
455 if($self->{NLM_SHORT_NAME}) {
456 push @m, '
2986a63f 457 if exist $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT) del $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)';
cd340a5d 458 push @m, '
2986a63f 459 rename $(NLM_SHORT_NAME).$(DLEXT) $(BASEEXT).$(DLEXT)';
cd340a5d 460 push @m, '
2986a63f 461 move $(BASEEXT).$(DLEXT) $(INST_AUTODIR)';
cd340a5d 462 }
2986a63f 463
464 push @m, '
465 $(CHMOD) 755 $@
466';
467
468 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
cd340a5d 469
2986a63f 470 join('',@m);
471}
472
2986a63f 473
4741;
475__END__
476
477=back
478
479=cut
480