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