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