1 package ExtUtils::MM_NW5;
5 ExtUtils::MM_NW5 - methods to override UN*X behaviour in ExtUtils::MakeMaker
9 use ExtUtils::MM_NW5; # Done internally by ExtUtils::MakeMaker if needed
13 See ExtUtils::MM_Unix for a documentation of the methods provided
14 there. This package overrides the implementation of these methods, not
24 use vars qw(@ISA $VERSION);
27 require ExtUtils::MM_Win32;
28 @ISA = qw(ExtUtils::MM_Win32);
30 use ExtUtils::MakeMaker qw( &neatvalue );
32 $ENV{EMXSHELL} = 'sh'; # to run `commands`
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;
45 $self->SUPER::init_others(@_);
47 # incpath is copied to makefile var INCLUDE in constants sub, here just make it empty
48 my $libpth = $Config{'libpth'};
50 $self->{'LIBPTH'} = $libpth;
51 $self->{'BASE_IMPORT'} = $Config{'base_import'};
53 # Additional import file specified from Makefile.pl
54 if($self->{'base_import'}) {
55 $self->{'BASE_IMPORT'} .= ', ' . $self->{'base_import'};
58 $self->{'NLM_VERSION'} = $Config{'nlm_version'};
59 $self->{'MPKTOOL'} = $Config{'mpktool'};
60 $self->{'TOOLPATH'} = $Config{'toolpath'};
66 Initializes lots of constants and .SUFFIXES and .PHONY
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) $(CCFLAGS) $(INC) $(OPTIMIZE) \\
76 $(PERLTYPE) $(MPOLLUTE) -o $@ \\
77 -DVERSION=\"$(VERSION)\" -DXS_VERSION=\"$(XS_VERSION)\"};
84 # Added LIBPTH, BASE_IMPORT, ABSTRACT, NLM_VERSION BOOT_SYMBOL, NLM_SHORT_NAME
89 AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION
90 VERSION_SYM XS_VERSION INST_BIN INST_LIB
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
96 PERL_INC PERL FULLPERL LIBPTH BASE_IMPORT PERLRUN
97 FULLPERLRUN PERLRUNINST FULL_AR PERL_CORE FULLPERLRUNINST
98 NLM_VERSION MPKTOOL TOOLPATH
101 next unless defined $self->{$tmp};
102 push @m, "$tmp = $self->{$tmp}\n";
105 (my $boot = $self->{'NAME'}) =~ s/:/_/g;
106 $self->{'BOOT_SYMBOL'}=$boot;
107 push @m, "BOOT_SYMBOL = $self->{'BOOT_SYMBOL'}\n";
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
113 if(length($self->{'BASEEXT'}) > 8) {
114 $self->{'NLM_SHORT_NAME'} = substr($self->{'BASEEXT'},0,8);
115 push @m, "NLM_SHORT_NAME = $self->{'NLM_SHORT_NAME'}\n";
119 VERSION_MACRO = VERSION
120 DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
121 XS_VERSION_MACRO = XS_VERSION
122 XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
125 # Get the include path and replace the spaces with ;
126 # Copy this to makefile as INCLUDE = d:\...;d:\;
127 (my $inc = $Config{'incpath'}) =~ s/([ ]*)-I/;/g;
132 # Set the path to CodeWarrior binaries which might not have been set in
135 PATH = \$(PATH);\$(TOOLPATH)
139 MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'}
140 MM_VERSION = $ExtUtils::MakeMaker::VERSION
144 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
145 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
146 # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
147 # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
151 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
154 next unless defined $self->{$tmp};
155 push @m, "$tmp = $self->{$tmp}\n";
159 # Handy lists of source code files:
160 XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
161 C_FILES = ".join(" \\\n\t", @{$self->{C}})."
162 O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
163 H_FILES = ".join(" \\\n\t", @{$self->{H}})."
164 MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
165 MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
169 INST_MAN1DIR INSTALLMAN1DIR MAN1EXT
170 INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
172 next unless defined $self->{$tmp};
173 push @m, "$tmp = $self->{$tmp}\n";
181 .NO_CONFIG_REC: Makefile
182 } if $ENV{CLEARCASE_ROOT};
184 # why not q{} ? -- emacs
186 # work around a famous dec-osf make(1) feature(?):
189 .SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
191 # Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
192 # some make implementations will delete the Makefile when we rebuild it. Because
193 # we call false(1) when we rebuild it. So make(1) is not completely wrong when it
194 # does so. Our milage may vary.
195 # .PRECIOUS: Makefile # seems to be not necessary anymore
197 .PHONY: all config static dynamic test linkext manifest
199 # Where is the Config information that we are using/depend on
200 CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h
203 my @parentdir = split(/::/, $self->{PARENT_NAME});
205 # Where to put things:
206 INST_LIBDIR = }. File::Spec->catdir('$(INST_LIB)',@parentdir) .q{
207 INST_ARCHLIBDIR = }. File::Spec->catdir('$(INST_ARCHLIB)',@parentdir) .q{
209 INST_AUTODIR = }. File::Spec->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
210 INST_ARCHAUTODIR = }. File::Spec->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
213 if ($self->has_link_code()) {
215 INST_STATIC = $(INST_ARCHAUTODIR)\$(BASEEXT)$(LIB_EXT)
216 INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT)
217 INST_BOOT = $(INST_ARCHAUTODIR)\$(BASEEXT).bs
227 $tmp = $self->export_list;
231 $tmp = $self->perl_archive;
237 #INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{
239 #PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
243 TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
245 PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
252 my($self, %attribs) = @_;
253 return '' unless $self->needs_linking(); #might be because of a subdir
255 return '' unless $self->has_link_code;
257 my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
258 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
259 my($ldfrom) = '$(LDFROM)';
261 (my $boot = $self->{NAME}) =~ s/:/_/g;
264 # This section creates the dynamically loadable $(INST_DYNAMIC)
265 # from $(OBJECT) and possibly $(MYEXTLIB).
266 OTHERLDFLAGS = '.$otherldflags.'
267 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
269 $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP)
272 # q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) }
273 # .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)});
275 # Create xdc data for an MT safe NLM in case of mpk build
276 # if ( scalar(keys %XS) == 0 ) { return; }
279 q{ @echo $(BASE_IMPORT) >> $(BASEEXT).def
282 q{ @echo Import @$(PERL_INC)\perl.imp >> $(BASEEXT).def
285 if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) {
287 push @m, ' $(MPKTOOL) $(XDCFLAGS) $(BASEEXT).xdc
289 push @m, ' @echo xdcdata $(BASEEXT).xdc >> $(BASEEXT).def
296 q{ $(LD) $(LDFLAGS) $(OBJECT:.obj=.obj) }
300 q{ -desc "Perl 5.7.3 Extension ($(BASEEXT)) XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION) }
303 # Taking care of long names like FileHandle, ByteLoader, SDBM_File etc
304 if($self->{NLM_SHORT_NAME}) {
305 # In case of nlms with names exceeding 8 chars, build nlm in the
306 # current dir, rename and move to auto\lib. If we create in auto\lib
307 # in the first place, we can't rename afterwards.
309 q{ -o $(NLM_SHORT_NAME).$(DLEXT)}
313 q{ -o $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)}
320 # q{ Option XDCDATA=$(BASEEXT).xdc }
324 # Add additional lib files if any (SDBM_File)
325 if($self->{MYEXTLIB}) {
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}
336 q{ $(PERL_INC)\Main.lib}
337 .q{ -commandfile $(BASEEXT).def }
340 # If it is having a short name, rename it
341 if($self->{NLM_SHORT_NAME}) {
343 if exist $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT) del $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)';
345 rename $(NLM_SHORT_NAME).$(DLEXT) $(BASEEXT).$(DLEXT)';
347 move $(BASEEXT).$(DLEXT) $(INST_AUTODIR)';
354 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
364 =item dynamic_lib (o)
366 Defines how to produce the *.so (or equivalent) files.
371 my($self, %attribs) = @_;
372 return '' unless $self->needs_linking(); #might be because of a subdir
374 return '' unless $self->has_link_code;
376 my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
377 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
378 my($ldfrom) = '$(LDFROM)';
380 (my $boot = $self->{NAME}) =~ s/:/_/g;
383 # This section creates the dynamically loadable $(INST_DYNAMIC)
384 # from $(OBJECT) and possibly $(MYEXTLIB).
385 OTHERLDFLAGS = '.$otherldflags.'
386 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
388 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP)
391 # q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) }
392 # .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)});
394 # Create xdc data for an MT safe NLM in case of mpk build
395 # if ( scalar(keys %XS) == 0 ) { return; }
397 q{ @echo Export boot_$(BOOT_SYMBOL) > $(BASEEXT).def
400 q{ @echo $(BASE_IMPORT) >> $(BASEEXT).def
403 q{ @echo Import @$(PERL_INC)\perl.imp >> $(BASEEXT).def
406 if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) {
408 push @m, ' $(MPKTOOL) $(XDCFLAGS) $(BASEEXT).xdc
410 push @m, ' @echo xdcdata $(BASEEXT).xdc >> $(BASEEXT).def
417 q{ $(LD) $(LDFLAGS) $(OBJECT:.obj=.obj) }
421 q{ -desc "Perl 5.7.3 Extension ($(BASEEXT)) XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION) }
424 # Taking care of long names like FileHandle, ByteLoader, SDBM_File etc
425 if($self->{NLM_SHORT_NAME}) {
426 # In case of nlms with names exceeding 8 chars, build nlm in the
427 # current dir, rename and move to auto\lib. If we create in auto\lib
428 # in the first place, we can't rename afterwards.
430 q{ -o $(NLM_SHORT_NAME).$(DLEXT)}
434 q{ -o $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)}
438 # Add additional lib files if any (SDBM_File)
439 if($self->{MYEXTLIB}) {
445 #For now lets comment all the Watcom lib calls
446 #q{ LibPath $(LIBPTH) Library plib3s.lib Library math3s.lib Library clib3s.lib Library emu387.lib Library $(PERL_ARCHIVE) Library $(PERL_INC)\Main.lib}
450 q{ $(PERL_INC)\Main.lib}
451 .q{ -commandfile $(BASEEXT).def }
454 # If it is having a short name, rename it
455 if($self->{NLM_SHORT_NAME}) {
457 if exist $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT) del $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)';
459 rename $(NLM_SHORT_NAME).$(DLEXT) $(BASEEXT).$(DLEXT)';
461 move $(BASEEXT).$(DLEXT) $(INST_AUTODIR)';
468 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');