This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Comment tweaks.
[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;
f582e489 23
f6d6199c 24use vars qw(@ISA $VERSION);
f582e489 25$VERSION = '2.02_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
f582e489
MS
34my $BORLAND = 1 if $Config{'cc'} =~ /^bcc/i;
35my $GCC = 1 if $Config{'cc'} =~ /^gcc/i;
36my $DMAKE = 1 if $Config{'make'} =~ /^dmake/i;
2986a63f 37
2986a63f 38
f582e489
MS
39sub init_others {
40 my ($self) = @_;
41 $self->SUPER::init_others(@_);
2986a63f 42
f582e489
MS
43 # incpath is copied to makefile var INCLUDE in constants sub, here just
44 # make it empty
45 my $libpth = $Config{'libpth'};
46 $libpth =~ s( )(;);
47 $self->{'LIBPTH'} = $libpth;
48 $self->{'BASE_IMPORT'} = $Config{'base_import'};
2986a63f 49
f582e489
MS
50 # Additional import file specified from Makefile.pl
51 if($self->{'base_import'}) {
52 $self->{'BASE_IMPORT'} .= ', ' . $self->{'base_import'};
53 }
2986a63f 54
f582e489
MS
55 $self->{'NLM_VERSION'} = $Config{'nlm_version'};
56 $self->{'MPKTOOL'} = $Config{'mpktool'};
57 $self->{'TOOLPATH'} = $Config{'toolpath'};
2986a63f
JH
58}
59
60
61=item constants (o)
62
63Initializes lots of constants and .SUFFIXES and .PHONY
64
65=cut
f582e489 66
2986a63f
JH
67sub const_cccmd {
68 my($self,$libperl)=@_;
69 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
70 return '' unless $self->needs_linking();
f582e489
MS
71 return $self->{CONST_CCCMD} = <<'MAKE_FRAG';
72CCCMD = $(CC) $(CCFLAGS) $(INC) $(OPTIMIZE) \
73 $(PERLTYPE) $(MPOLLUTE) -o $@ \
a5564b91 74 -DVERSION=\"$(VERSION)\" -DXS_VERSION=\"$(XS_VERSION)\"
f582e489
MS
75MAKE_FRAG
76
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
f582e489
MS
95 PERL_INC PERL FULLPERL LIBPTH BASE_IMPORT PERLRUN
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
f582e489
MS
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
f582e489
MS
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
f582e489
MS
127 # Get the additional include path and append to INCLUDE, keeping it
128 # in INC will give problems during compilation, hence reset it
129 # after getting the value
130 $self->{INC} = '';
3c7fc81c 131
f582e489 132 push @m, qq{
011f1a1a
JH
133INCLUDE = $inc;
134};
f582e489
MS
135
136 # Set the path to CodeWarrior binaries which might not have been set in
137 # any other place
138 push @m, qq{
2986a63f
JH
139PATH = \$(PATH);\$(TOOLPATH)
140};
141
142 push @m, qq{
f6d6199c 143MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'}
2986a63f
JH
144MM_VERSION = $ExtUtils::MakeMaker::VERSION
145};
146
147 push @m, q{
148# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
149# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
2986a63f
JH
150# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
151# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
152};
153
154 for $tmp (qw/
155 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
156 LDFROM LINKTYPE
157 / ) {
158 next unless defined $self->{$tmp};
159 push @m, "$tmp = $self->{$tmp}\n";
160 }
161
162 push @m, "
163# Handy lists of source code files:
164XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
165C_FILES = ".join(" \\\n\t", @{$self->{C}})."
166O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
167H_FILES = ".join(" \\\n\t", @{$self->{H}})."
2986a63f
JH
168MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
169MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
170";
171
172 for $tmp (qw/
2986a63f
JH
173 INST_MAN1DIR INSTALLMAN1DIR MAN1EXT
174 INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
175 /) {
176 next unless defined $self->{$tmp};
177 push @m, "$tmp = $self->{$tmp}\n";
178 }
179
180 push @m, qq{
181.USESHELL :
182} if $DMAKE;
183
184 push @m, q{
185.NO_CONFIG_REC: Makefile
186} if $ENV{CLEARCASE_ROOT};
187
188 # why not q{} ? -- emacs
189 push @m, qq{
190# work around a famous dec-osf make(1) feature(?):
191makemakerdflt: all
192
193.SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
194
2986a63f
JH
195.PHONY: all config static dynamic test linkext manifest
196
197# Where is the Config information that we are using/depend on
198CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h
199};
200
201 my @parentdir = split(/::/, $self->{PARENT_NAME});
202 push @m, q{
203# Where to put things:
ecf68df6
DR
204INST_LIBDIR = }. File::Spec->catdir('$(INST_LIB)',@parentdir) .q{
205INST_ARCHLIBDIR = }. File::Spec->catdir('$(INST_ARCHLIB)',@parentdir) .q{
2986a63f 206
ecf68df6
DR
207INST_AUTODIR = }. File::Spec->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
208INST_ARCHAUTODIR = }. File::Spec->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
2986a63f
JH
209};
210
211 if ($self->has_link_code()) {
212 push @m, '
213INST_STATIC = $(INST_ARCHAUTODIR)\$(BASEEXT)$(LIB_EXT)
214INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT)
215INST_BOOT = $(INST_ARCHAUTODIR)\$(BASEEXT).bs
216';
217 } else {
218 push @m, '
219INST_STATIC =
220INST_DYNAMIC =
221INST_BOOT =
222';
223 }
224
225 $tmp = $self->export_list;
226 push @m, "
227EXPORT_LIST = $tmp
228";
229 $tmp = $self->perl_archive;
230 push @m, "
231PERL_ARCHIVE = $tmp
232";
233
2986a63f
JH
234 push @m, q{
235TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
236
237PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
238};
239
240 join('',@m);
241}
242
f582e489
MS
243
244=item static_lib (o)
245
246=cut
247
cd340a5d 248sub static_lib {
3c7fc81c 249 my($self) = @_;
a5564b91
JH
250# Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
251# return '' unless $self->needs_linking(); #might be because of a subdir
cd340a5d
JH
252
253 return '' unless $self->has_link_code;
254
a5564b91
JH
255 my(@m);
256 push(@m, <<'END');
3c7fc81c
JH
257$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)\.exists
258 $(RM_RF) $@
259END
260
261 # If this extension has it's own library (eg SDBM_File)
262 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
a5564b91 263 push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
3c7fc81c 264
a5564b91
JH
265 push @m,
266q{ $(AR) }.($BORLAND ? '$@ $(OBJECT:^"+")'
267 : ($GCC ? '-ru $@ $(OBJECT)'
268 : '-type library -o $@ $(OBJECT)')).q{
269 }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld
cd340a5d 270 $(CHMOD) 755 $@
a5564b91
JH
271};
272# CW change ( -type library ... )
273# Old mechanism - still available:
3c7fc81c 274
a5564b91
JH
275 push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs}."\n\n"
276 if $self->{PERL_SRC};
cd340a5d 277
a5564b91
JH
278 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
279 join('', "\n",@m);
cd340a5d
JH
280}
281
45bc4d3a 282
2986a63f
JH
283=item dynamic_lib (o)
284
285Defines how to produce the *.so (or equivalent) files.
286
287=cut
288
289sub dynamic_lib {
f582e489 290 my($self, %attribs) = @_;
2986a63f
JH
291 return '' unless $self->needs_linking(); #might be because of a subdir
292
293 return '' unless $self->has_link_code;
294
295 my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
296 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
297 my($ldfrom) = '$(LDFROM)';
f582e489
MS
298
299 (my $boot = $self->{NAME}) =~ s/:/_/g;
300
301 my $m = <<'MAKE_FRAG';
2986a63f
JH
302# This section creates the dynamically loadable $(INST_DYNAMIC)
303# from $(OBJECT) and possibly $(MYEXTLIB).
304OTHERLDFLAGS = '.$otherldflags.'
305INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
306
f582e489 307# Create xdc data for an MT safe NLM in case of mpk build
2986a63f 308$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP)
f582e489
MS
309 @echo Export boot_$(BOOT_SYMBOL) > $(BASEEXT).def
310 @echo $(BASE_IMPORT) >> $(BASEEXT).def
311 @echo Import @$(PERL_INC)\perl.imp >> $(BASEEXT).def
312MAKE_FRAG
313
314
315 if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) {
316 $m .= <<'MAKE_FRAG';
317 $(MPKTOOL) $(XDCFLAGS) $(BASEEXT).xdc
318 @echo xdcdata $(BASEEXT).xdc >> $(BASEEXT).def
319MAKE_FRAG
320 }
321
322 $m .= ' $(LD) $(LDFLAGS) $(OBJECT:.obj=.obj) -desc "Perl 5.7.3 Extension ($(BASEEXT)) XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION)';
323
324 # Taking care of long names like FileHandle, ByteLoader, SDBM_File etc
325 if($self->{NLM_SHORT_NAME}) {
326 # In case of nlms with names exceeding 8 chars, build nlm in the
327 # current dir, rename and move to auto\lib. If we create in auto\lib
328 # in the first place, we can't rename afterwards.
329 $m .= q{ -o $(NLM_SHORT_NAME).$(DLEXT)}
330 } else {
331 $m .= q{ -o $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)}
332 }
333
334 # Add additional lib files if any (SDBM_File)
335 $m .= q{ $(MYEXTLIB) } if $self->{MYEXTLIB};
336
337 $m .= q{ $(PERL_INC)\Main.lib -commandfile $(BASEEXT).def}."\n";
338
339 # If it is having a short name, rename it
340 if($self->{NLM_SHORT_NAME}) {
341 $m .= <<'MAKE_FRAG';
342 if exist $(INST_AUTODIR)\$(BASEEXT).$(DLEXT) del $(INST_AUTODIR)\$(BASEEXT).$(DLEXT)
343 rename $(NLM_SHORT_NAME).$(DLEXT) $(BASEEXT).$(DLEXT)
344 move $(BASEEXT).$(DLEXT) $(INST_AUTODIR)
345MAKE_FRAG
346 }
347
348 $m .= <<'MAKE_FRAG';
349
2986a63f 350 $(CHMOD) 755 $@
f582e489
MS
351MAKE_FRAG
352
353 $m .= $self->dir_target('$(INST_ARCHAUTODIR)');
2986a63f 354
f582e489 355 return $m;
2986a63f
JH
356}
357
2986a63f
JH
358
3591;
360__END__
361
362=back
363
364=cut
365
f582e489 366