Commit | Line | Data |
68dc0745 |
1 | package ExtUtils::MM_Win32; |
2 | |
3 | =head1 NAME |
4 | |
5 | ExtUtils::MM_Win32 - methods to override UN*X behaviour in ExtUtils::MakeMaker |
6 | |
7 | =head1 SYNOPSIS |
8 | |
9 | use ExtUtils::MM_Win32; # 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 | |
3e3baf6d |
21 | use Config; |
68dc0745 |
22 | #use Cwd; |
23 | use File::Basename; |
24 | require Exporter; |
25 | |
26 | Exporter::import('ExtUtils::MakeMaker', |
27 | qw( $Verbose &neatvalue)); |
28 | |
29 | $ENV{EMXSHELL} = 'sh'; # to run `commands` |
30 | unshift @MM::ISA, 'ExtUtils::MM_Win32'; |
31 | |
3e3baf6d |
32 | $BORLAND = 1 if $Config{'cc'} =~ /^bcc/i; |
5b0d9cbe |
33 | $GCC = 1 if $Config{'cc'} =~ /^gcc/i; |
3e3baf6d |
34 | $DMAKE = 1 if $Config{'make'} =~ /^dmake/i; |
35 | $NMAKE = 1 if $Config{'make'} =~ /^nmake/i; |
dc0d354b |
36 | $PERLMAKE = 1 if $Config{'make'} =~ /^pmake/i; |
9d8a25dc |
37 | $OBJ = 1 if $Config{'ccflags'} =~ /PERL_OBJECT/i; |
3e3baf6d |
38 | |
68dc0745 |
39 | sub dlsyms { |
40 | my($self,%attribs) = @_; |
41 | |
42 | my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {}; |
43 | my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || []; |
762efda7 |
44 | my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || []; |
68dc0745 |
45 | my($imports) = $attribs{IMPORTS} || $self->{IMPORTS} || {}; |
46 | my(@m); |
47 | (my $boot = $self->{NAME}) =~ s/:/_/g; |
48 | |
49 | if (not $self->{SKIPHASH}{'dynamic'}) { |
50 | push(@m," |
51 | $self->{BASEEXT}.def: Makefile.PL |
52 | ", |
53 | q! $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Mksymlists \\ |
54 | -e "Mksymlists('NAME' => '!, $self->{NAME}, |
55 | q!', 'DLBASE' => '!,$self->{DLBASE}, |
56 | q!', 'DL_FUNCS' => !,neatvalue($funcs), |
762efda7 |
57 | q!, 'FUNCLIST' => !,neatvalue($funclist), |
68dc0745 |
58 | q!, 'IMPORTS' => !,neatvalue($imports), |
59 | q!, 'DL_VARS' => !, neatvalue($vars), q!);" |
60 | !); |
61 | } |
62 | join('',@m); |
63 | } |
64 | |
65 | sub replace_manpage_separator { |
66 | my($self,$man) = @_; |
67 | $man =~ s,/+,.,g; |
68 | $man; |
69 | } |
70 | |
71 | sub maybe_command { |
72 | my($self,$file) = @_; |
846f184a |
73 | my @e = exists($ENV{'PATHEXT'}) |
74 | ? split(/;/, $ENV{PATHEXT}) |
75 | : qw(.com .exe .bat .cmd); |
76 | my $e = ''; |
77 | for (@e) { $e .= "\Q$_\E|" } |
78 | chop $e; |
79 | # see if file ends in one of the known extensions |
2b2708c8 |
80 | if ($file =~ /($e)$/i) { |
846f184a |
81 | return $file if -e $file; |
82 | } |
83 | else { |
84 | for (@e) { |
85 | return "$file$_" if -e "$file$_"; |
86 | } |
87 | } |
68dc0745 |
88 | return; |
89 | } |
90 | |
91 | sub file_name_is_absolute { |
92 | my($self,$file) = @_; |
93 | $file =~ m{^([a-z]:)?[\\/]}i ; |
94 | } |
95 | |
96 | sub find_perl { |
97 | my($self, $ver, $names, $dirs, $trace) = @_; |
98 | my($name, $dir); |
99 | if ($trace >= 2){ |
100 | print "Looking for perl $ver by these names: |
101 | @$names |
102 | in these dirs: |
103 | @$dirs |
104 | "; |
105 | } |
106 | foreach $dir (@$dirs){ |
107 | next unless defined $dir; # $self->{PERL_SRC} may be undefined |
108 | foreach $name (@$names){ |
109 | my ($abs, $val); |
110 | if ($self->file_name_is_absolute($name)) { # /foo/bar |
111 | $abs = $name; |
112 | } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # foo |
113 | $abs = $self->catfile($dir, $name); |
114 | } else { # foo/bar |
115 | $abs = $self->canonpath($self->catfile($self->curdir, $name)); |
116 | } |
117 | print "Checking $abs\n" if ($trace >= 2); |
118 | next unless $self->maybe_command($abs); |
119 | print "Executing $abs\n" if ($trace >= 2); |
120 | $val = `$abs -e "require $ver;" 2>&1`; |
121 | if ($? == 0) { |
122 | print "Using PERL=$abs\n" if $trace; |
123 | return $abs; |
124 | } elsif ($trace >= 2) { |
125 | print "Result: `$val'\n"; |
126 | } |
127 | } |
128 | } |
129 | print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n"; |
130 | 0; # false and not empty |
131 | } |
132 | |
133 | sub catdir { |
134 | my $self = shift; |
135 | my @args = @_; |
136 | for (@args) { |
137 | # append a slash to each argument unless it has one there |
138 | $_ .= "\\" if $_ eq '' or substr($_,-1) ne "\\"; |
139 | } |
140 | my $result = $self->canonpath(join('', @args)); |
141 | $result; |
142 | } |
143 | |
144 | =item catfile |
145 | |
146 | Concatenate one or more directory names and a filename to form a |
147 | complete path ending with a filename |
148 | |
149 | =cut |
150 | |
151 | sub catfile { |
152 | my $self = shift @_; |
153 | my $file = pop @_; |
154 | return $file unless @_; |
155 | my $dir = $self->catdir(@_); |
96e4d5b1 |
156 | $dir =~ s/(\\\.)$//; |
157 | $dir .= "\\" unless substr($dir,length($dir)-1,1) eq "\\"; |
68dc0745 |
158 | return $dir.$file; |
159 | } |
160 | |
161 | sub init_others |
162 | { |
163 | my ($self) = @_; |
164 | &ExtUtils::MM_Unix::init_others; |
165 | $self->{'TOUCH'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e touch'; |
166 | $self->{'CHMOD'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e chmod'; |
167 | $self->{'CP'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e cp'; |
168 | $self->{'RM_F'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e rm_f'; |
169 | $self->{'RM_RF'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e rm_rf'; |
170 | $self->{'MV'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mv'; |
171 | $self->{'NOOP'} = 'rem'; |
172 | $self->{'TEST_F'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e test_f'; |
3e3baf6d |
173 | $self->{'LD'} = $Config{'ld'} || 'link'; |
174 | $self->{'AR'} = $Config{'ar'} || 'lib'; |
944acd49 |
175 | $self->{'LDLOADLIBS'} ||= $Config{'libs'}; |
e47a9bbc |
176 | # -Lfoo must come first for Borland, so we put it in LDDLFLAGS |
944acd49 |
177 | if ($BORLAND) { |
178 | my $libs = $self->{'LDLOADLIBS'}; |
179 | my $libpath = ''; |
e47a9bbc |
180 | while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) { |
944acd49 |
181 | $libpath .= ' ' if length $libpath; |
182 | $libpath .= $1; |
183 | } |
184 | $self->{'LDLOADLIBS'} = $libs; |
185 | $self->{'LDDLFLAGS'} ||= $Config{'lddlflags'}; |
186 | $self->{'LDDLFLAGS'} .= " $libpath"; |
187 | } |
68dc0745 |
188 | $self->{'DEV_NULL'} = '> NUL'; |
189 | # $self->{'NOECHO'} = ''; # till we have it working |
190 | } |
191 | |
3e3baf6d |
192 | |
193 | =item constants (o) |
194 | |
195 | Initializes lots of constants and .SUFFIXES and .PHONY |
196 | |
197 | =cut |
198 | |
199 | sub constants { |
200 | my($self) = @_; |
201 | my(@m,$tmp); |
202 | |
203 | for $tmp (qw/ |
204 | |
205 | AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION |
206 | VERSION_SYM XS_VERSION INST_BIN INST_EXE INST_LIB |
207 | INST_ARCHLIB INST_SCRIPT PREFIX INSTALLDIRS |
208 | INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB |
209 | INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB |
210 | PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB |
211 | FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC |
212 | PERL_INC PERL FULLPERL |
213 | |
214 | / ) { |
215 | next unless defined $self->{$tmp}; |
216 | push @m, "$tmp = $self->{$tmp}\n"; |
217 | } |
218 | |
219 | push @m, qq{ |
220 | VERSION_MACRO = VERSION |
221 | DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\" |
222 | XS_VERSION_MACRO = XS_VERSION |
223 | XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\" |
224 | }; |
225 | |
226 | push @m, qq{ |
227 | MAKEMAKER = $INC{'ExtUtils\MakeMaker.pm'} |
228 | MM_VERSION = $ExtUtils::MakeMaker::VERSION |
229 | }; |
230 | |
231 | push @m, q{ |
232 | # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). |
233 | # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) |
234 | # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) !!! Deprecated from MM 5.32 !!! |
235 | # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) |
236 | # DLBASE = Basename part of dynamic library. May be just equal BASEEXT. |
237 | }; |
238 | |
239 | for $tmp (qw/ |
240 | FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT |
241 | LDFROM LINKTYPE |
242 | / ) { |
243 | next unless defined $self->{$tmp}; |
244 | push @m, "$tmp = $self->{$tmp}\n"; |
245 | } |
246 | |
247 | push @m, " |
248 | # Handy lists of source code files: |
249 | XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})." |
250 | C_FILES = ".join(" \\\n\t", @{$self->{C}})." |
251 | O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})." |
252 | H_FILES = ".join(" \\\n\t", @{$self->{H}})." |
253 | MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})." |
254 | MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})." |
255 | "; |
256 | |
257 | for $tmp (qw/ |
258 | INST_MAN1DIR INSTALLMAN1DIR MAN1EXT INST_MAN3DIR INSTALLMAN3DIR MAN3EXT |
259 | /) { |
260 | next unless defined $self->{$tmp}; |
261 | push @m, "$tmp = $self->{$tmp}\n"; |
262 | } |
263 | |
264 | push @m, qq{ |
265 | .USESHELL : |
266 | } if $DMAKE; |
267 | |
268 | push @m, q{ |
269 | .NO_CONFIG_REC: Makefile |
270 | } if $ENV{CLEARCASE_ROOT}; |
271 | |
272 | # why not q{} ? -- emacs |
273 | push @m, qq{ |
274 | # work around a famous dec-osf make(1) feature(?): |
275 | makemakerdflt: all |
276 | |
277 | .SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT) |
278 | |
279 | # Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that |
280 | # some make implementations will delete the Makefile when we rebuild it. Because |
281 | # we call false(1) when we rebuild it. So make(1) is not completely wrong when it |
282 | # does so. Our milage may vary. |
283 | # .PRECIOUS: Makefile # seems to be not necessary anymore |
284 | |
285 | .PHONY: all config static dynamic test linkext manifest |
286 | |
287 | # Where is the Config information that we are using/depend on |
288 | CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h |
289 | }; |
290 | |
291 | my @parentdir = split(/::/, $self->{PARENT_NAME}); |
292 | push @m, q{ |
293 | # Where to put things: |
294 | INST_LIBDIR = }. $self->catdir('$(INST_LIB)',@parentdir) .q{ |
295 | INST_ARCHLIBDIR = }. $self->catdir('$(INST_ARCHLIB)',@parentdir) .q{ |
296 | |
297 | INST_AUTODIR = }. $self->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{ |
298 | INST_ARCHAUTODIR = }. $self->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{ |
299 | }; |
300 | |
301 | if ($self->has_link_code()) { |
302 | push @m, ' |
303 | INST_STATIC = $(INST_ARCHAUTODIR)\$(BASEEXT)$(LIB_EXT) |
304 | INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT) |
305 | INST_BOOT = $(INST_ARCHAUTODIR)\$(BASEEXT).bs |
306 | '; |
307 | } else { |
308 | push @m, ' |
309 | INST_STATIC = |
310 | INST_DYNAMIC = |
311 | INST_BOOT = |
312 | '; |
313 | } |
314 | |
315 | $tmp = $self->export_list; |
316 | push @m, " |
317 | EXPORT_LIST = $tmp |
318 | "; |
319 | $tmp = $self->perl_archive; |
320 | push @m, " |
321 | PERL_ARCHIVE = $tmp |
322 | "; |
323 | |
324 | # push @m, q{ |
325 | #INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{ |
326 | # |
327 | #PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{ |
328 | #}; |
329 | |
330 | push @m, q{ |
331 | TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{ |
332 | |
333 | PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{ |
334 | }; |
335 | |
336 | join('',@m); |
337 | } |
338 | |
339 | |
68dc0745 |
340 | sub path { |
341 | local $^W = 1; |
342 | my($self) = @_; |
343 | my $path = $ENV{'PATH'} || $ENV{'Path'} || $ENV{'path'}; |
344 | my @path = split(';',$path); |
345 | foreach(@path) { $_ = '.' if $_ eq '' } |
346 | @path; |
347 | } |
348 | |
349 | =item static_lib (o) |
350 | |
351 | Defines how to produce the *.a (or equivalent) files. |
352 | |
353 | =cut |
354 | |
355 | sub static_lib { |
356 | my($self) = @_; |
357 | # Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC |
358 | # return '' unless $self->needs_linking(); #might be because of a subdir |
359 | |
360 | return '' unless $self->has_link_code; |
361 | |
362 | my(@m); |
363 | push(@m, <<'END'); |
3e3baf6d |
364 | $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)\.exists |
68dc0745 |
365 | $(RM_RF) $@ |
366 | END |
367 | # If this extension has it's own library (eg SDBM_File) |
368 | # then copy that to $(INST_STATIC) and add $(OBJECT) into it. |
369 | push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB}; |
370 | |
371 | push @m, |
910dfcc8 |
372 | q{ $(AR) }.($BORLAND ? '$@ $(OBJECT:^"+")' |
373 | : ($GCC ? '-ru $@ $(OBJECT)' |
374 | : '-out:$@ $(OBJECT)')).q{ |
3e3baf6d |
375 | }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld |
68dc0745 |
376 | $(CHMOD) 755 $@ |
377 | }; |
378 | |
379 | # Old mechanism - still available: |
380 | |
3e3baf6d |
381 | push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs}."\n\n" |
68dc0745 |
382 | if $self->{PERL_SRC}; |
383 | |
384 | push @m, $self->dir_target('$(INST_ARCHAUTODIR)'); |
385 | join('', "\n",@m); |
386 | } |
387 | |
3e3baf6d |
388 | =item dynamic_bs (o) |
389 | |
390 | Defines targets for bootstrap files. |
391 | |
392 | =cut |
68dc0745 |
393 | |
3e3baf6d |
394 | sub dynamic_bs { |
395 | my($self, %attribs) = @_; |
396 | return ' |
397 | BOOTSTRAP = |
398 | ' unless $self->has_link_code(); |
399 | |
400 | return ' |
401 | BOOTSTRAP = '."$self->{BASEEXT}.bs".' |
402 | |
403 | # As Mkbootstrap might not write a file (if none is required) |
404 | # we use touch to prevent make continually trying to remake it. |
405 | # The DynaLoader only reads a non-empty file. |
406 | $(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)\.exists |
407 | '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))" |
408 | '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \ |
409 | -MExtUtils::Mkbootstrap \ |
410 | -e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');" |
411 | '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP) |
412 | $(CHMOD) 644 $@ |
413 | |
414 | $(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists |
415 | '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT) |
416 | -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT) |
417 | $(CHMOD) 644 $@ |
418 | '; |
419 | } |
68dc0745 |
420 | |
421 | =item dynamic_lib (o) |
422 | |
423 | Defines how to produce the *.so (or equivalent) files. |
424 | |
425 | =cut |
426 | |
427 | sub dynamic_lib { |
428 | my($self, %attribs) = @_; |
429 | return '' unless $self->needs_linking(); #might be because of a subdir |
430 | |
431 | return '' unless $self->has_link_code; |
432 | |
3e3baf6d |
433 | my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': ''); |
68dc0745 |
434 | my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || ""; |
435 | my($ldfrom) = '$(LDFROM)'; |
436 | my(@m); |
437 | push(@m,' |
438 | # This section creates the dynamically loadable $(INST_DYNAMIC) |
439 | # from $(OBJECT) and possibly $(MYEXTLIB). |
440 | OTHERLDFLAGS = '.$otherldflags.' |
441 | INST_DYNAMIC_DEP = '.$inst_dynamic_dep.' |
442 | |
3e3baf6d |
443 | $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP) |
68dc0745 |
444 | '); |
5b0d9cbe |
445 | if ($GCC) { |
446 | push(@m, |
910dfcc8 |
447 | q{ dlltool --def $(EXPORT_LIST) --output-exp dll.exp |
448 | $(LD) -o $@ -Wl,--base-file -Wl,dll.base $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp |
5b0d9cbe |
449 | dlltool --def $(EXPORT_LIST) --base-file dll.base --output-exp dll.exp |
450 | $(LD) -o $@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp }); |
dc0d354b |
451 | } elsif ($BORLAND) { |
452 | push(@m, |
453 | q{ $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) }.$ldfrom.q{,$@,,} |
454 | .($DMAKE ? q{$(PERL_ARCHIVE:s,/,\,) $(LDLOADLIBS:s,/,\,) } |
455 | .q{$(MYEXTLIB:s,/,\,),$(EXPORT_LIST:s,/,\,)} |
456 | : q{$(subst /,\,$(PERL_ARCHIVE)) $(subst /,\,$(LDLOADLIBS)) } |
457 | .q{$(subst /,\,$(MYEXTLIB)),$(subst /,\,$(EXPORT_LIST))}) |
458 | .q{,$(RESFILES)}); |
459 | } else { # VC |
460 | push(@m, |
461 | q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) } |
462 | .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)}); |
5b0d9cbe |
463 | } |
68dc0745 |
464 | push @m, ' |
465 | $(CHMOD) 755 $@ |
466 | '; |
467 | |
468 | push @m, $self->dir_target('$(INST_ARCHAUTODIR)'); |
469 | join('',@m); |
470 | } |
471 | |
472 | sub perl_archive |
473 | { |
e3b8966e |
474 | my ($self) = @_; |
f7a92b15 |
475 | if($OBJ) { |
e3b8966e |
476 | if ($self->{CAPI} eq 'TRUE') { |
6de196ee |
477 | return '$(PERL_INC)\perlCAPI$(LIB_EXT)'; |
e3b8966e |
478 | } |
f7a92b15 |
479 | } |
eda5ff31 |
480 | return '$(PERL_INC)\\'.$Config{'libperl'}; |
68dc0745 |
481 | } |
482 | |
483 | sub export_list |
484 | { |
485 | my ($self) = @_; |
486 | return "$self->{BASEEXT}.def"; |
487 | } |
488 | |
489 | =item canonpath |
490 | |
491 | No physical check on the filesystem, but a logical cleanup of a |
492 | path. On UNIX eliminated successive slashes and successive "/.". |
493 | |
494 | =cut |
495 | |
496 | sub canonpath { |
497 | my($self,$path) = @_; |
96e4d5b1 |
498 | $path =~ s/^([a-z]:)/\u$1/; |
68dc0745 |
499 | $path =~ s|/|\\|g; |
3e3baf6d |
500 | $path =~ s|(.)\\+|$1\\|g ; # xx////xx -> xx/xx |
68dc0745 |
501 | $path =~ s|(\\\.)+\\|\\|g ; # xx/././xx -> xx/xx |
502 | $path =~ s|^(\.\\)+|| unless $path eq ".\\"; # ./xx -> xx |
503 | $path =~ s|\\$|| |
504 | unless $path =~ m#^([a-z]:)?\\#; # xx/ -> xx |
505 | $path .= '.' if $path =~ m#\\$#; |
506 | $path; |
507 | } |
508 | |
509 | =item perl_script |
510 | |
511 | Takes one argument, a file name, and returns the file name, if the |
512 | argument is likely to be a perl script. On MM_Unix this is true for |
513 | any ordinary, readable file. |
514 | |
515 | =cut |
516 | |
517 | sub perl_script { |
518 | my($self,$file) = @_; |
519 | return "$file.pl" if -r "$file.pl" && -f _; |
520 | return; |
521 | } |
522 | |
523 | =item pm_to_blib |
524 | |
525 | Defines target that copies all files in the hash PM to their |
526 | destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION> |
527 | |
528 | =cut |
529 | |
530 | sub pm_to_blib { |
531 | my $self = shift; |
532 | my($autodir) = $self->catdir('$(INST_LIB)','auto'); |
533 | return q{ |
534 | pm_to_blib: $(TO_INST_PM) |
535 | }.$self->{NOECHO}.q{$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \ |
536 | "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \ |
dc0d354b |
537 | -e "pm_to_blib(}. |
538 | ($NMAKE ? 'qw[ <<pmfiles.dat ],' |
539 | : $DMAKE ? 'qw[ $(mktmp,pmfiles.dat $(PM_TO_BLIB:s,\\,\\\\,)\n) ],' |
540 | : '{ qw[$(PM_TO_BLIB)] },' |
541 | ).q{'}.$autodir.q{')" |
3e3baf6d |
542 | }. ($NMAKE ? q{ |
68dc0745 |
543 | $(PM_TO_BLIB) |
544 | << |
3e3baf6d |
545 | } : '') . $self->{NOECHO}.q{$(TOUCH) $@ |
68dc0745 |
546 | }; |
547 | } |
548 | |
549 | =item test_via_harness (o) |
550 | |
551 | Helper method to write the test targets |
552 | |
553 | =cut |
554 | |
555 | sub test_via_harness { |
556 | my($self, $perl, $tests) = @_; |
557 | "\t$perl".q! -Mblib -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e "use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;" !."$tests\n"; |
558 | } |
559 | |
3e3baf6d |
560 | |
68dc0745 |
561 | =item tool_autosplit (override) |
562 | |
563 | Use Win32 quoting on command line. |
564 | |
565 | =cut |
566 | |
567 | sub tool_autosplit{ |
568 | my($self, %attribs) = @_; |
569 | my($asl) = ""; |
570 | $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN}; |
571 | q{ |
572 | # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto |
573 | AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MAutoSplit }.$asl.q{ -e "autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1);" |
574 | }; |
575 | } |
576 | |
577 | =item tools_other (o) |
578 | |
579 | Win32 overrides. |
580 | |
581 | Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in |
582 | the Makefile. Also defines the perl programs MKPATH, |
583 | WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL. |
584 | |
585 | =cut |
586 | |
587 | sub tools_other { |
588 | my($self) = shift; |
589 | my @m; |
590 | my $bin_sh = $Config{sh} || 'cmd /c'; |
591 | push @m, qq{ |
592 | SHELL = $bin_sh |
3e3baf6d |
593 | } unless $DMAKE; # dmake determines its own shell |
68dc0745 |
594 | |
595 | for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) { |
596 | push @m, "$_ = $self->{$_}\n"; |
597 | } |
598 | |
599 | push @m, q{ |
600 | # The following is a portable way to say mkdir -p |
601 | # To see which directories are created, change the if 0 to if 1 |
602 | MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath |
603 | |
604 | # This helps us to minimize the effect of the .exists files A yet |
605 | # better solution would be to have a stable file in the perl |
606 | # distribution with a timestamp of zero. But this solution doesn't |
607 | # need any changes to the core distribution and works with older perls |
608 | EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime |
609 | }; |
610 | |
611 | |
612 | return join "", @m if $self->{PARENT}; |
613 | |
614 | push @m, q{ |
615 | # Here we warn users that an old packlist file was found somewhere, |
616 | # and that they should call some uninstall routine |
617 | WARN_IF_OLD_PACKLIST = $(PERL) -lwe "exit unless -f $$ARGV[0];" \\ |
618 | -e "print 'WARNING: I have found an old package in';" \\ |
619 | -e "print ' ', $$ARGV[0], '.';" \\ |
620 | -e "print 'Please make sure the two installations are not conflicting';" |
621 | |
622 | UNINST=0 |
623 | VERBINST=1 |
624 | |
625 | MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \ |
3e3baf6d |
626 | -e "install({ @ARGV },'$(VERBINST)',0,'$(UNINST)');" |
68dc0745 |
627 | |
628 | DOC_INSTALL = $(PERL) -e "$$\=\"\n\n\";" \ |
629 | -e "print '=head2 ', scalar(localtime), ': C<', shift, '>', ' L<', shift, '>';" \ |
630 | -e "print '=over 4';" \ |
3e3baf6d |
631 | -e "while (defined($$key = shift) and defined($$val = shift)) { print '=item *';print 'C<', \"$$key: $$val\", '>'; }" \ |
68dc0745 |
632 | -e "print '=back';" |
633 | |
634 | UNINSTALL = $(PERL) -MExtUtils::Install \ |
635 | -e "uninstall($$ARGV[0],1,1); print \"\nUninstall is deprecated. Please check the";" \ |
636 | -e "print \" packlist above carefully.\n There may be errors. Remove the\";" \ |
637 | -e "print \" appropriate files manually.\n Sorry for the inconveniences.\n\"" |
638 | }; |
639 | |
640 | return join "", @m; |
641 | } |
642 | |
3e3baf6d |
643 | =item xs_o (o) |
644 | |
645 | Defines suffix rules to go from XS to object files directly. This is |
646 | only intended for broken make implementations. |
647 | |
648 | =cut |
649 | |
650 | sub xs_o { # many makes are too dumb to use xs_c then c_o |
651 | my($self) = shift; |
652 | return '' |
653 | } |
654 | |
655 | =item top_targets (o) |
656 | |
657 | Defines the targets all, subdirs, config, and O_FILES |
658 | |
659 | =cut |
660 | |
661 | sub top_targets { |
662 | # --- Target Sections --- |
663 | |
664 | my($self) = shift; |
665 | my(@m); |
666 | push @m, ' |
667 | #all :: config $(INST_PM) subdirs linkext manifypods |
668 | '; |
669 | |
670 | push @m, ' |
671 | all :: pure_all manifypods |
672 | '.$self->{NOECHO}.'$(NOOP) |
673 | ' |
674 | unless $self->{SKIPHASH}{'all'}; |
675 | |
676 | push @m, ' |
677 | pure_all :: config pm_to_blib subdirs linkext |
678 | '.$self->{NOECHO}.'$(NOOP) |
679 | |
680 | subdirs :: $(MYEXTLIB) |
681 | '.$self->{NOECHO}.'$(NOOP) |
682 | |
683 | config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)\.exists |
684 | '.$self->{NOECHO}.'$(NOOP) |
685 | |
686 | config :: $(INST_ARCHAUTODIR)\.exists |
687 | '.$self->{NOECHO}.'$(NOOP) |
688 | |
689 | config :: $(INST_AUTODIR)\.exists |
690 | '.$self->{NOECHO}.'$(NOOP) |
691 | '; |
692 | |
693 | push @m, qq{ |
694 | config :: Version_check |
695 | $self->{NOECHO}\$(NOOP) |
696 | |
697 | } unless $self->{PARENT} or ($self->{PERL_SRC} && $self->{INSTALLDIRS} eq "perl") or $self->{NO_VC}; |
698 | |
699 | push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]); |
700 | |
701 | if (%{$self->{MAN1PODS}}) { |
702 | push @m, qq[ |
703 | config :: \$(INST_MAN1DIR)\\.exists |
704 | $self->{NOECHO}\$(NOOP) |
705 | |
706 | ]; |
707 | push @m, $self->dir_target(qw[$(INST_MAN1DIR)]); |
708 | } |
709 | if (%{$self->{MAN3PODS}}) { |
710 | push @m, qq[ |
711 | config :: \$(INST_MAN3DIR)\\.exists |
712 | $self->{NOECHO}\$(NOOP) |
713 | |
714 | ]; |
715 | push @m, $self->dir_target(qw[$(INST_MAN3DIR)]); |
716 | } |
717 | |
718 | push @m, ' |
719 | $(O_FILES): $(H_FILES) |
720 | ' if @{$self->{O_FILES} || []} && @{$self->{H} || []}; |
721 | |
722 | push @m, q{ |
723 | help: |
724 | perldoc ExtUtils::MakeMaker |
725 | }; |
726 | |
727 | push @m, q{ |
728 | Version_check: |
729 | }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \ |
730 | -MExtUtils::MakeMaker=Version_check \ |
731 | -e "Version_check('$(MM_VERSION)')" |
732 | }; |
733 | |
734 | join('',@m); |
735 | } |
736 | |
68dc0745 |
737 | =item manifypods (o) |
738 | |
739 | We don't want manpage process. XXX add pod2html support later. |
740 | |
741 | =cut |
742 | |
743 | sub manifypods { |
846f184a |
744 | my($self) = shift; |
68dc0745 |
745 | return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n"; |
746 | } |
747 | |
748 | =item dist_ci (o) |
749 | |
750 | Same as MM_Unix version (changes command-line quoting). |
751 | |
752 | =cut |
753 | |
754 | sub dist_ci { |
755 | my($self) = shift; |
756 | my @m; |
757 | push @m, q{ |
758 | ci : |
759 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=maniread \\ |
760 | -e "@all = keys %{ maniread() };" \\ |
761 | -e "print(\"Executing $(CI) @all\n\"); system(\"$(CI) @all\");" \\ |
762 | -e "print(\"Executing $(RCS_LABEL) ...\n\"); system(\"$(RCS_LABEL) @all\");" |
763 | }; |
764 | join "", @m; |
765 | } |
766 | |
767 | =item dist_core (o) |
768 | |
769 | Same as MM_Unix version (changes command-line quoting). |
770 | |
771 | =cut |
772 | |
773 | sub dist_core { |
774 | my($self) = shift; |
775 | my @m; |
776 | push @m, q{ |
777 | dist : $(DIST_DEFAULT) |
778 | }.$self->{NOECHO}.q{$(PERL) -le "print \"Warning: Makefile possibly out of date with $$vf\" if " \ |
779 | -e "-e ($$vf=\"$(VERSION_FROM)\") and -M $$vf < -M \"}.$self->{MAKEFILE}.q{\";" |
780 | |
781 | tardist : $(DISTVNAME).tar$(SUFFIX) |
782 | |
783 | zipdist : $(DISTVNAME).zip |
784 | |
785 | $(DISTVNAME).tar$(SUFFIX) : distdir |
786 | $(PREOP) |
787 | $(TO_UNIX) |
788 | $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) |
789 | $(RM_RF) $(DISTVNAME) |
790 | $(COMPRESS) $(DISTVNAME).tar |
791 | $(POSTOP) |
792 | |
793 | $(DISTVNAME).zip : distdir |
794 | $(PREOP) |
795 | $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) |
796 | $(RM_RF) $(DISTVNAME) |
797 | $(POSTOP) |
798 | |
799 | uutardist : $(DISTVNAME).tar$(SUFFIX) |
800 | uuencode $(DISTVNAME).tar$(SUFFIX) \\ |
801 | $(DISTVNAME).tar$(SUFFIX) > \\ |
802 | $(DISTVNAME).tar$(SUFFIX)_uu |
803 | |
804 | shdist : distdir |
805 | $(PREOP) |
806 | $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar |
807 | $(RM_RF) $(DISTVNAME) |
808 | $(POSTOP) |
809 | }; |
810 | join "", @m; |
811 | } |
812 | |
813 | =item pasthru (o) |
814 | |
815 | Defines the string that is passed to recursive make calls in |
816 | subdirectories. |
817 | |
818 | =cut |
819 | |
820 | sub pasthru { |
821 | my($self) = shift; |
3e3baf6d |
822 | return "PASTHRU = " . ($NMAKE ? "-nologo" : ""); |
68dc0745 |
823 | } |
824 | |
825 | |
826 | |
827 | 1; |
828 | __END__ |
829 | |
830 | =back |
831 | |
832 | =cut |
833 | |
5b0d9cbe |
834 | |