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