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