blib/lib/ExtUtils/MM_NW5.pm untested

filter: Statementstmt 0.0% 0 / 76 Branchbran 0.0% 0 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 111 CC 11 SCAR 26.7
CC
11
Cov
0%
xs_make_dynamic_lib
30.0
static_lib_pure_cmd
20.0
init_platform
12.0
CRAP 14.5
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 ExtUtils::MakeMaker::Config;
23 use File::Basename;
24  
25 our $VERSION = '7.13_01';
26 $VERSION = eval $VERSION;
27  
28 require ExtUtils::MM_Win32;
29 our @ISA = qw(ExtUtils::MM_Win32);
30  
31 use ExtUtils::MakeMaker qw(&neatvalue &_sprintf562);
32  
33 $ENV{EMXSHELL} = 'sh'; # to run `commands`
34  
35 my $BORLAND = $Config{'cc'} =~ /\bbcc/i;
36 my $GCC = $Config{'cc'} =~ /\bgcc/i;
37  
38  
39 =item os_flavor
40  
41 We're Netware in addition to being Windows.
42  
43 =cut
44  
45 sub os_flavor {
46 my $self = shift;
47 return ($self->SUPER::os_flavor, 'Netware');
48 }
49  
50 =item init_platform
51  
52 Add Netware macros.
53  
54 LIBPTH, BASE_IMPORT, NLM_VERSION, MPKTOOL, TOOLPATH, BOOT_SYMBOL,
55 NLM_SHORT_NAME, INCLUDE, PATH, MM_NW5_REVISION
56  
57  
58 =item platform_constants
59  
60 Add Netware macros initialized above to the Makefile.
61  
62 =cut
63  
64 sub init_platform {
65 my($self) = shift;
66  
67 # To get Win32's setup.
68 $self->SUPER::init_platform;
69  
70 # incpath is copied to makefile var INCLUDE in constants sub, here just
71 # make it empty
72 my $libpth = $Config{'libpth'};
73 $libpth =~ s( )(;);
74 $self->{'LIBPTH'} = $libpth;
75  
76 $self->{'BASE_IMPORT'} = $Config{'base_import'};
77  
78 # Additional import file specified from Makefile.pl
79 if($self->{'base_import'}) {
80 $self->{'BASE_IMPORT'} .= ', ' . $self->{'base_import'};
81 }
82  
83 $self->{'NLM_VERSION'} = $Config{'nlm_version'};
84 $self->{'MPKTOOL'} = $Config{'mpktool'};
85 $self->{'TOOLPATH'} = $Config{'toolpath'};
86  
87 (my $boot = $self->{'NAME'}) =~ s/:/_/g;
88 $self->{'BOOT_SYMBOL'}=$boot;
89  
90 # If the final binary name is greater than 8 chars,
91 # truncate it here.
92 if(length($self->{'BASEEXT'}) > 8) {
93 $self->{'NLM_SHORT_NAME'} = substr($self->{'BASEEXT'},0,8);
94 }
95  
96 # Get the include path and replace the spaces with ;
97 # Copy this to makefile as INCLUDE = d:\...;d:\;
98 ($self->{INCLUDE} = $Config{'incpath'}) =~ s/([ ]*)-I/;/g;
99  
100 # Set the path to CodeWarrior binaries which might not have been set in
101 # any other place
102 $self->{PATH} = '$(PATH);$(TOOLPATH)';
103  
104 $self->{MM_NW5_VERSION} = $VERSION;
105 }
106  
107 sub platform_constants {
108 my($self) = shift;
109 my $make_frag = '';
110  
111 # Setup Win32's constants.
112 $make_frag .= $self->SUPER::platform_constants;
113  
114 foreach my $macro (qw(LIBPTH BASE_IMPORT NLM_VERSION MPKTOOL
115 TOOLPATH BOOT_SYMBOL NLM_SHORT_NAME INCLUDE PATH
116 MM_NW5_VERSION
117 ))
118 {
119 next unless defined $self->{$macro};
120 $make_frag .= "$macro = $self->{$macro}\n";
121 }
122  
123 return $make_frag;
124 }
125  
126 =item static_lib_pure_cmd
127  
128 Defines how to run the archive utility
129  
130 =cut
131  
132 sub static_lib_pure_cmd {
133 my ($self, $src) = @_;
134 $src =~ s/(\$\(\w+)(\))/$1:^"+"$2/g if $BORLAND;
135 sprintf qq{\t\$(AR) %s\n}, ($BORLAND ? '$@ ' . $src
136 : ($GCC ? '-ru $@ ' . $src
137 : '-type library -o $@ ' . $src));
138 }
139  
140 =item dynamic_lib
141  
142 Override of utility methods for OS-specific work.
143  
144 =cut
145  
146 sub xs_make_dynamic_lib {
147 my ($self, $attribs, $from, $to, $todir, $ldfrom, $exportlist) = @_;
148 my @m;
149 # Taking care of long names like FileHandle, ByteLoader, SDBM_File etc
150 if ($to =~ /^\$/) {
151 if ($self->{NLM_SHORT_NAME}) {
152 # deal with shortnames
153 my $newto = q{$(INST_AUTODIR)\\$(NLM_SHORT_NAME).$(DLEXT)};
154 push @m, "$to: $newto\n\n";
155 $to = $newto;
156 }
157 } else {
158 my ($v, $d, $f) = File::Spec->splitpath($to);
159 # relies on $f having a literal "." in it, unlike for $(OBJ_EXT)
160 if ($f =~ /[^\.]{9}\./) {
161 # 9+ chars before '.', need to shorten
162 $f = substr $f, 0, 8;
163 }
164 my $newto = File::Spec->catpath($v, $d, $f);
165 push @m, "$to: $newto\n\n";
166 $to = $newto;
167 }
168 # bits below should be in dlsyms, not here
169 # 1 2 3 4
170 push @m, _sprintf562 <<'MAKE_FRAG', $to, $from, $todir, $exportlist;
171 # Create xdc data for an MT safe NLM in case of mpk build
172 %1$s: %2$s $(MYEXTLIB) $(BOOTSTRAP) %3$s$(DFSEP).exists
173 $(NOECHO) $(ECHO) Export boot_$(BOOT_SYMBOL) > %4$s
174 $(NOECHO) $(ECHO) $(BASE_IMPORT) >> %4$s
175 $(NOECHO) $(ECHO) Import @$(PERL_INC)\perl.imp >> %4$s
176 MAKE_FRAG
177 if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) {
178 (my $xdc = $exportlist) =~ s#def\z#xdc#;
179 $xdc = '$(BASEEXT).xdc';
180 push @m, sprintf <<'MAKE_FRAG', $xdc, $exportlist;
181 $(MPKTOOL) $(XDCFLAGS) %s
182 $(NOECHO) $(ECHO) xdcdata $(BASEEXT).xdc >> %s
183 MAKE_FRAG
184 }
185 # Reconstruct the X.Y.Z version.
186 my $version = join '.', map { sprintf "%d", $_ }
187 $] =~ /(\d)\.(\d{3})(\d{2})/;
188 push @m, sprintf <<'EOF', $from, $version, $to, $exportlist;
189 $(LD) $(LDFLAGS) %s -desc "Perl %s Extension ($(BASEEXT)) XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION) -o %s $(MYEXTLIB) $(PERL_INC)\Main.lib -commandfile %s
190 $(CHMOD) 755 $@
191 EOF
192 join '', @m;
193 }
194  
195 1;
196 __END__