This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[patch@25305] lib/ExtUtils/t/Constant.t VMS fixes
[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
3e9ffe50 21use strict;
7292dc67 22use ExtUtils::MakeMaker::Config;
2986a63f 23use File::Basename;
f582e489 24
f6d6199c 25use vars qw(@ISA $VERSION);
7292dc67 26$VERSION = '2.08';
2986a63f 27
f6d6199c
MS
28require ExtUtils::MM_Win32;
29@ISA = qw(ExtUtils::MM_Win32);
2986a63f 30
f6d6199c 31use ExtUtils::MakeMaker qw( &neatvalue );
2986a63f 32
f6d6199c 33$ENV{EMXSHELL} = 'sh'; # to run `commands`
2986a63f 34
76df5e8f
DM
35my $BORLAND = $Config{'cc'} =~ /^bcc/i;
36my $GCC = $Config{'cc'} =~ /^gcc/i;
37my $DMAKE = $Config{'make'} =~ /^dmake/i;
2986a63f 38
2986a63f 39
dedf98bc
MS
40=item os_flavor
41
42We're Netware in addition to being Windows.
43
44=cut
45
46sub os_flavor {
47 my $self = shift;
48 return ($self->SUPER::os_flavor, 'Netware');
49}
50
7292dc67 51=item init_platform
479d2113
MS
52
53Add Netware macros.
54
55LIBPTH, BASE_IMPORT, NLM_VERSION, MPKTOOL, TOOLPATH, BOOT_SYMBOL,
56NLM_SHORT_NAME, INCLUDE, PATH, MM_NW5_REVISION
57
58
59=item platform_constants
60
61Add Netware macros initialized above to the Makefile.
62
63=cut
64
65sub init_platform {
66 my($self) = shift;
67
68 # To get Win32's setup.
69 $self->SUPER::init_platform;
2986a63f 70
f582e489
MS
71 # incpath is copied to makefile var INCLUDE in constants sub, here just
72 # make it empty
73 my $libpth = $Config{'libpth'};
74 $libpth =~ s( )(;);
75 $self->{'LIBPTH'} = $libpth;
479d2113 76
f582e489 77 $self->{'BASE_IMPORT'} = $Config{'base_import'};
479d2113 78
f582e489
MS
79 # Additional import file specified from Makefile.pl
80 if($self->{'base_import'}) {
81 $self->{'BASE_IMPORT'} .= ', ' . $self->{'base_import'};
82 }
2986a63f 83
f582e489
MS
84 $self->{'NLM_VERSION'} = $Config{'nlm_version'};
85 $self->{'MPKTOOL'} = $Config{'mpktool'};
86 $self->{'TOOLPATH'} = $Config{'toolpath'};
2986a63f 87
f582e489
MS
88 (my $boot = $self->{'NAME'}) =~ s/:/_/g;
89 $self->{'BOOT_SYMBOL'}=$boot;
f582e489
MS
90
91 # If the final binary name is greater than 8 chars,
f355267c 92 # truncate it here.
f582e489
MS
93 if(length($self->{'BASEEXT'}) > 8) {
94 $self->{'NLM_SHORT_NAME'} = substr($self->{'BASEEXT'},0,8);
f582e489
MS
95 }
96
f582e489
MS
97 # Get the include path and replace the spaces with ;
98 # Copy this to makefile as INCLUDE = d:\...;d:\;
479d2113 99 ($self->{INCLUDE} = $Config{'incpath'}) =~ s/([ ]*)-I/;/g;
f582e489
MS
100
101 # Set the path to CodeWarrior binaries which might not have been set in
102 # any other place
479d2113 103 $self->{PATH} = '$(PATH);$(TOOLPATH)';
2986a63f 104
479d2113
MS
105 $self->{MM_NW5_VERSION} = $VERSION;
106}
107
108sub platform_constants {
109 my($self) = shift;
110 my $make_frag = '';
111
112 # Setup Win32's constants.
113 $make_frag .= $self->SUPER::platform_constants;
2986a63f 114
479d2113
MS
115 foreach my $macro (qw(LIBPTH BASE_IMPORT NLM_VERSION MPKTOOL
116 TOOLPATH BOOT_SYMBOL NLM_SHORT_NAME INCLUDE PATH
117 MM_NW5_VERSION
118 ))
119 {
120 next unless defined $self->{$macro};
121 $make_frag .= "$macro = $self->{$macro}\n";
2986a63f
JH
122 }
123
479d2113
MS
124 return $make_frag;
125}
126
2986a63f 127
7292dc67 128=item const_cccmd
479d2113
MS
129
130=cut
2986a63f 131
479d2113
MS
132sub const_cccmd {
133 my($self,$libperl)=@_;
134 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
135 return '' unless $self->needs_linking();
136 return $self->{CONST_CCCMD} = <<'MAKE_FRAG';
137CCCMD = $(CC) $(CCFLAGS) $(INC) $(OPTIMIZE) \
138 $(PERLTYPE) $(MPOLLUTE) -o $@ \
139 -DVERSION=\"$(VERSION)\" -DXS_VERSION=\"$(XS_VERSION)\"
140MAKE_FRAG
2986a63f 141
2986a63f
JH
142}
143
f582e489 144
7292dc67 145=item static_lib
f582e489
MS
146
147=cut
148
cd340a5d 149sub static_lib {
3c7fc81c 150 my($self) = @_;
cd340a5d
JH
151
152 return '' unless $self->has_link_code;
153
3e9ffe50 154 my $m = <<'END';
7292dc67 155$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists
3c7fc81c
JH
156 $(RM_RF) $@
157END
158
159 # If this extension has it's own library (eg SDBM_File)
160 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
3e9ffe50 161 $m .= <<'END' if $self->{MYEXTLIB};
57b1a898 162 $self->{CP} $(MYEXTLIB) $@
3e9ffe50
JH
163END
164
165 my $ar_arg;
166 if( $BORLAND ) {
167 $ar_arg = '$@ $(OBJECT:^"+")';
168 }
169 elsif( $GCC ) {
170 $ar_arg = '-ru $@ $(OBJECT)';
171 }
172 else {
173 $ar_arg = '-type library -o $@ $(OBJECT)';
174 }
3c7fc81c 175
3e9ffe50
JH
176 $m .= sprintf <<'END', $ar_arg;
177 $(AR) %s
479d2113 178 $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld
cd340a5d 179 $(CHMOD) 755 $@
3e9ffe50 180END
3c7fc81c 181
3e9ffe50 182 $m .= <<'END' if $self->{PERL_SRC};
479d2113 183 $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs
a7d1454b
RGS
184
185
3e9ffe50 186END
3e9ffe50 187 return $m;
cd340a5d
JH
188}
189
7292dc67 190=item dynamic_lib
2986a63f
JH
191
192Defines how to produce the *.so (or equivalent) files.
193
194=cut
195
196sub dynamic_lib {
f582e489 197 my($self, %attribs) = @_;
2986a63f
JH
198 return '' unless $self->needs_linking(); #might be because of a subdir
199
200 return '' unless $self->has_link_code;
201
202 my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
203 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
204 my($ldfrom) = '$(LDFROM)';
f582e489
MS
205
206 (my $boot = $self->{NAME}) =~ s/:/_/g;
207
208 my $m = <<'MAKE_FRAG';
2986a63f
JH
209# This section creates the dynamically loadable $(INST_DYNAMIC)
210# from $(OBJECT) and possibly $(MYEXTLIB).
211OTHERLDFLAGS = '.$otherldflags.'
212INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
213
f582e489 214# Create xdc data for an MT safe NLM in case of mpk build
7292dc67 215$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists
479d2113
MS
216 $(NOECHO) $(ECHO) Export boot_$(BOOT_SYMBOL) > $(BASEEXT).def
217 $(NOECHO) $(ECHO) $(BASE_IMPORT) >> $(BASEEXT).def
218 $(NOECHO) $(ECHO) Import @$(PERL_INC)\perl.imp >> $(BASEEXT).def
f582e489
MS
219MAKE_FRAG
220
221
222 if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) {
223 $m .= <<'MAKE_FRAG';
224 $(MPKTOOL) $(XDCFLAGS) $(BASEEXT).xdc
479d2113 225 $(NOECHO) $(ECHO) xdcdata $(BASEEXT).xdc >> $(BASEEXT).def
f582e489
MS
226MAKE_FRAG
227 }
228
69ff8adf
JH
229 # Reconstruct the X.Y.Z version.
230 my $version = join '.', map { sprintf "%d", $_ }
231 $] =~ /(\d)\.(\d{3})(\d{2})/;
232 $m .= sprintf ' $(LD) $(LDFLAGS) $(OBJECT:.obj=.obj) -desc "Perl %s Extension ($(BASEEXT)) XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION)', $version;
f582e489
MS
233
234 # Taking care of long names like FileHandle, ByteLoader, SDBM_File etc
235 if($self->{NLM_SHORT_NAME}) {
236 # In case of nlms with names exceeding 8 chars, build nlm in the
f355267c 237 # current dir, rename and move to auto\lib.
f582e489
MS
238 $m .= q{ -o $(NLM_SHORT_NAME).$(DLEXT)}
239 } else {
240 $m .= q{ -o $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)}
241 }
242
243 # Add additional lib files if any (SDBM_File)
244 $m .= q{ $(MYEXTLIB) } if $self->{MYEXTLIB};
245
246 $m .= q{ $(PERL_INC)\Main.lib -commandfile $(BASEEXT).def}."\n";
247
f582e489
MS
248 if($self->{NLM_SHORT_NAME}) {
249 $m .= <<'MAKE_FRAG';
f355267c
JH
250 if exist $(INST_AUTODIR)\$(NLM_SHORT_NAME).$(DLEXT) del $(INST_AUTODIR)\$(NLM_SHORT_NAME).$(DLEXT)
251 move $(NLM_SHORT_NAME).$(DLEXT) $(INST_AUTODIR)
f582e489
MS
252MAKE_FRAG
253 }
254
255 $m .= <<'MAKE_FRAG';
256
2986a63f 257 $(CHMOD) 755 $@
f582e489
MS
258MAKE_FRAG
259
f582e489 260 return $m;
2986a63f
JH
261}
262
2986a63f
JH
263
2641;
265__END__
266
267=back
268
269=cut
270
f582e489 271