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;
40 =item init_platform (o)
44 LIBPTH, BASE_IMPORT, NLM_VERSION, MPKTOOL, TOOLPATH, BOOT_SYMBOL,
45 NLM_SHORT_NAME, INCLUDE, PATH, MM_NW5_REVISION
48 =item platform_constants
50 Add Netware macros initialized above to the Makefile.
57 # To get Win32's setup.
58 $self->SUPER::init_platform;
60 # incpath is copied to makefile var INCLUDE in constants sub, here just
62 my $libpth = $Config{'libpth'};
64 $self->{'LIBPTH'} = $libpth;
66 $self->{'BASE_IMPORT'} = $Config{'base_import'};
68 # Additional import file specified from Makefile.pl
69 if($self->{'base_import'}) {
70 $self->{'BASE_IMPORT'} .= ', ' . $self->{'base_import'};
73 $self->{'NLM_VERSION'} = $Config{'nlm_version'};
74 $self->{'MPKTOOL'} = $Config{'mpktool'};
75 $self->{'TOOLPATH'} = $Config{'toolpath'};
77 (my $boot = $self->{'NAME'}) =~ s/:/_/g;
78 $self->{'BOOT_SYMBOL'}=$boot;
80 # If the final binary name is greater than 8 chars,
82 if(length($self->{'BASEEXT'}) > 8) {
83 $self->{'NLM_SHORT_NAME'} = substr($self->{'BASEEXT'},0,8);
86 # Get the include path and replace the spaces with ;
87 # Copy this to makefile as INCLUDE = d:\...;d:\;
88 ($self->{INCLUDE} = $Config{'incpath'}) =~ s/([ ]*)-I/;/g;
90 # Set the path to CodeWarrior binaries which might not have been set in
92 $self->{PATH} = '$(PATH);$(TOOLPATH)';
94 $self->{MM_NW5_VERSION} = $VERSION;
97 sub platform_constants {
101 # Setup Win32's constants.
102 $make_frag .= $self->SUPER::platform_constants;
104 foreach my $macro (qw(LIBPTH BASE_IMPORT NLM_VERSION MPKTOOL
105 TOOLPATH BOOT_SYMBOL NLM_SHORT_NAME INCLUDE PATH
109 next unless defined $self->{$macro};
110 $make_frag .= "$macro = $self->{$macro}\n";
117 =item const_cccmd (o)
122 my($self,$libperl)=@_;
123 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
124 return '' unless $self->needs_linking();
125 return $self->{CONST_CCCMD} = <<'MAKE_FRAG';
126 CCCMD = $(CC) $(CCFLAGS) $(INC) $(OPTIMIZE) \
127 $(PERLTYPE) $(MPOLLUTE) -o $@ \
128 -DVERSION=\"$(VERSION)\" -DXS_VERSION=\"$(XS_VERSION)\"
141 return '' unless $self->has_link_code;
144 $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists
148 # If this extension has it's own library (eg SDBM_File)
149 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
150 $m .= <<'END' if $self->{MYEXTLIB};
151 $self->{CP} $(MYEXTLIB) $@
156 $ar_arg = '$@ $(OBJECT:^"+")';
159 $ar_arg = '-ru $@ $(OBJECT)';
162 $ar_arg = '-type library -o $@ $(OBJECT)';
165 $m .= sprintf <<'END', $ar_arg;
167 $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld
171 $m .= <<'END' if $self->{PERL_SRC};
172 $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs
176 $m .= $self->dir_target('$(INST_ARCHAUTODIR)');
180 =item dynamic_lib (o)
182 Defines how to produce the *.so (or equivalent) files.
187 my($self, %attribs) = @_;
188 return '' unless $self->needs_linking(); #might be because of a subdir
190 return '' unless $self->has_link_code;
192 my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
193 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
194 my($ldfrom) = '$(LDFROM)';
196 (my $boot = $self->{NAME}) =~ s/:/_/g;
198 my $m = <<'MAKE_FRAG';
199 # This section creates the dynamically loadable $(INST_DYNAMIC)
200 # from $(OBJECT) and possibly $(MYEXTLIB).
201 OTHERLDFLAGS = '.$otherldflags.'
202 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
204 # Create xdc data for an MT safe NLM in case of mpk build
205 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP)
206 $(NOECHO) $(ECHO) Export boot_$(BOOT_SYMBOL) > $(BASEEXT).def
207 $(NOECHO) $(ECHO) $(BASE_IMPORT) >> $(BASEEXT).def
208 $(NOECHO) $(ECHO) Import @$(PERL_INC)\perl.imp >> $(BASEEXT).def
212 if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) {
214 $(MPKTOOL) $(XDCFLAGS) $(BASEEXT).xdc
215 $(NOECHO) $(ECHO) xdcdata $(BASEEXT).xdc >> $(BASEEXT).def
219 # Reconstruct the X.Y.Z version.
220 my $version = join '.', map { sprintf "%d", $_ }
221 $] =~ /(\d)\.(\d{3})(\d{2})/;
222 $m .= sprintf ' $(LD) $(LDFLAGS) $(OBJECT:.obj=.obj) -desc "Perl %s Extension ($(BASEEXT)) XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION)', $version;
224 # Taking care of long names like FileHandle, ByteLoader, SDBM_File etc
225 if($self->{NLM_SHORT_NAME}) {
226 # In case of nlms with names exceeding 8 chars, build nlm in the
227 # current dir, rename and move to auto\lib.
228 $m .= q{ -o $(NLM_SHORT_NAME).$(DLEXT)}
230 $m .= q{ -o $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)}
233 # Add additional lib files if any (SDBM_File)
234 $m .= q{ $(MYEXTLIB) } if $self->{MYEXTLIB};
236 $m .= q{ $(PERL_INC)\Main.lib -commandfile $(BASEEXT).def}."\n";
238 if($self->{NLM_SHORT_NAME}) {
240 if exist $(INST_AUTODIR)\$(NLM_SHORT_NAME).$(DLEXT) del $(INST_AUTODIR)\$(NLM_SHORT_NAME).$(DLEXT)
241 move $(NLM_SHORT_NAME).$(DLEXT) $(INST_AUTODIR)
250 $m .= $self->dir_target('$(INST_ARCHAUTODIR)');