| 1 |
root |
1.1 |
package ExtUtils::MM_NW5; |
| 2 |
|
|
|
| 3 |
|
|
=head1 NAME |
| 4 |
|
|
|
| 5 |
|
|
ExtUtils::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 |
|
|
|
| 13 |
|
|
See ExtUtils::MM_Unix for a documentation of the methods provided |
| 14 |
|
|
there. This package overrides the implementation of these methods, not |
| 15 |
|
|
the semantics. |
| 16 |
|
|
|
| 17 |
|
|
=over |
| 18 |
|
|
|
| 19 |
|
|
=cut |
| 20 |
|
|
|
| 21 |
|
|
use strict; |
| 22 |
|
|
use Config; |
| 23 |
|
|
use File::Basename; |
| 24 |
|
|
|
| 25 |
|
|
use vars qw(@ISA $VERSION); |
| 26 |
|
|
# Has same version as blead, but differs. Must resync when next CPAN release |
| 27 |
|
|
# of MM is merged from blead to maint |
| 28 |
|
|
$VERSION = '2.07_02'; |
| 29 |
|
|
|
| 30 |
|
|
require ExtUtils::MM_Win32; |
| 31 |
|
|
@ISA = qw(ExtUtils::MM_Win32); |
| 32 |
|
|
|
| 33 |
|
|
use ExtUtils::MakeMaker qw( &neatvalue ); |
| 34 |
|
|
|
| 35 |
|
|
$ENV{EMXSHELL} = 'sh'; # to run `commands` |
| 36 |
|
|
|
| 37 |
|
|
my $BORLAND = $Config{'cc'} =~ /^bcc/i; |
| 38 |
|
|
my $GCC = $Config{'cc'} =~ /^gcc/i; |
| 39 |
|
|
my $DMAKE = $Config{'make'} =~ /^dmake/i; |
| 40 |
|
|
|
| 41 |
|
|
|
| 42 |
|
|
=item os_flavor |
| 43 |
|
|
|
| 44 |
|
|
We're Netware in addition to being Windows. |
| 45 |
|
|
|
| 46 |
|
|
=cut |
| 47 |
|
|
|
| 48 |
|
|
sub os_flavor { |
| 49 |
|
|
my $self = shift; |
| 50 |
|
|
return ($self->SUPER::os_flavor, 'Netware'); |
| 51 |
|
|
} |
| 52 |
|
|
|
| 53 |
|
|
=item init_platform (o) |
| 54 |
|
|
|
| 55 |
|
|
Add Netware macros. |
| 56 |
|
|
|
| 57 |
|
|
LIBPTH, BASE_IMPORT, NLM_VERSION, MPKTOOL, TOOLPATH, BOOT_SYMBOL, |
| 58 |
|
|
NLM_SHORT_NAME, INCLUDE, PATH, MM_NW5_REVISION |
| 59 |
|
|
|
| 60 |
|
|
|
| 61 |
|
|
=item platform_constants |
| 62 |
|
|
|
| 63 |
|
|
Add Netware macros initialized above to the Makefile. |
| 64 |
|
|
|
| 65 |
|
|
=cut |
| 66 |
|
|
|
| 67 |
|
|
sub init_platform { |
| 68 |
|
|
my($self) = shift; |
| 69 |
|
|
|
| 70 |
|
|
# To get Win32's setup. |
| 71 |
|
|
$self->SUPER::init_platform; |
| 72 |
|
|
|
| 73 |
|
|
# incpath is copied to makefile var INCLUDE in constants sub, here just |
| 74 |
|
|
# make it empty |
| 75 |
|
|
my $libpth = $Config{'libpth'}; |
| 76 |
|
|
$libpth =~ s( )(;); |
| 77 |
|
|
$self->{'LIBPTH'} = $libpth; |
| 78 |
|
|
|
| 79 |
|
|
$self->{'BASE_IMPORT'} = $Config{'base_import'}; |
| 80 |
|
|
|
| 81 |
|
|
# Additional import file specified from Makefile.pl |
| 82 |
|
|
if($self->{'base_import'}) { |
| 83 |
|
|
$self->{'BASE_IMPORT'} .= ', ' . $self->{'base_import'}; |
| 84 |
|
|
} |
| 85 |
|
|
|
| 86 |
|
|
$self->{'NLM_VERSION'} = $Config{'nlm_version'}; |
| 87 |
|
|
$self->{'MPKTOOL'} = $Config{'mpktool'}; |
| 88 |
|
|
$self->{'TOOLPATH'} = $Config{'toolpath'}; |
| 89 |
|
|
|
| 90 |
|
|
(my $boot = $self->{'NAME'}) =~ s/:/_/g; |
| 91 |
|
|
$self->{'BOOT_SYMBOL'}=$boot; |
| 92 |
|
|
|
| 93 |
|
|
# If the final binary name is greater than 8 chars, |
| 94 |
|
|
# truncate it here. |
| 95 |
|
|
if(length($self->{'BASEEXT'}) > 8) { |
| 96 |
|
|
$self->{'NLM_SHORT_NAME'} = substr($self->{'BASEEXT'},0,8); |
| 97 |
|
|
} |
| 98 |
|
|
|
| 99 |
|
|
# Get the include path and replace the spaces with ; |
| 100 |
|
|
# Copy this to makefile as INCLUDE = d:\...;d:\; |
| 101 |
|
|
($self->{INCLUDE} = $Config{'incpath'}) =~ s/([ ]*)-I/;/g; |
| 102 |
|
|
|
| 103 |
|
|
# Set the path to CodeWarrior binaries which might not have been set in |
| 104 |
|
|
# any other place |
| 105 |
|
|
$self->{PATH} = '$(PATH);$(TOOLPATH)'; |
| 106 |
|
|
|
| 107 |
|
|
$self->{MM_NW5_VERSION} = $VERSION; |
| 108 |
|
|
} |
| 109 |
|
|
|
| 110 |
|
|
sub platform_constants { |
| 111 |
|
|
my($self) = shift; |
| 112 |
|
|
my $make_frag = ''; |
| 113 |
|
|
|
| 114 |
|
|
# Setup Win32's constants. |
| 115 |
|
|
$make_frag .= $self->SUPER::platform_constants; |
| 116 |
|
|
|
| 117 |
|
|
foreach my $macro (qw(LIBPTH BASE_IMPORT NLM_VERSION MPKTOOL |
| 118 |
|
|
TOOLPATH BOOT_SYMBOL NLM_SHORT_NAME INCLUDE PATH |
| 119 |
|
|
MM_NW5_VERSION |
| 120 |
|
|
)) |
| 121 |
|
|
{ |
| 122 |
|
|
next unless defined $self->{$macro}; |
| 123 |
|
|
$make_frag .= "$macro = $self->{$macro}\n"; |
| 124 |
|
|
} |
| 125 |
|
|
|
| 126 |
|
|
return $make_frag; |
| 127 |
|
|
} |
| 128 |
|
|
|
| 129 |
|
|
|
| 130 |
|
|
=item const_cccmd (o) |
| 131 |
|
|
|
| 132 |
|
|
=cut |
| 133 |
|
|
|
| 134 |
|
|
sub const_cccmd { |
| 135 |
|
|
my($self,$libperl)=@_; |
| 136 |
|
|
return $self->{CONST_CCCMD} if $self->{CONST_CCCMD}; |
| 137 |
|
|
return '' unless $self->needs_linking(); |
| 138 |
|
|
return $self->{CONST_CCCMD} = <<'MAKE_FRAG'; |
| 139 |
|
|
CCCMD = $(CC) $(CCFLAGS) $(INC) $(OPTIMIZE) \ |
| 140 |
|
|
$(PERLTYPE) $(MPOLLUTE) -o $@ \ |
| 141 |
|
|
-DVERSION=\"$(VERSION)\" -DXS_VERSION=\"$(XS_VERSION)\" |
| 142 |
|
|
MAKE_FRAG |
| 143 |
|
|
|
| 144 |
|
|
} |
| 145 |
|
|
|
| 146 |
|
|
|
| 147 |
|
|
=item static_lib (o) |
| 148 |
|
|
|
| 149 |
|
|
=cut |
| 150 |
|
|
|
| 151 |
|
|
sub static_lib { |
| 152 |
|
|
my($self) = @_; |
| 153 |
|
|
|
| 154 |
|
|
return '' unless $self->has_link_code; |
| 155 |
|
|
|
| 156 |
|
|
my $m = <<'END'; |
| 157 |
|
|
$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists |
| 158 |
|
|
$(RM_RF) $@ |
| 159 |
|
|
END |
| 160 |
|
|
|
| 161 |
|
|
# If this extension has it's own library (eg SDBM_File) |
| 162 |
|
|
# then copy that to $(INST_STATIC) and add $(OBJECT) into it. |
| 163 |
|
|
$m .= <<'END' if $self->{MYEXTLIB}; |
| 164 |
|
|
$self->{CP} $(MYEXTLIB) $@ |
| 165 |
|
|
END |
| 166 |
|
|
|
| 167 |
|
|
my $ar_arg; |
| 168 |
|
|
if( $BORLAND ) { |
| 169 |
|
|
$ar_arg = '$@ $(OBJECT:^"+")'; |
| 170 |
|
|
} |
| 171 |
|
|
elsif( $GCC ) { |
| 172 |
|
|
$ar_arg = '-ru $@ $(OBJECT)'; |
| 173 |
|
|
} |
| 174 |
|
|
else { |
| 175 |
|
|
$ar_arg = '-type library -o $@ $(OBJECT)'; |
| 176 |
|
|
} |
| 177 |
|
|
|
| 178 |
|
|
$m .= sprintf <<'END', $ar_arg; |
| 179 |
|
|
$(AR) %s |
| 180 |
|
|
$(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld |
| 181 |
|
|
$(CHMOD) 755 $@ |
| 182 |
|
|
END |
| 183 |
|
|
|
| 184 |
|
|
$m .= <<'END' if $self->{PERL_SRC}; |
| 185 |
|
|
$(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs |
| 186 |
|
|
|
| 187 |
|
|
|
| 188 |
|
|
END |
| 189 |
|
|
$m .= $self->dir_target('$(INST_ARCHAUTODIR)'); |
| 190 |
|
|
return $m; |
| 191 |
|
|
} |
| 192 |
|
|
|
| 193 |
|
|
=item dynamic_lib (o) |
| 194 |
|
|
|
| 195 |
|
|
Defines how to produce the *.so (or equivalent) files. |
| 196 |
|
|
|
| 197 |
|
|
=cut |
| 198 |
|
|
|
| 199 |
|
|
sub dynamic_lib { |
| 200 |
|
|
my($self, %attribs) = @_; |
| 201 |
|
|
return '' unless $self->needs_linking(); #might be because of a subdir |
| 202 |
|
|
|
| 203 |
|
|
return '' unless $self->has_link_code; |
| 204 |
|
|
|
| 205 |
|
|
my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': ''); |
| 206 |
|
|
my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || ""; |
| 207 |
|
|
my($ldfrom) = '$(LDFROM)'; |
| 208 |
|
|
|
| 209 |
|
|
(my $boot = $self->{NAME}) =~ s/:/_/g; |
| 210 |
|
|
|
| 211 |
|
|
my $m = <<'MAKE_FRAG'; |
| 212 |
|
|
# This section creates the dynamically loadable $(INST_DYNAMIC) |
| 213 |
|
|
# from $(OBJECT) and possibly $(MYEXTLIB). |
| 214 |
|
|
OTHERLDFLAGS = '.$otherldflags.' |
| 215 |
|
|
INST_DYNAMIC_DEP = '.$inst_dynamic_dep.' |
| 216 |
|
|
|
| 217 |
|
|
# Create xdc data for an MT safe NLM in case of mpk build |
| 218 |
|
|
$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) |
| 219 |
|
|
$(NOECHO) $(ECHO) Export boot_$(BOOT_SYMBOL) > $(BASEEXT).def |
| 220 |
|
|
$(NOECHO) $(ECHO) $(BASE_IMPORT) >> $(BASEEXT).def |
| 221 |
|
|
$(NOECHO) $(ECHO) Import @$(PERL_INC)\perl.imp >> $(BASEEXT).def |
| 222 |
|
|
MAKE_FRAG |
| 223 |
|
|
|
| 224 |
|
|
|
| 225 |
|
|
if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) { |
| 226 |
|
|
$m .= <<'MAKE_FRAG'; |
| 227 |
|
|
$(MPKTOOL) $(XDCFLAGS) $(BASEEXT).xdc |
| 228 |
|
|
$(NOECHO) $(ECHO) xdcdata $(BASEEXT).xdc >> $(BASEEXT).def |
| 229 |
|
|
MAKE_FRAG |
| 230 |
|
|
} |
| 231 |
|
|
|
| 232 |
|
|
# Reconstruct the X.Y.Z version. |
| 233 |
|
|
my $version = join '.', map { sprintf "%d", $_ } |
| 234 |
|
|
$] =~ /(\d)\.(\d{3})(\d{2})/; |
| 235 |
|
|
$m .= sprintf ' $(LD) $(LDFLAGS) $(OBJECT:.obj=.obj) -desc "Perl %s Extension ($(BASEEXT)) XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION)', $version; |
| 236 |
|
|
|
| 237 |
|
|
# Taking care of long names like FileHandle, ByteLoader, SDBM_File etc |
| 238 |
|
|
if($self->{NLM_SHORT_NAME}) { |
| 239 |
|
|
# In case of nlms with names exceeding 8 chars, build nlm in the |
| 240 |
|
|
# current dir, rename and move to auto\lib. |
| 241 |
|
|
$m .= q{ -o $(NLM_SHORT_NAME).$(DLEXT)} |
| 242 |
|
|
} else { |
| 243 |
|
|
$m .= q{ -o $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)} |
| 244 |
|
|
} |
| 245 |
|
|
|
| 246 |
|
|
# Add additional lib files if any (SDBM_File) |
| 247 |
|
|
$m .= q{ $(MYEXTLIB) } if $self->{MYEXTLIB}; |
| 248 |
|
|
|
| 249 |
|
|
$m .= q{ $(PERL_INC)\Main.lib -commandfile $(BASEEXT).def}."\n"; |
| 250 |
|
|
|
| 251 |
|
|
if($self->{NLM_SHORT_NAME}) { |
| 252 |
|
|
$m .= <<'MAKE_FRAG'; |
| 253 |
|
|
if exist $(INST_AUTODIR)\$(NLM_SHORT_NAME).$(DLEXT) del $(INST_AUTODIR)\$(NLM_SHORT_NAME).$(DLEXT) |
| 254 |
|
|
move $(NLM_SHORT_NAME).$(DLEXT) $(INST_AUTODIR) |
| 255 |
|
|
MAKE_FRAG |
| 256 |
|
|
} |
| 257 |
|
|
|
| 258 |
|
|
$m .= <<'MAKE_FRAG'; |
| 259 |
|
|
|
| 260 |
|
|
$(CHMOD) 755 $@ |
| 261 |
|
|
MAKE_FRAG |
| 262 |
|
|
|
| 263 |
|
|
$m .= $self->dir_target('$(INST_ARCHAUTODIR)'); |
| 264 |
|
|
|
| 265 |
|
|
return $m; |
| 266 |
|
|
} |
| 267 |
|
|
|
| 268 |
|
|
|
| 269 |
|
|
1; |
| 270 |
|
|
__END__ |
| 271 |
|
|
|
| 272 |
|
|
=back |
| 273 |
|
|
|
| 274 |
|
|
=cut |
| 275 |
|
|
|
| 276 |
|
|
|