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
25 use vars qw(@ISA $VERSION);
28 require ExtUtils::MM_Win32;
29 @ISA = qw(ExtUtils::MM_Win32);
31 use ExtUtils::MakeMaker qw( &neatvalue );
33 $ENV{EMXSHELL} = 'sh'; # to run `commands`
35 my $BORLAND = 1 if $Config{'cc'} =~ /^bcc/i;
36 my $GCC = 1 if $Config{'cc'} =~ /^gcc/i;
37 my $DMAKE = 1 if $Config{'make'} =~ /^dmake/i;
42 $self->SUPER::init_others(@_);
44 # incpath is copied to makefile var INCLUDE in constants sub, here just
46 my $libpth = $Config{'libpth'};
48 $self->{'LIBPTH'} = $libpth;
49 $self->{'BASE_IMPORT'} = $Config{'base_import'};
51 # Additional import file specified from Makefile.pl
52 if($self->{'base_import'}) {
53 $self->{'BASE_IMPORT'} .= ', ' . $self->{'base_import'};
56 $self->{'NLM_VERSION'} = $Config{'nlm_version'};
57 $self->{'MPKTOOL'} = $Config{'mpktool'};
58 $self->{'TOOLPATH'} = $Config{'toolpath'};
64 Initializes lots of constants and .SUFFIXES and .PHONY
69 my($self,$libperl)=@_;
70 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
71 return '' unless $self->needs_linking();
72 return $self->{CONST_CCCMD} = <<'MAKE_FRAG';
73 CCCMD = $(CC) $(CCFLAGS) $(INC) $(OPTIMIZE) \
74 $(PERLTYPE) $(MPOLLUTE) -o $@ \
75 -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 FULLPERLRUNINST
98 FULL_AR PERL_CORE 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
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";
118 VERSION_MACRO = VERSION
119 DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
120 XS_VERSION_MACRO = XS_VERSION
121 XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
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;
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
137 # Set the path to CodeWarrior binaries which might not have been set in
140 PATH = \$(PATH);\$(TOOLPATH)
144 MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'}
145 MM_VERSION = $ExtUtils::MakeMaker::VERSION
149 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
150 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
151 # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
152 # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
156 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
159 next unless defined $self->{$tmp};
160 push @m, "$tmp = $self->{$tmp}\n";
164 # Handy lists of source code files:
165 XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
166 C_FILES = ".join(" \\\n\t", @{$self->{C}})."
167 O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
168 H_FILES = ".join(" \\\n\t", @{$self->{H}})."
169 MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
170 MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
174 INST_MAN1DIR INSTALLMAN1DIR MAN1EXT
175 INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
177 next unless defined $self->{$tmp};
178 push @m, "$tmp = $self->{$tmp}\n";
186 .NO_CONFIG_REC: Makefile
187 } if $ENV{CLEARCASE_ROOT};
189 # why not q{} ? -- emacs
191 # work around a famous dec-osf make(1) feature(?):
194 .SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
196 .PHONY: all config static dynamic test linkext manifest
198 # Where is the Config information that we are using/depend on
199 CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h
202 my @parentdir = split(/::/, $self->{PARENT_NAME});
204 # Where to put things:
205 INST_LIBDIR = }. File::Spec->catdir('$(INST_LIB)',@parentdir) .q{
206 INST_ARCHLIBDIR = }. File::Spec->catdir('$(INST_ARCHLIB)',@parentdir) .q{
208 INST_AUTODIR = }. File::Spec->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
209 INST_ARCHAUTODIR = }. File::Spec->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
212 if ($self->has_link_code()) {
214 INST_STATIC = $(INST_ARCHAUTODIR)\$(BASEEXT)$(LIB_EXT)
215 INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT)
216 INST_BOOT = $(INST_ARCHAUTODIR)\$(BASEEXT).bs
226 $tmp = $self->export_list;
230 $tmp = $self->perl_archive;
236 TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
238 PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
252 return '' unless $self->has_link_code;
255 $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)\.exists
259 # If this extension has it's own library (eg SDBM_File)
260 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
261 $m .= <<'END' if $self->{MYEXTLIB};
262 $self->{CP} $(MYEXTLIB) $@
267 $ar_arg = '$@ $(OBJECT:^"+")';
270 $ar_arg = '-ru $@ $(OBJECT)';
273 $ar_arg = '-type library -o $@ $(OBJECT)';
276 $m .= sprintf <<'END', $ar_arg;
278 $(NOECHO)echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld
282 $m .= <<'END' if $self->{PERL_SRC};
283 $(NOECHO)echo "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs
287 $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;
310 my $m = <<'MAKE_FRAG';
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 # Create xdc data for an MT safe NLM in case of mpk build
317 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP)
318 @echo Export boot_$(BOOT_SYMBOL) > $(BASEEXT).def
319 @echo $(BASE_IMPORT) >> $(BASEEXT).def
320 @echo Import @$(PERL_INC)\perl.imp >> $(BASEEXT).def
324 if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) {
326 $(MPKTOOL) $(XDCFLAGS) $(BASEEXT).xdc
327 @echo xdcdata $(BASEEXT).xdc >> $(BASEEXT).def
331 $m .= ' $(LD) $(LDFLAGS) $(OBJECT:.obj=.obj) -desc "Perl 5.7.3 Extension ($(BASEEXT)) XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION)';
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)}
340 $m .= q{ -o $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)}
343 # Add additional lib files if any (SDBM_File)
344 $m .= q{ $(MYEXTLIB) } if $self->{MYEXTLIB};
346 $m .= q{ $(PERL_INC)\Main.lib -commandfile $(BASEEXT).def}."\n";
348 # If it is having a short name, rename it
349 if($self->{NLM_SHORT_NAME}) {
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)
362 $m .= $self->dir_target('$(INST_ARCHAUTODIR)');