ExtUtils::MakeMaker 5.92_01 -> 5.94_02
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_NW5.pm
CommitLineData
2986a63f 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);
57b1a898 26$VERSION = '2.04_01';
2986a63f 27
f6d6199c 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 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
f582e489 40sub init_others {
41 my ($self) = @_;
42 $self->SUPER::init_others(@_);
2986a63f 43
f582e489 44 # incpath is copied to makefile var INCLUDE in constants sub, here just
45 # make it empty
46 my $libpth = $Config{'libpth'};
47 $libpth =~ s( )(;);
48 $self->{'LIBPTH'} = $libpth;
49 $self->{'BASE_IMPORT'} = $Config{'base_import'};
2986a63f 50
f582e489 51 # Additional import file specified from Makefile.pl
52 if($self->{'base_import'}) {
53 $self->{'BASE_IMPORT'} .= ', ' . $self->{'base_import'};
54 }
2986a63f 55
f582e489 56 $self->{'NLM_VERSION'} = $Config{'nlm_version'};
57 $self->{'MPKTOOL'} = $Config{'mpktool'};
58 $self->{'TOOLPATH'} = $Config{'toolpath'};
2986a63f 59}
60
61
62=item constants (o)
63
64Initializes lots of constants and .SUFFIXES and .PHONY
65
66=cut
f582e489 67
2986a63f 68sub const_cccmd {
69 my($self,$libperl)=@_;
70 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
71 return '' unless $self->needs_linking();
f582e489 72 return $self->{CONST_CCCMD} = <<'MAKE_FRAG';
73CCCMD = $(CC) $(CCFLAGS) $(INC) $(OPTIMIZE) \
74 $(PERLTYPE) $(MPOLLUTE) -o $@ \
57b1a898 75 -DVERSION=\"$(VERSION)\" -DXS_VERSION=\"$(XS_VERSION)\"
f582e489 76MAKE_FRAG
77
2986a63f 78}
79
80sub constants {
81 my($self) = @_;
82 my(@m,$tmp);
83
84# Added LIBPTH, BASE_IMPORT, ABSTRACT, NLM_VERSION BOOT_SYMBOL, NLM_SHORT_NAME
85# for NETWARE
86
87 for $tmp (qw/
88
89 AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION
e0678a30 90 VERSION_SYM XS_VERSION INST_BIN INST_LIB
2986a63f 91 INST_ARCHLIB INST_SCRIPT PREFIX INSTALLDIRS
92 INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB
93 INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB
94 PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
95 FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC
f582e489 96 PERL_INC PERL FULLPERL LIBPTH BASE_IMPORT PERLRUN
97 FULLPERLRUN PERLRUNINST FULLPERLRUNINST
98 FULL_AR PERL_CORE NLM_VERSION MPKTOOL TOOLPATH
99
2986a63f 100 / ) {
101 next unless defined $self->{$tmp};
102 push @m, "$tmp = $self->{$tmp}\n";
103 }
104
f582e489 105 (my $boot = $self->{'NAME'}) =~ s/:/_/g;
106 $self->{'BOOT_SYMBOL'}=$boot;
107 push @m, "BOOT_SYMBOL = $self->{'BOOT_SYMBOL'}\n";
108
109 # If the final binary name is greater than 8 chars,
110 # truncate it here and rename it after creation
111 # otherwise, Watcom Linker fails
112 if(length($self->{'BASEEXT'}) > 8) {
113 $self->{'NLM_SHORT_NAME'} = substr($self->{'BASEEXT'},0,8);
114 push @m, "NLM_SHORT_NAME = $self->{'NLM_SHORT_NAME'}\n";
115 }
116
2986a63f 117 push @m, qq{
118VERSION_MACRO = VERSION
119DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
120XS_VERSION_MACRO = XS_VERSION
121XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
122};
123
f582e489 124 # Get the include path and replace the spaces with ;
125 # Copy this to makefile as INCLUDE = d:\...;d:\;
126 (my $inc = $Config{'incpath'}) =~ s/([ ]*)-I/;/g;
2986a63f 127
f582e489 128 # Get the additional include path and append to INCLUDE, keeping it
129 # in INC will give problems during compilation, hence reset it
130 # after getting the value
131 $self->{INC} = '';
3c7fc81c 132
f582e489 133 push @m, qq{
011f1a1a 134INCLUDE = $inc;
135};
f582e489 136
137 # Set the path to CodeWarrior binaries which might not have been set in
138 # any other place
139 push @m, qq{
2986a63f 140PATH = \$(PATH);\$(TOOLPATH)
141};
142
143 push @m, qq{
f6d6199c 144MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'}
2986a63f 145MM_VERSION = $ExtUtils::MakeMaker::VERSION
146};
147
148 push @m, q{
149# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
150# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
2986a63f 151# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
152# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
153};
154
155 for $tmp (qw/
156 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
157 LDFROM LINKTYPE
158 / ) {
159 next unless defined $self->{$tmp};
160 push @m, "$tmp = $self->{$tmp}\n";
161 }
162
163 push @m, "
164# Handy lists of source code files:
165XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
166C_FILES = ".join(" \\\n\t", @{$self->{C}})."
167O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
168H_FILES = ".join(" \\\n\t", @{$self->{H}})."
2986a63f 169MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
170MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
171";
172
173 for $tmp (qw/
2986a63f 174 INST_MAN1DIR INSTALLMAN1DIR MAN1EXT
175 INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
176 /) {
177 next unless defined $self->{$tmp};
178 push @m, "$tmp = $self->{$tmp}\n";
179 }
180
181 push @m, qq{
182.USESHELL :
183} if $DMAKE;
184
185 push @m, q{
186.NO_CONFIG_REC: Makefile
187} if $ENV{CLEARCASE_ROOT};
188
189 # why not q{} ? -- emacs
190 push @m, qq{
191# work around a famous dec-osf make(1) feature(?):
192makemakerdflt: all
193
194.SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
195
2986a63f 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 205INST_LIBDIR = }. File::Spec->catdir('$(INST_LIB)',@parentdir) .q{
206INST_ARCHLIBDIR = }. File::Spec->catdir('$(INST_ARCHLIB)',@parentdir) .q{
2986a63f 207
ecf68df6 208INST_AUTODIR = }. File::Spec->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
209INST_ARCHAUTODIR = }. File::Spec->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
2986a63f 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
2986a63f 235 push @m, q{
236TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
237
238PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
239};
240
241 join('',@m);
242}
243
f582e489 244
245=item static_lib (o)
246
247=cut
248
cd340a5d 249sub static_lib {
3c7fc81c 250 my($self) = @_;
cd340a5d 251
252 return '' unless $self->has_link_code;
253
3e9ffe50 254 my $m = <<'END';
3c7fc81c 255$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)\.exists
256 $(RM_RF) $@
257END
258
259 # If this extension has it's own library (eg SDBM_File)
260 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
3e9ffe50 261 $m .= <<'END' if $self->{MYEXTLIB};
57b1a898 262 $self->{CP} $(MYEXTLIB) $@
3e9ffe50 263END
264
265 my $ar_arg;
266 if( $BORLAND ) {
267 $ar_arg = '$@ $(OBJECT:^"+")';
268 }
269 elsif( $GCC ) {
270 $ar_arg = '-ru $@ $(OBJECT)';
271 }
272 else {
273 $ar_arg = '-type library -o $@ $(OBJECT)';
274 }
3c7fc81c 275
3e9ffe50 276 $m .= sprintf <<'END', $ar_arg;
277 $(AR) %s
278 $(NOECHO)echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld
cd340a5d 279 $(CHMOD) 755 $@
3e9ffe50 280END
3c7fc81c 281
3e9ffe50 282 $m .= <<'END' if $self->{PERL_SRC};
283 $(NOECHO)echo "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs
284
285END
cd340a5d 286
57b1a898 287 $m .= $self->dir_target('$(INST_ARCHAUTODIR)');
3e9ffe50 288 return $m;
cd340a5d 289}
290
45bc4d3a 291
2986a63f 292=item dynamic_lib (o)
293
294Defines how to produce the *.so (or equivalent) files.
295
296=cut
297
298sub dynamic_lib {
f582e489 299 my($self, %attribs) = @_;
2986a63f 300 return '' unless $self->needs_linking(); #might be because of a subdir
301
302 return '' unless $self->has_link_code;
303
304 my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
305 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
306 my($ldfrom) = '$(LDFROM)';
f582e489 307
308 (my $boot = $self->{NAME}) =~ s/:/_/g;
309
310 my $m = <<'MAKE_FRAG';
2986a63f 311# This section creates the dynamically loadable $(INST_DYNAMIC)
312# from $(OBJECT) and possibly $(MYEXTLIB).
313OTHERLDFLAGS = '.$otherldflags.'
314INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
315
f582e489 316# Create xdc data for an MT safe NLM in case of mpk build
2986a63f 317$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP)
f582e489 318 @echo Export boot_$(BOOT_SYMBOL) > $(BASEEXT).def
319 @echo $(BASE_IMPORT) >> $(BASEEXT).def
320 @echo Import @$(PERL_INC)\perl.imp >> $(BASEEXT).def
321MAKE_FRAG
322
323
324 if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) {
325 $m .= <<'MAKE_FRAG';
326 $(MPKTOOL) $(XDCFLAGS) $(BASEEXT).xdc
327 @echo xdcdata $(BASEEXT).xdc >> $(BASEEXT).def
328MAKE_FRAG
329 }
330
331 $m .= ' $(LD) $(LDFLAGS) $(OBJECT:.obj=.obj) -desc "Perl 5.7.3 Extension ($(BASEEXT)) XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION)';
332
333 # Taking care of long names like FileHandle, ByteLoader, SDBM_File etc
334 if($self->{NLM_SHORT_NAME}) {
335 # In case of nlms with names exceeding 8 chars, build nlm in the
336 # current dir, rename and move to auto\lib. If we create in auto\lib
337 # in the first place, we can't rename afterwards.
338 $m .= q{ -o $(NLM_SHORT_NAME).$(DLEXT)}
339 } else {
340 $m .= q{ -o $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)}
341 }
342
343 # Add additional lib files if any (SDBM_File)
344 $m .= q{ $(MYEXTLIB) } if $self->{MYEXTLIB};
345
346 $m .= q{ $(PERL_INC)\Main.lib -commandfile $(BASEEXT).def}."\n";
347
348 # If it is having a short name, rename it
349 if($self->{NLM_SHORT_NAME}) {
350 $m .= <<'MAKE_FRAG';
351 if exist $(INST_AUTODIR)\$(BASEEXT).$(DLEXT) del $(INST_AUTODIR)\$(BASEEXT).$(DLEXT)
352 rename $(NLM_SHORT_NAME).$(DLEXT) $(BASEEXT).$(DLEXT)
353 move $(BASEEXT).$(DLEXT) $(INST_AUTODIR)
354MAKE_FRAG
355 }
356
357 $m .= <<'MAKE_FRAG';
358
2986a63f 359 $(CHMOD) 755 $@
f582e489 360MAKE_FRAG
361
362 $m .= $self->dir_target('$(INST_ARCHAUTODIR)');
2986a63f 363
f582e489 364 return $m;
2986a63f 365}
366
2986a63f 367
3681;
369__END__
370
371=back
372
373=cut
374
f582e489 375