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