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