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