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