Integrate mainline
[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
21use Config;
2986a63f 22use File::Basename;
2986a63f 23
f6d6199c 24use vars qw(@ISA $VERSION);
25$VERSION = '2.01_01';
2986a63f 26
f6d6199c 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
f6d6199c 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;
38$PERLMAKE = 1 if $Config{'make'} =~ /^pmake/i;
2986a63f 39
2986a63f 40
41sub init_others
42{
43 my ($self) = @_;
f6d6199c 44 $self->SUPER::init_others(@_);
2986a63f 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'}) {
54 $self->{'BASE_IMPORT'} .= ',' . $self->{'base_import'};
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
f6d6199c 68
2986a63f 69# NetWare override
70sub const_cccmd {
71 my($self,$libperl)=@_;
72 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
73 return '' unless $self->needs_linking();
74 return $self->{CONST_CCCMD} =
75 q{CCCMD = $(CC) $(INC) $(CCFLAGS) $(OPTIMIZE) \\
76 $(PERLTYPE) $(LARGE) $(SPLIT) $(MPOLLUTE) \\
77 -DVERSION="$(VERSION)" -DXS_VERSION="$(XS_VERSION)"};
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
80a5d8e7 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
75dc7936 96 PERL_INC PERL FULLPERL LIBPTH BASE_IMPORT PERLRUN
80a5d8e7 97 FULLPERLRUN PERLRUNINST FULLPERLRUNINST
75e2e551 98 FULL_AR PERL_CORE NLM_VERSION MPKTOOL TOOLPATH
2986a63f 99
100 / ) {
101 next unless defined $self->{$tmp};
102 push @m, "$tmp = $self->{$tmp}\n";
103 }
104
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->{'NAME'},0,8);
114 push @m, "NLM_SHORT_NAME = $self->{'NLM_SHORT_NAME'}\n";
115 }
116
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
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/ /;/g;
127
128 # Get the additional include path and append to INCLUDE, keep it in
129 # INC will give problems during compilation, hence reset it after getting
130 # the value
131 (my $add_inc = $self->{'INC'}) =~ s/ -I/;/g;
132 $self->{'INC'} = '';
133 push @m, qq{
134INCLUDE = $inc;$add_inc;
135};
136
137 # Set the path to Watcom binaries which might not have been set in
138 # any other place
139 push @m, qq{
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
196# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
197# some make implementations will delete the Makefile when we rebuild it. Because
198# we call false(1) when we rebuild it. So make(1) is not completely wrong when it
199# does so. Our milage may vary.
200# .PRECIOUS: Makefile # seems to be not necessary anymore
201
202.PHONY: all config static dynamic test linkext manifest
203
204# Where is the Config information that we are using/depend on
205CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h
206};
207
208 my @parentdir = split(/::/, $self->{PARENT_NAME});
209 push @m, q{
210# Where to put things:
ecf68df6 211INST_LIBDIR = }. File::Spec->catdir('$(INST_LIB)',@parentdir) .q{
212INST_ARCHLIBDIR = }. File::Spec->catdir('$(INST_ARCHLIB)',@parentdir) .q{
2986a63f 213
ecf68df6 214INST_AUTODIR = }. File::Spec->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
215INST_ARCHAUTODIR = }. File::Spec->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
2986a63f 216};
217
218 if ($self->has_link_code()) {
219 push @m, '
220INST_STATIC = $(INST_ARCHAUTODIR)\$(BASEEXT)$(LIB_EXT)
221INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT)
222INST_BOOT = $(INST_ARCHAUTODIR)\$(BASEEXT).bs
223';
224 } else {
225 push @m, '
226INST_STATIC =
227INST_DYNAMIC =
228INST_BOOT =
229';
230 }
231
232 $tmp = $self->export_list;
233 push @m, "
234EXPORT_LIST = $tmp
235";
236 $tmp = $self->perl_archive;
237 push @m, "
238PERL_ARCHIVE = $tmp
239";
240
241# push @m, q{
242#INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{
243#
244#PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
245#};
246
247 push @m, q{
248TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
249
250PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
251};
252
253 join('',@m);
254}
255
256
2986a63f 257=item dynamic_lib (o)
258
259Defines how to produce the *.so (or equivalent) files.
260
261=cut
262
263sub dynamic_lib {
264 my($self, %attribs) = @_;
265 return '' unless $self->needs_linking(); #might be because of a subdir
266
267 return '' unless $self->has_link_code;
268
269 my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
270 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
271 my($ldfrom) = '$(LDFROM)';
272 my(@m);
273 (my $boot = $self->{NAME}) =~ s/:/_/g;
274 my ($mpk);
275 push(@m,'
276# This section creates the dynamically loadable $(INST_DYNAMIC)
277# from $(OBJECT) and possibly $(MYEXTLIB).
278OTHERLDFLAGS = '.$otherldflags.'
279INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
280
281$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP)
282');
283# push(@m,
284# q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) }
285# .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)});
286
287 # Create xdc data for an MT safe NLM in case of mpk build
288 if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) {
289 $mpk=1;
290 push @m, ' $(MPKTOOL) $(BASEEXT).xdc
291';
292 } else {
293 $mpk=0;
294 }
295
296 push(@m,
297 q{ $(LD) Form Novell NLM '$(DISTNAME) Extension, XS_VERSION=$(XS_VERSION)'}
298 );
299
300 # Taking care of long names like FileHandle, ByteLoader, SDBM_File etc
301 if($self->{NLM_SHORT_NAME}) {
302 # In case of nlms with names exceeding 8 chars, build nlm in the
303 # current dir, rename and move to auto\lib. If we create in auto\lib
304 # in the first place, we can't rename afterwards.
305 push(@m,
306 q{ Name $(NLM_SHORT_NAME).$(DLEXT)}
307 );
308 } else {
309 push(@m,
310 q{ Name $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)}
311 );
312 }
313
314 push(@m,
315 q{ Option Quiet Option Version = $(NLM_VERSION) Option Caseexact Option NoDefaultLibs Option screenname 'none' Option Synchronize }
316 );
317
318 if ($mpk) {
319 push (@m,
320 q{ Option XDCDATA=$(BASEEXT).xdc }
321 );
322 }
323
324 # Add additional lib files if any (SDBM_File)
325 if($self->{MYEXTLIB}) {
326 push(@m,
327 q{ Library $(MYEXTLIB) }
328 );
329 }
330
331#For now lets comment all the Watcom lib calls
332#q{ LibPath $(LIBPTH) Library plib3s.lib Library math3s.lib Library clib3s.lib Library emu387.lib Library $(PERL_ARCHIVE) Library $(PERL_INC)\Main.lib}
333
334 push(@m,
335 q{ Library $(PERL_ARCHIVE) Library $(PERL_INC)\Main.lib}
336 .q{ Export boot_$(BOOT_SYMBOL) $(BASE_IMPORT) }
337 .q{ FILE $(OBJECT:.obj=,)}
338 );
339
340 # If it is having a short name, rename it
341 if($self->{NLM_SHORT_NAME}) {
342 push @m, '
343 if exist $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT) del $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)';
344 push @m, '
345 rename $(NLM_SHORT_NAME).$(DLEXT) $(BASEEXT).$(DLEXT)';
346 push @m, '
347 move $(BASEEXT).$(DLEXT) $(INST_AUTODIR)';
348 }
349
350 push @m, '
351 $(CHMOD) 755 $@
352';
353
354 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
355 join('',@m);
356}
357
2986a63f 358
3591;
360__END__
361
362=back
363
364=cut
365
366