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
23 use vars qw(@ISA $VERSION);
26 require ExtUtils::MM_Win32;
27 @ISA = qw(ExtUtils::MM_Win32);
29 use ExtUtils::MakeMaker qw( &neatvalue );
31 $ENV{EMXSHELL} = 'sh'; # to run `commands`
33 $BORLAND = 1 if $Config{'cc'} =~ /^bcc/i;
34 $GCC = 1 if $Config{'cc'} =~ /^gcc/i;
35 $DMAKE = 1 if $Config{'make'} =~ /^dmake/i;
36 $NMAKE = 1 if $Config{'make'} =~ /^nmake/i;
37 $PERLMAKE = 1 if $Config{'make'} =~ /^pmake/i;
44 $self->SUPER::init_others(@_);
46 # incpath is copied to makefile var INCLUDE in constants sub, here just make it empty
47 my $libpth = $Config{'libpth'};
49 $self->{'LIBPTH'} = $libpth;
50 $self->{'BASE_IMPORT'} = $Config{'base_import'};
52 # Additional import file specified from Makefile.pl
53 if($self->{'base_import'}) {
54 $self->{'BASE_IMPORT'} .= ', ' . $self->{'base_import'};
57 $self->{'NLM_VERSION'} = $Config{'nlm_version'};
58 $self->{'MPKTOOL'} = $Config{'mpktool'};
59 $self->{'TOOLPATH'} = $Config{'toolpath'};
65 Initializes lots of constants and .SUFFIXES and .PHONY
70 my($self,$libperl)=@_;
71 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
72 return '' unless $self->needs_linking();
73 return $self->{CONST_CCCMD} =
74 q{CCCMD = $(CC) $(CCFLAGS) $(INC) $(OPTIMIZE) \\
75 $(PERLTYPE) $(MPOLLUTE) -o $@ \\
76 -DVERSION=\"$(VERSION)\" -DXS_VERSION=\"$(XS_VERSION)\"};
83 # Added LIBPTH, BASE_IMPORT, ABSTRACT, NLM_VERSION BOOT_SYMBOL, NLM_SHORT_NAME
88 AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION
89 VERSION_SYM XS_VERSION INST_BIN INST_LIB
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
95 PERL_INC PERL FULLPERL LIBPTH BASE_IMPORT PERLRUN FULLPERLRUN PERLRUNINST
96 FULL_AR PERL_CORE FULLPERLRUNINST NLM_VERSION MPKTOOL TOOLPATH
99 next unless defined $self->{$tmp};
100 push @m, "$tmp = $self->{$tmp}\n";
103 (my $boot = $self->{'NAME'}) =~ s/:/_/g;
104 $self->{'BOOT_SYMBOL'}=$boot;
105 push @m, "BOOT_SYMBOL = $self->{'BOOT_SYMBOL'}\n";
107 # If the final binary name is greater than 8 chars,
108 # truncate it here and rename it after creation
109 # 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";
117 VERSION_MACRO = VERSION
118 DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
119 XS_VERSION_MACRO = XS_VERSION
120 XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
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;
127 # Get the additional include path and append to INCLUDE, keep it in
128 # INC will give problems during compilation, hence reset it after getting
138 # Set the path to CodeWarrior binaries which might not have been set in
141 PATH = \$(PATH);\$(TOOLPATH)
145 MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'}
146 MM_VERSION = $ExtUtils::MakeMaker::VERSION
150 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
151 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
152 # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
153 # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
157 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
160 next unless defined $self->{$tmp};
161 push @m, "$tmp = $self->{$tmp}\n";
165 # Handy lists of source code files:
166 XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
167 C_FILES = ".join(" \\\n\t", @{$self->{C}})."
168 O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
169 H_FILES = ".join(" \\\n\t", @{$self->{H}})."
170 MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
171 MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
175 INST_MAN1DIR INSTALLMAN1DIR MAN1EXT
176 INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
178 next unless defined $self->{$tmp};
179 push @m, "$tmp = $self->{$tmp}\n";
187 .NO_CONFIG_REC: Makefile
188 } if $ENV{CLEARCASE_ROOT};
190 # why not q{} ? -- emacs
192 # work around a famous dec-osf make(1) feature(?):
195 .SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
197 # Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
198 # some make implementations will delete the Makefile when we rebuild it. Because
199 # we call false(1) when we rebuild it. So make(1) is not completely wrong when it
200 # does so. Our milage may vary.
201 # .PRECIOUS: Makefile # seems to be not necessary anymore
203 .PHONY: all config static dynamic test linkext manifest
205 # Where is the Config information that we are using/depend on
206 CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h
209 my @parentdir = split(/::/, $self->{PARENT_NAME});
211 # Where to put things:
212 INST_LIBDIR = }. File::Spec->catdir('$(INST_LIB)',@parentdir) .q{
213 INST_ARCHLIBDIR = }. File::Spec->catdir('$(INST_ARCHLIB)',@parentdir) .q{
215 INST_AUTODIR = }. File::Spec->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
216 INST_ARCHAUTODIR = }. File::Spec->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
219 if ($self->has_link_code()) {
221 INST_STATIC = $(INST_ARCHAUTODIR)\$(BASEEXT)$(LIB_EXT)
222 INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT)
223 INST_BOOT = $(INST_ARCHAUTODIR)\$(BASEEXT).bs
233 $tmp = $self->export_list;
237 $tmp = $self->perl_archive;
243 #INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{
245 #PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
249 TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
251 PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
259 # Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
260 # return '' unless $self->needs_linking(); #might be because of a subdir
262 return '' unless $self->has_link_code;
266 $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)\.exists
270 # If this extension has it's own library (eg SDBM_File)
271 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
272 push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
275 q{ $(AR) }.($BORLAND ? '$@ $(OBJECT:^"+")'
276 : ($GCC ? '-ru $@ $(OBJECT)'
277 : '-type library -o $@ $(OBJECT)')).q{
278 }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld
281 # CW change ( -type library ... )
282 # Old mechanism - still available:
284 push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs}."\n\n"
285 if $self->{PERL_SRC};
287 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
292 =item dynamic_lib (o)
294 Defines how to produce the *.so (or equivalent) files.
299 my($self, %attribs) = @_;
300 return '' unless $self->needs_linking(); #might be because of a subdir
302 return '' unless $self->has_link_code;
304 my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
305 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
306 my($ldfrom) = '$(LDFROM)';
308 (my $boot = $self->{NAME}) =~ s/:/_/g;
311 # This section creates the dynamically loadable $(INST_DYNAMIC)
312 # from $(OBJECT) and possibly $(MYEXTLIB).
313 OTHERLDFLAGS = '.$otherldflags.'
314 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
316 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP)
319 # q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) }
320 # .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)});
322 # Create xdc data for an MT safe NLM in case of mpk build
323 # if ( scalar(keys %XS) == 0 ) { return; }
325 q{ @echo Export boot_$(BOOT_SYMBOL) > $(BASEEXT).def
328 q{ @echo $(BASE_IMPORT) >> $(BASEEXT).def
331 q{ @echo Import @$(PERL_INC)\perl.imp >> $(BASEEXT).def
334 if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) {
336 push @m, ' $(MPKTOOL) $(XDCFLAGS) $(BASEEXT).xdc
338 push @m, ' @echo xdcdata $(BASEEXT).xdc >> $(BASEEXT).def
345 q{ $(LD) $(LDFLAGS) $(OBJECT:.obj=.obj) }
349 q{ -desc "Perl 5.7.3 Extension ($(BASEEXT)) XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION) }
352 # Taking care of long names like FileHandle, ByteLoader, SDBM_File etc
353 if($self->{NLM_SHORT_NAME}) {
354 # In case of nlms with names exceeding 8 chars, build nlm in the
355 # current dir, rename and move to auto\lib. If we create in auto\lib
356 # in the first place, we can't rename afterwards.
358 q{ -o $(NLM_SHORT_NAME).$(DLEXT)}
362 q{ -o $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)}
365 # Add additional lib files if any (SDBM_File)
366 if($self->{MYEXTLIB}) {
372 #For now lets comment all the Watcom lib calls
373 #q{ LibPath $(LIBPTH) Library plib3s.lib Library math3s.lib Library clib3s.lib Library emu387.lib Library $(PERL_ARCHIVE) Library $(PERL_INC)\Main.lib}
377 q{ $(PERL_INC)\Main.lib}
378 .q{ -commandfile $(BASEEXT).def }
381 # If it is having a short name, rename it
382 if($self->{NLM_SHORT_NAME}) {
384 if exist $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT) del $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)';
386 rename $(NLM_SHORT_NAME).$(DLEXT) $(BASEEXT).$(DLEXT)';
388 move $(BASEEXT).$(DLEXT) $(INST_AUTODIR)';
395 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');