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