Commit | Line | Data |
1e44e2bf |
1 | package ExtUtils::MM_Unix; |
2 | |
cfe45540 |
3 | $VERSION = substr q$Revision: 1.1.1.1 $, 10; |
4 | # $Id: MM_Unix.pm,v 1.1.1.1 1997/01/11 12:48:52 mbeattie Exp $ |
f4ae0f5e |
5 | |
f1387719 |
6 | require Exporter; |
7 | use Config; |
8 | use File::Basename qw(basename dirname fileparse); |
9 | use DirHandle; |
1e44e2bf |
10 | |
11 | Exporter::import('ExtUtils::MakeMaker', |
12 | qw( $Verbose &neatvalue)); |
13 | |
f1387719 |
14 | $Is_OS2 = $^O =~ m|^os/?2$|i; |
15 | $Is_Mac = $^O eq "MacOS"; |
16 | |
17 | if ($Is_VMS = $^O eq 'VMS') { |
18 | require VMS::Filespec; |
19 | import VMS::Filespec qw( &vmsify ); |
20 | } |
1e44e2bf |
21 | |
22 | =head1 NAME |
23 | |
24 | ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker |
25 | |
26 | =head1 SYNOPSIS |
27 | |
28 | C<require ExtUtils::MM_Unix;> |
29 | |
30 | =head1 DESCRIPTION |
31 | |
32 | The methods provided by this package are designed to be used in |
33 | conjunction with ExtUtils::MakeMaker. When MakeMaker writes a |
34 | Makefile, it creates one or more objects that inherit their methods |
35 | from a package C<MM>. MM itself doesn't provide any methods, but it |
36 | ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating |
37 | specific packages take the responsibility for all the methods provided |
38 | by MM_Unix. We are trying to reduce the number of the necessary |
39 | overrides by defining rather primitive operations within |
40 | ExtUtils::MM_Unix. |
41 | |
42 | If you are going to write a platform specific MM package, please try |
43 | to limit the necessary overrides to primitiv methods, and if it is not |
44 | possible to do so, let's work it out how to achieve that gain. |
45 | |
f4ae0f5e |
46 | If you are overriding any of these methods in your Makefile.PL (in the |
47 | MY class), please report that to the makemaker mailing list. We are |
48 | trying to minimize the necessary method overrides and switch to data |
49 | driven Makefile.PLs wherever possible. In the long run less methods |
50 | will be overridable via the MY class. |
51 | |
1e44e2bf |
52 | =head1 METHODS |
53 | |
54 | The following description of methods is still under |
55 | development. Please refer to the code for not suitably documented |
56 | sections and complain loudly to the makemaker mailing list. |
57 | |
f1387719 |
58 | Not all of the methods below are overridable in a |
f4ae0f5e |
59 | Makefile.PL. Overridable methods are marked as (o). All methods are |
60 | overridable by a platform specific MM_*.pm file (See |
61 | L<ExtUtils::MM_VMS>) and L<ExtUtils::MM_OS2>). |
62 | |
1e44e2bf |
63 | =head2 Preloaded methods |
64 | |
65 | =over 2 |
66 | |
f1387719 |
67 | =item canonpath |
68 | |
69 | No physical check on the filesystem, but a logical cleanup of a |
70 | path. On UNIX eliminated successive slashes and successive "/.". |
71 | |
72 | =cut |
73 | |
74 | sub canonpath { |
75 | my($self,$path) = @_; |
76 | $path =~ s|/+|/|g ; # xx////xx -> xx/xx |
77 | $path =~ s|(/\.)+/|/|g ; # xx/././xx -> xx/xx |
78 | $path =~ s|^(\./)+|| unless $path eq "./"; # ./xx -> xx |
79 | $path =~ s|/$|| unless $path eq "/"; # xx/ -> xx |
80 | $path; |
81 | } |
82 | |
1e44e2bf |
83 | =item catdir |
84 | |
85 | Concatenate two or more directory names to form a complete path ending |
f1387719 |
86 | with a directory. But remove the trailing slash from the resulting |
87 | string, because it doesn't look good, isn't necessary and confuses |
88 | OS2. Of course, if this is the root directory, don't cut off the |
89 | trailing slash :-) |
1e44e2bf |
90 | |
91 | =cut |
92 | |
93 | # '; |
94 | |
f1387719 |
95 | sub catdir { |
1e44e2bf |
96 | shift; |
f1387719 |
97 | my @args = @_; |
98 | for (@args) { |
99 | # append a slash to each argument unless it has one there |
100 | $_ .= "/" unless substr($_,length($_)-1,1) eq "/"; |
101 | } |
102 | my $result = join('', @args); |
103 | # remove a trailing slash unless we are root |
104 | substr($result,length($result)-1,1) = "" |
105 | if length($result) > 1 && substr($result,length($result)-1,1) eq "/"; |
1e44e2bf |
106 | $result; |
107 | } |
108 | |
109 | =item catfile |
110 | |
f1387719 |
111 | Concatenate one or more directory names and a filename to form a |
1e44e2bf |
112 | complete path ending with a filename |
113 | |
114 | =cut |
115 | |
116 | sub catfile { |
f1387719 |
117 | my $self = shift @_; |
118 | my $file = pop @_; |
119 | return $file unless @_; |
120 | my $dir = $self->catdir(@_); |
121 | for ($dir) { |
122 | $_ .= "/" unless substr($_,length($_)-1,1) eq "/"; |
123 | } |
124 | return $dir.$file; |
1e44e2bf |
125 | } |
126 | |
f1387719 |
127 | =item curdir |
128 | |
129 | Returns a string representing of the current directory. "." on UNIX. |
130 | |
131 | =cut |
132 | |
133 | sub curdir { |
134 | return "." ; |
135 | } |
136 | |
137 | =item rootdir |
138 | |
139 | Returns a string representing of the root directory. "/" on UNIX. |
140 | |
141 | =cut |
142 | |
143 | sub rootdir { |
144 | return "/"; |
145 | } |
146 | |
147 | =item updir |
148 | |
149 | Returns a string representing of the parent directory. ".." on UNIX. |
150 | |
151 | =cut |
152 | |
153 | sub updir { |
154 | return ".."; |
155 | } |
156 | |
157 | sub ExtUtils::MM_Unix::c_o ; |
158 | sub ExtUtils::MM_Unix::clean ; |
159 | sub ExtUtils::MM_Unix::const_cccmd ; |
f4ae0f5e |
160 | sub ExtUtils::MM_Unix::const_config ; |
f4ae0f5e |
161 | sub ExtUtils::MM_Unix::const_loadlibs ; |
f1387719 |
162 | sub ExtUtils::MM_Unix::constants ; |
f4ae0f5e |
163 | sub ExtUtils::MM_Unix::depend ; |
f1387719 |
164 | sub ExtUtils::MM_Unix::dir_target ; |
165 | sub ExtUtils::MM_Unix::dist ; |
166 | sub ExtUtils::MM_Unix::dist_basics ; |
167 | sub ExtUtils::MM_Unix::dist_ci ; |
168 | sub ExtUtils::MM_Unix::dist_core ; |
169 | sub ExtUtils::MM_Unix::dist_dir ; |
170 | sub ExtUtils::MM_Unix::dist_test ; |
f4ae0f5e |
171 | sub ExtUtils::MM_Unix::dlsyms ; |
172 | sub ExtUtils::MM_Unix::dynamic ; |
173 | sub ExtUtils::MM_Unix::dynamic_bs ; |
174 | sub ExtUtils::MM_Unix::dynamic_lib ; |
f1387719 |
175 | sub ExtUtils::MM_Unix::exescan ; |
176 | sub ExtUtils::MM_Unix::extliblist ; |
177 | sub ExtUtils::MM_Unix::file_name_is_absolute ; |
178 | sub ExtUtils::MM_Unix::find_perl ; |
179 | sub ExtUtils::MM_Unix::force ; |
180 | sub ExtUtils::MM_Unix::guess_name ; |
181 | sub ExtUtils::MM_Unix::has_link_code ; |
182 | sub ExtUtils::MM_Unix::init_dirscan ; |
183 | sub ExtUtils::MM_Unix::init_main ; |
184 | sub ExtUtils::MM_Unix::init_others ; |
185 | sub ExtUtils::MM_Unix::install ; |
186 | sub ExtUtils::MM_Unix::installbin ; |
187 | sub ExtUtils::MM_Unix::libscan ; |
188 | sub ExtUtils::MM_Unix::linkext ; |
189 | sub ExtUtils::MM_Unix::lsdir ; |
190 | sub ExtUtils::MM_Unix::macro ; |
191 | sub ExtUtils::MM_Unix::makeaperl ; |
192 | sub ExtUtils::MM_Unix::makefile ; |
f4ae0f5e |
193 | sub ExtUtils::MM_Unix::manifypods ; |
f1387719 |
194 | sub ExtUtils::MM_Unix::maybe_command ; |
195 | sub ExtUtils::MM_Unix::maybe_command_in_dirs ; |
196 | sub ExtUtils::MM_Unix::needs_linking ; |
197 | sub ExtUtils::MM_Unix::nicetext ; |
198 | sub ExtUtils::MM_Unix::parse_version ; |
199 | sub ExtUtils::MM_Unix::pasthru ; |
200 | sub ExtUtils::MM_Unix::path ; |
201 | sub ExtUtils::MM_Unix::perl_script ; |
202 | sub ExtUtils::MM_Unix::perldepend ; |
203 | sub ExtUtils::MM_Unix::pm_to_blib ; |
204 | sub ExtUtils::MM_Unix::post_constants ; |
205 | sub ExtUtils::MM_Unix::post_initialize ; |
206 | sub ExtUtils::MM_Unix::postamble ; |
207 | sub ExtUtils::MM_Unix::prefixify ; |
f4ae0f5e |
208 | sub ExtUtils::MM_Unix::processPL ; |
f4ae0f5e |
209 | sub ExtUtils::MM_Unix::realclean ; |
f1387719 |
210 | sub ExtUtils::MM_Unix::replace_manpage_separator ; |
211 | sub ExtUtils::MM_Unix::static ; |
212 | sub ExtUtils::MM_Unix::static_lib ; |
f4ae0f5e |
213 | sub ExtUtils::MM_Unix::staticmake ; |
f1387719 |
214 | sub ExtUtils::MM_Unix::subdir_x ; |
215 | sub ExtUtils::MM_Unix::subdirs ; |
f4ae0f5e |
216 | sub ExtUtils::MM_Unix::test ; |
217 | sub ExtUtils::MM_Unix::test_via_harness ; |
218 | sub ExtUtils::MM_Unix::test_via_script ; |
f1387719 |
219 | sub ExtUtils::MM_Unix::tool_autosplit ; |
220 | sub ExtUtils::MM_Unix::tool_xsubpp ; |
221 | sub ExtUtils::MM_Unix::tools_other ; |
222 | sub ExtUtils::MM_Unix::top_targets ; |
f4ae0f5e |
223 | sub ExtUtils::MM_Unix::writedoc ; |
f1387719 |
224 | sub ExtUtils::MM_Unix::xs_c ; |
225 | sub ExtUtils::MM_Unix::xs_o ; |
226 | sub ExtUtils::MM_Unix::xsubpp_version ; |
f4ae0f5e |
227 | |
228 | package ExtUtils::MM_Unix; |
229 | |
f1387719 |
230 | #use SelfLoader; |
f4ae0f5e |
231 | |
232 | 1; |
f1387719 |
233 | #__DATA__ |
f4ae0f5e |
234 | |
235 | =head2 SelfLoaded methods |
236 | |
f1387719 |
237 | =item c_o (o) |
1e44e2bf |
238 | |
f1387719 |
239 | Defines the suffix rules to compile different flavors of C files to |
240 | object files. |
1e44e2bf |
241 | |
242 | =cut |
243 | |
f1387719 |
244 | sub c_o { |
245 | # --- Translation Sections --- |
1e44e2bf |
246 | |
f1387719 |
247 | my($self) = shift; |
248 | return '' unless $self->needs_linking(); |
249 | my(@m); |
250 | push @m, ' |
251 | .c$(OBJ_EXT): |
252 | $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c |
1e44e2bf |
253 | |
f1387719 |
254 | .C$(OBJ_EXT): |
255 | $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.C |
1e44e2bf |
256 | |
f1387719 |
257 | .cpp$(OBJ_EXT): |
258 | $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cpp |
1e44e2bf |
259 | |
f1387719 |
260 | .cxx$(OBJ_EXT): |
261 | $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cxx |
1e44e2bf |
262 | |
f1387719 |
263 | .cc$(OBJ_EXT): |
264 | $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cc |
265 | '; |
266 | join "", @m; |
1e44e2bf |
267 | } |
268 | |
f1387719 |
269 | =item cflags (o) |
1e44e2bf |
270 | |
f1387719 |
271 | Does very much the same as the cflags script in the perl |
272 | distribution. It doesn't return the whole compiler command line, but |
273 | initializes all of its parts. The const_cccmd method then actually |
274 | returns the definition of the CCCMD macro which uses these parts. |
1e44e2bf |
275 | |
276 | =cut |
277 | |
f1387719 |
278 | #' |
1e44e2bf |
279 | |
f1387719 |
280 | sub cflags { |
281 | my($self,$libperl)=@_; |
282 | return $self->{CFLAGS} if $self->{CFLAGS}; |
283 | return '' unless $self->needs_linking(); |
1e44e2bf |
284 | |
f1387719 |
285 | my($prog, $uc, $perltype, %cflags); |
286 | $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ; |
287 | $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/; |
1e44e2bf |
288 | |
f1387719 |
289 | @cflags{qw(cc ccflags optimize large split shellflags)} |
290 | = @Config{qw(cc ccflags optimize large split shellflags)}; |
291 | my($optdebug) = ""; |
1e44e2bf |
292 | |
f1387719 |
293 | $cflags{shellflags} ||= ''; |
1e44e2bf |
294 | |
f1387719 |
295 | my(%map) = ( |
296 | D => '-DDEBUGGING', |
297 | E => '-DEMBED', |
298 | DE => '-DDEBUGGING -DEMBED', |
299 | M => '-DEMBED -DMULTIPLICITY', |
300 | DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY', |
301 | ); |
1e44e2bf |
302 | |
f1387719 |
303 | if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){ |
304 | $uc = uc($1); |
305 | } else { |
306 | $uc = ""; # avoid warning |
307 | } |
308 | $perltype = $map{$uc} ? $map{$uc} : ""; |
1e44e2bf |
309 | |
f1387719 |
310 | if ($uc =~ /^D/) { |
311 | $optdebug = "-g"; |
312 | } |
1e44e2bf |
313 | |
1e44e2bf |
314 | |
f1387719 |
315 | my($name); |
316 | ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ; |
317 | if ($prog = $Config::Config{$name}) { |
318 | # Expand hints for this extension via the shell |
319 | print STDOUT "Processing $name hint:\n" if $Verbose; |
320 | my(@o)=`cc=\"$cflags{cc}\" |
321 | ccflags=\"$cflags{ccflags}\" |
322 | optimize=\"$cflags{optimize}\" |
323 | perltype=\"$cflags{perltype}\" |
324 | optdebug=\"$cflags{optdebug}\" |
325 | large=\"$cflags{large}\" |
326 | split=\"$cflags{'split'}\" |
327 | eval '$prog' |
328 | echo cc=\$cc |
329 | echo ccflags=\$ccflags |
330 | echo optimize=\$optimize |
331 | echo perltype=\$perltype |
332 | echo optdebug=\$optdebug |
333 | echo large=\$large |
334 | echo split=\$split |
335 | `; |
336 | my($line); |
337 | foreach $line (@o){ |
338 | chomp $line; |
339 | if ($line =~ /(.*?)=\s*(.*)\s*$/){ |
340 | $cflags{$1} = $2; |
341 | print STDOUT " $1 = $2\n" if $Verbose; |
342 | } else { |
343 | print STDOUT "Unrecognised result from hint: '$line'\n"; |
344 | } |
345 | } |
346 | } |
1e44e2bf |
347 | |
f1387719 |
348 | if ($optdebug) { |
349 | $cflags{optimize} = $optdebug; |
350 | } |
1e44e2bf |
351 | |
f1387719 |
352 | for (qw(ccflags optimize perltype large split)) { |
353 | $cflags{$_} =~ s/^\s+//; |
354 | $cflags{$_} =~ s/\s+/ /g; |
355 | $cflags{$_} =~ s/\s+$//; |
356 | $self->{uc $_} ||= $cflags{$_} |
357 | } |
1e44e2bf |
358 | |
f1387719 |
359 | return $self->{CFLAGS} = qq{ |
360 | CCFLAGS = $self->{CCFLAGS} |
361 | OPTIMIZE = $self->{OPTIMIZE} |
362 | PERLTYPE = $self->{PERLTYPE} |
363 | LARGE = $self->{LARGE} |
364 | SPLIT = $self->{SPLIT} |
365 | }; |
1e44e2bf |
366 | |
1e44e2bf |
367 | } |
368 | |
f1387719 |
369 | =item clean (o) |
1e44e2bf |
370 | |
f1387719 |
371 | Defines the clean target. |
1e44e2bf |
372 | |
373 | =cut |
374 | |
f1387719 |
375 | sub clean { |
376 | # --- Cleanup and Distribution Sections --- |
1e44e2bf |
377 | |
f1387719 |
378 | my($self, %attribs) = @_; |
379 | my(@m,$dir); |
380 | push(@m, ' |
381 | # Delete temporary files but do not touch installed files. We don\'t delete |
382 | # the Makefile here so a later make realclean still has a makefile to use. |
1e44e2bf |
383 | |
f1387719 |
384 | clean :: |
385 | '); |
386 | # clean subdirectories first |
387 | for $dir (@{$self->{DIR}}) { |
388 | push @m, "\t-cd $dir && test -f $self->{MAKEFILE} && \$(MAKE) clean\n"; |
1e44e2bf |
389 | } |
f1387719 |
390 | |
391 | my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files |
392 | push(@otherfiles, $attribs{FILES}) if $attribs{FILES}; |
393 | push(@otherfiles, qw[./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all |
394 | perlmain.c mon.out core so_locations pm_to_blib |
395 | *~ */*~ */*/*~ *$(OBJ_EXT) *$(LIB_EXT) perl.exe |
396 | $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def |
397 | $(BASEEXT).exp |
398 | ]); |
399 | push @m, "\t-$self->{RM_RF} @otherfiles\n"; |
400 | # See realclean and ext/utils/make_ext for usage of Makefile.old |
401 | push(@m, |
402 | "\t-$self->{MV} $self->{MAKEFILE} $self->{MAKEFILE}.old 2>/dev/null\n"); |
403 | push(@m, |
404 | "\t$attribs{POSTOP}\n") if $attribs{POSTOP}; |
405 | join("", @m); |
1e44e2bf |
406 | } |
407 | |
f1387719 |
408 | =item const_cccmd (o) |
1e44e2bf |
409 | |
f1387719 |
410 | Returns the full compiler call for C programs and stores the |
411 | definition in CONST_CCCMD. |
1e44e2bf |
412 | |
413 | =cut |
414 | |
f1387719 |
415 | sub const_cccmd { |
416 | my($self,$libperl)=@_; |
417 | return $self->{CONST_CCCMD} if $self->{CONST_CCCMD}; |
418 | return '' unless $self->needs_linking(); |
419 | return $self->{CONST_CCCMD} = |
420 | q{CCCMD = $(CC) -c $(INC) $(CCFLAGS) $(OPTIMIZE) \\ |
421 | $(PERLTYPE) $(LARGE) $(SPLIT) $(DEFINE_VERSION) \\ |
422 | $(XS_DEFINE_VERSION)}; |
1e44e2bf |
423 | } |
424 | |
f1387719 |
425 | =item const_config (o) |
1e44e2bf |
426 | |
f1387719 |
427 | Defines a couple of constants in the Makefile that are imported from |
428 | %Config. |
1e44e2bf |
429 | |
430 | =cut |
431 | |
f1387719 |
432 | sub const_config { |
433 | # --- Constants Sections --- |
434 | |
435 | my($self) = shift; |
436 | my(@m,$m); |
437 | push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n"); |
438 | push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n"); |
439 | my(%once_only); |
440 | foreach $m (@{$self->{CONFIG}}){ |
441 | # SITE*EXP macros are defined in &constants; avoid duplicates here |
442 | next if $once_only{$m} or $m eq 'sitelibexp' or $m eq 'sitearchexp'; |
443 | push @m, "\U$m\E = ".$self->{uc $m}."\n"; |
444 | $once_only{$m} = 1; |
445 | } |
446 | join('', @m); |
1e44e2bf |
447 | } |
448 | |
f1387719 |
449 | =item const_loadlibs (o) |
1e44e2bf |
450 | |
f1387719 |
451 | Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. See |
452 | L<ExtUtils::Liblist> for details. |
1e44e2bf |
453 | |
454 | =cut |
455 | |
f1387719 |
456 | sub const_loadlibs { |
457 | my($self) = shift; |
458 | return "" unless $self->needs_linking; |
459 | my @m; |
460 | push @m, qq{ |
461 | # $self->{NAME} might depend on some other libraries: |
462 | # See ExtUtils::Liblist for details |
463 | # |
464 | }; |
465 | my($tmp); |
466 | for $tmp (qw/ |
467 | EXTRALIBS LDLOADLIBS BSLOADLIBS LD_RUN_PATH |
468 | /) { |
469 | next unless defined $self->{$tmp}; |
470 | push @m, "$tmp = $self->{$tmp}\n"; |
471 | } |
472 | return join "", @m; |
1e44e2bf |
473 | } |
474 | |
f1387719 |
475 | =item constants (o) |
1e44e2bf |
476 | |
f1387719 |
477 | Initializes lots of constants and .SUFFIXES and .PHONY |
1e44e2bf |
478 | |
479 | =cut |
480 | |
f1387719 |
481 | sub constants { |
1e44e2bf |
482 | my($self) = @_; |
f1387719 |
483 | my(@m,$tmp); |
1e44e2bf |
484 | |
f1387719 |
485 | for $tmp (qw/ |
1e44e2bf |
486 | |
f1387719 |
487 | AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION |
488 | VERSION_SYM XS_VERSION INST_BIN INST_EXE INST_LIB |
489 | INST_ARCHLIB INST_SCRIPT PREFIX INSTALLDIRS |
490 | INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB |
491 | INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB |
492 | PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB |
493 | FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC |
494 | PERL_INC PERL FULLPERL |
1e44e2bf |
495 | |
f1387719 |
496 | / ) { |
497 | next unless defined $self->{$tmp}; |
498 | push @m, "$tmp = $self->{$tmp}\n"; |
1e44e2bf |
499 | } |
500 | |
f1387719 |
501 | push @m, qq{ |
502 | VERSION_MACRO = VERSION |
503 | DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\" |
504 | XS_VERSION_MACRO = XS_VERSION |
505 | XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\" |
506 | }; |
1e44e2bf |
507 | |
f1387719 |
508 | push @m, qq{ |
509 | MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'} |
510 | MM_VERSION = $ExtUtils::MakeMaker::VERSION |
511 | }; |
1e44e2bf |
512 | |
f1387719 |
513 | push @m, q{ |
514 | # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). |
515 | # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) |
516 | # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) !!! Deprecated from MM 5.32 !!! |
517 | # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) |
518 | # DLBASE = Basename part of dynamic library. May be just equal BASEEXT. |
519 | }; |
1e44e2bf |
520 | |
f1387719 |
521 | for $tmp (qw/ |
522 | FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT |
523 | LDFROM LINKTYPE |
524 | / ) { |
525 | next unless defined $self->{$tmp}; |
526 | push @m, "$tmp = $self->{$tmp}\n"; |
527 | } |
1e44e2bf |
528 | |
f1387719 |
529 | push @m, " |
530 | # Handy lists of source code files: |
531 | XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})." |
532 | C_FILES = ".join(" \\\n\t", @{$self->{C}})." |
533 | O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})." |
534 | H_FILES = ".join(" \\\n\t", @{$self->{H}})." |
535 | MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})." |
536 | MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})." |
537 | "; |
1e44e2bf |
538 | |
f1387719 |
539 | for $tmp (qw/ |
540 | INST_MAN1DIR INSTALLMAN1DIR MAN1EXT INST_MAN3DIR INSTALLMAN3DIR MAN3EXT |
541 | /) { |
542 | next unless defined $self->{$tmp}; |
543 | push @m, "$tmp = $self->{$tmp}\n"; |
544 | } |
1e44e2bf |
545 | |
f1387719 |
546 | push @m, q{ |
547 | .NO_CONFIG_REC: Makefile |
548 | } if $ENV{CLEARCASE_ROOT}; |
1e44e2bf |
549 | |
f1387719 |
550 | # why not q{} ? -- emacs |
551 | push @m, qq{ |
552 | # work around a famous dec-osf make(1) feature(?): |
553 | makemakerdflt: all |
1e44e2bf |
554 | |
f1387719 |
555 | .SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT) |
1e44e2bf |
556 | |
f1387719 |
557 | # Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that |
558 | # some make implementations will delete the Makefile when we rebuild it. Because |
559 | # we call false(1) when we rebuild it. So make(1) is not completely wrong when it |
560 | # does so. Our milage may vary. |
561 | # .PRECIOUS: Makefile # seems to be not necessary anymore |
1e44e2bf |
562 | |
f1387719 |
563 | .PHONY: all config static dynamic test linkext manifest |
1e44e2bf |
564 | |
f1387719 |
565 | # Where is the Config information that we are using/depend on |
566 | CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm \$(PERL_INC)/config.h |
567 | }; |
1e44e2bf |
568 | |
f1387719 |
569 | my @parentdir = split(/::/, $self->{PARENT_NAME}); |
570 | push @m, q{ |
571 | # Where to put things: |
572 | INST_LIBDIR = }. $self->catdir('$(INST_LIB)',@parentdir) .q{ |
573 | INST_ARCHLIBDIR = }. $self->catdir('$(INST_ARCHLIB)',@parentdir) .q{ |
1e44e2bf |
574 | |
f1387719 |
575 | INST_AUTODIR = }. $self->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{ |
576 | INST_ARCHAUTODIR = }. $self->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{ |
577 | }; |
1e44e2bf |
578 | |
f1387719 |
579 | if ($self->has_link_code()) { |
580 | push @m, ' |
581 | INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT) |
582 | INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT) |
583 | INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs |
584 | '; |
585 | } else { |
586 | push @m, ' |
587 | INST_STATIC = |
588 | INST_DYNAMIC = |
589 | INST_BOOT = |
590 | '; |
1e44e2bf |
591 | } |
592 | |
f1387719 |
593 | if ($Is_OS2) { |
594 | $tmp = "$self->{BASEEXT}.def"; |
595 | } else { |
596 | $tmp = ""; |
597 | } |
598 | push @m, " |
599 | EXPORT_LIST = $tmp |
600 | "; |
1e44e2bf |
601 | |
f1387719 |
602 | if ($Is_OS2) { |
603 | $tmp = "\$(PERL_INC)/libperl\$(LIB_EXT)"; |
604 | } else { |
605 | $tmp = ""; |
606 | } |
607 | push @m, " |
608 | PERL_ARCHIVE = $tmp |
609 | "; |
1e44e2bf |
610 | |
f1387719 |
611 | # push @m, q{ |
612 | #INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{ |
613 | # |
614 | #PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{ |
615 | #}; |
1e44e2bf |
616 | |
f1387719 |
617 | push @m, q{ |
618 | TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{ |
1e44e2bf |
619 | |
f1387719 |
620 | PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{ |
621 | }; |
1e44e2bf |
622 | |
f1387719 |
623 | join('',@m); |
624 | } |
1e44e2bf |
625 | |
f1387719 |
626 | =item depend (o) |
1e44e2bf |
627 | |
f1387719 |
628 | Same as macro for the depend attribute. |
1e44e2bf |
629 | |
f1387719 |
630 | =cut |
1e44e2bf |
631 | |
f1387719 |
632 | sub depend { |
633 | my($self,%attribs) = @_; |
634 | my(@m,$key,$val); |
635 | while (($key,$val) = each %attribs){ |
636 | last unless defined $key; |
637 | push @m, "$key: $val\n"; |
1e44e2bf |
638 | } |
f1387719 |
639 | join "", @m; |
640 | } |
1e44e2bf |
641 | |
f1387719 |
642 | =item dir_target (o) |
1e44e2bf |
643 | |
f1387719 |
644 | Takes an array of directories that need to exist and returns a |
645 | Makefile entry for a .exists file in these directories. Returns |
646 | nothing, if the entry has already been processed. We're helpless |
647 | though, if the same directory comes as $(FOO) _and_ as "bar". Both of |
648 | them get an entry, that's why we use "::". |
1e44e2bf |
649 | |
f1387719 |
650 | =cut |
1e44e2bf |
651 | |
f1387719 |
652 | sub dir_target { |
653 | # --- Make-Directories section (internal method) --- |
654 | # dir_target(@array) returns a Makefile entry for the file .exists in each |
655 | # named directory. Returns nothing, if the entry has already been processed. |
656 | # We're helpless though, if the same directory comes as $(FOO) _and_ as "bar". |
657 | # Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the |
658 | # prerequisite, because there has to be one, something that doesn't change |
659 | # too often :) |
1e44e2bf |
660 | |
f1387719 |
661 | my($self,@dirs) = @_; |
662 | my(@m,$dir); |
663 | foreach $dir (@dirs) { |
664 | my($src) = $self->catfile($self->{PERL_INC},'perl.h'); |
665 | my($targ) = $self->catfile($dir,'.exists'); |
666 | my($targdir) = $targ; # Necessary because catfile may have |
667 | $targdir =~ s:/?.exists$::; # adapted syntax of $dir to target OS |
668 | next if $self->{DIR_TARGET}{$self}{$targdir}++; |
669 | push @m, qq{ |
670 | $targ :: $src |
671 | $self->{NOECHO}\$(MKPATH) $targdir |
672 | $self->{NOECHO}\$(EQUALIZE_TIMESTAMP) $src $targ |
673 | }; |
674 | push(@m,qq{ |
675 | -$self->{NOECHO}\$(CHMOD) 755 $targdir |
676 | }) unless $Is_VMS; |
677 | } |
678 | join "", @m; |
679 | } |
1e44e2bf |
680 | |
f1387719 |
681 | =item dist (o) |
1e44e2bf |
682 | |
f1387719 |
683 | Defines a lot of macros for distribution support. |
1e44e2bf |
684 | |
f1387719 |
685 | =cut |
1e44e2bf |
686 | |
f1387719 |
687 | sub dist { |
688 | my($self, %attribs) = @_; |
1e44e2bf |
689 | |
f1387719 |
690 | my(@m); |
691 | # VERSION should be sanitised before use as a file name |
692 | my($version) = $attribs{VERSION} || '$(VERSION)'; |
693 | my($name) = $attribs{NAME} || '$(DISTNAME)'; |
694 | my($tar) = $attribs{TAR} || 'tar'; # eg /usr/bin/gnutar |
695 | my($tarflags) = $attribs{TARFLAGS} || 'cvf'; |
696 | my($zip) = $attribs{ZIP} || 'zip'; # eg pkzip Yuck! |
697 | my($zipflags) = $attribs{ZIPFLAGS} || '-r'; |
698 | my($compress) = $attribs{COMPRESS} || 'compress'; # eg gzip |
699 | my($suffix) = $attribs{SUFFIX} || '.Z'; # eg .gz |
700 | my($shar) = $attribs{SHAR} || 'shar'; # eg "shar --gzip" |
701 | my($preop) = $attribs{PREOP} || "$self->{NOECHO}\$(NOOP)"; # eg update MANIFEST |
702 | my($postop) = $attribs{POSTOP} || "$self->{NOECHO}\$(NOOP)"; # eg remove the distdir |
1e44e2bf |
703 | |
f1387719 |
704 | my($to_unix) = $attribs{TO_UNIX} || ($Is_OS2 |
705 | ? "$self->{NOECHO}" |
706 | . 'test -f tmp.zip && $(RM) tmp.zip;' |
707 | . ' $(ZIP) -ll -mr tmp.zip $(DISTVNAME) && unzip -o tmp.zip && $(RM) tmp.zip' |
708 | : "$self->{NOECHO}\$(NOOP)"); |
1e44e2bf |
709 | |
f1387719 |
710 | my($ci) = $attribs{CI} || 'ci -u'; |
711 | my($rcs_label)= $attribs{RCS_LABEL}|| 'rcs -Nv$(VERSION_SYM): -q'; |
712 | my($dist_cp) = $attribs{DIST_CP} || 'best'; |
713 | my($dist_default) = $attribs{DIST_DEFAULT} || 'tardist'; |
1e44e2bf |
714 | |
f1387719 |
715 | push @m, " |
716 | DISTVNAME = ${name}-$version |
717 | TAR = $tar |
718 | TARFLAGS = $tarflags |
719 | ZIP = $zip |
720 | ZIPFLAGS = $zipflags |
721 | COMPRESS = $compress |
722 | SUFFIX = $suffix |
723 | SHAR = $shar |
724 | PREOP = $preop |
725 | POSTOP = $postop |
726 | TO_UNIX = $to_unix |
727 | CI = $ci |
728 | RCS_LABEL = $rcs_label |
729 | DIST_CP = $dist_cp |
730 | DIST_DEFAULT = $dist_default |
731 | "; |
732 | join "", @m; |
1e44e2bf |
733 | } |
734 | |
f1387719 |
735 | =item dist_basics (o) |
1e44e2bf |
736 | |
f1387719 |
737 | Defines the targets distclean, distcheck, skipcheck, manifest. |
1e44e2bf |
738 | |
739 | =cut |
740 | |
f1387719 |
741 | sub dist_basics { |
742 | my($self) = shift; |
743 | my @m; |
744 | push @m, q{ |
745 | distclean :: realclean distcheck |
746 | }; |
1e44e2bf |
747 | |
f1387719 |
748 | push @m, q{ |
749 | distcheck : |
750 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&fullcheck";' \\ |
751 | -e 'fullcheck();' |
752 | }; |
1e44e2bf |
753 | |
f1387719 |
754 | push @m, q{ |
755 | skipcheck : |
756 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&skipcheck";' \\ |
757 | -e 'skipcheck();' |
758 | }; |
1e44e2bf |
759 | |
f1387719 |
760 | push @m, q{ |
761 | manifest : |
762 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&mkmanifest";' \\ |
763 | -e 'mkmanifest();' |
764 | }; |
765 | join "", @m; |
1e44e2bf |
766 | } |
767 | |
f1387719 |
768 | =item dist_ci (o) |
1e44e2bf |
769 | |
f1387719 |
770 | Defines a check in target for RCS. |
1e44e2bf |
771 | |
772 | =cut |
773 | |
f1387719 |
774 | sub dist_ci { |
1e44e2bf |
775 | my($self) = shift; |
f1387719 |
776 | my @m; |
777 | push @m, q{ |
778 | ci : |
779 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&maniread";' \\ |
780 | -e '@all = keys %{ maniread() };' \\ |
781 | -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \\ |
782 | -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");' |
783 | }; |
784 | join "", @m; |
785 | } |
1e44e2bf |
786 | |
f1387719 |
787 | =item dist_core (o) |
1e44e2bf |
788 | |
f1387719 |
789 | Defeines the targets dist, tardist, zipdist, uutardist, shdist |
1e44e2bf |
790 | |
f1387719 |
791 | =cut |
1e44e2bf |
792 | |
f1387719 |
793 | sub dist_core { |
794 | my($self) = shift; |
795 | my @m; |
796 | push @m, q{ |
797 | dist : $(DIST_DEFAULT) |
798 | }.$self->{NOECHO}.q{$(PERL) -le 'print "Warning: Makefile possibly out of date with $$vf" if ' \ |
799 | -e '-e ($$vf="$(VERSION_FROM)") and -M $$vf < -M "}.$self->{MAKEFILE}.q{";' |
1e44e2bf |
800 | |
f1387719 |
801 | tardist : $(DISTVNAME).tar$(SUFFIX) |
1e44e2bf |
802 | |
f1387719 |
803 | zipdist : $(DISTVNAME).zip |
1e44e2bf |
804 | |
f1387719 |
805 | $(DISTVNAME).tar$(SUFFIX) : distdir |
806 | $(PREOP) |
807 | $(TO_UNIX) |
808 | $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) |
809 | $(RM_RF) $(DISTVNAME) |
810 | $(COMPRESS) $(DISTVNAME).tar |
811 | $(POSTOP) |
1e44e2bf |
812 | |
f1387719 |
813 | $(DISTVNAME).zip : distdir |
814 | $(PREOP) |
815 | $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) |
816 | $(RM_RF) $(DISTVNAME) |
817 | $(POSTOP) |
1e44e2bf |
818 | |
f1387719 |
819 | uutardist : $(DISTVNAME).tar$(SUFFIX) |
820 | uuencode $(DISTVNAME).tar$(SUFFIX) \\ |
821 | $(DISTVNAME).tar$(SUFFIX) > \\ |
822 | $(DISTVNAME).tar$(SUFFIX)_uu |
f4ae0f5e |
823 | |
f1387719 |
824 | shdist : distdir |
825 | $(PREOP) |
826 | $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar |
827 | $(RM_RF) $(DISTVNAME) |
828 | $(POSTOP) |
829 | }; |
830 | join "", @m; |
f4ae0f5e |
831 | } |
832 | |
f1387719 |
833 | =item dist_dir (o) |
f4ae0f5e |
834 | |
f1387719 |
835 | Defines the scratch directory target that will hold the distribution |
836 | before tar-ing (or shar-ing). |
1e44e2bf |
837 | |
838 | =cut |
839 | |
f1387719 |
840 | sub dist_dir { |
841 | my($self) = shift; |
842 | my @m; |
843 | push @m, q{ |
844 | distdir : |
845 | $(RM_RF) $(DISTVNAME) |
846 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=manicopy,maniread \\ |
847 | -e 'manicopy(maniread(),"$(DISTVNAME)", "$(DIST_CP)");' |
848 | }; |
849 | join "", @m; |
1e44e2bf |
850 | } |
851 | |
f1387719 |
852 | =item dist_test (o) |
1e44e2bf |
853 | |
f1387719 |
854 | Defines a target that produces the distribution in the |
855 | scratchdirectory, and runs 'perl Makefile.PL; make ;make test' in that |
856 | subdirectory. |
1e44e2bf |
857 | |
858 | =cut |
859 | |
f1387719 |
860 | sub dist_test { |
1e44e2bf |
861 | my($self) = shift; |
f1387719 |
862 | my @m; |
863 | push @m, q{ |
864 | disttest : distdir |
865 | cd $(DISTVNAME) && $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL |
866 | cd $(DISTVNAME) && $(MAKE) |
867 | cd $(DISTVNAME) && $(MAKE) test |
868 | }; |
869 | join "", @m; |
1e44e2bf |
870 | } |
871 | |
f1387719 |
872 | =item dlsyms (o) |
1e44e2bf |
873 | |
f1387719 |
874 | Used by AIX and VMS to define DL_FUNCS and DL_VARS and write the *.exp |
875 | files. |
1e44e2bf |
876 | |
877 | =cut |
878 | |
f1387719 |
879 | sub dlsyms { |
880 | my($self,%attribs) = @_; |
1e44e2bf |
881 | |
f1387719 |
882 | return '' unless ($^O eq 'aix' && $self->needs_linking() ); |
1e44e2bf |
883 | |
f1387719 |
884 | my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {}; |
885 | my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || []; |
886 | my(@m); |
1e44e2bf |
887 | |
f1387719 |
888 | push(@m," |
889 | dynamic :: $self->{BASEEXT}.exp |
1e44e2bf |
890 | |
f1387719 |
891 | ") unless $self->{SKIPHASH}{'dynamic'}; # dynamic and static are subs, so... |
1e44e2bf |
892 | |
f1387719 |
893 | push(@m," |
894 | static :: $self->{BASEEXT}.exp |
1e44e2bf |
895 | |
f1387719 |
896 | ") unless $self->{SKIPHASH}{'static'}; # we avoid a warning if we tick them |
1e44e2bf |
897 | |
f1387719 |
898 | push(@m," |
899 | $self->{BASEEXT}.exp: Makefile.PL |
900 | ",' $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\ |
901 | Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ', |
902 | neatvalue($funcs),', "DL_VARS" => ', neatvalue($vars), ');\' |
903 | '); |
1e44e2bf |
904 | |
f1387719 |
905 | join('',@m); |
906 | } |
1e44e2bf |
907 | |
f1387719 |
908 | =item dynamic (o) |
1e44e2bf |
909 | |
f1387719 |
910 | Defines the dynamic target. |
1e44e2bf |
911 | |
f1387719 |
912 | =cut |
1e44e2bf |
913 | |
f1387719 |
914 | sub dynamic { |
915 | # --- Dynamic Loading Sections --- |
1e44e2bf |
916 | |
f1387719 |
917 | my($self) = shift; |
918 | ' |
919 | ## $(INST_PM) has been moved to the all: target. |
920 | ## It remains here for awhile to allow for old usage: "make dynamic" |
921 | #dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM) |
922 | dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) |
923 | '.$self->{NOECHO}.'$(NOOP) |
924 | '; |
925 | } |
1e44e2bf |
926 | |
f1387719 |
927 | =item dynamic_bs (o) |
1e44e2bf |
928 | |
f1387719 |
929 | Defines targets for bootstrap files. |
1e44e2bf |
930 | |
f1387719 |
931 | =cut |
1e44e2bf |
932 | |
f1387719 |
933 | sub dynamic_bs { |
934 | my($self, %attribs) = @_; |
935 | return ' |
936 | BOOTSTRAP = |
937 | ' unless $self->has_link_code(); |
1e44e2bf |
938 | |
f1387719 |
939 | return ' |
940 | BOOTSTRAP = '."$self->{BASEEXT}.bs".' |
1e44e2bf |
941 | |
f1387719 |
942 | # As Mkbootstrap might not write a file (if none is required) |
943 | # we use touch to prevent make continually trying to remake it. |
944 | # The DynaLoader only reads a non-empty file. |
945 | $(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)/.exists |
946 | '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))" |
947 | '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \ |
948 | -e \'use ExtUtils::Mkbootstrap;\' \ |
949 | -e \'Mkbootstrap("$(BASEEXT)","$(BSLOADLIBS)");\' |
950 | '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP) |
951 | $(CHMOD) 644 $@ |
1e44e2bf |
952 | |
f1387719 |
953 | $(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists |
954 | '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT) |
955 | -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT) |
956 | $(CHMOD) 644 $@ |
1e44e2bf |
957 | '; |
f1387719 |
958 | } |
1e44e2bf |
959 | |
f1387719 |
960 | =item dynamic_lib (o) |
1e44e2bf |
961 | |
f1387719 |
962 | Defines how to produce the *.so (or equivalent) files. |
963 | |
964 | =cut |
965 | |
966 | sub dynamic_lib { |
967 | my($self, %attribs) = @_; |
968 | return '' unless $self->needs_linking(); #might be because of a subdir |
1e44e2bf |
969 | |
f1387719 |
970 | return '' unless $self->has_link_code; |
f4ae0f5e |
971 | |
f1387719 |
972 | my($otherldflags) = $attribs{OTHERLDFLAGS} || ""; |
973 | my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || ""; |
974 | my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":"; |
975 | my($ldfrom) = '$(LDFROM)'; |
976 | $armaybe = 'ar' if ($^O eq 'dec_osf' and $armaybe eq ':'); |
977 | my(@m); |
978 | push(@m,' |
979 | # This section creates the dynamically loadable $(INST_DYNAMIC) |
980 | # from $(OBJECT) and possibly $(MYEXTLIB). |
981 | ARMAYBE = '.$armaybe.' |
982 | OTHERLDFLAGS = '.$otherldflags.' |
983 | INST_DYNAMIC_DEP = '.$inst_dynamic_dep.' |
f4ae0f5e |
984 | |
f1387719 |
985 | $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP) |
986 | '); |
987 | if ($armaybe ne ':'){ |
988 | $ldfrom = 'tmp$(LIB_EXT)'; |
989 | push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n"); |
990 | push(@m,' $(RANLIB) '."$ldfrom\n"); |
991 | } |
992 | $ldfrom = "-all $ldfrom -none" if ($^O eq 'dec_osf'); |
993 | push(@m,' LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ $(LDDLFLAGS) '.$ldfrom. |
994 | ' $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) $(EXPORT_LIST)'); |
995 | push @m, ' |
996 | $(CHMOD) 755 $@ |
997 | '; |
1e44e2bf |
998 | |
f1387719 |
999 | push @m, $self->dir_target('$(INST_ARCHAUTODIR)'); |
1e44e2bf |
1000 | join('',@m); |
1001 | } |
1002 | |
f1387719 |
1003 | =item exescan |
1e44e2bf |
1004 | |
f1387719 |
1005 | Deprecated method. Use libscan instead. |
1e44e2bf |
1006 | |
1007 | =cut |
1008 | |
f1387719 |
1009 | sub exescan { |
1010 | my($self,$path) = @_; |
1011 | $path; |
1e44e2bf |
1012 | } |
1013 | |
f1387719 |
1014 | =item extliblist |
1e44e2bf |
1015 | |
f1387719 |
1016 | Called by init_others, and calls ext ExtUtils::Liblist. See |
1017 | L<ExtUtils::Liblist> for details. |
1e44e2bf |
1018 | |
1019 | =cut |
1020 | |
f1387719 |
1021 | sub extliblist { |
1022 | my($self,$libs) = @_; |
1023 | require ExtUtils::Liblist; |
1024 | $self->ext($libs, $Verbose); |
1025 | } |
f4ae0f5e |
1026 | |
f1387719 |
1027 | =item file_name_is_absolute |
f4ae0f5e |
1028 | |
f1387719 |
1029 | Takes as argument a path and returns true, it it is an absolute path. |
1e44e2bf |
1030 | |
f1387719 |
1031 | =cut |
1e44e2bf |
1032 | |
f1387719 |
1033 | sub file_name_is_absolute { |
1034 | my($self,$file) = @_; |
1035 | $file =~ m:^/: ; |
1036 | } |
1e44e2bf |
1037 | |
f1387719 |
1038 | =item find_perl |
1e44e2bf |
1039 | |
f1387719 |
1040 | Finds the executables PERL and FULLPERL |
1e44e2bf |
1041 | |
f1387719 |
1042 | =cut |
1e44e2bf |
1043 | |
f1387719 |
1044 | sub find_perl { |
1045 | my($self, $ver, $names, $dirs, $trace) = @_; |
1046 | my($name, $dir); |
1047 | if ($trace >= 2){ |
1048 | print "Looking for perl $ver by these names: |
1049 | @$names |
1050 | in these dirs: |
1051 | @$dirs |
1052 | "; |
1053 | } |
1054 | foreach $dir (@$dirs){ |
1055 | next unless defined $dir; # $self->{PERL_SRC} may be undefined |
1056 | foreach $name (@$names){ |
1057 | my $abs; |
1058 | if ($self->file_name_is_absolute($name)) { # /foo/bar |
1059 | $abs = $name; |
1060 | } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # foo |
1061 | $abs = $self->catfile($dir, $name); |
1062 | } else { # foo/bar |
1063 | $abs = $self->canonpath($self->catfile($self->curdir, $name)); |
1064 | } |
1065 | print "Checking $abs\n" if ($trace >= 2); |
1066 | next unless $self->maybe_command($abs); |
1067 | print "Executing $abs\n" if ($trace >= 2); |
1068 | if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) { |
1069 | print "Using PERL=$abs\n" if $trace; |
1070 | return $abs; |
1e44e2bf |
1071 | } |
1072 | } |
1e44e2bf |
1073 | } |
f1387719 |
1074 | print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n"; |
1075 | 0; # false and not empty |
1076 | } |
1e44e2bf |
1077 | |
f1387719 |
1078 | =head2 Methods to actually produce chunks of text for the Makefile |
1e44e2bf |
1079 | |
f1387719 |
1080 | The methods here are called in the order specified by |
1081 | @ExtUtils::MakeMaker::MM_Sections. This manpage reflects the order as |
1082 | well as possible. Some methods call each other, so in doubt refer to |
1083 | the code. |
f4ae0f5e |
1084 | |
f1387719 |
1085 | =item force (o) |
1086 | |
1087 | Just writes FORCE: |
1088 | |
1089 | =cut |
1e44e2bf |
1090 | |
f1387719 |
1091 | sub force { |
1092 | my($self) = shift; |
1093 | '# Phony target to force checking subdirectories. |
1094 | FORCE: |
1095 | '; |
1e44e2bf |
1096 | } |
1097 | |
f1387719 |
1098 | =item guess_name |
1e44e2bf |
1099 | |
f1387719 |
1100 | Guess the name of this package by examining the working directory's |
1101 | name. MakeMaker calls this only if the developer has not supplied a |
1102 | NAME attribute. |
1e44e2bf |
1103 | |
f1387719 |
1104 | =cut |
f4ae0f5e |
1105 | |
f1387719 |
1106 | # '; |
1107 | |
1108 | sub guess_name { |
1109 | my($self) = @_; |
1110 | use Cwd 'cwd'; |
1111 | my $name = basename(cwd()); |
1112 | $name =~ s|[\-_][\d\.\-]+$||; # this is new with MM 5.00, we |
1113 | # strip minus or underline |
1114 | # followed by a float or some such |
1115 | print "Warning: Guessing NAME [$name] from current directory name.\n"; |
1116 | $name; |
1117 | } |
1118 | |
1119 | =item has_link_code |
1120 | |
1121 | Returns true if C, XS, MYEXTLIB or similar objects exist within this |
1122 | object that need a compiler. Does not descend into subdirectories as |
1123 | needs_linking() does. |
f4ae0f5e |
1124 | |
1125 | =cut |
1126 | |
f1387719 |
1127 | sub has_link_code { |
1128 | my($self) = shift; |
1129 | return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE}; |
1130 | if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){ |
1131 | $self->{HAS_LINK_CODE} = 1; |
1132 | return 1; |
f4ae0f5e |
1133 | } |
f1387719 |
1134 | return $self->{HAS_LINK_CODE} = 0; |
f4ae0f5e |
1135 | } |
1136 | |
f1387719 |
1137 | =item init_dirscan |
f4ae0f5e |
1138 | |
f1387719 |
1139 | Initializes DIR, XS, PM, C, O_FILES, H, PL_FILES, MAN*PODS, EXE_FILES. |
1140 | |
1141 | =cut |
1142 | |
1143 | sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) |
1144 | my($self) = @_; |
1145 | my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods); |
1146 | local(%pm); #the sub in find() has to see this hash |
1147 | $ignore{'test.pl'} = 1; |
1148 | $ignore{'makefile.pl'} = 1 if $Is_VMS; |
1149 | foreach $name ($self->lsdir($self->curdir)){ |
1150 | next if $name eq $self->curdir or $name eq $self->updir or $ignore{$name}; |
1151 | next unless $self->libscan($name); |
1152 | if (-d $name){ |
1153 | next if -l $name; # We do not support symlinks at all |
1154 | $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL")); |
1155 | } elsif ($name =~ /\.xs$/){ |
1156 | my($c); ($c = $name) =~ s/\.xs$/.c/; |
1157 | $xs{$name} = $c; |
1158 | $c{$c} = 1; |
1159 | } elsif ($name =~ /\.c(pp|xx|c)?$/i){ # .c .C .cpp .cxx .cc |
1160 | $c{$name} = 1 |
1161 | unless $name =~ m/perlmain\.c/; # See MAP_TARGET |
1162 | } elsif ($name =~ /\.h$/i){ |
1163 | $h{$name} = 1; |
1164 | } elsif ($name =~ /\.(p[ml]|pod)$/){ |
1165 | $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name); |
1166 | } elsif ($name =~ /\.PL$/ && $name ne "Makefile.PL") { |
1167 | ($pl_files{$name} = $name) =~ s/\.PL$// ; |
1168 | } elsif ($Is_VMS && $name =~ /\.pl$/ && $name ne 'makefile.pl' && |
1169 | $name ne 'test.pl') { # case-insensitive filesystem |
1170 | ($pl_files{$name} = $name) =~ s/\.pl$// ; |
1171 | } |
1172 | } |
f4ae0f5e |
1173 | |
f1387719 |
1174 | # Some larger extensions often wish to install a number of *.pm/pl |
1175 | # files into the library in various locations. |
f4ae0f5e |
1176 | |
f1387719 |
1177 | # The attribute PMLIBDIRS holds an array reference which lists |
1178 | # subdirectories which we should search for library files to |
1179 | # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We |
1180 | # recursively search through the named directories (skipping any |
1181 | # which don't exist or contain Makefile.PL files). |
f4ae0f5e |
1182 | |
f1387719 |
1183 | # For each *.pm or *.pl file found $self->libscan() is called with |
1184 | # the default installation path in $_[1]. The return value of |
1185 | # libscan defines the actual installation location. The default |
1186 | # libscan function simply returns the path. The file is skipped |
1187 | # if libscan returns false. |
f4ae0f5e |
1188 | |
f1387719 |
1189 | # The default installation location passed to libscan in $_[1] is: |
1190 | # |
1191 | # ./*.pm => $(INST_LIBDIR)/*.pm |
1192 | # ./xyz/... => $(INST_LIBDIR)/xyz/... |
1193 | # ./lib/... => $(INST_LIB)/... |
1194 | # |
1195 | # In this way the 'lib' directory is seen as the root of the actual |
1196 | # perl library whereas the others are relative to INST_LIBDIR |
1197 | # (which includes PARENT_NAME). This is a subtle distinction but one |
1198 | # that's important for nested modules. |
1e44e2bf |
1199 | |
f1387719 |
1200 | $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}] |
1201 | unless $self->{PMLIBDIRS}; |
1e44e2bf |
1202 | |
f1387719 |
1203 | #only existing directories that aren't in $dir are allowed |
1e44e2bf |
1204 | |
f1387719 |
1205 | # Avoid $_ wherever possible: |
1206 | # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}}; |
1207 | my (@pmlibdirs) = @{$self->{PMLIBDIRS}}; |
1208 | my ($pmlibdir); |
1209 | @{$self->{PMLIBDIRS}} = (); |
1210 | foreach $pmlibdir (@pmlibdirs) { |
1211 | -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir; |
1e44e2bf |
1212 | } |
1e44e2bf |
1213 | |
f1387719 |
1214 | if (@{$self->{PMLIBDIRS}}){ |
1215 | print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n" |
1216 | if ($Verbose >= 2); |
1217 | require File::Find; |
1218 | File::Find::find(sub { |
1219 | if (-d $_){ |
1220 | if ($_ eq "CVS" || $_ eq "RCS"){ |
1221 | $File::Find::prune = 1; |
1222 | } |
1223 | return; |
1224 | } |
1225 | my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)'); |
1226 | my($striplibpath,$striplibname); |
1227 | $prefix = '$(INST_LIB)' if (($striplibpath = $path) =~ s:^(\W*)lib\W:$1:); |
1228 | ($striplibname,$striplibpath) = fileparse($striplibpath); |
1229 | my($inst) = $self->catfile($prefix,$striplibpath,$striplibname); |
1230 | local($_) = $inst; # for backwards compatibility |
1231 | $inst = $self->libscan($inst); |
1232 | print "libscan($path) => '$inst'\n" if ($Verbose >= 2); |
1233 | return unless $inst; |
1234 | $pm{$path} = $inst; |
1235 | }, @{$self->{PMLIBDIRS}}); |
1236 | } |
1e44e2bf |
1237 | |
f1387719 |
1238 | $self->{DIR} = [sort keys %dir] unless $self->{DIR}; |
1239 | $self->{XS} = \%xs unless $self->{XS}; |
1240 | $self->{PM} = \%pm unless $self->{PM}; |
1241 | $self->{C} = [sort keys %c] unless $self->{C}; |
1242 | my(@o_files) = @{$self->{C}}; |
1243 | $self->{O_FILES} = [grep s/\.c(pp|xx|c)?$/$self->{OBJ_EXT}/i, @o_files] ; |
1244 | $self->{H} = [sort keys %h] unless $self->{H}; |
1245 | $self->{PL_FILES} = \%pl_files unless $self->{PL_FILES}; |
1e44e2bf |
1246 | |
f1387719 |
1247 | # Set up names of manual pages to generate from pods |
1248 | if ($self->{MAN1PODS}) { |
1249 | } elsif ( $self->{INST_MAN1DIR} =~ /^(none|\s*)$/ ) { |
1250 | $self->{MAN1PODS} = {}; |
1251 | } else { |
1252 | my %manifypods = (); |
1253 | if ( exists $self->{EXE_FILES} ) { |
1254 | foreach $name (@{$self->{EXE_FILES}}) { |
1255 | # use FileHandle (); |
1256 | # my $fh = new FileHandle; |
1257 | local *FH; |
1258 | my($ispod)=0; |
1259 | # one day test, if $/ can be set to '' safely (is the bug fixed that was in 5.001m?) |
1260 | # if ($fh->open("<$name")) { |
1261 | if (open(FH,"<$name")) { |
1262 | # while (<$fh>) { |
1263 | while (<FH>) { |
1264 | if (/^=head1\s+\w+/) { |
1265 | $ispod=1; |
1266 | last; |
1267 | } |
1268 | } |
1269 | # $fh->close; |
1270 | close FH; |
1271 | } else { |
1272 | # If it doesn't exist yet, we assume, it has pods in it |
1273 | $ispod = 1; |
1e44e2bf |
1274 | } |
f1387719 |
1275 | if( $ispod ) { |
1276 | $manifypods{$name} = $self->catfile('$(INST_MAN1DIR)',basename($name).'.$(MAN1EXT)'); |
1e44e2bf |
1277 | } |
f1387719 |
1278 | } |
1e44e2bf |
1279 | } |
f1387719 |
1280 | $self->{MAN1PODS} = \%manifypods; |
1e44e2bf |
1281 | } |
f1387719 |
1282 | if ($self->{MAN3PODS}) { |
1283 | } elsif ( $self->{INST_MAN3DIR} =~ /^(none|\s*)$/ ) { |
1284 | $self->{MAN3PODS} = {}; |
1e44e2bf |
1285 | } else { |
f1387719 |
1286 | my %manifypods = (); # we collect the keys first, i.e. the files |
1287 | # we have to convert to pod |
1288 | foreach $name (keys %{$self->{PM}}) { |
1289 | if ($name =~ /\.pod$/ ) { |
1290 | $manifypods{$name} = $self->{PM}{$name}; |
1291 | } elsif ($name =~ /\.p[ml]$/ ) { |
1292 | # use FileHandle (); |
1293 | # my $fh = new FileHandle; |
1294 | local *FH; |
1295 | my($ispod)=0; |
1296 | # $fh->open("<$name"); |
1297 | if (open(FH,"<$name")) { |
1298 | # while (<$fh>) { |
1299 | while (<FH>) { |
1300 | if (/^=head1\s+\w+/) { |
1301 | $ispod=1; |
1302 | last; |
1303 | } |
1304 | } |
1305 | # $fh->close; |
1306 | close FH; |
1307 | } else { |
1308 | $ispod = 1; |
1309 | } |
1310 | if( $ispod ) { |
1311 | $manifypods{$name} = $self->{PM}{$name}; |
1312 | } |
1313 | } |
1314 | } |
1315 | |
1316 | # Remove "Configure.pm" and similar, if it's not the only pod listed |
1317 | # To force inclusion, just name it "Configure.pod", or override MAN3PODS |
1318 | foreach $name (keys %manifypods) { |
1319 | if ($name =~ /(config|setup).*\.pm/i) { |
1320 | delete $manifypods{$name}; |
1321 | next; |
1322 | } |
1323 | my($manpagename) = $name; |
1324 | unless ($manpagename =~ s!^\W*lib\W+!!) { # everything below lib is ok |
1325 | $manpagename = $self->catfile(split(/::/,$self->{PARENT_NAME}),$manpagename); |
1326 | } |
1327 | $manpagename =~ s/\.p(od|m|l)$//; |
1328 | $manpagename = $self->replace_manpage_separator($manpagename); |
1329 | $manifypods{$name} = $self->catfile("\$(INST_MAN3DIR)","$manpagename.\$(MAN3EXT)"); |
1e44e2bf |
1330 | } |
f1387719 |
1331 | $self->{MAN3PODS} = \%manifypods; |
1e44e2bf |
1332 | } |
f1387719 |
1333 | } |
1e44e2bf |
1334 | |
f1387719 |
1335 | =item init_main |
1e44e2bf |
1336 | |
f1387719 |
1337 | Initializes NAME, FULLEXT, BASEEXT, PARENT_NAME, DLBASE, PERL_SRC, |
1338 | PERL_LIB, PERL_ARCHLIB, PERL_INC, INSTALLDIRS, INST_*, INSTALL*, |
1339 | PREFIX, CONFIG, AR, AR_STATIC_ARGS, LD, OBJ_EXT, LIB_EXT, MAP_TARGET, |
1340 | LIBPERL_A, VERSION_FROM, VERSION, DISTNAME, VERSION_SYM. |
f4ae0f5e |
1341 | |
f1387719 |
1342 | =cut |
1e44e2bf |
1343 | |
f1387719 |
1344 | sub init_main { |
1345 | my($self) = @_; |
1e44e2bf |
1346 | |
f1387719 |
1347 | # --- Initialize Module Name and Paths |
1e44e2bf |
1348 | |
f1387719 |
1349 | # NAME = Foo::Bar::Oracle |
1350 | # FULLEXT = Foo/Bar/Oracle |
1351 | # BASEEXT = Oracle |
1352 | # ROOTEXT = Directory part of FULLEXT with leading /. !!! Deprecated from MM 5.32 !!! |
1353 | # PARENT_NAME = Foo::Bar |
1354 | ### Only UNIX: |
1355 | ### ($self->{FULLEXT} = |
1356 | ### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket |
1357 | $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME}); |
1e44e2bf |
1358 | |
1e44e2bf |
1359 | |
f1387719 |
1360 | # Copied from DynaLoader: |
1e44e2bf |
1361 | |
f1387719 |
1362 | my(@modparts) = split(/::/,$self->{NAME}); |
1363 | my($modfname) = $modparts[-1]; |
1e44e2bf |
1364 | |
f1387719 |
1365 | # Some systems have restrictions on files names for DLL's etc. |
1366 | # mod2fname returns appropriate file base name (typically truncated) |
1367 | # It may also edit @modparts if required. |
1368 | if (defined &DynaLoader::mod2fname) { |
1369 | $modfname = &DynaLoader::mod2fname(\@modparts); |
1370 | } elsif ($Is_OS2) { # Need manual correction if run with miniperl:-( |
1371 | $modfname = substr($modfname, 0, 7) . '_'; |
1372 | } |
1e44e2bf |
1373 | |
1e44e2bf |
1374 | |
f1387719 |
1375 | ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!([\w:]+::)?(\w+)$! ; |
1376 | |
1377 | if (defined &DynaLoader::mod2fname or $Is_OS2) { |
1378 | # As of 5.001m, dl_os2 appends '_' |
1379 | $self->{DLBASE} = $modfname; |
1380 | } else { |
1381 | $self->{DLBASE} = '$(BASEEXT)'; |
1382 | } |
1383 | |
1e44e2bf |
1384 | |
f1387719 |
1385 | ### ROOTEXT deprecated from MM 5.32 |
1386 | ### ($self->{ROOTEXT} = |
1387 | ### $self->{FULLEXT}) =~ s#/?\Q$self->{BASEEXT}\E$## ; #eg. /BSD/Foo |
1388 | ### $self->{ROOTEXT} = ($Is_VMS ? '' : '/') . $self->{ROOTEXT} if $self->{ROOTEXT}; |
1e44e2bf |
1389 | |
1e44e2bf |
1390 | |
f1387719 |
1391 | # --- Initialize PERL_LIB, INST_LIB, PERL_SRC |
1e44e2bf |
1392 | |
f1387719 |
1393 | # *Real* information: where did we get these two from? ... |
1394 | my $inc_config_dir = dirname($INC{'Config.pm'}); |
1395 | my $inc_carp_dir = dirname($INC{'Carp.pm'}); |
1e44e2bf |
1396 | |
f1387719 |
1397 | unless ($self->{PERL_SRC}){ |
1398 | my($dir); |
1399 | foreach $dir ($self->updir(),$self->catdir($self->updir(),$self->updir()),$self->catdir($self->updir(),$self->updir(),$self->updir())){ |
1400 | if ( |
1401 | -f $self->catfile($dir,"config.sh") |
1402 | && |
1403 | -f $self->catfile($dir,"perl.h") |
1404 | && |
1405 | -f $self->catfile($dir,"lib","Exporter.pm") |
1406 | ) { |
1407 | $self->{PERL_SRC}=$dir ; |
1408 | last; |
1409 | } |
1410 | } |
1411 | } |
1412 | if ($self->{PERL_SRC}){ |
1413 | $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib"); |
1414 | $self->{PERL_ARCHLIB} = $self->{PERL_LIB}; |
1415 | $self->{PERL_INC} = $self->{PERL_SRC}; |
1416 | # catch a situation that has occurred a few times in the past: |
1e44e2bf |
1417 | |
f1387719 |
1418 | warn <<EOM unless (-s $self->catfile($self->{PERL_SRC},'cflags') or $Is_VMS && -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt') or $Is_Mac); |
1419 | You cannot build extensions below the perl source tree after executing |
1420 | a 'make clean' in the perl source tree. |
1e44e2bf |
1421 | |
f1387719 |
1422 | To rebuild extensions distributed with the perl source you should |
1423 | simply Configure (to include those extensions) and then build perl as |
1424 | normal. After installing perl the source tree can be deleted. It is |
1425 | not needed for building extensions by running 'perl Makefile.PL' |
1426 | usually without extra arguments. |
1e44e2bf |
1427 | |
f1387719 |
1428 | It is recommended that you unpack and build additional extensions away |
1429 | from the perl source tree. |
1430 | EOM |
1431 | } else { |
1432 | # we should also consider $ENV{PERL5LIB} here |
1433 | $self->{PERL_LIB} ||= $Config::Config{privlibexp}; |
1434 | $self->{PERL_ARCHLIB} ||= $Config::Config{archlibexp}; |
1435 | $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now |
1436 | my $perl_h; |
1437 | die <<EOM unless (-f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))); |
1438 | Error: Unable to locate installed Perl libraries or Perl source code. |
f4ae0f5e |
1439 | |
f1387719 |
1440 | It is recommended that you install perl in a standard location before |
1441 | building extensions. You can say: |
1e44e2bf |
1442 | |
f1387719 |
1443 | $^X Makefile.PL PERL_SRC=/path/to/perl/source/directory |
1e44e2bf |
1444 | |
f1387719 |
1445 | if you have not yet installed perl but still want to build this |
1446 | extension now. |
1447 | (You get this message, because MakeMaker could not find "$perl_h") |
1448 | EOM |
f4ae0f5e |
1449 | |
f1387719 |
1450 | # print STDOUT "Using header files found in $self->{PERL_INC}\n" |
1451 | # if $Verbose && $self->needs_linking(); |
1e44e2bf |
1452 | |
f1387719 |
1453 | } |
1e44e2bf |
1454 | |
f1387719 |
1455 | # We get SITELIBEXP and SITEARCHEXP directly via |
1456 | # Get_from_Config. When we are running standard modules, these |
1457 | # won't matter, we will set INSTALLDIRS to "perl". Otherwise we |
1458 | # set it to "site". I prefer that INSTALLDIRS be set from outside |
1459 | # MakeMaker. |
1460 | $self->{INSTALLDIRS} ||= "site"; |
1e44e2bf |
1461 | |
f1387719 |
1462 | # INST_LIB typically pre-set if building an extension after |
1463 | # perl has been built and installed. Setting INST_LIB allows |
1464 | # you to build directly into, say $Config::Config{privlibexp}. |
1465 | unless ($self->{INST_LIB}){ |
1e44e2bf |
1466 | |
1e44e2bf |
1467 | |
f1387719 |
1468 | ##### XXXXX We have to change this nonsense |
1e44e2bf |
1469 | |
f1387719 |
1470 | if (defined $self->{PERL_SRC} and $self->{INSTALLDIRS} eq "perl") { |
1471 | $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB}; |
1472 | } else { |
1473 | $self->{INST_LIB} = $self->catdir($self->curdir,"blib","lib"); |
1474 | } |
1475 | } |
1476 | $self->{INST_ARCHLIB} ||= $self->catdir($self->curdir,"blib","arch"); |
1477 | $self->{INST_BIN} ||= $self->catdir($self->curdir,'blib','bin'); |
1e44e2bf |
1478 | |
f1387719 |
1479 | # INST_EXE is deprecated, should go away March '97 |
1480 | $self->{INST_EXE} ||= $self->catdir($self->curdir,'blib','script'); |
1481 | $self->{INST_SCRIPT} ||= $self->catdir($self->curdir,'blib','script'); |
1e44e2bf |
1482 | |
f1387719 |
1483 | # The user who requests an installation directory explicitly |
1484 | # should not have to tell us a architecture installation directory |
1485 | # as well We look if a directory exists that is named after the |
1486 | # architecture. If not we take it as a sign that it should be the |
1487 | # same as the requested installation directory. Otherwise we take |
1488 | # the found one. |
1489 | # We do the same thing twice: for privlib/archlib and for sitelib/sitearch |
1490 | my($libpair); |
1491 | for $libpair ({l=>"privlib", a=>"archlib"}, {l=>"sitelib", a=>"sitearch"}) { |
1492 | my $lib = "install$libpair->{l}"; |
1493 | my $Lib = uc $lib; |
1494 | my $Arch = uc "install$libpair->{a}"; |
1495 | if( $self->{$Lib} && ! $self->{$Arch} ){ |
1496 | my($ilib) = $Config{$lib}; |
1497 | $ilib = VMS::Filespec::unixify($ilib) if $Is_VMS; |
1e44e2bf |
1498 | |
f1387719 |
1499 | $self->prefixify($Arch,$ilib,$self->{$Lib}); |
1500 | |
1501 | unless (-d $self->{$Arch}) { |
1502 | print STDOUT "Directory $self->{$Arch} not found, thusly\n" if $Verbose; |
1503 | $self->{$Arch} = $self->{$Lib}; |
1504 | } |
1505 | print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose; |
1506 | } |
1e44e2bf |
1507 | } |
f4ae0f5e |
1508 | |
f1387719 |
1509 | # we have to look at the relation between $Config{prefix} and the |
1510 | # requested values. We're going to set the $Config{prefix} part of |
1511 | # all the installation path variables to literally $(PREFIX), so |
1512 | # the user can still say make PREFIX=foo |
1513 | my($prefix) = $Config{'prefix'}; |
1514 | $prefix = VMS::Filespec::unixify($prefix) if $Is_VMS; |
1515 | unless ($self->{PREFIX}){ |
1516 | $self->{PREFIX} = $prefix; |
1517 | } |
1518 | my($install_variable); |
1519 | for $install_variable (qw/ |
1e44e2bf |
1520 | |
f1387719 |
1521 | INSTALLPRIVLIB INSTALLARCHLIB INSTALLBIN |
1522 | INSTALLMAN1DIR INSTALLMAN3DIR INSTALLSCRIPT |
1523 | INSTALLSITELIB INSTALLSITEARCH |
1e44e2bf |
1524 | |
f1387719 |
1525 | /) { |
1526 | $self->prefixify($install_variable,$prefix,q[$(PREFIX)]); |
1527 | } |
1e44e2bf |
1528 | |
1529 | |
f1387719 |
1530 | # Now we head at the manpages. Maybe they DO NOT want manpages |
1531 | # installed |
1532 | $self->{INSTALLMAN1DIR} = $Config::Config{installman1dir} |
1533 | unless defined $self->{INSTALLMAN1DIR}; |
1534 | unless (defined $self->{INST_MAN1DIR}){ |
1535 | if ($self->{INSTALLMAN1DIR} =~ /^(none|\s*)$/){ |
1536 | $self->{INST_MAN1DIR} = $self->{INSTALLMAN1DIR}; |
1537 | } else { |
1538 | $self->{INST_MAN1DIR} = $self->catdir($self->curdir,'blib','man1'); |
1539 | } |
1540 | } |
1541 | $self->{MAN1EXT} ||= $Config::Config{man1ext}; |
1e44e2bf |
1542 | |
f1387719 |
1543 | $self->{INSTALLMAN3DIR} = $Config::Config{installman3dir} |
1544 | unless defined $self->{INSTALLMAN3DIR}; |
1545 | unless (defined $self->{INST_MAN3DIR}){ |
1546 | if ($self->{INSTALLMAN3DIR} =~ /^(none|\s*)$/){ |
1547 | $self->{INST_MAN3DIR} = $self->{INSTALLMAN3DIR}; |
1548 | } else { |
1549 | $self->{INST_MAN3DIR} = $self->catdir($self->curdir,'blib','man3'); |
1550 | } |
1e44e2bf |
1551 | } |
f1387719 |
1552 | $self->{MAN3EXT} ||= $Config::Config{man3ext}; |
1553 | |
1554 | |
1555 | # Get some stuff out of %Config if we haven't yet done so |
1556 | print STDOUT "CONFIG must be an array ref\n" |
1557 | if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY'); |
1558 | $self->{CONFIG} = [] unless (ref $self->{CONFIG}); |
1559 | push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config); |
1560 | push(@{$self->{CONFIG}}, 'shellflags') if $Config::Config{shellflags}; |
1561 | my(%once_only,$m); |
1562 | foreach $m (@{$self->{CONFIG}}){ |
1563 | next if $once_only{$m}; |
1564 | print STDOUT "CONFIG key '$m' does not exist in Config.pm\n" |
1565 | unless exists $Config::Config{$m}; |
1566 | $self->{uc $m} ||= $Config::Config{$m}; |
1567 | $once_only{$m} = 1; |
1e44e2bf |
1568 | } |
1e44e2bf |
1569 | |
f1387719 |
1570 | # This is too dangerous: |
1571 | # if ($^O eq "next") { |
1572 | # $self->{AR} = "libtool"; |
1573 | # $self->{AR_STATIC_ARGS} = "-o"; |
1574 | # } |
1575 | # But I leave it as a placeholder |
1e44e2bf |
1576 | |
f1387719 |
1577 | $self->{AR_STATIC_ARGS} ||= "cr"; |
1e44e2bf |
1578 | |
f1387719 |
1579 | # These should never be needed |
1580 | $self->{LD} ||= 'ld'; |
1581 | $self->{OBJ_EXT} ||= '.o'; |
1582 | $self->{LIB_EXT} ||= '.a'; |
1583 | |
1584 | $self->{MAP_TARGET} ||= "perl"; |
1585 | |
1586 | $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}"; |
1587 | |
1588 | # make a simple check if we find Exporter |
1589 | warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory |
1590 | (Exporter.pm not found)" |
1591 | unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") || |
1592 | $self->{NAME} eq "ExtUtils::MakeMaker"; |
1e44e2bf |
1593 | |
f1387719 |
1594 | # Determine VERSION and VERSION_FROM |
1595 | ($self->{DISTNAME}=$self->{NAME}) =~ s#(::)#-#g unless $self->{DISTNAME}; |
1596 | if ($self->{VERSION_FROM}){ |
1597 | $self->{VERSION} = $self->parse_version($self->{VERSION_FROM}) or |
1598 | Carp::carp "WARNING: Setting VERSION via file '$self->{VERSION_FROM}' failed\n" |
1e44e2bf |
1599 | } |
f1387719 |
1600 | |
1601 | # strip blanks |
1602 | if ($self->{VERSION}) { |
1603 | $self->{VERSION} =~ s/^\s+//; |
1604 | $self->{VERSION} =~ s/\s+$//; |
1e44e2bf |
1605 | } |
1e44e2bf |
1606 | |
f1387719 |
1607 | $self->{VERSION} ||= "0.10"; |
1608 | ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g; |
1e44e2bf |
1609 | |
1610 | |
f1387719 |
1611 | # Graham Barr and Paul Marquess had some ideas how to ensure |
1612 | # version compatibility between the *.pm file and the |
1613 | # corresponding *.xs file. The bottomline was, that we need an |
1614 | # XS_VERSION macro that defaults to VERSION: |
1615 | $self->{XS_VERSION} ||= $self->{VERSION}; |
1e44e2bf |
1616 | |
f1387719 |
1617 | # --- Initialize Perl Binary Locations |
1618 | |
1619 | # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL' |
1620 | # will be working versions of perl 5. miniperl has priority over perl |
1621 | # for PERL to ensure that $(PERL) is usable while building ./ext/* |
1622 | my ($component,@defpath); |
1623 | foreach $component ($self->{PERL_SRC}, $self->path(), $Config::Config{binexp}) { |
1624 | push @defpath, $component if defined $component; |
1e44e2bf |
1625 | } |
f1387719 |
1626 | $self->{PERL} = |
1627 | $self->find_perl(5.0, [ $^X, 'miniperl','perl','perl5',"perl$]" ], |
1628 | \@defpath, $Verbose ) unless ($self->{PERL}); |
1629 | # don't check if perl is executable, maybe they have decided to |
1630 | # supply switches with perl |
1631 | |
1632 | # Define 'FULLPERL' to be a non-miniperl (used in test: target) |
1633 | ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/perl/i |
1634 | unless ($self->{FULLPERL}); |
1e44e2bf |
1635 | } |
1636 | |
f1387719 |
1637 | =item init_others |
1e44e2bf |
1638 | |
f1387719 |
1639 | Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH, |
1640 | OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, NOOP, FIRST_MAKEFILE, |
1641 | MAKEFILE, NOECHO, RM_F, RM_RF, TOUCH, CP, MV, CHMOD, UMASK_NULL |
1e44e2bf |
1642 | |
1643 | =cut |
1644 | |
f1387719 |
1645 | sub init_others { # --- Initialize Other Attributes |
1e44e2bf |
1646 | my($self) = shift; |
1e44e2bf |
1647 | |
f1387719 |
1648 | # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS} |
1649 | # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or |
1650 | # undefined. In any case we turn it into an anon array: |
1e44e2bf |
1651 | |
f1387719 |
1652 | # May check $Config{libs} too, thus not empty. |
1653 | $self->{LIBS}=[''] unless $self->{LIBS}; |
f4ae0f5e |
1654 | |
f1387719 |
1655 | $self->{LIBS}=[$self->{LIBS}] if ref \$self->{LIBS} eq SCALAR; |
1656 | $self->{LD_RUN_PATH} = ""; |
1657 | my($libs); |
1658 | foreach $libs ( @{$self->{LIBS}} ){ |
1659 | $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace |
1660 | my(@libs) = $self->extliblist($libs); |
1661 | if ($libs[0] or $libs[1] or $libs[2]){ |
1662 | # LD_RUN_PATH now computed by ExtUtils::Liblist |
1663 | ($self->{EXTRALIBS}, $self->{BSLOADLIBS}, $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs; |
1664 | last; |
1665 | } |
1666 | } |
f4ae0f5e |
1667 | |
f1387719 |
1668 | if ( $self->{OBJECT} ) { |
1669 | $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g; |
1670 | } else { |
1671 | # init_dirscan should have found out, if we have C files |
1672 | $self->{OBJECT} = ""; |
1673 | $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]}; |
1e44e2bf |
1674 | } |
f1387719 |
1675 | $self->{OBJECT} =~ s/\n+/ \\\n\t/g; |
1676 | $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : ""; |
1677 | $self->{PERLMAINCC} ||= '$(CC)'; |
1678 | $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM}; |
1e44e2bf |
1679 | |
f1387719 |
1680 | # Sanity check: don't define LINKTYPE = dynamic if we're skipping |
1681 | # the 'dynamic' section of MM. We don't have this problem with |
1682 | # 'static', since we either must use it (%Config says we can't |
1683 | # use dynamic loading) or the caller asked for it explicitly. |
1684 | if (!$self->{LINKTYPE}) { |
1685 | $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'} |
1686 | ? 'static' |
1687 | : ($Config::Config{usedl} ? 'dynamic' : 'static'); |
1688 | }; |
1689 | |
1690 | # These get overridden for VMS and maybe some other systems |
1691 | $self->{NOOP} ||= "sh -c true"; |
1692 | $self->{FIRST_MAKEFILE} ||= "Makefile"; |
1693 | $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE}; |
1694 | $self->{MAKE_APERL_FILE} ||= "Makefile.aperl"; |
1695 | $self->{NOECHO} = '@' unless defined $self->{NOECHO}; |
1696 | $self->{RM_F} ||= "rm -f"; |
1697 | $self->{RM_RF} ||= "rm -rf"; |
1698 | $self->{TOUCH} ||= "touch"; |
1699 | $self->{CP} ||= "cp"; |
1700 | $self->{MV} ||= "mv"; |
1701 | $self->{CHMOD} ||= "chmod"; |
1702 | $self->{UMASK_NULL} ||= "umask 0"; |
1e44e2bf |
1703 | } |
1704 | |
f1387719 |
1705 | =item install (o) |
1e44e2bf |
1706 | |
f1387719 |
1707 | Defines the install target. |
1e44e2bf |
1708 | |
1709 | =cut |
1710 | |
f1387719 |
1711 | sub install { |
1712 | my($self, %attribs) = @_; |
1e44e2bf |
1713 | my(@m); |
a5f75d66 |
1714 | |
f1387719 |
1715 | push @m, q{ |
1716 | install :: all pure_install doc_install |
1e44e2bf |
1717 | |
f1387719 |
1718 | install_perl :: all pure_perl_install doc_perl_install |
1e44e2bf |
1719 | |
f1387719 |
1720 | install_site :: all pure_site_install doc_site_install |
1e44e2bf |
1721 | |
f1387719 |
1722 | install_ :: install_site |
1723 | @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site |
1e44e2bf |
1724 | |
f1387719 |
1725 | pure_install :: pure_$(INSTALLDIRS)_install |
1e44e2bf |
1726 | |
f1387719 |
1727 | doc_install :: doc_$(INSTALLDIRS)_install |
1728 | }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod |
1e44e2bf |
1729 | |
f1387719 |
1730 | pure__install : pure_site_install |
1731 | @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site |
1e44e2bf |
1732 | |
f1387719 |
1733 | doc__install : doc_site_install |
1734 | @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site |
1e44e2bf |
1735 | |
f1387719 |
1736 | pure_perl_install :: |
1737 | }.$self->{NOECHO}.q{$(MOD_INSTALL) \ |
1738 | read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \ |
1739 | write }.$self->catfile('$(INSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \ |
1740 | $(INST_LIB) $(INSTALLPRIVLIB) \ |
1741 | $(INST_ARCHLIB) $(INSTALLARCHLIB) \ |
1742 | $(INST_BIN) $(INSTALLBIN) \ |
1743 | $(INST_SCRIPT) $(INSTALLSCRIPT) \ |
1744 | $(INST_MAN1DIR) $(INSTALLMAN1DIR) \ |
1745 | $(INST_MAN3DIR) $(INSTALLMAN3DIR) |
1746 | }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \ |
1747 | }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{ |
1e44e2bf |
1748 | |
1e44e2bf |
1749 | |
f1387719 |
1750 | pure_site_install :: |
1751 | }.$self->{NOECHO}.q{$(MOD_INSTALL) \ |
1752 | read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \ |
1753 | write }.$self->catfile('$(INSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \ |
1754 | $(INST_LIB) $(INSTALLSITELIB) \ |
1755 | $(INST_ARCHLIB) $(INSTALLSITEARCH) \ |
1756 | $(INST_BIN) $(INSTALLBIN) \ |
1757 | $(INST_SCRIPT) $(INSTALLSCRIPT) \ |
1758 | $(INST_MAN1DIR) $(INSTALLMAN1DIR) \ |
1759 | $(INST_MAN3DIR) $(INSTALLMAN3DIR) |
1760 | }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \ |
1761 | }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{ |
1e44e2bf |
1762 | |
f1387719 |
1763 | doc_perl_install :: |
1764 | }.$self->{NOECHO}.q{$(DOC_INSTALL) \ |
1765 | "$(NAME)" \ |
1766 | "installed into" "$(INSTALLPRIVLIB)" \ |
1767 | LINKTYPE "$(LINKTYPE)" \ |
1768 | VERSION "$(VERSION)" \ |
1769 | EXE_FILES "$(EXE_FILES)" \ |
1770 | >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{ |
1e44e2bf |
1771 | |
f1387719 |
1772 | doc_site_install :: |
1773 | }.$self->{NOECHO}.q{$(DOC_INSTALL) \ |
1774 | "Module $(NAME)" \ |
1775 | "installed into" "$(INSTALLSITELIB)" \ |
1776 | LINKTYPE "$(LINKTYPE)" \ |
1777 | VERSION "$(VERSION)" \ |
1778 | EXE_FILES "$(EXE_FILES)" \ |
1779 | >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{ |
1e44e2bf |
1780 | |
f1387719 |
1781 | }; |
1e44e2bf |
1782 | |
f1387719 |
1783 | push @m, q{ |
1784 | uninstall :: uninstall_from_$(INSTALLDIRS)dirs |
f4ae0f5e |
1785 | |
f1387719 |
1786 | uninstall_from_perldirs :: |
1787 | }.$self->{NOECHO}. |
1788 | q{$(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ |
1e44e2bf |
1789 | |
f1387719 |
1790 | uninstall_from_sitedirs :: |
1791 | }.$self->{NOECHO}. |
1792 | q{$(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ |
1793 | }; |
1e44e2bf |
1794 | |
f1387719 |
1795 | join("",@m); |
1796 | } |
1e44e2bf |
1797 | |
f1387719 |
1798 | =item installbin (o) |
1e44e2bf |
1799 | |
f1387719 |
1800 | Defines targets to install EXE_FILES. |
1e44e2bf |
1801 | |
f1387719 |
1802 | =cut |
1e44e2bf |
1803 | |
f1387719 |
1804 | sub installbin { |
1805 | my($self) = shift; |
1806 | return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY"; |
1807 | return "" unless @{$self->{EXE_FILES}}; |
1808 | my(@m, $from, $to, %fromto, @to); |
1809 | push @m, $self->dir_target(qw[$(INST_SCRIPT)]); |
1810 | for $from (@{$self->{EXE_FILES}}) { |
1811 | my($path)= $self->catfile('$(INST_SCRIPT)', basename($from)); |
1812 | local($_) = $path; # for backwards compatibility |
1813 | $to = $self->libscan($path); |
1814 | print "libscan($from) => '$to'\n" if ($Verbose >=2); |
1815 | $fromto{$from}=$to; |
1816 | } |
1817 | @to = values %fromto; |
1818 | push(@m, " |
1819 | EXE_FILES = @{$self->{EXE_FILES}} |
1e44e2bf |
1820 | |
f1387719 |
1821 | all :: @to |
1e44e2bf |
1822 | |
f1387719 |
1823 | realclean :: |
1824 | $self->{RM_F} @to |
1825 | "); |
1e44e2bf |
1826 | |
f1387719 |
1827 | while (($from,$to) = each %fromto) { |
1828 | last unless defined $from; |
1829 | my $todir = dirname($to); |
1830 | push @m, " |
1831 | $to: $from $self->{MAKEFILE} $todir/.exists |
1832 | $self->{NOECHO}$self->{RM_F} $to |
1833 | $self->{CP} $from $to |
1834 | "; |
1e44e2bf |
1835 | } |
f1387719 |
1836 | join "", @m; |
1837 | } |
1e44e2bf |
1838 | |
f1387719 |
1839 | =item libscan (o) |
1e44e2bf |
1840 | |
f1387719 |
1841 | Takes a path to a file that is found by init_dirscan and returns false |
1842 | if we don't want to include this file in the library. Mainly used to |
1843 | exclude RCS, CVS, and SCCS directories from installation. |
1e44e2bf |
1844 | |
f1387719 |
1845 | =cut |
1e44e2bf |
1846 | |
f1387719 |
1847 | # '; |
1e44e2bf |
1848 | |
f1387719 |
1849 | sub libscan { |
1850 | my($self,$path) = @_; |
1851 | return '' if $path =~ m:\b(RCS|CVS|SCCS)\b: ; |
1852 | $path; |
1e44e2bf |
1853 | } |
1854 | |
f4ae0f5e |
1855 | =item linkext (o) |
1e44e2bf |
1856 | |
f4ae0f5e |
1857 | Defines the linkext target which in turn defines the LINKTYPE. |
1e44e2bf |
1858 | |
1859 | =cut |
1860 | |
1861 | sub linkext { |
1862 | my($self, %attribs) = @_; |
1e44e2bf |
1863 | # LINKTYPE => static or dynamic or '' |
1864 | my($linktype) = defined $attribs{LINKTYPE} ? |
1865 | $attribs{LINKTYPE} : '$(LINKTYPE)'; |
1866 | " |
1867 | linkext :: $linktype |
f4ae0f5e |
1868 | $self->{NOECHO}\$(NOOP) |
1e44e2bf |
1869 | "; |
1870 | } |
1871 | |
f1387719 |
1872 | =item lsdir |
1e44e2bf |
1873 | |
f1387719 |
1874 | Takes as arguments a directory name and a regular expression. Returns |
1875 | all entries in the directory that match the regular expression. |
1e44e2bf |
1876 | |
1877 | =cut |
1878 | |
f1387719 |
1879 | sub lsdir { |
1880 | my($self) = shift; |
1881 | my($dir, $regex) = @_; |
1882 | my(@ls); |
1883 | my $dh = new DirHandle; |
1884 | $dh->open($dir || ".") or return (); |
1885 | @ls = $dh->read; |
1886 | $dh->close; |
1887 | @ls = grep(/$regex/, @ls) if $regex; |
1888 | @ls; |
1889 | } |
1890 | |
1891 | =item macro (o) |
1892 | |
1893 | Simple subroutine to insert the macros defined by the macro attribute |
1894 | into the Makefile. |
1895 | |
1896 | =cut |
1897 | |
1898 | sub macro { |
1e44e2bf |
1899 | my($self,%attribs) = @_; |
f1387719 |
1900 | my(@m,$key,$val); |
1901 | while (($key,$val) = each %attribs){ |
1902 | last unless defined $key; |
1903 | push @m, "$key = $val\n"; |
1e44e2bf |
1904 | } |
f1387719 |
1905 | join "", @m; |
1906 | } |
1e44e2bf |
1907 | |
f1387719 |
1908 | =item makeaperl (o) |
1e44e2bf |
1909 | |
f1387719 |
1910 | Called by staticmake. Defines how to write the Makefile to produce a |
1911 | static new perl. |
1912 | |
1913 | =cut |
1914 | |
1915 | sub makeaperl { |
1916 | my($self, %attribs) = @_; |
1917 | my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) = |
1918 | @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)}; |
1e44e2bf |
1919 | my(@m); |
f1387719 |
1920 | push @m, " |
1921 | # --- MakeMaker makeaperl section --- |
1922 | MAP_TARGET = $target |
1923 | FULLPERL = $self->{FULLPERL} |
1924 | "; |
1925 | return join '', @m if $self->{PARENT}; |
1e44e2bf |
1926 | |
f1387719 |
1927 | my($dir) = join ":", @{$self->{DIR}}; |
1e44e2bf |
1928 | |
f1387719 |
1929 | unless ($self->{MAKEAPERL}) { |
1930 | push @m, q{ |
1931 | $(MAP_TARGET) :: static $(MAKE_APERL_FILE) |
1932 | $(MAKE) -f $(MAKE_APERL_FILE) $@ |
1e44e2bf |
1933 | |
f1387719 |
1934 | $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) |
1935 | }.$self->{NOECHO}.q{echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) |
1936 | }.$self->{NOECHO}.q{$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \ |
1937 | Makefile.PL DIR=}, $dir, q{ \ |
1938 | MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ |
1939 | MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=}; |
1e44e2bf |
1940 | |
f1387719 |
1941 | foreach (@ARGV){ |
1942 | if( /\s/ ){ |
1943 | s/=(.*)/='$1'/; |
1944 | } |
1945 | push @m, " \\\n\t\t$_"; |
1946 | } |
1947 | # push @m, map( " \\\n\t\t$_", @ARGV ); |
1948 | push @m, "\n"; |
1e44e2bf |
1949 | |
f1387719 |
1950 | return join '', @m; |
1951 | } |
1e44e2bf |
1952 | |
1e44e2bf |
1953 | |
1e44e2bf |
1954 | |
f1387719 |
1955 | my($cccmd, $linkcmd, $lperl); |
1e44e2bf |
1956 | |
1e44e2bf |
1957 | |
f1387719 |
1958 | $cccmd = $self->const_cccmd($libperl); |
1959 | $cccmd =~ s/^CCCMD\s*=\s*//; |
1960 | $cccmd =~ s/\$\(INC\)/ -I$self->{PERL_INC} /; |
1961 | $cccmd .= " $Config::Config{cccdlflags}" if ($Config::Config{d_shrplib}); |
1962 | $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/; |
1e44e2bf |
1963 | |
f1387719 |
1964 | # The front matter of the linkcommand... |
1965 | $linkcmd = join ' ', "\$(CC)", |
1966 | grep($_, @Config{qw(large split ldflags ccdlflags)}); |
1967 | $linkcmd =~ s/\s+/ /g; |
1e44e2bf |
1968 | |
f1387719 |
1969 | # Which *.a files could we make use of... |
1970 | local(%static); |
1971 | require File::Find; |
1972 | File::Find::find(sub { |
1973 | return unless m/\Q$self->{LIB_EXT}\E$/; |
1974 | return if m/^libperl/; |
1e44e2bf |
1975 | |
f1387719 |
1976 | if( exists $self->{INCLUDE_EXT} ){ |
1977 | my $found = 0; |
1978 | my $incl; |
1979 | my $xx; |
1980 | |
1981 | ($xx = $File::Find::name) =~ s,.*?/auto/,,; |
1982 | $xx =~ s,/?$_,,; |
1983 | $xx =~ s,/,::,g; |
1984 | |
1985 | # Throw away anything not explicitly marked for inclusion. |
1986 | # DynaLoader is implied. |
1987 | foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){ |
1988 | if( $xx eq $incl ){ |
1989 | $found++; |
1990 | last; |
1991 | } |
1992 | } |
1993 | return unless $found; |
1994 | } |
1995 | elsif( exists $self->{EXCLUDE_EXT} ){ |
1996 | my $excl; |
1997 | my $xx; |
1e44e2bf |
1998 | |
f1387719 |
1999 | ($xx = $File::Find::name) =~ s,.*?/auto/,,; |
2000 | $xx =~ s,/?$_,,; |
2001 | $xx =~ s,/,::,g; |
1e44e2bf |
2002 | |
f1387719 |
2003 | # Throw away anything explicitly marked for exclusion |
2004 | foreach $excl (@{$self->{EXCLUDE_EXT}}){ |
2005 | return if( $xx eq $excl ); |
2006 | } |
2007 | } |
2008 | |
2009 | # don't include the installed version of this extension. I |
2010 | # leave this line here, although it is not necessary anymore: |
2011 | # I patched minimod.PL instead, so that Miniperl.pm won't |
2012 | # enclude duplicates |
2013 | |
2014 | # Once the patch to minimod.PL is in the distribution, I can |
2015 | # drop it |
2016 | return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}$:; |
2017 | use Cwd 'cwd'; |
2018 | $static{cwd() . "/" . $_}++; |
2019 | }, grep( -d $_, @{$searchdirs || []}) ); |
2020 | |
2021 | # We trust that what has been handed in as argument, will be buildable |
2022 | $static = [] unless $static; |
2023 | @static{@{$static}} = (1) x @{$static}; |
2024 | |
2025 | $extra = [] unless $extra && ref $extra eq 'ARRAY'; |
2026 | for (sort keys %static) { |
2027 | next unless /\Q$self->{LIB_EXT}\E$/; |
2028 | $_ = dirname($_) . "/extralibs.ld"; |
2029 | push @$extra, $_; |
1e44e2bf |
2030 | } |
1e44e2bf |
2031 | |
f1387719 |
2032 | grep(s/^/-I/, @{$perlinc || []}); |
1e44e2bf |
2033 | |
f1387719 |
2034 | $target = "perl" unless $target; |
2035 | $tmp = "." unless $tmp; |
1e44e2bf |
2036 | |
f1387719 |
2037 | # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we |
2038 | # regenerate the Makefiles, MAP_STATIC and the dependencies for |
2039 | # extralibs.all are computed correctly |
2040 | push @m, " |
2041 | MAP_LINKCMD = $linkcmd |
2042 | MAP_PERLINC = @{$perlinc || []} |
2043 | MAP_STATIC = ", |
2044 | join(" \\\n\t", reverse sort keys %static), " |
1e44e2bf |
2045 | |
f1387719 |
2046 | MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib} |
2047 | "; |
2048 | |
2049 | if (defined $libperl) { |
2050 | ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/; |
2051 | } |
2052 | unless ($libperl && -f $lperl) { # Ilya's code... |
2053 | my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE"; |
2054 | $libperl ||= "libperl$self->{LIB_EXT}"; |
2055 | $libperl = "$dir/$libperl"; |
2056 | $lperl ||= "libperl$self->{LIB_EXT}"; |
2057 | $lperl = "$dir/$lperl"; |
2058 | print STDOUT "Warning: $libperl not found |
2059 | If you're going to build a static perl binary, make sure perl is installed |
2060 | otherwise ignore this warning\n" |
2061 | unless (-f $lperl || defined($self->{PERL_SRC})); |
2062 | } |
1e44e2bf |
2063 | |
f1387719 |
2064 | push @m, " |
2065 | MAP_LIBPERL = $libperl |
2066 | "; |
1e44e2bf |
2067 | |
f1387719 |
2068 | push @m, " |
2069 | \$(INST_ARCHAUTODIR)/extralibs.all: \$(INST_ARCHAUTODIR)/.exists ".join(" \\\n\t", @$extra)." |
2070 | $self->{NOECHO}$self->{RM_F} \$\@ |
2071 | $self->{NOECHO}\$(TOUCH) \$\@ |
2072 | "; |
1e44e2bf |
2073 | |
f1387719 |
2074 | my $catfile; |
2075 | foreach $catfile (@$extra){ |
2076 | push @m, "\tcat $catfile >> \$\@\n"; |
1e44e2bf |
2077 | } |
1e44e2bf |
2078 | |
f1387719 |
2079 | push @m, " |
2080 | \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all |
2081 | \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS) |
2082 | $self->{NOECHO}echo 'To install the new \"\$(MAP_TARGET)\" binary, call' |
2083 | $self->{NOECHO}echo ' make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)' |
2084 | $self->{NOECHO}echo 'To remove the intermediate files say' |
2085 | $self->{NOECHO}echo ' make -f $makefilename map_clean' |
1e44e2bf |
2086 | |
f1387719 |
2087 | $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c |
2088 | "; |
2089 | push @m, "\tcd $tmp && $cccmd -I\$(PERL_INC) perlmain.c\n"; |
1e44e2bf |
2090 | |
f1387719 |
2091 | push @m, qq{ |
2092 | $tmp/perlmain.c: $makefilename}, q{ |
2093 | }.$self->{NOECHO}.q{echo Writing $@ |
2094 | }.$self->{NOECHO}.q{$(PERL) $(MAP_PERLINC) -e 'use ExtUtils::Miniperl; \\ |
2095 | writemain(grep s#.*/auto/##, qw|$(MAP_STATIC)|)' > $@.tmp && mv $@.tmp $@ |
1e44e2bf |
2096 | |
f1387719 |
2097 | }; |
1e44e2bf |
2098 | |
f1387719 |
2099 | push @m, q{ |
2100 | doc_inst_perl: |
2101 | }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod |
2102 | }.$self->{NOECHO}.q{$(DOC_INSTALL) \ |
2103 | "Perl binary $(MAP_TARGET)" \ |
2104 | MAP_STATIC "$(MAP_STATIC)" \ |
2105 | MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \ |
2106 | MAP_LIBPERL "$(MAP_LIBPERL)" \ |
2107 | >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{ |
1e44e2bf |
2108 | |
f1387719 |
2109 | }; |
1e44e2bf |
2110 | |
f1387719 |
2111 | push @m, q{ |
2112 | inst_perl: pure_inst_perl doc_inst_perl |
1e44e2bf |
2113 | |
f1387719 |
2114 | pure_inst_perl: $(MAP_TARGET) |
2115 | }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(INSTALLBIN)','$(MAP_TARGET)').q{ |
1e44e2bf |
2116 | |
f1387719 |
2117 | clean :: map_clean |
2118 | |
2119 | map_clean : |
2120 | }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all |
2121 | }; |
2122 | |
2123 | join '', @m; |
1e44e2bf |
2124 | } |
2125 | |
f1387719 |
2126 | =item makefile (o) |
1e44e2bf |
2127 | |
f1387719 |
2128 | Defines how to rewrite the Makefile. |
1e44e2bf |
2129 | |
2130 | =cut |
2131 | |
f1387719 |
2132 | sub makefile { |
2133 | my($self) = shift; |
2134 | my @m; |
2135 | # We do not know what target was originally specified so we |
2136 | # must force a manual rerun to be sure. But as it should only |
2137 | # happen very rarely it is not a significant problem. |
2138 | push @m, ' |
2139 | $(OBJECT) : $(FIRST_MAKEFILE) |
2140 | ' if $self->{OBJECT}; |
1e44e2bf |
2141 | |
f1387719 |
2142 | push @m, q{ |
2143 | # We take a very conservative approach here, but it\'s worth it. |
2144 | # We move Makefile to Makefile.old here to avoid gnu make looping. |
2145 | }.$self->{MAKEFILE}.q{ : Makefile.PL $(CONFIGDEP) |
2146 | }.$self->{NOECHO}.q{echo "Makefile out-of-date with respect to $?" |
2147 | }.$self->{NOECHO}.q{echo "Cleaning current config before rebuilding Makefile..." |
2148 | -}.$self->{NOECHO}.q{mv }."$self->{MAKEFILE} $self->{MAKEFILE}.old".q{ |
2149 | -$(MAKE) -f }.$self->{MAKEFILE}.q{.old clean >/dev/null 2>&1 || true |
2150 | $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL }.join(" ",map(qq["$_"],@ARGV)).q{ |
2151 | }.$self->{NOECHO}.q{echo ">>> Your Makefile has been rebuilt. <<<" |
2152 | }.$self->{NOECHO}.q{echo ">>> Please rerun the make command. <<<"; false |
1e44e2bf |
2153 | |
f1387719 |
2154 | # To change behavior to :: would be nice, but would break Tk b9.02 |
2155 | # so you find such a warning below the dist target. |
2156 | #}.$self->{MAKEFILE}.q{ :: $(VERSION_FROM) |
2157 | # }.$self->{NOECHO}.q{echo "Warning: Makefile possibly out of date with $(VERSION_FROM)" |
1e44e2bf |
2158 | }; |
2159 | |
f1387719 |
2160 | join "", @m; |
1e44e2bf |
2161 | } |
2162 | |
f4ae0f5e |
2163 | =item manifypods (o) |
1e44e2bf |
2164 | |
f4ae0f5e |
2165 | Defines targets and routines to translate the pods into manpages and |
2166 | put them into the INST_* directories. |
1e44e2bf |
2167 | |
2168 | =cut |
2169 | |
2170 | sub manifypods { |
2171 | my($self, %attribs) = @_; |
f1387719 |
2172 | return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n" unless %{$self->{MAN3PODS}} or %{$self->{MAN1PODS}}; |
1e44e2bf |
2173 | my($dist); |
2174 | my($pod2man_exe); |
2175 | if (defined $self->{PERL_SRC}) { |
2176 | $pod2man_exe = $self->catfile($self->{PERL_SRC},'pod','pod2man'); |
2177 | } else { |
f1387719 |
2178 | $pod2man_exe = $self->catfile($Config{scriptdirexp},'pod2man'); |
1e44e2bf |
2179 | } |
2180 | unless ($self->perl_script($pod2man_exe)) { |
2181 | # No pod2man but some MAN3PODS to be installed |
2182 | print <<END; |
2183 | |
2184 | Warning: I could not locate your pod2man program. Please make sure, |
2185 | your pod2man program is in your PATH before you execute 'make' |
2186 | |
2187 | END |
2188 | $pod2man_exe = "-S pod2man"; |
2189 | } |
2190 | my(@m); |
2191 | push @m, |
2192 | qq[POD2MAN_EXE = $pod2man_exe\n], |
2193 | q[POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \\ |
2194 | -e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "].$self->{MAKEFILE}.q[";' \\ |
2195 | -e 'print "Manifying $$m{$$_}\n";' \\ |
f1387719 |
2196 | -e 'system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2MAN_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\ |
1e44e2bf |
2197 | -e 'chmod 0644, $$m{$$_} or warn "chmod 644 $$m{$$_}: $$!\n";}' |
2198 | ]; |
2199 | push @m, "\nmanifypods : "; |
2200 | push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}}; |
f1387719 |
2201 | |
2202 | push(@m,"\n"); |
2203 | if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) { |
2204 | push @m, "\t$self->{NOECHO}\$(POD2MAN) \\\n\t"; |
2205 | push @m, join " \\\n\t", %{$self->{MAN1PODS}}, %{$self->{MAN3PODS}}; |
1e44e2bf |
2206 | } |
f1387719 |
2207 | join('', @m); |
1e44e2bf |
2208 | } |
2209 | |
f1387719 |
2210 | =item maybe_command |
1e44e2bf |
2211 | |
f1387719 |
2212 | Returns true, if the argument is likely to be a command. |
1e44e2bf |
2213 | |
2214 | =cut |
2215 | |
f1387719 |
2216 | sub maybe_command { |
2217 | my($self,$file) = @_; |
2218 | return $file if -x $file && ! -d $file; |
2219 | return; |
1e44e2bf |
2220 | } |
2221 | |
f1387719 |
2222 | =item maybe_command_in_dirs |
1e44e2bf |
2223 | |
f1387719 |
2224 | method under development. Not yet used. Ask Ilya :-) |
1e44e2bf |
2225 | |
2226 | =cut |
2227 | |
f1387719 |
2228 | sub maybe_command_in_dirs { # $ver is optional argument if looking for perl |
2229 | # Ilya's suggestion. Not yet used, want to understand it first, but at least the code is here |
2230 | my($self, $names, $dirs, $trace, $ver) = @_; |
2231 | my($name, $dir); |
2232 | foreach $dir (@$dirs){ |
2233 | next unless defined $dir; # $self->{PERL_SRC} may be undefined |
2234 | foreach $name (@$names){ |
2235 | my($abs,$tryabs); |
2236 | if ($self->file_name_is_absolute($name)) { # /foo/bar |
2237 | $abs = $name; |
2238 | } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # bar |
2239 | $abs = $self->catfile($dir, $name); |
2240 | } else { # foo/bar |
2241 | $abs = $self->catfile($self->curdir, $name); |
2242 | } |
2243 | print "Checking $abs for $name\n" if ($trace >= 2); |
2244 | next unless $tryabs = $self->maybe_command($abs); |
2245 | print "Substituting $tryabs instead of $abs\n" |
2246 | if ($trace >= 2 and $tryabs ne $abs); |
2247 | $abs = $tryabs; |
2248 | if (defined $ver) { |
2249 | print "Executing $abs\n" if ($trace >= 2); |
2250 | if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) { |
2251 | print "Using PERL=$abs\n" if $trace; |
2252 | return $abs; |
2253 | } |
2254 | } else { # Do not look for perl |
2255 | return $abs; |
2256 | } |
2257 | } |
1e44e2bf |
2258 | } |
1e44e2bf |
2259 | } |
2260 | |
f1387719 |
2261 | =item needs_linking (o) |
1e44e2bf |
2262 | |
f1387719 |
2263 | Does this module need linking? Looks into subdirectory objects (see |
2264 | also has_link_code()) |
1e44e2bf |
2265 | |
2266 | =cut |
2267 | |
f1387719 |
2268 | sub needs_linking { |
2269 | my($self) = shift; |
2270 | my($child,$caller); |
2271 | $caller = (caller(0))[3]; |
2272 | Carp::confess("Needs_linking called too early") if $caller =~ /^ExtUtils::MakeMaker::/; |
2273 | return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING}; |
2274 | if ($self->has_link_code or $self->{MAKEAPERL}){ |
2275 | $self->{NEEDS_LINKING} = 1; |
2276 | return 1; |
1e44e2bf |
2277 | } |
f1387719 |
2278 | foreach $child (keys %{$self->{CHILDREN}}) { |
2279 | if ($self->{CHILDREN}->{$child}->needs_linking) { |
2280 | $self->{NEEDS_LINKING} = 1; |
2281 | return 1; |
2282 | } |
1e44e2bf |
2283 | } |
f1387719 |
2284 | return $self->{NEEDS_LINKING} = 0; |
1e44e2bf |
2285 | } |
2286 | |
f1387719 |
2287 | =item nicetext |
1e44e2bf |
2288 | |
f1387719 |
2289 | misnamed method (will have to be changed). The MM_Unix method just |
2290 | returns the argument without further processing. |
2291 | |
2292 | On VMS used to insure that colons marking targets are preceded by |
2293 | space - most Unix Makes don't need this, but it's necessary under VMS |
2294 | to distinguish the target delimiter from a colon appearing as part of |
2295 | a filespec. |
1e44e2bf |
2296 | |
2297 | =cut |
2298 | |
f1387719 |
2299 | sub nicetext { |
2300 | my($self,$text) = @_; |
2301 | $text; |
2302 | } |
1e44e2bf |
2303 | |
f1387719 |
2304 | =item parse_version |
1e44e2bf |
2305 | |
f1387719 |
2306 | parse a file and return what you think is $VERSION in this file set to |
1e44e2bf |
2307 | |
f1387719 |
2308 | =cut |
2309 | |
2310 | sub parse_version { |
2311 | my($self,$parsefile) = @_; |
2312 | my $result; |
2313 | local *FH; |
2314 | local $/ = "\n"; |
2315 | open(FH,$parsefile) or die "Could not open '$parsefile': $!"; |
2316 | my $inpod = 0; |
2317 | while (<FH>) { |
2318 | $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod; |
2319 | next if $inpod; |
2320 | chop; |
2321 | next unless /\$(([\w\:\']*)\bVERSION)\b.*\=/; |
2322 | local $ExtUtils::MakeMaker::module_version_variable = $1; |
2323 | my($thispackage) = $2 || $current_package; |
2324 | $thispackage =~ s/:+$//; |
2325 | my($eval) = "$_;"; |
2326 | eval $eval; |
2327 | die "Could not eval '$eval' in $parsefile: $@" if $@; |
2328 | $result = $ {$ExtUtils::MakeMaker::module_version_variable} || 0; |
2329 | last; |
2330 | } |
2331 | close FH; |
2332 | return $result; |
1e44e2bf |
2333 | } |
2334 | |
1e44e2bf |
2335 | |
f1387719 |
2336 | =item pasthru (o) |
2337 | |
2338 | Defines the string that is passed to recursive make calls in |
2339 | subdirectories. |
1e44e2bf |
2340 | |
2341 | =cut |
2342 | |
f1387719 |
2343 | sub pasthru { |
1e44e2bf |
2344 | my($self) = shift; |
f1387719 |
2345 | my(@m,$key); |
1e44e2bf |
2346 | |
f1387719 |
2347 | my(@pasthru); |
1e44e2bf |
2348 | |
f1387719 |
2349 | foreach $key (qw(LIBPERL_A LINKTYPE PREFIX OPTIMIZE)){ |
2350 | push @pasthru, "$key=\"\$($key)\""; |
2351 | } |
f4ae0f5e |
2352 | |
f1387719 |
2353 | push @m, "\nPASTHRU = ", join ("\\\n\t", @pasthru), "\n"; |
2354 | join "", @m; |
2355 | } |
1e44e2bf |
2356 | |
f1387719 |
2357 | =item path |
f4ae0f5e |
2358 | |
f1387719 |
2359 | Takes no argument, returns the environment variable PATH as an array. |
1e44e2bf |
2360 | |
f1387719 |
2361 | =cut |
2362 | |
2363 | sub path { |
2364 | my($self) = @_; |
2365 | my $path_sep = $Is_OS2 ? ";" : ":"; |
2366 | my $path = $ENV{PATH}; |
2367 | $path =~ s:\\:/:g if $Is_OS2; |
2368 | my @path = split $path_sep, $path; |
1e44e2bf |
2369 | } |
2370 | |
f1387719 |
2371 | =item perl_script |
1e44e2bf |
2372 | |
f1387719 |
2373 | Takes one argument, a file name, and returns the file name, if the |
2374 | argument is likely to be a perl script. On MM_Unix this is true for |
2375 | any ordinary, readable file. |
1e44e2bf |
2376 | |
2377 | =cut |
2378 | |
f1387719 |
2379 | sub perl_script { |
2380 | my($self,$file) = @_; |
2381 | return $file if -r $file && -f _; |
2382 | return; |
1e44e2bf |
2383 | } |
2384 | |
f1387719 |
2385 | =item perldepend (o) |
1e44e2bf |
2386 | |
f1387719 |
2387 | Defines the dependency from all *.h files that come with the perl |
2388 | distribution. |
1e44e2bf |
2389 | |
2390 | =cut |
2391 | |
f1387719 |
2392 | sub perldepend { |
1e44e2bf |
2393 | my($self) = shift; |
f1387719 |
2394 | my(@m); |
2395 | push @m, q{ |
2396 | # Check for unpropogated config.sh changes. Should never happen. |
2397 | # We do NOT just update config.h because that is not sufficient. |
2398 | # An out of date config.h is not fatal but complains loudly! |
2399 | $(PERL_INC)/config.h: $(PERL_SRC)/config.sh |
2400 | -}.$self->{NOECHO}.q{echo "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false |
2401 | |
2402 | $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh |
2403 | }.$self->{NOECHO}.q{echo "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh" |
2404 | cd $(PERL_SRC) && $(MAKE) lib/Config.pm |
2405 | } if $self->{PERL_SRC}; |
2406 | |
2407 | return join "", @m unless $self->needs_linking; |
2408 | |
1e44e2bf |
2409 | push @m, q{ |
f1387719 |
2410 | PERL_HDRS = \ |
2411 | $(PERL_INC)/EXTERN.h $(PERL_INC)/gv.h $(PERL_INC)/pp.h \ |
2412 | $(PERL_INC)/INTERN.h $(PERL_INC)/handy.h $(PERL_INC)/proto.h \ |
2413 | $(PERL_INC)/XSUB.h $(PERL_INC)/hv.h $(PERL_INC)/regcomp.h \ |
2414 | $(PERL_INC)/av.h $(PERL_INC)/keywords.h $(PERL_INC)/regexp.h \ |
2415 | $(PERL_INC)/config.h $(PERL_INC)/mg.h $(PERL_INC)/scope.h \ |
2416 | $(PERL_INC)/cop.h $(PERL_INC)/op.h $(PERL_INC)/sv.h \ |
2417 | $(PERL_INC)/cv.h $(PERL_INC)/opcode.h $(PERL_INC)/unixish.h \ |
2418 | $(PERL_INC)/dosish.h $(PERL_INC)/patchlevel.h $(PERL_INC)/util.h \ |
2419 | $(PERL_INC)/embed.h $(PERL_INC)/perl.h \ |
2420 | $(PERL_INC)/form.h $(PERL_INC)/perly.h |
2421 | |
2422 | $(OBJECT) : $(PERL_HDRS) |
2423 | } if $self->{OBJECT}; |
2424 | |
2425 | push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}}; |
2426 | |
2427 | join "\n", @m; |
1e44e2bf |
2428 | } |
2429 | |
f1387719 |
2430 | =item pm_to_blib |
1e44e2bf |
2431 | |
f1387719 |
2432 | Defines target that copies all files in the hash PM to their |
2433 | destination and autosplits them. See L<ExtUtils::Install/pm_to_blib> |
1e44e2bf |
2434 | |
2435 | =cut |
2436 | |
f1387719 |
2437 | sub pm_to_blib { |
2438 | my $self = shift; |
2439 | my($autodir) = $self->catdir('$(INST_LIB)','auto'); |
2440 | return q{ |
2441 | pm_to_blib: $(TO_INST_PM) |
2442 | }.$self->{NOECHO}.q{$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \ |
2443 | "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \ |
2444 | -e 'pm_to_blib({qw{$(PM_TO_BLIB)}},"}.$autodir.q{")' |
2445 | }.$self->{NOECHO}.q{$(TOUCH) $@ |
1e44e2bf |
2446 | }; |
1e44e2bf |
2447 | } |
2448 | |
f1387719 |
2449 | =item post_constants (o) |
1e44e2bf |
2450 | |
f1387719 |
2451 | Returns an empty string per default. Dedicated to overrides from |
2452 | within Makefile.PL after all constants have been defined. |
1e44e2bf |
2453 | |
2454 | =cut |
2455 | |
f1387719 |
2456 | sub post_constants{ |
2457 | my($self) = shift; |
2458 | ""; |
2459 | } |
1e44e2bf |
2460 | |
f1387719 |
2461 | =item post_initialize (o) |
1e44e2bf |
2462 | |
f1387719 |
2463 | Returns an ampty string per default. Used in Makefile.PLs to add some |
2464 | chunk of text to the Makefile after the object is initialized. |
1e44e2bf |
2465 | |
f1387719 |
2466 | =cut |
1e44e2bf |
2467 | |
f1387719 |
2468 | sub post_initialize { |
2469 | my($self) = shift; |
2470 | ""; |
2471 | } |
1e44e2bf |
2472 | |
f1387719 |
2473 | =item postamble (o) |
1e44e2bf |
2474 | |
f1387719 |
2475 | Returns an empty string. Can be used in Makefile.PLs to write some |
2476 | text to the Makefile at the end. |
1e44e2bf |
2477 | |
f1387719 |
2478 | =cut |
1e44e2bf |
2479 | |
f1387719 |
2480 | sub postamble { |
2481 | my($self) = shift; |
2482 | ""; |
2483 | } |
1e44e2bf |
2484 | |
f1387719 |
2485 | =item prefixify |
1e44e2bf |
2486 | |
f1387719 |
2487 | Check a path variable in $self from %Config, if it contains a prefix, |
2488 | and replace it with another one. |
1e44e2bf |
2489 | |
f1387719 |
2490 | Takes as arguments an attribute name, a search prefix and a |
2491 | replacement prefix. Changes the attribute in the object. |
1e44e2bf |
2492 | |
f1387719 |
2493 | =cut |
1e44e2bf |
2494 | |
f1387719 |
2495 | sub prefixify { |
2496 | my($self,$var,$sprefix,$rprefix) = @_; |
2497 | $self->{uc $var} ||= $Config{lc $var}; |
2498 | $self->{uc $var} = VMS::Filespec::unixpath($self->{uc $var}) if $Is_VMS; |
2499 | $self->{uc $var} =~ s/\Q$sprefix\E/$rprefix/; |
2500 | } |
1e44e2bf |
2501 | |
f1387719 |
2502 | =item processPL (o) |
1e44e2bf |
2503 | |
f1387719 |
2504 | Defines targets to run *.PL files. |
1e44e2bf |
2505 | |
f1387719 |
2506 | =cut |
1e44e2bf |
2507 | |
f1387719 |
2508 | sub processPL { |
2509 | my($self) = shift; |
2510 | return "" unless $self->{PL_FILES}; |
2511 | my(@m, $plfile); |
2512 | foreach $plfile (sort keys %{$self->{PL_FILES}}) { |
2513 | push @m, " |
2514 | all :: $self->{PL_FILES}->{$plfile} |
1e44e2bf |
2515 | |
f1387719 |
2516 | $self->{PL_FILES}->{$plfile} :: $plfile |
2517 | \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile |
2518 | "; |
2519 | } |
2520 | join "", @m; |
1e44e2bf |
2521 | } |
2522 | |
f1387719 |
2523 | =item realclean (o) |
1e44e2bf |
2524 | |
f1387719 |
2525 | Defines the realclean target. |
1e44e2bf |
2526 | |
2527 | =cut |
2528 | |
f1387719 |
2529 | sub realclean { |
2530 | my($self, %attribs) = @_; |
2531 | my(@m); |
2532 | push(@m,' |
2533 | # Delete temporary files (via clean) and also delete installed files |
2534 | realclean purge :: clean |
2535 | '); |
2536 | # realclean subdirectories first (already cleaned) |
2537 | my $sub = "\t-cd %s && test -f %s && \$(MAKE) %s realclean\n"; |
2538 | foreach(@{$self->{DIR}}){ |
2539 | push(@m, sprintf($sub,$_,"$self->{MAKEFILE}.old","-f $self->{MAKEFILE}.old")); |
2540 | push(@m, sprintf($sub,$_,"$self->{MAKEFILE}",'')); |
1e44e2bf |
2541 | } |
f1387719 |
2542 | push(@m, " $self->{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n"); |
2543 | if( $self->has_link_code ){ |
2544 | push(@m, " $self->{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n"); |
2545 | push(@m, " $self->{RM_F} \$(INST_STATIC)\n"); |
2546 | } |
2547 | push(@m, " $self->{RM_F} " . join(" ", values %{$self->{PM}}) . "\n"); |
2548 | my(@otherfiles) = ($self->{MAKEFILE}, |
2549 | "$self->{MAKEFILE}.old"); # Makefiles last |
2550 | push(@otherfiles, $attribs{FILES}) if $attribs{FILES}; |
2551 | push(@m, " $self->{RM_RF} @otherfiles\n") if @otherfiles; |
2552 | push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP}; |
2553 | join("", @m); |
1e44e2bf |
2554 | } |
2555 | |
f1387719 |
2556 | =item replace_manpage_separator |
1e44e2bf |
2557 | |
f1387719 |
2558 | Takes the name of a package, which may be a nested package, in the |
2559 | form Foo/Bar and replaces the slash with C<::>. Returns the replacement. |
1e44e2bf |
2560 | |
2561 | =cut |
2562 | |
f1387719 |
2563 | sub replace_manpage_separator { |
2564 | my($self,$man) = @_; |
2565 | $man =~ s,/+,::,g; |
2566 | $man; |
2567 | } |
1e44e2bf |
2568 | |
f1387719 |
2569 | =item static (o) |
1e44e2bf |
2570 | |
f1387719 |
2571 | Defines the static target. |
1e44e2bf |
2572 | |
f1387719 |
2573 | =cut |
1e44e2bf |
2574 | |
f1387719 |
2575 | sub static { |
2576 | # --- Static Loading Sections --- |
1e44e2bf |
2577 | |
f1387719 |
2578 | my($self) = shift; |
2579 | ' |
2580 | ## $(INST_PM) has been moved to the all: target. |
2581 | ## It remains here for awhile to allow for old usage: "make static" |
2582 | #static :: '.$self->{MAKEFILE}.' $(INST_STATIC) $(INST_PM) |
2583 | static :: '.$self->{MAKEFILE}.' $(INST_STATIC) |
2584 | '.$self->{NOECHO}.'$(NOOP) |
2585 | '; |
1e44e2bf |
2586 | } |
2587 | |
f1387719 |
2588 | =item static_lib (o) |
1e44e2bf |
2589 | |
f1387719 |
2590 | Defines how to produce the *.a (or equivalent) files. |
1e44e2bf |
2591 | |
2592 | =cut |
2593 | |
f1387719 |
2594 | sub static_lib { |
2595 | my($self) = @_; |
2596 | # Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC |
2597 | # return '' unless $self->needs_linking(); #might be because of a subdir |
1e44e2bf |
2598 | |
f1387719 |
2599 | return '' unless $self->has_link_code; |
2600 | |
2601 | my(@m); |
2602 | push(@m, <<'END'); |
2603 | $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists |
2604 | $(RM_RF) $@ |
2605 | END |
2606 | # If this extension has it's own library (eg SDBM_File) |
2607 | # then copy that to $(INST_STATIC) and add $(OBJECT) into it. |
2608 | push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB}; |
f4ae0f5e |
2609 | |
f1387719 |
2610 | push @m, |
2611 | q{ $(AR) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@ |
2612 | }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld |
2613 | $(CHMOD) 755 $@ |
f4ae0f5e |
2614 | }; |
1e44e2bf |
2615 | |
f1387719 |
2616 | # Old mechanism - still available: |
2617 | |
2618 | push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs}."\n\n" |
2619 | if $self->{PERL_SRC}; |
2620 | |
2621 | push @m, $self->dir_target('$(INST_ARCHAUTODIR)'); |
2622 | join('', "\n",@m); |
1e44e2bf |
2623 | } |
2624 | |
f4ae0f5e |
2625 | =item staticmake (o) |
1e44e2bf |
2626 | |
f4ae0f5e |
2627 | Calls makeaperl. |
1e44e2bf |
2628 | |
2629 | =cut |
2630 | |
2631 | sub staticmake { |
2632 | my($self, %attribs) = @_; |
1e44e2bf |
2633 | my(@static); |
2634 | |
2635 | my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB}); |
2636 | |
2637 | # And as it's not yet built, we add the current extension |
2638 | # but only if it has some C code (or XS code, which implies C code) |
2639 | if (@{$self->{C}}) { |
f4ae0f5e |
2640 | @static = $self->catfile($self->{INST_ARCHLIB}, |
2641 | "auto", |
2642 | $self->{FULLEXT}, |
2643 | "$self->{BASEEXT}$self->{LIB_EXT}" |
2644 | ); |
1e44e2bf |
2645 | } |
2646 | |
2647 | # Either we determine now, which libraries we will produce in the |
2648 | # subdirectories or we do it at runtime of the make. |
2649 | |
2650 | # We could ask all subdir objects, but I cannot imagine, why it |
2651 | # would be necessary. |
2652 | |
2653 | # Instead we determine all libraries for the new perl at |
2654 | # runtime. |
2655 | my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB}); |
2656 | |
2657 | $self->makeaperl(MAKE => $self->{MAKEFILE}, |
2658 | DIRS => \@searchdirs, |
2659 | STAT => \@static, |
2660 | INCL => \@perlinc, |
2661 | TARGET => $self->{MAP_TARGET}, |
2662 | TMP => "", |
2663 | LIBPERL => $self->{LIBPERL_A} |
2664 | ); |
2665 | } |
2666 | |
f1387719 |
2667 | =item subdir_x (o) |
2668 | |
2669 | Helper subroutine for subdirs |
2670 | |
2671 | =cut |
2672 | |
2673 | sub subdir_x { |
2674 | my($self, $subdir) = @_; |
2675 | my(@m); |
2676 | qq{ |
2677 | |
2678 | subdirs :: |
2679 | $self->{NOECHO}cd $subdir && \$(MAKE) all \$(PASTHRU) |
2680 | |
2681 | }; |
2682 | } |
2683 | |
2684 | =item subdirs (o) |
2685 | |
2686 | Defines targets to process subdirectories. |
2687 | |
2688 | =cut |
2689 | |
2690 | sub subdirs { |
2691 | # --- Sub-directory Sections --- |
2692 | my($self) = shift; |
2693 | my(@m,$dir); |
2694 | # This method provides a mechanism to automatically deal with |
2695 | # subdirectories containing further Makefile.PL scripts. |
2696 | # It calls the subdir_x() method for each subdirectory. |
2697 | foreach $dir (@{$self->{DIR}}){ |
2698 | push(@m, $self->subdir_x($dir)); |
2699 | #### print "Including $dir subdirectory\n"; |
2700 | } |
2701 | if (@m){ |
2702 | unshift(@m, " |
2703 | # The default clean, realclean and test targets in this Makefile |
2704 | # have automatically been given entries for each subdir. |
2705 | |
2706 | "); |
2707 | } else { |
2708 | push(@m, "\n# none") |
2709 | } |
2710 | join('',@m); |
2711 | } |
2712 | |
f4ae0f5e |
2713 | =item test (o) |
1e44e2bf |
2714 | |
f4ae0f5e |
2715 | Defines the test targets. |
1e44e2bf |
2716 | |
2717 | =cut |
2718 | |
2719 | sub test { |
2720 | # --- Test and Installation Sections --- |
2721 | |
2722 | my($self, %attribs) = @_; |
1e44e2bf |
2723 | my($tests) = $attribs{TESTS} || (-d "t" ? "t/*.t" : ""); |
2724 | my(@m); |
2725 | push(@m," |
2726 | TEST_VERBOSE=0 |
2727 | TEST_TYPE=test_\$(LINKTYPE) |
f1387719 |
2728 | TEST_FILE = test.pl |
2729 | TESTDB_SW = -d |
1e44e2bf |
2730 | |
f4ae0f5e |
2731 | testdb :: testdb_\$(LINKTYPE) |
f1387719 |
2732 | |
2733 | test :: \$(TEST_TYPE) |
1e44e2bf |
2734 | "); |
2735 | push(@m, map("\t$self->{NOECHO}cd $_ && test -f $self->{MAKEFILE} && \$(MAKE) test \$(PASTHRU)\n", |
2736 | @{$self->{DIR}})); |
2737 | push(@m, "\t$self->{NOECHO}echo 'No tests defined for \$(NAME) extension.'\n") |
2738 | unless $tests or -f "test.pl" or @{$self->{DIR}}; |
2739 | push(@m, "\n"); |
2740 | |
f4ae0f5e |
2741 | push(@m, "test_dynamic :: pure_all\n"); |
1e44e2bf |
2742 | push(@m, $self->test_via_harness('$(FULLPERL)', $tests)) if $tests; |
2743 | push(@m, $self->test_via_script('$(FULLPERL)', 'test.pl')) if -f "test.pl"; |
2744 | push(@m, "\n"); |
2745 | |
f1387719 |
2746 | push(@m, "testdb_dynamic :: pure_all\n"); |
2747 | push(@m, $self->test_via_script('$(FULLPERL) $(TESTDB_SW)', '$(TEST_FILE)')); |
2748 | push(@m, "\n"); |
f4ae0f5e |
2749 | |
1e44e2bf |
2750 | # Occasionally we may face this degenerate target: |
2751 | push @m, "test_ : test_dynamic\n\n"; |
2752 | |
2753 | if ($self->needs_linking()) { |
f4ae0f5e |
2754 | push(@m, "test_static :: pure_all \$(MAP_TARGET)\n"); |
1e44e2bf |
2755 | push(@m, $self->test_via_harness('./$(MAP_TARGET)', $tests)) if $tests; |
2756 | push(@m, $self->test_via_script('./$(MAP_TARGET)', 'test.pl')) if -f "test.pl"; |
2757 | push(@m, "\n"); |
f1387719 |
2758 | push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n"); |
2759 | push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)')); |
2760 | push(@m, "\n"); |
1e44e2bf |
2761 | } else { |
2762 | push @m, "test_static :: test_dynamic\n"; |
f4ae0f5e |
2763 | push @m, "testdb_static :: testdb_dynamic\n"; |
1e44e2bf |
2764 | } |
2765 | join("", @m); |
2766 | } |
2767 | |
f4ae0f5e |
2768 | =item test_via_harness (o) |
1e44e2bf |
2769 | |
f4ae0f5e |
2770 | Helper method to write the test targets |
1e44e2bf |
2771 | |
2772 | =cut |
2773 | |
2774 | sub test_via_harness { |
2775 | my($self, $perl, $tests) = @_; |
1e44e2bf |
2776 | "\tPERL_DL_NONLAZY=1 $perl".q! -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' !."$tests\n"; |
2777 | } |
2778 | |
f4ae0f5e |
2779 | =item test_via_script (o) |
1e44e2bf |
2780 | |
f4ae0f5e |
2781 | Other helper method for test. |
1e44e2bf |
2782 | |
2783 | =cut |
2784 | |
2785 | sub test_via_script { |
2786 | my($self, $perl, $script) = @_; |
1e44e2bf |
2787 | qq{\tPERL_DL_NONLAZY=1 $perl}.q{ -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) }.qq{$script |
2788 | }; |
2789 | } |
2790 | |
f1387719 |
2791 | =item tool_autosplit (o) |
1e44e2bf |
2792 | |
f1387719 |
2793 | Defines a simple perl call that runs autosplit. May be deprecated by |
2794 | pm_to_blib soon. |
1e44e2bf |
2795 | |
2796 | =cut |
2797 | |
f1387719 |
2798 | sub tool_autosplit { |
2799 | # --- Tool Sections --- |
2800 | |
2801 | my($self, %attribs) = @_; |
2802 | my($asl) = ""; |
2803 | $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN}; |
2804 | q{ |
2805 | # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto |
2806 | AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;}.$asl.q{autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;' |
2807 | }; |
1e44e2bf |
2808 | } |
2809 | |
f1387719 |
2810 | =item tools_other (o) |
1e44e2bf |
2811 | |
f1387719 |
2812 | Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in |
2813 | the Makefile. Also defines the perl programs MKPATH, |
2814 | WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL. |
1e44e2bf |
2815 | |
2816 | =cut |
2817 | |
f1387719 |
2818 | sub tools_other { |
2819 | my($self) = shift; |
2820 | my @m; |
2821 | my $bin_sh = $Config{sh} || '/bin/sh'; |
2822 | push @m, qq{ |
2823 | SHELL = $bin_sh |
2824 | }; |
2825 | |
2826 | for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TOUCH UMASK_NULL / ) { |
2827 | push @m, "$_ = $self->{$_}\n"; |
1e44e2bf |
2828 | } |
1e44e2bf |
2829 | |
1e44e2bf |
2830 | |
f1387719 |
2831 | push @m, q{ |
2832 | # The following is a portable way to say mkdir -p |
2833 | # To see which directories are created, change the if 0 to if 1 |
2834 | MKPATH = $(PERL) -wle '$$"="/"; foreach $$p (@ARGV){' \\ |
2835 | -e 'next if -d $$p; my(@p); foreach(split(/\//,$$p)){' \\ |
2836 | -e 'push(@p,$$_); next if -d "@p/"; print "mkdir @p" if 0;' \\ |
2837 | -e 'mkdir("@p",0777)||die $$! } } exit 0;' |
1e44e2bf |
2838 | |
f1387719 |
2839 | # This helps us to minimize the effect of the .exists files A yet |
2840 | # better solution would be to have a stable file in the perl |
2841 | # distribution with a timestamp of zero. But this solution doesn't |
2842 | # need any changes to the core distribution and works with older perls |
2843 | EQUALIZE_TIMESTAMP = $(PERL) -we 'open F, ">$$ARGV[1]"; close F;' \\ |
2844 | -e 'utime ((stat("$$ARGV[0]"))[8,9], $$ARGV[1])' |
2845 | }; |
1e44e2bf |
2846 | |
f1387719 |
2847 | return join "", @m if $self->{PARENT}; |
1e44e2bf |
2848 | |
f1387719 |
2849 | push @m, q{ |
2850 | # Here we warn users that an old packlist file was found somewhere, |
2851 | # and that they should call some uninstall routine |
2852 | WARN_IF_OLD_PACKLIST = $(PERL) -we 'exit unless -f $$ARGV[0];' \\ |
2853 | -e 'print "WARNING: I have found an old package in\n";' \\ |
2854 | -e 'print "\t$$ARGV[0].\n";' \\ |
2855 | -e 'print "Please make sure the two installations are not conflicting\n";' |
1e44e2bf |
2856 | |
f1387719 |
2857 | UNINST=0 |
2858 | VERBINST=1 |
1e44e2bf |
2859 | |
f1387719 |
2860 | MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \ |
2861 | -e 'install({@ARGV},"$(VERBINST)",0,"$(UNINST)");' |
1e44e2bf |
2862 | |
f1387719 |
2863 | DOC_INSTALL = $(PERL) -e '$$\="\n\n";print "=head3 ", scalar(localtime), ": C<", shift, ">";' \ |
2864 | -e 'print "=over 4";' \ |
2865 | -e 'while (defined($$key = shift) and defined($$val = shift)){print "=item *";print "C<$$key: $$val>";}' \ |
2866 | -e 'print "=back";' |
1e44e2bf |
2867 | |
f1387719 |
2868 | UNINSTALL = $(PERL) -MExtUtils::Install \ |
2869 | -e 'uninstall($$ARGV[0],1);' |
1e44e2bf |
2870 | |
f1387719 |
2871 | }; |
1e44e2bf |
2872 | |
f1387719 |
2873 | return join "", @m; |
2874 | } |
1e44e2bf |
2875 | |
f1387719 |
2876 | =item tool_xsubpp (o) |
1e44e2bf |
2877 | |
f1387719 |
2878 | Determines typemaps, xsubpp version, prototype behaviour. |
1e44e2bf |
2879 | |
f1387719 |
2880 | =cut |
1e44e2bf |
2881 | |
f1387719 |
2882 | sub tool_xsubpp { |
2883 | my($self) = shift; |
2884 | return "" unless $self->needs_linking; |
2885 | my($xsdir) = $self->catdir($self->{PERL_LIB},"ExtUtils"); |
2886 | my(@tmdeps) = $self->catdir('$(XSUBPPDIR)','typemap'); |
2887 | if( $self->{TYPEMAPS} ){ |
2888 | my $typemap; |
2889 | foreach $typemap (@{$self->{TYPEMAPS}}){ |
2890 | if( ! -f $typemap ){ |
2891 | warn "Typemap $typemap not found.\n"; |
2892 | } |
2893 | else{ |
2894 | push(@tmdeps, $typemap); |
2895 | } |
2896 | } |
2897 | } |
2898 | push(@tmdeps, "typemap") if -f "typemap"; |
2899 | my(@tmargs) = map("-typemap $_", @tmdeps); |
2900 | if( exists $self->{XSOPT} ){ |
2901 | unshift( @tmargs, $self->{XSOPT} ); |
1e44e2bf |
2902 | } |
2903 | |
1e44e2bf |
2904 | |
f1387719 |
2905 | my $xsubpp_version = $self->xsubpp_version($self->catfile($xsdir,"xsubpp")); |
1e44e2bf |
2906 | |
f1387719 |
2907 | # What are the correct thresholds for version 1 && 2 Paul? |
2908 | if ( $xsubpp_version > 1.923 ){ |
2909 | $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG}; |
2910 | } else { |
2911 | if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) { |
2912 | print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp. |
2913 | Your version of xsubpp is $xsubpp_version and cannot handle this. |
2914 | Please upgrade to a more recent version of xsubpp. |
2915 | }; |
2916 | } else { |
2917 | $self->{XSPROTOARG} = ""; |
2918 | } |
1e44e2bf |
2919 | } |
2920 | |
f1387719 |
2921 | return qq{ |
2922 | XSUBPPDIR = $xsdir |
2923 | XSUBPP = \$(XSUBPPDIR)/xsubpp |
2924 | XSPROTOARG = $self->{XSPROTOARG} |
2925 | XSUBPPDEPS = @tmdeps |
2926 | XSUBPPARGS = @tmargs |
2927 | }; |
2928 | }; |
1e44e2bf |
2929 | |
f1387719 |
2930 | sub xsubpp_version |
2931 | { |
2932 | my($self,$xsubpp) = @_; |
2933 | return $Xsubpp_Version if defined $Xsubpp_Version; # global variable |
1e44e2bf |
2934 | |
f1387719 |
2935 | my ($version) ; |
1e44e2bf |
2936 | |
f1387719 |
2937 | # try to figure out the version number of the xsubpp on the system |
1e44e2bf |
2938 | |
f1387719 |
2939 | # first try the -v flag, introduced in 1.921 & 2.000a2 |
1e44e2bf |
2940 | |
f1387719 |
2941 | return "" unless $self->needs_linking; |
1e44e2bf |
2942 | |
f1387719 |
2943 | my $command = "$self->{PERL} -I$self->{PERL_LIB} $xsubpp -v 2>&1"; |
2944 | print "Running $command\n" if $Verbose >= 2; |
2945 | $version = `$command` ; |
2946 | warn "Running '$command' exits with status " . ($?>>8) if $?; |
2947 | chop $version ; |
1e44e2bf |
2948 | |
f1387719 |
2949 | return $Xsubpp_Version = $1 if $version =~ /^xsubpp version (.*)/ ; |
1e44e2bf |
2950 | |
f1387719 |
2951 | # nope, then try something else |
1e44e2bf |
2952 | |
f1387719 |
2953 | my $counter = '000'; |
2954 | my ($file) = 'temp' ; |
2955 | $counter++ while -e "$file$counter"; # don't overwrite anything |
2956 | $file .= $counter; |
1e44e2bf |
2957 | |
f1387719 |
2958 | open(F, ">$file") or die "Cannot open file '$file': $!\n" ; |
2959 | print F <<EOM ; |
2960 | MODULE = fred PACKAGE = fred |
1e44e2bf |
2961 | |
f1387719 |
2962 | int |
2963 | fred(a) |
2964 | int a; |
2965 | EOM |
1e44e2bf |
2966 | |
f1387719 |
2967 | close F ; |
1e44e2bf |
2968 | |
f1387719 |
2969 | $command = "$self->{PERL} $xsubpp $file 2>&1"; |
2970 | print "Running $command\n" if $Verbose >= 2; |
2971 | my $text = `$command` ; |
2972 | warn "Running '$command' exits with status " . ($?>>8) if $?; |
2973 | unlink $file ; |
2974 | |
2975 | # gets 1.2 -> 1.92 and 2.000a1 |
2976 | return $Xsubpp_Version = $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/ ; |
2977 | |
2978 | # it is either 1.0 or 1.1 |
2979 | return $Xsubpp_Version = 1.1 if $text =~ /^Warning: ignored semicolon/ ; |
2980 | |
2981 | # none of the above, so 1.0 |
2982 | return $Xsubpp_Version = "1.0" ; |
1e44e2bf |
2983 | } |
2984 | |
f1387719 |
2985 | =item top_targets (o) |
1e44e2bf |
2986 | |
f1387719 |
2987 | Defines the targets all, subdirs, config, and O_FILES |
1e44e2bf |
2988 | |
2989 | =cut |
2990 | |
f1387719 |
2991 | sub top_targets { |
2992 | # --- Target Sections --- |
1e44e2bf |
2993 | |
f1387719 |
2994 | my($self) = shift; |
2995 | my(@m); |
2996 | push @m, ' |
2997 | #all :: config $(INST_PM) subdirs linkext manifypods |
1e44e2bf |
2998 | |
f1387719 |
2999 | all :: pure_all manifypods |
3000 | '.$self->{NOECHO}.'$(NOOP) |
1e44e2bf |
3001 | |
f1387719 |
3002 | pure_all :: config pm_to_blib subdirs linkext |
3003 | '.$self->{NOECHO}.'$(NOOP) |
1e44e2bf |
3004 | |
f1387719 |
3005 | subdirs :: $(MYEXTLIB) |
3006 | '.$self->{NOECHO}.'$(NOOP) |
1e44e2bf |
3007 | |
f1387719 |
3008 | config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)/.exists |
3009 | '.$self->{NOECHO}.'$(NOOP) |
3010 | |
3011 | config :: $(INST_ARCHAUTODIR)/.exists |
3012 | '.$self->{NOECHO}.'$(NOOP) |
3013 | |
3014 | config :: $(INST_AUTODIR)/.exists |
3015 | '.$self->{NOECHO}.'$(NOOP) |
3016 | '; |
3017 | |
3018 | push @m, qq{ |
3019 | config :: Version_check |
3020 | $self->{NOECHO}\$(NOOP) |
3021 | |
3022 | } unless $self->{PARENT} or ($self->{PERL_SRC} && $self->{INSTALLDIRS} eq "perl") or $self->{NO_VC}; |
3023 | |
3024 | push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]); |
3025 | |
3026 | if (%{$self->{MAN1PODS}}) { |
3027 | push @m, qq[ |
3028 | config :: \$(INST_MAN1DIR)/.exists |
3029 | $self->{NOECHO}\$(NOOP) |
3030 | |
3031 | ]; |
3032 | push @m, $self->dir_target(qw[$(INST_MAN1DIR)]); |
1e44e2bf |
3033 | } |
f1387719 |
3034 | if (%{$self->{MAN3PODS}}) { |
3035 | push @m, qq[ |
3036 | config :: \$(INST_MAN3DIR)/.exists |
3037 | $self->{NOECHO}\$(NOOP) |
3038 | |
3039 | ]; |
3040 | push @m, $self->dir_target(qw[$(INST_MAN3DIR)]); |
1e44e2bf |
3041 | } |
1e44e2bf |
3042 | |
f1387719 |
3043 | push @m, ' |
3044 | $(O_FILES): $(H_FILES) |
3045 | ' if @{$self->{O_FILES} || []} && @{$self->{H} || []}; |
1e44e2bf |
3046 | |
f1387719 |
3047 | push @m, q{ |
3048 | help: |
3049 | perldoc ExtUtils::MakeMaker |
3050 | }; |
1e44e2bf |
3051 | |
f1387719 |
3052 | push @m, q{ |
3053 | Version_check: |
3054 | }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \ |
3055 | -MExtUtils::MakeMaker=Version_check \ |
3056 | -e 'Version_check("$(MM_VERSION)")' |
3057 | }; |
1e44e2bf |
3058 | |
f1387719 |
3059 | join('',@m); |
1e44e2bf |
3060 | } |
3061 | |
3062 | =item writedoc |
3063 | |
f4ae0f5e |
3064 | Obsolete, depecated method. Not used since Version 5.21. |
1e44e2bf |
3065 | |
3066 | =cut |
3067 | |
3068 | sub writedoc { |
3069 | # --- perllocal.pod section --- |
3070 | my($self,$what,$name,@attribs)=@_; |
1e44e2bf |
3071 | my $time = localtime; |
3072 | print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n"; |
3073 | print join "\n\n=item *\n\n", map("C<$_>",@attribs); |
3074 | print "\n\n=back\n\n"; |
3075 | } |
3076 | |
f1387719 |
3077 | =item xs_c (o) |
3078 | |
3079 | Defines the suffix rules to compile XS files to C. |
3080 | |
3081 | =cut |
3082 | |
3083 | sub xs_c { |
3084 | my($self) = shift; |
3085 | return '' unless $self->needs_linking(); |
3086 | ' |
3087 | .xs.c: |
3088 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >$*.tc && mv $*.tc $@ |
3089 | '; |
3090 | } |
3091 | |
3092 | =item xs_o (o) |
3093 | |
3094 | Defines suffix rules to go from XS to object files directly. This is |
3095 | only intended for broken make implementations. |
3096 | |
3097 | =cut |
3098 | |
3099 | sub xs_o { # many makes are too dumb to use xs_c then c_o |
3100 | my($self) = shift; |
3101 | return '' unless $self->needs_linking(); |
3102 | ' |
3103 | .xs$(OBJ_EXT): |
3104 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >xstmp.c && mv xstmp.c $*.c |
3105 | $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c |
3106 | '; |
3107 | } |
3108 | |
f4ae0f5e |
3109 | 1; |
3110 | |
3111 | |
1e44e2bf |
3112 | =head1 SEE ALSO |
3113 | |
3114 | L<ExtUtils::MakeMaker> |
3115 | |
3116 | =cut |
3117 | |
f4ae0f5e |
3118 | __END__ |