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